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
3 // found in the LICENSE file.
5 #include "media/base/android/video_decoder_job.h"
8 #include "base/lazy_instance.h"
9 #include "base/threading/thread.h"
10 #include "media/base/android/media_codec_bridge.h"
14 class VideoDecoderThread : public base::Thread {
16 VideoDecoderThread() : base::Thread("MediaSource_VideoDecoderThread") {
21 // TODO(qinmin): Check if it is tolerable to use worker pool to handle all the
22 // decoding tasks so that we don't need a global thread here.
23 // http://crbug.com/245750
24 base::LazyInstance<VideoDecoderThread>::Leaky
25 g_video_decoder_thread = LAZY_INSTANCE_INITIALIZER;
27 VideoDecoderJob* VideoDecoderJob::Create(const VideoCodec video_codec,
29 const gfx::Size& size,
32 const base::Closure& request_data_cb) {
33 scoped_ptr<VideoCodecBridge> codec(
34 VideoCodecBridge::Create(video_codec, is_secure));
35 if (codec && codec->Start(video_codec, size, surface, media_crypto))
36 return new VideoDecoderJob(codec.Pass(), request_data_cb);
38 LOG(ERROR) << "Failed to create VideoDecoderJob.";
42 VideoDecoderJob::VideoDecoderJob(
43 scoped_ptr<VideoCodecBridge> video_codec_bridge,
44 const base::Closure& request_data_cb)
45 : MediaDecoderJob(g_video_decoder_thread.Pointer()->message_loop_proxy(),
46 video_codec_bridge.get(), request_data_cb),
47 video_codec_bridge_(video_codec_bridge.Pass()) {
50 VideoDecoderJob::~VideoDecoderJob() {
53 void VideoDecoderJob::ReleaseOutputBuffer(
54 int output_buffer_index,
57 const ReleaseOutputCompletionCallback& callback) {
58 video_codec_bridge_->ReleaseOutputBuffer(output_buffer_index, render_output);
62 bool VideoDecoderJob::ComputeTimeToRender() const {