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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" | 38 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" |
| 39 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 39 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
| 40 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 40 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| 41 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 41 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaSource.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaSource.h" |
| 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
| 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 45 #include "v8/include/v8.h" | 45 #include "v8/include/v8.h" |
| 46 #include "webkit/compositor_bindings/web_layer_impl.h" | 46 #include "webkit/compositor_bindings/web_layer_impl.h" |
| 47 #include "webkit/media/buffered_data_source.h" | 47 #include "webkit/media/buffered_data_source.h" |
| 48 #include "webkit/media/texttrack_impl.h" | |
| 48 #include "webkit/media/webaudiosourceprovider_impl.h" | 49 #include "webkit/media/webaudiosourceprovider_impl.h" |
| 50 #include "webkit/media/webinbandtexttrack_impl.h" | |
| 49 #include "webkit/media/webmediaplayer_delegate.h" | 51 #include "webkit/media/webmediaplayer_delegate.h" |
| 50 #include "webkit/media/webmediaplayer_params.h" | 52 #include "webkit/media/webmediaplayer_params.h" |
| 51 #include "webkit/media/webmediaplayer_util.h" | 53 #include "webkit/media/webmediaplayer_util.h" |
| 52 #include "webkit/media/webmediasourceclient_impl.h" | 54 #include "webkit/media/webmediasourceclient_impl.h" |
| 53 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" | 55 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" |
| 54 | 56 |
| 55 using WebKit::WebCanvas; | 57 using WebKit::WebCanvas; |
| 56 using WebKit::WebMediaPlayer; | 58 using WebKit::WebMediaPlayer; |
| 57 using WebKit::WebRect; | 59 using WebKit::WebRect; |
| 58 using WebKit::WebSize; | 60 using WebKit::WebSize; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 media_log_(params.media_log()), | 141 media_log_(params.media_log()), |
| 140 accelerated_compositing_reported_(false), | 142 accelerated_compositing_reported_(false), |
| 141 incremented_externally_allocated_memory_(false), | 143 incremented_externally_allocated_memory_(false), |
| 142 gpu_factories_(params.gpu_factories()), | 144 gpu_factories_(params.gpu_factories()), |
| 143 is_local_source_(false), | 145 is_local_source_(false), |
| 144 supports_save_(true), | 146 supports_save_(true), |
| 145 starting_(false), | 147 starting_(false), |
| 146 chunk_demuxer_(NULL), | 148 chunk_demuxer_(NULL), |
| 147 pending_repaint_(false), | 149 pending_repaint_(false), |
| 148 pending_size_change_(false), | 150 pending_size_change_(false), |
| 149 video_frame_provider_client_(NULL) { | 151 video_frame_provider_client_(NULL), |
| 152 text_track_index_(0) { | |
| 150 media_log_->AddEvent( | 153 media_log_->AddEvent( |
| 151 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 154 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
| 152 | 155 |
| 153 CHECK(media_thread_.Start()); | 156 CHECK(media_thread_.Start()); |
| 154 pipeline_.reset(new media::Pipeline( | 157 pipeline_.reset(new media::Pipeline( |
| 155 media_thread_.message_loop_proxy(), media_log_)); | 158 media_thread_.message_loop_proxy(), media_log_)); |
| 156 | 159 |
| 157 // Let V8 know we started new thread if we did not do it yet. | 160 // Let V8 know we started new thread if we did not do it yet. |
| 158 // Made separate task to avoid deletion of player currently being created. | 161 // Made separate task to avoid deletion of player currently being created. |
| 159 // Also, delaying GC until after player starts gets rid of starting lag -- | 162 // Also, delaying GC until after player starts gets rid of starting lag -- |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 982 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_); | 985 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_); |
| 983 if (init_data_type_.empty()) | 986 if (init_data_type_.empty()) |
| 984 init_data_type_ = type; | 987 init_data_type_ = type; |
| 985 | 988 |
| 986 GetClient()->keyNeeded(WebString::fromUTF8(key_system), | 989 GetClient()->keyNeeded(WebString::fromUTF8(key_system), |
| 987 WebString::fromUTF8(session_id), | 990 WebString::fromUTF8(session_id), |
| 988 init_data.get(), | 991 init_data.get(), |
| 989 init_data_size); | 992 init_data_size); |
| 990 } | 993 } |
| 991 | 994 |
| 995 scoped_ptr<media::TextTrack> | |
| 996 WebMediaPlayerImpl::OnTextTrack(media::TextKind kind, | |
| 997 const std::string& label, | |
| 998 const std::string& language) { | |
| 999 typedef WebInbandTextTrackImpl::Kind webkind_t; | |
| 1000 const webkind_t webkind = static_cast<webkind_t>(kind); | |
| 1001 const WebKit::WebString weblabel = WebKit::WebString::fromUTF8(label); | |
| 1002 const WebKit::WebString weblanguage = WebKit::WebString::fromUTF8(language); | |
| 1003 | |
| 1004 // TODO(matthewjheaney): resolve lifetime issues for text_track_. | |
| 1005 // Note that the text track object is adopted by its client, and so | |
| 1006 // it does get destroyed during teardown of the tracks, and | |
| 1007 // therefore there's no memory leak. However, there is the issue of | |
| 1008 // lifetime, since we share a pointer to this text track object with | |
| 1009 // its (owning) client. | |
|
acolwell GONE FROM CHROMIUM
2013/05/15 22:42:36
This needs to be resolved before the final l g t m
Matthew Heaney (Chromium)
2013/05/16 22:05:22
Done.
| |
| 1010 | |
| 1011 WebInbandTextTrackImpl* const text_track = | |
| 1012 new WebInbandTextTrackImpl(webkind, weblabel, weblanguage, | |
| 1013 text_track_index_++); | |
| 1014 GetClient()->addTextTrack(text_track); | |
| 1015 | |
| 1016 // TODO(matthewjheaney): give text_cb ownership of text_track. | |
| 1017 // This means webkit will not adopt text_track. | |
|
acolwell GONE FROM CHROMIUM
2013/05/15 22:42:36
ditto
Matthew Heaney (Chromium)
2013/05/16 22:05:22
Done.
| |
| 1018 return scoped_ptr<media::TextTrack>(new TextTrackImpl(text_track->client())); | |
| 1019 } | |
| 1020 | |
| 992 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ | 1021 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
| 993 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \ | 1022 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \ |
| 994 static_cast<int>(media::Decryptor::k ## name), \ | 1023 static_cast<int>(media::Decryptor::k ## name), \ |
| 995 mismatching_enums) | 1024 mismatching_enums) |
| 996 COMPILE_ASSERT_MATCHING_ENUM(UnknownError); | 1025 COMPILE_ASSERT_MATCHING_ENUM(UnknownError); |
| 997 COMPILE_ASSERT_MATCHING_ENUM(ClientError); | 1026 COMPILE_ASSERT_MATCHING_ENUM(ClientError); |
| 998 COMPILE_ASSERT_MATCHING_ENUM(ServiceError); | 1027 COMPILE_ASSERT_MATCHING_ENUM(ServiceError); |
| 999 COMPILE_ASSERT_MATCHING_ENUM(OutputError); | 1028 COMPILE_ASSERT_MATCHING_ENUM(OutputError); |
| 1000 COMPILE_ASSERT_MATCHING_ENUM(HardwareChangeError); | 1029 COMPILE_ASSERT_MATCHING_ENUM(HardwareChangeError); |
| 1001 COMPILE_ASSERT_MATCHING_ENUM(DomainError); | 1030 COMPILE_ASSERT_MATCHING_ENUM(DomainError); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1077 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""))); | 1106 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""))); |
| 1078 } else { | 1107 } else { |
| 1079 DCHECK(!chunk_demuxer_); | 1108 DCHECK(!chunk_demuxer_); |
| 1080 DCHECK(!data_source_); | 1109 DCHECK(!data_source_); |
| 1081 | 1110 |
| 1082 scoped_ptr<WebKit::WebMediaSource> ms(media_source); | 1111 scoped_ptr<WebKit::WebMediaSource> ms(media_source); |
| 1083 chunk_demuxer_ = new media::ChunkDemuxer( | 1112 chunk_demuxer_ = new media::ChunkDemuxer( |
| 1084 BIND_TO_RENDER_LOOP_1(&WebMediaPlayerImpl::OnDemuxerOpened, | 1113 BIND_TO_RENDER_LOOP_1(&WebMediaPlayerImpl::OnDemuxerOpened, |
| 1085 base::Passed(&ms)), | 1114 base::Passed(&ms)), |
| 1086 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""), | 1115 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""), |
| 1116 base::Bind(&WebMediaPlayerImpl::OnTextTrack, base::Unretained(this)), | |
| 1087 base::Bind(&LogMediaSourceError, media_log_)); | 1117 base::Bind(&LogMediaSourceError, media_log_)); |
| 1088 demuxer_.reset(chunk_demuxer_); | 1118 demuxer_.reset(chunk_demuxer_); |
| 1089 | 1119 |
| 1090 // Disable GpuVideoDecoder creation until it supports codec config changes. | 1120 // Disable GpuVideoDecoder creation until it supports codec config changes. |
| 1091 // TODO(acolwell): Remove this once http://crbug.com/151045 is fixed. | 1121 // TODO(acolwell): Remove this once http://crbug.com/151045 is fixed. |
| 1092 gpu_factories_ = NULL; | 1122 gpu_factories_ = NULL; |
| 1093 } | 1123 } |
| 1094 | 1124 |
| 1095 scoped_ptr<media::FilterCollection> filter_collection( | 1125 scoped_ptr<media::FilterCollection> filter_collection( |
| 1096 new media::FilterCollection()); | 1126 new media::FilterCollection()); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1268 | 1298 |
| 1269 if (pending_repaint_) | 1299 if (pending_repaint_) |
| 1270 return; | 1300 return; |
| 1271 | 1301 |
| 1272 pending_repaint_ = true; | 1302 pending_repaint_ = true; |
| 1273 main_loop_->PostTask(FROM_HERE, base::Bind( | 1303 main_loop_->PostTask(FROM_HERE, base::Bind( |
| 1274 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); | 1304 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); |
| 1275 } | 1305 } |
| 1276 | 1306 |
| 1277 } // namespace webkit_media | 1307 } // namespace webkit_media |
| OLD | NEW |