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/filters/ffmpeg_video_decoder.cc

Issue 1083883003: Move BindToCurrentLoop from media/base/ to base/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix media/base/callback_holder.h compile Created 5 years, 8 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/ffmpeg_demuxer.cc ('k') | media/filters/gpu_video_decoder.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 (c) 2012 The Chromium Authors. All rights reserved. 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 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/ffmpeg_video_decoder.h" 5 #include "media/filters/ffmpeg_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_to_current_loop.h"
11 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/location.h" 14 #include "base/location.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "media/base/bind_to_current_loop.h"
17 #include "media/base/decoder_buffer.h" 17 #include "media/base/decoder_buffer.h"
18 #include "media/base/limits.h" 18 #include "media/base/limits.h"
19 #include "media/base/media_switches.h" 19 #include "media/base/media_switches.h"
20 #include "media/base/pipeline.h" 20 #include "media/base/pipeline.h"
21 #include "media/base/video_decoder_config.h" 21 #include "media/base/video_decoder_config.h"
22 #include "media/base/video_frame.h" 22 #include "media/base/video_frame.h"
23 #include "media/base/video_util.h" 23 #include "media/base/video_util.h"
24 #include "media/ffmpeg/ffmpeg_common.h" 24 #include "media/ffmpeg/ffmpeg_common.h"
25 #include "media/filters/ffmpeg_glue.h" 25 #include "media/filters/ffmpeg_glue.h"
26 26
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 bool low_delay, 163 bool low_delay,
164 const PipelineStatusCB& status_cb, 164 const PipelineStatusCB& status_cb,
165 const OutputCB& output_cb) { 165 const OutputCB& output_cb) {
166 DCHECK(task_runner_->BelongsToCurrentThread()); 166 DCHECK(task_runner_->BelongsToCurrentThread());
167 DCHECK(!config.is_encrypted()); 167 DCHECK(!config.is_encrypted());
168 DCHECK(!output_cb.is_null()); 168 DCHECK(!output_cb.is_null());
169 169
170 FFmpegGlue::InitializeFFmpeg(); 170 FFmpegGlue::InitializeFFmpeg();
171 171
172 config_ = config; 172 config_ = config;
173 PipelineStatusCB initialize_cb = BindToCurrentLoop(status_cb); 173 PipelineStatusCB initialize_cb = base::BindToCurrentLoop(status_cb);
174 174
175 if (!config.IsValidConfig() || !ConfigureDecoder(low_delay)) { 175 if (!config.IsValidConfig() || !ConfigureDecoder(low_delay)) {
176 initialize_cb.Run(DECODER_ERROR_NOT_SUPPORTED); 176 initialize_cb.Run(DECODER_ERROR_NOT_SUPPORTED);
177 return; 177 return;
178 } 178 }
179 179
180 output_cb_ = BindToCurrentLoop(output_cb); 180 output_cb_ = base::BindToCurrentLoop(output_cb);
181 181
182 // Success! 182 // Success!
183 state_ = kNormal; 183 state_ = kNormal;
184 initialize_cb.Run(PIPELINE_OK); 184 initialize_cb.Run(PIPELINE_OK);
185 } 185 }
186 186
187 void FFmpegVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, 187 void FFmpegVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
188 const DecodeCB& decode_cb) { 188 const DecodeCB& decode_cb) {
189 DCHECK(task_runner_->BelongsToCurrentThread()); 189 DCHECK(task_runner_->BelongsToCurrentThread());
190 DCHECK(buffer.get()); 190 DCHECK(buffer.get());
191 DCHECK(!decode_cb.is_null()); 191 DCHECK(!decode_cb.is_null());
192 CHECK_NE(state_, kUninitialized); 192 CHECK_NE(state_, kUninitialized);
193 193
194 DecodeCB decode_cb_bound = BindToCurrentLoop(decode_cb); 194 DecodeCB decode_cb_bound = base::BindToCurrentLoop(decode_cb);
195 195
196 if (state_ == kError) { 196 if (state_ == kError) {
197 decode_cb_bound.Run(kDecodeError); 197 decode_cb_bound.Run(kDecodeError);
198 return; 198 return;
199 } 199 }
200 200
201 if (state_ == kDecodeFinished) { 201 if (state_ == kDecodeFinished) {
202 decode_cb_bound.Run(kOk); 202 decode_cb_bound.Run(kOk);
203 return; 203 return;
204 } 204 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { 353 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
354 ReleaseFFmpegResources(); 354 ReleaseFFmpegResources();
355 return false; 355 return false;
356 } 356 }
357 357
358 av_frame_.reset(av_frame_alloc()); 358 av_frame_.reset(av_frame_alloc());
359 return true; 359 return true;
360 } 360 }
361 361
362 } // namespace media 362 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | media/filters/gpu_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698