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

Unified Diff: media/mp2t/ts_packet.h

Issue 23566013: Mpeg2 TS stream parser for media source. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clang warning fix 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
« no previous file with comments | « media/mp2t/mp2t_stream_parser_unittest.cc ('k') | media/mp2t/ts_packet.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mp2t/ts_packet.h
diff --git a/media/mp2t/ts_packet.h b/media/mp2t/ts_packet.h
new file mode 100644
index 0000000000000000000000000000000000000000..99df82dac1aed1931a4139db0ffc57407ee539f6
--- /dev/null
+++ b/media/mp2t/ts_packet.h
@@ -0,0 +1,73 @@
+// 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_MP2T_TS_PACKET_H_
+#define MEDIA_MP2T_TS_PACKET_H_
+
+#include "base/basictypes.h"
+
+namespace media {
+
+class BitReader;
+
+namespace mp2t {
+
+class TsPacket {
+ public:
+ static const int kPacketSize = 188;
+
+ // Return the number of bytes to discard
+ // to be synchronized on a TS syncword.
+ static int Sync(const uint8* buf, int size);
+
+ // Parse a TS packet.
+ // Return a TsPacket only when parsing was successful.
+ // Return NULL otherwise.
+ static TsPacket* Parse(const uint8* buf, int size);
+
+ ~TsPacket();
+
+ // TS header accessors.
+ bool payload_unit_start_indicator() const {
+ return payload_unit_start_indicator_;
+ }
+ int pid() const { return pid_; }
+ int continuity_counter() const { return continuity_counter_; }
+ bool discontinuity_indicator() const { return discontinuity_indicator_; }
+ bool random_access_indicator() const { return random_access_indicator_; }
+
+ // Return the offset and the size of the payload.
+ const uint8* payload() const { return payload_; }
+ int payload_size() const { return payload_size_; }
+
+ private:
+ TsPacket();
+
+ // Parse an Mpeg2 TS header.
+ // The buffer size should be at least |kPacketSize|
+ bool ParseHeader(const uint8* buf);
+ bool ParseAdaptationField(BitReader* bit_reader,
+ int adaptation_field_length);
+
+ // Size of the payload.
+ const uint8* payload_;
+ int payload_size_;
+
+ // TS header.
+ bool payload_unit_start_indicator_;
+ int pid_;
+ int continuity_counter_;
+
+ // Params from the adaptation field.
+ bool discontinuity_indicator_;
+ bool random_access_indicator_;
+
+ DISALLOW_COPY_AND_ASSIGN(TsPacket);
+};
+
+} // namespace mp2t
+} // namespace media
+
+#endif
+
« no previous file with comments | « media/mp2t/mp2t_stream_parser_unittest.cc ('k') | media/mp2t/ts_packet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698