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

Unified Diff: media/formats/mpeg/mpeg1_audio_stream_parser.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/formats/mpeg/mp3_stream_parser_unittest.cc ('k') | media/formats/mpeg/mpeg1_audio_stream_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/formats/mpeg/mpeg1_audio_stream_parser.h
diff --git a/media/formats/mpeg/mpeg1_audio_stream_parser.h b/media/formats/mpeg/mpeg1_audio_stream_parser.h
new file mode 100644
index 0000000000000000000000000000000000000000..a5f98263b1f0c974575e0a0a3e97850b596d3a56
--- /dev/null
+++ b/media/formats/mpeg/mpeg1_audio_stream_parser.h
@@ -0,0 +1,88 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_FORMATS_MPEG_MPEG1_AUDIO_STREAM_PARSER_H_
+#define MEDIA_FORMATS_MPEG_MPEG1_AUDIO_STREAM_PARSER_H_
+
+#include "base/basictypes.h"
+#include "media/base/media_export.h"
+#include "media/formats/mpeg/mpeg_audio_stream_parser_base.h"
+
+namespace media {
+
+// MPEG1AudioStreamParser handles MPEG-1 audio streams (ISO/IEC 11172-3)
+// as well as the following extensions:
+// - MPEG-2 audio (ISO/IEC 13818-3),
+// - and MPEG2.5 (not an ISO standard).
+class MEDIA_EXPORT MPEG1AudioStreamParser : public MPEGAudioStreamParserBase {
+ public:
+ // Size of an MPEG-1 frame header in bytes.
+ enum {
+ kHeaderSize = 4,
+ };
+
+ // Versions and layers as defined in ISO/IEC 11172-3.
+ enum Version {
+ kVersion1 = 3,
+ kVersion2 = 2,
+ kVersionReserved = 1,
+ kVersion2_5 = 0,
+ };
+
+ enum Layer {
+ kLayer1 = 3,
+ kLayer2 = 2,
+ kLayer3 = 1,
+ kLayerReserved = 0,
+ };
+
+ struct Header {
+ Version version;
+
+ // Layer as defined in ISO/IEC 11172-3 bitstream specification.
+ Layer layer;
+
+ // Frame size in bytes.
+ int frame_size;
+
+ // Sample frequency.
+ int sample_rate;
+
+ // Channel mode as defined in ISO/IEC 11172-3 bitstream specification.
+ int channel_mode;
+
+ // Channel layout.
+ ChannelLayout channel_layout;
+
+ // Number of samples per frame.
+ int sample_count;
+ };
+
+ // Parses the header starting at |data|.
+ // Assumption: size of array |data| should be at least |kHeaderSize|.
+ // Returns false if the header is not valid.
+ static bool ParseHeader(
+ const LogCB& log_cb,
+ const uint8* data,
+ Header* header);
+
+ MPEG1AudioStreamParser();
+ virtual ~MPEG1AudioStreamParser();
+
+ private:
+ // MPEGAudioStreamParserBase overrides.
+ virtual int ParseFrameHeader(const uint8* data,
+ int size,
+ int* frame_size,
+ int* sample_rate,
+ ChannelLayout* channel_layout,
+ int* sample_count,
+ bool* metadata_frame) const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(MPEG1AudioStreamParser);
+};
+
+} // namespace media
+
+#endif // MEDIA_FORMATS_MPEG_MPEG1_AUDIO_STREAM_PARSER_H_
« no previous file with comments | « media/formats/mpeg/mp3_stream_parser_unittest.cc ('k') | media/formats/mpeg/mpeg1_audio_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698