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
3 // found in the LICENSE file.
5 #ifndef MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_
6 #define MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_
11 #include "base/callback.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h"
15 #include "media/base/audio_decoder_config.h"
16 #include "media/base/media_export.h"
17 #include "media/formats/mp2t/es_parser.h"
20 class AudioTimestampHelper;
22 class OffsetByteQueue;
23 class StreamParserBuffer;
29 class MEDIA_EXPORT EsParserAdts : public EsParser {
31 typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB;
33 EsParserAdts(const NewAudioConfigCB& new_audio_config_cb,
34 const EmitBufferCB& emit_buffer_cb,
35 bool sbr_in_mimetype);
36 virtual ~EsParserAdts();
38 // EsParser implementation.
39 virtual void Flush() OVERRIDE;
44 // EsParser implementation.
45 virtual bool ParseFromEsQueue() OVERRIDE;
46 virtual void ResetInternal() OVERRIDE;
48 // Synchronize the stream on an ADTS syncword (consuming bytes from
49 // |es_queue_| if needed).
50 // Returns true when a full ADTS frame has been found: in that case
51 // |adts_frame| structure is filled up accordingly.
52 // Returns false otherwise (no ADTS syncword found or partial ADTS frame).
53 bool LookForAdtsFrame(AdtsFrame* adts_frame);
55 // Skip an ADTS frame in the ES queue.
56 void SkipAdtsFrame(const AdtsFrame& adts_frame);
58 // Signal any audio configuration change (if any).
59 // Return false if the current audio config is not
60 // a supported ADTS audio config.
61 bool UpdateAudioConfiguration(const uint8* adts_header);
64 // - to signal a new audio configuration,
65 // - to send ES buffers.
66 NewAudioConfigCB new_audio_config_cb_;
67 EmitBufferCB emit_buffer_cb_;
69 // True when AAC SBR extension is signalled in the mimetype
70 // (mp4a.40.5 in the codecs parameter).
71 bool sbr_in_mimetype_;
73 // Interpolated PTS for frames that don't have one.
74 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_;
77 AudioDecoderConfig last_audio_decoder_config_;
79 DISALLOW_COPY_AND_ASSIGN(EsParserAdts);