Chromium Code Reviews| Index: media/formats/mp2t/es_parser.cc |
| diff --git a/media/formats/mp2t/es_parser.cc b/media/formats/mp2t/es_parser.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..75eb2b2055e8fb3f4aeed966551b14eb4e872e25 |
| --- /dev/null |
| +++ b/media/formats/mp2t/es_parser.cc |
| @@ -0,0 +1,61 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "media/formats/mp2t/es_parser.h" |
| + |
| +#include "media/formats/common/offset_byte_queue.h" |
| + |
| +namespace media { |
| +namespace mp2t { |
| + |
| +EsParser::TimingDesc::TimingDesc() |
| + : dts(kNoDecodeTimestamp()), |
| + pts(kNoTimestamp()) { |
| +} |
| + |
| +EsParser::TimingDesc::TimingDesc( |
| + DecodeTimestamp dts_in, base::TimeDelta pts_in) |
| + : dts(dts_in), |
| + pts(pts_in) { |
| +} |
| + |
| +EsParser::EsParser() |
| + : es_queue_(new media::OffsetByteQueue()) { |
| +} |
| + |
| +EsParser::~EsParser() { |
| +} |
| + |
| +bool EsParser::Parse(const uint8* buf, int size, |
|
wolenetz
2014/08/26 23:01:44
nit: protect borders: DCHECK(buf) + DCHECK_GT(size
damienv1
2014/08/27 16:23:43
Assertions should be done on variables that are ac
wolenetz
2014/08/27 18:23:02
I have no strong feeling, though if we ever use st
|
| + base::TimeDelta pts, |
| + DecodeTimestamp dts) { |
| + if (pts != kNoTimestamp()) { |
| + // Link the end of the byte queue with the incoming timing descriptor. |
| + TimingDesc timing_desc(dts, pts); |
| + timing_desc_list_.push_back( |
| + std::pair<int64, TimingDesc>(es_queue_->tail(), timing_desc)); |
| + } |
| + |
| + // Add the incoming bytes to the ES queue. |
| + es_queue_->Push(buf, size); |
| + return ParseFromEsQueue(); |
| +} |
| + |
| +void EsParser::Reset() { |
| + es_queue_.reset(new media::OffsetByteQueue()); |
| + timing_desc_list_.clear(); |
| +} |
| + |
| +EsParser::TimingDesc EsParser::GetTimingDescriptor(int64 es_byte_count) { |
| + TimingDesc timing_desc; |
| + while (!timing_desc_list_.empty() && |
| + timing_desc_list_.front().first <= es_byte_count) { |
| + timing_desc = timing_desc_list_.front().second; |
| + timing_desc_list_.pop_front(); |
| + } |
| + return timing_desc; |
| +} |
| + |
| +} // namespace mp2t |
| +} // namespace media |