liveMedia/VP8VideoRTPSource.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 // VP8 Video RTP Sources
00019 // Implementation
00020 
00021 #include "VP8VideoRTPSource.hh"
00022 
00023 VP8VideoRTPSource*
00024 VP8VideoRTPSource::createNew(UsageEnvironment& env, Groupsock* RTPgs,
00025                               unsigned char rtpPayloadFormat,
00026                               unsigned rtpTimestampFrequency) {
00027   return new VP8VideoRTPSource(env, RTPgs, rtpPayloadFormat,
00028                                rtpTimestampFrequency);
00029 }
00030 
00031 VP8VideoRTPSource
00032 ::VP8VideoRTPSource(UsageEnvironment& env, Groupsock* RTPgs,
00033                      unsigned char rtpPayloadFormat,
00034                      unsigned rtpTimestampFrequency)
00035   : MultiFramedRTPSource(env, RTPgs, rtpPayloadFormat, rtpTimestampFrequency) {
00036 }
00037 
00038 VP8VideoRTPSource::~VP8VideoRTPSource() {
00039 }
00040 
00041 Boolean VP8VideoRTPSource
00042 ::processSpecialHeader(BufferedPacket* packet,
00043                        unsigned& resultSpecialHeaderSize) {
00044   unsigned char* headerStart = packet->data();
00045   unsigned packetSize = packet->dataSize();
00046 
00047   // The special header is from 1 to 6 bytes long.
00048   if (packetSize == 0) return False; // error
00049   resultSpecialHeaderSize = 1; // unless we learn otherwise
00050 
00051   u_int8_t const byte1 = headerStart[0];
00052   Boolean const X = (byte1&0x80) != 0;
00053   Boolean const S = (byte1&0x10) != 0;
00054   u_int8_t const PartID = byte1&0x0F;
00055 
00056   fCurrentPacketBeginsFrame = S && PartID == 0;
00057   fCurrentPacketCompletesFrame = packet->rtpMarkerBit(); // RTP header's "M" bit
00058 
00059   if (X) {
00060     ++resultSpecialHeaderSize;
00061 
00062     u_int8_t const byte2 = headerStart[1];
00063     Boolean const I = (byte2&0x80) != 0;
00064     Boolean const L = (byte2&0x40) != 0;
00065     Boolean const T = (byte2&0x20) != 0;
00066     Boolean const K = (byte2&0x10) != 0;
00067 
00068     if (I) {
00069       ++resultSpecialHeaderSize;
00070       if (headerStart[2]&0x80) { // extension flag in the PictureID is set
00071         ++resultSpecialHeaderSize;
00072       }
00073     }
00074 
00075     if (L) ++resultSpecialHeaderSize;
00076     if (T||K) ++resultSpecialHeaderSize;
00077   }
00078   
00079   return True;
00080 }
00081 
00082 char const* VP8VideoRTPSource::MIMEtype() const {
00083   return "video/VP8";
00084 }

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