OLD | NEW |
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 if (config.codec() == media::kCodecVP9) { | 128 if (config.codec() == media::kCodecVP9) { |
129 decoder_.reset( | 129 decoder_.reset( |
130 new media::VpxVideoDecoder(base::MessageLoopProxy::current())); | 130 new media::VpxVideoDecoder(base::MessageLoopProxy::current())); |
131 } else { | 131 } else { |
132 scoped_ptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder( | 132 scoped_ptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder( |
133 new media::FFmpegVideoDecoder(base::MessageLoopProxy::current())); | 133 new media::FFmpegVideoDecoder(base::MessageLoopProxy::current())); |
134 ffmpeg_video_decoder->set_decode_nalus(true); | 134 ffmpeg_video_decoder->set_decode_nalus(true); |
135 decoder_ = ffmpeg_video_decoder.Pass(); | 135 decoder_ = ffmpeg_video_decoder.Pass(); |
136 } | 136 } |
137 max_decodes_at_decoder_ = decoder_->GetMaxDecodeRequests(); | 137 max_decodes_at_decoder_ = decoder_->GetMaxDecodeRequests(); |
138 // We can use base::Unretained() safely in decoder callbacks because we call | 138 // We can use base::Unretained() safely in decoder callbacks because |
139 // VideoDecoder::Stop() before deletion. Stop() guarantees there will be no | 139 // |decoder_| is owned by DecoderImpl. During Stop(), the |decoder_| will be |
140 // outstanding callbacks after it returns. | 140 // destroyed and all outstanding callbacks will be fired. |
141 decoder_->Initialize( | 141 decoder_->Initialize( |
142 config, | 142 config, |
143 true /* low_delay */, | 143 true /* low_delay */, |
144 base::Bind(&VideoDecoderShim::DecoderImpl::OnPipelineStatus, | 144 base::Bind(&VideoDecoderShim::DecoderImpl::OnPipelineStatus, |
145 base::Unretained(this)), | 145 base::Unretained(this)), |
146 base::Bind(&VideoDecoderShim::DecoderImpl::OnOutputComplete, | 146 base::Bind(&VideoDecoderShim::DecoderImpl::OnOutputComplete, |
147 base::Unretained(this))); | 147 base::Unretained(this))); |
148 } | 148 } |
149 | 149 |
150 void VideoDecoderShim::DecoderImpl::Decode( | 150 void VideoDecoderShim::DecoderImpl::Decode( |
(...skipping 20 matching lines...) Expand all Loading... |
171 decoder_->Reset(base::Bind(&VideoDecoderShim::DecoderImpl::OnResetComplete, | 171 decoder_->Reset(base::Bind(&VideoDecoderShim::DecoderImpl::OnResetComplete, |
172 base::Unretained(this))); | 172 base::Unretained(this))); |
173 } | 173 } |
174 | 174 |
175 void VideoDecoderShim::DecoderImpl::Stop() { | 175 void VideoDecoderShim::DecoderImpl::Stop() { |
176 DCHECK(decoder_); | 176 DCHECK(decoder_); |
177 // Clear pending decodes now. We don't want OnDecodeComplete to call DoDecode | 177 // Clear pending decodes now. We don't want OnDecodeComplete to call DoDecode |
178 // again. | 178 // again. |
179 while (!pending_decodes_.empty()) | 179 while (!pending_decodes_.empty()) |
180 pending_decodes_.pop(); | 180 pending_decodes_.pop(); |
181 decoder_->Stop(); | 181 decoder_.reset(); |
182 // This instance is deleted once we exit this scope. | 182 // This instance is deleted once we exit this scope. |
183 } | 183 } |
184 | 184 |
185 void VideoDecoderShim::DecoderImpl::OnPipelineStatus( | 185 void VideoDecoderShim::DecoderImpl::OnPipelineStatus( |
186 media::PipelineStatus status) { | 186 media::PipelineStatus status) { |
187 int32_t result; | 187 int32_t result; |
188 switch (status) { | 188 switch (status) { |
189 case media::PIPELINE_OK: | 189 case media::PIPELINE_OK: |
190 result = PP_OK; | 190 result = PP_OK; |
191 break; | 191 break; |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { | 586 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { |
587 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 587 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
588 gles2->DeleteTextures(1, &texture_id); | 588 gles2->DeleteTextures(1, &texture_id); |
589 } | 589 } |
590 | 590 |
591 void VideoDecoderShim::FlushCommandBuffer() { | 591 void VideoDecoderShim::FlushCommandBuffer() { |
592 context_provider_->ContextGL()->Flush(); | 592 context_provider_->ContextGL()->Flush(); |
593 } | 593 } |
594 | 594 |
595 } // namespace content | 595 } // namespace content |
OLD | NEW |