liveMedia/MPEG1or2AudioRTPSink.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 sink for MPEG audio (RFC 2250)
00019 // Implementation
00020 
00021 #include "MPEG1or2AudioRTPSink.hh"
00022 
00023 MPEG1or2AudioRTPSink::MPEG1or2AudioRTPSink(UsageEnvironment& env, Groupsock* RTPgs)
00024   : AudioRTPSink(env, RTPgs, 14, 90000, "MPA") {
00025 }
00026 
00027 MPEG1or2AudioRTPSink::~MPEG1or2AudioRTPSink() {
00028 }
00029 
00030 MPEG1or2AudioRTPSink*
00031 MPEG1or2AudioRTPSink::createNew(UsageEnvironment& env, Groupsock* RTPgs) {
00032   return new MPEG1or2AudioRTPSink(env, RTPgs);
00033 }
00034 
00035 void MPEG1or2AudioRTPSink::doSpecialFrameHandling(unsigned fragmentationOffset,
00036                                               unsigned char* frameStart,
00037                                               unsigned numBytesInFrame,
00038                                               struct timeval framePresentationTime,
00039                                               unsigned numRemainingBytes) {
00040   // If this is the 1st frame in the 1st packet, set the RTP 'M' (marker)
00041   // bit (because this is considered the start of a talk spurt):
00042   if (isFirstPacket() && isFirstFrameInPacket()) {
00043     setMarkerBit();
00044   }
00045 
00046   // If this is the first frame in the packet, set the lower half of the
00047   // audio-specific header (to the "fragmentationOffset"):
00048   if (isFirstFrameInPacket()) {
00049     setSpecialHeaderWord(fragmentationOffset&0xFFFF);
00050   }
00051 
00052   // Important: Also call our base class's doSpecialFrameHandling(),
00053   // to set the packet's timestamp:
00054   MultiFramedRTPSink::doSpecialFrameHandling(fragmentationOffset,
00055                                              frameStart, numBytesInFrame,
00056                                              framePresentationTime,
00057                                              numRemainingBytes);
00058 }
00059 
00060 unsigned MPEG1or2AudioRTPSink::specialHeaderSize() const {
00061   // There's a 4 byte special audio header:
00062   return 4;
00063 }

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