liveMedia/MP3ADURTPSource.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 // RTP source for 'ADUized' MP3 frames ("mpa-robust")
00019 // Implementation
00020 
00021 #include "MP3ADURTPSource.hh"
00022 #include "MP3ADUdescriptor.hh"
00023 
00025 
00026 class ADUBufferedPacket: public BufferedPacket {
00027 private: // redefined virtual functions
00028   virtual unsigned nextEnclosedFrameSize(unsigned char*& framePtr,
00029                                  unsigned dataSize);
00030 };
00031 
00032 class ADUBufferedPacketFactory: public BufferedPacketFactory {
00033 private: // redefined virtual functions
00034   virtual BufferedPacket* createNewPacket(MultiFramedRTPSource* ourSource);
00035 };
00036 
00038 
00039 MP3ADURTPSource*
00040 MP3ADURTPSource::createNew(UsageEnvironment& env, Groupsock* RTPgs,
00041                            unsigned char rtpPayloadFormat,
00042                            unsigned rtpTimestampFrequency) {
00043    return new MP3ADURTPSource(env, RTPgs, rtpPayloadFormat,
00044                               rtpTimestampFrequency);
00045 }
00046 
00047 MP3ADURTPSource::MP3ADURTPSource(UsageEnvironment& env, Groupsock* RTPgs,
00048                                  unsigned char rtpPayloadFormat,
00049                                  unsigned rtpTimestampFrequency)
00050   : MultiFramedRTPSource(env, RTPgs,
00051                          rtpPayloadFormat, rtpTimestampFrequency,
00052                          new ADUBufferedPacketFactory) {
00053 }
00054 
00055 MP3ADURTPSource::~MP3ADURTPSource() {
00056 }
00057 
00058 char const* MP3ADURTPSource::MIMEtype() const {
00059   return "audio/MPA-ROBUST";
00060 }
00061 
00063 
00064 unsigned ADUBufferedPacket
00065 ::nextEnclosedFrameSize(unsigned char*& framePtr, unsigned dataSize) {
00066   // Return the size of the next MP3 'ADU', on the assumption that
00067   // the input data is ADU-encoded MP3 frames.
00068   unsigned char* frameDataPtr = framePtr;
00069   unsigned remainingFrameSize
00070     = ADUdescriptor::getRemainingFrameSize(frameDataPtr);
00071   unsigned descriptorSize = (unsigned)(frameDataPtr - framePtr);
00072   unsigned fullADUSize = descriptorSize + remainingFrameSize;
00073 
00074   return (fullADUSize <= dataSize) ? fullADUSize : dataSize;
00075 }
00076 
00077 BufferedPacket* ADUBufferedPacketFactory
00078 ::createNewPacket(MultiFramedRTPSource* /*ourSource*/) {
00079   return new ADUBufferedPacket;
00080 }

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