OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 LayerFilteringTransport::LayerFilteringTransport( | 22 LayerFilteringTransport::LayerFilteringTransport( |
23 const FakeNetworkPipe::Config& config, | 23 const FakeNetworkPipe::Config& config, |
24 uint8_t vp8_video_payload_type, | 24 uint8_t vp8_video_payload_type, |
25 uint8_t vp9_video_payload_type, | 25 uint8_t vp9_video_payload_type, |
26 uint8_t tl_discard_threshold, | 26 uint8_t tl_discard_threshold, |
27 uint8_t sl_discard_threshold) | 27 uint8_t sl_discard_threshold) |
28 : test::DirectTransport(config), | 28 : test::DirectTransport(config), |
29 vp8_video_payload_type_(vp8_video_payload_type), | 29 vp8_video_payload_type_(vp8_video_payload_type), |
30 vp9_video_payload_type_(vp9_video_payload_type), | 30 vp9_video_payload_type_(vp9_video_payload_type), |
31 tl_discard_threshold_(tl_discard_threshold), | 31 tl_discard_threshold_(tl_discard_threshold), |
32 sl_discard_threshold_(sl_discard_threshold), | 32 sl_discard_threshold_(sl_discard_threshold) { |
33 current_seq_num_(10000) { | 33 } |
34 } // TODO(ivica): random seq num? | 34 |
| 35 uint16_t LayerFilteringTransport::NextSequenceNumber(uint32_t ssrc) { |
| 36 auto it = current_seq_nums_.find(ssrc); |
| 37 if (it == current_seq_nums_.end()) |
| 38 return current_seq_nums_[ssrc] = 10000; |
| 39 return ++it->second; |
| 40 } |
35 | 41 |
36 bool LayerFilteringTransport::SendRtp(const uint8_t* packet, | 42 bool LayerFilteringTransport::SendRtp(const uint8_t* packet, |
37 size_t length, | 43 size_t length, |
38 const PacketOptions& options) { | 44 const PacketOptions& options) { |
39 if (tl_discard_threshold_ == 0 && sl_discard_threshold_ == 0) { | 45 if (tl_discard_threshold_ == 0 && sl_discard_threshold_ == 0) { |
40 // Nothing to change, forward the packet immediately. | 46 // Nothing to change, forward the packet immediately. |
41 return test::DirectTransport::SendRtp(packet, length, options); | 47 return test::DirectTransport::SendRtp(packet, length, options); |
42 } | 48 } |
43 | 49 |
44 bool set_marker_bit = false; | 50 bool set_marker_bit = false; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 RTC_NOTREACHED() << "Parse error"; | 87 RTC_NOTREACHED() << "Parse error"; |
82 } | 88 } |
83 } | 89 } |
84 | 90 |
85 uint8_t temp_buffer[IP_PACKET_SIZE]; | 91 uint8_t temp_buffer[IP_PACKET_SIZE]; |
86 memcpy(temp_buffer, packet, length); | 92 memcpy(temp_buffer, packet, length); |
87 | 93 |
88 // We are discarding some of the packets (specifically, whole layers), so | 94 // We are discarding some of the packets (specifically, whole layers), so |
89 // make sure the marker bit is set properly, and that sequence numbers are | 95 // make sure the marker bit is set properly, and that sequence numbers are |
90 // continuous. | 96 // continuous. |
91 if (set_marker_bit) { | 97 if (set_marker_bit) |
92 temp_buffer[1] |= kRtpMarkerBitMask; | 98 temp_buffer[1] |= kRtpMarkerBitMask; |
93 } | |
94 ByteWriter<uint16_t>::WriteBigEndian(&temp_buffer[2], current_seq_num_); | |
95 | 99 |
96 ++current_seq_num_; // Increase only if packet not discarded. | 100 uint16_t seq_num = NextSequenceNumber(header.ssrc); |
97 | 101 ByteWriter<uint16_t>::WriteBigEndian(&temp_buffer[2], seq_num); |
98 return test::DirectTransport::SendRtp(temp_buffer, length, options); | 102 return test::DirectTransport::SendRtp(temp_buffer, length, options); |
99 } | 103 } |
100 | 104 |
101 } // namespace test | 105 } // namespace test |
102 } // namespace webrtc | 106 } // namespace webrtc |
OLD | NEW |