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

Side by Side Diff: media/formats/mp2t/es_parser_mpeg1audio.h

Issue 506943003: Support MPEG1 audio in the MPEG2-TS stream parser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments from patch set #5. Created 6 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 | Annotate | Revision Log
OLDNEW
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_MPEG1AUDIO_H_
6 #define MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_ 6 #define MEDIA_FORMATS_MP2T_ES_PARSER_MPEG1AUDIO_H_
7 7
8 #include <list> 8 #include <list>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "media/base/audio_decoder_config.h" 15 #include "media/base/audio_decoder_config.h"
16 #include "media/base/media_export.h" 16 #include "media/base/media_export.h"
17 #include "media/base/media_log.h"
17 #include "media/formats/mp2t/es_parser.h" 18 #include "media/formats/mp2t/es_parser.h"
18 19
19 namespace media { 20 namespace media {
20 class AudioTimestampHelper; 21 class AudioTimestampHelper;
21 class BitReader; 22 class BitReader;
22 class OffsetByteQueue; 23 class OffsetByteQueue;
23 class StreamParserBuffer; 24 class StreamParserBuffer;
24 } 25 }
25 26
26 namespace media { 27 namespace media {
27 namespace mp2t { 28 namespace mp2t {
28 29
29 class MEDIA_EXPORT EsParserAdts : public EsParser { 30 class MEDIA_EXPORT EsParserMpeg1Audio : public EsParser {
30 public: 31 public:
31 typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB; 32 typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB;
32 33
33 EsParserAdts(const NewAudioConfigCB& new_audio_config_cb, 34 EsParserMpeg1Audio(const NewAudioConfigCB& new_audio_config_cb,
34 const EmitBufferCB& emit_buffer_cb, 35 const EmitBufferCB& emit_buffer_cb,
35 bool sbr_in_mimetype); 36 const LogCB& log_cb);
36 virtual ~EsParserAdts(); 37 virtual ~EsParserMpeg1Audio();
37 38
38 // EsParser implementation. 39 // EsParser implementation.
39 virtual void Flush() OVERRIDE; 40 virtual void Flush() OVERRIDE;
40 41
41 private: 42 private:
42 struct AdtsFrame; 43 // Used to link a PTS with a byte position in the ES stream.
44 typedef std::pair<int64, base::TimeDelta> EsPts;
45 typedef std::list<EsPts> EsPtsList;
46
47 struct Mpeg1AudioFrame;
43 48
44 // EsParser implementation. 49 // EsParser implementation.
45 virtual bool ParseFromEsQueue() OVERRIDE; 50 virtual bool ParseFromEsQueue() OVERRIDE;
46 virtual void ResetInternal() OVERRIDE; 51 virtual void ResetInternal() OVERRIDE;
47 52
48 // Synchronize the stream on an ADTS syncword (consuming bytes from 53 // Synchronize the stream on a Mpeg1 audio syncword (consuming bytes from
49 // |es_queue_| if needed). 54 // |es_queue_| if needed).
50 // Returns true when a full ADTS frame has been found: in that case 55 // Returns true when a full Mpeg1 audio frame has been found: in that case
51 // |adts_frame| structure is filled up accordingly. 56 // |mpeg1audio_frame| structure is filled up accordingly.
52 // Returns false otherwise (no ADTS syncword found or partial ADTS frame). 57 // Returns false otherwise (no Mpeg1 audio syncword found or partial Mpeg1
53 bool LookForAdtsFrame(AdtsFrame* adts_frame); 58 // audio frame).
54 59 bool LookForMpeg1AudioFrame(Mpeg1AudioFrame* mpeg1audio_frame);
55 // Skip an ADTS frame in the ES queue.
56 void SkipAdtsFrame(const AdtsFrame& adts_frame);
57 60
58 // Signal any audio configuration change (if any). 61 // Signal any audio configuration change (if any).
59 // Return false if the current audio config is not 62 // Return false if the current audio config is not
60 // a supported ADTS audio config. 63 // a supported Mpeg1 audio config.
61 bool UpdateAudioConfiguration(const uint8* adts_header); 64 bool UpdateAudioConfiguration(const uint8* mpeg1audio_header);
65
66 void SkipMpeg1AudioFrame(const Mpeg1AudioFrame& mpeg1audio_frame);
67
68 LogCB log_cb_;
62 69
63 // Callbacks: 70 // Callbacks:
64 // - to signal a new audio configuration, 71 // - to signal a new audio configuration,
65 // - to send ES buffers. 72 // - to send ES buffers.
66 NewAudioConfigCB new_audio_config_cb_; 73 NewAudioConfigCB new_audio_config_cb_;
67 EmitBufferCB emit_buffer_cb_; 74 EmitBufferCB emit_buffer_cb_;
68 75
69 // True when AAC SBR extension is signalled in the mimetype
70 // (mp4a.40.5 in the codecs parameter).
71 bool sbr_in_mimetype_;
72
73 // Interpolated PTS for frames that don't have one. 76 // Interpolated PTS for frames that don't have one.
74 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; 77 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_;
75 78
76 // Last audio config. 79 // Last audio config.
77 AudioDecoderConfig last_audio_decoder_config_; 80 AudioDecoderConfig last_audio_decoder_config_;
78 81
79 DISALLOW_COPY_AND_ASSIGN(EsParserAdts); 82 DISALLOW_COPY_AND_ASSIGN(EsParserMpeg1Audio);
80 }; 83 };
81 84
82 } // namespace mp2t 85 } // namespace mp2t
83 } // namespace media 86 } // namespace media
84 87
85 #endif 88 #endif // MEDIA_FORMATS_MP2T_ES_PARSER_MPEG1AUDIO_H_
OLDNEW
« no previous file with comments | « media/formats/mp2t/es_parser_adts_unittest.cc ('k') | media/formats/mp2t/es_parser_mpeg1audio.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698