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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 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 "media/base/fake_text_track_stream.h"
6
7 #include "base/bind.h"
8 #include "base/callback_helpers.h"
9 #include "media/base/decoder_buffer.h"
10 #include "media/filters/webvtt_util.h"
11
12 namespace media {
13
14 FakeTextTrackStream::FakeTextTrackStream()
15 : message_loop_(base::MessageLoopProxy::current()),
16 stopping_(false) {
17 }
18
19 FakeTextTrackStream::~FakeTextTrackStream() {
20 DCHECK(read_cb_.is_null());
21 }
22
23 void FakeTextTrackStream::Read(const ReadCB& read_cb) {
24 DCHECK(!read_cb.is_null());
25 DCHECK(read_cb_.is_null());
26 OnRead();
27 read_cb_ = read_cb;
28
29 if (stopping_) {
30 message_loop_->PostTask(FROM_HERE, base::Bind(
31 &FakeTextTrackStream::AbortPendingRead, base::Unretained(this)));
32 }
33 }
34
35 DemuxerStream::Type FakeTextTrackStream::type() {
36 return DemuxerStream::TEXT;
37 }
38
39 void FakeTextTrackStream::SatisfyPendingRead(
40 const base::TimeDelta& start,
41 const base::TimeDelta& duration,
42 const std::string& id,
43 const std::string& content,
44 const std::string& settings) {
45 DCHECK(!read_cb_.is_null());
46
47 const uint8* const data_buf = reinterpret_cast<const uint8*>(content.data());
48 const int data_len = static_cast<int>(content.size());
49
50 std::vector<uint8> side_data;
51 MakeSideData(id.begin(), id.end(),
52 settings.begin(), settings.end(),
53 &side_data);
54
55 const uint8* const sd_buf = &side_data[0];
56 const int sd_len = static_cast<int>(side_data.size());
57
58 scoped_refptr<DecoderBuffer> buffer;
59 buffer = DecoderBuffer::CopyFrom(data_buf, data_len, sd_buf, sd_len);
60
61 buffer->set_timestamp(start);
62 buffer->set_duration(duration);
63
64 base::ResetAndReturn(&read_cb_).Run(kOk, buffer);
65 }
66
67 void FakeTextTrackStream::AbortPendingRead() {
68 DCHECK(!read_cb_.is_null());
69 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL);
70 }
71
72 void FakeTextTrackStream::SendEosNotification() {
73 DCHECK(!read_cb_.is_null());
74 base::ResetAndReturn(&read_cb_).Run(kOk, DecoderBuffer::CreateEOSBuffer());
75 }
76
77 void FakeTextTrackStream::Stop() {
78 stopping_ = true;
79 if (!read_cb_.is_null())
80 AbortPendingRead();
81 }
82
83 } // namespace media
OLDNEW
« 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