Chromium Code Reviews| 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> | |
| 9 | |
| 8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 11 #include "base/callback.h" |
| 10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 11 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 12 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
| 13 #include "media/base/stream_parser_buffer.h" | 15 #include "media/base/stream_parser_buffer.h" |
| 14 | 16 |
| 15 namespace media { | 17 namespace media { |
| 16 | 18 |
| 19 class OffsetByteQueue; | |
| 17 class StreamParserBuffer; | 20 class StreamParserBuffer; |
| 18 | 21 |
| 19 namespace mp2t { | 22 namespace mp2t { |
| 20 | 23 |
| 21 class MEDIA_EXPORT EsParser { | 24 class MEDIA_EXPORT EsParser { |
| 22 public: | 25 public: |
| 23 typedef base::Callback<void(scoped_refptr<StreamParserBuffer>)> EmitBufferCB; | 26 typedef base::Callback<void(scoped_refptr<StreamParserBuffer>)> EmitBufferCB; |
| 24 | 27 |
| 25 EsParser() {} | 28 EsParser(); |
| 26 virtual ~EsParser() {} | 29 virtual ~EsParser(); |
| 27 | 30 |
| 28 // ES parsing. | 31 // ES parsing. |
| 29 // Should use kNoTimestamp when a timestamp is not valid. | 32 // Should use kNoTimestamp when a timestamp is not valid. |
| 30 virtual bool Parse(const uint8* buf, int size, | 33 bool Parse(const uint8* buf, int size, |
| 31 base::TimeDelta pts, | 34 base::TimeDelta pts, |
| 32 DecodeTimestamp dts) = 0; | 35 DecodeTimestamp dts); |
| 33 | 36 |
| 34 // Flush any pending buffer. | 37 // Flush any pending buffer. |
| 35 virtual void Flush() = 0; | 38 virtual void Flush() = 0; |
| 36 | 39 |
| 37 // Reset the state of the ES parser. | 40 // Reset the state of the ES parser. |
| 38 virtual void Reset() = 0; | 41 virtual void Reset(); |
| 42 | |
| 43 protected: | |
| 44 struct TimingDesc { | |
| 45 TimingDesc(); | |
| 46 TimingDesc(DecodeTimestamp dts, base::TimeDelta pts); | |
| 47 | |
| 48 DecodeTimestamp dts; | |
| 49 base::TimeDelta pts; | |
| 50 }; | |
| 51 | |
| 52 // Parse ES data from |es_queue_|. | |
| 53 // Return true when successful. | |
| 54 virtual bool ParseFromEsQueue() = 0; | |
| 55 | |
| 56 // Get the timing descriptor that applies to position |es_byte_count| inside | |
|
wolenetz
2014/08/26 23:01:44
nit: Can there be a position in |es_queue_| for wh
damienv1
2014/08/27 16:23:43
There is not necessarily a timing descriptor assoc
| |
| 57 // the ES byte queue. This timing descriptor and all the ones that come before | |
| 58 // (in stream order) are removed from list |timing_desc_list_|. | |
| 59 // If no timing descriptor is found, then the default TimingDesc is returned. | |
| 60 TimingDesc GetTimingDescriptor(int64 es_byte_count); | |
| 61 | |
| 62 // Bytes of the ES stream that have not been emitted yet. | |
| 63 scoped_ptr<media::OffsetByteQueue> es_queue_; | |
| 64 | |
| 65 private: | |
| 66 // Anchor some timing information into the ES queue. | |
| 67 // A timing descriptor associated with a given ES position applies to the | |
| 68 // first access unit that comes at or after this ES position in the queue. | |
| 69 std::list<std::pair<int64, TimingDesc> > timing_desc_list_; | |
|
wolenetz
2014/08/26 23:01:44
lint nit: add #include for pair<>
damienv1
2014/08/27 16:23:43
Done.
| |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(EsParser); | |
| 39 }; | 72 }; |
| 40 | 73 |
| 41 } // namespace mp2t | 74 } // namespace mp2t |
| 42 } // namespace media | 75 } // namespace media |
| 43 | 76 |
| 44 #endif | 77 #endif |
| OLD | NEW |