Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: media/cast/test/encode_decode_test.cc

Issue 145443005: Fixes for memory and threading issues in cast (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/cast/rtcp/rtcp_unittest.cc ('k') | media/cast/test/end2end_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Joint encoder and decoder testing. 5 // Joint encoder and decoder testing.
6 // These tests operate directly on the VP8 encoder and decoder, not the 6 // These tests operate directly on the VP8 encoder and decoder, not the
7 // transport layer, and are targeted at validating the bit stream. 7 // transport layer, and are targeted at validating the bit stream.
8 8
9 #include <gtest/gtest.h> 9 #include <gtest/gtest.h>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 friend class base::RefCountedThreadSafe<EncodeDecodeTestFrameCallback>; 66 friend class base::RefCountedThreadSafe<EncodeDecodeTestFrameCallback>;
67 67
68 int num_called_; 68 int num_called_;
69 scoped_refptr<media::VideoFrame> original_frame_; 69 scoped_refptr<media::VideoFrame> original_frame_;
70 }; 70 };
71 } // namespace 71 } // namespace
72 72
73 class EncodeDecodeTest : public ::testing::Test { 73 class EncodeDecodeTest : public ::testing::Test {
74 protected: 74 protected:
75 EncodeDecodeTest() 75 EncodeDecodeTest()
76 : task_runner_(new test::FakeTaskRunner(&testing_clock_)), 76 : testing_clock_(new base::SimpleTestTickClock()),
77 task_runner_(new test::FakeTaskRunner(testing_clock_)),
77 // CastEnvironment will only be used by the vp8 decoder; Enable only the 78 // CastEnvironment will only be used by the vp8 decoder; Enable only the
78 // video decoder and main threads. 79 // video decoder and main threads.
79 cast_environment_(new CastEnvironment(&testing_clock_, task_runner_, 80 cast_environment_(new CastEnvironment(
81 scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_,
80 NULL, NULL, NULL, task_runner_, NULL, 82 NULL, NULL, NULL, task_runner_, NULL,
81 GetDefaultCastReceiverLoggingConfig())), 83 GetDefaultCastReceiverLoggingConfig())),
82 test_callback_(new EncodeDecodeTestFrameCallback()) { 84 test_callback_(new EncodeDecodeTestFrameCallback()) {
83 testing_clock_.Advance( 85 testing_clock_->Advance(
84 base::TimeDelta::FromMilliseconds(kStartMillisecond)); 86 base::TimeDelta::FromMilliseconds(kStartMillisecond));
85 encoder_config_.max_number_of_video_buffers_used = 1; 87 encoder_config_.max_number_of_video_buffers_used = 1;
86 encoder_config_.number_of_cores = 1; 88 encoder_config_.number_of_cores = 1;
87 encoder_config_.width = kWidth; 89 encoder_config_.width = kWidth;
88 encoder_config_.height = kHeight; 90 encoder_config_.height = kHeight;
89 encoder_config_.start_bitrate = kStartbitrate; 91 encoder_config_.start_bitrate = kStartbitrate;
90 encoder_config_.min_qp = kMaxQp; 92 encoder_config_.min_qp = kMaxQp;
91 encoder_config_.min_qp = kMinQp; 93 encoder_config_.min_qp = kMinQp;
92 encoder_config_.max_frame_rate = kMaxFrameRate; 94 encoder_config_.max_frame_rate = kMaxFrameRate;
93 int max_unacked_frames = 1; 95 int max_unacked_frames = 1;
(...skipping 11 matching lines...) Expand all
105 video_frame_ = media::VideoFrame::CreateFrame(VideoFrame::I420, 107 video_frame_ = media::VideoFrame::CreateFrame(VideoFrame::I420,
106 size, gfx::Rect(size), size, base::TimeDelta()); 108 size, gfx::Rect(size), size, base::TimeDelta());
107 PopulateVideoFrame(video_frame_, start_value); 109 PopulateVideoFrame(video_frame_, start_value);
108 test_callback_->SetFrameStartValue(start_value); 110 test_callback_->SetFrameStartValue(start_value);
109 } 111 }
110 112
111 VideoSenderConfig encoder_config_; 113 VideoSenderConfig encoder_config_;
112 scoped_ptr<Vp8Encoder> encoder_; 114 scoped_ptr<Vp8Encoder> encoder_;
113 scoped_ptr<Vp8Decoder> decoder_; 115 scoped_ptr<Vp8Decoder> decoder_;
114 scoped_refptr<media::VideoFrame> video_frame_; 116 scoped_refptr<media::VideoFrame> video_frame_;
115 base::SimpleTestTickClock testing_clock_; 117 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
116 scoped_refptr<test::FakeTaskRunner> task_runner_; 118 scoped_refptr<test::FakeTaskRunner> task_runner_;
117 scoped_refptr<CastEnvironment> cast_environment_; 119 scoped_refptr<CastEnvironment> cast_environment_;
118 scoped_refptr<EncodeDecodeTestFrameCallback> test_callback_; 120 scoped_refptr<EncodeDecodeTestFrameCallback> test_callback_;
119 }; 121 };
120 122
121 TEST_F(EncodeDecodeTest, BasicEncodeDecode) { 123 TEST_F(EncodeDecodeTest, BasicEncodeDecode) {
122 transport::EncodedVideoFrame encoded_frame; 124 transport::EncodedVideoFrame encoded_frame;
123 // Encode frame. 125 // Encode frame.
124 encoder_->Encode(video_frame_, &encoded_frame); 126 encoder_->Encode(video_frame_, &encoded_frame);
125 EXPECT_GT(encoded_frame.data.size(), GG_UINT64_C(0)); 127 EXPECT_GT(encoded_frame.data.size(), GG_UINT64_C(0));
126 // Decode frame. 128 // Decode frame.
127 decoder_->Decode(&encoded_frame, base::TimeTicks(), base::Bind( 129 decoder_->Decode(&encoded_frame, base::TimeTicks(), base::Bind(
128 &EncodeDecodeTestFrameCallback::DecodeComplete, test_callback_)); 130 &EncodeDecodeTestFrameCallback::DecodeComplete, test_callback_));
129 task_runner_->RunTasks(); 131 task_runner_->RunTasks();
130 } 132 }
131 133
132 } // namespace cast 134 } // namespace cast
133 } // namespace media 135 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/rtcp/rtcp_unittest.cc ('k') | media/cast/test/end2end_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698