summaryrefslogtreecommitdiffstats
path: root/media/cast
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-24 13:09:08 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-24 13:09:08 +0000
commit7f14cecb6320d376210401220ebe407300e2368e (patch)
tree361fa8ed1c2b67729cf4c79a79cc27925bde8cdd /media/cast
parent2eccbb3f4891f515ffb070aae7ecda2524cb7964 (diff)
downloadchromium_src-7f14cecb6320d376210401220ebe407300e2368e.zip
chromium_src-7f14cecb6320d376210401220ebe407300e2368e.tar.gz
chromium_src-7f14cecb6320d376210401220ebe407300e2368e.tar.bz2
Fixes for memory and threading issues in cast
This change fixes one issue in media/cast code. TickClock is not owned by CastEnvironment TickClock assigned to CastEnvironment is owned by the creator of CastSender/CastReceiver. However CastEnvironment is ref-counted. This means it is possible that TickClock is deleted but deferenced by some objects that still uses CastEnvironment. Fixing this requires a sweeping change in unit tests. And it also affects End2End test. The result is that CastEnvironment is shared between CastSender and CastReceiver. This adds requirements to log filtering because now a CastEnvironment used by CastSender can see receiver events. Tested this patch with valgrind and cast_unittests reports no error. BUG=336887 Review URL: https://codereview.chromium.org/145443005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246863 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cast')
-rw-r--r--media/cast/audio_receiver/audio_decoder_unittest.cc13
-rw-r--r--media/cast/audio_receiver/audio_receiver_unittest.cc27
-rw-r--r--media/cast/audio_sender/audio_encoder_unittest.cc18
-rw-r--r--media/cast/audio_sender/audio_sender_unittest.cc14
-rw-r--r--media/cast/cast_environment.cc6
-rw-r--r--media/cast/cast_environment.h4
-rw-r--r--media/cast/rtcp/rtcp_receiver_unittest.cc8
-rw-r--r--media/cast/rtcp/rtcp_sender.cc60
-rw-r--r--media/cast/rtcp/rtcp_sender.h4
-rw-r--r--media/cast/rtcp/rtcp_sender_unittest.cc10
-rw-r--r--media/cast/rtcp/rtcp_unittest.cc24
-rw-r--r--media/cast/test/encode_decode_test.cc10
-rw-r--r--media/cast/test/end2end_unittest.cc73
-rw-r--r--media/cast/test/receiver.cc4
-rw-r--r--media/cast/test/sender.cc6
-rw-r--r--media/cast/video_receiver/video_decoder_unittest.cc16
-rw-r--r--media/cast/video_receiver/video_receiver.cc4
-rw-r--r--media/cast/video_receiver/video_receiver_unittest.cc10
-rw-r--r--media/cast/video_sender/external_video_encoder_unittest.cc8
-rw-r--r--media/cast/video_sender/video_encoder_impl_unittest.cc10
-rw-r--r--media/cast/video_sender/video_sender.cc8
-rw-r--r--media/cast/video_sender/video_sender_unittest.cc15
22 files changed, 194 insertions, 158 deletions
diff --git a/media/cast/audio_receiver/audio_decoder_unittest.cc b/media/cast/audio_receiver/audio_decoder_unittest.cc
index 4c29169..f01f0ef 100644
--- a/media/cast/audio_receiver/audio_decoder_unittest.cc
+++ b/media/cast/audio_receiver/audio_decoder_unittest.cc
@@ -27,9 +27,11 @@ class TestRtpPayloadFeedback : public RtpPayloadFeedback {
class AudioDecoderTest : public ::testing::Test {
protected:
AudioDecoderTest() {
- testing_clock_.Advance(base::TimeDelta::FromMilliseconds(1234));
- task_runner_ = new test::FakeTaskRunner(&testing_clock_);
- cast_environment_ = new CastEnvironment(&testing_clock_, task_runner_,
+ testing_clock_ = new base::SimpleTestTickClock();
+ testing_clock_->Advance(base::TimeDelta::FromMilliseconds(1234));
+ task_runner_ = new test::FakeTaskRunner(testing_clock_);
+ cast_environment_ = new CastEnvironment(
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_,
task_runner_, task_runner_, task_runner_, task_runner_, task_runner_,
GetDefaultCastReceiverLoggingConfig());
}
@@ -41,7 +43,8 @@ class AudioDecoderTest : public ::testing::Test {
}
TestRtpPayloadFeedback cast_feedback_;
- base::SimpleTestTickClock testing_clock_;
+ // Owned by CastEnvironment.
+ base::SimpleTestTickClock* testing_clock_;
scoped_refptr<test::FakeTaskRunner> task_runner_;
scoped_refptr<CastEnvironment> cast_environment_;
scoped_ptr<AudioDecoder> audio_decoder_;
@@ -162,7 +165,7 @@ TEST_F(AudioDecoderTest, Pcm16StereoNoResampleTwoPackets) {
}
// Test cast callback.
audio_decoder_->SendCastMessage();
- testing_clock_.Advance(base::TimeDelta::FromMilliseconds(33));
+ testing_clock_->Advance(base::TimeDelta::FromMilliseconds(33));
audio_decoder_->SendCastMessage();
}
diff --git a/media/cast/audio_receiver/audio_receiver_unittest.cc b/media/cast/audio_receiver/audio_receiver_unittest.cc
index aa06d9c..660291d 100644
--- a/media/cast/audio_receiver/audio_receiver_unittest.cc
+++ b/media/cast/audio_receiver/audio_receiver_unittest.cc
@@ -75,10 +75,12 @@ class AudioReceiverTest : public ::testing::Test {
audio_config_.codec = transport::kPcm16;
audio_config_.use_external_decoder = false;
audio_config_.feedback_ssrc = 1234;
- testing_clock_.Advance(
+ testing_clock_ = new base::SimpleTestTickClock();
+ testing_clock_->Advance(
base::TimeDelta::FromMilliseconds(kStartMillisecond));
- task_runner_ = new test::FakeTaskRunner(&testing_clock_);
- cast_environment_ = new CastEnvironment(&testing_clock_, task_runner_,
+ task_runner_ = new test::FakeTaskRunner(testing_clock_);
+ cast_environment_ = new CastEnvironment(
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_,
task_runner_, task_runner_, task_runner_, task_runner_,
task_runner_, GetDefaultCastReceiverLoggingConfig());
test_audio_encoder_callback_ = new TestAudioEncoderCallback();
@@ -108,7 +110,7 @@ class AudioReceiverTest : public ::testing::Test {
AudioReceiverConfig audio_config_;
std::vector<uint8> payload_;
RtpCastHeader rtp_header_;
- base::SimpleTestTickClock testing_clock_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
transport::MockPacedPacketSender mock_transport_;
scoped_refptr<test::FakeTaskRunner> task_runner_;
scoped_ptr<PeerAudioReceiver> receiver_;
@@ -124,7 +126,8 @@ TEST_F(AudioReceiverTest, GetOnePacketEncodedframe) {
payload_.size(), rtp_header_);
transport::EncodedAudioFrame audio_frame;
base::TimeTicks playout_time;
- test_audio_encoder_callback_->SetExpectedResult(0, testing_clock_.NowTicks());
+ test_audio_encoder_callback_->SetExpectedResult(
+ 0, testing_clock_->NowTicks());
AudioFrameEncodedCallback frame_encoded_callback =
base::Bind(&TestAudioEncoderCallback::DeliverEncodedAudioFrame,
@@ -151,7 +154,8 @@ TEST_F(AudioReceiverTest, MultiplePendingGetCalls) {
transport::EncodedAudioFrame audio_frame;
base::TimeTicks playout_time;
- test_audio_encoder_callback_->SetExpectedResult(0, testing_clock_.NowTicks());
+ test_audio_encoder_callback_->SetExpectedResult(
+ 0, testing_clock_->NowTicks());
task_runner_->RunTasks();
EXPECT_EQ(1, test_audio_encoder_callback_->number_times_called());
@@ -160,11 +164,11 @@ TEST_F(AudioReceiverTest, MultiplePendingGetCalls) {
uint32 ntp_high;
uint32 ntp_low;
- ConvertTimeTicksToNtp(testing_clock_.NowTicks(), &ntp_high, &ntp_low);
+ ConvertTimeTicksToNtp(testing_clock_->NowTicks(), &ntp_high, &ntp_low);
rtcp_packet.AddSrWithNtp(audio_config_.feedback_ssrc, ntp_high, ntp_low,
rtp_header_.webrtc.header.timestamp);
- testing_clock_.Advance(base::TimeDelta::FromMilliseconds(20));
+ testing_clock_->Advance(base::TimeDelta::FromMilliseconds(20));
receiver_->IncomingPacket(rtcp_packet.Packet(), rtcp_packet.Length(),
base::Bind(AudioReceiverTest::DummyDeletePacket, rtcp_packet.Packet()));
@@ -177,7 +181,7 @@ TEST_F(AudioReceiverTest, MultiplePendingGetCalls) {
rtp_header_.reference_frame_id = 0;
rtp_header_.webrtc.header.timestamp = 960;
test_audio_encoder_callback_->SetExpectedResult(2,
- testing_clock_.NowTicks() + base::TimeDelta::FromMilliseconds(100));
+ testing_clock_->NowTicks() + base::TimeDelta::FromMilliseconds(100));
receiver_->IncomingParsedRtpPacket(payload_.data(), payload_.size(),
rtp_header_);
@@ -190,12 +194,13 @@ TEST_F(AudioReceiverTest, MultiplePendingGetCalls) {
// Through on one more pending callback.
receiver_->GetEncodedAudioFrame(frame_encoded_callback);
- testing_clock_.Advance(base::TimeDelta::FromMilliseconds(100));
+ testing_clock_->Advance(base::TimeDelta::FromMilliseconds(100));
task_runner_->RunTasks();
EXPECT_EQ(2, test_audio_encoder_callback_->number_times_called());
- test_audio_encoder_callback_->SetExpectedResult(3, testing_clock_.NowTicks());
+ test_audio_encoder_callback_->SetExpectedResult(
+ 3, testing_clock_->NowTicks());
// Through on one more pending audio frame.
rtp_header_.frame_id = 3;
diff --git a/media/cast/audio_sender/audio_encoder_unittest.cc b/media/cast/audio_sender/audio_encoder_unittest.cc
index 95feab4..877f2f2 100644
--- a/media/cast/audio_sender/audio_encoder_unittest.cc
+++ b/media/cast/audio_sender/audio_encoder_unittest.cc
@@ -90,13 +90,15 @@ class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> {
public:
AudioEncoderTest() {
InitializeMediaLibraryForTesting();
- testing_clock_.Advance(
+ testing_clock_ = new base::SimpleTestTickClock();
+ testing_clock_->Advance(
base::TimeDelta::FromMilliseconds(kStartMillisecond));
}
virtual void SetUp() {
- task_runner_ = new test::FakeTaskRunner(&testing_clock_);
- cast_environment_ = new CastEnvironment(&testing_clock_, task_runner_,
+ task_runner_ = new test::FakeTaskRunner(testing_clock_);
+ cast_environment_ = new CastEnvironment(
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_,
task_runner_, task_runner_, task_runner_, task_runner_, task_runner_,
GetDefaultCastSenderLoggingConfig());
}
@@ -110,26 +112,26 @@ class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> {
CreateObjectsForCodec(codec);
- receiver_->SetRecordedTimeLowerBound(testing_clock_.NowTicks());
+ receiver_->SetRecordedTimeLowerBound(testing_clock_->NowTicks());
for (size_t i = 0; i < scenario.num_durations; ++i) {
const base::TimeDelta duration =
base::TimeDelta::FromMilliseconds(scenario.durations_in_ms[i]);
receiver_->SetRecordedTimeUpperBound(
- testing_clock_.NowTicks() + duration);
+ testing_clock_->NowTicks() + duration);
const scoped_ptr<AudioBus> bus(
audio_bus_factory_->NextAudioBus(duration));
const int last_count = release_callback_count_;
audio_encoder_->InsertAudio(
- bus.get(), testing_clock_.NowTicks(),
+ bus.get(), testing_clock_->NowTicks(),
base::Bind(&AudioEncoderTest::IncrementReleaseCallbackCounter,
base::Unretained(this)));
task_runner_->RunTasks();
EXPECT_EQ(1, release_callback_count_ - last_count)
<< "Release callback was not invoked once.";
- testing_clock_.Advance(duration);
+ testing_clock_->Advance(duration);
}
DVLOG(1) << "Received " << receiver_->frames_received()
@@ -163,7 +165,7 @@ class AudioEncoderTest : public ::testing::TestWithParam<TestScenario> {
++release_callback_count_;
}
- base::SimpleTestTickClock testing_clock_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
scoped_refptr<test::FakeTaskRunner> task_runner_;
scoped_ptr<TestAudioBusFactory> audio_bus_factory_;
scoped_ptr<TestEncodedAudioFrameReceiver> receiver_;
diff --git a/media/cast/audio_sender/audio_sender_unittest.cc b/media/cast/audio_sender/audio_sender_unittest.cc
index ecbd910..4fdff91 100644
--- a/media/cast/audio_sender/audio_sender_unittest.cc
+++ b/media/cast/audio_sender/audio_sender_unittest.cc
@@ -65,11 +65,13 @@ class AudioSenderTest : public ::testing::Test {
protected:
AudioSenderTest() {
InitializeMediaLibraryForTesting();
- testing_clock_.Advance(
+ testing_clock_ = new base::SimpleTestTickClock();
+ testing_clock_->Advance(
base::TimeDelta::FromMilliseconds(kStartMillisecond));
- task_runner_ = new test::FakeTaskRunner(&testing_clock_);
+ task_runner_ = new test::FakeTaskRunner(testing_clock_);
cast_environment_ = new CastEnvironment(
- &testing_clock_, task_runner_, task_runner_, task_runner_, task_runner_,
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(),
+ task_runner_, task_runner_, task_runner_, task_runner_,
task_runner_, task_runner_, GetDefaultCastSenderLoggingConfig());
audio_config_.codec = transport::kOpus;
audio_config_.use_external_encoder = false;
@@ -82,7 +84,7 @@ class AudioSenderTest : public ::testing::Test {
transport_config.audio_rtp_payload_type = 127;
transport_config.audio_channels = 2;
transport_sender_.reset(new transport::CastTransportSenderImpl(
- &testing_clock_,
+ testing_clock_,
transport_config,
base::Bind(&UpdateCastTransportStatus), task_runner_));
transport_sender_->InsertFakeTransportForTesting(&transport_);
@@ -97,7 +99,7 @@ class AudioSenderTest : public ::testing::Test {
EXPECT_EQ(status, transport::TRANSPORT_INITIALIZED);
}
- base::SimpleTestTickClock testing_clock_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
TestPacketSender transport_;
scoped_ptr<transport::CastTransportSenderImpl> transport_sender_;
scoped_refptr<test::FakeTaskRunner> task_runner_;
@@ -145,7 +147,7 @@ TEST_F(AudioSenderTest, RtcpTimer) {
// Make sure that we send at least one RTCP packet.
base::TimeDelta max_rtcp_timeout =
base::TimeDelta::FromMilliseconds(1 + kDefaultRtcpIntervalMs * 3 / 2);
- testing_clock_.Advance(max_rtcp_timeout);
+ testing_clock_->Advance(max_rtcp_timeout);
task_runner_->RunTasks();
EXPECT_GE(transport_.number_of_rtp_packets(), 1);
EXPECT_EQ(transport_.number_of_rtcp_packets(), 1);
diff --git a/media/cast/cast_environment.cc b/media/cast/cast_environment.cc
index ea79e10..dddd0f7 100644
--- a/media/cast/cast_environment.cc
+++ b/media/cast/cast_environment.cc
@@ -22,7 +22,7 @@ namespace media {
namespace cast {
CastEnvironment::CastEnvironment(
- base::TickClock* clock,
+ scoped_ptr<base::TickClock> clock,
scoped_refptr<TaskRunner> main_thread_proxy,
scoped_refptr<TaskRunner> audio_encode_thread_proxy,
scoped_refptr<TaskRunner> audio_decode_thread_proxy,
@@ -30,7 +30,7 @@ CastEnvironment::CastEnvironment(
scoped_refptr<TaskRunner> video_decode_thread_proxy,
scoped_refptr<TaskRunner> transport_thread_proxy,
const CastLoggingConfig& config)
- : clock_(clock),
+ : clock_(clock.Pass()),
main_thread_proxy_(main_thread_proxy),
audio_encode_thread_proxy_(audio_encode_thread_proxy),
audio_decode_thread_proxy_(audio_decode_thread_proxy),
@@ -113,7 +113,7 @@ bool CastEnvironment::CurrentlyOn(ThreadId identifier) {
}
base::TickClock* CastEnvironment::Clock() const {
- return clock_;
+ return clock_.get();
}
LoggingImpl* CastEnvironment::Logging() {
diff --git a/media/cast/cast_environment.h b/media/cast/cast_environment.h
index 31e4f50..f7f9b7e2 100644
--- a/media/cast/cast_environment.h
+++ b/media/cast/cast_environment.h
@@ -38,7 +38,7 @@ class CastEnvironment : public base::RefCountedThreadSafe<CastEnvironment> {
TRANSPORT,
};
- CastEnvironment(base::TickClock* clock,
+ CastEnvironment(scoped_ptr<base::TickClock> clock,
scoped_refptr<base::TaskRunner> main_thread_proxy,
scoped_refptr<base::TaskRunner> audio_encode_thread_proxy,
scoped_refptr<base::TaskRunner> audio_decode_thread_proxy,
@@ -77,7 +77,7 @@ class CastEnvironment : public base::RefCountedThreadSafe<CastEnvironment> {
private:
friend class base::RefCountedThreadSafe<CastEnvironment>;
- base::TickClock* const clock_; // Not owned by this class.
+ scoped_ptr<base::TickClock> clock_;
scoped_refptr<base::TaskRunner> main_thread_proxy_;
scoped_refptr<base::TaskRunner> audio_encode_thread_proxy_;
scoped_refptr<base::TaskRunner> audio_decode_thread_proxy_;
diff --git a/media/cast/rtcp/rtcp_receiver_unittest.cc b/media/cast/rtcp/rtcp_receiver_unittest.cc
index f325b14..5bc4419 100644
--- a/media/cast/rtcp/rtcp_receiver_unittest.cc
+++ b/media/cast/rtcp/rtcp_receiver_unittest.cc
@@ -153,8 +153,10 @@ class RtcpReceiverCastLogVerification : public RtcpReceiverFeedback {
class RtcpReceiverTest : public ::testing::Test {
protected:
RtcpReceiverTest()
- : task_runner_(new test::FakeTaskRunner(&testing_clock_)),
- cast_environment_(new CastEnvironment(&testing_clock_, task_runner_,
+ : testing_clock_(new base::SimpleTestTickClock()),
+ task_runner_(new test::FakeTaskRunner(testing_clock_)),
+ cast_environment_(new CastEnvironment(
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_,
task_runner_, task_runner_, task_runner_, task_runner_,
task_runner_, GetDefaultCastReceiverLoggingConfig())),
rtcp_receiver_(new RtcpReceiver(cast_environment_,
@@ -201,7 +203,7 @@ class RtcpReceiverTest : public ::testing::Test {
rtcp_receiver_->IncomingRtcpPacket(&rtcp_parser);
}
- base::SimpleTestTickClock testing_clock_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
scoped_refptr<test::FakeTaskRunner> task_runner_;
scoped_refptr<CastEnvironment> cast_environment_;
MockRtcpReceiverFeedback mock_receiver_feedback_;
diff --git a/media/cast/rtcp/rtcp_sender.cc b/media/cast/rtcp/rtcp_sender.cc
index 87d3889..23f7466 100644
--- a/media/cast/rtcp/rtcp_sender.cc
+++ b/media/cast/rtcp/rtcp_sender.cc
@@ -20,48 +20,45 @@ static const size_t kRtcpReceiverFrameLogSize = 8;
static const size_t kRtcpReceiverEventLogSize = 4;
namespace {
-uint16 MergeEventTypeAndTimestampForWireFormat(
- const media::cast::CastLoggingEvent& event,
- const base::TimeDelta& time_delta) {
- int64 time_delta_ms = time_delta.InMilliseconds();
- // Max delta is 4096 milliseconds.
- DCHECK_GE(GG_INT64_C(0xfff), time_delta_ms);
-
- uint16 event_type_and_timestamp_delta =
- static_cast<uint16>(time_delta_ms & 0xfff);
- uint16 event_type = 0;
+// Converts a log event type to an integer value.
+int ConvertEventTypeToWireFormat(const media::cast::CastLoggingEvent& event) {
switch (event) {
case media::cast::kAudioAckSent:
- event_type = 1;
- break;
+ return 1;
case media::cast::kAudioPlayoutDelay:
- event_type = 2;
- break;
+ return 2;
case media::cast::kAudioFrameDecoded:
- event_type = 3;
- break;
+ return 3;
case media::cast::kAudioPacketReceived:
- event_type = 4;
- break;
+ return 4;
case media::cast::kVideoAckSent:
- event_type = 5;
- break;
+ return 5;
case media::cast::kVideoFrameDecoded:
- event_type = 6;
- break;
+ return 6;
case media::cast::kVideoRenderDelay:
- event_type = 7;
- break;
+ return 7;
case media::cast::kVideoPacketReceived:
- event_type = 8;
- break;
+ return 8;
case media::cast::kDuplicatePacketReceived:
- event_type = 9;
- break;
+ return 9;
default:
- NOTREACHED();
+ return 0; // Not an interesting event.
}
+}
+
+uint16 MergeEventTypeAndTimestampForWireFormat(
+ const media::cast::CastLoggingEvent& event,
+ const base::TimeDelta& time_delta) {
+ int64 time_delta_ms = time_delta.InMilliseconds();
+ // Max delta is 4096 milliseconds.
+ DCHECK_GE(GG_INT64_C(0xfff), time_delta_ms);
+
+ uint16 event_type_and_timestamp_delta =
+ static_cast<uint16>(time_delta_ms & 0xfff);
+
+ uint16 event_type = ConvertEventTypeToWireFormat(event);
+ DCHECK(event_type);
DCHECK(!(event_type & 0xfff0));
return (event_type << 12) + event_type_and_timestamp_delta;
}
@@ -147,6 +144,11 @@ RtcpSender::RtcpSender(scoped_refptr<CastEnvironment> cast_environment,
RtcpSender::~RtcpSender() {}
+// static
+bool RtcpSender::IsReceiverEvent(const media::cast::CastLoggingEvent& event) {
+ return ConvertEventTypeToWireFormat(event) != 0;
+}
+
void RtcpSender::SendRtcpFromRtpReceiver(
uint32 packet_type_flags,
const transport::RtcpReportBlock* report_block,
diff --git a/media/cast/rtcp/rtcp_sender.h b/media/cast/rtcp/rtcp_sender.h
index 1c3465b..d278fa8 100644
--- a/media/cast/rtcp/rtcp_sender.h
+++ b/media/cast/rtcp/rtcp_sender.h
@@ -28,6 +28,10 @@ class RtcpSender {
virtual ~RtcpSender();
+ // Returns true if |event| is an interesting receiver event.
+ // Such an event should be sent via RTCP.
+ static bool IsReceiverEvent(const media::cast::CastLoggingEvent& event);
+
void SendRtcpFromRtpReceiver(uint32 packet_type_flags,
const transport::RtcpReportBlock* report_block,
const RtcpReceiverReferenceTimeReport* rrtr,
diff --git a/media/cast/rtcp/rtcp_sender_unittest.cc b/media/cast/rtcp/rtcp_sender_unittest.cc
index 2ed6041..97e9461 100644
--- a/media/cast/rtcp/rtcp_sender_unittest.cc
+++ b/media/cast/rtcp/rtcp_sender_unittest.cc
@@ -61,17 +61,19 @@ class TestRtcpTransport : public transport::PacedPacketSender {
class RtcpSenderTest : public ::testing::Test {
protected:
RtcpSenderTest()
- : task_runner_(new test::FakeTaskRunner(&testing_clock_)),
- cast_environment_(new CastEnvironment(&testing_clock_, task_runner_,
+ : testing_clock_(new base::SimpleTestTickClock()),
+ task_runner_(new test::FakeTaskRunner(testing_clock_)),
+ cast_environment_(new CastEnvironment(
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(),
task_runner_, task_runner_, task_runner_, task_runner_,
- task_runner_, GetDefaultCastSenderLoggingConfig())),
+ task_runner_, task_runner_, GetDefaultCastSenderLoggingConfig())),
rtcp_sender_(new RtcpSender(cast_environment_,
&test_transport_,
kSendingSsrc,
kCName)) {
}
- base::SimpleTestTickClock testing_clock_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
TestRtcpTransport test_transport_;
scoped_refptr<test::FakeTaskRunner> task_runner_;
scoped_refptr<CastEnvironment> cast_environment_;
diff --git a/media/cast/rtcp/rtcp_unittest.cc b/media/cast/rtcp/rtcp_unittest.cc
index 605c688..5fca5f1 100644
--- a/media/cast/rtcp/rtcp_unittest.cc
+++ b/media/cast/rtcp/rtcp_unittest.cc
@@ -147,17 +147,19 @@ class RtcpPeer : public Rtcp {
class RtcpTest : public ::testing::Test {
protected:
RtcpTest()
- : task_runner_(new test::FakeTaskRunner(&testing_clock_)),
- cast_environment_(new CastEnvironment(&testing_clock_, task_runner_,
+ : testing_clock_(new base::SimpleTestTickClock()),
+ task_runner_(new test::FakeTaskRunner(testing_clock_)),
+ cast_environment_(new CastEnvironment(
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(),
task_runner_, task_runner_, task_runner_, task_runner_,
- task_runner_, GetDefaultCastSenderLoggingConfig())),
- sender_to_receiver_(&testing_clock_),
- receiver_to_sender_(cast_environment_, &testing_clock_) {
- testing_clock_.Advance(
+ task_runner_, task_runner_, GetDefaultCastSenderLoggingConfig())),
+ sender_to_receiver_(testing_clock_),
+ receiver_to_sender_(cast_environment_, testing_clock_) {
+ testing_clock_->Advance(
base::TimeDelta::FromMilliseconds(kStartMillisecond));
transport::CastTransportConfig transport_config;
transport_sender_.reset(new transport::CastTransportSenderImpl(
- &testing_clock_,
+ testing_clock_,
transport_config,
base::Bind(&UpdateCastTransportStatus), task_runner_));
transport_sender_->InsertFakeTransportForTesting(&sender_to_receiver_);
@@ -173,12 +175,12 @@ class RtcpTest : public ::testing::Test {
void RunTasks(int during_ms) {
for (int i = 0; i < during_ms; ++i) {
// Call process the timers every 1 ms.
- testing_clock_.Advance(base::TimeDelta::FromMilliseconds(1));
+ testing_clock_->Advance(base::TimeDelta::FromMilliseconds(1));
task_runner_->RunTasks();
}
}
- base::SimpleTestTickClock testing_clock_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
scoped_refptr<test::FakeTaskRunner> task_runner_;
scoped_refptr<CastEnvironment> cast_environment_;
RtcpTestPacketSender sender_to_receiver_;
@@ -207,8 +209,8 @@ TEST_F(RtcpTest, TimeToSend) {
kRtcpIntervalMs * 3 / 2),
rtcp.TimeToSendNextRtcpReport());
base::TimeDelta delta = rtcp.TimeToSendNextRtcpReport() - start_time;
- testing_clock_.Advance(delta);
- EXPECT_EQ(testing_clock_.NowTicks(), rtcp.TimeToSendNextRtcpReport());
+ testing_clock_->Advance(delta);
+ EXPECT_EQ(testing_clock_->NowTicks(), rtcp.TimeToSendNextRtcpReport());
}
TEST_F(RtcpTest, BasicSenderReport) {
diff --git a/media/cast/test/encode_decode_test.cc b/media/cast/test/encode_decode_test.cc
index 9464872..1d5fe56 100644
--- a/media/cast/test/encode_decode_test.cc
+++ b/media/cast/test/encode_decode_test.cc
@@ -73,14 +73,16 @@ class EncodeDecodeTestFrameCallback :
class EncodeDecodeTest : public ::testing::Test {
protected:
EncodeDecodeTest()
- : task_runner_(new test::FakeTaskRunner(&testing_clock_)),
+ : testing_clock_(new base::SimpleTestTickClock()),
+ task_runner_(new test::FakeTaskRunner(testing_clock_)),
// CastEnvironment will only be used by the vp8 decoder; Enable only the
// video decoder and main threads.
- cast_environment_(new CastEnvironment(&testing_clock_, task_runner_,
+ cast_environment_(new CastEnvironment(
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_,
NULL, NULL, NULL, task_runner_, NULL,
GetDefaultCastReceiverLoggingConfig())),
test_callback_(new EncodeDecodeTestFrameCallback()) {
- testing_clock_.Advance(
+ testing_clock_->Advance(
base::TimeDelta::FromMilliseconds(kStartMillisecond));
encoder_config_.max_number_of_video_buffers_used = 1;
encoder_config_.number_of_cores = 1;
@@ -112,7 +114,7 @@ class EncodeDecodeTest : public ::testing::Test {
scoped_ptr<Vp8Encoder> encoder_;
scoped_ptr<Vp8Decoder> decoder_;
scoped_refptr<media::VideoFrame> video_frame_;
- base::SimpleTestTickClock testing_clock_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
scoped_refptr<test::FakeTaskRunner> task_runner_;
scoped_refptr<CastEnvironment> cast_environment_;
scoped_refptr<EncodeDecodeTestFrameCallback> test_callback_;
diff --git a/media/cast/test/end2end_unittest.cc b/media/cast/test/end2end_unittest.cc
index 842387a..88b6e34 100644
--- a/media/cast/test/end2end_unittest.cc
+++ b/media/cast/test/end2end_unittest.cc
@@ -341,19 +341,18 @@ class End2EndTest : public ::testing::Test {
protected:
End2EndTest()
: start_time_(),
- task_runner_(new test::FakeTaskRunner(&testing_clock_)),
- transport_task_runner_(new test::FakeTaskRunner(&testing_clock_)),
- cast_environment_sender_(new CastEnvironment(&testing_clock_,
+ testing_clock_(new base::SimpleTestTickClock()),
+ task_runner_(new test::FakeTaskRunner(testing_clock_)),
+ transport_task_runner_(new test::FakeTaskRunner(testing_clock_)),
+ cast_environment_(new CastEnvironment(
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(),
task_runner_, task_runner_, task_runner_, task_runner_,
task_runner_, task_runner_, EnableCastLoggingConfig(true))),
- cast_environment_receiver_(new CastEnvironment(&testing_clock_,
- task_runner_, task_runner_, task_runner_, task_runner_,
- task_runner_, task_runner_, EnableCastLoggingConfig(false))),
- receiver_to_sender_(cast_environment_receiver_),
- sender_to_receiver_(cast_environment_sender_),
+ receiver_to_sender_(cast_environment_),
+ sender_to_receiver_(cast_environment_),
test_receiver_audio_callback_(new TestReceiverAudioCallback()),
test_receiver_video_callback_(new TestReceiverVideoCallback()) {
- testing_clock_.Advance(
+ testing_clock_->Advance(
base::TimeDelta::FromMilliseconds(kStartMillisecond));
}
@@ -429,18 +428,18 @@ class End2EndTest : public ::testing::Test {
void Create() {
cast_receiver_.reset(CastReceiver::CreateCastReceiver(
- cast_environment_receiver_,
+ cast_environment_,
audio_receiver_config_,
video_receiver_config_,
&receiver_to_sender_));
transport_sender_.reset(new transport::CastTransportSenderImpl(
- &testing_clock_,
+ testing_clock_,
transport_config_,
base::Bind(&UpdateCastTransportStatus),
transport_task_runner_));
transport_sender_->InsertFakeTransportForTesting(&sender_to_receiver_);
- cast_sender_.reset(CastSender::CreateCastSender(cast_environment_sender_,
+ cast_sender_.reset(CastSender::CreateCastSender(cast_environment_,
audio_sender_config_,
video_sender_config_,
NULL,
@@ -461,9 +460,9 @@ class End2EndTest : public ::testing::Test {
void SendVideoFrame(int start_value, const base::TimeTicks& capture_time) {
if (start_time_.is_null())
- start_time_ = testing_clock_.NowTicks();
- start_time_ = testing_clock_.NowTicks();
- base::TimeDelta time_diff = testing_clock_.NowTicks() - start_time_;
+ start_time_ = testing_clock_->NowTicks();
+ start_time_ = testing_clock_->NowTicks();
+ base::TimeDelta time_diff = testing_clock_->NowTicks() - start_time_;
gfx::Size size(kVideoWidth, kVideoHeight);
EXPECT_TRUE(VideoFrame::IsValidConfig(VideoFrame::I420,
size, gfx::Rect(size), size));
@@ -477,7 +476,7 @@ class End2EndTest : public ::testing::Test {
void RunTasks(int during_ms) {
for (int i = 0; i < during_ms; ++i) {
// Call process the timers every 1 ms.
- testing_clock_.Advance(base::TimeDelta::FromMilliseconds(1));
+ testing_clock_->Advance(base::TimeDelta::FromMilliseconds(1));
task_runner_->RunTasks();
transport_task_runner_->RunTasks();
}
@@ -489,12 +488,11 @@ class End2EndTest : public ::testing::Test {
VideoSenderConfig video_sender_config_;
transport::CastTransportConfig transport_config_;
- base::SimpleTestTickClock testing_clock_;
base::TimeTicks start_time_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
scoped_refptr<test::FakeTaskRunner> task_runner_;
scoped_refptr<test::FakeTaskRunner> transport_task_runner_;
- scoped_refptr<CastEnvironment> cast_environment_sender_;
- scoped_refptr<CastEnvironment> cast_environment_receiver_;
+ scoped_refptr<CastEnvironment> cast_environment_;
LoopBackTransport receiver_to_sender_;
LoopBackTransport sender_to_receiver_;
@@ -524,7 +522,7 @@ TEST_F(End2EndTest, DISABLED_LoopNoLossPcm16) {
for (; i < 10; ++i) {
int num_10ms_blocks = audio_diff / 10;
audio_diff -= num_10ms_blocks * 10;
- base::TimeTicks send_time = testing_clock_.NowTicks();
+ base::TimeTicks send_time = testing_clock_->NowTicks();
test_receiver_video_callback_->AddExpectedResult(video_start,
video_sender_config_.width, video_sender_config_.height, send_time);
@@ -590,7 +588,7 @@ TEST_F(End2EndTest, MAYBE_LoopNoLossPcm16ExternalDecoder) {
int i = 0;
for (; i < 10; ++i) {
- base::TimeTicks send_time = testing_clock_.NowTicks();
+ base::TimeTicks send_time = testing_clock_->NowTicks();
scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus(
base::TimeDelta::FromMilliseconds(10)));
test_receiver_audio_callback_->AddExpectedResult(
@@ -624,7 +622,7 @@ TEST_F(End2EndTest, MAYBE_LoopNoLossOpus) {
int i = 0;
for (; i < 10; ++i) {
int num_10ms_blocks = 3;
- base::TimeTicks send_time = testing_clock_.NowTicks();
+ base::TimeTicks send_time = testing_clock_->NowTicks();
scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus(
base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks));
@@ -674,7 +672,7 @@ TEST_F(End2EndTest, DISABLED_StartSenderBeforeReceiver) {
int num_10ms_blocks = audio_diff / 10;
audio_diff -= num_10ms_blocks * 10;
- base::TimeTicks send_time = testing_clock_.NowTicks();
+ base::TimeTicks send_time = testing_clock_->NowTicks();
scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus(
base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks));
@@ -695,7 +693,7 @@ TEST_F(End2EndTest, DISABLED_StartSenderBeforeReceiver) {
for (; j < 10; ++j) {
int num_10ms_blocks = audio_diff / 10;
audio_diff -= num_10ms_blocks * 10;
- base::TimeTicks send_time = testing_clock_.NowTicks();
+ base::TimeTicks send_time = testing_clock_->NowTicks();
scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus(
base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks));
@@ -747,7 +745,7 @@ TEST_F(End2EndTest, GlitchWith3Buffers) {
Create();
int video_start = 50;
- base::TimeTicks send_time = testing_clock_.NowTicks();
+ base::TimeTicks send_time = testing_clock_->NowTicks();
SendVideoFrame(video_start, send_time);
RunTasks(kFrameTimerMs);
@@ -764,7 +762,7 @@ TEST_F(End2EndTest, GlitchWith3Buffers) {
// Introduce a glitch lasting for 10 frames.
sender_to_receiver_.SetSendPackets(false);
for (int i = 0; i < 10; ++i) {
- send_time = testing_clock_.NowTicks();
+ send_time = testing_clock_->NowTicks();
// First 3 will be sent and lost.
SendVideoFrame(video_start, send_time);
RunTasks(kFrameTimerMs);
@@ -772,7 +770,7 @@ TEST_F(End2EndTest, GlitchWith3Buffers) {
}
sender_to_receiver_.SetSendPackets(true);
RunTasks(100);
- send_time = testing_clock_.NowTicks();
+ send_time = testing_clock_->NowTicks();
// Frame 1 should be acked by now and we should have an opening to send 4.
SendVideoFrame(video_start, send_time);
@@ -801,7 +799,7 @@ TEST_F(End2EndTest, DropEveryOtherFrame3Buffers) {
int i = 0;
for (; i < 20; ++i) {
- send_time = testing_clock_.NowTicks();
+ send_time = testing_clock_->NowTicks();
SendVideoFrame(video_start, send_time);
if (i % 2 == 0) {
@@ -831,7 +829,7 @@ TEST_F(End2EndTest, ResetReferenceFrameId) {
int frames_counter = 0;
for (; frames_counter < 20; ++frames_counter) {
- const base::TimeTicks send_time = testing_clock_.NowTicks();
+ const base::TimeTicks send_time = testing_clock_->NowTicks();
SendVideoFrame(frames_counter, send_time);
test_receiver_video_callback_->AddExpectedResult(frames_counter,
@@ -864,7 +862,7 @@ TEST_F(End2EndTest, CryptoVideo) {
int frames_counter = 0;
for (; frames_counter < 3; ++frames_counter) {
- const base::TimeTicks send_time = testing_clock_.NowTicks();
+ const base::TimeTicks send_time = testing_clock_->NowTicks();
SendVideoFrame(frames_counter, send_time);
@@ -906,7 +904,7 @@ TEST_F(End2EndTest, MAYBE_CryptoAudio) {
for (; frames_counter < 3; ++frames_counter) {
int num_10ms_blocks = 2;
- const base::TimeTicks send_time = testing_clock_.NowTicks();
+ const base::TimeTicks send_time = testing_clock_->NowTicks();
scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus(
base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks));
@@ -951,7 +949,7 @@ TEST_F(End2EndTest, VideoLogging) {
int video_start = 1;
int i = 0;
for (; i < 1; ++i) {
- base::TimeTicks send_time = testing_clock_.NowTicks();
+ base::TimeTicks send_time = testing_clock_->NowTicks();
test_receiver_video_callback_->AddExpectedResult(video_start,
video_sender_config_.width, video_sender_config_.height, send_time);
@@ -970,7 +968,7 @@ TEST_F(End2EndTest, VideoLogging) {
EXPECT_EQ(i, test_receiver_video_callback_->number_times_called());
// Sender logging tests.
- LoggingImpl* sender_log = cast_environment_sender_->Logging();
+ LoggingImpl* sender_log = cast_environment_->Logging();
// Verify that all frames and all required events were logged.
FrameRawMap frame_raw_log = sender_log->GetFrameRawData();
@@ -1020,13 +1018,11 @@ TEST_F(End2EndTest, VideoLogging) {
event_log = (++(packet_it->second.packet_map.begin()))->second.type;
EXPECT_TRUE((std::find(event_log.begin(), event_log.end(),
kVideoPacketReceived)) != event_log.end());
- // Verify that there were no other events logged with respect to this frame.
- EXPECT_EQ(1u, event_log.size());
RunTasks(750); // Make sure that we send a RTCP message with the log.
// Receiver logging tests.
- LoggingImpl* receiver_log = cast_environment_receiver_->Logging();
+ LoggingImpl* receiver_log = cast_environment_->Logging();
// Verify that all frames and all required events were logged.
frame_raw_log = receiver_log->GetFrameRawData();
@@ -1044,7 +1040,6 @@ TEST_F(End2EndTest, VideoLogging) {
kVideoRenderDelay);
EXPECT_TRUE(event_it != event_log.end());
- EXPECT_EQ(2u, event_log.size());
}
// TODO(mikhal): Crashes on the bots. Re-enable. http://crbug.com/329563
@@ -1065,7 +1060,7 @@ TEST_F(End2EndTest, MAYBE_AudioLogging) {
for (; i < 10; ++i) {
int num_10ms_blocks = audio_diff / 10;
audio_diff -= num_10ms_blocks * 10;
- base::TimeTicks send_time = testing_clock_.NowTicks();
+ base::TimeTicks send_time = testing_clock_->NowTicks();
scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus(
base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks));
@@ -1104,7 +1099,7 @@ TEST_F(End2EndTest, MAYBE_AudioLogging) {
//EXPECT_EQ(i - 1, test_receiver_audio_callback_->number_times_called());
EXPECT_EQ(i - 1, test_receiver_audio_callback_->number_times_called());
// Logging tests.
- LoggingImpl* sender_log = cast_environment_sender_->Logging();
+ LoggingImpl* sender_log = cast_environment_->Logging();
// Verify that all frames and all required events were logged.
FrameRawMap frame_raw_log = sender_log->GetFrameRawData();
// TODO(mikhal): Results are wrong. Need to resolve passing/calculation of
diff --git a/media/cast/test/receiver.cc b/media/cast/test/receiver.cc
index 2b05778..2ffb776 100644
--- a/media/cast/test/receiver.cc
+++ b/media/cast/test/receiver.cc
@@ -225,13 +225,13 @@ int main(int argc, char** argv) {
audio_thread.Start();
video_thread.Start();
- base::DefaultTickClock clock;
+ scoped_ptr<base::TickClock> clock(new base::DefaultTickClock());
// Enable receiver side threads, and disable logging.
// Running transport on main thread.
scoped_refptr<media::cast::CastEnvironment> cast_environment(new
media::cast::CastEnvironment(
- &clock,
+ clock.Pass(),
main_message_loop.message_loop_proxy(),
NULL,
audio_thread.message_loop_proxy(),
diff --git a/media/cast/test/sender.cc b/media/cast/test/sender.cc
index 6ad6d3e..d66165c 100644
--- a/media/cast/test/sender.cc
+++ b/media/cast/test/sender.cc
@@ -308,7 +308,7 @@ int main(int argc, char** argv) {
audio_thread.Start();
video_thread.Start();
- base::DefaultTickClock clock;
+ scoped_ptr<base::TickClock> clock(new base::DefaultTickClock());
base::MessageLoopForIO io_message_loop;
int remote_port, local_port;
@@ -336,7 +336,7 @@ int main(int argc, char** argv) {
scoped_ptr<media::cast::transport::CastTransportSender> transport_sender(
media::cast::transport::
- CastTransportSender::CreateCastTransportSender(&clock, config,
+ CastTransportSender::CreateCastTransportSender(clock.get(), config,
base::Bind(&UpdateCastTransportStatus),
io_message_loop.message_loop_proxy()));
@@ -344,7 +344,7 @@ int main(int argc, char** argv) {
// Running transport on the main thread.
scoped_refptr<media::cast::CastEnvironment> cast_environment(new
media::cast::CastEnvironment(
- &clock,
+ clock.Pass(),
io_message_loop.message_loop_proxy(),
audio_thread.message_loop_proxy(),
NULL,
diff --git a/media/cast/video_receiver/video_decoder_unittest.cc b/media/cast/video_receiver/video_decoder_unittest.cc
index 32fe16b..76e7e27 100644
--- a/media/cast/video_receiver/video_decoder_unittest.cc
+++ b/media/cast/video_receiver/video_decoder_unittest.cc
@@ -40,16 +40,18 @@ class DecodeTestFrameCallback :
class VideoDecoderTest : public ::testing::Test {
protected:
VideoDecoderTest()
- : task_runner_(new test::FakeTaskRunner(&testing_clock_)),
- cast_environment_(new CastEnvironment(&testing_clock_, task_runner_,
- task_runner_, task_runner_, task_runner_, task_runner_,
- task_runner_, GetDefaultCastReceiverLoggingConfig())),
- test_callback_(new DecodeTestFrameCallback()) {
+ : testing_clock_(new base::SimpleTestTickClock()),
+ task_runner_(new test::FakeTaskRunner(testing_clock_)),
+ cast_environment_(new CastEnvironment(
+ scoped_ptr<base::TickClock>(testing_clock_), task_runner_,
+ task_runner_, task_runner_, task_runner_, task_runner_,
+ task_runner_, GetDefaultCastReceiverLoggingConfig())),
+ test_callback_(new DecodeTestFrameCallback()) {
// Configure to vp8.
config_.codec = transport::kVp8;
config_.use_external_decoder = false;
decoder_.reset(new VideoDecoder(config_, cast_environment_));
- testing_clock_.Advance(
+ testing_clock_->Advance(
base::TimeDelta::FromMilliseconds(kStartMillisecond));
}
@@ -57,7 +59,7 @@ class VideoDecoderTest : public ::testing::Test {
scoped_ptr<VideoDecoder> decoder_;
VideoReceiverConfig config_;
- base::SimpleTestTickClock testing_clock_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
scoped_refptr<test::FakeTaskRunner> task_runner_;
scoped_refptr<CastEnvironment> cast_environment_;
scoped_refptr<DecodeTestFrameCallback> test_callback_;
diff --git a/media/cast/video_receiver/video_receiver.cc b/media/cast/video_receiver/video_receiver.cc
index 141c986..0ee93fd 100644
--- a/media/cast/video_receiver/video_receiver.cc
+++ b/media/cast/video_receiver/video_receiver.cc
@@ -13,6 +13,7 @@
#include "crypto/symmetric_key.h"
#include "media/cast/cast_defines.h"
#include "media/cast/framer/framer.h"
+#include "media/cast/rtcp/rtcp_sender.h"
#include "media/cast/video_receiver/video_decoder.h"
namespace media {
@@ -443,6 +444,7 @@ void VideoReceiver::CastFeedback(const RtcpCastMessage& cast_message) {
cast_environment_->Logging()->GetVideoRtcpRawData();
while (!video_logs.empty()) {
+ // TODO(hclam): Avoid calling begin() within a loop.
VideoRtcpRawMap::iterator it = video_logs.begin();
uint32 rtp_timestamp = it->first;
std::pair<VideoRtcpRawMap::iterator, VideoRtcpRawMap::iterator>
@@ -452,6 +454,8 @@ void VideoReceiver::CastFeedback(const RtcpCastMessage& cast_message) {
VideoRtcpRawMap::const_iterator event_it = frame_range.first;
for (; event_it != frame_range.second; ++event_it) {
+ if (!RtcpSender::IsReceiverEvent(event_it->second.type))
+ continue;
RtcpReceiverEventLogMessage event_log_message;
event_log_message.type = event_it->second.type;
event_log_message.event_timestamp = event_it->second.timestamp;
diff --git a/media/cast/video_receiver/video_receiver_unittest.cc b/media/cast/video_receiver/video_receiver_unittest.cc
index ef4f9ec..765c85f 100644
--- a/media/cast/video_receiver/video_receiver_unittest.cc
+++ b/media/cast/video_receiver/video_receiver_unittest.cc
@@ -71,13 +71,15 @@ class VideoReceiverTest : public ::testing::Test {
// Configure to use vp8 software implementation.
config_.codec = transport::kVp8;
config_.use_external_decoder = false;
- task_runner_ = new test::FakeTaskRunner(&testing_clock_);
- cast_environment_ = new CastEnvironment(&testing_clock_, task_runner_,
+ testing_clock_ = new base::SimpleTestTickClock();
+ task_runner_ = new test::FakeTaskRunner(testing_clock_);
+ cast_environment_ = new CastEnvironment(
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_,
task_runner_, task_runner_, task_runner_, task_runner_,
task_runner_, GetDefaultCastReceiverLoggingConfig());
receiver_.reset(new
PeerVideoReceiver(cast_environment_, config_, &mock_transport_));
- testing_clock_.Advance(
+ testing_clock_->Advance(
base::TimeDelta::FromMilliseconds(kStartMillisecond));
video_receiver_callback_ = new TestVideoReceiverCallback();
}
@@ -101,7 +103,7 @@ class VideoReceiverTest : public ::testing::Test {
scoped_ptr<PeerVideoReceiver> receiver_;
std::vector<uint8> payload_;
RtpCastHeader rtp_header_;
- base::SimpleTestTickClock testing_clock_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
scoped_refptr<test::FakeTaskRunner> task_runner_;
scoped_refptr<CastEnvironment> cast_environment_;
diff --git a/media/cast/video_sender/external_video_encoder_unittest.cc b/media/cast/video_sender/external_video_encoder_unittest.cc
index ed4f6be..11ce290 100644
--- a/media/cast/video_sender/external_video_encoder_unittest.cc
+++ b/media/cast/video_sender/external_video_encoder_unittest.cc
@@ -89,8 +89,10 @@ class ExternalVideoEncoderTest : public ::testing::Test {
virtual ~ExternalVideoEncoderTest() {}
virtual void SetUp() {
- task_runner_ = new test::FakeTaskRunner(&testing_clock_);
- cast_environment_ = new CastEnvironment(&testing_clock_, task_runner_,
+ testing_clock_ = new base::SimpleTestTickClock();
+ task_runner_ = new test::FakeTaskRunner(testing_clock_);
+ cast_environment_ = new CastEnvironment(
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_,
task_runner_, task_runner_, task_runner_, task_runner_, task_runner_,
GetDefaultCastSenderLoggingConfig());
video_encoder_.reset(new ExternalVideoEncoder(
@@ -99,7 +101,7 @@ class ExternalVideoEncoderTest : public ::testing::Test {
new test::FakeGpuVideoAcceleratorFactories(task_runner_)));
}
- base::SimpleTestTickClock testing_clock_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
scoped_refptr<TestVideoEncoderCallback> test_video_encoder_callback_;
VideoSenderConfig video_config_;
scoped_refptr<test::FakeTaskRunner> task_runner_;
diff --git a/media/cast/video_sender/video_encoder_impl_unittest.cc b/media/cast/video_sender/video_encoder_impl_unittest.cc
index 993e901..1db0c89 100644
--- a/media/cast/video_sender/video_encoder_impl_unittest.cc
+++ b/media/cast/video_sender/video_encoder_impl_unittest.cc
@@ -85,9 +85,11 @@ class VideoEncoderImplTest : public ::testing::Test {
virtual ~VideoEncoderImplTest() {}
- virtual void SetUp() {
- task_runner_ = new test::FakeTaskRunner(&testing_clock_);
- cast_environment_ = new CastEnvironment(&testing_clock_, task_runner_,
+ virtual void SetUp() OVERRIDE {
+ testing_clock_ = new base::SimpleTestTickClock();
+ task_runner_ = new test::FakeTaskRunner(testing_clock_);
+ cast_environment_ = new CastEnvironment(
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_,
task_runner_, task_runner_, task_runner_, task_runner_,
task_runner_, GetDefaultCastSenderLoggingConfig());
}
@@ -97,7 +99,7 @@ class VideoEncoderImplTest : public ::testing::Test {
max_unacked_frames));
}
- base::SimpleTestTickClock testing_clock_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
scoped_refptr<TestVideoEncoderCallback> test_video_encoder_callback_;
VideoSenderConfig video_config_;
scoped_refptr<test::FakeTaskRunner> task_runner_;
diff --git a/media/cast/video_sender/video_sender.cc b/media/cast/video_sender/video_sender.cc
index 16f8f6b..a679fa3 100644
--- a/media/cast/video_sender/video_sender.cc
+++ b/media/cast/video_sender/video_sender.cc
@@ -185,12 +185,14 @@ void VideoSender::SendRtcpReport() {
cast_environment_->Logging()->GetVideoRtcpRawData();
while (!video_logs.empty()) {
+ // TODO(hclam): Avoid calling begin() within a loop.
VideoRtcpRawMap::iterator it = video_logs.begin();
uint32 rtp_timestamp = it->first;
transport::RtcpSenderFrameLogMessage frame_message;
frame_message.rtp_timestamp = rtp_timestamp;
frame_message.frame_status = transport::kRtcpSenderFrameStatusUnknown;
+ bool ignore_event = false;
switch (it->second.type) {
case kVideoFrameCaptured:
@@ -206,11 +208,11 @@ void VideoSender::SendRtcpReport() {
transport::kRtcpSenderFrameStatusSentToNetwork;
break;
default:
- NOTREACHED();
- break;
+ ignore_event = true;
}
video_logs.erase(rtp_timestamp);
- sender_log_message.push_back(frame_message);
+ if (!ignore_event)
+ sender_log_message.push_back(frame_message);
}
rtcp_->SendRtcpFromRtpSender(sender_log_message);
diff --git a/media/cast/video_sender/video_sender_unittest.cc b/media/cast/video_sender/video_sender_unittest.cc
index f591577..9f4a49b 100644
--- a/media/cast/video_sender/video_sender_unittest.cc
+++ b/media/cast/video_sender/video_sender_unittest.cc
@@ -82,15 +82,17 @@ class PeerVideoSender : public VideoSender {
class VideoSenderTest : public ::testing::Test {
protected:
VideoSenderTest() {
- testing_clock_.Advance(
+ testing_clock_ = new base::SimpleTestTickClock();
+ testing_clock_->Advance(
base::TimeDelta::FromMilliseconds(kStartMillisecond));
- task_runner_ = new test::FakeTaskRunner(&testing_clock_);
+ task_runner_ = new test::FakeTaskRunner(testing_clock_);
cast_environment_ = new CastEnvironment(
- &testing_clock_, task_runner_, task_runner_, task_runner_, task_runner_,
+ scoped_ptr<base::TickClock>(testing_clock_).Pass(),
+ task_runner_, task_runner_, task_runner_, task_runner_,
task_runner_, task_runner_, GetDefaultCastSenderLoggingConfig());
transport::CastTransportConfig transport_config;
transport_sender_.reset(new transport::CastTransportSenderImpl(
- &testing_clock_, transport_config,
+ testing_clock_, transport_config,
base::Bind(&UpdateCastTransportStatus), task_runner_));
transport_sender_->InsertFakeTransportForTesting(&transport_);
}
@@ -142,12 +144,12 @@ class VideoSenderTest : public ::testing::Test {
void RunTasks(int during_ms) {
for (int i = 0; i < during_ms; ++i) {
// Call process the timers every 1 ms.
- testing_clock_.Advance(base::TimeDelta::FromMilliseconds(1));
+ testing_clock_->Advance(base::TimeDelta::FromMilliseconds(1));
task_runner_->RunTasks();
}
}
- base::SimpleTestTickClock testing_clock_;
+ base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
TestPacketSender transport_;
scoped_ptr<transport::CastTransportSenderImpl> transport_sender_;
scoped_refptr<test::FakeTaskRunner> task_runner_;
@@ -232,4 +234,3 @@ TEST_F(VideoSenderTest, ResendTimer) {
} // namespace cast
} // namespace media
-