Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / media / formats / mpeg / mpeg1_audio_stream_parser.h
blob3b299a105bd07b952abd7d2d94d8f6d18293b8d1
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_MPEG_MPEG1_AUDIO_STREAM_PARSER_H_
6 #define MEDIA_FORMATS_MPEG_MPEG1_AUDIO_STREAM_PARSER_H_
8 #include "base/basictypes.h"
9 #include "media/base/media_export.h"
10 #include "media/formats/mpeg/mpeg_audio_stream_parser_base.h"
12 namespace media {
14 // MPEG1AudioStreamParser handles MPEG-1 audio streams (ISO/IEC 11172-3)
15 // as well as the following extensions:
16 // - MPEG-2 audio (ISO/IEC 13818-3),
17 // - and MPEG2.5 (not an ISO standard).
18 class MEDIA_EXPORT MPEG1AudioStreamParser : public MPEGAudioStreamParserBase {
19 public:
20 // Size of an MPEG-1 frame header in bytes.
21 enum {
22 kHeaderSize = 4,
25 // Versions and layers as defined in ISO/IEC 11172-3.
26 enum Version {
27 kVersion1 = 3,
28 kVersion2 = 2,
29 kVersionReserved = 1,
30 kVersion2_5 = 0,
33 enum Layer {
34 kLayer1 = 3,
35 kLayer2 = 2,
36 kLayer3 = 1,
37 kLayerReserved = 0,
40 struct Header {
41 Version version;
43 // Layer as defined in ISO/IEC 11172-3 bitstream specification.
44 Layer layer;
46 // Frame size in bytes.
47 int frame_size;
49 // Sample frequency.
50 int sample_rate;
52 // Channel mode as defined in ISO/IEC 11172-3 bitstream specification.
53 int channel_mode;
55 // Channel layout.
56 ChannelLayout channel_layout;
58 // Number of samples per frame.
59 int sample_count;
62 // Parses the header starting at |data|.
63 // Assumption: size of array |data| should be at least |kHeaderSize|.
64 // Returns false if the header is not valid.
65 static bool ParseHeader(const scoped_refptr<MediaLog>& media_log,
66 const uint8* data,
67 Header* header);
69 MPEG1AudioStreamParser();
70 ~MPEG1AudioStreamParser() override;
72 private:
73 // MPEGAudioStreamParserBase overrides.
74 int ParseFrameHeader(const uint8* data,
75 int size,
76 int* frame_size,
77 int* sample_rate,
78 ChannelLayout* channel_layout,
79 int* sample_count,
80 bool* metadata_frame) const override;
82 DISALLOW_COPY_AND_ASSIGN(MPEG1AudioStreamParser);
85 } // namespace media
87 #endif // MEDIA_FORMATS_MPEG_MPEG1_AUDIO_STREAM_PARSER_H_