| 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 18 matching lines...) Expand all Loading... |
| 29 // PayloadRouter routes outgoing data to the correct sending RTP module, based | 29 // PayloadRouter routes outgoing data to the correct sending RTP module, based |
| 30 // on the simulcast layer in RTPVideoHeader. | 30 // on the simulcast layer in RTPVideoHeader. |
| 31 class PayloadRouter { | 31 class PayloadRouter { |
| 32 public: | 32 public: |
| 33 PayloadRouter(); | 33 PayloadRouter(); |
| 34 ~PayloadRouter(); | 34 ~PayloadRouter(); |
| 35 | 35 |
| 36 static size_t DefaultMaxPayloadLength(); | 36 static size_t DefaultMaxPayloadLength(); |
| 37 | 37 |
| 38 // Rtp modules are assumed to be sorted in simulcast index order. | 38 // Rtp modules are assumed to be sorted in simulcast index order. |
| 39 void SetSendingRtpModules(const std::vector<RtpRtcp*>& rtp_modules); | 39 void Init(const std::vector<RtpRtcp*>& rtp_modules); |
| 40 |
| 41 void SetSendingRtpModules(size_t num_sending_modules); |
| 40 | 42 |
| 41 // PayloadRouter will only route packets if being active, all packets will be | 43 // PayloadRouter will only route packets if being active, all packets will be |
| 42 // dropped otherwise. | 44 // dropped otherwise. |
| 43 void set_active(bool active); | 45 void set_active(bool active); |
| 44 bool active(); | 46 bool active(); |
| 45 | 47 |
| 46 // Input parameters according to the signature of RtpRtcp::SendOutgoingData. | 48 // Input parameters according to the signature of RtpRtcp::SendOutgoingData. |
| 47 // Returns true if the packet was routed / sent, false otherwise. | 49 // Returns true if the packet was routed / sent, false otherwise. |
| 48 bool RoutePayload(FrameType frame_type, | 50 bool RoutePayload(FrameType frame_type, |
| 49 int8_t payload_type, | 51 int8_t payload_type, |
| 50 uint32_t time_stamp, | 52 uint32_t time_stamp, |
| 51 int64_t capture_time_ms, | 53 int64_t capture_time_ms, |
| 52 const uint8_t* payload_data, | 54 const uint8_t* payload_data, |
| 53 size_t payload_size, | 55 size_t payload_size, |
| 54 const RTPFragmentationHeader* fragmentation, | 56 const RTPFragmentationHeader* fragmentation, |
| 55 const RTPVideoHeader* rtp_video_hdr); | 57 const RTPVideoHeader* rtp_video_hdr); |
| 56 | 58 |
| 57 // Configures current target bitrate per module. 'stream_bitrates' is assumed | 59 // Configures current target bitrate per module. 'stream_bitrates' is assumed |
| 58 // to be in the same order as 'SetSendingRtpModules'. | 60 // to be in the same order as 'SetSendingRtpModules'. |
| 59 void SetTargetSendBitrates(const std::vector<uint32_t>& stream_bitrates); | 61 void SetTargetSendBitrates(const std::vector<uint32_t>& stream_bitrates); |
| 60 | 62 |
| 61 // Returns the maximum allowed data payload length, given the configured MTU | 63 // Returns the maximum allowed data payload length, given the configured MTU |
| 62 // and RTP headers. | 64 // and RTP headers. |
| 63 size_t MaxPayloadLength() const; | 65 size_t MaxPayloadLength() const; |
| 64 | 66 |
| 65 void AddRef() { ++ref_count_; } | 67 private: |
| 66 void Release() { if (--ref_count_ == 0) { delete this; } } | 68 void UpdateModuleSendingState() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 67 | 69 |
| 68 private: | 70 // TODO(pbos): Set once and for all on construction and make const. |
| 69 // TODO(mflodman): When the new video API has launched, remove crit_ and | 71 std::vector<RtpRtcp*> rtp_modules_; |
| 70 // assume rtp_modules_ will never change during a call. | 72 |
| 71 rtc::CriticalSection crit_; | 73 rtc::CriticalSection crit_; |
| 72 | |
| 73 // Active sending RTP modules, in layer order. | |
| 74 std::vector<RtpRtcp*> rtp_modules_ GUARDED_BY(crit_); | |
| 75 bool active_ GUARDED_BY(crit_); | 74 bool active_ GUARDED_BY(crit_); |
| 76 | 75 size_t num_sending_modules_ GUARDED_BY(crit_); |
| 77 Atomic32 ref_count_; | |
| 78 | 76 |
| 79 RTC_DISALLOW_COPY_AND_ASSIGN(PayloadRouter); | 77 RTC_DISALLOW_COPY_AND_ASSIGN(PayloadRouter); |
| 80 }; | 78 }; |
| 81 | 79 |
| 82 } // namespace webrtc | 80 } // namespace webrtc |
| 83 | 81 |
| 84 #endif // WEBRTC_VIDEO_PAYLOAD_ROUTER_H_ | 82 #endif // WEBRTC_VIDEO_PAYLOAD_ROUTER_H_ |
| OLD | NEW |