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

Side by Side Diff: media/base/stream_parser.h

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 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/pipeline_unittest.cc ('k') | media/base/text_cue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_STREAM_PARSER_H_ 5 #ifndef MEDIA_BASE_STREAM_PARSER_H_
6 #define MEDIA_BASE_STREAM_PARSER_H_ 6 #define MEDIA_BASE_STREAM_PARSER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map>
9 #include <string> 10 #include <string>
10 11
11 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "media/base/media_export.h" 16 #include "media/base/media_export.h"
16 #include "media/base/media_log.h" 17 #include "media/base/media_log.h"
17 #include "media/base/text_track.h"
18 18
19 namespace media { 19 namespace media {
20 20
21 class AudioDecoderConfig; 21 class AudioDecoderConfig;
22 class StreamParserBuffer; 22 class StreamParserBuffer;
23 class TextTrackConfig;
23 class VideoDecoderConfig; 24 class VideoDecoderConfig;
24 25
25 // Abstract interface for parsing media byte streams. 26 // Abstract interface for parsing media byte streams.
26 class MEDIA_EXPORT StreamParser { 27 class MEDIA_EXPORT StreamParser {
27 public: 28 public:
28 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; 29 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue;
30 typedef std::map<int, TextTrackConfig> TextTrackConfigMap;
29 31
30 StreamParser(); 32 StreamParser();
31 virtual ~StreamParser(); 33 virtual ~StreamParser();
32 34
33 // Indicates completion of parser initialization. 35 // Indicates completion of parser initialization.
34 // First parameter - Indicates initialization success. Set to true if 36 // First parameter - Indicates initialization success. Set to true if
35 // initialization was successful. False if an error 37 // initialization was successful. False if an error
36 // occurred. 38 // occurred.
37 // Second parameter - Indicates the stream duration. Only contains a valid 39 // Second parameter - Indicates the stream duration. Only contains a valid
38 // value if the first parameter is true. 40 // value if the first parameter is true.
39 typedef base::Callback<void(bool, base::TimeDelta)> InitCB; 41 typedef base::Callback<void(bool, base::TimeDelta)> InitCB;
40 42
41 // Indicates when new stream configurations have been parsed. 43 // Indicates when new stream configurations have been parsed.
42 // First parameter - The new audio configuration. If the config is not valid 44 // First parameter - The new audio configuration. If the config is not valid
43 // then it means that there isn't an audio stream. 45 // then it means that there isn't an audio stream.
44 // Second parameter - The new video configuration. If the config is not valid 46 // Second parameter - The new video configuration. If the config is not valid
45 // then it means that there isn't an audio stream. 47 // then it means that there isn't an audio stream.
48 // Third parameter - The new text tracks configuration. If the map is empty,
49 // then no text tracks were parsed from the stream.
46 // Return value - True if the new configurations are accepted. 50 // Return value - True if the new configurations are accepted.
47 // False if the new configurations are not supported 51 // False if the new configurations are not supported
48 // and indicates that a parsing error should be signalled. 52 // and indicates that a parsing error should be signalled.
49 typedef base::Callback<bool(const AudioDecoderConfig&, 53 typedef base::Callback<bool(const AudioDecoderConfig&,
50 const VideoDecoderConfig&)> NewConfigCB; 54 const VideoDecoderConfig&,
55 const TextTrackConfigMap&)> NewConfigCB;
51 56
52 // New stream buffers have been parsed. 57 // New stream buffers have been parsed.
53 // First parameter - A queue of newly parsed audio buffers. 58 // First parameter - A queue of newly parsed audio buffers.
54 // Second parameter - A queue of newly parsed video buffers. 59 // Second parameter - A queue of newly parsed video buffers.
55 // Return value - True indicates that the buffers are accepted. 60 // Return value - True indicates that the buffers are accepted.
56 // False if something was wrong with the buffers and a parsing 61 // False if something was wrong with the buffers and a parsing
57 // error should be signalled. 62 // error should be signalled.
58 typedef base::Callback<bool(const BufferQueue&, 63 typedef base::Callback<bool(const BufferQueue&,
59 const BufferQueue&)> NewBuffersCB; 64 const BufferQueue&)> NewBuffersCB;
60 65
61 // New stream buffers of inband text have been parsed. 66 // New stream buffers of inband text have been parsed.
62 // First parameter - The text track to which these cues will be added. 67 // First parameter - The id of the text track to which these cues will
68 // be added.
63 // Second parameter - A queue of newly parsed buffers. 69 // Second parameter - A queue of newly parsed buffers.
64 // Return value - True indicates that the buffers are accepted. 70 // Return value - True indicates that the buffers are accepted.
65 // False if something was wrong with the buffers and a parsing 71 // False if something was wrong with the buffers and a parsing
66 // error should be signalled. 72 // error should be signalled.
67 typedef base::Callback<bool(TextTrack*, const BufferQueue&)> NewTextBuffersCB; 73 typedef base::Callback<bool(int, const BufferQueue&)> NewTextBuffersCB;
68 74
69 // Signals the beginning of a new media segment. 75 // Signals the beginning of a new media segment.
70 typedef base::Callback<void()> NewMediaSegmentCB; 76 typedef base::Callback<void()> NewMediaSegmentCB;
71 77
72 // A new potentially encrypted stream has been parsed. 78 // A new potentially encrypted stream has been parsed.
73 // First parameter - The type of the initialization data associated with the 79 // First parameter - The type of the initialization data associated with the
74 // stream. 80 // stream.
75 // Second parameter - The initialization data associated with the stream. 81 // Second parameter - The initialization data associated with the stream.
76 typedef base::Callback<void(const std::string&, 82 typedef base::Callback<void(const std::string&,
77 const std::vector<uint8>&)> NeedKeyCB; 83 const std::vector<uint8>&)> NeedKeyCB;
78 84
79 // Initialize the parser with necessary callbacks. Must be called before any 85 // Initialize the parser with necessary callbacks. Must be called before any
80 // data is passed to Parse(). |init_cb| will be called once enough data has 86 // data is passed to Parse(). |init_cb| will be called once enough data has
81 // been parsed to determine the initial stream configurations, presentation 87 // been parsed to determine the initial stream configurations, presentation
82 // start time, and duration. 88 // start time, and duration.
83 virtual void Init(const InitCB& init_cb, 89 virtual void Init(const InitCB& init_cb,
84 const NewConfigCB& config_cb, 90 const NewConfigCB& config_cb,
85 const NewBuffersCB& new_buffers_cb, 91 const NewBuffersCB& new_buffers_cb,
86 const NewTextBuffersCB& text_cb, 92 const NewTextBuffersCB& text_cb,
87 const NeedKeyCB& need_key_cb, 93 const NeedKeyCB& need_key_cb,
88 const AddTextTrackCB& add_text_track_cb,
89 const NewMediaSegmentCB& new_segment_cb, 94 const NewMediaSegmentCB& new_segment_cb,
90 const base::Closure& end_of_segment_cb, 95 const base::Closure& end_of_segment_cb,
91 const LogCB& log_cb) = 0; 96 const LogCB& log_cb) = 0;
92 97
93 // Called when a seek occurs. This flushes the current parser state 98 // Called when a seek occurs. This flushes the current parser state
94 // and puts the parser in a state where it can receive data for the new seek 99 // and puts the parser in a state where it can receive data for the new seek
95 // point. 100 // point.
96 virtual void Flush() = 0; 101 virtual void Flush() = 0;
97 102
98 // Called when there is new data to parse. 103 // Called when there is new data to parse.
99 // 104 //
100 // Returns true if the parse succeeds. 105 // Returns true if the parse succeeds.
101 virtual bool Parse(const uint8* buf, int size) = 0; 106 virtual bool Parse(const uint8* buf, int size) = 0;
102 107
103 private: 108 private:
104 DISALLOW_COPY_AND_ASSIGN(StreamParser); 109 DISALLOW_COPY_AND_ASSIGN(StreamParser);
105 }; 110 };
106 111
107 } // namespace media 112 } // namespace media
108 113
109 #endif // MEDIA_BASE_STREAM_PARSER_H_ 114 #endif // MEDIA_BASE_STREAM_PARSER_H_
OLDNEW
« no previous file with comments | « media/base/pipeline_unittest.cc ('k') | media/base/text_cue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698