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

Unified Diff: media/base/fake_text_track_stream.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 | « media/base/fake_text_track_stream.h ('k') | media/base/filter_collection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/fake_text_track_stream.cc
diff --git a/media/base/fake_text_track_stream.cc b/media/base/fake_text_track_stream.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2620a7a43f6e8bb8d1f4f6ec79d723bbb659e4c5
--- /dev/null
+++ b/media/base/fake_text_track_stream.cc
@@ -0,0 +1,83 @@
+// Copyright (c) 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/base/fake_text_track_stream.h"
+
+#include "base/bind.h"
+#include "base/callback_helpers.h"
+#include "media/base/decoder_buffer.h"
+#include "media/filters/webvtt_util.h"
+
+namespace media {
+
+FakeTextTrackStream::FakeTextTrackStream()
+ : message_loop_(base::MessageLoopProxy::current()),
+ stopping_(false) {
+}
+
+FakeTextTrackStream::~FakeTextTrackStream() {
+ DCHECK(read_cb_.is_null());
+}
+
+void FakeTextTrackStream::Read(const ReadCB& read_cb) {
+ DCHECK(!read_cb.is_null());
+ DCHECK(read_cb_.is_null());
+ OnRead();
+ read_cb_ = read_cb;
+
+ if (stopping_) {
+ message_loop_->PostTask(FROM_HERE, base::Bind(
+ &FakeTextTrackStream::AbortPendingRead, base::Unretained(this)));
+ }
+}
+
+DemuxerStream::Type FakeTextTrackStream::type() {
+ return DemuxerStream::TEXT;
+}
+
+void FakeTextTrackStream::SatisfyPendingRead(
+ const base::TimeDelta& start,
+ const base::TimeDelta& duration,
+ const std::string& id,
+ const std::string& content,
+ const std::string& settings) {
+ DCHECK(!read_cb_.is_null());
+
+ const uint8* const data_buf = reinterpret_cast<const uint8*>(content.data());
+ const int data_len = static_cast<int>(content.size());
+
+ std::vector<uint8> side_data;
+ MakeSideData(id.begin(), id.end(),
+ settings.begin(), settings.end(),
+ &side_data);
+
+ const uint8* const sd_buf = &side_data[0];
+ const int sd_len = static_cast<int>(side_data.size());
+
+ scoped_refptr<DecoderBuffer> buffer;
+ buffer = DecoderBuffer::CopyFrom(data_buf, data_len, sd_buf, sd_len);
+
+ buffer->set_timestamp(start);
+ buffer->set_duration(duration);
+
+ base::ResetAndReturn(&read_cb_).Run(kOk, buffer);
+}
+
+void FakeTextTrackStream::AbortPendingRead() {
+ DCHECK(!read_cb_.is_null());
+ base::ResetAndReturn(&read_cb_).Run(kAborted, NULL);
+}
+
+void FakeTextTrackStream::SendEosNotification() {
+ DCHECK(!read_cb_.is_null());
+ base::ResetAndReturn(&read_cb_).Run(kOk, DecoderBuffer::CreateEOSBuffer());
+}
+
+void FakeTextTrackStream::Stop() {
+ stopping_ = true;
+ if (!read_cb_.is_null())
+ AbortPendingRead();
+}
+
+} // namespace media
« no previous file with comments | « media/base/fake_text_track_stream.h ('k') | media/base/filter_collection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698