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

Unified Diff: content/renderer/media/texttrack_impl.cc

Issue 23702007: Render inband text tracks in the media pipeline (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix compile errors 11/21 #6 Created 7 years, 1 month 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
« no previous file with comments | « content/renderer/media/texttrack_impl.h ('k') | content/renderer/media/webmediaplayer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/texttrack_impl.cc
diff --git a/content/renderer/media/texttrack_impl.cc b/content/renderer/media/texttrack_impl.cc
index e50c39017ac63a9313517a687df15e7bc0e5ea73..3df473b593a2a9e7b0456d5bc21f9eb94d288831 100644
--- a/content/renderer/media/texttrack_impl.cc
+++ b/content/renderer/media/texttrack_impl.cc
@@ -4,21 +4,32 @@
#include "content/renderer/media/texttrack_impl.h"
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "content/renderer/media/webinbandtexttrack_impl.h"
+#include "media/base/bind_to_loop.h"
#include "third_party/WebKit/public/platform/WebInbandTextTrackClient.h"
#include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
namespace content {
-TextTrackImpl::TextTrackImpl(blink::WebMediaPlayerClient* client,
- WebInbandTextTrackImpl* text_track)
- : client_(client), text_track_(text_track) {
+TextTrackImpl::TextTrackImpl(
+ const scoped_refptr<base::MessageLoopProxy>& message_loop,
+ blink::WebMediaPlayerClient* client,
+ scoped_ptr<WebInbandTextTrackImpl> text_track)
+ : message_loop_(message_loop),
+ client_(client),
+ text_track_(text_track.Pass()) {
client_->addTextTrack(text_track_.get());
}
TextTrackImpl::~TextTrackImpl() {
- if (text_track_->client())
- client_->removeTextTrack(text_track_.get());
+ message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&TextTrackImpl::OnRemoveTrack,
+ client_,
+ base::Passed(&text_track_)));
}
void TextTrackImpl::addWebVTTCue(const base::TimeDelta& start,
@@ -26,12 +37,34 @@ void TextTrackImpl::addWebVTTCue(const base::TimeDelta& start,
const std::string& id,
const std::string& content,
const std::string& settings) {
- if (blink::WebInbandTextTrackClient* client = text_track_->client())
+ message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&TextTrackImpl::OnAddCue,
+ text_track_.get(),
+ start, end,
+ id, content, settings));
+}
+
+void TextTrackImpl::OnAddCue(WebInbandTextTrackImpl* text_track,
+ const base::TimeDelta& start,
+ const base::TimeDelta& end,
+ const std::string& id,
+ const std::string& content,
+ const std::string& settings) {
+ if (blink::WebInbandTextTrackClient* client = text_track->client()) {
client->addWebVTTCue(start.InSecondsF(),
end.InSecondsF(),
blink::WebString::fromUTF8(id),
blink::WebString::fromUTF8(content),
blink::WebString::fromUTF8(settings));
+ }
+}
+
+void TextTrackImpl::OnRemoveTrack(
+ blink::WebMediaPlayerClient* client,
+ scoped_ptr<WebInbandTextTrackImpl> text_track) {
+ if (text_track->client())
+ client->removeTextTrack(text_track.get());
}
} // namespace content
« no previous file with comments | « content/renderer/media/texttrack_impl.h ('k') | content/renderer/media/webmediaplayer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698