OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | |
10 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" |
12 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" | |
danilchap
2016/07/04 09:57:49
just noticed this includes are not in alphabetical
| |
13 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" | |
11 | 14 |
12 namespace webrtc { | 15 namespace webrtc { |
13 | 16 |
17 // We decide which header extensions to register by reading one byte | |
18 // from the beginning of |data| and interpreting it as a bitmask over | |
19 // the RTPExtensionType enum. This assert ensures one byte is enough. | |
20 static_assert(kRtpExtensionNumberOfExtensions <= 8, | |
21 "Insufficient bits read to configure all header extensions. Add " | |
22 "an extra byte and update the switches."); | |
23 | |
14 void FuzzOneInput(const uint8_t* data, size_t size) { | 24 void FuzzOneInput(const uint8_t* data, size_t size) { |
15 RtpPacketReceived packet; | 25 if (size <= 1) |
26 return; | |
16 | 27 |
28 // Don't use the configuration byte as part of the packet. | |
29 std::bitset<8> extensionMask(data[0]); | |
30 data++; | |
31 size--; | |
32 | |
33 RtpPacketReceived::ExtensionManager extensions; | |
34 for (int i = 0; i < kRtpExtensionNumberOfExtensions; i++) { | |
35 RTPExtensionType extension_type = static_cast<RTPExtensionType>(i); | |
36 if (extensionMask[i] && extension_type != kRtpExtensionNone) { | |
37 // Extensions are registered with an ID, which you signal to the | |
38 // peer so they know what to expect. This code only cares about | |
39 // parsing so the value of the ID isn't relevant; we use i. | |
40 extensions.Register(extension_type, i); | |
41 } | |
42 } | |
43 | |
44 RtpPacketReceived packet(&extensions); | |
17 packet.Parse(data, size); | 45 packet.Parse(data, size); |
18 | 46 |
19 // Call packet accessors because they have extra checks. | 47 // Call packet accessors because they have extra checks. |
20 packet.Marker(); | 48 packet.Marker(); |
21 packet.PayloadType(); | 49 packet.PayloadType(); |
22 packet.SequenceNumber(); | 50 packet.SequenceNumber(); |
23 packet.Timestamp(); | 51 packet.Timestamp(); |
24 packet.Ssrc(); | 52 packet.Ssrc(); |
25 packet.Csrcs(); | 53 packet.Csrcs(); |
54 | |
55 // Each extension has its own getter. It is supported behaviour to | |
56 // call GetExtension on an extension which was not registered, so we | |
57 // don't check the bitmask here. | |
58 for (int i = 0; i < kRtpExtensionNumberOfExtensions; i++) { | |
59 switch (static_cast<RTPExtensionType>(i)) { | |
60 case kRtpExtensionNone: | |
61 case kRtpExtensionNumberOfExtensions: | |
62 break; | |
63 case kRtpExtensionTransmissionTimeOffset: | |
64 int32_t offset; | |
65 packet.GetExtension<TransmissionOffset>(&offset); | |
66 break; | |
67 case kRtpExtensionAudioLevel: | |
68 bool voice_activity; | |
69 uint8_t audio_level; | |
70 packet.GetExtension<AudioLevel>(&voice_activity, &audio_level); | |
71 break; | |
72 case kRtpExtensionAbsoluteSendTime: | |
73 uint32_t sendtime; | |
74 packet.GetExtension<AbsoluteSendTime>(&sendtime); | |
75 break; | |
76 case kRtpExtensionVideoRotation: | |
77 uint8_t rotation; | |
78 packet.GetExtension<VideoOrientation>(&rotation); | |
79 break; | |
80 case kRtpExtensionTransportSequenceNumber: | |
81 uint16_t seqnum; | |
82 packet.GetExtension<TransportSequenceNumber>(&seqnum); | |
83 break; | |
84 case kRtpExtensionPlayoutDelay: | |
85 // TODO(katrielc) Add this once it's written. | |
86 break; | |
87 } | |
88 } | |
26 } | 89 } |
27 | |
28 } // namespace webrtc | 90 } // namespace webrtc |
29 | |
OLD | NEW |