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_MP4_MP4_STREAM_PARSER_H_ | 5 #ifndef MEDIA_MP4_MP4_STREAM_PARSER_H_ |
6 #define MEDIA_MP4_MP4_STREAM_PARSER_H_ | 6 #define MEDIA_MP4_MP4_STREAM_PARSER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 class MEDIA_EXPORT MP4StreamParser : public StreamParser { | 23 class MEDIA_EXPORT MP4StreamParser : public StreamParser { |
24 public: | 24 public: |
25 MP4StreamParser(bool has_sbr); | 25 MP4StreamParser(bool has_sbr); |
26 virtual ~MP4StreamParser(); | 26 virtual ~MP4StreamParser(); |
27 | 27 |
28 virtual void Init(const InitCB& init_cb, const NewConfigCB& config_cb, | 28 virtual void Init(const InitCB& init_cb, const NewConfigCB& config_cb, |
29 const NewBuffersCB& audio_cb, | 29 const NewBuffersCB& audio_cb, |
30 const NewBuffersCB& video_cb, | 30 const NewBuffersCB& video_cb, |
31 const NeedKeyCB& need_key_cb, | 31 const NeedKeyCB& need_key_cb, |
32 const NewMediaSegmentCB& new_segment_cb) OVERRIDE; | 32 const NewMediaSegmentCB& new_segment_cb, |
| 33 const base::Closure& end_of_segment_cb) OVERRIDE; |
33 virtual void Flush() OVERRIDE; | 34 virtual void Flush() OVERRIDE; |
34 virtual bool Parse(const uint8* buf, int size) OVERRIDE; | 35 virtual bool Parse(const uint8* buf, int size) OVERRIDE; |
35 | 36 |
36 private: | 37 private: |
37 enum State { | 38 enum State { |
38 kWaitingForInit, | 39 kWaitingForInit, |
39 kParsingBoxes, | 40 kParsingBoxes, |
40 kEmittingSamples, | 41 kEmittingSamples, |
41 kError | 42 kError |
42 }; | 43 }; |
(...skipping 13 matching lines...) Expand all Loading... |
56 bool SendAndFlushSamples(BufferQueue* audio_buffers, | 57 bool SendAndFlushSamples(BufferQueue* audio_buffers, |
57 BufferQueue* video_buffers); | 58 BufferQueue* video_buffers); |
58 | 59 |
59 State state_; | 60 State state_; |
60 InitCB init_cb_; | 61 InitCB init_cb_; |
61 NewConfigCB config_cb_; | 62 NewConfigCB config_cb_; |
62 NewBuffersCB audio_cb_; | 63 NewBuffersCB audio_cb_; |
63 NewBuffersCB video_cb_; | 64 NewBuffersCB video_cb_; |
64 NeedKeyCB need_key_cb_; | 65 NeedKeyCB need_key_cb_; |
65 NewMediaSegmentCB new_segment_cb_; | 66 NewMediaSegmentCB new_segment_cb_; |
| 67 base::Closure end_of_segment_cb_; |
66 | 68 |
67 OffsetByteQueue queue_; | 69 OffsetByteQueue queue_; |
68 | 70 |
69 // These two parameters are only valid in the |kEmittingSegments| state. | 71 // These two parameters are only valid in the |kEmittingSegments| state. |
70 // | 72 // |
71 // |moof_head_| is the offset of the start of the most recently parsed moof | 73 // |moof_head_| is the offset of the start of the most recently parsed moof |
72 // block. All byte offsets in sample information are relative to this offset, | 74 // block. All byte offsets in sample information are relative to this offset, |
73 // as mandated by the Media Source spec. | 75 // as mandated by the Media Source spec. |
74 int64 moof_head_; | 76 int64 moof_head_; |
75 // |mdat_tail_| is the stream offset of the end of the current 'mdat' box. | 77 // |mdat_tail_| is the stream offset of the end of the current 'mdat' box. |
76 // Valid iff it is greater than the head of the queue. | 78 // Valid iff it is greater than the head of the queue. |
77 int64 mdat_tail_; | 79 int64 mdat_tail_; |
78 | 80 |
79 scoped_ptr<mp4::Movie> moov_; | 81 scoped_ptr<mp4::Movie> moov_; |
80 scoped_ptr<mp4::TrackRunIterator> runs_; | 82 scoped_ptr<mp4::TrackRunIterator> runs_; |
81 | 83 |
82 bool has_audio_; | 84 bool has_audio_; |
83 bool has_video_; | 85 bool has_video_; |
84 uint32 audio_track_id_; | 86 uint32 audio_track_id_; |
85 uint32 video_track_id_; | 87 uint32 video_track_id_; |
86 bool has_sbr_; | 88 bool has_sbr_; |
87 | 89 |
88 DISALLOW_COPY_AND_ASSIGN(MP4StreamParser); | 90 DISALLOW_COPY_AND_ASSIGN(MP4StreamParser); |
89 }; | 91 }; |
90 | 92 |
91 } // namespace mp4 | 93 } // namespace mp4 |
92 } // namespace media | 94 } // namespace media |
93 | 95 |
94 #endif // MEDIA_MP4_MP4_STREAM_PARSER_H_ | 96 #endif // MEDIA_MP4_MP4_STREAM_PARSER_H_ |
OLD | NEW |