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

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

Issue 12320078: Delete old RTCVideoDecoder code path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make the line no longer than 80 chars Created 7 years, 9 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
« 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')
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/video_frame.h"
11
12 namespace media {
13
14 VideoFrameGenerator::VideoFrameGenerator(
15 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy,
16 const gfx::Size& size,
17 const base::TimeDelta& frame_duration)
18 : message_loop_proxy_(message_loop_proxy),
19 size_(size),
20 stopped_(true),
21 frame_duration_(frame_duration) {
22 }
23
24 void VideoFrameGenerator::Initialize(
25 const scoped_refptr<DemuxerStream>& stream,
26 const PipelineStatusCB& status_cb,
27 const StatisticsCB& statistics_cb) {
28 message_loop_proxy_->PostTask(
29 FROM_HERE,
30 base::Bind(&VideoFrameGenerator::InitializeOnDecoderThread,
31 this, stream, status_cb, statistics_cb));
32 }
33
34 void VideoFrameGenerator::Read(const ReadCB& read_cb) {
35 message_loop_proxy_->PostTask(
36 FROM_HERE,
37 base::Bind(&VideoFrameGenerator::ReadOnDecoderThread, this, read_cb));
38 }
39
40 void VideoFrameGenerator::Reset(const base::Closure& closure) {
41 message_loop_proxy_->PostTask(
42 FROM_HERE,
43 base::Bind(&VideoFrameGenerator::ResetOnDecoderThread, this, closure));
44 }
45
46 void VideoFrameGenerator::Stop(const base::Closure& closure) {
47 message_loop_proxy_->PostTask(
48 FROM_HERE,
49 base::Bind(&VideoFrameGenerator::StopOnDecoderThread, this, closure));
50 }
51
52 VideoFrameGenerator::~VideoFrameGenerator() {}
53
54 void VideoFrameGenerator::InitializeOnDecoderThread(
55 const scoped_refptr<DemuxerStream>& /* stream */,
56 const PipelineStatusCB& status_cb,
57 const StatisticsCB& statistics_cb) {
58 DVLOG(1) << "InitializeOnDecoderThread";
59 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
60
61 status_cb.Run(PIPELINE_OK);
62 stopped_ = false;
63 }
64
65 void VideoFrameGenerator::ReadOnDecoderThread(const ReadCB& read_cb) {
66 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
67 CHECK(!read_cb.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, size_, gfx::Rect(size_), size_,
76 current_time_);
77 current_time_ += frame_duration_;
78
79 // TODO(wjia): set pixel data to pre-defined patterns if it's desired to
80 // verify frame content.
81
82 read_cb.Run(kOk, video_frame);
83 }
84
85 void VideoFrameGenerator::ResetOnDecoderThread(const base::Closure& closure) {
86 DVLOG(1) << "ResetOnDecoderThread";
87 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
88 current_time_ = base::TimeDelta();
89 closure.Run();
90 }
91
92 void VideoFrameGenerator::StopOnDecoderThread(const base::Closure& closure) {
93 DVLOG(1) << "StopOnDecoderThread";
94 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
95 stopped_ = true;
96 current_time_ = base::TimeDelta();
97 closure.Run();
98 }
99
100 } // 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