OLD | NEW |
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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <deque> | 11 #include <deque> |
12 #include <map> | 12 #include <map> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/callback_forward.h" | 16 #include "base/callback_forward.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "media/base/demuxer_stream.h" | 21 #include "media/base/demuxer_stream.h" |
22 #include "media/base/eme_constants.h" | 22 #include "media/base/eme_constants.h" |
23 #include "media/base/media_export.h" | 23 #include "media/base/media_export.h" |
24 #include "media/base/media_log.h" | 24 #include "media/base/media_log.h" |
25 | 25 |
26 namespace media { | 26 namespace media { |
27 | 27 |
28 class AudioDecoderConfig; | 28 class MediaTracks; |
29 class StreamParserBuffer; | 29 class StreamParserBuffer; |
30 class TextTrackConfig; | 30 class TextTrackConfig; |
31 class VideoDecoderConfig; | |
32 | 31 |
33 // Abstract interface for parsing media byte streams. | 32 // Abstract interface for parsing media byte streams. |
34 class MEDIA_EXPORT StreamParser { | 33 class MEDIA_EXPORT StreamParser { |
35 public: | 34 public: |
36 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; | 35 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; |
37 | 36 |
38 // Range of |TrackId| is dependent upon stream parsers. It is currently | 37 // Range of |TrackId| is dependent upon stream parsers. It is currently |
39 // the key for the buffer's text track config in the applicable | 38 // the key for the buffer's text track config in the applicable |
40 // TextTrackConfigMap (which is passed in StreamParser::NewConfigCB), or | 39 // TextTrackConfigMap (which is passed in StreamParser::NewConfigCB), or |
41 // 0 for other media types that currently allow at most one track. | 40 // 0 for other media types that currently allow at most one track. |
(...skipping 27 matching lines...) Expand all Loading... |
69 | 68 |
70 // Indicates live stream. | 69 // Indicates live stream. |
71 DemuxerStream::Liveness liveness; | 70 DemuxerStream::Liveness liveness; |
72 }; | 71 }; |
73 | 72 |
74 // Indicates completion of parser initialization. | 73 // Indicates completion of parser initialization. |
75 // params - Stream parameters. | 74 // params - Stream parameters. |
76 typedef base::Callback<void(const InitParameters& params)> InitCB; | 75 typedef base::Callback<void(const InitParameters& params)> InitCB; |
77 | 76 |
78 // Indicates when new stream configurations have been parsed. | 77 // Indicates when new stream configurations have been parsed. |
79 // First parameter - The new audio configuration. If the config is not valid | 78 // First parameter - An object containing information about media tracks as |
80 // then it means that there isn't an audio stream. | 79 // well as audio/video decoder configs associated with each |
81 // Second parameter - The new video configuration. If the config is not valid | 80 // track. |
82 // then it means that there isn't an audio stream. | 81 // Second parameter - The new text tracks configuration. If the map is empty, |
83 // Third parameter - The new text tracks configuration. If the map is empty, | 82 // then no text tracks were parsed from the stream. |
84 // then no text tracks were parsed from the stream. | |
85 // Return value - True if the new configurations are accepted. | 83 // Return value - True if the new configurations are accepted. |
86 // False if the new configurations are not supported | 84 // False if the new configurations are not supported |
87 // and indicates that a parsing error should be signalled. | 85 // and indicates that a parsing error should be signalled. |
88 typedef base::Callback<bool(const AudioDecoderConfig&, | 86 typedef base::Callback<bool(scoped_ptr<MediaTracks>, |
89 const VideoDecoderConfig&, | 87 const TextTrackConfigMap&)> |
90 const TextTrackConfigMap&)> NewConfigCB; | 88 NewConfigCB; |
91 | 89 |
92 // New stream buffers have been parsed. | 90 // New stream buffers have been parsed. |
93 // First parameter - A queue of newly parsed audio buffers. | 91 // First parameter - A queue of newly parsed audio buffers. |
94 // Second parameter - A queue of newly parsed video buffers. | 92 // Second parameter - A queue of newly parsed video buffers. |
95 // Third parameter - A map of text track ids to queues of newly parsed inband | 93 // Third parameter - A map of text track ids to queues of newly parsed inband |
96 // text buffers. If the map is not empty, it must contain | 94 // text buffers. If the map is not empty, it must contain |
97 // at least one track with a non-empty queue of text | 95 // at least one track with a non-empty queue of text |
98 // buffers. | 96 // buffers. |
99 // Return value - True indicates that the buffers are accepted. | 97 // Return value - True indicates that the buffers are accepted. |
100 // False if something was wrong with the buffers and a parsing | 98 // False if something was wrong with the buffers and a parsing |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // subtle issues with tie-breaking. See http://crbug.com/338484. | 160 // subtle issues with tie-breaking. See http://crbug.com/338484. |
163 MEDIA_EXPORT bool MergeBufferQueues( | 161 MEDIA_EXPORT bool MergeBufferQueues( |
164 const StreamParser::BufferQueue& audio_buffers, | 162 const StreamParser::BufferQueue& audio_buffers, |
165 const StreamParser::BufferQueue& video_buffers, | 163 const StreamParser::BufferQueue& video_buffers, |
166 const StreamParser::TextBufferQueueMap& text_buffers, | 164 const StreamParser::TextBufferQueueMap& text_buffers, |
167 StreamParser::BufferQueue* merged_buffers); | 165 StreamParser::BufferQueue* merged_buffers); |
168 | 166 |
169 } // namespace media | 167 } // namespace media |
170 | 168 |
171 #endif // MEDIA_BASE_STREAM_PARSER_H_ | 169 #endif // MEDIA_BASE_STREAM_PARSER_H_ |
OLD | NEW |