| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/scoped_file.h" | 10 #include "base/files/scoped_file.h" |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 PtsToTimeDelta(avframe->pkt_pts - video_first_pts_, time_base); | 550 PtsToTimeDelta(avframe->pkt_pts - video_first_pts_, time_base); |
| 551 if (timestamp < last_video_frame_timestamp_) { | 551 if (timestamp < last_video_frame_timestamp_) { |
| 552 // Stream has rewound. Rebase |video_first_pts_|. | 552 // Stream has rewound. Rebase |video_first_pts_|. |
| 553 const AVRational& frame_rate = av_video_stream()->r_frame_rate; | 553 const AVRational& frame_rate = av_video_stream()->r_frame_rate; |
| 554 timestamp = last_video_frame_timestamp_ + | 554 timestamp = last_video_frame_timestamp_ + |
| 555 (base::TimeDelta::FromSeconds(1) * frame_rate.den / frame_rate.num); | 555 (base::TimeDelta::FromSeconds(1) * frame_rate.den / frame_rate.num); |
| 556 const int64_t adjustment_pts = TimeDeltaToPts(timestamp, time_base); | 556 const int64_t adjustment_pts = TimeDeltaToPts(timestamp, time_base); |
| 557 video_first_pts_ = avframe->pkt_pts - adjustment_pts; | 557 video_first_pts_ = avframe->pkt_pts - adjustment_pts; |
| 558 } | 558 } |
| 559 | 559 |
| 560 video_frame_queue_.push(VideoFrame::WrapExternalYuvData( | 560 scoped_refptr<media::VideoFrame> video_frame = |
| 561 media::PIXEL_FORMAT_YV12, size, gfx::Rect(size), size, | 561 VideoFrame::WrapExternalYuvData( |
| 562 avframe->linesize[0], avframe->linesize[1], avframe->linesize[2], | 562 media::PIXEL_FORMAT_YV12, size, gfx::Rect(size), size, |
| 563 avframe->data[0], avframe->data[1], avframe->data[2], timestamp)); | 563 avframe->linesize[0], avframe->linesize[1], avframe->linesize[2], |
| 564 avframe->data[0], avframe->data[1], avframe->data[2], timestamp); |
| 565 if (!video_frame) |
| 566 return; |
| 567 video_frame_queue_.push(video_frame); |
| 564 video_frame_queue_.back()->AddDestructionObserver( | 568 video_frame_queue_.back()->AddDestructionObserver( |
| 565 base::Bind(&AVFreeFrame, avframe)); | 569 base::Bind(&AVFreeFrame, avframe)); |
| 566 last_video_frame_timestamp_ = timestamp; | 570 last_video_frame_timestamp_ = timestamp; |
| 567 } | 571 } |
| 568 | 572 |
| 569 void FakeMediaSource::Decode(bool decode_audio) { | 573 void FakeMediaSource::Decode(bool decode_audio) { |
| 570 // Read the stream until one video frame can be decoded. | 574 // Read the stream until one video frame can be decoded. |
| 571 while (true) { | 575 while (true) { |
| 572 if (decode_audio && !audio_bus_queue_.empty()) | 576 if (decode_audio && !audio_bus_queue_.empty()) |
| 573 return; | 577 return; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 AVCodecContext* FakeMediaSource::av_audio_context() { | 624 AVCodecContext* FakeMediaSource::av_audio_context() { |
| 621 return av_audio_stream()->codec; | 625 return av_audio_stream()->codec; |
| 622 } | 626 } |
| 623 | 627 |
| 624 AVCodecContext* FakeMediaSource::av_video_context() { | 628 AVCodecContext* FakeMediaSource::av_video_context() { |
| 625 return av_video_stream()->codec; | 629 return av_video_stream()->codec; |
| 626 } | 630 } |
| 627 | 631 |
| 628 } // namespace cast | 632 } // namespace cast |
| 629 } // namespace media | 633 } // namespace media |
| OLD | NEW |