1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// "liveMedia"
17// Copyright (c) 1996-2020 Live Networks, Inc. All rights reserved.
18// RTP sink for VP8 video
19// Implementation
20
21#include "VP8VideoRTPSink.hh"
22
23VP8VideoRTPSink
24::VP8VideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat)
25 : VideoRTPSink(env, RTPgs, rtpPayloadFormat, 90000, "VP8") {
26}
27
28VP8VideoRTPSink::~VP8VideoRTPSink() {
29}
30
31VP8VideoRTPSink*
32VP8VideoRTPSink::createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat) {
33 return new VP8VideoRTPSink(env, RTPgs, rtpPayloadFormat);
34}
35
36Boolean VP8VideoRTPSink
37::frameCanAppearAfterPacketStart(unsigned char const* /*frameStart*/,
38 unsigned /*numBytesInFrame*/) const {
39 // A packet can contain only one frame
40 return False;
41}
42
43void VP8VideoRTPSink
44::doSpecialFrameHandling(unsigned fragmentationOffset,
45 unsigned char* /*frameStart*/,
46 unsigned /*numBytesInFrame*/,
47 struct timeval framePresentationTime,
48 unsigned numRemainingBytes) {
49 // Set the "VP8 Payload Descriptor" (just the minimal required 1-byte version):
50 u_int8_t vp8PayloadDescriptor = fragmentationOffset == 0 ? 0x10 : 0x00;
51 // X = R = N = 0; PartID = 0; S = 1 iff this is the first (or only) fragment of the frame
52 setSpecialHeaderBytes(&vp8PayloadDescriptor, 1);
53
54 if (numRemainingBytes == 0) {
55 // This packet contains the last (or only) fragment of the frame.
56 // Set the RTP 'M' ('marker') bit:
57 setMarkerBit();
58 }
59
60 // Also set the RTP timestamp:
61 setTimestamp(framePresentationTime);
62}
63
64
65unsigned VP8VideoRTPSink::specialHeaderSize() const {
66 // We include only the required 1-byte form of the "VP8 Payload Descriptor":
67 return 1;
68}
69