diff options
author | imcheng@chromium.org <imcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-15 18:51:00 +0000 |
---|---|---|
committer | imcheng@chromium.org <imcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-15 18:51:00 +0000 |
commit | 05d7fd7ffbd3deead228106cf1ce269ecdcfc419 (patch) | |
tree | 77c8c4f119eb74dbfdd6e04613c7fcc1c5605a53 /media | |
parent | 0aacf631decd0e8c3c28c45fd85cd0329bdd79d9 (diff) | |
download | chromium_src-05d7fd7ffbd3deead228106cf1ce269ecdcfc419.zip chromium_src-05d7fd7ffbd3deead228106cf1ce269ecdcfc419.tar.gz chromium_src-05d7fd7ffbd3deead228106cf1ce269ecdcfc419.tar.bz2 |
Cast: Remove SenderRtcpEventSubscriber from cast library.
It is not used anymore after sender RTCP logs were removed in r270182.
Review URL: https://codereview.chromium.org/281293002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270755 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/cast/cast.gyp | 2 | ||||
-rw-r--r-- | media/cast/cast_testing.gypi | 1 | ||||
-rw-r--r-- | media/cast/rtcp/sender_rtcp_event_subscriber.cc | 92 | ||||
-rw-r--r-- | media/cast/rtcp/sender_rtcp_event_subscriber.h | 69 | ||||
-rw-r--r-- | media/cast/rtcp/sender_rtcp_event_subscriber_unittest.cc | 120 | ||||
-rw-r--r-- | media/cast/video_sender/video_sender.cc | 1 | ||||
-rw-r--r-- | media/cast/video_sender/video_sender.h | 1 |
7 files changed, 0 insertions, 286 deletions
diff --git a/media/cast/cast.gyp b/media/cast/cast.gyp index d489a6a..578e582 100644 --- a/media/cast/cast.gyp +++ b/media/cast/cast.gyp @@ -147,8 +147,6 @@ 'rtcp/rtcp_sender.h', 'rtcp/rtcp_utility.cc', 'rtcp/rtcp_utility.h', - 'rtcp/sender_rtcp_event_subscriber.cc', - 'rtcp/sender_rtcp_event_subscriber.h', 'rtcp/receiver_rtcp_event_subscriber.cc', 'rtcp/receiver_rtcp_event_subscriber.cc', ], # source diff --git a/media/cast/cast_testing.gypi b/media/cast/cast_testing.gypi index f8c2553..2aa9fe1 100644 --- a/media/cast/cast_testing.gypi +++ b/media/cast/cast_testing.gypi @@ -84,7 +84,6 @@ 'rtcp/rtcp_sender_unittest.cc', 'rtcp/rtcp_unittest.cc', 'rtcp/receiver_rtcp_event_subscriber_unittest.cc', - 'rtcp/sender_rtcp_event_subscriber_unittest.cc', # TODO(miu): The following two are test utility modules. Rename/move the files. 'rtcp/test_rtcp_packet_builder.cc', 'rtcp/test_rtcp_packet_builder.h', diff --git a/media/cast/rtcp/sender_rtcp_event_subscriber.cc b/media/cast/rtcp/sender_rtcp_event_subscriber.cc deleted file mode 100644 index 6a44b33..0000000 --- a/media/cast/rtcp/sender_rtcp_event_subscriber.cc +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "media/cast/rtcp/sender_rtcp_event_subscriber.h" - -#include <utility> - -#include "base/logging.h" -#include "media/cast/rtcp/rtcp_defines.h" - -namespace media { -namespace cast { - -SenderRtcpEventSubscriber::SenderRtcpEventSubscriber( - const size_t max_size_to_retain) - : max_size_to_retain_(max_size_to_retain) { - DCHECK(max_size_to_retain_ > 0u); -} - -SenderRtcpEventSubscriber::~SenderRtcpEventSubscriber() { - DCHECK(thread_checker_.CalledOnValidThread()); -} - -void SenderRtcpEventSubscriber::OnReceiveFrameEvent( - const FrameEvent& frame_event) { - DCHECK(thread_checker_.CalledOnValidThread()); - if (frame_event.media_type != VIDEO_EVENT) - return; - if (frame_event.type != FRAME_CAPTURE_BEGIN && - frame_event.type != FRAME_ENCODED) { - // Not interested in other events. - return; - } - - RtcpEventMap::iterator it = rtcp_events_.find(frame_event.rtp_timestamp); - if (it == rtcp_events_.end()) { - // We have not stored this frame (RTP timestamp) in our map. - RtcpEvent rtcp_event; - rtcp_event.type = frame_event.type; - rtcp_event.timestamp = frame_event.timestamp; - - // Do not need to fill out rtcp_event.delay_delta or rtcp_event.packet_id - // as they are not set in frame events we are interested in. - rtcp_events_.insert(std::make_pair(frame_event.rtp_timestamp, rtcp_event)); - - TruncateMapIfNeeded(); - } else { - // We already have this frame (RTP timestamp) in our map. - // Only update events that are later in the chain. - // This is due to that events can be reordered on the wire. - if (frame_event.type == FRAME_CAPTURE_BEGIN) { - return; // First event in chain can not be late by definition. - } - - if (it->second.type == FRAME_ENCODED) { - return; // Last event in chain should not be updated. - } - - // Update existing entry. - it->second.type = frame_event.type; - } - - DCHECK(rtcp_events_.size() <= max_size_to_retain_); -} - -void SenderRtcpEventSubscriber::OnReceivePacketEvent( - const PacketEvent& packet_event) { - DCHECK(thread_checker_.CalledOnValidThread()); - // Do nothing as RTP sender is not interested in packet events for RTCP. -} - -void SenderRtcpEventSubscriber::GetRtcpEventsAndReset( - RtcpEventMap* rtcp_events) { - DCHECK(thread_checker_.CalledOnValidThread()); - rtcp_events->swap(rtcp_events_); - rtcp_events_.clear(); -} - -void SenderRtcpEventSubscriber::TruncateMapIfNeeded() { - // If map size has exceeded |max_size_to_retain_|, remove entry with - // the smallest RTP timestamp. - if (rtcp_events_.size() > max_size_to_retain_) { - DVLOG(2) << "RTCP event map exceeded size limit; " - << "removing oldest entry"; - // This is fine since we only insert elements one at a time. - rtcp_events_.erase(rtcp_events_.begin()); - } -} - -} // namespace cast -} // namespace media diff --git a/media/cast/rtcp/sender_rtcp_event_subscriber.h b/media/cast/rtcp/sender_rtcp_event_subscriber.h deleted file mode 100644 index 32c22d5..0000000 --- a/media/cast/rtcp/sender_rtcp_event_subscriber.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MEDIA_CAST_RTCP_SENDER_RTCP_EVENT_SUBSCRIBER_H_ -#define MEDIA_CAST_RTCP_SENDER_RTCP_EVENT_SUBSCRIBER_H_ - -#include <map> - -#include "base/threading/thread_checker.h" -#include "media/cast/logging/logging_defines.h" -#include "media/cast/logging/raw_event_subscriber.h" -#include "media/cast/rtcp/rtcp_defines.h" - -namespace media { -namespace cast { - -// The key should really be something more than just a RTP timestamp in order -// to differentiate between video and audio frames, but since the implementation -// only process video frame events, RTP timestamp only as key is fine. -typedef std::map<RtpTimestamp, RtcpEvent> RtcpEventMap; - -// A RawEventSubscriber implementation with the following properties: -// - Only processes raw event types that are relevant for sending from cast -// sender to cast receiver via RTCP. -// - Captures information to be sent over to RTCP from raw event logs into the -// more compact RtcpEvent struct. -// - Orders events by RTP timestamp with a map. -// - Internally, the map is capped at a maximum size configurable by the caller. -// The subscriber only keeps the most recent events (determined by RTP -// timestamp) up to the size limit. -class SenderRtcpEventSubscriber : public RawEventSubscriber { - public: - // |max_size_to_retain|: The object will keep up to |max_size_to_retain| - // events - // in the map. Once threshold has been reached, an event with the smallest - // RTP timestamp will be removed. - SenderRtcpEventSubscriber(const size_t max_size_to_retain); - - virtual ~SenderRtcpEventSubscriber(); - - // RawEventSubscriber implementation. - virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; - virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; - - // Assigns all collected events since last invocation to |rtcp_events|, and - // clears |rtcp_events_|. - void GetRtcpEventsAndReset(RtcpEventMap* rtcp_events); - - private: - // If |rtcp_events_.size()| exceeds |max_size_to_retain_|, remove an oldest - // entry - // (determined by RTP timestamp) so its size no greater than - // |max_size_to_retain_|. - void TruncateMapIfNeeded(); - - const size_t max_size_to_retain_; - RtcpEventMap rtcp_events_; - - // Ensures methods are only called on the main thread. - base::ThreadChecker thread_checker_; - - DISALLOW_COPY_AND_ASSIGN(SenderRtcpEventSubscriber); -}; - -} // namespace cast -} // namespace media - -#endif // MEDIA_CAST_RTCP_SENDER_RTCP_EVENT_SUBSCRIBER_H_ diff --git a/media/cast/rtcp/sender_rtcp_event_subscriber_unittest.cc b/media/cast/rtcp/sender_rtcp_event_subscriber_unittest.cc deleted file mode 100644 index d760286..0000000 --- a/media/cast/rtcp/sender_rtcp_event_subscriber_unittest.cc +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "base/test/simple_test_tick_clock.h" -#include "base/time/tick_clock.h" -#include "media/cast/cast_environment.h" -#include "media/cast/logging/logging_defines.h" -#include "media/cast/rtcp/sender_rtcp_event_subscriber.h" -#include "media/cast/test/fake_single_thread_task_runner.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace media { -namespace cast { - -namespace { - -const size_t kMaxEventEntries = 10u; - -} // namespace - -class SenderRtcpEventSubscriberTest : public ::testing::Test { - protected: - SenderRtcpEventSubscriberTest() - : testing_clock_(new base::SimpleTestTickClock()), - task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), - cast_environment_(new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_).Pass(), - task_runner_, - task_runner_, - task_runner_)), - event_subscriber_(kMaxEventEntries) { - cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber_); - } - - virtual ~SenderRtcpEventSubscriberTest() { - cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber_); - } - - base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. - scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; - scoped_refptr<CastEnvironment> cast_environment_; - SenderRtcpEventSubscriber event_subscriber_; -}; - -TEST_F(SenderRtcpEventSubscriberTest, InsertEntry) { - cast_environment_->Logging()->InsertFrameEvent( - testing_clock_->NowTicks(), FRAME_CAPTURE_BEGIN, VIDEO_EVENT, 100u, 1u); - cast_environment_->Logging()->InsertFrameEvent( - testing_clock_->NowTicks(), FRAME_CAPTURE_BEGIN, VIDEO_EVENT, 200u, 2u); - cast_environment_->Logging()->InsertFrameEvent(testing_clock_->NowTicks(), - FRAME_ENCODED, VIDEO_EVENT, - 100u, 1u); - cast_environment_->Logging()->InsertFrameEvent(testing_clock_->NowTicks(), - FRAME_ENCODED, VIDEO_EVENT, - 300u, 3u); - - RtcpEventMap events; - event_subscriber_.GetRtcpEventsAndReset(&events); - - ASSERT_EQ(3u, events.size()); - - RtcpEventMap::iterator it = events.begin(); - EXPECT_EQ(100u, it->first); - EXPECT_EQ(FRAME_ENCODED, it->second.type); - - ++it; - EXPECT_EQ(200u, it->first); - EXPECT_EQ(FRAME_CAPTURE_BEGIN, it->second.type); - - ++it; - EXPECT_EQ(300u, it->first); - EXPECT_EQ(FRAME_ENCODED, it->second.type); -} - -TEST_F(SenderRtcpEventSubscriberTest, MapReset) { - cast_environment_->Logging()->InsertFrameEvent( - testing_clock_->NowTicks(), FRAME_CAPTURE_BEGIN, VIDEO_EVENT, 100u, 1u); - - RtcpEventMap events; - event_subscriber_.GetRtcpEventsAndReset(&events); - EXPECT_EQ(1u, events.size()); - - // Call again without any logging in between, should return empty map. - event_subscriber_.GetRtcpEventsAndReset(&events); - EXPECT_TRUE(events.empty()); -} - -TEST_F(SenderRtcpEventSubscriberTest, DropEventsWhenSizeExceeded) { - for (uint32 i = 1u; i <= 10u; ++i) { - cast_environment_->Logging()->InsertFrameEvent( - testing_clock_->NowTicks(), FRAME_CAPTURE_BEGIN, VIDEO_EVENT, - i * 10, i); - } - - RtcpEventMap events; - event_subscriber_.GetRtcpEventsAndReset(&events); - - ASSERT_EQ(10u, events.size()); - EXPECT_EQ(10u, events.begin()->first); - EXPECT_EQ(100u, events.rbegin()->first); - - for (uint32 i = 1u; i <= 11u; ++i) { - cast_environment_->Logging()->InsertFrameEvent( - testing_clock_->NowTicks(), FRAME_CAPTURE_BEGIN, VIDEO_EVENT, - i * 10, i); - } - - event_subscriber_.GetRtcpEventsAndReset(&events); - - // Event with RTP timestamp 10 should have been dropped when 110 is inserted. - ASSERT_EQ(10u, events.size()); - EXPECT_EQ(20u, events.begin()->first); - EXPECT_EQ(110u, events.rbegin()->first); -} - -} // namespace cast -} // namespace media diff --git a/media/cast/video_sender/video_sender.cc b/media/cast/video_sender/video_sender.cc index 663202e..153b579 100644 --- a/media/cast/video_sender/video_sender.cc +++ b/media/cast/video_sender/video_sender.cc @@ -13,7 +13,6 @@ #include "base/message_loop/message_loop.h" #include "media/cast/cast_defines.h" #include "media/cast/rtcp/rtcp_defines.h" -#include "media/cast/rtcp/sender_rtcp_event_subscriber.h" #include "media/cast/transport/cast_transport_config.h" #include "media/cast/video_sender/external_video_encoder.h" #include "media/cast/video_sender/video_encoder_impl.h" diff --git a/media/cast/video_sender/video_sender.h b/media/cast/video_sender/video_sender.h index 5275394..d06a075 100644 --- a/media/cast/video_sender/video_sender.h +++ b/media/cast/video_sender/video_sender.h @@ -17,7 +17,6 @@ #include "media/cast/congestion_control/congestion_control.h" #include "media/cast/logging/logging_defines.h" #include "media/cast/rtcp/rtcp.h" -#include "media/cast/rtcp/sender_rtcp_event_subscriber.h" namespace media { class VideoFrame; |