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 else | |
sprang_webrtc
2015/09/23 13:58:19
don't need this else
ivica
2015/10/07 12:07:41
Done.
| |
40 return ++it->second; | |
41 } | |
35 | 42 |
36 bool LayerFilteringTransport::SendRtp(const uint8_t* packet, size_t length) { | 43 bool LayerFilteringTransport::SendRtp(const uint8_t* packet, size_t length) { |
37 if (tl_discard_threshold_ == 0 && sl_discard_threshold_ == 0) { | 44 if (tl_discard_threshold_ == 0 && sl_discard_threshold_ == 0) { |
38 // Nothing to change, forward the packet immediately. | 45 // Nothing to change, forward the packet immediately. |
39 return test::DirectTransport::SendRtp(packet, length); | 46 return test::DirectTransport::SendRtp(packet, length); |
40 } | 47 } |
41 | 48 |
42 bool set_marker_bit = false; | 49 bool set_marker_bit = false; |
43 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); | 50 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); |
44 RTPHeader header; | 51 RTPHeader header; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 } | 88 } |
82 | 89 |
83 uint8_t temp_buffer[IP_PACKET_SIZE]; | 90 uint8_t temp_buffer[IP_PACKET_SIZE]; |
84 memcpy(temp_buffer, packet, length); | 91 memcpy(temp_buffer, packet, length); |
85 | 92 |
86 // We are discarding some of the packets (specifically, whole layers), so | 93 // We are discarding some of the packets (specifically, whole layers), so |
87 // make sure the marker bit is set properly, and that sequence numbers are | 94 // make sure the marker bit is set properly, and that sequence numbers are |
88 // continuous. | 95 // continuous. |
89 if (set_marker_bit) { | 96 if (set_marker_bit) { |
90 temp_buffer[1] |= kRtpMarkerBitMask; | 97 temp_buffer[1] |= kRtpMarkerBitMask; |
91 } | 98 } |
sprang_webrtc
2015/09/23 13:58:19
Remove {}
ivica
2015/10/07 12:07:41
Done.
| |
92 ByteWriter<uint16_t>::WriteBigEndian(&temp_buffer[2], current_seq_num_); | |
93 | 99 |
94 ++current_seq_num_; // Increase only if packet not discarded. | 100 uint16_t seq_num = NextSequenceNumber(header.ssrc); |
95 | 101 ByteWriter<uint16_t>::WriteBigEndian(&temp_buffer[2], seq_num); |
96 return test::DirectTransport::SendRtp(temp_buffer, length); | 102 return test::DirectTransport::SendRtp(temp_buffer, length); |
97 } | 103 } |
98 | 104 |
99 } // namespace test | 105 } // namespace test |
100 } // namespace webrtc | 106 } // namespace webrtc |
OLD | NEW |