diff options
Diffstat (limited to 'src/libmplex_wrapper.cc')
-rw-r--r-- | src/libmplex_wrapper.cc | 71 |
1 files changed, 32 insertions, 39 deletions
diff --git a/src/libmplex_wrapper.cc b/src/libmplex_wrapper.cc index 4164ffe..542d900 100644 --- a/src/libmplex_wrapper.cc +++ b/src/libmplex_wrapper.cc @@ -39,13 +39,15 @@ #include <mplex/outputstrm.hpp> #include <mplex/multiplexor.hpp> +#include <hugin.hpp> + /** * FrameOutputStream - Wraps the File object */ class FrameOutputStream : public OutputStream { public: - FrameOutputStream( Info *info, File *outputfile ); + FrameOutputStream(File *outputfile ); int Open( ); void Close(); off_t SegmentSize( ); @@ -53,38 +55,36 @@ public: void Write(uint8_t *data, unsigned int len); private: - Info *info; off_t written; File *file; }; -FrameOutputStream::FrameOutputStream( Info *info, File *outputfile ) +FrameOutputStream::FrameOutputStream(File *outputfile ) { - this->info = info; file = outputfile; written = 0; - info->info("FrameOutputStream - constructor"); + DEBUG(frame, "FrameOutputStream - constructor"); } int FrameOutputStream::Open() { - // info->info("FrameOutputStream::Open"); + // DEBUG(frame, "FrameOutputStream::Open"); // Nothing to do here! return 0; } void FrameOutputStream::Close() { - // info->info("FrameOutputStream::Close"); + // DEBUG(frame, "FrameOutputStream::Close"); // Nothing to do here! } off_t FrameOutputStream::SegmentSize() { - // info->info("FrameOutputStream::SegmentSize - return: %d", written); + // DEBUG(frame, "FrameOutputStream::SegmentSize - return: %d", written); return written; /* @@ -97,7 +97,7 @@ off_t FrameOutputStream::SegmentSize() void FrameOutputStream::NextSegment( ) { - // info->info("FrameOutputStream::NextSegment"); + // DEBUG(frame, "FrameOutputStream::NextSegment"); // Nothing to do here! /* auto_ptr<char> prev_filename_buf( new char[strlen(cur_filename)+1] ); @@ -122,7 +122,7 @@ void FrameOutputStream::Write( uint8_t *buf, unsigned int len ) unsigned int write; write = file->Write(buf, len); written += write; - // info->info("FrameOutputStream::Write - len: %d", len); + // DEBUG(frame, "FrameOutputStream::Write - len: %d", len); } /** @@ -132,7 +132,7 @@ void FrameOutputStream::Write( uint8_t *buf, unsigned int len ) class FrameInputStream : public IBitStream { public: - FrameInputStream( Info *info, ThreadSafeQueuePriority *queue ); + FrameInputStream(ThreadSafeQueuePriority *queue ); ~FrameInputStream(); private: @@ -140,24 +140,22 @@ private: size_t ReadStreamBytes( uint8_t *buf, size_t size ); bool EndOfStream(); - Info *info; ThreadSafeQueuePriority *queue; bool seen_eof; Frame *frame; unsigned int read; }; -FrameInputStream::FrameInputStream( Info *info, ThreadSafeQueuePriority *queue ) : +FrameInputStream::FrameInputStream(ThreadSafeQueuePriority *queue ) : IBitStream() { - this->info = info; this->queue = queue; seen_eof = false; frame = NULL; read = 0; streamname = "MIaV Stream\0"; - // info->info("FrameInputStream - constructor", seen_eof); + // DEBUG(frame, "FrameInputStream - constructor", seen_eof); /* if ((fileh = fopen(bs_filename, "rb")) == NULL) @@ -184,11 +182,11 @@ FrameInputStream::FrameInputStream( Info *info, ThreadSafeQueuePriority *queue ) byteidx = 0; if (!ReadIntoBuffer()) { if (buffered==0) { - info->error( "Unable to read from %s.", streamname); + ERR(frame, "Unable to read from %s.", streamname); } } - // info->info("FrameInputStream - leaving constructor", seen_eof); + // DEBUG(frame, "FrameInputStream - leaving constructor", seen_eof); } @@ -198,7 +196,7 @@ FrameInputStream::FrameInputStream( Info *info, ThreadSafeQueuePriority *queue ) */ FrameInputStream::~FrameInputStream() { - // info->info("FrameInputStream - destructor", seen_eof); + // DEBUG(frame, "FrameInputStream - destructor", seen_eof); // Nothing to do here! /* if (fileh) @@ -219,13 +217,13 @@ Frame *FrameInputStream::getFrame() bool FrameInputStream::EndOfStream() { - // info->info("FrameInputStream::EndOfStream - return: %d", seen_eof); + // DEBUG(frame, "FrameInputStream::EndOfStream - return: %d", seen_eof); return seen_eof; } size_t FrameInputStream::ReadStreamBytes( uint8_t *buf, size_t size ) { - // info->info("FrameInputStream::ReadStreamBytes - size: %d", size); + // DEBUG(frame, "FrameInputStream::ReadStreamBytes - size: %d", size); unsigned int copied = 0; while( copied < size ) { @@ -251,7 +249,7 @@ size_t FrameInputStream::ReadStreamBytes( uint8_t *buf, size_t size ) unsigned int doread = (size - copied) < (frame->size - read) ? size - copied : (frame->size - read); - //info->info("Requested: %d. Read: %d. Doread: %d. In buffer %d", size, (*read), doread, (*frame)->size); + // DEBUG(frame, "Requested: %d. Read: %d. Doread: %d. In buffer %d", size, (*read), doread, (*frame)->size); memcpy(buf + copied, frame->data + read, doread); read += doread; @@ -272,8 +270,7 @@ size_t FrameInputStream::ReadStreamBytes( uint8_t *buf, size_t size ) class MIaVMultiplexJob : public MultiplexJob { public: - MIaVMultiplexJob(Info *info, - ThreadSafeQueuePriority *video_queue, + MIaVMultiplexJob(ThreadSafeQueuePriority *video_queue, ThreadSafeQueuePriority *audio_queue); private: @@ -281,13 +278,11 @@ private: bool ParseLpcmOpt( const char *optarg ); }; -MIaVMultiplexJob::MIaVMultiplexJob(Info *info, - ThreadSafeQueuePriority *video_queue, +MIaVMultiplexJob::MIaVMultiplexJob(ThreadSafeQueuePriority *video_queue, ThreadSafeQueuePriority *audio_queue) : MultiplexJob() { - // this->info = info; - // info->info("MIaVMultiplexJob - constructor"); + // DEBUG(job, "MIaVMultiplexJob - constructor"); outfile_pattern = "/tmp/aaargh.mpg"; // Output file... or something verbose = 0; // Level of verbosity. 0 = quiet, 1 = normal 2 = verbose/debug @@ -298,10 +293,10 @@ MIaVMultiplexJob::MIaVMultiplexJob(Info *info, // Specifies decoder buffers size in kB. [ 20...2000] if( ! ParseVideoOpt( "500" ) ) - info->error( "Illegal video decoder buffer size(s): %s", "500" ); + ERR(job, "Illegal video decoder buffer size(s): %s", "500" ); // --lpcm-params | -L samppersec:chan:bits [, samppersec:chan:bits] - // if( ! ParseLpcmOpt( "48000:2:16" ) ) info->error( "Illegal LPCM option(s): %s", "48000:2:16" ); + // if( ! ParseLpcmOpt( "48000:2:16" ) ) ERR(job, "Illegal LPCM option(s): %s", "48000:2:16" ); data_rate = 0; //Specify data rate of output stream in kbit/sec (default 0=Compute from source streams) // Convert from kbit/sec (user spec) to 50B/sec units... @@ -334,12 +329,12 @@ MIaVMultiplexJob::MIaVMultiplexJob(Info *info, // is encountered ithe input video (void)mjpeg_default_handler_verbosity(verbose); - info->info( "mplex version %s (%s %s)", VERSION,MPLEX_VER, MPLEX_DATE ); + INFO(mplex, "mplex version %s (%s %s)", VERSION,MPLEX_VER, MPLEX_DATE ); // Connect streams vector<IBitStream *> inputs; - if(video_queue) inputs.push_back( new FrameInputStream( info, video_queue ) ); - if(audio_queue) inputs.push_back( new FrameInputStream( info, audio_queue ) ); + if(video_queue) inputs.push_back(new FrameInputStream(video_queue)); + if(audio_queue) inputs.push_back(new FrameInputStream(audio_queue)); SetupInputStreams( inputs ); } @@ -445,12 +440,10 @@ bool MIaVMultiplexJob::ParseVideoOpt( const char *optarg ) return true; } -LibMPlexWrapper::LibMPlexWrapper(Info *info, - File *outputfile, +LibMPlexWrapper::LibMPlexWrapper(File *outputfile, ThreadSafeQueuePriority *video_queue, ThreadSafeQueuePriority *audio_queue) { - this->info = info; this->outputfile = outputfile; this->video_queue = video_queue; this->audio_queue = audio_queue; @@ -463,11 +456,11 @@ LibMPlexWrapper::~LibMPlexWrapper() void LibMPlexWrapper::multiplex() { - // info->info("MPLEX!"); + // DEBUG(mplex, "MPLEX!"); // sleep(10); - // info->info("The road goes ever on and on..."); - MIaVMultiplexJob job(info, video_queue, audio_queue); - FrameOutputStream output( info, outputfile ); + // DEBUG(mplex, "The road goes ever on and on..."); + MIaVMultiplexJob job(video_queue, audio_queue); + FrameOutputStream output(outputfile); Multiplexor mux(job, output); mux.Multiplex(); } |