Chromium Code Reviews| 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/media/webmediaplayer_impl.h" | 5 #include "webkit/media/webmediaplayer_impl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/message_loop_proxy.h" | 13 #include "base/message_loop_proxy.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/string_number_conversions.h" | |
| 15 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 16 #include "media/audio/null_audio_sink.h" | 17 #include "media/audio/null_audio_sink.h" |
| 17 #include "media/base/filter_collection.h" | 18 #include "media/base/filter_collection.h" |
| 18 #include "media/base/limits.h" | 19 #include "media/base/limits.h" |
| 19 #include "media/base/media_log.h" | 20 #include "media/base/media_log.h" |
| 20 #include "media/base/media_switches.h" | 21 #include "media/base/media_switches.h" |
| 21 #include "media/base/pipeline.h" | 22 #include "media/base/pipeline.h" |
| 22 #include "media/base/video_frame.h" | 23 #include "media/base/video_frame.h" |
| 23 #include "media/filters/audio_renderer_impl.h" | 24 #include "media/filters/audio_renderer_impl.h" |
| 24 #include "media/filters/video_renderer_base.h" | 25 #include "media/filters/video_renderer_base.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
| 30 #include "v8/include/v8.h" | 32 #include "v8/include/v8.h" |
| 31 #include "webkit/media/buffered_data_source.h" | 33 #include "webkit/media/buffered_data_source.h" |
| 32 #include "webkit/media/filter_helpers.h" | 34 #include "webkit/media/filter_helpers.h" |
| 35 #include "webkit/media/mime_util.h" | |
| 33 #include "webkit/media/webmediaplayer_delegate.h" | 36 #include "webkit/media/webmediaplayer_delegate.h" |
| 34 #include "webkit/media/webmediaplayer_proxy.h" | 37 #include "webkit/media/webmediaplayer_proxy.h" |
| 35 #include "webkit/media/webvideoframe_impl.h" | 38 #include "webkit/media/webvideoframe_impl.h" |
| 36 | 39 |
| 37 using WebKit::WebCanvas; | 40 using WebKit::WebCanvas; |
| 38 using WebKit::WebRect; | 41 using WebKit::WebRect; |
| 39 using WebKit::WebSize; | 42 using WebKit::WebSize; |
| 40 using media::NetworkEvent; | 43 using media::NetworkEvent; |
| 41 using media::PipelineStatus; | 44 using media::PipelineStatus; |
| 42 | 45 |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 661 case WebKit::WebMediaPlayer::EosDecodeError: | 664 case WebKit::WebMediaPlayer::EosDecodeError: |
| 662 pipeline_status = media::PIPELINE_ERROR_DECODE; | 665 pipeline_status = media::PIPELINE_ERROR_DECODE; |
| 663 break; | 666 break; |
| 664 default: | 667 default: |
| 665 NOTIMPLEMENTED(); | 668 NOTIMPLEMENTED(); |
| 666 } | 669 } |
| 667 | 670 |
| 668 proxy_->DemuxerEndOfStream(pipeline_status); | 671 proxy_->DemuxerEndOfStream(pipeline_status); |
| 669 } | 672 } |
| 670 | 673 |
| 674 WebKit::WebMediaPlayer::MediaKeyException | |
| 675 WebMediaPlayerImpl::generateKeyRequest(const WebKit::WebString& key_system, | |
| 676 const unsigned char* init_data, | |
| 677 unsigned init_data_length) { | |
| 678 if (!mime_util::isKeySystemSupported(key_system)) | |
| 679 return WebKit::WebMediaPlayer::KeySystemNotSupported; | |
| 680 | |
| 681 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | |
| 682 &WebMediaPlayerImpl::generateKeyRequestTask, | |
|
scherkus (not reviewing)
2012/04/13 02:43:59
this (and rest of args) should be indented 4 space
ddorwin
2012/04/13 21:48:49
Done.
I misinterpreted your preferred style commen
| |
| 683 AsWeakPtr(), | |
| 684 key_system, | |
| 685 init_data, | |
| 686 init_data_length)); | |
| 687 | |
| 688 return WebKit::WebMediaPlayer::NoError; | |
| 689 } | |
| 690 | |
| 691 WebKit::WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::addKey( | |
| 692 const WebKit::WebString& key_system, | |
| 693 const unsigned char* key, | |
| 694 unsigned key_length, | |
| 695 const unsigned char* init_data, | |
| 696 unsigned init_data_length, | |
| 697 const WebKit::WebString& session_id) { | |
| 698 if (!mime_util::isKeySystemSupported(key_system)) | |
| 699 return WebKit::WebMediaPlayer::KeySystemNotSupported; | |
| 700 | |
| 701 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | |
| 702 &WebMediaPlayerImpl::addKeyTask, | |
| 703 AsWeakPtr(), | |
| 704 key_system, | |
| 705 key, | |
| 706 key_length, | |
| 707 init_data, | |
| 708 init_data_length, | |
| 709 session_id)); | |
| 710 | |
| 711 return WebKit::WebMediaPlayer::NoError; | |
| 712 } | |
| 713 | |
| 714 WebKit::WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::cancelKeyRequest( | |
| 715 const WebKit::WebString& key_system, | |
| 716 const WebKit::WebString& session_id) { | |
| 717 if (!mime_util::isKeySystemSupported(key_system)) | |
| 718 return WebKit::WebMediaPlayer::KeySystemNotSupported; | |
| 719 | |
| 720 // TODO(ddorwin): Cancel the key request in the decrypter. | |
| 721 | |
| 722 return WebKit::WebMediaPlayer::NoError; | |
| 723 } | |
| 724 | |
| 671 void WebMediaPlayerImpl::WillDestroyCurrentMessageLoop() { | 725 void WebMediaPlayerImpl::WillDestroyCurrentMessageLoop() { |
| 672 Destroy(); | 726 Destroy(); |
| 673 main_loop_ = NULL; | 727 main_loop_ = NULL; |
| 674 } | 728 } |
| 675 | 729 |
| 676 void WebMediaPlayerImpl::Repaint() { | 730 void WebMediaPlayerImpl::Repaint() { |
| 677 DCHECK_EQ(main_loop_, MessageLoop::current()); | 731 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 678 GetClient()->repaint(); | 732 GetClient()->repaint(); |
| 679 } | 733 } |
| 680 | 734 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 913 WebKit::WebAudioSourceProvider* WebMediaPlayerImpl::audioSourceProvider() { | 967 WebKit::WebAudioSourceProvider* WebMediaPlayerImpl::audioSourceProvider() { |
| 914 return audio_source_provider_; | 968 return audio_source_provider_; |
| 915 } | 969 } |
| 916 | 970 |
| 917 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 971 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
| 918 DCHECK_EQ(main_loop_, MessageLoop::current()); | 972 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 919 incremented_externally_allocated_memory_ = true; | 973 incremented_externally_allocated_memory_ = true; |
| 920 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 974 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
| 921 } | 975 } |
| 922 | 976 |
| 977 void WebMediaPlayerImpl::generateKeyRequestTask( | |
|
scherkus (not reviewing)
2012/04/13 02:43:59
per email discussion just nuke these tasks for now
ddorwin
2012/04/13 21:48:49
Done.
| |
| 978 const WebKit::WebString& key_system, | |
| 979 const unsigned char* init_data, | |
| 980 unsigned init_data_length) { | |
| 981 // Every request call creates a unique ID. | |
| 982 // TODO(ddorwin): Move this to the CDM implementations since the CDMs may | |
| 983 // create their own IDs and since CDMs supporting multiple renderer processes | |
|
scherkus (not reviewing)
2012/04/13 02:43:59
I do have to say this is one area that makes me th
ddorwin
2012/04/13 21:48:49
Filing a bug on this is on my task list (also affe
ddorwin
2012/04/13 22:29:03
Filed: https://www.w3.org/Bugs/Public/show_bug.cgi
| |
| 984 // need globally unique IDs. | |
| 985 static uint32_t next_available_session_id = 1; | |
| 986 uint32_t session_id = next_available_session_id++; | |
| 987 | |
| 988 WebKit::WebString sessionIdString(base::UintToString16(session_id)); | |
| 989 | |
| 990 DVLOG(1) << "generateKeyRequest: " << key_system.utf8().data() << ": " | |
| 991 << std::string(reinterpret_cast<const char*>(init_data), | |
| 992 static_cast<size_t>(init_data_length)) | |
| 993 << " [" << sessionIdString.utf8().data() << "]"; | |
| 994 | |
| 995 // TODO(ddorwin): Generate a key request in the decrypter and fire | |
| 996 // keyMessage when it completes. | |
| 997 // For now, just fire the event with the init_data as the request. | |
| 998 const unsigned char* message = init_data; | |
| 999 unsigned messageLength = init_data_length; | |
| 1000 | |
| 1001 GetClient()->keyMessage(key_system, sessionIdString, message, messageLength); | |
| 1002 } | |
| 1003 | |
| 1004 void WebMediaPlayerImpl::addKeyTask(const WebKit::WebString& key_system, | |
| 1005 const unsigned char* key, | |
| 1006 unsigned key_length, | |
| 1007 const unsigned char* init_data, | |
| 1008 unsigned init_data_length, | |
| 1009 const WebKit::WebString& session_id) { | |
| 1010 DVLOG(1) << "addKey: " << key_system.utf8().data() << ": " | |
| 1011 << std::string(reinterpret_cast<const char*>(key), | |
| 1012 static_cast<size_t>(key_length)) << ", " | |
| 1013 << std::string(reinterpret_cast<const char*>(init_data), | |
| 1014 static_cast<size_t>(init_data_length)) | |
| 1015 << " [" << session_id.utf8().data() << "]"; | |
| 1016 | |
| 1017 // TODO(ddorwin): Add the key to the decrypter and fire keyAdded when it | |
| 1018 // completes. Check the key length there. | |
| 1019 // Temporarily, fire an error for invalid key length so we can test the error | |
| 1020 // event and fire the keyAdded event in all other cases. | |
| 1021 const int kSupportedKeyLength = 16; // 128-bit key. | |
| 1022 if (key_length != kSupportedKeyLength) { | |
| 1023 DLOG(ERROR) << "invalid key length: " << key_length; | |
| 1024 GetClient()->keyError(key_system, session_id, | |
| 1025 WebKit::WebMediaPlayerClient::UnknownError, 0); | |
| 1026 return; | |
| 1027 } | |
| 1028 | |
| 1029 GetClient()->keyAdded(key_system, session_id); | |
| 1030 } | |
| 1031 | |
| 923 } // namespace webkit_media | 1032 } // namespace webkit_media |
| OLD | NEW |