MPEG1or2VideoStreamDiscreteFramer Class Reference

#include <MPEG1or2VideoStreamDiscreteFramer.hh>

Inheritance diagram for MPEG1or2VideoStreamDiscreteFramer:

Inheritance graph
[legend]
Collaboration diagram for MPEG1or2VideoStreamDiscreteFramer:

Collaboration graph
[legend]

Public Types

typedef void( afterGettingFunc )(void *clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)
typedef void( onCloseFunc )(void *clientData)

Public Member Functions

BooleanpictureEndMarker ()
void flushInput ()
FramedSourceinputSource () const
void getNextFrame (unsigned char *to, unsigned maxSize, afterGettingFunc *afterGettingFunc, void *afterGettingClientData, onCloseFunc *onCloseFunc, void *onCloseClientData)
void stopGettingFrames ()
virtual unsigned maxFrameSize () const
Boolean isCurrentlyAwaitingData () const
virtual Boolean isRTPSource () const
virtual Boolean isMPEG4VideoStreamFramer () const
virtual Boolean isH264VideoStreamFramer () const
virtual Boolean isJPEGVideoSource () const
virtual Boolean isAMRAudioSource () const
UsageEnvironmentenvir () const
char const * name () const
virtual Boolean isSink () const
virtual Boolean isRTCPInstance () const
virtual Boolean isRTSPClient () const
virtual Boolean isRTSPServer () const
virtual Boolean isMediaSession () const
virtual Boolean isServerMediaSession () const
virtual Boolean isDarwinInjector () const

Static Public Member Functions

static MPEG1or2VideoStreamDiscreteFramercreateNew (UsageEnvironment &env, FramedSource *inputSource, Boolean iFramesOnly=False, double vshPeriod=5.0)
static Boolean lookupByName (UsageEnvironment &env, char const *sourceName, FramedSource *&resultSource)
static Boolean lookupByName (UsageEnvironment &env, char const *sourceName, MediaSource *&resultSource)
static Boolean lookupByName (UsageEnvironment &env, char const *mediumName, Medium *&resultMedium)
static void handleClosure (void *clientData)
static void close (UsageEnvironment &env, char const *mediumName)
static void close (Medium *medium)

Protected Member Functions

void computePresentationTime (unsigned numAdditionalPictures)
void setTimeCode (unsigned hours, unsigned minutes, unsigned seconds, unsigned pictures, unsigned picturesSinceLastGOP)
virtual char const * MIMEtype () const
virtual void getAttributes () const
virtual void doStopGettingFrames ()
TaskTokennextTask ()

Static Protected Member Functions

static void afterGetting (FramedSource *source)

Protected Attributes

double fFrameRate
unsigned fPictureCount
Boolean fPictureEndMarker
MPEGVideoStreamParserfParser
FramedSourcefInputSource
unsigned char * fTo
unsigned fMaxSize
unsigned fFrameSize
unsigned fNumTruncatedBytes
timeval fPresentationTime
unsigned fDurationInMicroseconds

Private Member Functions

 MPEG1or2VideoStreamDiscreteFramer (UsageEnvironment &env, FramedSource *inputSource, Boolean iFramesOnly, double vshPeriod)
virtual ~MPEG1or2VideoStreamDiscreteFramer ()
virtual void doGetNextFrame ()
void afterGettingFrame1 (unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)

Static Private Member Functions

static void afterGettingFrame (void *clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)

Private Attributes

timeval fLastNonBFramePresentationTime
unsigned fLastNonBFrameTemporal_reference
unsigned char fSavedVSHBuffer [VSH_MAX_SIZE]
unsigned fSavedVSHSize
double fSavedVSHTimestamp
Boolean fIFramesOnly
double fVSHPeriod

Friends

class MPEGVideoStreamParser

Detailed Description

Definition at line 33 of file MPEG1or2VideoStreamDiscreteFramer.hh.


Member Typedef Documentation

typedef void( FramedSource::afterGettingFunc)(void *clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds) [inherited]

Definition at line 36 of file FramedSource.hh.

typedef void( FramedSource::onCloseFunc)(void *clientData) [inherited]

Definition at line 40 of file FramedSource.hh.


Constructor & Destructor Documentation

MPEG1or2VideoStreamDiscreteFramer::MPEG1or2VideoStreamDiscreteFramer ( UsageEnvironment env,
FramedSource inputSource,
Boolean  iFramesOnly,
double  vshPeriod 
) [private]

Definition at line 37 of file MPEG1or2VideoStreamDiscreteFramer.cpp.

References fLastNonBFramePresentationTime.

Referenced by createNew().

00040   : MPEG1or2VideoStreamFramer(env, inputSource, iFramesOnly, vshPeriod,
00041                               False/*don't create a parser*/),
00042     fLastNonBFrameTemporal_reference(0),
00043     fSavedVSHSize(0), fSavedVSHTimestamp(0.0),
00044     fIFramesOnly(iFramesOnly), fVSHPeriod(vshPeriod) {
00045   fLastNonBFramePresentationTime.tv_sec = 0;
00046   fLastNonBFramePresentationTime.tv_usec = 0;
00047 }

MPEG1or2VideoStreamDiscreteFramer::~MPEG1or2VideoStreamDiscreteFramer (  )  [private, virtual]

Definition at line 49 of file MPEG1or2VideoStreamDiscreteFramer.cpp.

00049                                                                       {
00050 }


Member Function Documentation

MPEG1or2VideoStreamDiscreteFramer * MPEG1or2VideoStreamDiscreteFramer::createNew ( UsageEnvironment env,
FramedSource inputSource,
Boolean  iFramesOnly = False,
double  vshPeriod = 5.0 
) [static]

Reimplemented from MPEG1or2VideoStreamFramer.

Definition at line 27 of file MPEG1or2VideoStreamDiscreteFramer.cpp.

References env, FramedFilter::inputSource(), and MPEG1or2VideoStreamDiscreteFramer().

00030                                                                {
00031   // Need to add source type checking here???  #####
00032   return new MPEG1or2VideoStreamDiscreteFramer(env, inputSource,
00033                                                iFramesOnly, vshPeriod);
00034 }

void MPEG1or2VideoStreamDiscreteFramer::doGetNextFrame (  )  [private, virtual]

Reimplemented from MPEGVideoStreamFramer.

Definition at line 52 of file MPEG1or2VideoStreamDiscreteFramer.cpp.

References afterGettingFrame(), FramedFilter::fInputSource, FramedSource::fMaxSize, FramedSource::fTo, FramedSource::getNextFrame(), and FramedSource::handleClosure().

Referenced by afterGettingFrame1().

00052                                                        {
00053   // Arrange to read data (which should be a complete MPEG-1 or 2 video frame)
00054   // from our data source, directly into the client's input buffer.
00055   // After reading this, we'll do some parsing on the frame.
00056   fInputSource->getNextFrame(fTo, fMaxSize,
00057                              afterGettingFrame, this,
00058                              FramedSource::handleClosure, this);
00059 }

void MPEG1or2VideoStreamDiscreteFramer::afterGettingFrame ( void *  clientData,
unsigned  frameSize,
unsigned  numTruncatedBytes,
struct timeval  presentationTime,
unsigned  durationInMicroseconds 
) [static, private]

Definition at line 62 of file MPEG1or2VideoStreamDiscreteFramer.cpp.

References afterGettingFrame1().

Referenced by doGetNextFrame().

00065                                                      {
00066   MPEG1or2VideoStreamDiscreteFramer* source
00067     = (MPEG1or2VideoStreamDiscreteFramer*)clientData;
00068   source->afterGettingFrame1(frameSize, numTruncatedBytes,
00069                              presentationTime, durationInMicroseconds);
00070 }

void MPEG1or2VideoStreamDiscreteFramer::afterGettingFrame1 ( unsigned  frameSize,
unsigned  numTruncatedBytes,
struct timeval  presentationTime,
unsigned  durationInMicroseconds 
) [private]

Definition at line 94 of file MPEG1or2VideoStreamDiscreteFramer.cpp.

References doGetNextFrame(), MPEGVideoStreamFramer::fFrameRate, fIFramesOnly, fLastNonBFramePresentationTime, fLastNonBFrameTemporal_reference, FramedSource::fMaxSize, MPEGVideoStreamFramer::fPictureEndMarker, frameRateFromCode, fSavedVSHBuffer, fSavedVSHSize, fSavedVSHTimestamp, FramedSource::fTo, fVSHPeriod, if(), MILLION, and True.

Referenced by afterGettingFrame().

00096                                                       {
00097   // Check that the first 4 bytes are a system code:
00098   if (frameSize >= 4 && fTo[0] == 0 && fTo[1] == 0 && fTo[2] == 1) {
00099     fPictureEndMarker = True; // Assume that we have a complete 'picture' here
00100 
00101     u_int8_t nextCode = fTo[3];
00102     if (nextCode == 0xB3) { // VIDEO_SEQUENCE_HEADER_START_CODE
00103       // Note the following 'frame rate' code:
00104       if (frameSize >= 8) {
00105         u_int8_t frame_rate_code = fTo[7]&0x0F;
00106         fFrameRate = frameRateFromCode[frame_rate_code];
00107       }
00108 
00109       // Also, save away this Video Sequence Header, in case we need it later:
00110       // First, figure out how big it is:
00111       unsigned vshSize;
00112       for (vshSize = 4; vshSize < frameSize-3; ++vshSize) {
00113         if (fTo[vshSize] == 0 && fTo[vshSize+1] == 0 && fTo[vshSize+2] == 1 &&
00114             (fTo[vshSize+3] == 0xB8 || fTo[vshSize+3] == 0x00)) break;
00115       }
00116       if (vshSize == frameSize-3) vshSize = frameSize; // There was nothing else following it
00117       if (vshSize <= sizeof fSavedVSHBuffer) {
00118         memmove(fSavedVSHBuffer, fTo, vshSize);
00119         fSavedVSHSize = vshSize;
00120         fSavedVSHTimestamp
00121           = presentationTime.tv_sec + presentationTime.tv_usec/(double)MILLION;
00122       }
00123     } else if (nextCode == 0xB8) { // GROUP_START_CODE
00124       // If necessary, insert a saved Video Sequence Header in front of this:
00125       double pts = presentationTime.tv_sec + presentationTime.tv_usec/(double)MILLION;
00126       if (pts > fSavedVSHTimestamp + fVSHPeriod &&
00127           fSavedVSHSize + frameSize <= fMaxSize) {
00128         memmove(&fTo[fSavedVSHSize], &fTo[0], frameSize); // make room for the header
00129         memmove(&fTo[0], fSavedVSHBuffer, fSavedVSHSize); // insert it
00130         frameSize += fSavedVSHSize;
00131         fSavedVSHTimestamp = pts;
00132       }
00133     }
00134 
00135     unsigned i = 3;
00136     if (nextCode == 0xB3 /*VIDEO_SEQUENCE_HEADER_START_CODE*/ ||
00137         nextCode == 0xB8 /*GROUP_START_CODE*/) {
00138       // Skip to the following PICTURE_START_CODE (if any):
00139       for (i += 4; i < frameSize; ++i) {
00140         if (fTo[i] == 0x00 /*PICTURE_START_CODE*/
00141             && fTo[i-1] == 1 && fTo[i-2] == 0 && fTo[i-3] == 0) {
00142           nextCode = fTo[i];
00143           break;
00144         }
00145       }
00146     }
00147 
00148     if (nextCode == 0x00 /*PICTURE_START_CODE*/ && i+2 < frameSize) {
00149       // Get the 'temporal_reference' and 'picture_coding_type' from the
00150       // following 2 bytes:
00151       ++i;
00152       unsigned short temporal_reference = (fTo[i]<<2)|(fTo[i+1]>>6);
00153       unsigned char picture_coding_type = (fTo[i+1]&0x38)>>3;
00154 
00155       // If this is not an "I" frame, but we were asked for "I" frames only, then try again:
00156       if (fIFramesOnly && picture_coding_type != 1) {
00157         doGetNextFrame();
00158         return;
00159       }
00160 
00161       // If this is a "B" frame, then we have to tweak "presentationTime":
00162       if (picture_coding_type == 3/*B*/
00163           && (fLastNonBFramePresentationTime.tv_usec > 0 ||
00164               fLastNonBFramePresentationTime.tv_sec > 0)) {
00165         int trIncrement
00166             = fLastNonBFrameTemporal_reference - temporal_reference;
00167         if (trIncrement < 0) trIncrement += 1024; // field is 10 bits in size
00168 
00169         unsigned usIncrement = fFrameRate == 0.0 ? 0
00170           : (unsigned)((trIncrement*MILLION)/fFrameRate);
00171         unsigned secondsToSubtract = usIncrement/MILLION;
00172         unsigned uSecondsToSubtract = usIncrement%MILLION;
00173 
00174         presentationTime = fLastNonBFramePresentationTime;
00175         if ((unsigned)presentationTime.tv_usec < uSecondsToSubtract) {
00176           presentationTime.tv_usec += MILLION;
00177           if (presentationTime.tv_sec > 0) --presentationTime.tv_sec;
00178         }
00179         presentationTime.tv_usec -= uSecondsToSubtract;
00180         if ((unsigned)presentationTime.tv_sec > secondsToSubtract) {
00181           presentationTime.tv_sec -= secondsToSubtract;
00182         } else {
00183           presentationTime.tv_sec = presentationTime.tv_usec = 0;
00184         }
00185       } else {
00186         fLastNonBFramePresentationTime = presentationTime;
00187         fLastNonBFrameTemporal_reference = temporal_reference;
00188       }
00189     }
00190   }
00191 
00192   // ##### Later:
00193   // - do "iFramesOnly" if requested
00194 
00195   // Complete delivery to the client:
00196   fFrameSize = frameSize;
00197   fNumTruncatedBytes = numTruncatedBytes;
00198   fPresentationTime = presentationTime;
00199   fDurationInMicroseconds = durationInMicroseconds;
00200   afterGetting(this);
00201 }

Boolean& MPEGVideoStreamFramer::pictureEndMarker (  )  [inline, inherited]

Definition at line 40 of file MPEGVideoStreamFramer.hh.

References MPEGVideoStreamFramer::fPictureEndMarker.

Referenced by MPEG4ESVideoRTPSink::doSpecialFrameHandling(), and MPEG1or2VideoRTPSink::doSpecialFrameHandling().

00040 { return fPictureEndMarker; }

void MPEGVideoStreamFramer::flushInput (  )  [inherited]

Definition at line 53 of file MPEGVideoStreamFramer.cpp.

References StreamParser::flushInput(), MPEGVideoStreamFramer::fParser, NULL, and MPEGVideoStreamFramer::reset().

Referenced by MPEG1or2DemuxedServerMediaSubsession::seekStreamSource().

00053                                        {
00054   reset();
00055   if (fParser != NULL) fParser->flushInput();
00056 }

void MPEGVideoStreamFramer::computePresentationTime ( unsigned  numAdditionalPictures  )  [protected, inherited]

Definition at line 74 of file MPEGVideoStreamFramer.cpp.

References TimeCode::days, MPEGVideoStreamFramer::fCurGOPTimeCode, MPEGVideoStreamFramer::fFrameRate, MPEGVideoStreamFramer::fPicturesAdjustment, MPEGVideoStreamFramer::fPictureTimeBase, FramedSource::fPresentationTime, MPEGVideoStreamFramer::fPresentationTimeBase, MPEGVideoStreamFramer::fTcSecsBase, TimeCode::hours, TimeCode::minutes, TimeCode::pictures, and TimeCode::seconds.

Referenced by MPEG1or2VideoStreamParser::parseGOPHeader(), MPEG4VideoStreamParser::parseGroupOfVideoObjectPlane(), MPEG1or2VideoStreamParser::parsePictureHeader(), MPEG1or2VideoStreamParser::parseSlice(), MPEG4VideoStreamParser::parseVideoObjectLayer(), MPEG4VideoStreamParser::parseVideoObjectPlane(), MPEG1or2VideoStreamParser::parseVideoSequenceHeader(), MPEG4VideoStreamParser::parseVisualObject(), and MPEG4VideoStreamParser::parseVisualObjectSequence().

00074                                                         {
00075   // Computes "fPresentationTime" from the most recent GOP's
00076   // time_code, along with the "numAdditionalPictures" parameter:
00077   TimeCode& tc = fCurGOPTimeCode;
00078 
00079   unsigned tcSecs
00080     = (((tc.days*24)+tc.hours)*60+tc.minutes)*60+tc.seconds - fTcSecsBase;
00081   double pictureTime = fFrameRate == 0.0 ? 0.0
00082     : (tc.pictures + fPicturesAdjustment + numAdditionalPictures)/fFrameRate;
00083   while (pictureTime < fPictureTimeBase) { // "if" should be enough, but just in case
00084     if (tcSecs > 0) tcSecs -= 1;
00085     pictureTime += 1.0;
00086   }
00087   pictureTime -= fPictureTimeBase;
00088   if (pictureTime < 0.0) pictureTime = 0.0; // sanity check
00089   unsigned pictureSeconds = (unsigned)pictureTime;
00090   double pictureFractionOfSecond = pictureTime - (double)pictureSeconds;
00091 
00092   fPresentationTime = fPresentationTimeBase;
00093   fPresentationTime.tv_sec += tcSecs + pictureSeconds;
00094   fPresentationTime.tv_usec += (long)(pictureFractionOfSecond*1000000.0);
00095   if (fPresentationTime.tv_usec >= 1000000) {
00096     fPresentationTime.tv_usec -= 1000000;
00097     ++fPresentationTime.tv_sec;
00098   }
00099 #ifdef DEBUG
00100   if (firstPT.tv_sec == 0 && firstPT.tv_usec == 0) firstPT = fPresentationTime;
00101   struct timeval diffPT;
00102   diffPT.tv_sec = fPresentationTime.tv_sec - firstPT.tv_sec;
00103   diffPT.tv_usec = fPresentationTime.tv_usec - firstPT.tv_usec;
00104   if (fPresentationTime.tv_usec < firstPT.tv_usec) {
00105     --diffPT.tv_sec;
00106     diffPT.tv_usec += 1000000;
00107   }
00108   fprintf(stderr, "MPEGVideoStreamFramer::computePresentationTime(%d) -> %lu.%06ld [%lu.%06ld]\n", numAdditionalPictures, fPresentationTime.tv_sec, fPresentationTime.tv_usec, diffPT.tv_sec, diffPT.tv_usec);
00109 #endif
00110 }

void MPEGVideoStreamFramer::setTimeCode ( unsigned  hours,
unsigned  minutes,
unsigned  seconds,
unsigned  pictures,
unsigned  picturesSinceLastGOP 
) [protected, inherited]

Definition at line 113 of file MPEGVideoStreamFramer.cpp.

References TimeCode::days, MPEGVideoStreamFramer::fCurGOPTimeCode, MPEGVideoStreamFramer::fFrameRate, MPEGVideoStreamFramer::fHaveSeenFirstTimeCode, MPEGVideoStreamFramer::fPicturesAdjustment, MPEGVideoStreamFramer::fPictureTimeBase, MPEGVideoStreamFramer::fPrevGOPTimeCode, MPEGVideoStreamFramer::fTcSecsBase, TimeCode::hours, TimeCode::minutes, TimeCode::pictures, TimeCode::seconds, and True.

Referenced by MPEG1or2VideoStreamParser::parseGOPHeader(), and MPEG4VideoStreamParser::parseGroupOfVideoObjectPlane().

00114                                                                 {
00115   TimeCode& tc = fCurGOPTimeCode; // abbrev
00116   unsigned days = tc.days;
00117   if (hours < tc.hours) {
00118     // Assume that the 'day' has wrapped around:
00119     ++days;
00120   }
00121   tc.days = days;
00122   tc.hours = hours;
00123   tc.minutes = minutes;
00124   tc.seconds = seconds;
00125   tc.pictures = pictures;
00126   if (!fHaveSeenFirstTimeCode) {
00127     fPictureTimeBase = fFrameRate == 0.0 ? 0.0 : tc.pictures/fFrameRate;
00128     fTcSecsBase = (((tc.days*24)+tc.hours)*60+tc.minutes)*60+tc.seconds;
00129     fHaveSeenFirstTimeCode = True;
00130   } else if (fCurGOPTimeCode == fPrevGOPTimeCode) {
00131     // The time code has not changed since last time.  Adjust for this:
00132     fPicturesAdjustment += picturesSinceLastGOP;
00133   } else {
00134     // Normal case: The time code changed since last time.
00135     fPrevGOPTimeCode = tc;
00136     fPicturesAdjustment = 0;
00137   }
00138 }

FramedSource* FramedFilter::inputSource (  )  const [inline, inherited]

Definition at line 30 of file FramedFilter.hh.

References FramedFilter::fInputSource.

Referenced by AC3AudioStreamFramer::AC3AudioStreamFramer(), EndianSwap16::createNew(), HostFromNetworkOrder16::createNew(), NetworkFromHostOrder16::createNew(), PCMFromuLawAudioSource::createNew(), QCELPDeinterleaver::createNew(), MPEG4VideoStreamFramer::createNew(), MPEG4VideoStreamDiscreteFramer::createNew(), MPEG2IFrameIndexFromTransportStream::createNew(), MPEG1or2VideoStreamFramer::createNew(), createNew(), MPEG1or2AudioStreamFramer::createNew(), MP3Transcoder::createNew(), MP3ADUTranscoder::createNew(), MP3ADUdeinterleaver::createNew(), MP3ADUinterleaver::createNew(), MP3FromADUSource::createNew(), ADUFromMP3Source::createNew(), H263plusVideoStreamFramer::createNew(), AC3AudioStreamFramer::createNew(), H264VideoRTPSink::doSpecialFrameHandling(), MP3ADUinterleaverBase::getInputSource(), H263plusVideoStreamFramer::H263plusVideoStreamFramer(), MPEG1or2VideoStreamFramer::MPEG1or2VideoStreamFramer(), MPEG4VideoStreamFramer::MPEG4VideoStreamFramer(), MP3AudioFileServerMediaSubsession::seekStreamSource(), ClientTrickPlayState::setSource(), and MP3AudioFileServerMediaSubsession::setStreamSourceScale().

00030 { return fInputSource; }

char const * FramedFilter::MIMEtype (  )  const [protected, virtual, inherited]

Reimplemented from MediaSource.

Reimplemented in ADUFromMP3Source, and MP3FromADUSource.

Definition at line 39 of file FramedFilter.cpp.

References FramedFilter::fInputSource, MediaSource::MIMEtype(), and NULL.

00039                                          {
00040   if (fInputSource == NULL) return "";
00041 
00042   return fInputSource->MIMEtype();
00043 }

void FramedFilter::getAttributes (  )  const [protected, virtual, inherited]

Reimplemented from MediaSource.

Reimplemented in MP3ADUTranscoder.

Definition at line 45 of file FramedFilter.cpp.

References FramedFilter::fInputSource, MediaSource::getAttributes(), and NULL.

00045                                        {
00046   if (fInputSource != NULL) fInputSource->getAttributes();
00047 }

void FramedFilter::doStopGettingFrames (  )  [protected, virtual, inherited]

Reimplemented from FramedSource.

Reimplemented in MPEG2TransportStreamFramer, and MPEG2TransportStreamTrickModeFilter.

Definition at line 49 of file FramedFilter.cpp.

References FramedFilter::fInputSource, NULL, and FramedSource::stopGettingFrames().

Referenced by MPEG2TransportStreamTrickModeFilter::doStopGettingFrames(), and MPEG2TransportStreamFramer::doStopGettingFrames().

00049                                        {
00050   if (fInputSource != NULL) fInputSource->stopGettingFrames();
00051 }

Boolean FramedSource::lookupByName ( UsageEnvironment env,
char const *  sourceName,
FramedSource *&  resultSource 
) [static, inherited]

Definition at line 41 of file FramedSource.cpp.

References env, False, MediaSource::isFramedSource(), MediaSource::lookupByName(), NULL, and True.

Referenced by MP3ADUinterleaverBase::getInputSource().

00042                                                                 {
00043   resultSource = NULL; // unless we succeed
00044 
00045   MediaSource* source;
00046   if (!MediaSource::lookupByName(env, sourceName, source)) return False;
00047 
00048   if (!source->isFramedSource()) {
00049     env.setResultMsg(sourceName, " is not a framed source");
00050     return False;
00051   }
00052 
00053   resultSource = (FramedSource*)source;
00054   return True;
00055 }

Boolean MediaSource::lookupByName ( UsageEnvironment env,
char const *  sourceName,
MediaSource *&  resultSource 
) [static, inherited]

Definition at line 62 of file MediaSource.cpp.

References env, False, Medium::isSource(), Medium::lookupByName(), NULL, and True.

Referenced by RTPSource::lookupByName(), and FramedSource::lookupByName().

00064                                                               {
00065   resultSource = NULL; // unless we succeed
00066 
00067   Medium* medium;
00068   if (!Medium::lookupByName(env, sourceName, medium)) return False;
00069 
00070   if (!medium->isSource()) {
00071     env.setResultMsg(sourceName, " is not a media source");
00072     return False;
00073   }
00074 
00075   resultSource = (MediaSource*)medium;
00076   return True;
00077 }

Boolean Medium::lookupByName ( UsageEnvironment env,
char const *  mediumName,
Medium *&  resultMedium 
) [static, inherited]

Definition at line 65 of file Media.cpp.

References env, False, MediaLookupTable::lookup(), NULL, MediaLookupTable::ourMedia(), UsageEnvironment::setResultMsg(), and True.

Referenced by ServerMediaSession::lookupByName(), RTSPServer::lookupByName(), RTSPClient::lookupByName(), RTCPInstance::lookupByName(), MediaSource::lookupByName(), MediaSink::lookupByName(), MediaSession::lookupByName(), and DarwinInjector::lookupByName().

00066                                                          {
00067   resultMedium = MediaLookupTable::ourMedia(env)->lookup(mediumName);
00068   if (resultMedium == NULL) {
00069     env.setResultMsg("Medium ", mediumName, " does not exist");
00070     return False;
00071   }
00072 
00073   return True;
00074 }

void FramedSource::getNextFrame ( unsigned char *  to,
unsigned  maxSize,
afterGettingFunc afterGettingFunc,
void *  afterGettingClientData,
onCloseFunc onCloseFunc,
void *  onCloseClientData 
) [inherited]

Definition at line 57 of file FramedSource.cpp.

References FramedSource::doGetNextFrame(), Medium::envir(), FramedSource::fAfterGettingClientData, FramedSource::fAfterGettingFunc, FramedSource::fDurationInMicroseconds, FramedSource::fIsCurrentlyAwaitingData, FramedSource::fMaxSize, FramedSource::fNumTruncatedBytes, FramedSource::fOnCloseClientData, FramedSource::fOnCloseFunc, FramedSource::fTo, and True.

Referenced by MPEG2TransportStreamFramer::afterGettingFrame1(), InputESSourceRecord::askForNewData(), MPEG2TransportStreamFromPESSource::awaitNewBuffer(), QuickTimeFileSink::continuePlaying(), DummySink::continuePlaying(), HTTPSink::continuePlaying(), FileSink::continuePlaying(), AVIFileSink::continuePlaying(), BasicUDPSink::continuePlaying1(), EndianSwap16::doGetNextFrame(), HostFromNetworkOrder16::doGetNextFrame(), NetworkFromHostOrder16::doGetNextFrame(), PCMFromuLawAudioSource::doGetNextFrame(), uLawFromPCMAudioSource::doGetNextFrame(), QCELPDeinterleaver::doGetNextFrame(), MPEG4VideoStreamDiscreteFramer::doGetNextFrame(), MPEG2TransportStreamFramer::doGetNextFrame(), MPEG2IFrameIndexFromTransportStream::doGetNextFrame(), doGetNextFrame(), MP3ADUTranscoder::doGetNextFrame(), MP3ADUdeinterleaver::doGetNextFrame(), MP3ADUinterleaver::doGetNextFrame(), H264FUAFragmenter::doGetNextFrame(), ByteStreamMultiFileSource::doGetNextFrame(), AMRDeinterleaver::doGetNextFrame(), SegmentQueue::enqueueNewSegment(), StreamParser::ensureValidBytes1(), MultiFramedRTPSink::packFrame(), AC3AudioStreamParser::readAndSaveAFrame(), and MPEG2TransportStreamTrickModeFilter::readTransportPacket().

00061                                                          {
00062   // Make sure we're not already being read:
00063   if (fIsCurrentlyAwaitingData) {
00064     envir() << "FramedSource[" << this << "]::getNextFrame(): attempting to read more than once at the same time!\n";
00065     exit(1);
00066   }
00067 
00068   fTo = to;
00069   fMaxSize = maxSize;
00070   fNumTruncatedBytes = 0; // by default; could be changed by doGetNextFrame()
00071   fDurationInMicroseconds = 0; // by default; could be changed by doGetNextFrame()
00072   fAfterGettingFunc = afterGettingFunc;
00073   fAfterGettingClientData = afterGettingClientData;
00074   fOnCloseFunc = onCloseFunc;
00075   fOnCloseClientData = onCloseClientData;
00076   fIsCurrentlyAwaitingData = True;
00077 
00078   doGetNextFrame();
00079 }

void FramedSource::handleClosure ( void *  clientData  )  [static, inherited]

Definition at line 95 of file FramedSource.cpp.

References False, FramedSource::fIsCurrentlyAwaitingData, FramedSource::fOnCloseClientData, FramedSource::fOnCloseFunc, and NULL.

Referenced by MPEG2TransportStreamFramer::afterGettingFrame1(), MP3ADUTranscoder::afterGettingFrame1(), InputESSourceRecord::askForNewData(), MPEG2TransportStreamFromPESSource::awaitNewBuffer(), WAVAudioFileSource::doGetNextFrame(), EndianSwap16::doGetNextFrame(), HostFromNetworkOrder16::doGetNextFrame(), NetworkFromHostOrder16::doGetNextFrame(), PCMFromuLawAudioSource::doGetNextFrame(), uLawFromPCMAudioSource::doGetNextFrame(), QCELPDeinterleaver::doGetNextFrame(), MPEG4VideoStreamDiscreteFramer::doGetNextFrame(), MPEG2TransportStreamFramer::doGetNextFrame(), doGetNextFrame(), MPEG1or2DemuxedElementaryStream::doGetNextFrame(), MP3FileSource::doGetNextFrame(), MP3ADUTranscoder::doGetNextFrame(), MP3ADUdeinterleaver::doGetNextFrame(), MP3ADUinterleaver::doGetNextFrame(), ADUFromMP3Source::doGetNextFrame(), H264FUAFragmenter::doGetNextFrame(), DeviceSource::doGetNextFrame(), ByteStreamMultiFileSource::doGetNextFrame(), ByteStreamFileSource::doGetNextFrame(), AMRDeinterleaver::doGetNextFrame(), AMRAudioFileSource::doGetNextFrame(), ADTSAudioFileSource::doGetNextFrame(), ByteStreamFileSource::doReadFromFile(), SegmentQueue::enqueueNewSegment(), MPEG2IFrameIndexFromTransportStream::handleInputClosure1(), and MPEG2TransportStreamTrickModeFilter::onSourceClosure1().

00095                                                  {
00096   FramedSource* source = (FramedSource*)clientData;
00097   source->fIsCurrentlyAwaitingData = False; // because we got a close instead
00098   if (source->fOnCloseFunc != NULL) {
00099     (*(source->fOnCloseFunc))(source->fOnCloseClientData);
00100   }
00101 }

void FramedSource::stopGettingFrames (  )  [inherited]

Definition at line 103 of file FramedSource.cpp.

References FramedSource::doStopGettingFrames(), False, and FramedSource::fIsCurrentlyAwaitingData.

Referenced by MPEG2TransportStreamFromPESSource::doStopGettingFrames(), FramedFilter::doStopGettingFrames(), AMRDeinterleaver::doStopGettingFrames(), and MediaSink::stopPlaying().

00103                                      {
00104   fIsCurrentlyAwaitingData = False; // indicates that we can be read again
00105 
00106   // Perform any specialized action now:
00107   doStopGettingFrames();
00108 }

unsigned FramedSource::maxFrameSize (  )  const [virtual, inherited]

Reimplemented in MPEG1or2DemuxedElementaryStream.

Definition at line 116 of file FramedSource.cpp.

Referenced by StreamParser::ensureValidBytes1().

00116                                           {
00117   // By default, this source has no maximum frame size.
00118   return 0;
00119 }

Boolean FramedSource::isCurrentlyAwaitingData (  )  const [inline, inherited]

Definition at line 60 of file FramedSource.hh.

References FramedSource::fIsCurrentlyAwaitingData.

Referenced by afterPlaying(), InputESSourceRecord::askForNewData(), MPEG2TransportStreamFromESSource::awaitNewBuffer(), QuickTimeFileSink::continuePlaying(), AVIFileSink::continuePlaying(), DeviceSource::deliverFrame(), QCELPDeinterleaver::doGetNextFrame(), AMRDeinterleaver::doGetNextFrame(), ByteStreamFileSource::fileReadableHandler(), and BasicUDPSource::incomingPacketHandler1().

00060 {return fIsCurrentlyAwaitingData;}

void FramedSource::afterGetting ( FramedSource source  )  [static, protected, inherited]

Definition at line 81 of file FramedSource.cpp.

References FramedSource::fAfterGettingClientData, FramedSource::fAfterGettingFunc, False, FramedSource::fDurationInMicroseconds, FramedSource::fFrameSize, FramedSource::fIsCurrentlyAwaitingData, FramedSource::fNumTruncatedBytes, FramedSource::fPresentationTime, and NULL.

Referenced by ByteStreamMultiFileSource::afterGettingFrame(), EndianSwap16::afterGettingFrame1(), HostFromNetworkOrder16::afterGettingFrame1(), NetworkFromHostOrder16::afterGettingFrame1(), PCMFromuLawAudioSource::afterGettingFrame1(), uLawFromPCMAudioSource::afterGettingFrame1(), MPEG2TransportStreamFramer::afterGettingFrame1(), MPEG1or2DemuxedElementaryStream::afterGettingFrame1(), MP3ADUTranscoder::afterGettingFrame1(), MPEG2TransportStreamTrickModeFilter::attemptDeliveryToClient(), MPEGVideoStreamFramer::continueReadProcessing(), MPEG1or2AudioStreamFramer::continueReadProcessing(), H263plusVideoStreamFramer::continueReadProcessing(), DeviceSource::deliverFrame(), MPEG2IFrameIndexFromTransportStream::deliverIndexRecord(), WAVAudioFileSource::doGetNextFrame(), QCELPDeinterleaver::doGetNextFrame(), MPEG2TransportStreamTrickModeFilter::doGetNextFrame(), MPEG2TransportStreamMultiplexor::doGetNextFrame(), MP3FileSource::doGetNextFrame(), MP3ADUdeinterleaver::doGetNextFrame(), MP3ADUinterleaver::doGetNextFrame(), MP3FromADUSource::doGetNextFrame(), H264FUAFragmenter::doGetNextFrame(), AMRDeinterleaver::doGetNextFrame(), AMRAudioFileSource::doGetNextFrame(), ADTSAudioFileSource::doGetNextFrame(), MultiFramedRTPSource::doGetNextFrame1(), ADUFromMP3Source::doGetNextFrame1(), ByteStreamFileSource::doReadFromFile(), BasicUDPSource::incomingPacketHandler1(), and AC3AudioStreamFramer::parseNextFrame().

00081                                                     {
00082   source->fIsCurrentlyAwaitingData = False;
00083       // indicates that we can be read again
00084       // Note that this needs to be done here, in case the "fAfterFunc"
00085       // called below tries to read another frame (which it usually will)
00086 
00087   if (source->fAfterGettingFunc != NULL) {
00088     (*(source->fAfterGettingFunc))(source->fAfterGettingClientData,
00089                                    source->fFrameSize, source->fNumTruncatedBytes,
00090                                    source->fPresentationTime,
00091                                    source->