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

Side by Side Diff: content/common/gpu/media/android_video_decode_accelerator.cc

Issue 74563002: AndroidVideoEncodeAccelerator is born! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/common/gpu/media/android_video_decode_accelerator.h" 5 #include "content/common/gpu/media/android_video_decode_accelerator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 if (profile == media::VP8PROFILE_MAIN) { 78 if (profile == media::VP8PROFILE_MAIN) {
79 codec_ = media::kCodecVP8; 79 codec_ = media::kCodecVP8;
80 } else { 80 } else {
81 // TODO(dwkang): enable H264 once b/8125974 is fixed. 81 // TODO(dwkang): enable H264 once b/8125974 is fixed.
82 LOG(ERROR) << "Unsupported profile: " << profile; 82 LOG(ERROR) << "Unsupported profile: " << profile;
83 return false; 83 return false;
84 } 84 }
85 85
86 // Only consider using MediaCodec if it's likely backed by hardware. 86 // Only consider using MediaCodec if it's likely backed by hardware.
87 if (media::VideoCodecBridge::IsKnownUnaccelerated(codec_)) 87 if (media::VideoCodecBridge::IsKnownUnaccelerated(codec_, false))
88 return false; 88 return false;
89 89
90 if (!make_context_current_.Run()) { 90 if (!make_context_current_.Run()) {
91 LOG(ERROR) << "Failed to make this decoder's GL context current."; 91 LOG(ERROR) << "Failed to make this decoder's GL context current.";
92 return false; 92 return false;
93 } 93 }
94 94
95 if (!gl_decoder_) { 95 if (!gl_decoder_) {
96 LOG(ERROR) << "Failed to get gles2 decoder instance."; 96 LOG(ERROR) << "Failed to get gles2 decoder instance.";
97 return false; 97 return false;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 204 }
205 205
206 bool eos = false; 206 bool eos = false;
207 base::TimeDelta timestamp; 207 base::TimeDelta timestamp;
208 int32 buf_index = 0; 208 int32 buf_index = 0;
209 do { 209 do {
210 size_t offset = 0; 210 size_t offset = 0;
211 size_t size = 0; 211 size_t size = 0;
212 212
213 media::MediaCodecStatus status = media_codec_->DequeueOutputBuffer( 213 media::MediaCodecStatus status = media_codec_->DequeueOutputBuffer(
214 NoWaitTimeOut(), &buf_index, &offset, &size, &timestamp, &eos); 214 NoWaitTimeOut(), &buf_index, &offset, &size, &timestamp, &eos, NULL);
215 switch (status) { 215 switch (status) {
216 case media::MEDIA_CODEC_DEQUEUE_OUTPUT_AGAIN_LATER: 216 case media::MEDIA_CODEC_DEQUEUE_OUTPUT_AGAIN_LATER:
217 case media::MEDIA_CODEC_ERROR: 217 case media::MEDIA_CODEC_ERROR:
218 return; 218 return;
219 219
220 case media::MEDIA_CODEC_OUTPUT_FORMAT_CHANGED: { 220 case media::MEDIA_CODEC_OUTPUT_FORMAT_CHANGED: {
221 int32 width, height; 221 int32 width, height;
222 media_codec_->GetOutputFormat(&width, &height); 222 media_codec_->GetOutputFormat(&width, &height);
223 223
224 if (!picturebuffers_requested_) { 224 if (!picturebuffers_requested_) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 393 }
394 394
395 void AndroidVideoDecodeAccelerator::Flush() { 395 void AndroidVideoDecodeAccelerator::Flush() {
396 DCHECK(thread_checker_.CalledOnValidThread()); 396 DCHECK(thread_checker_.CalledOnValidThread());
397 397
398 Decode(media::BitstreamBuffer(-1, base::SharedMemoryHandle(), 0)); 398 Decode(media::BitstreamBuffer(-1, base::SharedMemoryHandle(), 0));
399 } 399 }
400 400
401 bool AndroidVideoDecodeAccelerator::ConfigureMediaCodec() { 401 bool AndroidVideoDecodeAccelerator::ConfigureMediaCodec() {
402 DCHECK(surface_texture_.get()); 402 DCHECK(surface_texture_.get());
403 media_codec_.reset(media::VideoCodecBridge::Create(codec_, false));
404
405 if (!media_codec_)
406 return false;
407 403
408 gfx::ScopedJavaSurface surface(surface_texture_.get()); 404 gfx::ScopedJavaSurface surface(surface_texture_.get());
405
409 // Pass a dummy 320x240 canvas size and let the codec signal the real size 406 // Pass a dummy 320x240 canvas size and let the codec signal the real size
410 // when it's known from the bitstream. 407 // when it's known from the bitstream.
411 if (!media_codec_->Start( 408 media_codec_.reset(media::VideoCodecBridge::CreateDecoder(
412 codec_, gfx::Size(320, 240), surface.j_surface().obj(), NULL)) { 409 codec_, false, gfx::Size(320, 240), surface.j_surface().obj(), NULL));
413 return false; 410 if (!media_codec_) return false;
414 } 411
415 io_timer_.Start(FROM_HERE, 412 io_timer_.Start(FROM_HERE,
416 DecodePollDelay(), 413 DecodePollDelay(),
417 this, 414 this,
418 &AndroidVideoDecodeAccelerator::DoIOTask); 415 &AndroidVideoDecodeAccelerator::DoIOTask);
419 return media_codec_->GetOutputBuffers(); 416 return true;
420 } 417 }
421 418
422 void AndroidVideoDecodeAccelerator::Reset() { 419 void AndroidVideoDecodeAccelerator::Reset() {
423 DCHECK(thread_checker_.CalledOnValidThread()); 420 DCHECK(thread_checker_.CalledOnValidThread());
424 421
425 while (!pending_bitstream_buffers_.empty()) { 422 while (!pending_bitstream_buffers_.empty()) {
426 int32 bitstream_buffer_id = pending_bitstream_buffers_.front().first.id(); 423 int32 bitstream_buffer_id = pending_bitstream_buffers_.front().first.id();
427 pending_bitstream_buffers_.pop(); 424 pending_bitstream_buffers_.pop();
428 425
429 if (bitstream_buffer_id != -1) { 426 if (bitstream_buffer_id != -1) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 void AndroidVideoDecodeAccelerator::NotifyResetDone() { 495 void AndroidVideoDecodeAccelerator::NotifyResetDone() {
499 client_->NotifyResetDone(); 496 client_->NotifyResetDone();
500 } 497 }
501 498
502 void AndroidVideoDecodeAccelerator::NotifyError( 499 void AndroidVideoDecodeAccelerator::NotifyError(
503 media::VideoDecodeAccelerator::Error error) { 500 media::VideoDecodeAccelerator::Error error) {
504 client_->NotifyError(error); 501 client_->NotifyError(error);
505 } 502 }
506 503
507 } // namespace content 504 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698