1 | /********** |
2 | This library is free software; you can redistribute it and/or modify it under |
3 | the terms of the GNU Lesser General Public License as published by the |
4 | Free Software Foundation; either version 3 of the License, or (at your |
5 | option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) |
6 | |
7 | This library is distributed in the hope that it will be useful, but WITHOUT |
8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
10 | more details. |
11 | |
12 | You should have received a copy of the GNU Lesser General Public License |
13 | along with this library; if not, write to the Free Software Foundation, Inc., |
14 | 51 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 | |
23 | VP8VideoRTPSink |
24 | ::VP8VideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat) |
25 | : VideoRTPSink(env, RTPgs, rtpPayloadFormat, 90000, "VP8" ) { |
26 | } |
27 | |
28 | VP8VideoRTPSink::~VP8VideoRTPSink() { |
29 | } |
30 | |
31 | VP8VideoRTPSink* |
32 | VP8VideoRTPSink::createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat) { |
33 | return new VP8VideoRTPSink(env, RTPgs, rtpPayloadFormat); |
34 | } |
35 | |
36 | Boolean VP8VideoRTPSink |
37 | ::frameCanAppearAfterPacketStart(unsigned char const* /*frameStart*/, |
38 | unsigned /*numBytesInFrame*/) const { |
39 | // A packet can contain only one frame |
40 | return False; |
41 | } |
42 | |
43 | void 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 | |
65 | unsigned VP8VideoRTPSink::() const { |
66 | // We include only the required 1-byte form of the "VP8 Payload Descriptor": |
67 | return 1; |
68 | } |
69 | |