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

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

Issue 149153002: MSE: Add StreamParser buffer remuxing utility and tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased, fixed comments from PS3, and prepped for TrackId unification work. Created 6 years, 10 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 | Annotate | Revision Log
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 <map>
10 #include <string> 10 #include <string>
11 #include <vector>
11 12
12 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "media/base/media_export.h" 17 #include "media/base/media_export.h"
17 #include "media/base/media_log.h" 18 #include "media/base/media_log.h"
18 19
19 namespace media { 20 namespace media {
20 21
21 class AudioDecoderConfig; 22 class AudioDecoderConfig;
22 class StreamParserBuffer; 23 class StreamParserBuffer;
23 class TextTrackConfig; 24 class TextTrackConfig;
24 class VideoDecoderConfig; 25 class VideoDecoderConfig;
25 26
26 // Abstract interface for parsing media byte streams. 27 // Abstract interface for parsing media byte streams.
27 class MEDIA_EXPORT StreamParser { 28 class MEDIA_EXPORT StreamParser {
28 public: 29 public:
29 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; 30 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue;
30 31
31 // Map of text track number to the track configuration. 32 // Range of |TrackId| is dependent upon stream parsers. It is currently
32 typedef std::map<int, TextTrackConfig> TextTrackConfigMap; 33 // the key for the buffer's text track config in the applicable
34 // TextTrackConfigMap (which is passed in StreamParser::NewConfigCB), or
35 // 0 for other media types that currently allow at most one track.
36 // WebMTracksParser uses -1 as an invalid text track number.
37 // TODO(wolenetz/acolwell): Change to size_type while fixing stream parsers to
38 // emit validated track configuration and buffer vectors rather than max 1
39 // audio, max 1 video, and N text tracks in a map keyed by
40 // bytestream-specific-ranged track numbers. See http://crbug.com/341581.
41 typedef int TrackId;
33 42
34 // Map of text track number to decode-timestamp-ordered buffers for the track. 43 // Map of text track ID to the track configuration.
35 typedef std::map<int, const BufferQueue> TextBufferQueueMap; 44 typedef std::map<TrackId, TextTrackConfig> TextTrackConfigMap;
45
46 // Map of text track ID to decode-timestamp-ordered buffers for the track.
47 typedef std::map<TrackId, const BufferQueue> TextBufferQueueMap;
36 48
37 StreamParser(); 49 StreamParser();
38 virtual ~StreamParser(); 50 virtual ~StreamParser();
39 51
40 // Indicates completion of parser initialization. 52 // Indicates completion of parser initialization.
41 // First parameter - Indicates initialization success. Set to true if 53 // First parameter - Indicates initialization success. Set to true if
42 // initialization was successful. False if an error 54 // initialization was successful. False if an error
43 // occurred. 55 // occurred.
44 // Second parameter - Indicates the stream duration. Only contains a valid 56 // Second parameter - Indicates the stream duration. Only contains a valid
45 // value if the first parameter is true. 57 // value if the first parameter is true.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 116
105 // Called when there is new data to parse. 117 // Called when there is new data to parse.
106 // 118 //
107 // Returns true if the parse succeeds. 119 // Returns true if the parse succeeds.
108 virtual bool Parse(const uint8* buf, int size) = 0; 120 virtual bool Parse(const uint8* buf, int size) = 0;
109 121
110 private: 122 private:
111 DISALLOW_COPY_AND_ASSIGN(StreamParser); 123 DISALLOW_COPY_AND_ASSIGN(StreamParser);
112 }; 124 };
113 125
126 // Appends to |merged_buffers| the provided buffers in decode-timestamp order.
127 // Any previous contents of |merged_buffers| is assumed to have lower
128 // decode timestamps versus the provided buffers. All provided buffer queues
129 // are assumed to already be in decode-timestamp order.
130 // Returns false if any of the provided audio/video/text buffers are found
131 // to not be in decode timestamp order, or have a decode timestamp less than
132 // the last buffer, if any, in |merged_buffers|. Partial results may exist
133 // in |merged_buffers| in this case. Returns true on success.
134 // No validation of media type within the various buffer queues is done here.
135 // TODO(wolenetz/acolwell): Merge incrementally in parsers to eliminate
136 // subtle issues with tie-breaking. See http://crbug.com/338484.
137 MEDIA_EXPORT bool MergeBufferQueues(
138 const StreamParser::BufferQueue& audio_buffers,
139 const StreamParser::BufferQueue& video_buffers,
140 const StreamParser::TextBufferQueueMap& text_buffers,
141 StreamParser::BufferQueue* merged_buffers);
142
114 } // namespace media 143 } // namespace media
115 144
116 #endif // MEDIA_BASE_STREAM_PARSER_H_ 145 #endif // MEDIA_BASE_STREAM_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/stream_parser.cc » ('j') | media/filters/source_buffer_stream_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698