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

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: rebase 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
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 #include "media/base/filter_host.h"
acolwell GONE FROM CHROMIUM 2012/01/06 18:09:16 nit: I don't think this include is needed.
wjia(left Chromium) 2012/01/06 22:18:59 Done.
11
12 namespace media {
13
14 VideoFrameGenerator::VideoFrameGenerator(
15 base::MessageLoopProxy* message_loop_proxy,
16 const gfx::Size& size,
17 const base::TimeDelta& frame_duration)
18 : message_loop_proxy_(message_loop_proxy),
19 natural_size_(size),
20 stopped_(true),
21 frame_duration_(frame_duration) {
22 }
23
24 VideoFrameGenerator::~VideoFrameGenerator() {}
25
26 void VideoFrameGenerator::Initialize(
27 DemuxerStream* demuxer_stream,
28 const PipelineStatusCB& filter_callback,
29 const StatisticsCallback& stat_callback) {
30 message_loop_proxy_->PostTask(
31 FROM_HERE,
32 base::Bind(&VideoFrameGenerator::InitializeOnDecoderThread,
33 this, make_scoped_refptr(demuxer_stream),
34 filter_callback, stat_callback));
35 }
36
37 void VideoFrameGenerator::Read(const ReadCB& callback) {
38 message_loop_proxy_->PostTask(
39 FROM_HERE,
40 base::Bind(&VideoFrameGenerator::ReadOnDecoderThread,
41 this, callback));
42 }
43
44 const gfx::Size& VideoFrameGenerator::natural_size() {
45 return natural_size_;
46 }
47
48 void VideoFrameGenerator::Stop(const base::Closure& callback) {
49 message_loop_proxy_->PostTask(
50 FROM_HERE,
51 base::Bind(&VideoFrameGenerator::StopOnDecoderThread,
52 this, callback));
53 }
54
55 void VideoFrameGenerator::InitializeOnDecoderThread(
56 DemuxerStream* demuxer_stream,
57 const PipelineStatusCB& filter_callback,
58 const StatisticsCallback& stat_callback) {
59 DVLOG(1) << "InitializeOnDecoderThread";
60 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
61
62 filter_callback.Run(PIPELINE_OK);
63 stopped_ = false;
64 }
65
66 void VideoFrameGenerator::ReadOnDecoderThread(const ReadCB& callback) {
67 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
68 CHECK(!callback.is_null());
69 if (stopped_)
70 return;
71
72 // Always allocate a new frame.
73 //
74 // TODO(scherkus): migrate this to proper buffer recycling.
75 scoped_refptr<VideoFrame> video_frame =
76 VideoFrame::CreateFrame(VideoFrame::YV12,
77 natural_size_.width(),
78 natural_size_.height(),
79 current_time_,
80 frame_duration_);
81 current_time_ += frame_duration_;
82
83 // TODO(wjia): set pixel data to pre-defined patterns if it's desired to
84 // verify frame content.
85
86 callback.Run(video_frame);
87 }
88
89 void VideoFrameGenerator::StopOnDecoderThread(
90 const base::Closure& callback) {
91 DVLOG(1) << "StopOnDecoderThread";
92 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
93 stopped_ = true;
94 current_time_ = base::TimeDelta();
95 callback.Run();
96 }
97
98 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698