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 | // VP8 Video RTP Sources |
19 | // Implementation |
20 | |
21 | #include "VP8VideoRTPSource.hh" |
22 | |
23 | VP8VideoRTPSource* |
24 | VP8VideoRTPSource::createNew(UsageEnvironment& env, Groupsock* RTPgs, |
25 | unsigned char rtpPayloadFormat, |
26 | unsigned rtpTimestampFrequency) { |
27 | return new VP8VideoRTPSource(env, RTPgs, rtpPayloadFormat, |
28 | rtpTimestampFrequency); |
29 | } |
30 | |
31 | VP8VideoRTPSource |
32 | ::VP8VideoRTPSource(UsageEnvironment& env, Groupsock* RTPgs, |
33 | unsigned char rtpPayloadFormat, |
34 | unsigned rtpTimestampFrequency) |
35 | : MultiFramedRTPSource(env, RTPgs, rtpPayloadFormat, rtpTimestampFrequency) { |
36 | } |
37 | |
38 | VP8VideoRTPSource::~VP8VideoRTPSource() { |
39 | } |
40 | |
41 | #define do { ++resultSpecialHeaderSize; ++headerStart; if (--packetSize == 0) return False; } while (0) |
42 | |
43 | Boolean VP8VideoRTPSource |
44 | ::(BufferedPacket* packet, |
45 | unsigned& ) { |
46 | unsigned char* = packet->data(); |
47 | unsigned packetSize = packet->dataSize(); |
48 | |
49 | // The special header is from 1 to 6 bytes long. |
50 | if (packetSize == 0) return False; // error |
51 | resultSpecialHeaderSize = 1; // unless we learn otherwise |
52 | |
53 | u_int8_t const byte1 = *headerStart; |
54 | Boolean const X = (byte1&0x80) != 0; |
55 | Boolean const S = (byte1&0x10) != 0; |
56 | u_int8_t const PartID = byte1&0x0F; |
57 | |
58 | fCurrentPacketBeginsFrame = S && PartID == 0; |
59 | fCurrentPacketCompletesFrame = packet->rtpMarkerBit(); // RTP header's "M" bit |
60 | |
61 | if (X) { |
62 | incrHeader; |
63 | |
64 | u_int8_t const byte2 = *headerStart; |
65 | Boolean const I = (byte2&0x80) != 0; |
66 | Boolean const L = (byte2&0x40) != 0; |
67 | Boolean const T = (byte2&0x20) != 0; |
68 | Boolean const K = (byte2&0x10) != 0; |
69 | |
70 | if (I) { |
71 | incrHeader; |
72 | if ((*headerStart)&0x80) { // extension flag in the PictureID is set |
73 | incrHeader; |
74 | } |
75 | } |
76 | |
77 | if (L) incrHeader; |
78 | if (T||K) incrHeader; |
79 | } |
80 | |
81 | return True; |
82 | } |
83 | |
84 | char const* VP8VideoRTPSource::MIMEtype() const { |
85 | return "video/VP8" ; |
86 | } |
87 | |