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 |
11 #include "webrtc/video/payload_router.h" | 11 #include "webrtc/video/payload_router.h" |
12 | 12 |
13 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
14 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 14 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
15 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 15 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 | 18 |
19 PayloadRouter::PayloadRouter() | 19 PayloadRouter::PayloadRouter(const std::vector<RtpRtcp*>& rtp_modules) |
20 : active_(false), num_sending_modules_(0) {} | 20 : active_(false), num_sending_modules_(1), rtp_modules_(rtp_modules) { |
| 21 UpdateModuleSendingState(); |
| 22 } |
21 | 23 |
22 PayloadRouter::~PayloadRouter() {} | 24 PayloadRouter::~PayloadRouter() {} |
23 | 25 |
24 size_t PayloadRouter::DefaultMaxPayloadLength() { | 26 size_t PayloadRouter::DefaultMaxPayloadLength() { |
25 const size_t kIpUdpSrtpLength = 44; | 27 const size_t kIpUdpSrtpLength = 44; |
26 return IP_PACKET_SIZE - kIpUdpSrtpLength; | 28 return IP_PACKET_SIZE - kIpUdpSrtpLength; |
27 } | 29 } |
28 | 30 |
29 void PayloadRouter::Init( | |
30 const std::vector<RtpRtcp*>& rtp_modules) { | |
31 RTC_DCHECK(rtp_modules_.empty()); | |
32 rtp_modules_ = rtp_modules; | |
33 } | |
34 | |
35 void PayloadRouter::set_active(bool active) { | 31 void PayloadRouter::set_active(bool active) { |
36 rtc::CritScope lock(&crit_); | 32 rtc::CritScope lock(&crit_); |
37 if (active_ == active) | 33 if (active_ == active) |
38 return; | 34 return; |
39 active_ = active; | 35 active_ = active; |
40 UpdateModuleSendingState(); | 36 UpdateModuleSendingState(); |
41 } | 37 } |
42 | 38 |
43 bool PayloadRouter::active() { | 39 bool PayloadRouter::active() { |
44 rtc::CritScope lock(&crit_); | 40 rtc::CritScope lock(&crit_); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 rtc::CritScope lock(&crit_); | 101 rtc::CritScope lock(&crit_); |
106 for (size_t i = 0; i < num_sending_modules_; ++i) { | 102 for (size_t i = 0; i < num_sending_modules_; ++i) { |
107 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength(); | 103 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength(); |
108 if (module_payload_length < min_payload_length) | 104 if (module_payload_length < min_payload_length) |
109 min_payload_length = module_payload_length; | 105 min_payload_length = module_payload_length; |
110 } | 106 } |
111 return min_payload_length; | 107 return min_payload_length; |
112 } | 108 } |
113 | 109 |
114 } // namespace webrtc | 110 } // namespace webrtc |
OLD | NEW |