OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/cast/test/fake_media_source.h" | 5 #include "media/cast/test/fake_media_source.h" |
6 | 6 |
7 #include "base/files/memory_mapped_file.h" | 7 #include "base/files/memory_mapped_file.h" |
8 #include "base/files/scoped_file.h" | 8 #include "base/files/scoped_file.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 FROM_HERE, | 226 FROM_HERE, |
227 base::Bind( | 227 base::Bind( |
228 &FakeMediaSource::SendNextFrame, | 228 &FakeMediaSource::SendNextFrame, |
229 base::Unretained(this))); | 229 base::Unretained(this))); |
230 } | 230 } |
231 | 231 |
232 void FakeMediaSource::SendNextFakeFrame() { | 232 void FakeMediaSource::SendNextFakeFrame() { |
233 gfx::Size size(video_config_.width, video_config_.height); | 233 gfx::Size size(video_config_.width, video_config_.height); |
234 scoped_refptr<VideoFrame> video_frame = | 234 scoped_refptr<VideoFrame> video_frame = |
235 VideoFrame::CreateBlackFrame(size); | 235 VideoFrame::CreateBlackFrame(size); |
236 PopulateVideoFrame(video_frame, synthetic_count_); | 236 PopulateVideoFrame(video_frame.get(), synthetic_count_); |
237 ++synthetic_count_; | 237 ++synthetic_count_; |
238 | 238 |
239 base::TimeTicks now = clock_->NowTicks(); | 239 base::TimeTicks now = clock_->NowTicks(); |
240 if (start_time_.is_null()) | 240 if (start_time_.is_null()) |
241 start_time_ = now; | 241 start_time_ = now; |
242 | 242 |
243 base::TimeDelta video_time = VideoFrameTime(++video_frame_count_); | 243 base::TimeDelta video_time = VideoFrameTime(++video_frame_count_); |
244 video_frame->set_timestamp(video_time); | 244 video_frame->set_timestamp(video_time); |
245 video_frame_input_->InsertRawVideoFrame(video_frame, | 245 video_frame_input_->InsertRawVideoFrame(video_frame, |
246 start_time_ + video_time); | 246 start_time_ + video_time); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 return false; | 295 return false; |
296 | 296 |
297 gfx::Size size(video_config_.width, video_config_.height); | 297 gfx::Size size(video_config_.width, video_config_.height); |
298 scoped_refptr<VideoFrame> video_frame = | 298 scoped_refptr<VideoFrame> video_frame = |
299 VideoFrame::CreateBlackFrame(size); | 299 VideoFrame::CreateBlackFrame(size); |
300 video_frame_queue_.pop(); | 300 video_frame_queue_.pop(); |
301 media::CopyPlane(VideoFrame::kYPlane, | 301 media::CopyPlane(VideoFrame::kYPlane, |
302 decoded_frame->data(VideoFrame::kYPlane), | 302 decoded_frame->data(VideoFrame::kYPlane), |
303 decoded_frame->stride(VideoFrame::kYPlane), | 303 decoded_frame->stride(VideoFrame::kYPlane), |
304 decoded_frame->rows(VideoFrame::kYPlane), | 304 decoded_frame->rows(VideoFrame::kYPlane), |
305 video_frame); | 305 video_frame.get()); |
306 media::CopyPlane(VideoFrame::kUPlane, | 306 media::CopyPlane(VideoFrame::kUPlane, |
307 decoded_frame->data(VideoFrame::kUPlane), | 307 decoded_frame->data(VideoFrame::kUPlane), |
308 decoded_frame->stride(VideoFrame::kUPlane), | 308 decoded_frame->stride(VideoFrame::kUPlane), |
309 decoded_frame->rows(VideoFrame::kUPlane), | 309 decoded_frame->rows(VideoFrame::kUPlane), |
310 video_frame); | 310 video_frame.get()); |
311 media::CopyPlane(VideoFrame::kVPlane, | 311 media::CopyPlane(VideoFrame::kVPlane, |
312 decoded_frame->data(VideoFrame::kVPlane), | 312 decoded_frame->data(VideoFrame::kVPlane), |
313 decoded_frame->stride(VideoFrame::kVPlane), | 313 decoded_frame->stride(VideoFrame::kVPlane), |
314 decoded_frame->rows(VideoFrame::kVPlane), | 314 decoded_frame->rows(VideoFrame::kVPlane), |
315 video_frame); | 315 video_frame.get()); |
316 | 316 |
317 base::TimeDelta video_time; | 317 base::TimeDelta video_time; |
318 // Use the timestamp from the file if we're transcoding. | 318 // Use the timestamp from the file if we're transcoding. |
319 video_time = ScaleTimestamp(decoded_frame->timestamp()); | 319 video_time = ScaleTimestamp(decoded_frame->timestamp()); |
320 video_frame_input_->InsertRawVideoFrame( | 320 video_frame_input_->InsertRawVideoFrame( |
321 video_frame, start_time_ + video_time); | 321 video_frame, start_time_ + video_time); |
322 | 322 |
323 // Make sure queue is not empty. | 323 // Make sure queue is not empty. |
324 Decode(false); | 324 Decode(false); |
325 return true; | 325 return true; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 AVCodecContext* FakeMediaSource::av_audio_context() { | 586 AVCodecContext* FakeMediaSource::av_audio_context() { |
587 return av_audio_stream()->codec; | 587 return av_audio_stream()->codec; |
588 } | 588 } |
589 | 589 |
590 AVCodecContext* FakeMediaSource::av_video_context() { | 590 AVCodecContext* FakeMediaSource::av_video_context() { |
591 return av_video_stream()->codec; | 591 return av_video_stream()->codec; |
592 } | 592 } |
593 | 593 |
594 } // namespace cast | 594 } // namespace cast |
595 } // namespace media | 595 } // namespace media |
OLD | NEW |