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

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

Issue 1476523005: Verify returned frames from media::VideoFrame::Wrap*() methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: LOG in video_Frame and CHECK/return outside. Created 5 years 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
OLDNEW
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/bind.h" 7 #include "base/bind.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/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 PtsToTimeDelta(avframe->pkt_pts - video_first_pts_, time_base); 539 PtsToTimeDelta(avframe->pkt_pts - video_first_pts_, time_base);
540 if (timestamp < last_video_frame_timestamp_) { 540 if (timestamp < last_video_frame_timestamp_) {
541 // Stream has rewound. Rebase |video_first_pts_|. 541 // Stream has rewound. Rebase |video_first_pts_|.
542 const AVRational& frame_rate = av_video_stream()->r_frame_rate; 542 const AVRational& frame_rate = av_video_stream()->r_frame_rate;
543 timestamp = last_video_frame_timestamp_ + 543 timestamp = last_video_frame_timestamp_ +
544 (base::TimeDelta::FromSeconds(1) * frame_rate.den / frame_rate.num); 544 (base::TimeDelta::FromSeconds(1) * frame_rate.den / frame_rate.num);
545 const int64 adjustment_pts = TimeDeltaToPts(timestamp, time_base); 545 const int64 adjustment_pts = TimeDeltaToPts(timestamp, time_base);
546 video_first_pts_ = avframe->pkt_pts - adjustment_pts; 546 video_first_pts_ = avframe->pkt_pts - adjustment_pts;
547 } 547 }
548 548
549 video_frame_queue_.push(VideoFrame::WrapExternalYuvData( 549 scoped_refptr<media::VideoFrame> video_frame =
550 media::PIXEL_FORMAT_YV12, size, gfx::Rect(size), size, 550 VideoFrame::WrapExternalYuvData(
551 avframe->linesize[0], avframe->linesize[1], avframe->linesize[2], 551 media::PIXEL_FORMAT_YV12, size, gfx::Rect(size), size,
552 avframe->data[0], avframe->data[1], avframe->data[2], timestamp)); 552 avframe->linesize[0], avframe->linesize[1], avframe->linesize[2],
553 avframe->data[0], avframe->data[1], avframe->data[2], timestamp);
554 if (!video_frame)
555 return;
556 video_frame_queue_.push(video_frame);
553 video_frame_queue_.back()->AddDestructionObserver( 557 video_frame_queue_.back()->AddDestructionObserver(
554 base::Bind(&AVFreeFrame, avframe)); 558 base::Bind(&AVFreeFrame, avframe));
555 last_video_frame_timestamp_ = timestamp; 559 last_video_frame_timestamp_ = timestamp;
556 } 560 }
557 561
558 void FakeMediaSource::Decode(bool decode_audio) { 562 void FakeMediaSource::Decode(bool decode_audio) {
559 // Read the stream until one video frame can be decoded. 563 // Read the stream until one video frame can be decoded.
560 while (true) { 564 while (true) {
561 if (decode_audio && !audio_bus_queue_.empty()) 565 if (decode_audio && !audio_bus_queue_.empty())
562 return; 566 return;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 AVCodecContext* FakeMediaSource::av_audio_context() { 613 AVCodecContext* FakeMediaSource::av_audio_context() {
610 return av_audio_stream()->codec; 614 return av_audio_stream()->codec;
611 } 615 }
612 616
613 AVCodecContext* FakeMediaSource::av_video_context() { 617 AVCodecContext* FakeMediaSource::av_video_context() {
614 return av_video_stream()->codec; 618 return av_video_stream()->codec;
615 } 619 }
616 620
617 } // namespace cast 621 } // namespace cast
618 } // namespace media 622 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698