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 13 matching lines...) Expand all Loading... | |
| 24 #include "media/base/media_log.h" | 24 #include "media/base/media_log.h" |
| 25 #include "media/base/pipeline.h" | 25 #include "media/base/pipeline.h" |
| 26 #include "media/base/video_frame.h" | 26 #include "media/base/video_frame.h" |
| 27 #include "media/filters/audio_renderer_impl.h" | 27 #include "media/filters/audio_renderer_impl.h" |
| 28 #include "media/filters/chunk_demuxer.h" | 28 #include "media/filters/chunk_demuxer.h" |
| 29 #include "media/filters/video_renderer_base.h" | 29 #include "media/filters/video_renderer_base.h" |
| 30 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" | 30 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" |
| 31 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 31 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
| 32 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 32 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| 33 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 33 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInbandTextTrackCli ent.h" | |
| 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaSource.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaSource.h" |
| 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
| 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 37 #include "v8/include/v8.h" | 38 #include "v8/include/v8.h" |
| 38 #include "webkit/compositor_bindings/web_layer_impl.h" | 39 #include "webkit/compositor_bindings/web_layer_impl.h" |
| 39 #include "webkit/media/buffered_data_source.h" | 40 #include "webkit/media/buffered_data_source.h" |
| 40 #include "webkit/media/filter_helpers.h" | 41 #include "webkit/media/filter_helpers.h" |
| 41 #include "webkit/media/webaudiosourceprovider_impl.h" | 42 #include "webkit/media/webaudiosourceprovider_impl.h" |
| 43 #include "webkit/media/webinbandtexttrack_impl.h" | |
| 42 #include "webkit/media/webmediaplayer_delegate.h" | 44 #include "webkit/media/webmediaplayer_delegate.h" |
| 43 #include "webkit/media/webmediaplayer_params.h" | 45 #include "webkit/media/webmediaplayer_params.h" |
| 44 #include "webkit/media/webmediaplayer_util.h" | 46 #include "webkit/media/webmediaplayer_util.h" |
| 45 #include "webkit/media/webmediasourceclient_impl.h" | 47 #include "webkit/media/webmediasourceclient_impl.h" |
| 46 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" | 48 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" |
| 47 | 49 |
| 48 using WebKit::WebCanvas; | 50 using WebKit::WebCanvas; |
| 49 using WebKit::WebMediaPlayer; | 51 using WebKit::WebMediaPlayer; |
| 50 using WebKit::WebRect; | 52 using WebKit::WebRect; |
| 51 using WebKit::WebSize; | 53 using WebKit::WebSize; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 WebKit::WebMediaSource* media_source, | 301 WebKit::WebMediaSource* media_source, |
| 300 CORSMode cors_mode) { | 302 CORSMode cors_mode) { |
| 301 scoped_ptr<WebKit::WebMediaSource> ms(media_source); | 303 scoped_ptr<WebKit::WebMediaSource> ms(media_source); |
| 302 LoadSetup(url); | 304 LoadSetup(url); |
| 303 | 305 |
| 304 // Media source pipelines can start immediately. | 306 // Media source pipelines can start immediately. |
| 305 chunk_demuxer_ = new media::ChunkDemuxer( | 307 chunk_demuxer_ = new media::ChunkDemuxer( |
| 306 BIND_TO_RENDER_LOOP_1(&WebMediaPlayerImpl::OnDemuxerOpened, | 308 BIND_TO_RENDER_LOOP_1(&WebMediaPlayerImpl::OnDemuxerOpened, |
| 307 base::Passed(&ms)), | 309 base::Passed(&ms)), |
| 308 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""), | 310 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""), |
| 311 base::Bind(&WebMediaPlayerImpl::OnTextTrack, AsWeakPtr()), | |
| 312 base::Bind(&WebMediaPlayerImpl::OnText, AsWeakPtr()), | |
| 309 base::Bind(&LogMediaSourceError, media_log_)); | 313 base::Bind(&LogMediaSourceError, media_log_)); |
| 310 | 314 |
| 311 BuildMediaSourceCollection(chunk_demuxer_, | 315 BuildMediaSourceCollection(chunk_demuxer_, |
| 312 media_thread_.message_loop_proxy(), | 316 media_thread_.message_loop_proxy(), |
| 313 filter_collection_.get()); | 317 filter_collection_.get()); |
| 314 supports_save_ = false; | 318 supports_save_ = false; |
| 315 StartPipeline(); | 319 StartPipeline(); |
| 316 } | 320 } |
| 317 | 321 |
| 318 void WebMediaPlayerImpl::LoadSetup(const WebKit::WebURL& url) { | 322 void WebMediaPlayerImpl::LoadSetup(const WebKit::WebURL& url) { |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1032 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_); | 1036 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_); |
| 1033 if (init_data_type_.empty()) | 1037 if (init_data_type_.empty()) |
| 1034 init_data_type_ = type; | 1038 init_data_type_ = type; |
| 1035 | 1039 |
| 1036 GetClient()->keyNeeded(WebString::fromUTF8(key_system), | 1040 GetClient()->keyNeeded(WebString::fromUTF8(key_system), |
| 1037 WebString::fromUTF8(session_id), | 1041 WebString::fromUTF8(session_id), |
| 1038 init_data.get(), | 1042 init_data.get(), |
| 1039 init_data_size); | 1043 init_data_size); |
| 1040 } | 1044 } |
| 1041 | 1045 |
| 1046 void WebMediaPlayerImpl::OnTextTrack(const media::TextKind kind, | |
| 1047 const std::string& label, | |
| 1048 const std::string& language) { | |
| 1049 const WebInbandTextTrackImpl::Kind kind_map[] = { | |
| 1050 WebInbandTextTrackImpl::Subtitles, | |
| 1051 WebInbandTextTrackImpl::Captions, | |
| 1052 WebInbandTextTrackImpl::Descriptions, | |
| 1053 WebInbandTextTrackImpl::Chapters, | |
| 1054 WebInbandTextTrackImpl::Metadata, | |
| 1055 WebInbandTextTrackImpl::None | |
| 1056 }; | |
| 1057 | |
| 1058 const WebInbandTextTrackImpl::Kind webkind = kind_map[kind]; | |
|
acolwell GONE FROM CHROMIUM
2013/04/05 16:29:23
A simple cast should be possible here. You can als
Matthew Heaney (Chromium)
2013/05/09 03:53:11
For now I just made it into a static_cast.
| |
| 1059 const WebKit::WebString weblabel = WebKit::WebString::fromUTF8(label); | |
| 1060 const WebKit::WebString weblanguage = WebKit::WebString::fromUTF8(language); | |
| 1061 | |
| 1062 // TODO(matthewjheaney): resolve lifetime issues for text_track_. | |
| 1063 text_track_ = new WebInbandTextTrackImpl(webkind, weblabel, weblanguage); | |
| 1064 GetClient()->addTextTrack(text_track_); | |
| 1065 } | |
| 1066 | |
| 1067 void WebMediaPlayerImpl::OnText(const base::TimeDelta& time) { | |
| 1068 WebKit::WebInbandTextTrackClient* const client = text_track_->client(); | |
| 1069 // TODO(matthewjheaney): correct type? | |
| 1070 const double start = time.InSecondsF(); | |
| 1071 const double end = start + 1.0; // TODO(matthewjheaney) | |
| 1072 const WebString id("id"); // TODO(matthewjheaney) | |
| 1073 const WebString content("hello, world!"); // TODO | |
| 1074 const WebString settings(""); // TODO | |
| 1075 | |
| 1076 client->addWebVTTCue(start, end, id, content, settings); | |
| 1077 } | |
| 1078 | |
| 1042 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ | 1079 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
| 1043 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \ | 1080 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \ |
| 1044 static_cast<int>(media::Decryptor::k ## name), \ | 1081 static_cast<int>(media::Decryptor::k ## name), \ |
| 1045 mismatching_enums) | 1082 mismatching_enums) |
| 1046 COMPILE_ASSERT_MATCHING_ENUM(UnknownError); | 1083 COMPILE_ASSERT_MATCHING_ENUM(UnknownError); |
| 1047 COMPILE_ASSERT_MATCHING_ENUM(ClientError); | 1084 COMPILE_ASSERT_MATCHING_ENUM(ClientError); |
| 1048 COMPILE_ASSERT_MATCHING_ENUM(ServiceError); | 1085 COMPILE_ASSERT_MATCHING_ENUM(ServiceError); |
| 1049 COMPILE_ASSERT_MATCHING_ENUM(OutputError); | 1086 COMPILE_ASSERT_MATCHING_ENUM(OutputError); |
| 1050 COMPILE_ASSERT_MATCHING_ENUM(HardwareChangeError); | 1087 COMPILE_ASSERT_MATCHING_ENUM(HardwareChangeError); |
| 1051 COMPILE_ASSERT_MATCHING_ENUM(DomainError); | 1088 COMPILE_ASSERT_MATCHING_ENUM(DomainError); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1223 | 1260 |
| 1224 if (pending_repaint_) | 1261 if (pending_repaint_) |
| 1225 return; | 1262 return; |
| 1226 | 1263 |
| 1227 pending_repaint_ = true; | 1264 pending_repaint_ = true; |
| 1228 main_loop_->PostTask(FROM_HERE, base::Bind( | 1265 main_loop_->PostTask(FROM_HERE, base::Bind( |
| 1229 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); | 1266 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); |
| 1230 } | 1267 } |
| 1231 | 1268 |
| 1232 } // namespace webkit_media | 1269 } // namespace webkit_media |
| OLD | NEW |