liveMedia/VP8VideoRTPSink.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 VP8 video
00019 // Implementation
00020 
00021 #include "VP8VideoRTPSink.hh"
00022 
00023 VP8VideoRTPSink
00024 ::VP8VideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat)
00025   : VideoRTPSink(env, RTPgs, rtpPayloadFormat, 90000, "VP8") {
00026 }
00027 
00028 VP8VideoRTPSink::~VP8VideoRTPSink() {
00029 }
00030 
00031 VP8VideoRTPSink*
00032 VP8VideoRTPSink::createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat) {
00033   return new VP8VideoRTPSink(env, RTPgs, rtpPayloadFormat);
00034 }
00035 
00036 Boolean VP8VideoRTPSink
00037 ::frameCanAppearAfterPacketStart(unsigned char const* /*frameStart*/,
00038                                  unsigned /*numBytesInFrame*/) const {
00039   // A packet can contain only one frame
00040   return False;
00041 }
00042 
00043 void VP8VideoRTPSink
00044 ::doSpecialFrameHandling(unsigned fragmentationOffset,
00045                          unsigned char* /*frameStart*/,
00046                          unsigned /*numBytesInFrame*/,
00047                          struct timeval framePresentationTime,
00048                          unsigned numRemainingBytes) {
00049   // Set the "VP8 Payload Descriptor" (just the minimal required 1-byte version):
00050   u_int8_t vp8PayloadDescriptor = fragmentationOffset == 0 ? 0x10 : 0x00;
00051     // X = R = N = 0; PartID = 0; S = 1 iff this is the first (or only) fragment of the frame
00052   setSpecialHeaderBytes(&vp8PayloadDescriptor, 1);
00053 
00054   if (numRemainingBytes == 0) {
00055     // This packet contains the last (or only) fragment of the frame.
00056     // Set the RTP 'M' ('marker') bit:
00057     setMarkerBit();
00058   }
00059 
00060   // Also set the RTP timestamp:
00061   setTimestamp(framePresentationTime);
00062 }
00063 
00064 
00065 unsigned VP8VideoRTPSink::specialHeaderSize() const {
00066   // We include only the required 1-byte form of the "VP8 Payload Descriptor":
00067   return 1;
00068 }

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