diff options
author | acolwell <acolwell@chromium.org> | 2014-09-06 12:01:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-06 19:06:46 +0000 |
commit | 9e0840d0672da96350a1f33d684f2c64d2574f46 (patch) | |
tree | 6d72e3d50fcfd66f70a58c5d3583358055de4d9a /media/blink/texttrack_impl.cc | |
parent | 87a3ebac6b26918b151151efed3311d0ddc20d73 (diff) | |
download | chromium_src-9e0840d0672da96350a1f33d684f2c64d2574f46.zip chromium_src-9e0840d0672da96350a1f33d684f2c64d2574f46.tar.gz chromium_src-9e0840d0672da96350a1f33d684f2c64d2574f46.tar.bz2 |
Move WebMediaPlayerImpl and its dependencies to media/blink.
Moving WebMediaPlayerImpl and related classes in content/renderer/media to media/blink so that they can be reused by Mojo code.
BUG=408338
Review URL: https://codereview.chromium.org/495353003
Cr-Commit-Position: refs/heads/master@{#293628}
Diffstat (limited to 'media/blink/texttrack_impl.cc')
-rw-r--r-- | media/blink/texttrack_impl.cc | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/media/blink/texttrack_impl.cc b/media/blink/texttrack_impl.cc new file mode 100644 index 0000000..1d58af9 --- /dev/null +++ b/media/blink/texttrack_impl.cc @@ -0,0 +1,70 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/blink/texttrack_impl.h" + +#include "base/bind.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "media/base/bind_to_current_loop.h" +#include "media/blink/webinbandtexttrack_impl.h" +#include "third_party/WebKit/public/platform/WebInbandTextTrackClient.h" +#include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" + +namespace media { + +TextTrackImpl::TextTrackImpl( + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, + blink::WebMediaPlayerClient* client, + scoped_ptr<WebInbandTextTrackImpl> text_track) + : task_runner_(task_runner), + client_(client), + text_track_(text_track.Pass()) { + client_->addTextTrack(text_track_.get()); +} + +TextTrackImpl::~TextTrackImpl() { + task_runner_->PostTask( + FROM_HERE, + base::Bind(&TextTrackImpl::OnRemoveTrack, + client_, + base::Passed(&text_track_))); +} + +void TextTrackImpl::addWebVTTCue(const base::TimeDelta& start, + const base::TimeDelta& end, + const std::string& id, + const std::string& content, + const std::string& settings) { + task_runner_->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 media |