liveMedia/MPEG1or2DemuxedElementaryStream.cpp

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015 **********/
00016 // "liveMedia"
00017 // Copyright (c) 1996-2012 Live Networks, Inc.  All rights reserved.
00018 // A MPEG 1 or 2 Elementary Stream, demultiplexed from a Program Stream
00019 // Implementation
00020 
00021 #include "MPEG1or2DemuxedElementaryStream.hh"
00022 
00024 
00025 MPEG1or2DemuxedElementaryStream::
00026 MPEG1or2DemuxedElementaryStream(UsageEnvironment& env, u_int8_t streamIdTag,
00027                             MPEG1or2Demux& sourceDemux)
00028   : FramedSource(env),
00029     fOurStreamIdTag(streamIdTag), fOurSourceDemux(sourceDemux), fMPEGversion(0) {
00030   // Set our MIME type string for known media types:
00031   if ((streamIdTag&0xE0) == 0xC0) {
00032     fMIMEtype = "audio/MPEG";
00033   } else if ((streamIdTag&0xF0) == 0xE0) {
00034     fMIMEtype = "video/MPEG";
00035   } else {
00036     fMIMEtype = MediaSource::MIMEtype();
00037   }
00038 }
00039 
00040 MPEG1or2DemuxedElementaryStream::~MPEG1or2DemuxedElementaryStream() {
00041   fOurSourceDemux.noteElementaryStreamDeletion(this);
00042 }
00043 
00044 void MPEG1or2DemuxedElementaryStream::doGetNextFrame() {
00045   fOurSourceDemux.getNextFrame(fOurStreamIdTag, fTo, fMaxSize,
00046                                afterGettingFrame, this,
00047                                handleClosure, this);
00048 }
00049 
00050 void MPEG1or2DemuxedElementaryStream::doStopGettingFrames() {
00051   fOurSourceDemux.stopGettingFrames(fOurStreamIdTag);
00052 }
00053 
00054 char const* MPEG1or2DemuxedElementaryStream::MIMEtype() const {
00055   return fMIMEtype;
00056 }
00057 
00058 unsigned MPEG1or2DemuxedElementaryStream::maxFrameSize() const {
00059   return 6+65535;
00060       // because the MPEG spec allows for PES packets as large as
00061       // (6 + 65535) bytes (header + data)
00062 }
00063 
00064 void MPEG1or2DemuxedElementaryStream
00065 ::afterGettingFrame(void* clientData,
00066                     unsigned frameSize, unsigned numTruncatedBytes,
00067                     struct timeval presentationTime,
00068                     unsigned durationInMicroseconds) {
00069   MPEG1or2DemuxedElementaryStream* stream
00070     = (MPEG1or2DemuxedElementaryStream*)clientData;
00071   stream->afterGettingFrame1(frameSize, numTruncatedBytes,
00072                              presentationTime, durationInMicroseconds);
00073 }
00074 
00075 void MPEG1or2DemuxedElementaryStream
00076 ::afterGettingFrame1(unsigned frameSize, unsigned numTruncatedBytes,
00077                      struct timeval presentationTime,
00078                      unsigned durationInMicroseconds) {
00079   fFrameSize = frameSize;
00080   fNumTruncatedBytes = numTruncatedBytes;
00081   fPresentationTime = presentationTime;
00082   fDurationInMicroseconds = durationInMicroseconds;
00083 
00084   fLastSeenSCR = fOurSourceDemux.lastSeenSCR();
00085   fMPEGversion = fOurSourceDemux.mpegVersion();
00086 
00087   FramedSource::afterGetting(this);
00088 }

Generated on Thu May 17 07:11:46 2012 for live by  doxygen 1.5.2