Fix for browser_plugin_host_browsertest when embedder is not yet available.
[chromium-blink-merge.git] / media / base / android / video_decoder_job.cc
blob02b41c4b5c4272bd4c3e6f8a1e8dda3e904c5dc1
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"
7 #include "base/bind.h"
8 #include "base/lazy_instance.h"
9 #include "base/threading/thread.h"
10 #include "media/base/android/media_codec_bridge.h"
12 namespace media {
14 class VideoDecoderThread : public base::Thread {
15 public:
16 VideoDecoderThread() : base::Thread("MediaSource_VideoDecoderThread") {
17 Start();
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,
28 bool is_secure,
29 const gfx::Size& size,
30 jobject surface,
31 jobject media_crypto,
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.";
39 return NULL;
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,
55 size_t size,
56 bool render_output,
57 const ReleaseOutputCompletionCallback& callback) {
58 video_codec_bridge_->ReleaseOutputBuffer(output_buffer_index, render_output);
59 callback.Run(0u);
62 bool VideoDecoderJob::ComputeTimeToRender() const {
63 return true;
66 } // namespace media