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_ES_PARSER_H_ | 5 #ifndef MEDIA_FORMATS_MP2T_ES_PARSER_H_ |
6 #define MEDIA_FORMATS_MP2T_ES_PARSER_H_ | 6 #define MEDIA_FORMATS_MP2T_ES_PARSER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/basictypes.h" | |
12 #include "base/callback.h" | 11 #include "base/callback.h" |
13 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
14 #include "base/time/time.h" | 13 #include "base/time/time.h" |
15 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
16 #include "media/base/stream_parser_buffer.h" | 15 #include "media/base/stream_parser_buffer.h" |
17 | 16 |
18 namespace media { | 17 namespace media { |
19 | 18 |
20 class OffsetByteQueue; | 19 class OffsetByteQueue; |
21 class StreamParserBuffer; | 20 class StreamParserBuffer; |
22 | 21 |
23 namespace mp2t { | 22 namespace mp2t { |
24 | 23 |
25 class MEDIA_EXPORT EsParser { | 24 class MEDIA_EXPORT EsParser { |
26 public: | 25 public: |
27 typedef base::Callback<void(scoped_refptr<StreamParserBuffer>)> EmitBufferCB; | 26 typedef base::Callback<void(scoped_refptr<StreamParserBuffer>)> EmitBufferCB; |
28 | 27 |
29 EsParser(); | 28 EsParser(); |
30 virtual ~EsParser(); | 29 virtual ~EsParser(); |
31 | 30 |
32 // ES parsing. | 31 // ES parsing. |
33 // Should use kNoTimestamp when a timestamp is not valid. | 32 // Should use kNoTimestamp when a timestamp is not valid. |
34 bool Parse(const uint8* buf, int size, | 33 bool Parse(const uint8_t* buf, |
| 34 int size, |
35 base::TimeDelta pts, | 35 base::TimeDelta pts, |
36 DecodeTimestamp dts); | 36 DecodeTimestamp dts); |
37 | 37 |
38 // Flush any pending buffer. | 38 // Flush any pending buffer. |
39 virtual void Flush() = 0; | 39 virtual void Flush() = 0; |
40 | 40 |
41 // Reset the state of the ES parser. | 41 // Reset the state of the ES parser. |
42 void Reset(); | 42 void Reset(); |
43 | 43 |
44 protected: | 44 protected: |
(...skipping 10 matching lines...) Expand all Loading... |
55 virtual bool ParseFromEsQueue() = 0; | 55 virtual bool ParseFromEsQueue() = 0; |
56 | 56 |
57 // Reset the internal state of the ES parser. | 57 // Reset the internal state of the ES parser. |
58 virtual void ResetInternal() = 0; | 58 virtual void ResetInternal() = 0; |
59 | 59 |
60 // Get the timing descriptor with the largest byte count that is less or | 60 // Get the timing descriptor with the largest byte count that is less or |
61 // equal to |es_byte_count|. | 61 // equal to |es_byte_count|. |
62 // This timing descriptor and all the ones that come before (in stream order) | 62 // This timing descriptor and all the ones that come before (in stream order) |
63 // are removed from list |timing_desc_list_|. | 63 // are removed from list |timing_desc_list_|. |
64 // If no timing descriptor is found, then the default TimingDesc is returned. | 64 // If no timing descriptor is found, then the default TimingDesc is returned. |
65 TimingDesc GetTimingDescriptor(int64 es_byte_count); | 65 TimingDesc GetTimingDescriptor(int64_t es_byte_count); |
66 | 66 |
67 // Bytes of the ES stream that have not been emitted yet. | 67 // Bytes of the ES stream that have not been emitted yet. |
68 scoped_ptr<media::OffsetByteQueue> es_queue_; | 68 scoped_ptr<media::OffsetByteQueue> es_queue_; |
69 | 69 |
70 private: | 70 private: |
71 // Anchor some timing information into the ES queue. | 71 // Anchor some timing information into the ES queue. |
72 // Here are two examples how this timing info is applied according to | 72 // Here are two examples how this timing info is applied according to |
73 // the MPEG-2 TS spec - ISO/IEC 13818: | 73 // the MPEG-2 TS spec - ISO/IEC 13818: |
74 // - "In the case of audio, if a PTS is present in PES packet header it shall | 74 // - "In the case of audio, if a PTS is present in PES packet header it shall |
75 // refer to the first access unit commencing in the PES packet. An audio | 75 // refer to the first access unit commencing in the PES packet. An audio |
76 // access unit commences in a PES packet if the first byte of the audio | 76 // access unit commences in a PES packet if the first byte of the audio |
77 // access unit is present in the PES packet." | 77 // access unit is present in the PES packet." |
78 // - "For AVC video streams conforming to one or more profiles defined | 78 // - "For AVC video streams conforming to one or more profiles defined |
79 // in Annex A of Rec. ITU-T H.264 | ISO/IEC 14496-10 video, if a PTS is | 79 // in Annex A of Rec. ITU-T H.264 | ISO/IEC 14496-10 video, if a PTS is |
80 // present in the PES packet header, it shall refer to the first AVC access | 80 // present in the PES packet header, it shall refer to the first AVC access |
81 // unit that commences in this PES packet. | 81 // unit that commences in this PES packet. |
82 std::list<std::pair<int64, TimingDesc> > timing_desc_list_; | 82 std::list<std::pair<int64_t, TimingDesc>> timing_desc_list_; |
83 | 83 |
84 DISALLOW_COPY_AND_ASSIGN(EsParser); | 84 DISALLOW_COPY_AND_ASSIGN(EsParser); |
85 }; | 85 }; |
86 | 86 |
87 } // namespace mp2t | 87 } // namespace mp2t |
88 } // namespace media | 88 } // namespace media |
89 | 89 |
90 #endif | 90 #endif |
OLD | NEW |