OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 | 5 |
6 #include "chrome/renderer/media/ipc_video_decoder.h" | 6 #include "chrome/renderer/media/ipc_video_decoder.h" |
7 | 7 |
8 #include "base/task.h" | 8 #include "base/task.h" |
| 9 #include "chrome/renderer/ggl/ggl.h" |
9 #include "media/base/callback.h" | 10 #include "media/base/callback.h" |
10 #include "media/base/filters.h" | 11 #include "media/base/filters.h" |
11 #include "media/base/filter_host.h" | 12 #include "media/base/filter_host.h" |
12 #include "media/base/limits.h" | 13 #include "media/base/limits.h" |
13 #include "media/base/media_format.h" | 14 #include "media/base/media_format.h" |
14 #include "media/base/video_frame.h" | 15 #include "media/base/video_frame.h" |
15 #include "media/ffmpeg/ffmpeg_common.h" | 16 #include "media/ffmpeg/ffmpeg_common.h" |
16 #include "media/ffmpeg/ffmpeg_util.h" | 17 #include "media/ffmpeg/ffmpeg_util.h" |
17 #include "media/filters/ffmpeg_interfaces.h" | 18 #include "media/filters/ffmpeg_interfaces.h" |
18 | 19 |
(...skipping 21 matching lines...) Expand all Loading... |
40 demuxer_stream, | 41 demuxer_stream, |
41 callback)); | 42 callback)); |
42 return; | 43 return; |
43 } | 44 } |
44 | 45 |
45 CHECK(!demuxer_stream_); | 46 CHECK(!demuxer_stream_); |
46 demuxer_stream_ = demuxer_stream; | 47 demuxer_stream_ = demuxer_stream; |
47 initialize_callback_.reset(callback); | 48 initialize_callback_.reset(callback); |
48 | 49 |
49 // We require bit stream converter for openmax hardware decoder. | 50 // We require bit stream converter for openmax hardware decoder. |
| 51 // TODO(hclam): This is a wrong place to initialize the demuxer stream's |
| 52 // bitstream converter. |
50 demuxer_stream->EnableBitstreamConverter(); | 53 demuxer_stream->EnableBitstreamConverter(); |
51 | 54 |
52 // Get the AVStream by querying for the provider interface. | 55 // Get the AVStream by querying for the provider interface. |
53 AVStreamProvider* av_stream_provider; | 56 AVStreamProvider* av_stream_provider; |
54 if (!demuxer_stream->QueryInterface(&av_stream_provider)) { | 57 if (!demuxer_stream->QueryInterface(&av_stream_provider)) { |
55 GpuVideoDecoderInitDoneParam param; | 58 GpuVideoDecoderInitDoneParam param; |
56 OnInitializeDone(false, param); | 59 OnInitializeDone(false, param); |
57 return; | 60 return; |
58 } | 61 } |
59 | 62 |
60 AVStream* av_stream = av_stream_provider->GetAVStream(); | 63 AVStream* av_stream = av_stream_provider->GetAVStream(); |
61 width_ = av_stream->codec->width; | 64 width_ = av_stream->codec->width; |
62 height_ = av_stream->codec->height; | 65 height_ = av_stream->codec->height; |
63 | 66 |
64 // Create hardware decoder instance. | 67 // TODO(hclam): Pass an actual context instead of NULL. |
65 GpuVideoServiceHost* gpu_video_service_host = GpuVideoServiceHost::get(); | 68 gpu_video_decoder_host_ = ggl::CreateVideoDecoder(NULL); |
66 gpu_video_decoder_host_ = gpu_video_service_host->CreateVideoDecoder(this); | |
67 | 69 |
68 // Initialize hardware decoder. | 70 // Initialize hardware decoder. |
69 GpuVideoDecoderInitParam param = {0}; | 71 GpuVideoDecoderInitParam param = {0}; |
70 param.width_ = width_; | 72 param.width_ = width_; |
71 param.height_ = height_; | 73 param.height_ = height_; |
72 if (!gpu_video_decoder_host_->Initialize(param)) { | 74 if (!gpu_video_decoder_host_->Initialize(this, param)) { |
73 GpuVideoDecoderInitDoneParam param; | 75 GpuVideoDecoderInitDoneParam param; |
74 OnInitializeDone(false, param); | 76 OnInitializeDone(false, param); |
75 } | 77 } |
76 } | 78 } |
77 | 79 |
78 void IpcVideoDecoder::OnInitializeDone( | 80 void IpcVideoDecoder::OnInitializeDone( |
79 bool success, const GpuVideoDecoderInitDoneParam& param) { | 81 bool success, const GpuVideoDecoderInitDoneParam& param) { |
80 if (MessageLoop::current() != renderer_thread_message_loop_) { | 82 if (MessageLoop::current() != renderer_thread_message_loop_) { |
81 renderer_thread_message_loop_->PostTask( | 83 renderer_thread_message_loop_->PostTask( |
82 FROM_HERE, | 84 FROM_HERE, |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 return false; | 339 return false; |
338 | 340 |
339 // TODO(jiesun): Although we current only support H264 hardware decoding, | 341 // TODO(jiesun): Although we current only support H264 hardware decoding, |
340 // in the future, we should query GpuVideoService for capabilities. | 342 // in the future, we should query GpuVideoService for capabilities. |
341 int codec_id; | 343 int codec_id; |
342 return format.GetAsInteger(MediaFormat::kFFmpegCodecID, &codec_id) && | 344 return format.GetAsInteger(MediaFormat::kFFmpegCodecID, &codec_id) && |
343 codec_id == CODEC_ID_H264; | 345 codec_id == CODEC_ID_H264; |
344 } | 346 } |
345 | 347 |
346 } // namespace media | 348 } // namespace media |
347 | |
OLD | NEW |