| OLD | NEW |
| 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_TS_PACKET_H_ | 5 #ifndef MEDIA_FORMATS_MP2T_TS_PACKET_H_ |
| 6 #define MEDIA_FORMATS_MP2T_TS_PACKET_H_ | 6 #define MEDIA_FORMATS_MP2T_TS_PACKET_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include <stdint.h> |
| 9 |
| 10 #include "base/macros.h" |
| 9 | 11 |
| 10 namespace media { | 12 namespace media { |
| 11 | 13 |
| 12 class BitReader; | 14 class BitReader; |
| 13 | 15 |
| 14 namespace mp2t { | 16 namespace mp2t { |
| 15 | 17 |
| 16 class TsPacket { | 18 class TsPacket { |
| 17 public: | 19 public: |
| 18 static const int kPacketSize = 188; | 20 static const int kPacketSize = 188; |
| 19 | 21 |
| 20 // Return the number of bytes to discard | 22 // Return the number of bytes to discard |
| 21 // to be synchronized on a TS syncword. | 23 // to be synchronized on a TS syncword. |
| 22 static int Sync(const uint8* buf, int size); | 24 static int Sync(const uint8_t* buf, int size); |
| 23 | 25 |
| 24 // Parse a TS packet. | 26 // Parse a TS packet. |
| 25 // Return a TsPacket only when parsing was successful. | 27 // Return a TsPacket only when parsing was successful. |
| 26 // Return NULL otherwise. | 28 // Return NULL otherwise. |
| 27 static TsPacket* Parse(const uint8* buf, int size); | 29 static TsPacket* Parse(const uint8_t* buf, int size); |
| 28 | 30 |
| 29 ~TsPacket(); | 31 ~TsPacket(); |
| 30 | 32 |
| 31 // TS header accessors. | 33 // TS header accessors. |
| 32 bool payload_unit_start_indicator() const { | 34 bool payload_unit_start_indicator() const { |
| 33 return payload_unit_start_indicator_; | 35 return payload_unit_start_indicator_; |
| 34 } | 36 } |
| 35 int pid() const { return pid_; } | 37 int pid() const { return pid_; } |
| 36 int continuity_counter() const { return continuity_counter_; } | 38 int continuity_counter() const { return continuity_counter_; } |
| 37 bool discontinuity_indicator() const { return discontinuity_indicator_; } | 39 bool discontinuity_indicator() const { return discontinuity_indicator_; } |
| 38 bool random_access_indicator() const { return random_access_indicator_; } | 40 bool random_access_indicator() const { return random_access_indicator_; } |
| 39 | 41 |
| 40 // Return the offset and the size of the payload. | 42 // Return the offset and the size of the payload. |
| 41 const uint8* payload() const { return payload_; } | 43 const uint8_t* payload() const { return payload_; } |
| 42 int payload_size() const { return payload_size_; } | 44 int payload_size() const { return payload_size_; } |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 TsPacket(); | 47 TsPacket(); |
| 46 | 48 |
| 47 // Parse an Mpeg2 TS header. | 49 // Parse an Mpeg2 TS header. |
| 48 // The buffer size should be at least |kPacketSize| | 50 // The buffer size should be at least |kPacketSize| |
| 49 bool ParseHeader(const uint8* buf); | 51 bool ParseHeader(const uint8_t* buf); |
| 50 bool ParseAdaptationField(BitReader* bit_reader, | 52 bool ParseAdaptationField(BitReader* bit_reader, |
| 51 int adaptation_field_length); | 53 int adaptation_field_length); |
| 52 | 54 |
| 53 // Size of the payload. | 55 // Size of the payload. |
| 54 const uint8* payload_; | 56 const uint8_t* payload_; |
| 55 int payload_size_; | 57 int payload_size_; |
| 56 | 58 |
| 57 // TS header. | 59 // TS header. |
| 58 bool payload_unit_start_indicator_; | 60 bool payload_unit_start_indicator_; |
| 59 int pid_; | 61 int pid_; |
| 60 int continuity_counter_; | 62 int continuity_counter_; |
| 61 | 63 |
| 62 // Params from the adaptation field. | 64 // Params from the adaptation field. |
| 63 bool discontinuity_indicator_; | 65 bool discontinuity_indicator_; |
| 64 bool random_access_indicator_; | 66 bool random_access_indicator_; |
| 65 | 67 |
| 66 DISALLOW_COPY_AND_ASSIGN(TsPacket); | 68 DISALLOW_COPY_AND_ASSIGN(TsPacket); |
| 67 }; | 69 }; |
| 68 | 70 |
| 69 } // namespace mp2t | 71 } // namespace mp2t |
| 70 } // namespace media | 72 } // namespace media |
| 71 | 73 |
| 72 #endif | 74 #endif |
| 73 | 75 |
| OLD | NEW |