Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(878)

Side by Side Diff: media/filters/omx_video_decoder.cc

Issue 3335014: Added FakeGlVideoDecodeEngine to exercise the IPC protocol for hardware video decoding (Closed)
Patch Set: compile man... Created 10 years, 3 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/omx_video_decoder.h" 5 #include "media/filters/omx_video_decoder.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "media/base/callback.h" 8 #include "media/base/callback.h"
9 #include "media/base/factory.h" 9 #include "media/base/factory.h"
10 #include "media/base/filter_host.h" 10 #include "media/base/filter_host.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 height_ > Limits::kMaxDimension || 88 height_ > Limits::kMaxDimension ||
89 (width_ * height_) > Limits::kMaxCanvas) { 89 (width_ * height_) > Limits::kMaxCanvas) {
90 VideoCodecInfo info = {0}; 90 VideoCodecInfo info = {0};
91 OmxVideoDecoder::OnInitializeComplete(info); 91 OmxVideoDecoder::OnInitializeComplete(info);
92 return; 92 return;
93 } 93 }
94 94
95 VideoCodecConfig config; 95 VideoCodecConfig config;
96 switch (av_stream->codec->codec_id) { 96 switch (av_stream->codec->codec_id) {
97 case CODEC_ID_VC1: 97 case CODEC_ID_VC1:
98 config.codec_ = kCodecVC1; break; 98 config.codec = kCodecVC1; break;
99 case CODEC_ID_H264: 99 case CODEC_ID_H264:
100 config.codec_ = kCodecH264; break; 100 config.codec = kCodecH264; break;
101 case CODEC_ID_THEORA: 101 case CODEC_ID_THEORA:
102 config.codec_ = kCodecTheora; break; 102 config.codec = kCodecTheora; break;
103 case CODEC_ID_MPEG2VIDEO: 103 case CODEC_ID_MPEG2VIDEO:
104 config.codec_ = kCodecMPEG2; break; 104 config.codec = kCodecMPEG2; break;
105 case CODEC_ID_MPEG4: 105 case CODEC_ID_MPEG4:
106 config.codec_ = kCodecMPEG4; break; 106 config.codec = kCodecMPEG4; break;
107 default: 107 default:
108 NOTREACHED(); 108 NOTREACHED();
109 } 109 }
110 config.opaque_context_ = NULL; 110 config.opaque_context = NULL;
111 config.width_ = width_; 111 config.width = width_;
112 config.height_ = height_; 112 config.height = height_;
113 omx_engine_->Initialize(message_loop(), this, config); 113 omx_engine_->Initialize(message_loop(), this, config);
114 } 114 }
115 115
116 void OmxVideoDecoder::OnInitializeComplete(const VideoCodecInfo& info) { 116 void OmxVideoDecoder::OnInitializeComplete(const VideoCodecInfo& info) {
117 DCHECK_EQ(MessageLoop::current(), message_loop()); 117 DCHECK_EQ(MessageLoop::current(), message_loop());
118 DCHECK(initialize_callback_.get()); 118 DCHECK(initialize_callback_.get());
119 119
120 info_ = info; // Save a copy. 120 info_ = info; // Save a copy.
121 AutoCallbackRunner done_runner(initialize_callback_.release()); 121 AutoCallbackRunner done_runner(initialize_callback_.release());
122 122
123 if (info.success_) { 123 if (info.success) {
124 media_format_.SetAsString(MediaFormat::kMimeType, 124 media_format_.SetAsString(MediaFormat::kMimeType,
125 mime_type::kUncompressedVideo); 125 mime_type::kUncompressedVideo);
126 media_format_.SetAsInteger(MediaFormat::kWidth, width_); 126 media_format_.SetAsInteger(MediaFormat::kWidth, width_);
127 media_format_.SetAsInteger(MediaFormat::kHeight, height_); 127 media_format_.SetAsInteger(MediaFormat::kHeight, height_);
128 media_format_.SetAsInteger( 128 media_format_.SetAsInteger(
129 MediaFormat::kSurfaceType, 129 MediaFormat::kSurfaceType,
130 static_cast<int>(info.stream_info_.surface_type_)); 130 static_cast<int>(info.stream_info.surface_type));
131 media_format_.SetAsInteger( 131 media_format_.SetAsInteger(
132 MediaFormat::kSurfaceFormat, 132 MediaFormat::kSurfaceFormat,
133 static_cast<int>(info.stream_info_.surface_format_)); 133 static_cast<int>(info.stream_info.surface_format));
134 } else { 134 } else {
135 host()->SetError(PIPELINE_ERROR_DECODE); 135 host()->SetError(PIPELINE_ERROR_DECODE);
136 } 136 }
137 } 137 }
138 138
139 void OmxVideoDecoder::Stop(FilterCallback* callback) { 139 void OmxVideoDecoder::Stop(FilterCallback* callback) {
140 if (MessageLoop::current() != message_loop()) { 140 if (MessageLoop::current() != message_loop()) {
141 message_loop()->PostTask(FROM_HERE, 141 message_loop()->PostTask(FROM_HERE,
142 NewRunnableMethod(this, 142 NewRunnableMethod(this,
143 &OmxVideoDecoder::Stop, 143 &OmxVideoDecoder::Stop,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 229
230 void OmxVideoDecoder::ProduceVideoFrame(scoped_refptr<VideoFrame> frame) { 230 void OmxVideoDecoder::ProduceVideoFrame(scoped_refptr<VideoFrame> frame) {
231 DCHECK(omx_engine_.get()); 231 DCHECK(omx_engine_.get());
232 message_loop()->PostTask( 232 message_loop()->PostTask(
233 FROM_HERE, 233 FROM_HERE,
234 NewRunnableMethod(omx_engine_.get(), 234 NewRunnableMethod(omx_engine_.get(),
235 &VideoDecodeEngine::ProduceVideoFrame, frame)); 235 &VideoDecodeEngine::ProduceVideoFrame, frame));
236 } 236 }
237 237
238 bool OmxVideoDecoder::ProvidesBuffer() { 238 bool OmxVideoDecoder::ProvidesBuffer() {
239 DCHECK(info_.success_); 239 DCHECK(info_.success);
240 return info_.provides_buffers_; 240 return info_.provides_buffers;
241 } 241 }
242 242
243 void OmxVideoDecoder::DemuxCompleteTask(Buffer* buffer) { 243 void OmxVideoDecoder::DemuxCompleteTask(Buffer* buffer) {
244 // We simply delicate the buffer to the right message loop. 244 // We simply delicate the buffer to the right message loop.
245 scoped_refptr<Buffer> ref_buffer = buffer; 245 scoped_refptr<Buffer> ref_buffer = buffer;
246 DCHECK(omx_engine_.get()); 246 DCHECK(omx_engine_.get());
247 message_loop()->PostTask( 247 message_loop()->PostTask(
248 FROM_HERE, 248 FROM_HERE,
249 NewRunnableMethod(omx_engine_.get(), 249 NewRunnableMethod(omx_engine_.get(),
250 &VideoDecodeEngine::ConsumeVideoSample, ref_buffer)); 250 &VideoDecodeEngine::ConsumeVideoSample, ref_buffer));
251 } 251 }
252 252
253 } // namespace media 253 } // namespace media
254 254
255 // Disable refcounting for the decode engine because it only lives on the 255 // Disable refcounting for the decode engine because it only lives on the
256 // video decoder thread. 256 // video decoder thread.
257 DISABLE_RUNNABLE_METHOD_REFCOUNT(media::VideoDecodeEngine); 257 DISABLE_RUNNABLE_METHOD_REFCOUNT(media::VideoDecodeEngine);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698