| 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 |
| 11 #ifndef WEBRTC_VIDEO_VIE_CHANNEL_H_ | 11 #ifndef WEBRTC_VIDEO_VIE_CHANNEL_H_ |
| 12 #define WEBRTC_VIDEO_VIE_CHANNEL_H_ | 12 #define WEBRTC_VIDEO_VIE_CHANNEL_H_ |
| 13 | 13 |
| 14 #include <list> | 14 #include <list> |
| 15 #include <map> | 15 #include <map> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "webrtc/base/criticalsection.h" |
| 18 #include "webrtc/base/platform_thread.h" | 19 #include "webrtc/base/platform_thread.h" |
| 19 #include "webrtc/base/scoped_ptr.h" | 20 #include "webrtc/base/scoped_ptr.h" |
| 20 #include "webrtc/base/scoped_ref_ptr.h" | 21 #include "webrtc/base/scoped_ref_ptr.h" |
| 21 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" | 22 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" |
| 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
| 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 24 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 25 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
| 25 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | |
| 26 #include "webrtc/system_wrappers/include/tick_util.h" | 26 #include "webrtc/system_wrappers/include/tick_util.h" |
| 27 #include "webrtc/typedefs.h" | 27 #include "webrtc/typedefs.h" |
| 28 #include "webrtc/video/vie_receiver.h" | 28 #include "webrtc/video/vie_receiver.h" |
| 29 #include "webrtc/video/vie_sync_module.h" | 29 #include "webrtc/video/vie_sync_module.h" |
| 30 | 30 |
| 31 namespace webrtc { | 31 namespace webrtc { |
| 32 | 32 |
| 33 class CallStatsObserver; | 33 class CallStatsObserver; |
| 34 class ChannelStatsObserver; | 34 class ChannelStatsObserver; |
| 35 class Config; | 35 class Config; |
| 36 class CriticalSectionWrapper; | |
| 37 class EncodedImageCallback; | 36 class EncodedImageCallback; |
| 38 class I420FrameCallback; | 37 class I420FrameCallback; |
| 39 class IncomingVideoStream; | 38 class IncomingVideoStream; |
| 40 class PacedSender; | 39 class PacedSender; |
| 41 class PacketRouter; | 40 class PacketRouter; |
| 42 class PayloadRouter; | 41 class PayloadRouter; |
| 43 class ProcessThread; | 42 class ProcessThread; |
| 44 class ReceiveStatisticsProxy; | 43 class ReceiveStatisticsProxy; |
| 45 class ReportBlockStats; | 44 class ReportBlockStats; |
| 46 class RtcpRttStats; | 45 class RtcpRttStats; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 void UpdateHistograms(); | 314 void UpdateHistograms(); |
| 316 | 315 |
| 317 // ViEChannel exposes methods that allow to modify observers and callbacks | 316 // ViEChannel exposes methods that allow to modify observers and callbacks |
| 318 // to be modified. Such an API-style is cumbersome to implement and maintain | 317 // to be modified. Such an API-style is cumbersome to implement and maintain |
| 319 // at all the levels when comparing to only setting them at construction. As | 318 // at all the levels when comparing to only setting them at construction. As |
| 320 // so this class instantiates its children with a wrapper that can be modified | 319 // so this class instantiates its children with a wrapper that can be modified |
| 321 // at a later time. | 320 // at a later time. |
| 322 template <class T> | 321 template <class T> |
| 323 class RegisterableCallback : public T { | 322 class RegisterableCallback : public T { |
| 324 public: | 323 public: |
| 325 RegisterableCallback() | 324 RegisterableCallback() : callback_(NULL) {} |
| 326 : critsect_(CriticalSectionWrapper::CreateCriticalSection()), | |
| 327 callback_(NULL) {} | |
| 328 | 325 |
| 329 void Set(T* callback) { | 326 void Set(T* callback) { |
| 330 CriticalSectionScoped cs(critsect_.get()); | 327 rtc::CritScope lock(&critsect_); |
| 331 callback_ = callback; | 328 callback_ = callback; |
| 332 } | 329 } |
| 333 | 330 |
| 334 protected: | 331 protected: |
| 335 // Note: this should be implemented with a RW-lock to allow simultaneous | 332 // Note: this should be implemented with a RW-lock to allow simultaneous |
| 336 // calls into the callback. However that doesn't seem to be needed for the | 333 // calls into the callback. However that doesn't seem to be needed for the |
| 337 // current type of callbacks covered by this class. | 334 // current type of callbacks covered by this class. |
| 338 rtc::scoped_ptr<CriticalSectionWrapper> critsect_; | 335 mutable rtc::CriticalSection critsect_; |
| 339 T* callback_ GUARDED_BY(critsect_); | 336 T* callback_ GUARDED_BY(critsect_); |
| 340 | 337 |
| 341 private: | 338 private: |
| 342 RTC_DISALLOW_COPY_AND_ASSIGN(RegisterableCallback); | 339 RTC_DISALLOW_COPY_AND_ASSIGN(RegisterableCallback); |
| 343 }; | 340 }; |
| 344 | 341 |
| 345 class RegisterableBitrateStatisticsObserver: | 342 class RegisterableBitrateStatisticsObserver: |
| 346 public RegisterableCallback<BitrateStatisticsObserver> { | 343 public RegisterableCallback<BitrateStatisticsObserver> { |
| 347 virtual void Notify(const BitrateStatistics& total_stats, | 344 virtual void Notify(const BitrateStatistics& total_stats, |
| 348 const BitrateStatistics& retransmit_stats, | 345 const BitrateStatistics& retransmit_stats, |
| 349 uint32_t ssrc) { | 346 uint32_t ssrc) { |
| 350 CriticalSectionScoped cs(critsect_.get()); | 347 rtc::CritScope lock(&critsect_); |
| 351 if (callback_) | 348 if (callback_) |
| 352 callback_->Notify(total_stats, retransmit_stats, ssrc); | 349 callback_->Notify(total_stats, retransmit_stats, ssrc); |
| 353 } | 350 } |
| 354 } send_bitrate_observer_; | 351 } send_bitrate_observer_; |
| 355 | 352 |
| 356 class RegisterableFrameCountObserver | 353 class RegisterableFrameCountObserver |
| 357 : public RegisterableCallback<FrameCountObserver> { | 354 : public RegisterableCallback<FrameCountObserver> { |
| 358 public: | 355 public: |
| 359 virtual void FrameCountUpdated(const FrameCounts& frame_counts, | 356 virtual void FrameCountUpdated(const FrameCounts& frame_counts, |
| 360 uint32_t ssrc) { | 357 uint32_t ssrc) { |
| 361 CriticalSectionScoped cs(critsect_.get()); | 358 rtc::CritScope lock(&critsect_); |
| 362 if (callback_) | 359 if (callback_) |
| 363 callback_->FrameCountUpdated(frame_counts, ssrc); | 360 callback_->FrameCountUpdated(frame_counts, ssrc); |
| 364 } | 361 } |
| 365 | 362 |
| 366 private: | 363 private: |
| 367 } send_frame_count_observer_; | 364 } send_frame_count_observer_; |
| 368 | 365 |
| 369 class RegisterableSendSideDelayObserver : | 366 class RegisterableSendSideDelayObserver : |
| 370 public RegisterableCallback<SendSideDelayObserver> { | 367 public RegisterableCallback<SendSideDelayObserver> { |
| 371 void SendSideDelayUpdated(int avg_delay_ms, | 368 void SendSideDelayUpdated(int avg_delay_ms, |
| 372 int max_delay_ms, | 369 int max_delay_ms, |
| 373 uint32_t ssrc) override { | 370 uint32_t ssrc) override { |
| 374 CriticalSectionScoped cs(critsect_.get()); | 371 rtc::CritScope lock(&critsect_); |
| 375 if (callback_) | 372 if (callback_) |
| 376 callback_->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); | 373 callback_->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc); |
| 377 } | 374 } |
| 378 } send_side_delay_observer_; | 375 } send_side_delay_observer_; |
| 379 | 376 |
| 380 class RegisterableRtcpPacketTypeCounterObserver | 377 class RegisterableRtcpPacketTypeCounterObserver |
| 381 : public RegisterableCallback<RtcpPacketTypeCounterObserver> { | 378 : public RegisterableCallback<RtcpPacketTypeCounterObserver> { |
| 382 public: | 379 public: |
| 383 void RtcpPacketTypesCounterUpdated( | 380 void RtcpPacketTypesCounterUpdated( |
| 384 uint32_t ssrc, | 381 uint32_t ssrc, |
| 385 const RtcpPacketTypeCounter& packet_counter) override { | 382 const RtcpPacketTypeCounter& packet_counter) override { |
| 386 CriticalSectionScoped cs(critsect_.get()); | 383 rtc::CritScope lock(&critsect_); |
| 387 if (callback_) | 384 if (callback_) |
| 388 callback_->RtcpPacketTypesCounterUpdated(ssrc, packet_counter); | 385 callback_->RtcpPacketTypesCounterUpdated(ssrc, packet_counter); |
| 389 counter_map_[ssrc] = packet_counter; | 386 counter_map_[ssrc] = packet_counter; |
| 390 } | 387 } |
| 391 | 388 |
| 392 virtual std::map<uint32_t, RtcpPacketTypeCounter> GetPacketTypeCounterMap() | 389 virtual std::map<uint32_t, RtcpPacketTypeCounter> GetPacketTypeCounterMap() |
| 393 const { | 390 const { |
| 394 CriticalSectionScoped cs(critsect_.get()); | 391 rtc::CritScope lock(&critsect_); |
| 395 return counter_map_; | 392 return counter_map_; |
| 396 } | 393 } |
| 397 | 394 |
| 398 private: | 395 private: |
| 399 std::map<uint32_t, RtcpPacketTypeCounter> counter_map_ | 396 std::map<uint32_t, RtcpPacketTypeCounter> counter_map_ |
| 400 GUARDED_BY(critsect_); | 397 GUARDED_BY(critsect_); |
| 401 } rtcp_packet_type_counter_observer_; | 398 } rtcp_packet_type_counter_observer_; |
| 402 | 399 |
| 403 const uint32_t number_of_cores_; | 400 const uint32_t number_of_cores_; |
| 404 const bool sender_; | 401 const bool sender_; |
| 405 | 402 |
| 406 ProcessThread* const module_process_thread_; | 403 ProcessThread* const module_process_thread_; |
| 407 | 404 |
| 408 // Used for all registered callbacks except rendering. | 405 // Used for all registered callbacks except rendering. |
| 409 rtc::scoped_ptr<CriticalSectionWrapper> crit_; | 406 mutable rtc::CriticalSection crit_; |
| 410 | 407 |
| 411 // Owned modules/classes. | 408 // Owned modules/classes. |
| 412 rtc::scoped_refptr<PayloadRouter> send_payload_router_; | 409 rtc::scoped_refptr<PayloadRouter> send_payload_router_; |
| 413 rtc::scoped_ptr<ViEChannelProtectionCallback> vcm_protection_callback_; | 410 rtc::scoped_ptr<ViEChannelProtectionCallback> vcm_protection_callback_; |
| 414 | 411 |
| 415 VideoCodingModule* const vcm_; | 412 VideoCodingModule* const vcm_; |
| 416 ViEReceiver vie_receiver_; | 413 ViEReceiver vie_receiver_; |
| 417 ViESyncModule vie_sync_; | 414 ViESyncModule vie_sync_; |
| 418 | 415 |
| 419 // Helper to report call statistics. | 416 // Helper to report call statistics. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 445 size_t num_rtts_ GUARDED_BY(crit_); | 442 size_t num_rtts_ GUARDED_BY(crit_); |
| 446 | 443 |
| 447 // RtpRtcp modules, declared last as they use other members on construction. | 444 // RtpRtcp modules, declared last as they use other members on construction. |
| 448 const std::vector<RtpRtcp*> rtp_rtcp_modules_; | 445 const std::vector<RtpRtcp*> rtp_rtcp_modules_; |
| 449 size_t num_active_rtp_rtcp_modules_ GUARDED_BY(crit_); | 446 size_t num_active_rtp_rtcp_modules_ GUARDED_BY(crit_); |
| 450 }; | 447 }; |
| 451 | 448 |
| 452 } // namespace webrtc | 449 } // namespace webrtc |
| 453 | 450 |
| 454 #endif // WEBRTC_VIDEO_VIE_CHANNEL_H_ | 451 #endif // WEBRTC_VIDEO_VIE_CHANNEL_H_ |
| OLD | NEW |