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