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

Side by Side Diff: media/filters/text_renderer_impl.h

Issue 23702007: Render inband text tracks in the media pipeline (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
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 #ifndef MEDIA_FILTERS_TEXT_RENDERER_IMPL_H_
6 #define MEDIA_FILTERS_TEXT_RENDERER_IMPL_H_
7
8 #include <vector>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "media/base/media_export.h"
13 #include "media/base/text_renderer.h"
14
15 namespace base {
16 class MessageLoopProxy;
17 }
18
19 namespace media {
20
21 class TextBuffer;
22 class TextDecoder;
23
24 // Indicates that a cue has been delivered from the stream at |index|,
25 // and hence that it should be added to the cue list for its text track.
26 typedef base::Callback<void(int index,
27 const scoped_refptr<TextBuffer>&)> CueReadyCB;
28
29 // Receives the decoded cues from the upstream decoder and passes them
30 // up to the player (via CueReadyCB) as they arrive.
31 class MEDIA_EXPORT TextRendererImpl : public TextRenderer {
32 public:
33 // |message_loop| is the thread on which TextRendererImpl will execute.
34 //
35 // |decoder| contains the TextDecoder to use when initializing.
36 //
37 // |cue_ready_cb] is called when the read of a decoded cue completes.
38 TextRendererImpl(const scoped_refptr<base::MessageLoopProxy>& message_loop,
39 scoped_ptr<TextDecoder> decoder,
40 const CueReadyCB& cue_ready_cb);
41 virtual ~TextRendererImpl();
42
43 // TextRenderer implementation.
44 virtual void Initialize(Demuxer* demuxer,
acolwell GONE FROM CHROMIUM 2013/09/12 00:15:15 I think there should be an AddStream(DemuxerStream
Matthew Heaney (Chromium) 2013/09/13 19:51:54 OK. I had written you a few questions about the e
Matthew Heaney (Chromium) 2013/09/20 23:53:54 I added the new method(s) to DemuxerHost and Pipel
45 const PipelineStatusCB& init_cb,
46 const base::Closure& ended_cb) OVERRIDE;
47 virtual void Play(const base::Closure& callback) OVERRIDE;
48 virtual void Pause(const base::Closure& callback) OVERRIDE;
49 virtual void Stop(const base::Closure& callback) OVERRIDE;
50
acolwell GONE FROM CHROMIUM 2013/09/12 00:15:15 I think there should be an AddTrack() / RemoveTrac
Matthew Heaney (Chromium) 2013/09/13 19:51:54 OK, I'll look into that.
51 private:
52 // Callback delivered by the text decoder, when the read on the text
53 // demuxer stream at |index| has completed, and the frame decoded.
54 void CueReady(int index, const scoped_refptr<TextBuffer>& text_buffer);
55
56 scoped_refptr<base::MessageLoopProxy> message_loop_;
57 base::WeakPtrFactory<TextRendererImpl> weak_factory_;
58 base::WeakPtr<TextRendererImpl> weak_this_;
59 scoped_ptr<TextDecoder> decoder_;
60 const CueReadyCB cue_ready_cb_;
61
62 // Callbacks provided during Initialize().
63 PipelineStatusCB init_cb_;
64 base::Closure ended_cb_;
65
66 // Callback provided to Pause().
67 base::Closure pause_cb_;
68
69 // Callback provided to Stop().
70 base::Closure stop_cb_;
71
72 // After Initialize() has completed, all variables below must be accessed
73 // under |lock_|. ------------------------------------------------------------
74 base::Lock lock_;
acolwell GONE FROM CHROMIUM 2013/09/12 00:15:15 Do you really need this lock? Doesn't this code on
Matthew Heaney (Chromium) 2013/09/13 19:51:54 Done.
75
76 // Simple state tracking variable.
77 enum State {
78 kUninitialized,
79 kPausePending,
80 kPaused,
81 kPlaying,
82 kStopPending,
83 kStopped
84 };
85 State state_;
86
87 // To differentiate among demuxer stream kinds, and determine read progress.
88 enum ReadState {
89 kReadInactive,
90 kReadIdle,
91 kReadPending
92 };
93 std::vector<ReadState> read_state_;
94
95 // Indicates how many text streams, among all demuxer streams.
96 int text_stream_count_;
97
98 // Indicates how many read requests are in flight.
99 int pending_read_count_;
100
101 // Indicates how many text streams have delivered end-of-stream indications.
acolwell GONE FROM CHROMIUM 2013/09/12 00:15:15 nit: This comment does not appear to match the cod
Matthew Heaney (Chromium) 2013/09/13 19:51:54 Done.
102 int eos_count_;
103
104 // End variables which must be accessed under |lock_|. ----------------------
105
106 DISALLOW_COPY_AND_ASSIGN(TextRendererImpl);
107 };
108
109 } // namespace media
110
111 #endif // MEDIA_FILTERS_TEXT_RENDERER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698