gotCTRL = false;
repeatPhaseB = false;
silenceHeard = false;
+ imagefd = 0;
}
Class1Modem::~Class1Modem()
u_long ecmStuffedBlockPos; // fill pointer for ecmStuffedBlockPos
u_int frameNumber; // frame sequence number of ecmFrame in ecmBlock
u_short blockNumber; // block sequence number of ecmBlock in page
+ int imagefd; // file descriptor for raw image
static const u_int modemPFMCodes[8];// map T.30 FCF to Class 2 PFM
static const u_int modemPPMCodes[8];// map T.30 FCF to Class 2 PPM
bool
Class1Modem::sendPageData(u_char* data, u_int cc, const u_char* bitrev, bool ecm, Status& eresult)
{
+ if (imagefd > 0) Sys::write(imagefd, (const char*) data, cc);
beginTimedTransfer();
bool rc;
if (ecm)
if (params.df <= DF_2DMMR && fillorder != FILLORDER_LSB2MSB) {
TIFFReverseBits(dp, totdata);
}
+
+ /* For debugging purposes we may want to write the image-data to file. */
+ if (conf.saverawimage) imagefd = Sys::open("/tmp/out.fax", O_RDWR|O_CREAT|O_EXCL);
+
u_int minLen = params.minScanlineSize();
if (minLen > 0) { // only in non-ECM
/*
/*
* Flush anything that was not sent above.
*/
- if (fp > fill && rc)
+ if (fp > fill && rc) {
rc = sendPageData(fill, fp-fill, bitrev, (params.ec != EC_DISABLE), eresult);
+ }
delete fill;
} else {
/*
rc = sendPageData(dp, (u_int) totdata, bitrev, (params.ec != EC_DISABLE), eresult);
}
delete data;
+ if (imagefd > 0) {
+ Sys::close(imagefd);
+ imagefd = 0;
+ }
}
if (rc || abortRequested())
rc = sendRTC(params, ppmcmd, rowsperstrip, eresult);
serviceType = 0; // must be set in derived class
useExtendedDF = false; // T.32 Amendment 1 extension for data format is detectable
useJP = false; // JP +FCC option support is detectable
+ imagefd = 0;
}
Class2Modem::~Class2Modem()
char hangupCode[5]; // hangup reason (from modem)
bool hadHangup; // true if +FHNG:/+FHS: received
fxStr lid; // prepared local identifier string
+ int imagefd; // file descriptor for raw image data
// modem setup stuff
virtual bool setupModem(bool isSend = true);
* OF THIS SOFTWARE.
*/
#include <stdio.h>
+#include "Sys.h"
#include "Class2.h"
#include "ModemConfig.h"
#include "FaxRequest.h"
{
bool rc = true;
+ /* For debugging purposes we may want to write the image-data to file. */
+ if (conf.saverawimage) imagefd = Sys::open("/tmp/out.fax", O_RDWR|O_CREAT|O_EXCL);
+
tstrip_t nstrips = TIFFNumberOfStrips(tif);
if (nstrips > 0) {
TIFFReverseBits(dp, totdata);
}
+ if (imagefd > 0) Sys::write(imagefd, (const char*) dp, (u_int) totdata);
beginTimedTransfer();
rc = putModemDLEData(dp, (u_int) totdata, bitrev, getDataTimeout(), conf.doPhaseCDebug);
endTimedTransfer();
protoTrace("SENT %u bytes of data", totdata);
}
+ if (imagefd > 0) {
+ Sys::close(imagefd);
+ imagefd = 0;
+ }
return (rc);
}
FaxModem::recvPageDLEData(TIFF* tif, bool checkQuality,
const Class2Params& params, Status& eresult)
{
+ /* For debugging purposes we may want to write the image-data to file. */
+ if (conf.saverawimage) imagefd = Sys::open("/tmp/in.fax", O_RDWR|O_CREAT|O_EXCL);
+
initializeDecoder(params);
u_int rowpixels = params.pageWidth(); // NB: assume rowpixels <= 4864
/*
if (params.df == DF_JBIG) clearSDNORMCount();
else fixupJPEG(tif);
}
+ if (imagefd > 0) Sys::close(imagefd);
recvEndPage(tif, params);
return (true);
}
recvEOLCount = getRTCRow();
}
}
+ if (imagefd > 0) Sys::close(imagefd);
recvEndPage(tif, params);
return (true);
}
void
FaxModem::flushEncodedData(TIFF* tif, tstrip_t strip, const u_char* buf, u_int cc)
{
+ if (imagefd > 0) Sys::write(imagefd, (const char*) buf, cc);
// NB: must update ImageLength for each new strip
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, recvEOLCount);
if (TIFFWriteEncodedStrip(tif, strip, (tdata_t)buf, cc) == -1)
void
FaxModem::flushRawData(TIFF* tif, tstrip_t strip, const u_char* buf, u_int cc)
{
+ if (imagefd > 0) Sys::write(imagefd, (const char*) buf, cc);
recvTrace("%u bytes of data, %lu total lines", cc, recvEOLCount);
if (TIFFWriteRawStrip(tif, strip, (tdata_t)buf, cc) == -1)
serverTrace("RECV: %s: write error", TIFFFileName(tif));
minsp = BR_2400;
curreq = NULL;
group3opts = 0;
+ imagefd = 0;
// fill order settings may be overwritten in derived class
recvFillOrder = (conf.recvFillOrder != 0)? conf.recvFillOrder : FILLORDER_LSB2MSB;
sendFillOrder = (conf.sendFillOrder != 0)? conf.sendFillOrder : FILLORDER_LSB2MSB;
pid_t decoderPid; // process id for the decoding process
u_char parserBuf[16]; // buffer used for parsing JBIG and JPEG
u_long parserCount[3]; // counters used in parsing JBIG and JPEG
+ int imagefd; // file descriptor for image file
void flushEncodedData(TIFF*, tstrip_t, const u_char*, u_int);
void flushRawData(TIFF*, tstrip_t, const u_char*, u_int);
softRTFCC = true; // real-time fax comp. conv. (software)
doPhaseCDebug = false; // query modem for responses in Phase C transmit
noAnswerVoice = false; // answer voice calls
+ saverawimage = false; // don't save raw image data by default
idConfig.resize(0);
callidIndex = (u_int) -1;
class2RTFCC = getBoolean(value);
else if (streq(tag, "noanswervoice"))
noAnswerVoice = getBoolean(value);
+ else if (streq(tag, "saverawimage"))
+ saverawimage = getBoolean(value);
else if (streq(tag, "modemsoftrtfcc"))
softRTFCC = getBoolean(value);
else if (streq(tag, "modemdophasecdebug"))
fxStr dringOn; // pattern for distinctive ring silence interval
fxStr dringOff; // pattern for distinctive ring ring interval
bool noAnswerVoice; // leave voice calls unanswered
+ bool saverawimage; // debugging feature to save raw image data
// call identification
IDConfArray idConfig; // pattern for ID info
// protocol timers