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 VP9 video |
19 | // Implementation |
20 | |
21 | #include "VP9VideoRTPSink.hh" |
22 | |
23 | VP9VideoRTPSink |
24 | ::VP9VideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat) |
25 | : VideoRTPSink(env, RTPgs, rtpPayloadFormat, 90000, "VP9" ) { |
26 | } |
27 | |
28 | VP9VideoRTPSink::~VP9VideoRTPSink() { |
29 | } |
30 | |
31 | VP9VideoRTPSink* |
32 | VP9VideoRTPSink::createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat) { |
33 | return new VP9VideoRTPSink(env, RTPgs, rtpPayloadFormat); |
34 | } |
35 | |
36 | Boolean VP9VideoRTPSink |
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 VP9VideoRTPSink |
44 | ::doSpecialFrameHandling(unsigned fragmentationOffset, |
45 | unsigned char* /*frameStart*/, |
46 | unsigned /*numBytesInFrame*/, |
47 | struct timeval framePresentationTime, |
48 | unsigned numRemainingBytes) { |
49 | // Set the "VP9 Payload Descriptor" (just the minimal required 1-byte version): |
50 | u_int8_t vp9PayloadDescriptor = fragmentationOffset == 0 ? 0x10 : 0x00; |
51 | // I = L = F = V = U = 0; S = 1 iff this is the first (or only) fragment of the frame |
52 | |
53 | if (numRemainingBytes == 0) { |
54 | // This packet contains the last (or only) fragment of the frame. |
55 | // Set the E bit: |
56 | vp9PayloadDescriptor |= 0x08; |
57 | // Also set the RTP 'M' ('marker') bit: |
58 | setMarkerBit(); |
59 | } |
60 | |
61 | setSpecialHeaderBytes(&vp9PayloadDescriptor, 1); |
62 | |
63 | // Also set the RTP timestamp: |
64 | setTimestamp(framePresentationTime); |
65 | } |
66 | |
67 | |
68 | unsigned VP9VideoRTPSink::() const { |
69 | // We include only the required 1-byte form of the "VP9 Payload Descriptor": |
70 | return 1; |
71 | } |
72 | |