Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / media / base / android / video_decoder_job.cc
blob884bc6d3d0ba6247073c9adb355783cf90576a0e
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(
28 const VideoCodec video_codec,
29 bool is_secure,
30 const gfx::Size& size,
31 jobject surface,
32 jobject media_crypto,
33 const base::Closure& request_data_cb,
34 const base::Closure& request_resources_cb,
35 const base::Closure& release_resources_cb) {
36 scoped_ptr<VideoCodecBridge> codec(VideoCodecBridge::CreateDecoder(
37 video_codec, is_secure, size, surface, media_crypto));
38 if (codec)
39 return new VideoDecoderJob(codec.Pass(), request_data_cb,
40 request_resources_cb, release_resources_cb);
42 LOG(ERROR) << "Failed to create VideoDecoderJob.";
43 return NULL;
46 VideoDecoderJob::VideoDecoderJob(
47 scoped_ptr<VideoCodecBridge> video_codec_bridge,
48 const base::Closure& request_data_cb,
49 const base::Closure& request_resources_cb,
50 const base::Closure& release_resources_cb)
51 : MediaDecoderJob(g_video_decoder_thread.Pointer()->message_loop_proxy(),
52 video_codec_bridge.get(), request_data_cb),
53 video_codec_bridge_(video_codec_bridge.Pass()),
54 release_resources_cb_(release_resources_cb) {
55 request_resources_cb.Run();
58 VideoDecoderJob::~VideoDecoderJob() {
59 release_resources_cb_.Run();
62 void VideoDecoderJob::ReleaseOutputBuffer(
63 int output_buffer_index,
64 size_t size,
65 bool render_output,
66 base::TimeDelta current_presentation_timestamp,
67 const ReleaseOutputCompletionCallback& callback) {
68 video_codec_bridge_->ReleaseOutputBuffer(output_buffer_index, render_output);
69 callback.Run(current_presentation_timestamp, current_presentation_timestamp);
72 bool VideoDecoderJob::ComputeTimeToRender() const {
73 return true;
76 } // namespace media