| 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 #ifndef WEBRTC_MODULES_PACING_PACKET_ROUTER_H_ | 11 #ifndef WEBRTC_MODULES_PACING_PACKET_ROUTER_H_ |
| 12 #define WEBRTC_MODULES_PACING_PACKET_ROUTER_H_ | 12 #define WEBRTC_MODULES_PACING_PACKET_ROUTER_H_ |
| 13 | 13 |
| 14 #include <list> | 14 #include <list> |
| 15 #include <vector> |
| 15 | 16 |
| 16 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
| 17 #include "webrtc/base/criticalsection.h" | 18 #include "webrtc/base/criticalsection.h" |
| 18 #include "webrtc/base/thread_annotations.h" | 19 #include "webrtc/base/thread_annotations.h" |
| 19 #include "webrtc/base/thread_checker.h" | 20 #include "webrtc/base/thread_checker.h" |
| 20 #include "webrtc/common_types.h" | 21 #include "webrtc/common_types.h" |
| 21 #include "webrtc/modules/pacing/paced_sender.h" | 22 #include "webrtc/modules/pacing/paced_sender.h" |
| 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 23 | 24 |
| 24 namespace webrtc { | 25 namespace webrtc { |
| 25 | 26 |
| 26 class RtpRtcp; | 27 class RtpRtcp; |
| 27 namespace rtcp { | 28 namespace rtcp { |
| 28 class TransportFeedback; | 29 class TransportFeedback; |
| 29 } // namespace rtcp | 30 } // namespace rtcp |
| 30 | 31 |
| 31 // PacketRouter routes outgoing data to the correct sending RTP module, based | 32 // PacketRouter keeps track of rtp send modules to support the pacer. |
| 32 // on the simulcast layer in RTPVideoHeader. | 33 // In addition, it handles feedback messages, which are sent on a send |
| 34 // module if possible (sender report), otherwise on receive module |
| 35 // (receiver report). For the latter case, we also keep track of the |
| 36 // receive modules. |
| 33 class PacketRouter : public PacedSender::PacketSender, | 37 class PacketRouter : public PacedSender::PacketSender, |
| 34 public TransportSequenceNumberAllocator { | 38 public TransportSequenceNumberAllocator { |
| 35 public: | 39 public: |
| 36 PacketRouter(); | 40 PacketRouter(); |
| 37 virtual ~PacketRouter(); | 41 virtual ~PacketRouter(); |
| 38 | 42 |
| 39 void AddRtpModule(RtpRtcp* rtp_module); | 43 // TODO(nisse): Delete, as soon as downstream app is updated. |
| 40 void RemoveRtpModule(RtpRtcp* rtp_module); | 44 RTC_DEPRECATED void AddRtpModule(RtpRtcp* rtp_module) { |
| 45 AddReceiveRtpModule(rtp_module); |
| 46 } |
| 47 RTC_DEPRECATED void RemoveRtpModule(RtpRtcp* rtp_module) { |
| 48 RemoveReceiveRtpModule(rtp_module); |
| 49 } |
| 50 void AddSendRtpModule(RtpRtcp* rtp_module); |
| 51 void RemoveSendRtpModule(RtpRtcp* rtp_module); |
| 52 |
| 53 void AddReceiveRtpModule(RtpRtcp* rtp_module); |
| 54 void RemoveReceiveRtpModule(RtpRtcp* rtp_module); |
| 41 | 55 |
| 42 // Implements PacedSender::Callback. | 56 // Implements PacedSender::Callback. |
| 43 bool TimeToSendPacket(uint32_t ssrc, | 57 bool TimeToSendPacket(uint32_t ssrc, |
| 44 uint16_t sequence_number, | 58 uint16_t sequence_number, |
| 45 int64_t capture_timestamp, | 59 int64_t capture_timestamp, |
| 46 bool retransmission, | 60 bool retransmission, |
| 47 const PacedPacketInfo& packet_info) override; | 61 const PacedPacketInfo& packet_info) override; |
| 48 | 62 |
| 49 size_t TimeToSendPadding(size_t bytes, | 63 size_t TimeToSendPadding(size_t bytes, |
| 50 const PacedPacketInfo& packet_info) override; | 64 const PacedPacketInfo& packet_info) override; |
| 51 | 65 |
| 52 void SetTransportWideSequenceNumber(uint16_t sequence_number); | 66 void SetTransportWideSequenceNumber(uint16_t sequence_number); |
| 53 uint16_t AllocateSequenceNumber() override; | 67 uint16_t AllocateSequenceNumber() override; |
| 54 | 68 |
| 55 // Send transport feedback packet to send-side. | 69 // Send transport feedback packet to send-side. |
| 56 virtual bool SendFeedback(rtcp::TransportFeedback* packet); | 70 virtual bool SendFeedback(rtcp::TransportFeedback* packet); |
| 57 | 71 |
| 58 private: | 72 private: |
| 59 rtc::ThreadChecker pacer_thread_checker_; | 73 rtc::ThreadChecker pacer_thread_checker_; |
| 60 rtc::CriticalSection modules_crit_; | 74 rtc::CriticalSection modules_crit_; |
| 61 std::list<RtpRtcp*> rtp_modules_ GUARDED_BY(modules_crit_); | 75 std::list<RtpRtcp*> rtp_send_modules_ GUARDED_BY(modules_crit_); |
| 76 std::vector<RtpRtcp*> rtp_receive_modules_ GUARDED_BY(modules_crit_); |
| 62 | 77 |
| 63 volatile int transport_seq_; | 78 volatile int transport_seq_; |
| 64 | 79 |
| 65 RTC_DISALLOW_COPY_AND_ASSIGN(PacketRouter); | 80 RTC_DISALLOW_COPY_AND_ASSIGN(PacketRouter); |
| 66 }; | 81 }; |
| 67 } // namespace webrtc | 82 } // namespace webrtc |
| 68 #endif // WEBRTC_MODULES_PACING_PACKET_ROUTER_H_ | 83 #endif // WEBRTC_MODULES_PACING_PACKET_ROUTER_H_ |
| OLD | NEW |