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

Unified Diff: media/mpeg2/es_parser_adts.h

Issue 23566013: Mpeg2 TS stream parser for media source. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
Index: media/mpeg2/es_parser_adts.h
diff --git a/media/mpeg2/es_parser_adts.h b/media/mpeg2/es_parser_adts.h
new file mode 100644
index 0000000000000000000000000000000000000000..b0fa2fdc319d7b9af2b8eb2d875f8c33d5aed68a
--- /dev/null
+++ b/media/mpeg2/es_parser_adts.h
@@ -0,0 +1,83 @@
+// Copyright (c) 2013 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_MPEG2_ES_PARSER_ADTS_H_
+#define MEDIA_MPEG2_ES_PARSER_ADTS_H_
+
+#include <list>
+#include <vector>
acolwell GONE FROM CHROMIUM 2013/09/05 18:29:10 Add #include <utility> for std::pair
damienv1 2013/09/09 23:29:45 Done.
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "base/time/time.h"
+#include "media/base/byte_queue.h"
+#include "media/mpeg2/es_parser.h"
+
+namespace media {
+class BitReader;
+class AudioDecoderConfig;
+class StreamParserBuffer;
+}
+
+namespace media {
+namespace mpeg2ts {
+
+class EsParserAdts : public EsParser {
+ public:
+ typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB;
+ typedef base::Callback<void(scoped_refptr<StreamParserBuffer>)> EmitBufferCB;
+
+ EsParserAdts(NewAudioConfigCB new_audio_config_cb,
+ EmitBufferCB emit_buffer_cb);
+ virtual ~EsParserAdts();
+
+ // EsParser implementation.
+ virtual void Parse(const uint8* buf, int size,
+ base::TimeDelta pts,
+ base::TimeDelta dts) OVERRIDE;
+ virtual void Flush() OVERRIDE;
+
+ private:
+ // Used to link a PTS with a byte position in the ES stream.
+ typedef std::pair<int, base::TimeDelta> EsPts;
+ typedef std::list<EsPts> EsPtsList;
+
+ // Signal any audio configuration change (if any).
+ void UpdateAudioConfiguration(const uint8* adts_header);
+
+ // Discard some bytes from the ES stream.
+ void DiscardEs(int nbytes);
+
+ // Callbacks:
+ // - to signal a new audio configuration,
+ // - to send ES buffers.
+ NewAudioConfigCB new_audio_config_cb_;
+ EmitBufferCB emit_buffer_cb_;
+
+ // Bytes of the ES stream that have not been emitted yet.
+ ByteQueue es_byte_queue_;
+
+ // List of PTS associated with a position in the ES stream.
+ EsPtsList pts_list_;
+
+ // Interpolated PTS for frames that don't have one.
+ base::TimeDelta estimated_pts_;
+
+ bool first_frame_;
+ base::TimeDelta last_frame_pts_;
+
+ // Last audio config.
+ bool is_audio_config_known_;
+ int sampling_frequency_;
+ int channel_configuration_;
+
+ DISALLOW_COPY_AND_ASSIGN(EsParserAdts);
+};
+
+} // namespace mpeg2ts
+} // namespace media
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698