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

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

Issue 141243003: Add AudioBufferStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decoderstream_rebased
Patch Set: Rebase! Created 6 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/fake_video_decoder.h ('k') | media/filters/fake_video_decoder_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/filters/fake_video_decoder.h" 5 #include "media/filters/fake_video_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "media/base/bind_to_current_loop.h" 11 #include "media/base/bind_to_current_loop.h"
12 #include "media/base/test_helpers.h" 12 #include "media/base/test_helpers.h"
13 13
14 namespace media { 14 namespace media {
15 15
16 FakeVideoDecoder::FakeVideoDecoder(int decoding_delay) 16 FakeVideoDecoder::FakeVideoDecoder(int decoding_delay,
17 bool supports_get_decode_output)
17 : task_runner_(base::MessageLoopProxy::current()), 18 : task_runner_(base::MessageLoopProxy::current()),
18 weak_factory_(this), 19 weak_factory_(this),
19 decoding_delay_(decoding_delay), 20 decoding_delay_(decoding_delay),
21 supports_get_decode_output_(supports_get_decode_output),
20 state_(UNINITIALIZED), 22 state_(UNINITIALIZED),
21 total_bytes_decoded_(0) { 23 total_bytes_decoded_(0) {
22 DCHECK_GE(decoding_delay, 0); 24 DCHECK_GE(decoding_delay, 0);
23 } 25 }
24 26
25 FakeVideoDecoder::~FakeVideoDecoder() { 27 FakeVideoDecoder::~FakeVideoDecoder() {
26 DCHECK_EQ(state_, UNINITIALIZED); 28 DCHECK_EQ(state_, UNINITIALIZED);
27 } 29 }
28 30
29 void FakeVideoDecoder::Initialize(const VideoDecoderConfig& config, 31 void FakeVideoDecoder::Initialize(const VideoDecoderConfig& config,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 DCHECK(task_runner_->BelongsToCurrentThread()); 98 DCHECK(task_runner_->BelongsToCurrentThread());
97 stop_cb_.SetCallback(BindToCurrentLoop(closure)); 99 stop_cb_.SetCallback(BindToCurrentLoop(closure));
98 100
99 // Defer the stop if an init, a decode or a reset is pending. 101 // Defer the stop if an init, a decode or a reset is pending.
100 if (!init_cb_.IsNull() || !decode_cb_.IsNull() || !reset_cb_.IsNull()) 102 if (!init_cb_.IsNull() || !decode_cb_.IsNull() || !reset_cb_.IsNull())
101 return; 103 return;
102 104
103 DoStop(); 105 DoStop();
104 } 106 }
105 107
108 scoped_refptr<VideoFrame> FakeVideoDecoder::GetDecodeOutput() {
109 DCHECK(task_runner_->BelongsToCurrentThread());
110 if (!supports_get_decode_output_ || decoded_frames_.empty())
111 return NULL;
112 scoped_refptr<VideoFrame> out = decoded_frames_.front();
113 decoded_frames_.pop_front();
114 return out;
115 }
116
106 void FakeVideoDecoder::HoldNextInit() { 117 void FakeVideoDecoder::HoldNextInit() {
107 DCHECK(task_runner_->BelongsToCurrentThread()); 118 DCHECK(task_runner_->BelongsToCurrentThread());
108 init_cb_.HoldCallback(); 119 init_cb_.HoldCallback();
109 } 120 }
110 121
111 void FakeVideoDecoder::HoldNextRead() { 122 void FakeVideoDecoder::HoldNextRead() {
112 DCHECK(task_runner_->BelongsToCurrentThread()); 123 DCHECK(task_runner_->BelongsToCurrentThread());
113 decode_cb_.HoldCallback(); 124 decode_cb_.HoldCallback();
114 } 125 }
115 126
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 int buffer_size, 196 int buffer_size,
186 const DecodeCB& decode_cb, 197 const DecodeCB& decode_cb,
187 Status status, 198 Status status,
188 const scoped_refptr<VideoFrame>& video_frame) { 199 const scoped_refptr<VideoFrame>& video_frame) {
189 if (status == kOk || status == kNotEnoughData) 200 if (status == kOk || status == kNotEnoughData)
190 total_bytes_decoded_ += buffer_size; 201 total_bytes_decoded_ += buffer_size;
191 decode_cb.Run(status, video_frame); 202 decode_cb.Run(status, video_frame);
192 } 203 }
193 204
194 } // namespace media 205 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/fake_video_decoder.h ('k') | media/filters/fake_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698