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

Unified 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: incorporated Frank's comments Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« webkit/media/webmediaplayer_impl.h ('K') | « webkit/media/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/media/webmediaplayer_impl.cc
diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc
index edae2bb3fd1781eebf9d51ed27dc88d06b18390e..88b8fd7dbadd088a2014cb0dd04e246fdada58a2 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/WebInbandTextTrackClient.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,39 @@ 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[] = {
+ WebInbandTextTrackImpl::Subtitles,
+ WebInbandTextTrackImpl::Captions,
+ WebInbandTextTrackImpl::Descriptions,
+ WebInbandTextTrackImpl::Chapters,
+ WebInbandTextTrackImpl::Metadata,
+ WebInbandTextTrackImpl::None
+ };
+
+ 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.
+ 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::WebInbandTextTrackClient* const client = text_track_->client();
+ // TODO(matthewjheaney): correct type?
+ const double start = time.InSecondsF();
+ const double end = start + 1.0; // TODO(matthewjheaney)
+ const WebString id("id"); // TODO(matthewjheaney)
+ const WebString content("hello, world!"); // TODO
+ const WebString settings(""); // TODO
+
+ client->addWebVTTCue(start, end, id, content, settings);
+}
+
#define COMPILE_ASSERT_MATCHING_ENUM(name) \
COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \
static_cast<int>(media::Decryptor::k ## name), \
« webkit/media/webmediaplayer_impl.h ('K') | « webkit/media/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698