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

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