Chromium Code Reviews| Index: webkit/media/webmediaplayer_impl.cc |
| diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc |
| index edae2bb3fd1781eebf9d51ed27dc88d06b18390e..028de20ef52e10ef4a8fbba3b104e0a09bdd4e7b 100644 |
| --- a/webkit/media/webmediaplayer_impl.cc |
| +++ b/webkit/media/webmediaplayer_impl.cc |
| @@ -31,6 +31,7 @@ |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebInbandTextTrackPrivateClient.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaSource.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| @@ -39,6 +40,7 @@ |
| #include "webkit/media/buffered_data_source.h" |
| #include "webkit/media/filter_helpers.h" |
| #include "webkit/media/webaudiosourceprovider_impl.h" |
| +#include "webkit/media/webinbandtexttrack_impl.h" |
| #include "webkit/media/webmediaplayer_delegate.h" |
| #include "webkit/media/webmediaplayer_params.h" |
| #include "webkit/media/webmediaplayer_util.h" |
| @@ -306,6 +308,8 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url, |
| BIND_TO_RENDER_LOOP_1(&WebMediaPlayerImpl::OnDemuxerOpened, |
| base::Passed(&ms)), |
| BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""), |
| + base::Bind(&WebMediaPlayerImpl::OnTextTrack, AsWeakPtr()), |
| + base::Bind(&WebMediaPlayerImpl::OnText, AsWeakPtr()), |
| base::Bind(&LogMediaSourceError, media_log_)); |
| BuildMediaSourceCollection(chunk_demuxer_, |
| @@ -1039,6 +1043,42 @@ void WebMediaPlayerImpl::OnNeedKey(const std::string& key_system, |
| init_data_size); |
| } |
| +void WebMediaPlayerImpl::OnTextTrack(const media::TextKind kind, |
| + const std::string& label, |
| + const std::string& language) { |
| + const WebInbandTextTrackImpl::Kind kind_map[] = |
| + { |
|
fgalligan1
2013/04/02 19:38:32
Move curly brace up one line.
Matthew Heaney (Chromium)
2013/04/04 04:01:52
Done.
|
| + WebInbandTextTrackImpl::Subtitles, |
| + WebInbandTextTrackImpl::Captions, |
| + WebInbandTextTrackImpl::Descriptions, |
| + WebInbandTextTrackImpl::Chapters, |
| + WebInbandTextTrackImpl::Metadata, |
| + WebInbandTextTrackImpl::None |
| + }; |
| + |
| + const WebInbandTextTrackImpl::Kind webkind = kind_map[kind]; |
| + const WebKit::WebString weblabel = WebKit::WebString::fromUTF8(label); |
| + const WebKit::WebString weblanguage = WebKit::WebString::fromUTF8(language); |
| + |
| + // TODO(matthewjheaney): resolve lifetime issues for text_track_. |
| + text_track_ = new WebInbandTextTrackImpl(webkind, weblabel, weblanguage); |
| + GetClient()->addTextTrack(text_track_); |
| +} |
| + |
| +void WebMediaPlayerImpl::OnText(const base::TimeDelta& time) { |
| + WebKit::WebInbandTextTrackPrivateClient* const client = text_track_->client(); |
| + //WebCore::InbandTextTrackPrivate* const text_track_private = NULL; // TODO |
| + const double start = time.InSecondsF(); |
| + const double end = start + 1.0; // TODO(matthewjheaney) |
| + //const WTF::String id("id"); // TODO(matthewjheaney) |
| + //const WTF::String content("hello, world!"); // TODO |
| + //const WTF::String settings(""); // TODO |
| + const WebKit::WebString content("hey, frank!"); |
| + |
| + // TODO(matthewjheaney): figure out first parameter |
| + client->addWebVTTCue(NULL, start, end, "", content, ""); |
| +} |
| + |
| #define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
| COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \ |
| static_cast<int>(media::Decryptor::k ## name), \ |