OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_FORMATS_MP2T_ES_PARSER_ADTS_H_ | 5 #ifndef MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_ |
6 #define MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_ | 6 #define MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 class MEDIA_EXPORT EsParserAdts : public EsParser { | 29 class MEDIA_EXPORT EsParserAdts : public EsParser { |
30 public: | 30 public: |
31 typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB; | 31 typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB; |
32 | 32 |
33 EsParserAdts(const NewAudioConfigCB& new_audio_config_cb, | 33 EsParserAdts(const NewAudioConfigCB& new_audio_config_cb, |
34 const EmitBufferCB& emit_buffer_cb, | 34 const EmitBufferCB& emit_buffer_cb, |
35 bool sbr_in_mimetype); | 35 bool sbr_in_mimetype); |
36 virtual ~EsParserAdts(); | 36 virtual ~EsParserAdts(); |
37 | 37 |
38 // EsParser implementation. | 38 // EsParser implementation. |
39 virtual bool Parse(const uint8* buf, int size, | |
40 base::TimeDelta pts, | |
41 DecodeTimestamp dts) OVERRIDE; | |
42 virtual void Flush() OVERRIDE; | 39 virtual void Flush() OVERRIDE; |
43 virtual void Reset() OVERRIDE; | |
44 | 40 |
45 private: | 41 private: |
46 // Used to link a PTS with a byte position in the ES stream. | 42 struct AdtsFrame; |
47 typedef std::pair<int64, base::TimeDelta> EsPts; | |
48 typedef std::list<EsPts> EsPtsList; | |
49 | 43 |
50 struct AdtsFrame; | 44 // EsParser implementation. |
| 45 virtual bool ParseFromEsQueue() OVERRIDE; |
| 46 virtual void ResetInternal() OVERRIDE; |
51 | 47 |
52 // Synchronize the stream on an ADTS syncword (consuming bytes from | 48 // Synchronize the stream on an ADTS syncword (consuming bytes from |
53 // |es_queue_| if needed). | 49 // |es_queue_| if needed). |
54 // Returns true when a full ADTS frame has been found: in that case | 50 // Returns true when a full ADTS frame has been found: in that case |
55 // |adts_frame| structure is filled up accordingly. | 51 // |adts_frame| structure is filled up accordingly. |
56 // Returns false otherwise (no ADTS syncword found or partial ADTS frame). | 52 // Returns false otherwise (no ADTS syncword found or partial ADTS frame). |
57 bool LookForAdtsFrame(AdtsFrame* adts_frame); | 53 bool LookForAdtsFrame(AdtsFrame* adts_frame); |
58 | 54 |
59 // Skip an ADTS frame in the ES queue. | 55 // Skip an ADTS frame in the ES queue. |
60 void SkipAdtsFrame(const AdtsFrame& adts_frame); | 56 void SkipAdtsFrame(const AdtsFrame& adts_frame); |
61 | 57 |
62 // Signal any audio configuration change (if any). | 58 // Signal any audio configuration change (if any). |
63 // Return false if the current audio config is not | 59 // Return false if the current audio config is not |
64 // a supported ADTS audio config. | 60 // a supported ADTS audio config. |
65 bool UpdateAudioConfiguration(const uint8* adts_header); | 61 bool UpdateAudioConfiguration(const uint8* adts_header); |
66 | 62 |
67 // Callbacks: | 63 // Callbacks: |
68 // - to signal a new audio configuration, | 64 // - to signal a new audio configuration, |
69 // - to send ES buffers. | 65 // - to send ES buffers. |
70 NewAudioConfigCB new_audio_config_cb_; | 66 NewAudioConfigCB new_audio_config_cb_; |
71 EmitBufferCB emit_buffer_cb_; | 67 EmitBufferCB emit_buffer_cb_; |
72 | 68 |
73 // True when AAC SBR extension is signalled in the mimetype | 69 // True when AAC SBR extension is signalled in the mimetype |
74 // (mp4a.40.5 in the codecs parameter). | 70 // (mp4a.40.5 in the codecs parameter). |
75 bool sbr_in_mimetype_; | 71 bool sbr_in_mimetype_; |
76 | 72 |
77 // Bytes of the ES stream that have not been emitted yet. | |
78 scoped_ptr<media::OffsetByteQueue> es_queue_; | |
79 | |
80 // List of PTS associated with a position in the ES stream. | |
81 EsPtsList pts_list_; | |
82 | |
83 // Interpolated PTS for frames that don't have one. | 73 // Interpolated PTS for frames that don't have one. |
84 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; | 74 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; |
85 | 75 |
86 // Last audio config. | 76 // Last audio config. |
87 AudioDecoderConfig last_audio_decoder_config_; | 77 AudioDecoderConfig last_audio_decoder_config_; |
88 | 78 |
89 DISALLOW_COPY_AND_ASSIGN(EsParserAdts); | 79 DISALLOW_COPY_AND_ASSIGN(EsParserAdts); |
90 }; | 80 }; |
91 | 81 |
92 } // namespace mp2t | 82 } // namespace mp2t |
93 } // namespace media | 83 } // namespace media |
94 | 84 |
95 #endif | 85 #endif |
OLD | NEW |