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

Side by Side Diff: media/mpeg2/mpeg2ts_stream_parser.h

Issue 23566013: Mpeg2 TS stream parser for media source. (Closed) Base URL: https://chromium.googlesource.com/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_MPEG2_MPEG2TS_STREAM_PARSER_H_
6 #define MEDIA_MPEG2_MPEG2TS_STREAM_PARSER_H_
7
8 #include <list>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/stl_util.h"
13 #include "media/base/media_export.h"
14 #include "media/base/stream_parser.h"
15
16 namespace media {
17
18 class AudioDecoderConfig;
19 class StreamParserBuffer;
20 class VideoDecoderConfig;
21
22 namespace mpeg2ts {
23
24 class PidState;
25
26 class MEDIA_EXPORT Mpeg2TsStreamParser : public StreamParser {
27 public:
28 Mpeg2TsStreamParser();
29 virtual ~Mpeg2TsStreamParser();
30
31 // StreamParser implementation.
32 virtual void Init(const InitCB& init_cb,
33 const NewConfigCB& config_cb,
34 const NewBuffersCB& new_buffers_cb,
35 const NewTextBuffersCB& text_cb,
36 const NeedKeyCB& need_key_cb,
37 const AddTextTrackCB& add_text_track_cb,
38 const NewMediaSegmentCB& new_segment_cb,
39 const base::Closure& end_of_segment_cb,
40 const LogCB& log_cb) OVERRIDE;
41 virtual void Flush() OVERRIDE;
42 virtual bool Parse(const uint8* buf, int size) OVERRIDE;
43
44 private:
45 typedef std::map<int, PidState*> PidMap;
46
47 void RegisterPmt(int program_number, int pmt_pid);
acolwell GONE FROM CHROMIUM 2013/08/29 20:44:24 nit: Docs for all these methods.
damienv1 2013/09/04 01:37:13 Done.
48 void RegisterPes(int pmt_pid, int pes_pid, int stream_type);
49
50 void OnVideoConfigChanged(int pes_pid,
51 const VideoDecoderConfig& video_decoder_config);
52 void OnAudioConfigChanged(int pes_pid,
53 const AudioDecoderConfig& audio_decoder_config);
54 void OnAudioVideoConfigChanged();
55 void OnEmitAudioBuffer(
56 int pes_pid,
57 scoped_refptr<StreamParserBuffer> stream_parser_buffer);
58 void OnEmitVideoBuffer(
59 int pes_pid,
60 scoped_refptr<StreamParserBuffer> stream_parser_buffer);
61 void EmitRemainingBuffers();
62 void StartSegmentIfNeeded();
63
64 // List of callbacks.
65 InitCB init_cb_;
66 NewConfigCB config_cb_;
67 NewBuffersCB new_buffers_cb_;
68 NeedKeyCB need_key_cb_;
69 NewMediaSegmentCB new_segment_cb_;
70 base::Closure end_of_segment_cb_;
71 LogCB log_cb_;
72
73 std::vector<uint8> ts_buffer_;
74
75 // List of program numbers and the corresponding PIDs.
76 std::map<int, std::list<int> > programs_;
77
78 // List of PIDs and their state.
79 PidMap pids_;
80 STLValueDeleter<PidMap> pids_deleter_;
acolwell GONE FROM CHROMIUM 2013/08/29 20:44:24 nit: This seems unnecessary. Just put a call to ST
damienv1 2013/09/04 01:37:13 Done.
81
82 // Selected audio and video PIDs.
83 int selected_pmt_pid_;
84 int selected_audio_pid_;
85 int selected_video_pid_;
86
87 // Audio & video config have to be sent all together.
88 // Remember the audio and video configs.
89 scoped_ptr<AudioDecoderConfig> audio_config_;
90 scoped_ptr<VideoDecoderConfig> video_config_;
91
92 // Pending audio & video buffers.
93 StreamParser::BufferQueue audio_buffer_queue_;
94 StreamParser::BufferQueue video_buffer_queue_;
95
96 // Whether init_cb_ has been invoked.
acolwell GONE FROM CHROMIUM 2013/08/29 20:44:24 nit: References to variables should have || around
damienv1 2013/09/04 01:37:13 Done.
97 // i.e. whether the stream parser is initialized
98 // from the ChunkDemuxer perspective.
acolwell GONE FROM CHROMIUM 2013/08/29 20:44:24 nit: You shouldn't refer to ChunkDemuxer here. s/t
damienv1 2013/09/04 01:37:13 Done.
99 bool is_initialized_;
100
101 // Indicate whether a segment was started.
102 bool segment_started_;
103 base::TimeDelta time_offset_;
104
105 DISALLOW_COPY_AND_ASSIGN(Mpeg2TsStreamParser);
106 };
107
108 } // namespace mpeg2ts
109 } // namespace media
110
111 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698