| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 24 matching lines...) Expand all Loading... |
| 35 class Config; | 35 class Config; |
| 36 class EncodedImageCallback; | 36 class EncodedImageCallback; |
| 37 class I420FrameCallback; | 37 class I420FrameCallback; |
| 38 class IncomingVideoStream; | 38 class IncomingVideoStream; |
| 39 class PacedSender; | 39 class PacedSender; |
| 40 class PacketRouter; | 40 class PacketRouter; |
| 41 class PayloadRouter; | 41 class PayloadRouter; |
| 42 class ProcessThread; | 42 class ProcessThread; |
| 43 class ReceiveStatisticsProxy; | 43 class ReceiveStatisticsProxy; |
| 44 class RtcpRttStats; | 44 class RtcpRttStats; |
| 45 class ViEChannelProtectionCallback; | |
| 46 class ViERTPObserver; | 45 class ViERTPObserver; |
| 47 class VideoCodingModule; | 46 class VideoCodingModule; |
| 48 class VideoRenderCallback; | 47 class VideoRenderCallback; |
| 49 class VoEVideoSync; | 48 class VoEVideoSync; |
| 50 | 49 |
| 51 enum StreamType { | 50 enum StreamType { |
| 52 kViEStreamTypeNormal = 0, // Normal media stream | 51 kViEStreamTypeNormal = 0, // Normal media stream |
| 53 kViEStreamTypeRtx = 1 // Retransmission media stream | 52 kViEStreamTypeRtx = 1 // Retransmission media stream |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 class ViEChannel : public VCMFrameTypeCallback, | 55 class ViEChannel : public VCMFrameTypeCallback, |
| 57 public VCMReceiveCallback, | 56 public VCMReceiveCallback, |
| 58 public VCMReceiveStatisticsCallback, | 57 public VCMReceiveStatisticsCallback, |
| 59 public VCMDecoderTimingCallback, | 58 public VCMDecoderTimingCallback, |
| 60 public VCMPacketRequestCallback, | 59 public VCMPacketRequestCallback, |
| 61 public RtpFeedback { | 60 public RtpFeedback { |
| 62 public: | 61 public: |
| 63 friend class ChannelStatsObserver; | 62 friend class ChannelStatsObserver; |
| 64 friend class ViEChannelProtectionCallback; | |
| 65 | 63 |
| 66 ViEChannel(Transport* transport, | 64 ViEChannel(Transport* transport, |
| 67 ProcessThread* module_process_thread, | 65 ProcessThread* module_process_thread, |
| 68 PayloadRouter* send_payload_router, | |
| 69 VideoCodingModule* vcm, | 66 VideoCodingModule* vcm, |
| 70 RtcpIntraFrameObserver* intra_frame_observer, | |
| 71 RtcpBandwidthObserver* bandwidth_observer, | |
| 72 TransportFeedbackObserver* transport_feedback_observer, | |
| 73 RemoteBitrateEstimator* remote_bitrate_estimator, | 67 RemoteBitrateEstimator* remote_bitrate_estimator, |
| 74 RtcpRttStats* rtt_stats, | 68 RtcpRttStats* rtt_stats, |
| 75 PacedSender* paced_sender, | 69 PacedSender* paced_sender, |
| 76 PacketRouter* packet_router, | 70 PacketRouter* packet_router); |
| 77 size_t max_rtp_streams, | |
| 78 bool sender); | |
| 79 ~ViEChannel(); | 71 ~ViEChannel(); |
| 80 | 72 |
| 81 int32_t Init(); | 73 int32_t Init(); |
| 82 | 74 |
| 83 void SetProtectionMode(bool enable_nack, | 75 void SetProtectionMode(bool enable_nack, |
| 84 bool enable_fec, | 76 bool enable_fec, |
| 85 int payload_type_red, | 77 int payload_type_red, |
| 86 int payload_type_fec); | 78 int payload_type_fec); |
| 87 | 79 |
| 88 RtpState GetRtpStateForSsrc(uint32_t ssrc) const; | 80 RtpState GetRtpStateForSsrc(uint32_t ssrc) const; |
| 89 | 81 |
| 90 // Gets send statistics for the rtp and rtx stream. | |
| 91 void GetSendStreamDataCounters(StreamDataCounters* rtp_counters, | |
| 92 StreamDataCounters* rtx_counters) const; | |
| 93 | |
| 94 void RegisterSendSideDelayObserver(SendSideDelayObserver* observer); | |
| 95 | |
| 96 // Called on any new send bitrate estimate. | |
| 97 void RegisterSendBitrateObserver(BitrateStatisticsObserver* observer); | |
| 98 | |
| 99 // Implements RtpFeedback. | 82 // Implements RtpFeedback. |
| 100 int32_t OnInitializeDecoder(const int8_t payload_type, | 83 int32_t OnInitializeDecoder(const int8_t payload_type, |
| 101 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 84 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 102 const int frequency, | 85 const int frequency, |
| 103 const size_t channels, | 86 const size_t channels, |
| 104 const uint32_t rate) override; | 87 const uint32_t rate) override; |
| 105 void OnIncomingSSRCChanged(const uint32_t ssrc) override; | 88 void OnIncomingSSRCChanged(const uint32_t ssrc) override; |
| 106 void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override; | 89 void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override; |
| 107 | 90 |
| 108 // Gets the modules used by the channel. | 91 // Gets the module used by the channel. |
| 109 const std::vector<RtpRtcp*>& rtp_rtcp() const; | 92 RtpRtcp* rtp_rtcp() const; |
| 110 ViEReceiver* vie_receiver(); | 93 ViEReceiver* vie_receiver(); |
| 111 VCMProtectionCallback* vcm_protection_callback(); | |
| 112 | |
| 113 | 94 |
| 114 CallStatsObserver* GetStatsObserver(); | 95 CallStatsObserver* GetStatsObserver(); |
| 115 | 96 |
| 116 // Implements VCMReceiveCallback. | 97 // Implements VCMReceiveCallback. |
| 117 virtual int32_t FrameToRender(VideoFrame& video_frame); // NOLINT | 98 virtual int32_t FrameToRender(VideoFrame& video_frame); // NOLINT |
| 118 | 99 |
| 119 // Implements VCMReceiveCallback. | 100 // Implements VCMReceiveCallback. |
| 120 virtual int32_t ReceivedDecodedReferenceFrame( | 101 virtual int32_t ReceivedDecodedReferenceFrame( |
| 121 const uint64_t picture_id); | 102 const uint64_t picture_id); |
| 122 | 103 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 144 // Implements FrameTypeCallback. | 125 // Implements FrameTypeCallback. |
| 145 virtual int32_t SliceLossIndicationRequest( | 126 virtual int32_t SliceLossIndicationRequest( |
| 146 const uint64_t picture_id); | 127 const uint64_t picture_id); |
| 147 | 128 |
| 148 // Implements VideoPacketRequestCallback. | 129 // Implements VideoPacketRequestCallback. |
| 149 int32_t ResendPackets(const uint16_t* sequence_numbers, | 130 int32_t ResendPackets(const uint16_t* sequence_numbers, |
| 150 uint16_t length) override; | 131 uint16_t length) override; |
| 151 | 132 |
| 152 void RegisterPreRenderCallback(I420FrameCallback* pre_render_callback); | 133 void RegisterPreRenderCallback(I420FrameCallback* pre_render_callback); |
| 153 | 134 |
| 154 void RegisterSendFrameCountObserver(FrameCountObserver* observer); | |
| 155 void RegisterRtcpPacketTypeCounterObserver( | 135 void RegisterRtcpPacketTypeCounterObserver( |
| 156 RtcpPacketTypeCounterObserver* observer); | 136 RtcpPacketTypeCounterObserver* observer); |
| 157 void RegisterReceiveStatisticsProxy( | 137 void RegisterReceiveStatisticsProxy( |
| 158 ReceiveStatisticsProxy* receive_statistics_proxy); | 138 ReceiveStatisticsProxy* receive_statistics_proxy); |
| 159 void SetIncomingVideoStream(IncomingVideoStream* incoming_video_stream); | 139 void SetIncomingVideoStream(IncomingVideoStream* incoming_video_stream); |
| 160 | 140 |
| 161 protected: | 141 protected: |
| 162 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms); | 142 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms); |
| 163 | 143 |
| 164 int ProtectionRequest(const FecProtectionParams* delta_fec_params, | |
| 165 const FecProtectionParams* key_fec_params, | |
| 166 uint32_t* sent_video_rate_bps, | |
| 167 uint32_t* sent_nack_rate_bps, | |
| 168 uint32_t* sent_fec_rate_bps); | |
| 169 | |
| 170 private: | 144 private: |
| 171 static std::vector<RtpRtcp*> CreateRtpRtcpModules( | |
| 172 bool receiver_only, | |
| 173 ReceiveStatistics* receive_statistics, | |
| 174 Transport* outgoing_transport, | |
| 175 RtcpIntraFrameObserver* intra_frame_callback, | |
| 176 RtcpBandwidthObserver* bandwidth_callback, | |
| 177 TransportFeedbackObserver* transport_feedback_callback, | |
| 178 RtcpRttStats* rtt_stats, | |
| 179 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer, | |
| 180 RemoteBitrateEstimator* remote_bitrate_estimator, | |
| 181 RtpPacketSender* paced_sender, | |
| 182 TransportSequenceNumberAllocator* transport_sequence_number_allocator, | |
| 183 BitrateStatisticsObserver* send_bitrate_observer, | |
| 184 FrameCountObserver* send_frame_count_observer, | |
| 185 SendSideDelayObserver* send_side_delay_observer, | |
| 186 size_t num_modules); | |
| 187 | |
| 188 // Assumed to be protected. | 145 // Assumed to be protected. |
| 189 void StartDecodeThread(); | 146 void StartDecodeThread(); |
| 190 void StopDecodeThread(); | 147 void StopDecodeThread(); |
| 191 | 148 |
| 192 void ProcessNACKRequest(const bool enable); | 149 void ProcessNACKRequest(const bool enable); |
| 193 // Compute NACK list parameters for the buffering mode. | 150 // Compute NACK list parameters for the buffering mode. |
| 194 int GetRequiredNackListSize(int target_delay_ms); | 151 int GetRequiredNackListSize(int target_delay_ms); |
| 195 | 152 |
| 196 // ViEChannel exposes methods that allow to modify observers and callbacks | 153 // ViEChannel exposes methods that allow to modify observers and callbacks |
| 197 // to be modified. Such an API-style is cumbersome to implement and maintain | 154 // to be modified. Such an API-style is cumbersome to implement and maintain |
| (...skipping 14 matching lines...) Expand all Loading... |
| 212 // Note: this should be implemented with a RW-lock to allow simultaneous | 169 // Note: this should be implemented with a RW-lock to allow simultaneous |
| 213 // calls into the callback. However that doesn't seem to be needed for the | 170 // calls into the callback. However that doesn't seem to be needed for the |
| 214 // current type of callbacks covered by this class. | 171 // current type of callbacks covered by this class. |
| 215 rtc::CriticalSection critsect_; | 172 rtc::CriticalSection critsect_; |
| 216 T* callback_ GUARDED_BY(critsect_); | 173 T* callback_ GUARDED_BY(critsect_); |
| 217 | 174 |
| 218 private: | 175 private: |
| 219 RTC_DISALLOW_COPY_AND_ASSIGN(RegisterableCallback); | 176 RTC_DISALLOW_COPY_AND_ASSIGN(RegisterableCallback); |
| 220 }; | 177 }; |
| 221 | 178 |
| 222 class RegisterableBitrateStatisticsObserver: | |
| 223 public RegisterableCallback<BitrateStatisticsObserver> { | |
| 224 virtual void Notify(const BitrateStatistics& total_stats, | |
| 225 const BitrateStatistics& retransmit_stats, | |
| 226 uint32_t ssrc) { | |
| 227 rtc::CritScope lock(&critsect_); | |
| 228 if (callback_) | |
| 229 callback_->Notify(total_stats, retransmit_stats, ssrc); | |
| 230 } | |
| 231 } send_bitrate_observer_; | |
| 232 | |
| 233 class RegisterableFrameCountObserver | |
| 234 : public RegisterableCallback<FrameCountObserver> { | |
| 235 public: | |
| 236 virtual void FrameCountUpdated(const FrameCounts& frame_counts, | |
| 237 uint32_t ssrc) { | |
| 238 rtc::CritScope lock(&critsect_); | |
| 239 if (callback_) | |
| 240 callback_->FrameCountUpdated(frame_counts, ssrc); | |
| 241 } | |
| 242 | |
| 243 private: | |
| 244 } send_frame_count_observer_; | |
| 245 | |
| 246 class RegisterableSendSideDelayObserver : | |
| 247 public RegisterableCallback<SendSideDelayObserver> { | |
| 248 void SendSideDelayUpdated(int avg_delay_ms, | |
| 249 int max_delay_ms, | |
| 250 uint32_t ssrc) override { | |
| 251 rtc::CritScope lock(&critsect_); | |
| 252 if (callback_) | |
| 253 callback_->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); | |
| 254 } | |
| 255 } send_side_delay_observer_; | |
| 256 | |
| 257 class RegisterableRtcpPacketTypeCounterObserver | 179 class RegisterableRtcpPacketTypeCounterObserver |
| 258 : public RegisterableCallback<RtcpPacketTypeCounterObserver> { | 180 : public RegisterableCallback<RtcpPacketTypeCounterObserver> { |
| 259 public: | 181 public: |
| 260 void RtcpPacketTypesCounterUpdated( | 182 void RtcpPacketTypesCounterUpdated( |
| 261 uint32_t ssrc, | 183 uint32_t ssrc, |
| 262 const RtcpPacketTypeCounter& packet_counter) override { | 184 const RtcpPacketTypeCounter& packet_counter) override { |
| 263 rtc::CritScope lock(&critsect_); | 185 rtc::CritScope lock(&critsect_); |
| 264 if (callback_) | 186 if (callback_) |
| 265 callback_->RtcpPacketTypesCounterUpdated(ssrc, packet_counter); | 187 callback_->RtcpPacketTypesCounterUpdated(ssrc, packet_counter); |
| 266 } | 188 } |
| 267 | 189 |
| 268 private: | 190 private: |
| 269 } rtcp_packet_type_counter_observer_; | 191 } rtcp_packet_type_counter_observer_; |
| 270 | 192 |
| 271 const bool sender_; | |
| 272 | 193 |
| 273 ProcessThread* const module_process_thread_; | 194 ProcessThread* const module_process_thread_; |
| 274 PayloadRouter* const send_payload_router_; | |
| 275 | 195 |
| 276 // Used for all registered callbacks except rendering. | 196 // Used for all registered callbacks except rendering. |
| 277 rtc::CriticalSection crit_; | 197 rtc::CriticalSection crit_; |
| 278 | 198 |
| 279 // Owned modules/classes. | |
| 280 std::unique_ptr<ViEChannelProtectionCallback> vcm_protection_callback_; | |
| 281 | |
| 282 VideoCodingModule* const vcm_; | 199 VideoCodingModule* const vcm_; |
| 283 ViEReceiver vie_receiver_; | 200 ViEReceiver vie_receiver_; |
| 284 | 201 |
| 285 // Helper to report call statistics. | 202 // Helper to report call statistics. |
| 286 std::unique_ptr<ChannelStatsObserver> stats_observer_; | 203 std::unique_ptr<ChannelStatsObserver> stats_observer_; |
| 287 | 204 |
| 288 // Not owned. | 205 // Not owned. |
| 289 ReceiveStatisticsProxy* receive_stats_callback_ GUARDED_BY(crit_); | 206 ReceiveStatisticsProxy* receive_stats_callback_ GUARDED_BY(crit_); |
| 290 FrameCounts receive_frame_counts_ GUARDED_BY(crit_); | 207 FrameCounts receive_frame_counts_ GUARDED_BY(crit_); |
| 291 IncomingVideoStream* incoming_video_stream_ GUARDED_BY(crit_); | 208 IncomingVideoStream* incoming_video_stream_ GUARDED_BY(crit_); |
| 292 RtcpIntraFrameObserver* const intra_frame_observer_; | |
| 293 RtcpRttStats* const rtt_stats_; | 209 RtcpRttStats* const rtt_stats_; |
| 294 PacedSender* const paced_sender_; | 210 PacedSender* const paced_sender_; |
| 295 PacketRouter* const packet_router_; | 211 PacketRouter* const packet_router_; |
| 296 | 212 |
| 297 const std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_; | |
| 298 TransportFeedbackObserver* const transport_feedback_observer_; | |
| 299 | |
| 300 int max_nack_reordering_threshold_; | 213 int max_nack_reordering_threshold_; |
| 301 I420FrameCallback* pre_render_callback_ GUARDED_BY(crit_); | 214 I420FrameCallback* pre_render_callback_ GUARDED_BY(crit_); |
| 302 | 215 |
| 303 int64_t last_rtt_ms_ GUARDED_BY(crit_); | 216 int64_t last_rtt_ms_ GUARDED_BY(crit_); |
| 304 | 217 |
| 305 // RtpRtcp modules, declared last as they use other members on construction. | 218 // RtpRtcp module, declared last as it use other members on construction. |
| 306 const std::vector<RtpRtcp*> rtp_rtcp_modules_; | 219 const std::unique_ptr<RtpRtcp> rtp_rtcp_; |
| 307 }; | 220 }; |
| 308 | 221 |
| 309 } // namespace webrtc | 222 } // namespace webrtc |
| 310 | 223 |
| 311 #endif // WEBRTC_VIDEO_VIE_CHANNEL_H_ | 224 #endif // WEBRTC_VIDEO_VIE_CHANNEL_H_ |
| OLD | NEW |