| 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 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 pts(pts_in) { | 21 pts(pts_in) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 EsParser::EsParser() | 24 EsParser::EsParser() |
| 25 : es_queue_(new media::OffsetByteQueue()) { | 25 : es_queue_(new media::OffsetByteQueue()) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 EsParser::~EsParser() { | 28 EsParser::~EsParser() { |
| 29 } | 29 } |
| 30 | 30 |
| 31 bool EsParser::Parse(const uint8* buf, int size, | 31 bool EsParser::Parse(const uint8_t* buf, |
| 32 int size, |
| 32 base::TimeDelta pts, | 33 base::TimeDelta pts, |
| 33 DecodeTimestamp dts) { | 34 DecodeTimestamp dts) { |
| 34 DCHECK(buf); | 35 DCHECK(buf); |
| 35 DCHECK_GT(size, 0); | 36 DCHECK_GT(size, 0); |
| 36 | 37 |
| 37 if (pts != kNoTimestamp()) { | 38 if (pts != kNoTimestamp()) { |
| 38 // Link the end of the byte queue with the incoming timing descriptor. | 39 // Link the end of the byte queue with the incoming timing descriptor. |
| 39 TimingDesc timing_desc(dts, pts); | 40 TimingDesc timing_desc(dts, pts); |
| 40 timing_desc_list_.push_back( | 41 timing_desc_list_.push_back( |
| 41 std::pair<int64, TimingDesc>(es_queue_->tail(), timing_desc)); | 42 std::pair<int64_t, TimingDesc>(es_queue_->tail(), timing_desc)); |
| 42 } | 43 } |
| 43 | 44 |
| 44 // Add the incoming bytes to the ES queue. | 45 // Add the incoming bytes to the ES queue. |
| 45 es_queue_->Push(buf, size); | 46 es_queue_->Push(buf, size); |
| 46 return ParseFromEsQueue(); | 47 return ParseFromEsQueue(); |
| 47 } | 48 } |
| 48 | 49 |
| 49 void EsParser::Reset() { | 50 void EsParser::Reset() { |
| 50 es_queue_.reset(new media::OffsetByteQueue()); | 51 es_queue_.reset(new media::OffsetByteQueue()); |
| 51 timing_desc_list_.clear(); | 52 timing_desc_list_.clear(); |
| 52 ResetInternal(); | 53 ResetInternal(); |
| 53 } | 54 } |
| 54 | 55 |
| 55 EsParser::TimingDesc EsParser::GetTimingDescriptor(int64 es_byte_count) { | 56 EsParser::TimingDesc EsParser::GetTimingDescriptor(int64_t es_byte_count) { |
| 56 TimingDesc timing_desc; | 57 TimingDesc timing_desc; |
| 57 while (!timing_desc_list_.empty() && | 58 while (!timing_desc_list_.empty() && |
| 58 timing_desc_list_.front().first <= es_byte_count) { | 59 timing_desc_list_.front().first <= es_byte_count) { |
| 59 timing_desc = timing_desc_list_.front().second; | 60 timing_desc = timing_desc_list_.front().second; |
| 60 timing_desc_list_.pop_front(); | 61 timing_desc_list_.pop_front(); |
| 61 } | 62 } |
| 62 return timing_desc; | 63 return timing_desc; |
| 63 } | 64 } |
| 64 | 65 |
| 65 } // namespace mp2t | 66 } // namespace mp2t |
| 66 } // namespace media | 67 } // namespace media |
| OLD | NEW |