blob: c57b79b0b6df5df388b4c947749315d05cc1f39a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// 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,
base::TimeDelta pts,
DecodeTimestamp dts) {
DCHECK(buf);
DCHECK_GT(size, 0);
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();
ResetInternal();
}
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
|