| 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 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 // No more callbacks from the delegate will be received now. | 861 // No more callbacks from the delegate will be received now. |
| 862 | 862 |
| 863 // The callback now holds the only reference to the DecoderImpl, which will be | 863 // The callback now holds the only reference to the DecoderImpl, which will be |
| 864 // deleted when Stop completes. | 864 // deleted when Stop completes. |
| 865 media_task_runner_->PostTask( | 865 media_task_runner_->PostTask( |
| 866 FROM_HERE, | 866 FROM_HERE, |
| 867 base::Bind(&VideoDecoderShim::DecoderImpl::Stop, | 867 base::Bind(&VideoDecoderShim::DecoderImpl::Stop, |
| 868 base::Owned(decoder_impl_.release()))); | 868 base::Owned(decoder_impl_.release()))); |
| 869 } | 869 } |
| 870 | 870 |
| 871 bool VideoDecoderShim::Initialize( | 871 bool VideoDecoderShim::Initialize(const Config& vda_config, Client* client) { |
| 872 media::VideoCodecProfile profile, | |
| 873 media::VideoDecodeAccelerator::Client* client) { | |
| 874 DCHECK_EQ(client, host_); | 872 DCHECK_EQ(client, host_); |
| 875 DCHECK(RenderThreadImpl::current()); | 873 DCHECK(RenderThreadImpl::current()); |
| 876 DCHECK_EQ(state_, UNINITIALIZED); | 874 DCHECK_EQ(state_, UNINITIALIZED); |
| 875 |
| 876 if (vda_config.is_encrypted) { |
| 877 NOTREACHED() << "Encrypted streams are not supported"; |
| 878 return false; |
| 879 } |
| 880 |
| 877 media::VideoCodec codec = media::kUnknownVideoCodec; | 881 media::VideoCodec codec = media::kUnknownVideoCodec; |
| 878 if (profile <= media::H264PROFILE_MAX) | 882 if (vda_config.profile <= media::H264PROFILE_MAX) |
| 879 codec = media::kCodecH264; | 883 codec = media::kCodecH264; |
| 880 else if (profile <= media::VP8PROFILE_MAX) | 884 else if (vda_config.profile <= media::VP8PROFILE_MAX) |
| 881 codec = media::kCodecVP8; | 885 codec = media::kCodecVP8; |
| 882 else if (profile <= media::VP9PROFILE_MAX) | 886 else if (vda_config.profile <= media::VP9PROFILE_MAX) |
| 883 codec = media::kCodecVP9; | 887 codec = media::kCodecVP9; |
| 884 DCHECK_NE(codec, media::kUnknownVideoCodec); | 888 DCHECK_NE(codec, media::kUnknownVideoCodec); |
| 885 | 889 |
| 886 if (!IsCodecSupported(codec)) | 890 if (!IsCodecSupported(codec)) |
| 887 return false; | 891 return false; |
| 888 | 892 |
| 889 if (!yuv_converter_->Initialize()) | 893 if (!yuv_converter_->Initialize()) |
| 890 return false; | 894 return false; |
| 891 | 895 |
| 892 media::VideoDecoderConfig config( | 896 media::VideoDecoderConfig video_decoder_config( |
| 893 codec, profile, media::PIXEL_FORMAT_YV12, media::COLOR_SPACE_UNSPECIFIED, | 897 codec, vda_config.profile, media::PIXEL_FORMAT_YV12, |
| 898 media::COLOR_SPACE_UNSPECIFIED, |
| 894 gfx::Size(32, 24), // Small sizes that won't fail. | 899 gfx::Size(32, 24), // Small sizes that won't fail. |
| 895 gfx::Rect(32, 24), gfx::Size(32, 24), | 900 gfx::Rect(32, 24), gfx::Size(32, 24), |
| 896 // TODO(bbudge): Verify extra data isn't needed. | 901 // TODO(bbudge): Verify extra data isn't needed. |
| 897 media::EmptyExtraData(), false /* decryption */); | 902 media::EmptyExtraData(), false /* decryption */); |
| 898 | 903 |
| 899 media_task_runner_->PostTask( | 904 media_task_runner_->PostTask( |
| 900 FROM_HERE, | 905 FROM_HERE, |
| 901 base::Bind(&VideoDecoderShim::DecoderImpl::Initialize, | 906 base::Bind(&VideoDecoderShim::DecoderImpl::Initialize, |
| 902 base::Unretained(decoder_impl_.get()), | 907 base::Unretained(decoder_impl_.get()), video_decoder_config)); |
| 903 config)); | |
| 904 | 908 |
| 905 state_ = DECODING; | 909 state_ = DECODING; |
| 906 | 910 |
| 907 // Return success, even though we are asynchronous, to mimic | 911 // Return success, even though we are asynchronous, to mimic |
| 908 // media::VideoDecodeAccelerator. | 912 // media::VideoDecodeAccelerator. |
| 909 return true; | 913 return true; |
| 910 } | 914 } |
| 911 | 915 |
| 912 void VideoDecoderShim::Decode(const media::BitstreamBuffer& bitstream_buffer) { | 916 void VideoDecoderShim::Decode(const media::BitstreamBuffer& bitstream_buffer) { |
| 913 DCHECK(RenderThreadImpl::current()); | 917 DCHECK(RenderThreadImpl::current()); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { | 1120 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { |
| 1117 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 1121 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
| 1118 gles2->DeleteTextures(1, &texture_id); | 1122 gles2->DeleteTextures(1, &texture_id); |
| 1119 } | 1123 } |
| 1120 | 1124 |
| 1121 void VideoDecoderShim::FlushCommandBuffer() { | 1125 void VideoDecoderShim::FlushCommandBuffer() { |
| 1122 context_provider_->ContextGL()->Flush(); | 1126 context_provider_->ContextGL()->Flush(); |
| 1123 } | 1127 } |
| 1124 | 1128 |
| 1125 } // namespace content | 1129 } // namespace content |
| OLD | NEW |