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 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... | |
30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
33 #include "v8/include/v8.h" | 33 #include "v8/include/v8.h" |
34 #include "webkit/media/buffered_data_source.h" | 34 #include "webkit/media/buffered_data_source.h" |
35 #include "webkit/media/filter_helpers.h" | 35 #include "webkit/media/filter_helpers.h" |
36 #include "webkit/media/webmediaplayer_delegate.h" | 36 #include "webkit/media/webmediaplayer_delegate.h" |
37 #include "webkit/media/webmediaplayer_proxy.h" | 37 #include "webkit/media/webmediaplayer_proxy.h" |
38 #include "webkit/media/webmediaplayer_util.h" | 38 #include "webkit/media/webmediaplayer_util.h" |
39 #include "webkit/media/webvideoframe_impl.h" | 39 #include "webkit/media/webvideoframe_impl.h" |
40 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" | |
40 | 41 |
41 using WebKit::WebCanvas; | 42 using WebKit::WebCanvas; |
42 using WebKit::WebMediaPlayer; | 43 using WebKit::WebMediaPlayer; |
43 using WebKit::WebRect; | 44 using WebKit::WebRect; |
44 using WebKit::WebSize; | 45 using WebKit::WebSize; |
45 using WebKit::WebString; | 46 using WebKit::WebString; |
46 using media::PipelineStatus; | 47 using media::PipelineStatus; |
47 | 48 |
48 namespace { | 49 namespace { |
49 | 50 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 pending_seek_seconds_(0.0f), | 123 pending_seek_seconds_(0.0f), |
123 client_(client), | 124 client_(client), |
124 proxy_(new WebMediaPlayerProxy(main_loop_->message_loop_proxy(), this)), | 125 proxy_(new WebMediaPlayerProxy(main_loop_->message_loop_proxy(), this)), |
125 delegate_(delegate), | 126 delegate_(delegate), |
126 media_stream_client_(media_stream_client), | 127 media_stream_client_(media_stream_client), |
127 media_log_(media_log), | 128 media_log_(media_log), |
128 accelerated_compositing_reported_(false), | 129 accelerated_compositing_reported_(false), |
129 incremented_externally_allocated_memory_(false), | 130 incremented_externally_allocated_memory_(false), |
130 audio_source_provider_(audio_source_provider), | 131 audio_source_provider_(audio_source_provider), |
131 is_local_source_(false), | 132 is_local_source_(false), |
132 decryptor_(proxy_.get()) { | 133 decryptor_(proxy_.get(), |
134 base::Bind(&WebMediaPlayerImpl::CreatePluginInstance, | |
135 base::Unretained(this))) { | |
xhwang
2012/07/17 00:57:23
This "Unretained" is ugly but should work. The cal
| |
133 media_log_->AddEvent( | 136 media_log_->AddEvent( |
134 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 137 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
135 | 138 |
136 MessageLoop* pipeline_message_loop = | 139 MessageLoop* pipeline_message_loop = |
137 message_loop_factory_->GetMessageLoop("PipelineThread"); | 140 message_loop_factory_->GetMessageLoop("PipelineThread"); |
138 pipeline_ = new media::Pipeline(pipeline_message_loop, media_log_); | 141 pipeline_ = new media::Pipeline(pipeline_message_loop, media_log_); |
139 | 142 |
140 // Let V8 know we started new thread if we did not did it yet. | 143 // Let V8 know we started new thread if we did not did it yet. |
141 // Made separate task to avoid deletion of player currently being created. | 144 // Made separate task to avoid deletion of player currently being created. |
142 // Also, delaying GC until after player starts gets rid of starting lag -- | 145 // Also, delaying GC until after player starts gets rid of starting lag -- |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1036 proxy_ = NULL; | 1039 proxy_ = NULL; |
1037 } | 1040 } |
1038 } | 1041 } |
1039 | 1042 |
1040 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 1043 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
1041 DCHECK_EQ(main_loop_, MessageLoop::current()); | 1044 DCHECK_EQ(main_loop_, MessageLoop::current()); |
1042 DCHECK(client_); | 1045 DCHECK(client_); |
1043 return client_; | 1046 return client_; |
1044 } | 1047 } |
1045 | 1048 |
1049 scoped_refptr<webkit::ppapi::PluginInstance> | |
1050 WebMediaPlayerImpl::CreatePluginInstance(const std::string& plugin_type) { | |
xhwang
2012/07/17 00:57:23
We can replace this function with something like
ddorwin
2012/07/17 21:31:28
If we replaced it, where would the checks and cast
xhwang
2012/07/18 19:43:17
All of these are done in PpapiDecryptor::Init() no
| |
1051 WebKit::WebPlugin* plugin = GetClient()->createHelperPlugin( | |
1052 WebString::fromUTF8(plugin_type), frame_); | |
1053 DCHECK(!plugin->isPlaceholder()); // Prevented by WebKit. | |
1054 // Only Pepper plugins are supported, so it must be a ppapi object. | |
1055 webkit::ppapi::WebPluginImpl* ppapi_plugin = | |
1056 static_cast<webkit::ppapi::WebPluginImpl*>(plugin); | |
1057 return scoped_refptr<webkit::ppapi::PluginInstance>(ppapi_plugin->instance()); | |
1058 } | |
1059 | |
1046 WebKit::WebAudioSourceProvider* WebMediaPlayerImpl::audioSourceProvider() { | 1060 WebKit::WebAudioSourceProvider* WebMediaPlayerImpl::audioSourceProvider() { |
1047 return audio_source_provider_; | 1061 return audio_source_provider_; |
1048 } | 1062 } |
1049 | 1063 |
1050 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 1064 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
1051 DCHECK_EQ(main_loop_, MessageLoop::current()); | 1065 DCHECK_EQ(main_loop_, MessageLoop::current()); |
1052 incremented_externally_allocated_memory_ = true; | 1066 incremented_externally_allocated_memory_ = true; |
1053 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 1067 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
1054 } | 1068 } |
1055 | 1069 |
1056 } // namespace webkit_media | 1070 } // namespace webkit_media |
OLD | NEW |