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 #include "media/formats/mp2t/es_parser.h" | 5 #include "media/formats/mp2t/es_parser.h" |
6 | 6 |
7 #include "media/base/timestamp_constants.h" | 7 #include "media/base/timestamp_constants.h" |
8 #include "media/formats/common/offset_byte_queue.h" | 8 #include "media/formats/common/offset_byte_queue.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 namespace mp2t { | 11 namespace mp2t { |
12 | 12 |
13 EsParser::TimingDesc::TimingDesc() | 13 EsParser::TimingDesc::TimingDesc() |
14 : dts(kNoDecodeTimestamp()), | 14 : dts(kNoDecodeTimestamp()), pts(kNoTimestamp) {} |
mmoroz
2016/07/19 08:50:33
Shouldn't |kNoDecodeTimestamp()| become |kNoDecode
| |
15 pts(kNoTimestamp()) { | |
16 } | |
17 | 15 |
18 EsParser::TimingDesc::TimingDesc( | 16 EsParser::TimingDesc::TimingDesc( |
19 DecodeTimestamp dts_in, base::TimeDelta pts_in) | 17 DecodeTimestamp dts_in, base::TimeDelta pts_in) |
20 : dts(dts_in), | 18 : dts(dts_in), |
21 pts(pts_in) { | 19 pts(pts_in) { |
22 } | 20 } |
23 | 21 |
24 EsParser::EsParser() | 22 EsParser::EsParser() |
25 : es_queue_(new media::OffsetByteQueue()) { | 23 : es_queue_(new media::OffsetByteQueue()) { |
26 } | 24 } |
27 | 25 |
28 EsParser::~EsParser() { | 26 EsParser::~EsParser() { |
29 } | 27 } |
30 | 28 |
31 bool EsParser::Parse(const uint8_t* buf, | 29 bool EsParser::Parse(const uint8_t* buf, |
32 int size, | 30 int size, |
33 base::TimeDelta pts, | 31 base::TimeDelta pts, |
34 DecodeTimestamp dts) { | 32 DecodeTimestamp dts) { |
35 DCHECK(buf); | 33 DCHECK(buf); |
36 DCHECK_GT(size, 0); | 34 DCHECK_GT(size, 0); |
37 | 35 |
38 if (pts != kNoTimestamp()) { | 36 if (pts != kNoTimestamp) { |
39 // Link the end of the byte queue with the incoming timing descriptor. | 37 // Link the end of the byte queue with the incoming timing descriptor. |
40 TimingDesc timing_desc(dts, pts); | 38 TimingDesc timing_desc(dts, pts); |
41 timing_desc_list_.push_back( | 39 timing_desc_list_.push_back( |
42 std::pair<int64_t, TimingDesc>(es_queue_->tail(), timing_desc)); | 40 std::pair<int64_t, TimingDesc>(es_queue_->tail(), timing_desc)); |
43 } | 41 } |
44 | 42 |
45 // Add the incoming bytes to the ES queue. | 43 // Add the incoming bytes to the ES queue. |
46 es_queue_->Push(buf, size); | 44 es_queue_->Push(buf, size); |
47 return ParseFromEsQueue(); | 45 return ParseFromEsQueue(); |
48 } | 46 } |
49 | 47 |
50 void EsParser::Reset() { | 48 void EsParser::Reset() { |
51 es_queue_.reset(new media::OffsetByteQueue()); | 49 es_queue_.reset(new media::OffsetByteQueue()); |
52 timing_desc_list_.clear(); | 50 timing_desc_list_.clear(); |
53 ResetInternal(); | 51 ResetInternal(); |
54 } | 52 } |
55 | 53 |
56 EsParser::TimingDesc EsParser::GetTimingDescriptor(int64_t es_byte_count) { | 54 EsParser::TimingDesc EsParser::GetTimingDescriptor(int64_t es_byte_count) { |
57 TimingDesc timing_desc; | 55 TimingDesc timing_desc; |
58 while (!timing_desc_list_.empty() && | 56 while (!timing_desc_list_.empty() && |
59 timing_desc_list_.front().first <= es_byte_count) { | 57 timing_desc_list_.front().first <= es_byte_count) { |
60 timing_desc = timing_desc_list_.front().second; | 58 timing_desc = timing_desc_list_.front().second; |
61 timing_desc_list_.pop_front(); | 59 timing_desc_list_.pop_front(); |
62 } | 60 } |
63 return timing_desc; | 61 return timing_desc; |
64 } | 62 } |
65 | 63 |
66 } // namespace mp2t | 64 } // namespace mp2t |
67 } // namespace media | 65 } // namespace media |
OLD | NEW |