1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "content/renderer/media/texttrack_impl.h" 6 7 #include "content/renderer/media/webinbandtexttrack_impl.h" 8 #include "third_party/WebKit/public/web/WebInbandTextTrackClient.h" 9 #include "third_party/WebKit/public/web/WebMediaPlayerClient.h" 10 11 namespace content { 12 13 TextTrackImpl::TextTrackImpl(WebKit::WebMediaPlayerClient* client, 14 WebInbandTextTrackImpl* text_track) 15 : client_(client), text_track_(text_track) { 16 client_->addTextTrack(text_track_.get()); 17 } 18 19 TextTrackImpl::~TextTrackImpl() { 20 if (text_track_->client()) 21 client_->removeTextTrack(text_track_.get()); 22 } 23 24 void TextTrackImpl::addWebVTTCue(const base::TimeDelta& start, 25 const base::TimeDelta& end, 26 const std::string& id, 27 const std::string& content, 28 const std::string& settings) { 29 if (WebKit::WebInbandTextTrackClient* client = text_track_->client()) 30 client->addWebVTTCue(start.InSecondsF(), 31 end.InSecondsF(), 32 WebKit::WebString::fromUTF8(id), 33 WebKit::WebString::fromUTF8(content), 34 WebKit::WebString::fromUTF8(settings)); 35 } 36 37 } // namespace content 38