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

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: incorporate aaron's comments (9/28) Created 7 years, 3 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
Index: content/renderer/media/texttrack_impl.cc
diff --git a/content/renderer/media/texttrack_impl.cc b/content/renderer/media/texttrack_impl.cc
index 7acf39a1a488039c5748bfa031ec9e7ece5a83da..44557b33be2086fe5183ce6f37e250ac5b2e578a 100644
--- a/content/renderer/media/texttrack_impl.cc
+++ b/content/renderer/media/texttrack_impl.cc
@@ -4,21 +4,31 @@
#include "content/renderer/media/texttrack_impl.h"
+#include "base/bind.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/web/WebInbandTextTrackClient.h"
#include "third_party/WebKit/public/web/WebMediaPlayerClient.h"
namespace content {
-TextTrackImpl::TextTrackImpl(WebKit::WebMediaPlayerClient* client,
- WebInbandTextTrackImpl* text_track)
- : client_(client), text_track_(text_track) {
+TextTrackImpl::TextTrackImpl(
+ const scoped_refptr<base::MessageLoopProxy>& message_loop,
+ WebKit::WebMediaPlayerClient* client,
+ WebInbandTextTrackImpl* text_track)
+ : message_loop_(message_loop),
+ client_(client),
+ text_track_(text_track) {
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_,
+ text_track_.release()));
}
void TextTrackImpl::addWebVTTCue(const base::TimeDelta& start,
@@ -26,12 +36,36 @@ void TextTrackImpl::addWebVTTCue(const base::TimeDelta& start,
const std::string& id,
const std::string& content,
const std::string& settings) {
- if (WebKit::WebInbandTextTrackClient* client = text_track_->client())
- client->addWebVTTCue(start.InSecondsF(),
- end.InSecondsF(),
- WebKit::WebString::fromUTF8(id),
- WebKit::WebString::fromUTF8(content),
- WebKit::WebString::fromUTF8(settings));
+ if (WebKit::WebInbandTextTrackClient* client = text_track_->client()) {
acolwell GONE FROM CHROMIUM 2013/10/08 15:45:24 I don't think this is safe. I think you have to do
Matthew Heaney (Chromium) 2013/10/13 05:30:17 Done.
+ message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&TextTrackImpl::OnAddCue,
+ client,
+ start, end,
+ id, content, settings));
+ }
+}
+
+void TextTrackImpl::OnAddCue(WebKit::WebInbandTextTrackClient* client,
+ const base::TimeDelta& start,
+ const base::TimeDelta& end,
+ const std::string& id,
+ const std::string& content,
+ const std::string& settings) {
+ client->addWebVTTCue(start.InSecondsF(),
+ end.InSecondsF(),
+ WebKit::WebString::fromUTF8(id),
+ WebKit::WebString::fromUTF8(content),
+ WebKit::WebString::fromUTF8(settings));
+}
+
+void TextTrackImpl::OnRemoveTrack(
+ WebKit::WebMediaPlayerClient* client,
+ WebInbandTextTrackImpl* text_track) {
acolwell GONE FROM CHROMIUM 2013/10/08 15:45:24 You should be able to make text_track a scoped_ptr
Matthew Heaney (Chromium) 2013/10/13 05:30:17 I had tried that, but the compiler complains about
+ scoped_ptr<WebInbandTextTrackImpl> auto_delete(text_track);
+
+ if (text_track->client())
+ client->removeTextTrack(text_track);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698