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