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

Side by Side Diff: content/renderer/pepper/video_decoder_shim.cc

Issue 1143223007: media: Reland "Simplify {Audio|Video}Decoder initialization callback." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | media/base/audio_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer/pepper/video_decoder_shim.h" 5 #include "content/renderer/pepper/video_decoder_shim.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <GLES2/gl2extchromium.h> 9 #include <GLES2/gl2extchromium.h>
10 10
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 public: 626 public:
627 explicit DecoderImpl(const base::WeakPtr<VideoDecoderShim>& proxy); 627 explicit DecoderImpl(const base::WeakPtr<VideoDecoderShim>& proxy);
628 ~DecoderImpl(); 628 ~DecoderImpl();
629 629
630 void Initialize(media::VideoDecoderConfig config); 630 void Initialize(media::VideoDecoderConfig config);
631 void Decode(uint32_t decode_id, scoped_refptr<media::DecoderBuffer> buffer); 631 void Decode(uint32_t decode_id, scoped_refptr<media::DecoderBuffer> buffer);
632 void Reset(); 632 void Reset();
633 void Stop(); 633 void Stop();
634 634
635 private: 635 private:
636 void OnPipelineStatus(media::PipelineStatus status); 636 void OnInitDone(bool success);
637 void DoDecode(); 637 void DoDecode();
638 void OnDecodeComplete(media::VideoDecoder::Status status); 638 void OnDecodeComplete(media::VideoDecoder::Status status);
639 void OnOutputComplete(const scoped_refptr<media::VideoFrame>& frame); 639 void OnOutputComplete(const scoped_refptr<media::VideoFrame>& frame);
640 void OnResetComplete(); 640 void OnResetComplete();
641 641
642 // WeakPtr is bound to main_message_loop_. Use only in shim callbacks. 642 // WeakPtr is bound to main_message_loop_. Use only in shim callbacks.
643 base::WeakPtr<VideoDecoderShim> shim_; 643 base::WeakPtr<VideoDecoderShim> shim_;
644 scoped_ptr<media::VideoDecoder> decoder_; 644 scoped_ptr<media::VideoDecoder> decoder_;
645 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 645 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
646 // Queue of decodes waiting for the decoder. 646 // Queue of decodes waiting for the decoder.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 ffmpeg_video_decoder->set_decode_nalus(true); 685 ffmpeg_video_decoder->set_decode_nalus(true);
686 decoder_ = ffmpeg_video_decoder.Pass(); 686 decoder_ = ffmpeg_video_decoder.Pass();
687 } 687 }
688 688
689 // VpxVideoDecoder and FFmpegVideoDecoder support only one pending Decode() 689 // VpxVideoDecoder and FFmpegVideoDecoder support only one pending Decode()
690 // request. 690 // request.
691 DCHECK_EQ(decoder_->GetMaxDecodeRequests(), 1); 691 DCHECK_EQ(decoder_->GetMaxDecodeRequests(), 1);
692 692
693 decoder_->Initialize( 693 decoder_->Initialize(
694 config, true /* low_delay */, 694 config, true /* low_delay */,
695 base::Bind(&VideoDecoderShim::DecoderImpl::OnPipelineStatus, 695 base::Bind(&VideoDecoderShim::DecoderImpl::OnInitDone,
696 weak_ptr_factory_.GetWeakPtr()), 696 weak_ptr_factory_.GetWeakPtr()),
697 base::Bind(&VideoDecoderShim::DecoderImpl::OnOutputComplete, 697 base::Bind(&VideoDecoderShim::DecoderImpl::OnOutputComplete,
698 weak_ptr_factory_.GetWeakPtr())); 698 weak_ptr_factory_.GetWeakPtr()));
699 } 699 }
700 700
701 void VideoDecoderShim::DecoderImpl::Decode( 701 void VideoDecoderShim::DecoderImpl::Decode(
702 uint32_t decode_id, 702 uint32_t decode_id,
703 scoped_refptr<media::DecoderBuffer> buffer) { 703 scoped_refptr<media::DecoderBuffer> buffer) {
704 DCHECK(decoder_); 704 DCHECK(decoder_);
705 pending_decodes_.push(PendingDecode(decode_id, buffer)); 705 pending_decodes_.push(PendingDecode(decode_id, buffer));
(...skipping 18 matching lines...) Expand all
724 void VideoDecoderShim::DecoderImpl::Stop() { 724 void VideoDecoderShim::DecoderImpl::Stop() {
725 DCHECK(decoder_); 725 DCHECK(decoder_);
726 // Clear pending decodes now. We don't want OnDecodeComplete to call DoDecode 726 // Clear pending decodes now. We don't want OnDecodeComplete to call DoDecode
727 // again. 727 // again.
728 while (!pending_decodes_.empty()) 728 while (!pending_decodes_.empty())
729 pending_decodes_.pop(); 729 pending_decodes_.pop();
730 decoder_.reset(); 730 decoder_.reset();
731 // This instance is deleted once we exit this scope. 731 // This instance is deleted once we exit this scope.
732 } 732 }
733 733
734 void VideoDecoderShim::DecoderImpl::OnPipelineStatus( 734 void VideoDecoderShim::DecoderImpl::OnInitDone(bool success) {
735 media::PipelineStatus status) { 735 int32_t result = success ? PP_OK : PP_ERROR_NOTSUPPORTED;
736 int32_t result;
737 switch (status) {
738 case media::PIPELINE_OK:
739 result = PP_OK;
740 break;
741 case media::DECODER_ERROR_NOT_SUPPORTED:
742 result = PP_ERROR_NOTSUPPORTED;
743 break;
744 default:
745 result = PP_ERROR_FAILED;
746 break;
747 }
748 736
749 // Calculate how many textures the shim should create. 737 // Calculate how many textures the shim should create.
750 uint32_t shim_texture_pool_size = media::limits::kMaxVideoFrames + 1; 738 uint32_t shim_texture_pool_size = media::limits::kMaxVideoFrames + 1;
751 main_task_runner_->PostTask( 739 main_task_runner_->PostTask(
752 FROM_HERE, base::Bind(&VideoDecoderShim::OnInitializeComplete, shim_, 740 FROM_HERE, base::Bind(&VideoDecoderShim::OnInitializeComplete, shim_,
753 result, shim_texture_pool_size)); 741 result, shim_texture_pool_size));
754 } 742 }
755 743
756 void VideoDecoderShim::DecoderImpl::DoDecode() { 744 void VideoDecoderShim::DecoderImpl::DoDecode() {
757 if (pending_decodes_.empty() || awaiting_decoder_) 745 if (pending_decodes_.empty() || awaiting_decoder_)
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { 1094 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) {
1107 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); 1095 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL();
1108 gles2->DeleteTextures(1, &texture_id); 1096 gles2->DeleteTextures(1, &texture_id);
1109 } 1097 }
1110 1098
1111 void VideoDecoderShim::FlushCommandBuffer() { 1099 void VideoDecoderShim::FlushCommandBuffer() {
1112 context_provider_->ContextGL()->Flush(); 1100 context_provider_->ContextGL()->Flush();
1113 } 1101 }
1114 1102
1115 } // namespace content 1103 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698