| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/plugins/ppapi/content_decryptor_delegate.h" | 5 #include "webkit/plugins/ppapi/content_decryptor_delegate.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "media/base/audio_decoder_config.h" | 10 #include "media/base/audio_decoder_config.h" |
| 11 #include "media/base/bind_to_loop.h" | 11 #include "media/base/bind_to_loop.h" |
| 12 #include "media/base/channel_layout.h" | 12 #include "media/base/channel_layout.h" |
| 13 #include "media/base/data_buffer.h" | 13 #include "media/base/data_buffer.h" |
| 14 #include "media/base/decoder_buffer.h" | 14 #include "media/base/decoder_buffer.h" |
| 15 #include "media/base/decryptor_client.h" | 15 #include "media/base/decryptor_client.h" |
| 16 #include "media/base/video_decoder_config.h" | 16 #include "media/base/video_decoder_config.h" |
| 17 #include "media/base/video_frame.h" | 17 #include "media/base/video_frame.h" |
| 18 #include "media/base/video_util.h" | 18 #include "media/base/video_util.h" |
| 19 #include "ppapi/shared_impl/var.h" | 19 #include "ppapi/shared_impl/var.h" |
| 20 #include "ppapi/shared_impl/var_tracker.h" | 20 #include "ppapi/shared_impl/var_tracker.h" |
| 21 #include "ppapi/thunk/enter.h" | 21 #include "ppapi/thunk/enter.h" |
| 22 #include "ppapi/thunk/ppb_buffer_api.h" | 22 #include "ppapi/thunk/ppb_buffer_api.h" |
| 23 #include "ui/gfx/rect.h" |
| 23 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" | 24 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" |
| 24 | 25 |
| 25 using ppapi::PpapiGlobals; | 26 using ppapi::PpapiGlobals; |
| 26 using ppapi::ScopedPPResource; | 27 using ppapi::ScopedPPResource; |
| 27 using ppapi::StringVar; | 28 using ppapi::StringVar; |
| 28 using ppapi::thunk::EnterResourceNoLock; | 29 using ppapi::thunk::EnterResourceNoLock; |
| 29 using ppapi::thunk::PPB_Buffer_API; | 30 using ppapi::thunk::PPB_Buffer_API; |
| 30 | 31 |
| 31 namespace webkit { | 32 namespace webkit { |
| 32 namespace ppapi { | 33 namespace ppapi { |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 decoder_config.extra_data_size(), | 469 decoder_config.extra_data_size(), |
| 469 &extra_data_resource)) { | 470 &extra_data_resource)) { |
| 470 return false; | 471 return false; |
| 471 } | 472 } |
| 472 | 473 |
| 473 DCHECK_EQ(pending_video_decoder_init_request_id_, 0u); | 474 DCHECK_EQ(pending_video_decoder_init_request_id_, 0u); |
| 474 DCHECK(pending_video_decoder_init_cb_.is_null()); | 475 DCHECK(pending_video_decoder_init_cb_.is_null()); |
| 475 pending_video_decoder_init_request_id_ = pp_decoder_config.request_id; | 476 pending_video_decoder_init_request_id_ = pp_decoder_config.request_id; |
| 476 pending_video_decoder_init_cb_ = init_cb; | 477 pending_video_decoder_init_cb_ = init_cb; |
| 477 | 478 |
| 479 natural_size_ = decoder_config.natural_size(); |
| 480 |
| 478 plugin_decryption_interface_->InitializeVideoDecoder(pp_instance_, | 481 plugin_decryption_interface_->InitializeVideoDecoder(pp_instance_, |
| 479 &pp_decoder_config, | 482 &pp_decoder_config, |
| 480 extra_data_resource); | 483 extra_data_resource); |
| 481 | 484 |
| 482 return true; | 485 return true; |
| 483 } | 486 } |
| 484 | 487 |
| 485 bool ContentDecryptorDelegate::DeinitializeDecoder( | 488 bool ContentDecryptorDelegate::DeinitializeDecoder( |
| 486 media::Decryptor::StreamType stream_type) { | 489 media::Decryptor::StreamType stream_type) { |
| 487 CancelDecode(stream_type); | 490 CancelDecode(stream_type); |
| 488 | 491 |
| 492 natural_size_ = gfx::Size(); |
| 493 |
| 489 // TODO(tomfinegan): Add decoder deinitialize request tracking, and get | 494 // TODO(tomfinegan): Add decoder deinitialize request tracking, and get |
| 490 // stream type from media stack. | 495 // stream type from media stack. |
| 491 plugin_decryption_interface_->DeinitializeDecoder( | 496 plugin_decryption_interface_->DeinitializeDecoder( |
| 492 pp_instance_, MediaDecryptorStreamTypeToPpStreamType(stream_type), 0); | 497 pp_instance_, MediaDecryptorStreamTypeToPpStreamType(stream_type), 0); |
| 493 return true; | 498 return true; |
| 494 } | 499 } |
| 495 | 500 |
| 496 bool ContentDecryptorDelegate::ResetDecoder( | 501 bool ContentDecryptorDelegate::ResetDecoder( |
| 497 media::Decryptor::StreamType stream_type) { | 502 media::Decryptor::StreamType stream_type) { |
| 498 CancelDecode(stream_type); | 503 CancelDecode(stream_type); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 | 700 |
| 696 DCHECK(!pending_audio_decoder_init_cb_.is_null()); | 701 DCHECK(!pending_audio_decoder_init_cb_.is_null()); |
| 697 pending_audio_decoder_init_request_id_ = 0; | 702 pending_audio_decoder_init_request_id_ = 0; |
| 698 base::ResetAndReturn( | 703 base::ResetAndReturn( |
| 699 &pending_audio_decoder_init_cb_).Run(PP_ToBool(success)); | 704 &pending_audio_decoder_init_cb_).Run(PP_ToBool(success)); |
| 700 } else { | 705 } else { |
| 701 if (request_id == 0 || | 706 if (request_id == 0 || |
| 702 request_id != pending_video_decoder_init_request_id_) | 707 request_id != pending_video_decoder_init_request_id_) |
| 703 return; | 708 return; |
| 704 | 709 |
| 710 if (!success) |
| 711 natural_size_ = gfx::Size(); |
| 712 |
| 705 DCHECK(!pending_video_decoder_init_cb_.is_null()); | 713 DCHECK(!pending_video_decoder_init_cb_.is_null()); |
| 706 pending_video_decoder_init_request_id_ = 0; | 714 pending_video_decoder_init_request_id_ = 0; |
| 707 base::ResetAndReturn( | 715 base::ResetAndReturn( |
| 708 &pending_video_decoder_init_cb_).Run(PP_ToBool(success)); | 716 &pending_video_decoder_init_cb_).Run(PP_ToBool(success)); |
| 709 } | 717 } |
| 710 } | 718 } |
| 711 | 719 |
| 712 void ContentDecryptorDelegate::DecoderDeinitializeDone( | 720 void ContentDecryptorDelegate::DecoderDeinitializeDone( |
| 713 PP_DecryptorStreamType decoder_type, | 721 PP_DecryptorStreamType decoder_type, |
| 714 uint32_t request_id) { | 722 uint32_t request_id) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 | 829 |
| 822 uint32_t mapped_size = 0; | 830 uint32_t mapped_size = 0; |
| 823 if (!ppb_buffer->Describe(&mapped_size) || !mapped_size) { | 831 if (!ppb_buffer->Describe(&mapped_size) || !mapped_size) { |
| 824 video_decode_cb.Run(media::Decryptor::kError, NULL); | 832 video_decode_cb.Run(media::Decryptor::kError, NULL); |
| 825 return; | 833 return; |
| 826 } | 834 } |
| 827 | 835 |
| 828 gfx::Size frame_size(frame_info->width, frame_info->height); | 836 gfx::Size frame_size(frame_info->width, frame_info->height); |
| 829 DCHECK_EQ(frame_info->format, PP_DECRYPTEDFRAMEFORMAT_YV12); | 837 DCHECK_EQ(frame_info->format, PP_DECRYPTEDFRAMEFORMAT_YV12); |
| 830 | 838 |
| 831 // TODO(xhwang): Support visible_rect and natural_size in EME video decoding | |
| 832 // implementations. | |
| 833 scoped_refptr<media::VideoFrame> decoded_frame = | 839 scoped_refptr<media::VideoFrame> decoded_frame = |
| 834 media::VideoFrame::WrapExternalYuvData( | 840 media::VideoFrame::WrapExternalYuvData( |
| 835 media::VideoFrame::YV12, | 841 media::VideoFrame::YV12, |
| 836 frame_size, gfx::Rect(frame_size), frame_size, | 842 frame_size, gfx::Rect(frame_size), natural_size_, |
| 837 frame_info->strides[PP_DECRYPTEDFRAMEPLANES_Y], | 843 frame_info->strides[PP_DECRYPTEDFRAMEPLANES_Y], |
| 838 frame_info->strides[PP_DECRYPTEDFRAMEPLANES_U], | 844 frame_info->strides[PP_DECRYPTEDFRAMEPLANES_U], |
| 839 frame_info->strides[PP_DECRYPTEDFRAMEPLANES_V], | 845 frame_info->strides[PP_DECRYPTEDFRAMEPLANES_V], |
| 840 frame_data + frame_info->plane_offsets[PP_DECRYPTEDFRAMEPLANES_Y], | 846 frame_data + frame_info->plane_offsets[PP_DECRYPTEDFRAMEPLANES_Y], |
| 841 frame_data + frame_info->plane_offsets[PP_DECRYPTEDFRAMEPLANES_U], | 847 frame_data + frame_info->plane_offsets[PP_DECRYPTEDFRAMEPLANES_U], |
| 842 frame_data + frame_info->plane_offsets[PP_DECRYPTEDFRAMEPLANES_V], | 848 frame_data + frame_info->plane_offsets[PP_DECRYPTEDFRAMEPLANES_V], |
| 843 base::TimeDelta::FromMicroseconds( | 849 base::TimeDelta::FromMicroseconds( |
| 844 frame_info->tracking_info.timestamp), | 850 frame_info->tracking_info.timestamp), |
| 845 media::BindToLoop(base::MessageLoopProxy::current(), | 851 media::BindToLoop(base::MessageLoopProxy::current(), |
| 846 base::Bind(&PPB_Buffer_Impl::Unmap, ppb_buffer))); | 852 base::Bind(&PPB_Buffer_Impl::Unmap, ppb_buffer))); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 return false; | 975 return false; |
| 970 } | 976 } |
| 971 memcpy(mapper.data(), data, size); | 977 memcpy(mapper.data(), data, size); |
| 972 | 978 |
| 973 *resource = media_resource; | 979 *resource = media_resource; |
| 974 return true; | 980 return true; |
| 975 } | 981 } |
| 976 | 982 |
| 977 } // namespace ppapi | 983 } // namespace ppapi |
| 978 } // namespace webkit | 984 } // namespace webkit |
| OLD | NEW |