summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authormikhal@chromium.org <mikhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-09 19:16:13 +0000
committermikhal@chromium.org <mikhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-09 19:16:13 +0000
commit3eeef33c0987837b11d6896d71c73a726fa5e804 (patch)
treef6c36415f980a4957ad2f53902a2c27c21ba19b1 /media
parentbc18603451160339bf860c6951fadd634413a141 (diff)
downloadchromium_src-3eeef33c0987837b11d6896d71c73a726fa5e804.zip
chromium_src-3eeef33c0987837b11d6896d71c73a726fa5e804.tar.gz
chromium_src-3eeef33c0987837b11d6896d71c73a726fa5e804.tar.bz2
Cast: Updating tests
1. Cast Sender app: Switching from Sleep to a delayed task on a designated thread. 2. Properly setting audio closure to make sure that the frame is alive for the required duration. Can only be committed after: https://chromiumcodereview.appspot.com/106183005/ BUG=323703 Review URL: https://codereview.chromium.org/108403004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239528 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/cast/test/end2end_unittest.cc31
-rw-r--r--media/cast/test/sender.cc36
-rw-r--r--media/cast/video_sender/video_sender.cc1
3 files changed, 46 insertions, 22 deletions
diff --git a/media/cast/test/end2end_unittest.cc b/media/cast/test/end2end_unittest.cc
index bba27b8..71a1895 100644
--- a/media/cast/test/end2end_unittest.cc
+++ b/media/cast/test/end2end_unittest.cc
@@ -52,7 +52,14 @@ static const int kFrameTimerMs = 33;
// The packets pass through the pacer which can delay the beginning of the
// frame by 10 ms if there is packets belonging to the previous frame being
// retransmitted.
-static const int kTimerErrorMs = 11;
+static const int kTimerErrorMs = 15;
+
+namespace {
+// Dummy callback function that does nothing except to accept ownership of
+// |audio_bus| for destruction.
+void OwnThatAudioBus(scoped_ptr<AudioBus> audio_bus) {
+}
+} // namespace
// Class that sends the packet direct from sender into the receiver with the
// ability to drop packets between the two.
@@ -175,8 +182,8 @@ class TestReceiverAudioCallback :
<< (playout_time - upper_bound).InMicroseconds() << " usec";
EXPECT_LT(expected_audio_frame.record_time, playout_time)
<< "playout_time - expected == "
- << (playout_time - expected_audio_frame.record_time).InMicroseconds()
- << " usec";
+ << (playout_time - expected_audio_frame.record_time).InMilliseconds()
+ << " mS";
EXPECT_EQ(audio_frame->samples.size(),
expected_audio_frame.audio_frame.samples.size());
@@ -288,7 +295,7 @@ class TestReceiverVideoCallback :
EXPECT_GE(upper_bound, time_since_capture)
<< "time_since_capture - upper_bound == "
- << (time_since_capture - upper_bound).InMicroseconds() << " usec";
+ << (time_since_capture - upper_bound).InMilliseconds() << " mS";
EXPECT_LE(expected_video_frame.capture_time, render_time);
EXPECT_EQ(expected_video_frame.width, video_frame->coded_size().width());
EXPECT_EQ(expected_video_frame.height, video_frame->coded_size().height());
@@ -474,7 +481,7 @@ TEST_F(End2EndTest, LoopNoLossPcm16) {
int i = 0;
std::cout << "Progress ";
- for (; i < 100; ++i) {
+ for (; i < 300; ++i) {
int num_10ms_blocks = audio_diff / 10;
audio_diff -= num_10ms_blocks * 10;
base::TimeTicks send_time = testing_clock_.NowTicks();
@@ -496,7 +503,7 @@ TEST_F(End2EndTest, LoopNoLossPcm16) {
AudioBus* const audio_bus_ptr = audio_bus.get();
frame_input_->InsertAudio(audio_bus_ptr, send_time,
- base::Bind(base::DoNothing));
+ base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus)));
SendVideoFrame(video_start, send_time);
@@ -546,7 +553,7 @@ TEST_F(End2EndTest, LoopNoLossPcm16ExternalDecoder) {
AudioBus* const audio_bus_ptr = audio_bus.get();
frame_input_->InsertAudio(audio_bus_ptr, send_time,
- base::Bind(base::DoNothing));
+ base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus)));
RunTasks(10);
frame_receiver_->GetCodedAudioFrame(
@@ -578,7 +585,7 @@ TEST_F(End2EndTest, LoopNoLossOpus) {
AudioBus* const audio_bus_ptr = audio_bus.get();
frame_input_->InsertAudio(audio_bus_ptr, send_time,
- base::Bind(base::DoNothing));
+ base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus)));
RunTasks(30);
@@ -621,7 +628,7 @@ TEST_F(End2EndTest, DISABLED_StartSenderBeforeReceiver) {
AudioBus* const audio_bus_ptr = audio_bus.get();
frame_input_->InsertAudio(audio_bus_ptr, send_time,
- base::Bind(base::DoNothing));
+ base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus)));
SendVideoFrame(video_start, send_time);
RunTasks(kFrameTimerMs);
@@ -649,7 +656,7 @@ TEST_F(End2EndTest, DISABLED_StartSenderBeforeReceiver) {
AudioBus* const audio_bus_ptr = audio_bus.get();
frame_input_->InsertAudio(audio_bus_ptr, send_time,
- base::Bind(base::DoNothing));
+ base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus)));
test_receiver_video_callback_->AddExpectedResult(video_start,
video_sender_config_.width, video_sender_config_.height, send_time);
@@ -858,7 +865,7 @@ TEST_F(End2EndTest, CryptoAudio) {
}
AudioBus* const audio_bus_ptr = audio_bus.get();
frame_input_->InsertAudio(audio_bus_ptr, send_time,
- base::Bind(base::DoNothing));
+ base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus)));
RunTasks(num_10ms_blocks * 10);
@@ -977,7 +984,7 @@ TEST_F(End2EndTest, AudioLogging) {
AudioBus* const audio_bus_ptr = audio_bus.get();
frame_input_->InsertAudio(audio_bus_ptr, send_time,
- base::Bind(base::DoNothing));
+ base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus)));
RunTasks(kFrameTimerMs);
audio_diff += kFrameTimerMs;
diff --git a/media/cast/test/sender.cc b/media/cast/test/sender.cc
index e4c26de..b6a933f 100644
--- a/media/cast/test/sender.cc
+++ b/media/cast/test/sender.cc
@@ -193,14 +193,16 @@ VideoSenderConfig GetVideoSenderConfig() {
class SendProcess {
public:
- SendProcess(scoped_refptr<CastEnvironment> cast_environment,
- const VideoSenderConfig& video_config,
- FrameInput* frame_input)
- : video_config_(video_config),
+ SendProcess(scoped_refptr<base::TaskRunner> thread_proxy,
+ base::TickClock* clock,
+ const VideoSenderConfig& video_config,
+ FrameInput* frame_input)
+ : test_app_thread_proxy_(thread_proxy),
+ video_config_(video_config),
audio_diff_(kFrameTimerMs),
frame_input_(frame_input),
synthetic_count_(0),
- clock_(cast_environment->Clock()),
+ clock_(clock),
start_time_(),
send_time_(),
weak_factory_(this) {
@@ -224,7 +226,8 @@ class SendProcess {
}
void ReleaseVideoFrame(const scoped_refptr<media::VideoFrame>&) {
- SendFrame();
+ test_app_thread_proxy_->PostTask(FROM_HERE,
+ base::Bind(&SendProcess::SendFrame, base::Unretained(this)));
}
void SendFrame() {
@@ -262,11 +265,20 @@ class SendProcess {
base::TimeDelta::FromMilliseconds(kFrameTimerMs);
base::TimeDelta elapsed_time = now - send_time_;
if (elapsed_time < video_frame_time) {
- base::PlatformThread::Sleep(video_frame_time - elapsed_time);
- VLOG(1) << "Sleep" <<
+ VLOG(1) << "Wait" <<
(video_frame_time - elapsed_time).InMilliseconds();
+ test_app_thread_proxy_->PostDelayedTask(FROM_HERE,
+ base::Bind(&SendProcess::SendVideoFrameOnTime, base::Unretained(this),
+ video_frame),
+ video_frame_time - elapsed_time);
+ } else {
+ test_app_thread_proxy_->PostTask(FROM_HERE,
+ base::Bind(&SendProcess::SendVideoFrameOnTime, base::Unretained(this),
+ video_frame));
}
+ }
+ void SendVideoFrameOnTime(scoped_refptr<media::VideoFrame> video_frame) {
send_time_ = clock_->NowTicks();
frame_input_->InsertRawVideoFrame(video_frame, send_time_,
base::Bind(&SendProcess::ReleaseVideoFrame, weak_factory_.GetWeakPtr(),
@@ -274,6 +286,7 @@ class SendProcess {
}
private:
+ scoped_refptr<base::TaskRunner> test_app_thread_proxy_;
const VideoSenderConfig video_config_;
int audio_diff_;
const scoped_refptr<FrameInput> frame_input_;
@@ -293,9 +306,11 @@ class SendProcess {
int main(int argc, char** argv) {
base::AtExitManager at_exit;
VLOG(1) << "Cast Sender";
+ base::Thread test_thread("Cast sender test app thread");
base::Thread main_thread("Cast main send thread");
base::Thread audio_thread("Cast audio encoder thread");
base::Thread video_thread("Cast video encoder thread");
+ test_thread.Start();
main_thread.Start();
audio_thread.Start();
video_thread.Start();
@@ -343,7 +358,10 @@ int main(int argc, char** argv) {
media::cast::FrameInput* frame_input = cast_sender->frame_input();
scoped_ptr<media::cast::SendProcess> send_process(new
- media::cast::SendProcess(cast_environment, video_config, frame_input));
+ media::cast::SendProcess(test_thread.message_loop_proxy(),
+ cast_environment->Clock(),
+ video_config,
+ frame_input));
send_process->SendFrame();
io_message_loop.Run();
diff --git a/media/cast/video_sender/video_sender.cc b/media/cast/video_sender/video_sender.cc
index b53247e..e18a15d 100644
--- a/media/cast/video_sender/video_sender.cc
+++ b/media/cast/video_sender/video_sender.cc
@@ -367,7 +367,6 @@ void VideoSender::OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) {
void VideoSender::ReceivedAck(uint32 acked_frame_id) {
DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
- VLOG(1) << "ReceivedAck:" << acked_frame_id;
last_acked_frame_id_ = static_cast<int>(acked_frame_id);
cast_environment_->Logging()->InsertGenericEvent(kAckReceived,
acked_frame_id);