Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: webkit/media/webmediaplayer_impl.cc

Issue 13419002: Media Source dispatches inband text tracks (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/WebInbandTextTrackPri vateClient.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
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
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 {
fgalligan1 2013/04/02 19:38:32 Move curly brace up one line.
Matthew Heaney (Chromium) 2013/04/04 04:01:52 Done.
1051 WebInbandTextTrackImpl::Subtitles,
1052 WebInbandTextTrackImpl::Captions,
1053 WebInbandTextTrackImpl::Descriptions,
1054 WebInbandTextTrackImpl::Chapters,
1055 WebInbandTextTrackImpl::Metadata,
1056 WebInbandTextTrackImpl::None
1057 };
1058
1059 const WebInbandTextTrackImpl::Kind webkind = kind_map[kind];
1060 const WebKit::WebString weblabel = WebKit::WebString::fromUTF8(label);
1061 const WebKit::WebString weblanguage = WebKit::WebString::fromUTF8(language);
1062
1063 // TODO(matthewjheaney): resolve lifetime issues for text_track_.
1064 text_track_ = new WebInbandTextTrackImpl(webkind, weblabel, weblanguage);
1065 GetClient()->addTextTrack(text_track_);
1066 }
1067
1068 void WebMediaPlayerImpl::OnText(const base::TimeDelta& time) {
1069 WebKit::WebInbandTextTrackPrivateClient* const client = text_track_->client();
1070 //WebCore::InbandTextTrackPrivate* const text_track_private = NULL; // TODO
1071 const double start = time.InSecondsF();
1072 const double end = start + 1.0; // TODO(matthewjheaney)
1073 //const WTF::String id("id"); // TODO(matthewjheaney)
1074 //const WTF::String content("hello, world!"); // TODO
1075 //const WTF::String settings(""); // TODO
1076 const WebKit::WebString content("hey, frank!");
1077
1078 // TODO(matthewjheaney): figure out first parameter
1079 client->addWebVTTCue(NULL, start, end, "", content, "");
1080 }
1081
1042 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ 1082 #define COMPILE_ASSERT_MATCHING_ENUM(name) \
1043 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \ 1083 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \
1044 static_cast<int>(media::Decryptor::k ## name), \ 1084 static_cast<int>(media::Decryptor::k ## name), \
1045 mismatching_enums) 1085 mismatching_enums)
1046 COMPILE_ASSERT_MATCHING_ENUM(UnknownError); 1086 COMPILE_ASSERT_MATCHING_ENUM(UnknownError);
1047 COMPILE_ASSERT_MATCHING_ENUM(ClientError); 1087 COMPILE_ASSERT_MATCHING_ENUM(ClientError);
1048 COMPILE_ASSERT_MATCHING_ENUM(ServiceError); 1088 COMPILE_ASSERT_MATCHING_ENUM(ServiceError);
1049 COMPILE_ASSERT_MATCHING_ENUM(OutputError); 1089 COMPILE_ASSERT_MATCHING_ENUM(OutputError);
1050 COMPILE_ASSERT_MATCHING_ENUM(HardwareChangeError); 1090 COMPILE_ASSERT_MATCHING_ENUM(HardwareChangeError);
1051 COMPILE_ASSERT_MATCHING_ENUM(DomainError); 1091 COMPILE_ASSERT_MATCHING_ENUM(DomainError);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 1263
1224 if (pending_repaint_) 1264 if (pending_repaint_)
1225 return; 1265 return;
1226 1266
1227 pending_repaint_ = true; 1267 pending_repaint_ = true;
1228 main_loop_->PostTask(FROM_HERE, base::Bind( 1268 main_loop_->PostTask(FROM_HERE, base::Bind(
1229 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); 1269 &WebMediaPlayerImpl::Repaint, AsWeakPtr()));
1230 } 1270 }
1231 1271
1232 } // namespace webkit_media 1272 } // namespace webkit_media
OLDNEW
« webkit/media/webinbandtexttrackprivateclient_impl.cc ('K') | « webkit/media/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698