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

Side by Side Diff: media/filters/video_frame_generator.cc

Issue 8887004: add components for integration test which will detect breakage of media pipeline with video captu... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: code review and final Created 8 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/filters/video_frame_generator.h ('k') | media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/filters/video_frame_generator.h"
6
7 #include "base/bind.h"
8 #include "base/message_loop.h"
9 #include "media/base/demuxer_stream.h"
10
11 namespace media {
12
13 VideoFrameGenerator::VideoFrameGenerator(
14 base::MessageLoopProxy* message_loop_proxy,
15 const gfx::Size& size,
16 const base::TimeDelta& frame_duration)
17 : message_loop_proxy_(message_loop_proxy),
18 natural_size_(size),
19 stopped_(true),
20 frame_duration_(frame_duration) {
21 }
22
23 VideoFrameGenerator::~VideoFrameGenerator() {}
24
25 void VideoFrameGenerator::Initialize(
26 DemuxerStream* demuxer_stream,
27 const PipelineStatusCB& filter_callback,
28 const StatisticsCallback& stat_callback) {
29 message_loop_proxy_->PostTask(
30 FROM_HERE,
31 base::Bind(&VideoFrameGenerator::InitializeOnDecoderThread,
32 this, make_scoped_refptr(demuxer_stream),
33 filter_callback, stat_callback));
34 }
35
36 void VideoFrameGenerator::Read(const ReadCB& callback) {
37 message_loop_proxy_->PostTask(
38 FROM_HERE,
39 base::Bind(&VideoFrameGenerator::ReadOnDecoderThread,
40 this, callback));
41 }
42
43 const gfx::Size& VideoFrameGenerator::natural_size() {
44 return natural_size_;
45 }
46
47 void VideoFrameGenerator::Stop(const base::Closure& callback) {
48 message_loop_proxy_->PostTask(
49 FROM_HERE,
50 base::Bind(&VideoFrameGenerator::StopOnDecoderThread,
51 this, callback));
52 }
53
54 void VideoFrameGenerator::InitializeOnDecoderThread(
55 DemuxerStream* demuxer_stream,
56 const PipelineStatusCB& filter_callback,
57 const StatisticsCallback& stat_callback) {
58 DVLOG(1) << "InitializeOnDecoderThread";
59 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
60
61 filter_callback.Run(PIPELINE_OK);
62 stopped_ = false;
63 }
64
65 void VideoFrameGenerator::ReadOnDecoderThread(const ReadCB& callback) {
66 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
67 CHECK(!callback.is_null());
68 if (stopped_)
69 return;
70
71 // Always allocate a new frame.
72 //
73 // TODO(scherkus): migrate this to proper buffer recycling.
74 scoped_refptr<VideoFrame> video_frame =
75 VideoFrame::CreateFrame(VideoFrame::YV12,
76 natural_size_.width(),
77 natural_size_.height(),
78 current_time_,
79 frame_duration_);
80 current_time_ += frame_duration_;
81
82 // TODO(wjia): set pixel data to pre-defined patterns if it's desired to
83 // verify frame content.
84
85 callback.Run(video_frame);
86 }
87
88 void VideoFrameGenerator::StopOnDecoderThread(
89 const base::Closure& callback) {
90 DVLOG(1) << "StopOnDecoderThread";
91 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
92 stopped_ = true;
93 current_time_ = base::TimeDelta();
94 callback.Run();
95 }
96
97 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/video_frame_generator.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698