diff options
-rw-r--r-- | test/direct_transport.h | 2 | ||||
-rw-r--r-- | test/fake_encoder.h | 2 | ||||
-rw-r--r-- | test/frame_generator_capturer.h | 2 | ||||
-rw-r--r-- | test/rtp_rtcp_observer.h | 43 | ||||
-rw-r--r-- | video/bitrate_estimator_tests.cc | 11 | ||||
-rw-r--r-- | video/call.cc | 14 | ||||
-rw-r--r-- | video/call_perf_tests.cc | 13 | ||||
-rw-r--r-- | video/call_tests.cc | 13 | ||||
-rw-r--r-- | video/full_stack.cc | 89 | ||||
-rw-r--r-- | video/rampup_tests.cc | 91 | ||||
-rw-r--r-- | video/receive_statistics_proxy.cc | 20 | ||||
-rw-r--r-- | video/receive_statistics_proxy.h | 16 | ||||
-rw-r--r-- | video/send_statistics_proxy.cc | 21 | ||||
-rw-r--r-- | video/send_statistics_proxy.h | 6 | ||||
-rw-r--r-- | video/video_receive_stream.h | 2 | ||||
-rw-r--r-- | video/video_send_stream.cc | 5 | ||||
-rw-r--r-- | video/video_send_stream.h | 2 | ||||
-rw-r--r-- | video/video_send_stream_tests.cc | 63 |
18 files changed, 220 insertions, 195 deletions
diff --git a/test/direct_transport.h b/test/direct_transport.h index 9dc9e1fc..c40a8c38 100644 --- a/test/direct_transport.h +++ b/test/direct_transport.h @@ -49,7 +49,7 @@ class DirectTransport : public newapi::Transport { scoped_ptr<CriticalSectionWrapper> lock_; scoped_ptr<EventWrapper> packet_event_; scoped_ptr<ThreadWrapper> thread_; - Clock* clock_; + Clock* const clock_; bool shutting_down_; diff --git a/test/fake_encoder.h b/test/fake_encoder.h index c0709c12..2a444a10 100644 --- a/test/fake_encoder.h +++ b/test/fake_encoder.h @@ -42,7 +42,7 @@ class FakeEncoder : public VideoEncoder { uint32_t framerate) OVERRIDE; private: - Clock* clock_; + Clock* const clock_; VideoCodec config_; EncodedImageCallback* callback_; int target_bitrate_kbps_; diff --git a/test/frame_generator_capturer.h b/test/frame_generator_capturer.h index 84b3c495..ee3f0e01 100644 --- a/test/frame_generator_capturer.h +++ b/test/frame_generator_capturer.h @@ -54,7 +54,7 @@ class FrameGeneratorCapturer : public VideoCapturer { void InsertFrame(); static bool Run(void* obj); - Clock* clock_; + Clock* const clock_; bool sending_; scoped_ptr<EventWrapper> tick_; diff --git a/test/rtp_rtcp_observer.h b/test/rtp_rtcp_observer.h index 00422cce..e4486534 100644 --- a/test/rtp_rtcp_observer.h +++ b/test/rtp_rtcp_observer.h @@ -53,15 +53,15 @@ class RtpRtcpObserver { protected: RtpRtcpObserver(unsigned int event_timeout_ms, const FakeNetworkPipe::Config& configuration) - : lock_(CriticalSectionWrapper::CreateCriticalSection()), + : crit_(CriticalSectionWrapper::CreateCriticalSection()), observation_complete_(EventWrapper::Create()), parser_(RtpHeaderParser::Create()), - send_transport_(lock_.get(), + send_transport_(crit_.get(), this, &RtpRtcpObserver::OnSendRtp, &RtpRtcpObserver::OnSendRtcp, configuration), - receive_transport_(lock_.get(), + receive_transport_(crit_.get(), this, &RtpRtcpObserver::OnReceiveRtp, &RtpRtcpObserver::OnReceiveRtcp, @@ -69,15 +69,15 @@ class RtpRtcpObserver { timeout_ms_(event_timeout_ms) {} explicit RtpRtcpObserver(unsigned int event_timeout_ms) - : lock_(CriticalSectionWrapper::CreateCriticalSection()), + : crit_(CriticalSectionWrapper::CreateCriticalSection()), observation_complete_(EventWrapper::Create()), parser_(RtpHeaderParser::Create()), - send_transport_(lock_.get(), + send_transport_(crit_.get(), this, &RtpRtcpObserver::OnSendRtp, &RtpRtcpObserver::OnSendRtcp, FakeNetworkPipe::Config()), - receive_transport_(lock_.get(), + receive_transport_(crit_.get(), this, &RtpRtcpObserver::OnReceiveRtp, &RtpRtcpObserver::OnReceiveRtcp, @@ -89,23 +89,26 @@ class RtpRtcpObserver { DROP_PACKET, }; - virtual Action OnSendRtp(const uint8_t* packet, size_t length) { + virtual Action OnSendRtp(const uint8_t* packet, size_t length) + EXCLUSIVE_LOCKS_REQUIRED(crit_) { return SEND_PACKET; } - virtual Action OnSendRtcp(const uint8_t* packet, size_t length) { + virtual Action OnSendRtcp(const uint8_t* packet, size_t length) + EXCLUSIVE_LOCKS_REQUIRED(crit_) { return SEND_PACKET; } - virtual Action OnReceiveRtp(const uint8_t* packet, size_t length) { + virtual Action OnReceiveRtp(const uint8_t* packet, size_t length) + EXCLUSIVE_LOCKS_REQUIRED(crit_) { return SEND_PACKET; } - virtual Action OnReceiveRtcp(const uint8_t* packet, size_t length) { + virtual Action OnReceiveRtcp(const uint8_t* packet, size_t length) + EXCLUSIVE_LOCKS_REQUIRED(crit_) { return SEND_PACKET; } - private: class PacketTransport : public test::DirectTransport { public: @@ -118,7 +121,7 @@ class RtpRtcpObserver { PacketTransportAction on_rtcp, const FakeNetworkPipe::Config& configuration) : test::DirectTransport(configuration), - lock_(lock), + crit_(lock), observer_(observer), on_rtp_(on_rtp), on_rtcp_(on_rtcp) {} @@ -128,7 +131,7 @@ class RtpRtcpObserver { EXPECT_FALSE(RtpHeaderParser::IsRtcp(packet, static_cast<int>(length))); Action action; { - CriticalSectionScoped crit_(lock_); + CriticalSectionScoped lock(crit_); action = (observer_->*on_rtp_)(packet, length); } switch (action) { @@ -145,7 +148,7 @@ class RtpRtcpObserver { EXPECT_TRUE(RtpHeaderParser::IsRtcp(packet, static_cast<int>(length))); Action action; { - CriticalSectionScoped crit_(lock_); + CriticalSectionScoped lock(crit_); action = (observer_->*on_rtcp_)(packet, length); } switch (action) { @@ -159,16 +162,16 @@ class RtpRtcpObserver { } // Pointer to shared lock instance protecting on_rtp_/on_rtcp_ calls. - CriticalSectionWrapper* lock_; + CriticalSectionWrapper* const crit_; - RtpRtcpObserver* observer_; - PacketTransportAction on_rtp_, on_rtcp_; + RtpRtcpObserver* const observer_; + const PacketTransportAction on_rtp_, on_rtcp_; }; protected: - scoped_ptr<CriticalSectionWrapper> lock_; - scoped_ptr<EventWrapper> observation_complete_; - scoped_ptr<RtpHeaderParser> parser_; + const scoped_ptr<CriticalSectionWrapper> crit_; + const scoped_ptr<EventWrapper> observation_complete_; + const scoped_ptr<RtpHeaderParser> parser_; private: PacketTransport send_transport_, receive_transport_; diff --git a/video/bitrate_estimator_tests.cc b/video/bitrate_estimator_tests.cc index c28aea58..0cb30e3a 100644 --- a/video/bitrate_estimator_tests.cc +++ b/video/bitrate_estimator_tests.cc @@ -17,6 +17,7 @@ #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/event_wrapper.h" #include "webrtc/system_wrappers/interface/scoped_ptr.h" +#include "webrtc/system_wrappers/interface/thread_annotations.h" #include "webrtc/test/direct_transport.h" #include "webrtc/test/encoder_settings.h" #include "webrtc/test/fake_decoder.h" @@ -111,14 +112,14 @@ class BitrateEstimatorTest : public ::testing::Test { } void PushExpectedLogLine(const std::string& expected_log_line) { - CriticalSectionScoped cs(crit_sect_.get()); + CriticalSectionScoped lock(crit_sect_.get()); expected_log_lines_.push_back(expected_log_line); } virtual void Print(TraceLevel level, const char* message, int length) OVERRIDE { - CriticalSectionScoped cs(crit_sect_.get()); + CriticalSectionScoped lock(crit_sect_.get()); if (!(level & kTraceStateInfo)) { return; } @@ -147,9 +148,9 @@ class BitrateEstimatorTest : public ::testing::Test { private: typedef std::list<std::string> Strings; - scoped_ptr<CriticalSectionWrapper> crit_sect_; - Strings received_log_lines_; - Strings expected_log_lines_; + const scoped_ptr<CriticalSectionWrapper> crit_sect_; + Strings received_log_lines_ GUARDED_BY(crit_sect_); + Strings expected_log_lines_ GUARDED_BY(crit_sect_); scoped_ptr<EventWrapper> done_; }; diff --git a/video/call.cc b/video/call.cc index 595ec6ff..a3276540 100644 --- a/video/call.cc +++ b/video/call.cc @@ -21,6 +21,7 @@ #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" #include "webrtc/system_wrappers/interface/scoped_ptr.h" +#include "webrtc/system_wrappers/interface/thread_annotations.h" #include "webrtc/system_wrappers/interface/trace.h" #include "webrtc/video/video_receive_stream.h" #include "webrtc/video/video_send_stream.h" @@ -45,18 +46,18 @@ class CpuOveruseObserverProxy : public webrtc::CpuOveruseObserver { virtual ~CpuOveruseObserverProxy() {} virtual void OveruseDetected() OVERRIDE { - CriticalSectionScoped cs(crit_.get()); + CriticalSectionScoped lock(crit_.get()); overuse_callback_->OnOveruse(); } virtual void NormalUsage() OVERRIDE { - CriticalSectionScoped cs(crit_.get()); + CriticalSectionScoped lock(crit_.get()); overuse_callback_->OnNormalUse(); } private: - scoped_ptr<CriticalSectionWrapper> crit_; - OveruseCallback* overuse_callback_; + const scoped_ptr<CriticalSectionWrapper> crit_; + OveruseCallback* overuse_callback_ GUARDED_BY(crit_); }; class Call : public webrtc::Call, public PacketReceiver { @@ -95,10 +96,11 @@ class Call : public webrtc::Call, public PacketReceiver { Call::Config config_; - std::map<uint32_t, VideoReceiveStream*> receive_ssrcs_; + std::map<uint32_t, VideoReceiveStream*> receive_ssrcs_ + GUARDED_BY(receive_lock_); scoped_ptr<RWLockWrapper> receive_lock_; - std::map<uint32_t, VideoSendStream*> send_ssrcs_; + std::map<uint32_t, VideoSendStream*> send_ssrcs_ GUARDED_BY(send_lock_); scoped_ptr<RWLockWrapper> send_lock_; scoped_ptr<RtpHeaderParser> rtp_header_parser_; diff --git a/video/call_perf_tests.cc b/video/call_perf_tests.cc index 83ea1d08..6b8ff96a 100644 --- a/video/call_perf_tests.cc +++ b/video/call_perf_tests.cc @@ -22,6 +22,7 @@ #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/scoped_ptr.h" +#include "webrtc/system_wrappers/interface/thread_annotations.h" #include "webrtc/test/direct_transport.h" #include "webrtc/test/encoder_settings.h" #include "webrtc/test/fake_audio_device.h" @@ -93,7 +94,7 @@ class SyncRtcpObserver : public test::RtpRtcpObserver { public: explicit SyncRtcpObserver(const FakeNetworkPipe::Config& config) : test::RtpRtcpObserver(kLongTimeoutMs, config), - critical_section_(CriticalSectionWrapper::CreateCriticalSection()) {} + crit_(CriticalSectionWrapper::CreateCriticalSection()) {} virtual Action OnSendRtcp(const uint8_t* packet, size_t length) OVERRIDE { RTCPUtility::RTCPParserV2 parser(packet, length, true); @@ -115,7 +116,7 @@ class SyncRtcpObserver : public test::RtpRtcpObserver { } int64_t RtpTimestampToNtp(uint32_t timestamp) const { - CriticalSectionScoped cs(critical_section_.get()); + CriticalSectionScoped lock(crit_.get()); int64_t timestamp_in_ms = -1; if (ntp_rtp_pairs_.size() == 2) { // TODO(stefan): We can't EXPECT_TRUE on this call due to a bug in the @@ -129,7 +130,7 @@ class SyncRtcpObserver : public test::RtpRtcpObserver { private: void StoreNtpRtpPair(synchronization::RtcpMeasurement ntp_rtp_pair) { - CriticalSectionScoped cs(critical_section_.get()); + CriticalSectionScoped lock(crit_.get()); for (synchronization::RtcpList::iterator it = ntp_rtp_pairs_.begin(); it != ntp_rtp_pairs_.end(); ++it) { @@ -147,8 +148,8 @@ class SyncRtcpObserver : public test::RtpRtcpObserver { ntp_rtp_pairs_.push_front(ntp_rtp_pair); } - scoped_ptr<CriticalSectionWrapper> critical_section_; - synchronization::RtcpList ntp_rtp_pairs_; + const scoped_ptr<CriticalSectionWrapper> crit_; + synchronization::RtcpList ntp_rtp_pairs_ GUARDED_BY(crit_); }; class VideoRtcpAndSyncObserver : public SyncRtcpObserver, public VideoRenderer { @@ -213,7 +214,7 @@ class VideoRtcpAndSyncObserver : public SyncRtcpObserver, public VideoRenderer { } private: - Clock* clock_; + Clock* const clock_; int voe_channel_; VoEVideoSync* voe_sync_; SyncRtcpObserver* audio_observer_; diff --git a/video/call_tests.cc b/video/call_tests.cc index 472fa53a..617b944f 100644 --- a/video/call_tests.cc +++ b/video/call_tests.cc @@ -446,7 +446,8 @@ TEST_F(CallTest, DISABLED_CanReceiveFec) { protected_frame_timestamp_(0) {} private: - virtual Action OnSendRtp(const uint8_t* packet, size_t length) OVERRIDE { + virtual Action OnSendRtp(const uint8_t* packet, size_t length) OVERRIDE + EXCLUSIVE_LOCKS_REQUIRED(crit_) { RTPHeader header; EXPECT_TRUE(parser_->Parse(packet, static_cast<int>(length), &header)); @@ -487,7 +488,7 @@ TEST_F(CallTest, DISABLED_CanReceiveFec) { virtual void RenderFrame(const I420VideoFrame& video_frame, int time_to_render_ms) OVERRIDE { - CriticalSectionScoped crit_(lock_.get()); + CriticalSectionScoped lock(crit_.get()); // Rendering frame with timestamp associated with dropped packet -> FEC // protection worked. if (state_ == kProtectedPacketDropped && @@ -503,8 +504,8 @@ TEST_F(CallTest, DISABLED_CanReceiveFec) { kProtectedPacketDropped, } state_; - uint32_t protected_sequence_number_; - uint32_t protected_frame_timestamp_; + uint32_t protected_sequence_number_ GUARDED_BY(crit_); + uint32_t protected_frame_timestamp_ GUARDED_BY(crit_); } observer; CreateCalls(Call::Config(observer.SendTransport()), @@ -581,7 +582,7 @@ void CallTest::DecodesRetransmittedFrame(bool retransmit_over_rtx) { } virtual void FrameCallback(I420VideoFrame* frame) OVERRIDE { - CriticalSectionScoped crit_(lock_.get()); + CriticalSectionScoped lock(crit_.get()); if (frame->timestamp() == retransmitted_timestamp_) { EXPECT_TRUE(frame_retransmitted_); observation_complete_->Set(); @@ -785,7 +786,7 @@ class PliObserver : public test::RtpRtcpObserver, public VideoRenderer { virtual void RenderFrame(const I420VideoFrame& video_frame, int time_to_render_ms) OVERRIDE { - CriticalSectionScoped crit_(lock_.get()); + CriticalSectionScoped lock(crit_.get()); if (received_pli_ && video_frame.timestamp() > highest_dropped_timestamp_) { observation_complete_->Set(); } diff --git a/video/full_stack.cc b/video/full_stack.cc index a55270bc..51c0a8a7 100644 --- a/video/full_stack.cc +++ b/video/full_stack.cc @@ -24,6 +24,7 @@ #include "webrtc/system_wrappers/interface/event_wrapper.h" #include "webrtc/system_wrappers/interface/scoped_ptr.h" #include "webrtc/system_wrappers/interface/sleep.h" +#include "webrtc/system_wrappers/interface/thread_annotations.h" #include "webrtc/test/direct_transport.h" #include "webrtc/test/encoder_settings.h" #include "webrtc/test/fake_encoder.h" @@ -81,18 +82,18 @@ class VideoAnalyzer : public PacketReceiver, transport_(transport), receiver_(NULL), test_label_(test_label), + frames_left_(duration_frames), dropped_frames_(0), + last_render_time_(0), rtp_timestamp_delta_(0), + crit_(CriticalSectionWrapper::CreateCriticalSection()), first_send_frame_(NULL), - last_render_time_(0), avg_psnr_threshold_(avg_psnr_threshold), avg_ssim_threshold_(avg_ssim_threshold), - frames_left_(duration_frames), - crit_(CriticalSectionWrapper::CreateCriticalSection()), comparison_lock_(CriticalSectionWrapper::CreateCriticalSection()), comparison_thread_(ThreadWrapper::CreateThread(&FrameComparisonThread, this)), - trigger_(EventWrapper::Create()) { + done_(EventWrapper::Create()) { unsigned int id; EXPECT_TRUE(comparison_thread_->Start(id)); } @@ -117,7 +118,7 @@ class VideoAnalyzer : public PacketReceiver, RTPHeader header; parser->Parse(packet, static_cast<int>(length), &header); { - CriticalSectionScoped cs(crit_.get()); + CriticalSectionScoped lock(crit_.get()); recv_times_[header.timestamp - rtp_timestamp_delta_] = Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); } @@ -132,7 +133,7 @@ class VideoAnalyzer : public PacketReceiver, virtual void SwapFrame(I420VideoFrame* video_frame) OVERRIDE { I420VideoFrame* copy = NULL; { - CriticalSectionScoped cs(crit_.get()); + CriticalSectionScoped lock(crit_.get()); if (frame_pool_.size() > 0) { copy = frame_pool_.front(); frame_pool_.pop_front(); @@ -145,7 +146,7 @@ class VideoAnalyzer : public PacketReceiver, copy->set_timestamp(copy->render_time_ms() * 90); { - CriticalSectionScoped cs(crit_.get()); + CriticalSectionScoped lock(crit_.get()); if (first_send_frame_ == NULL && rtp_timestamp_delta_ == 0) first_send_frame_ = copy; @@ -161,7 +162,7 @@ class VideoAnalyzer : public PacketReceiver, parser->Parse(packet, static_cast<int>(length), &header); { - CriticalSectionScoped cs(crit_.get()); + CriticalSectionScoped lock(crit_.get()); if (rtp_timestamp_delta_ == 0) { rtp_timestamp_delta_ = header.timestamp - first_send_frame_->timestamp(); @@ -184,29 +185,27 @@ class VideoAnalyzer : public PacketReceiver, Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_; - { - CriticalSectionScoped cs(crit_.get()); - while (frames_.front()->timestamp() < send_timestamp) { - AddFrameComparison( - frames_.front(), &last_rendered_frame_, true, render_time_ms); - frame_pool_.push_back(frames_.front()); - frames_.pop_front(); - } - - I420VideoFrame* reference_frame = frames_.front(); + CriticalSectionScoped lock(crit_.get()); + while (frames_.front()->timestamp() < send_timestamp) { + AddFrameComparison( + frames_.front(), &last_rendered_frame_, true, render_time_ms); + frame_pool_.push_back(frames_.front()); frames_.pop_front(); - assert(reference_frame != NULL); - EXPECT_EQ(reference_frame->timestamp(), send_timestamp); - assert(reference_frame->timestamp() == send_timestamp); - - AddFrameComparison(reference_frame, &video_frame, false, render_time_ms); - frame_pool_.push_back(reference_frame); } + I420VideoFrame* reference_frame = frames_.front(); + frames_.pop_front(); + assert(reference_frame != NULL); + EXPECT_EQ(reference_frame->timestamp(), send_timestamp); + assert(reference_frame->timestamp() == send_timestamp); + + AddFrameComparison(reference_frame, &video_frame, false, render_time_ms); + frame_pool_.push_back(reference_frame); + last_rendered_frame_.CopyFrame(video_frame); } - void Wait() { trigger_->Wait(120 * 1000); } + void Wait() { done_->Wait(120 * 1000); } VideoSendStreamInput* input_; Transport* transport_; @@ -250,7 +249,8 @@ class VideoAnalyzer : public PacketReceiver, void AddFrameComparison(const I420VideoFrame* reference, const I420VideoFrame* render, bool dropped, - int64_t render_time_ms) { + int64_t render_time_ms) + EXCLUSIVE_LOCKS_REQUIRED(crit_) { int64_t send_time_ms = send_times_[reference->timestamp()]; send_times_.erase(reference->timestamp()); int64_t recv_time_ms = recv_times_[reference->timestamp()]; @@ -313,7 +313,7 @@ class VideoAnalyzer : public PacketReceiver, PrintResult("time_between_rendered_frames", rendered_delta_, " ms"); EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_); EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_); - trigger_->Set(); + done_->Set(); return false; } @@ -353,31 +353,32 @@ class VideoAnalyzer : public PacketReceiver, unit); } - const char* test_label_; + const char* const test_label_; test::Statistics sender_time_; test::Statistics receiver_time_; test::Statistics psnr_; test::Statistics ssim_; test::Statistics end_to_end_; test::Statistics rendered_delta_; - + int frames_left_; int dropped_frames_; - std::deque<I420VideoFrame*> frames_; - std::deque<I420VideoFrame*> frame_pool_; - I420VideoFrame last_rendered_frame_; - std::map<uint32_t, int64_t> send_times_; - std::map<uint32_t, int64_t> recv_times_; - uint32_t rtp_timestamp_delta_; - I420VideoFrame* first_send_frame_; int64_t last_render_time_; - double avg_psnr_threshold_; - double avg_ssim_threshold_; - int frames_left_; - scoped_ptr<CriticalSectionWrapper> crit_; - scoped_ptr<CriticalSectionWrapper> comparison_lock_; - scoped_ptr<ThreadWrapper> comparison_thread_; - std::deque<FrameComparison> comparisons_; - scoped_ptr<EventWrapper> trigger_; + uint32_t rtp_timestamp_delta_; + + const scoped_ptr<CriticalSectionWrapper> crit_; + std::deque<I420VideoFrame*> frames_ GUARDED_BY(crit_); + std::deque<I420VideoFrame*> frame_pool_ GUARDED_BY(crit_); + I420VideoFrame last_rendered_frame_ GUARDED_BY(crit_); + std::map<uint32_t, int64_t> send_times_ GUARDED_BY(crit_); + std::map<uint32_t, int64_t> recv_times_ GUARDED_BY(crit_); + I420VideoFrame* first_send_frame_ GUARDED_BY(crit_); + double avg_psnr_threshold_ GUARDED_BY(crit_); + double avg_ssim_threshold_ GUARDED_BY(crit_); + + const scoped_ptr<CriticalSectionWrapper> comparison_lock_; + const scoped_ptr<ThreadWrapper> comparison_thread_; + std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); + const scoped_ptr<EventWrapper> done_; }; TEST_P(FullStackTest, NoPacketLoss) { diff --git a/video/rampup_tests.cc b/video/rampup_tests.cc index a53fe62e..32a29982 100644 --- a/video/rampup_tests.cc +++ b/video/rampup_tests.cc @@ -48,14 +48,14 @@ class StreamObserver : public newapi::Transport, public RemoteBitrateObserver { StreamObserver(const SsrcMap& rtx_media_ssrcs, newapi::Transport* feedback_transport, Clock* clock) - : critical_section_(CriticalSectionWrapper::CreateCriticalSection()), + : clock_(clock), test_done_(EventWrapper::Create()), rtp_parser_(RtpHeaderParser::Create()), feedback_transport_(feedback_transport), receive_stats_(ReceiveStatistics::Create(clock)), payload_registry_( new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(false))), - clock_(clock), + crit_(CriticalSectionWrapper::CreateCriticalSection()), expected_bitrate_bps_(0), rtx_media_ssrcs_(rtx_media_ssrcs), total_sent_(0), @@ -85,12 +85,13 @@ class StreamObserver : public newapi::Transport, public RemoteBitrateObserver { } void set_expected_bitrate_bps(unsigned int expected_bitrate_bps) { + CriticalSectionScoped lock(crit_.get()); expected_bitrate_bps_ = expected_bitrate_bps; } virtual void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs, unsigned int bitrate) OVERRIDE { - CriticalSectionScoped lock(critical_section_.get()); + CriticalSectionScoped lock(crit_.get()); assert(expected_bitrate_bps_ > 0); if (bitrate >= expected_bitrate_bps_) { // Just trigger if there was any rtx padding packet. @@ -104,7 +105,7 @@ class StreamObserver : public newapi::Transport, public RemoteBitrateObserver { } virtual bool SendRtp(const uint8_t* packet, size_t length) OVERRIDE { - CriticalSectionScoped lock(critical_section_.get()); + CriticalSectionScoped lock(crit_.get()); RTPHeader header; EXPECT_TRUE(rtp_parser_->Parse(packet, static_cast<int>(length), &header)); receive_stats_->IncomingPacket(header, length, false); @@ -156,7 +157,7 @@ class StreamObserver : public newapi::Transport, public RemoteBitrateObserver { value, units, false); } - void TriggerTestDone() { + void TriggerTestDone() EXCLUSIVE_LOCKS_REQUIRED(crit_) { ReportResult("total-sent", total_sent_, "bytes"); ReportResult("padding-sent", padding_sent_, "bytes"); ReportResult("rtx-media-sent", rtx_media_sent_, "bytes"); @@ -166,23 +167,24 @@ class StreamObserver : public newapi::Transport, public RemoteBitrateObserver { test_done_->Set(); } - scoped_ptr<CriticalSectionWrapper> critical_section_; - scoped_ptr<EventWrapper> test_done_; - scoped_ptr<RtpHeaderParser> rtp_parser_; + Clock* const clock_; + const scoped_ptr<EventWrapper> test_done_; + const scoped_ptr<RtpHeaderParser> rtp_parser_; scoped_ptr<RtpRtcp> rtp_rtcp_; internal::TransportAdapter feedback_transport_; - scoped_ptr<ReceiveStatistics> receive_stats_; - scoped_ptr<RTPPayloadRegistry> payload_registry_; + const scoped_ptr<ReceiveStatistics> receive_stats_; + const scoped_ptr<RTPPayloadRegistry> payload_registry_; scoped_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_; - Clock* clock_; - unsigned int expected_bitrate_bps_; - SsrcMap rtx_media_ssrcs_; - size_t total_sent_; - size_t padding_sent_; - size_t rtx_media_sent_; - int total_packets_sent_; - int padding_packets_sent_; - int rtx_media_packets_sent_; + + const scoped_ptr<CriticalSectionWrapper> crit_; + unsigned int expected_bitrate_bps_ GUARDED_BY(crit_); + SsrcMap rtx_media_ssrcs_ GUARDED_BY(crit_); + size_t total_sent_ GUARDED_BY(crit_); + size_t padding_sent_ GUARDED_BY(crit_); + size_t rtx_media_sent_ GUARDED_BY(crit_); + int total_packets_sent_ GUARDED_BY(crit_); + int padding_packets_sent_ GUARDED_BY(crit_); + int rtx_media_packets_sent_ GUARDED_BY(crit_); }; class LowRateStreamObserver : public test::DirectTransport, @@ -193,21 +195,21 @@ class LowRateStreamObserver : public test::DirectTransport, Clock* clock, size_t number_of_streams, bool rtx_used) - : critical_section_(CriticalSectionWrapper::CreateCriticalSection()), + : clock_(clock), + number_of_streams_(number_of_streams), + rtx_used_(rtx_used), test_done_(EventWrapper::Create()), rtp_parser_(RtpHeaderParser::Create()), feedback_transport_(feedback_transport), receive_stats_(ReceiveStatistics::Create(clock)), - clock_(clock), + crit_(CriticalSectionWrapper::CreateCriticalSection()), + send_stream_(NULL), test_state_(kFirstRampup), state_start_ms_(clock_->TimeInMilliseconds()), interval_start_ms_(state_start_ms_), last_remb_bps_(0), sent_bytes_(0), total_overuse_bytes_(0), - number_of_streams_(number_of_streams), - rtx_used_(rtx_used), - send_stream_(NULL), suspended_in_stats_(false) { RtpRtcp::Configuration config; config.receive_statistics = receive_stats_.get(); @@ -231,12 +233,13 @@ class LowRateStreamObserver : public test::DirectTransport, } virtual void SetSendStream(const VideoSendStream* send_stream) { + CriticalSectionScoped lock(crit_.get()); send_stream_ = send_stream; } virtual void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs, unsigned int bitrate) { - CriticalSectionScoped lock(critical_section_.get()); + CriticalSectionScoped lock(crit_.get()); rtp_rtcp_->SetREMBData( bitrate, static_cast<uint8_t>(ssrcs.size()), &ssrcs[0]); rtp_rtcp_->Process(); @@ -244,6 +247,7 @@ class LowRateStreamObserver : public test::DirectTransport, } virtual bool SendRtp(const uint8_t* data, size_t length) OVERRIDE { + CriticalSectionScoped lock(crit_.get()); sent_bytes_ += length; int64_t now_ms = clock_->TimeInMilliseconds(); if (now_ms > interval_start_ms_ + 1000) { // Let at least 1 second pass. @@ -265,7 +269,7 @@ class LowRateStreamObserver : public test::DirectTransport, } virtual bool DeliverPacket(const uint8_t* packet, size_t length) OVERRIDE { - CriticalSectionScoped lock(critical_section_.get()); + CriticalSectionScoped lock(crit_.get()); RTPHeader header; EXPECT_TRUE(rtp_parser_->Parse(packet, static_cast<int>(length), &header)); receive_stats_->IncomingPacket(header, length, false); @@ -300,8 +304,8 @@ class LowRateStreamObserver : public test::DirectTransport, // This method defines the state machine for the ramp up-down-up test. void EvolveTestState(unsigned int bitrate_bps) { int64_t now = clock_->TimeInMilliseconds(); + CriticalSectionScoped lock(crit_.get()); assert(send_stream_ != NULL); - CriticalSectionScoped lock(critical_section_.get()); switch (test_state_) { case kFirstRampup: { EXPECT_FALSE(suspended_in_stats_); @@ -374,25 +378,26 @@ class LowRateStreamObserver : public test::DirectTransport, static const unsigned int kExpectedLowBitrateBps = 20000; enum TestStates { kFirstRampup, kLowRate, kSecondRampup }; - scoped_ptr<CriticalSectionWrapper> critical_section_; - scoped_ptr<EventWrapper> test_done_; - scoped_ptr<RtpHeaderParser> rtp_parser_; + Clock* const clock_; + const size_t number_of_streams_; + const bool rtx_used_; + const scoped_ptr<EventWrapper> test_done_; + const scoped_ptr<RtpHeaderParser> rtp_parser_; scoped_ptr<RtpRtcp> rtp_rtcp_; internal::TransportAdapter feedback_transport_; - scoped_ptr<ReceiveStatistics> receive_stats_; + const scoped_ptr<ReceiveStatistics> receive_stats_; scoped_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_; - Clock* clock_; - FakeNetworkPipe::Config forward_transport_config_; - TestStates test_state_; - int64_t state_start_ms_; - int64_t interval_start_ms_; - unsigned int last_remb_bps_; - size_t sent_bytes_; - size_t total_overuse_bytes_; - const size_t number_of_streams_; - const bool rtx_used_; - const VideoSendStream* send_stream_; - bool suspended_in_stats_ GUARDED_BY(critical_section_); + + scoped_ptr<CriticalSectionWrapper> crit_; + const VideoSendStream* send_stream_ GUARDED_BY(crit_); + FakeNetworkPipe::Config forward_transport_config_ GUARDED_BY(crit_); + TestStates test_state_ GUARDED_BY(crit_); + int64_t state_start_ms_ GUARDED_BY(crit_); + int64_t interval_start_ms_ GUARDED_BY(crit_); + unsigned int last_remb_bps_ GUARDED_BY(crit_); + size_t sent_bytes_ GUARDED_BY(crit_); + size_t total_overuse_bytes_ GUARDED_BY(crit_); + bool suspended_in_stats_ GUARDED_BY(crit_); }; } diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc index f42e4d33..60042818 100644 --- a/video/receive_statistics_proxy.cc +++ b/video/receive_statistics_proxy.cc @@ -22,13 +22,13 @@ ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, ViECodec* codec, int channel) : channel_(channel), - lock_(CriticalSectionWrapper::CreateCriticalSection()), clock_(clock), + codec_(codec), + rtp_rtcp_(rtp_rtcp), + crit_(CriticalSectionWrapper::CreateCriticalSection()), // 1000ms window, scale 1000 for ms to s. decode_fps_estimator_(1000, 1000), - renders_fps_estimator_(1000, 1000), - codec_(codec), - rtp_rtcp_(rtp_rtcp) { + renders_fps_estimator_(1000, 1000) { stats_.ssrc = ssrc; } @@ -37,7 +37,7 @@ ReceiveStatisticsProxy::~ReceiveStatisticsProxy() {} VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const { VideoReceiveStream::Stats stats; { - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); stats = stats_; } stats.c_name = GetCName(); @@ -59,7 +59,7 @@ std::string ReceiveStatisticsProxy::GetCName() const { void ReceiveStatisticsProxy::IncomingRate(const int video_channel, const unsigned int framerate, const unsigned int bitrate) { - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); stats_.network_frame_rate = framerate; stats_.bitrate_bps = bitrate; } @@ -67,7 +67,7 @@ void ReceiveStatisticsProxy::IncomingRate(const int video_channel, void ReceiveStatisticsProxy::StatisticsUpdated( const webrtc::RtcpStatistics& statistics, uint32_t ssrc) { - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); stats_.rtcp_stats = statistics; } @@ -75,7 +75,7 @@ void ReceiveStatisticsProxy::StatisticsUpdated( void ReceiveStatisticsProxy::DataCountersUpdated( const webrtc::StreamDataCounters& counters, uint32_t ssrc) { - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); stats_.rtp_stats = counters; } @@ -83,7 +83,7 @@ void ReceiveStatisticsProxy::DataCountersUpdated( void ReceiveStatisticsProxy::OnDecodedFrame() { uint64_t now = clock_->TimeInMilliseconds(); - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); decode_fps_estimator_.Update(1, now); stats_.decode_frame_rate = decode_fps_estimator_.Rate(now); } @@ -91,7 +91,7 @@ void ReceiveStatisticsProxy::OnDecodedFrame() { void ReceiveStatisticsProxy::OnRenderedFrame() { uint64_t now = clock_->TimeInMilliseconds(); - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); renders_fps_estimator_.Update(1, now); stats_.render_frame_rate = renders_fps_estimator_.Rate(now); } diff --git a/video/receive_statistics_proxy.h b/video/receive_statistics_proxy.h index bedebb3f..35e5cc3e 100644 --- a/video/receive_statistics_proxy.h +++ b/video/receive_statistics_proxy.h @@ -16,6 +16,7 @@ #include "webrtc/common_types.h" #include "webrtc/frame_callback.h" #include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h" +#include "webrtc/system_wrappers/interface/thread_annotations.h" #include "webrtc/video_engine/include/vie_codec.h" #include "webrtc/video_engine/include/vie_rtp_rtcp.h" #include "webrtc/video_receive_stream.h" @@ -73,13 +74,14 @@ class ReceiveStatisticsProxy : public ViEDecoderObserver, std::string GetCName() const; const int channel_; - scoped_ptr<CriticalSectionWrapper> lock_; - Clock* clock_; - VideoReceiveStream::Stats stats_; - RateStatistics decode_fps_estimator_; - RateStatistics renders_fps_estimator_; - ViECodec* codec_; - ViERTP_RTCP* rtp_rtcp_; + Clock* const clock_; + ViECodec* const codec_; + ViERTP_RTCP* const rtp_rtcp_; + + scoped_ptr<CriticalSectionWrapper> crit_; + VideoReceiveStream::Stats stats_ GUARDED_BY(crit_); + RateStatistics decode_fps_estimator_ GUARDED_BY(crit_); + RateStatistics renders_fps_estimator_ GUARDED_BY(crit_); }; } // namespace internal diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc index 1cd4e26a..c9bd05c1 100644 --- a/video/send_statistics_proxy.cc +++ b/video/send_statistics_proxy.cc @@ -20,33 +20,34 @@ SendStatisticsProxy::SendStatisticsProxy( const VideoSendStream::Config& config, SendStatisticsProxy::StatsProvider* stats_provider) : config_(config), - lock_(CriticalSectionWrapper::CreateCriticalSection()), - stats_provider_(stats_provider) {} + stats_provider_(stats_provider), + crit_(CriticalSectionWrapper::CreateCriticalSection()) { +} SendStatisticsProxy::~SendStatisticsProxy() {} void SendStatisticsProxy::OutgoingRate(const int video_channel, const unsigned int framerate, const unsigned int bitrate) { - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); stats_.encode_frame_rate = framerate; } void SendStatisticsProxy::SuspendChange(int video_channel, bool is_suspended) { - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); stats_.suspended = is_suspended; } void SendStatisticsProxy::CapturedFrameRate(const int capture_id, const unsigned char frame_rate) { - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); stats_.input_frame_rate = frame_rate; } VideoSendStream::Stats SendStatisticsProxy::GetStats() const { VideoSendStream::Stats stats; { - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); stats = stats_; } stats_provider_->GetSendSideDelay(&stats); @@ -68,7 +69,7 @@ StreamStats* SendStatisticsProxy::GetStatsEntry(uint32_t ssrc) { void SendStatisticsProxy::StatisticsUpdated(const RtcpStatistics& statistics, uint32_t ssrc) { - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); StreamStats* stats = GetStatsEntry(ssrc); if (stats == NULL) return; @@ -79,7 +80,7 @@ void SendStatisticsProxy::StatisticsUpdated(const RtcpStatistics& statistics, void SendStatisticsProxy::DataCountersUpdated( const StreamDataCounters& counters, uint32_t ssrc) { - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); StreamStats* stats = GetStatsEntry(ssrc); if (stats == NULL) return; @@ -89,7 +90,7 @@ void SendStatisticsProxy::DataCountersUpdated( void SendStatisticsProxy::Notify(const BitrateStatistics& bitrate, uint32_t ssrc) { - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); StreamStats* stats = GetStatsEntry(ssrc); if (stats == NULL) return; @@ -100,7 +101,7 @@ void SendStatisticsProxy::Notify(const BitrateStatistics& bitrate, void SendStatisticsProxy::FrameCountUpdated(FrameType frame_type, uint32_t frame_count, const unsigned int ssrc) { - CriticalSectionScoped cs(lock_.get()); + CriticalSectionScoped lock(crit_.get()); StreamStats* stats = GetStatsEntry(ssrc); if (stats == NULL) return; diff --git a/video/send_statistics_proxy.h b/video/send_statistics_proxy.h index 2f45ff7f..a1ff14cd 100644 --- a/video/send_statistics_proxy.h +++ b/video/send_statistics_proxy.h @@ -81,12 +81,12 @@ class SendStatisticsProxy : public RtcpStatisticsCallback, const CaptureAlarm alarm) OVERRIDE {} private: - StreamStats* GetStatsEntry(uint32_t ssrc) EXCLUSIVE_LOCKS_REQUIRED(lock_); + StreamStats* GetStatsEntry(uint32_t ssrc) EXCLUSIVE_LOCKS_REQUIRED(crit_); const VideoSendStream::Config config_; - scoped_ptr<CriticalSectionWrapper> lock_; - VideoSendStream::Stats stats_ GUARDED_BY(lock_); StatsProvider* const stats_provider_; + scoped_ptr<CriticalSectionWrapper> crit_; + VideoSendStream::Stats stats_ GUARDED_BY(crit_); }; } // namespace webrtc diff --git a/video/video_receive_stream.h b/video/video_receive_stream.h index b4d13bce..4ff086a5 100644 --- a/video/video_receive_stream.h +++ b/video/video_receive_stream.h @@ -70,7 +70,7 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream, TransportAdapter transport_adapter_; EncodedFrameCallbackAdapter encoded_frame_proxy_; VideoReceiveStream::Config config_; - Clock* clock_; + Clock* const clock_; ViEBase* video_engine_base_; ViECodec* codec_; diff --git a/video/video_send_stream.cc b/video/video_send_stream.cc index 2680b09d..e6e683a1 100644 --- a/video/video_send_stream.cc +++ b/video/video_send_stream.cc @@ -37,7 +37,8 @@ VideoSendStream::VideoSendStream(newapi::Transport* transport, codec_lock_(CriticalSectionWrapper::CreateCriticalSection()), config_(config), external_codec_(NULL), - channel_(-1) { + channel_(-1), + stats_proxy_(new SendStatisticsProxy(config, this)) { video_engine_base_ = ViEBase::GetInterface(video_engine); video_engine_base_->CreateChannel(channel_, base_channel); assert(channel_ != -1); @@ -142,8 +143,6 @@ VideoSendStream::VideoSendStream(newapi::Transport* transport, codec_->SuspendBelowMinBitrate(channel_); } - stats_proxy_.reset(new SendStatisticsProxy(config, this)); - rtp_rtcp_->RegisterSendChannelRtcpStatisticsCallback(channel_, stats_proxy_.get()); rtp_rtcp_->RegisterSendChannelRtpStatisticsCallback(channel_, diff --git a/video/video_send_stream.h b/video/video_send_stream.h index 8cfc2962..b8f5661f 100644 --- a/video/video_send_stream.h +++ b/video/video_send_stream.h @@ -87,7 +87,7 @@ class VideoSendStream : public webrtc::VideoSendStream, int channel_; int capture_id_; - scoped_ptr<SendStatisticsProxy> stats_proxy_; + const scoped_ptr<SendStatisticsProxy> stats_proxy_; }; } // namespace internal } // namespace webrtc diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc index 2845bba7..13ac01cf 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -820,14 +820,14 @@ TEST_F(VideoSendStreamTest, SuspendBelowMinBitrate) { : RtpRtcpObserver(30 * 1000), // Timeout after 30 seconds. transport_adapter_(&transport_), clock_(Clock::GetRealTimeClock()), + send_stream_ptr_(send_stream_ptr), + crit_(CriticalSectionWrapper::CreateCriticalSection()), test_state_(kBeforeSuspend), rtp_count_(0), last_sequence_number_(0), suspended_frame_count_(0), low_remb_bps_(0), - high_remb_bps_(0), - crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), - send_stream_ptr_(send_stream_ptr) { + high_remb_bps_(0) { transport_adapter_.Enable(); } @@ -838,13 +838,13 @@ TEST_F(VideoSendStreamTest, SuspendBelowMinBitrate) { virtual Action OnSendRtcp(const uint8_t* packet, size_t length) OVERRIDE { // Receive statistics reporting having lost 0% of the packets. // This is needed for the send-side bitrate controller to work properly. - CriticalSectionScoped lock(crit_sect_.get()); + CriticalSectionScoped lock(crit_.get()); SendRtcpFeedback(0); // REMB is only sent if value is > 0. return SEND_PACKET; } virtual Action OnSendRtp(const uint8_t* packet, size_t length) OVERRIDE { - CriticalSectionScoped lock(crit_sect_.get()); + CriticalSectionScoped lock(crit_.get()); ++rtp_count_; RTPHeader header; EXPECT_TRUE(parser_->Parse(packet, static_cast<int>(length), &header)); @@ -880,7 +880,7 @@ TEST_F(VideoSendStreamTest, SuspendBelowMinBitrate) { // This method implements the I420FrameCallback. void FrameCallback(I420VideoFrame* video_frame) OVERRIDE { - CriticalSectionScoped lock(crit_sect_.get()); + CriticalSectionScoped lock(crit_.get()); if (test_state_ == kDuringSuspend && ++suspended_frame_count_ > kSuspendTimeFrames) { assert(*send_stream_ptr_); @@ -891,9 +891,15 @@ TEST_F(VideoSendStreamTest, SuspendBelowMinBitrate) { } } - void set_low_remb_bps(int value) { low_remb_bps_ = value; } + void set_low_remb_bps(int value) { + CriticalSectionScoped lock(crit_.get()); + low_remb_bps_ = value; + } - void set_high_remb_bps(int value) { high_remb_bps_ = value; } + void set_high_remb_bps(int value) { + CriticalSectionScoped lock(crit_.get()); + high_remb_bps_ = value; + } void Stop() { transport_.StopSending(); } @@ -905,7 +911,8 @@ TEST_F(VideoSendStreamTest, SuspendBelowMinBitrate) { kWaitingForStats }; - virtual void SendRtcpFeedback(int remb_value) { + virtual void SendRtcpFeedback(int remb_value) + EXCLUSIVE_LOCKS_REQUIRED(crit_) { FakeReceiveStatistics receive_stats( kSendSsrc, last_sequence_number_, rtp_count_, 0); RTCPSender rtcp_sender(0, false, clock_, &receive_stats); @@ -923,15 +930,16 @@ TEST_F(VideoSendStreamTest, SuspendBelowMinBitrate) { internal::TransportAdapter transport_adapter_; test::DirectTransport transport_; - Clock* clock_; - TestState test_state_; - int rtp_count_; - int last_sequence_number_; - int suspended_frame_count_; - int low_remb_bps_; - int high_remb_bps_; - scoped_ptr<CriticalSectionWrapper> crit_sect_; - VideoSendStream** send_stream_ptr_; + Clock* const clock_; + VideoSendStream** const send_stream_ptr_; + + const scoped_ptr<CriticalSectionWrapper> crit_; + TestState test_state_ GUARDED_BY(crit_); + int rtp_count_ GUARDED_BY(crit_); + int last_sequence_number_ GUARDED_BY(crit_); + int suspended_frame_count_ GUARDED_BY(crit_); + int low_remb_bps_ GUARDED_BY(crit_); + int high_remb_bps_ GUARDED_BY(crit_); } observer(&send_stream_); // Note that |send_stream_| is created in RunSendTest(), called below. This // is why a pointer to |send_stream_| must be provided here. @@ -961,26 +969,27 @@ TEST_F(VideoSendStreamTest, NoPaddingWhenVideoIsMuted) { PacketObserver() : RtpRtcpObserver(30 * 1000), // Timeout after 30 seconds. clock_(Clock::GetRealTimeClock()), - last_packet_time_ms_(-1), transport_adapter_(ReceiveTransport()), - capturer_(NULL), - crit_sect_(CriticalSectionWrapper::CreateCriticalSection()) { + crit_(CriticalSectionWrapper::CreateCriticalSection()), + last_packet_time_ms_(-1), + capturer_(NULL) { transport_adapter_.Enable(); } void SetCapturer(test::FrameGeneratorCapturer* capturer) { + CriticalSectionScoped lock(crit_.get()); capturer_ = capturer; } virtual Action OnSendRtp(const uint8_t* packet, size_t length) OVERRIDE { - CriticalSectionScoped lock(crit_sect_.get()); + CriticalSectionScoped lock(crit_.get()); last_packet_time_ms_ = clock_->TimeInMilliseconds(); capturer_->Stop(); return SEND_PACKET; } virtual Action OnSendRtcp(const uint8_t* packet, size_t length) OVERRIDE { - CriticalSectionScoped lock(crit_sect_.get()); + CriticalSectionScoped lock(crit_.get()); const int kVideoMutedThresholdMs = 10000; if (last_packet_time_ms_ > 0 && clock_->TimeInMilliseconds() - last_packet_time_ms_ > @@ -1002,11 +1011,11 @@ TEST_F(VideoSendStreamTest, NoPaddingWhenVideoIsMuted) { } private: - Clock* clock_; - int64_t last_packet_time_ms_; + Clock* const clock_; internal::TransportAdapter transport_adapter_; - test::FrameGeneratorCapturer* capturer_; - scoped_ptr<CriticalSectionWrapper> crit_sect_; + const scoped_ptr<CriticalSectionWrapper> crit_; + int64_t last_packet_time_ms_ GUARDED_BY(crit_); + test::FrameGeneratorCapturer* capturer_ GUARDED_BY(crit_); } observer; Call::Config call_config(observer.SendTransport()); |