OLD | NEW |
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 #include <cstdlib> | 5 #include <cstdlib> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/synchronization/condition_variable.h" | 9 #include "base/synchronization/condition_variable.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 CHECK_EQ(STATUS_VIDEO_INITIALIZED, video_decoder_->InitializationResult()); | 54 CHECK_EQ(STATUS_VIDEO_INITIALIZED, video_decoder_->InitializationResult()); |
55 | 55 |
56 next_frame_timestamp_ = base::TimeDelta(); | 56 next_frame_timestamp_ = base::TimeDelta(); |
57 last_frame_id_ = 0; | 57 last_frame_id_ = 0; |
58 seen_a_decoded_frame_ = false; | 58 seen_a_decoded_frame_ = false; |
59 | 59 |
60 total_video_frames_feed_in_ = 0; | 60 total_video_frames_feed_in_ = 0; |
61 total_video_frames_decoded_ = 0; | 61 total_video_frames_decoded_ = 0; |
62 } | 62 } |
63 | 63 |
64 // Called from the unit test thread to create another EncodedVideoFrame and | 64 // Called from the unit test thread to create another EncodedFrame and push it |
65 // push it into the decoding pipeline. | 65 // into the decoding pipeline. |
66 void FeedMoreVideo(int num_dropped_frames) { | 66 void FeedMoreVideo(int num_dropped_frames) { |
67 // Prepare a simulated EncodedVideoFrame to feed into the VideoDecoder. | 67 // Prepare a simulated EncodedFrame to feed into the VideoDecoder. |
68 | 68 |
69 const gfx::Size frame_size(kWidth, kHeight); | 69 const gfx::Size frame_size(kWidth, kHeight); |
70 const scoped_refptr<VideoFrame> video_frame = | 70 const scoped_refptr<VideoFrame> video_frame = |
71 VideoFrame::CreateFrame(VideoFrame::YV12, | 71 VideoFrame::CreateFrame(VideoFrame::YV12, |
72 frame_size, | 72 frame_size, |
73 gfx::Rect(frame_size), | 73 gfx::Rect(frame_size), |
74 frame_size, | 74 frame_size, |
75 next_frame_timestamp_); | 75 next_frame_timestamp_); |
76 next_frame_timestamp_ += base::TimeDelta::FromSeconds(1) / kFrameRate; | 76 next_frame_timestamp_ += base::TimeDelta::FromSeconds(1) / kFrameRate; |
77 PopulateVideoFrame(video_frame, 0); | 77 PopulateVideoFrame(video_frame, 0); |
78 | 78 |
79 // Encode |frame| into |encoded_frame->data|. | 79 // Encode |frame| into |encoded_frame->data|. |
80 scoped_ptr<transport::EncodedVideoFrame> encoded_frame( | 80 scoped_ptr<transport::EncodedFrame> encoded_frame( |
81 new transport::EncodedVideoFrame()); | 81 new transport::EncodedFrame()); |
82 CHECK_EQ(transport::kVp8, GetParam()); // Only support VP8 test currently. | 82 CHECK_EQ(transport::kVp8, GetParam()); // Only support VP8 test currently. |
83 vp8_encoder_.Encode(video_frame, encoded_frame.get()); | 83 vp8_encoder_.Encode(video_frame, encoded_frame.get()); |
84 encoded_frame->codec = GetParam(); | |
85 encoded_frame->frame_id = last_frame_id_ + 1 + num_dropped_frames; | 84 encoded_frame->frame_id = last_frame_id_ + 1 + num_dropped_frames; |
86 last_frame_id_ = encoded_frame->frame_id; | 85 last_frame_id_ = encoded_frame->frame_id; |
87 | 86 |
88 { | 87 { |
89 base::AutoLock auto_lock(lock_); | 88 base::AutoLock auto_lock(lock_); |
90 ++total_video_frames_feed_in_; | 89 ++total_video_frames_feed_in_; |
91 } | 90 } |
92 | 91 |
93 cast_environment_->PostTask( | 92 cast_environment_->PostTask( |
94 CastEnvironment::MAIN, | 93 CastEnvironment::MAIN, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 177 } |
179 WaitForAllVideoToBeDecoded(); | 178 WaitForAllVideoToBeDecoded(); |
180 } | 179 } |
181 | 180 |
182 INSTANTIATE_TEST_CASE_P(VideoDecoderTestScenarios, | 181 INSTANTIATE_TEST_CASE_P(VideoDecoderTestScenarios, |
183 VideoDecoderTest, | 182 VideoDecoderTest, |
184 ::testing::Values(transport::kVp8)); | 183 ::testing::Values(transport::kVp8)); |
185 | 184 |
186 } // namespace cast | 185 } // namespace cast |
187 } // namespace media | 186 } // namespace media |
OLD | NEW |