Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: media/formats/mp2t/es_parser.cc

Issue 497203004: Mpeg2 TS parser: Es parsing using an ES byte queue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add DCHECKs. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/formats/mp2t/es_parser.h ('k') | media/formats/mp2t/es_parser_adts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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,
31 base::TimeDelta pts,
32 DecodeTimestamp dts) {
33 DCHECK(buf);
34 DCHECK_GT(size, 0);
35
36 if (pts != kNoTimestamp()) {
37 // Link the end of the byte queue with the incoming timing descriptor.
38 TimingDesc timing_desc(dts, pts);
39 timing_desc_list_.push_back(
40 std::pair<int64, TimingDesc>(es_queue_->tail(), timing_desc));
41 }
42
43 // Add the incoming bytes to the ES queue.
44 es_queue_->Push(buf, size);
45 return ParseFromEsQueue();
46 }
47
48 void EsParser::Reset() {
49 es_queue_.reset(new media::OffsetByteQueue());
50 timing_desc_list_.clear();
51 ResetInternal();
52 }
53
54 EsParser::TimingDesc EsParser::GetTimingDescriptor(int64 es_byte_count) {
55 TimingDesc timing_desc;
56 while (!timing_desc_list_.empty() &&
57 timing_desc_list_.front().first <= es_byte_count) {
58 timing_desc = timing_desc_list_.front().second;
59 timing_desc_list_.pop_front();
60 }
61 return timing_desc;
62 }
63
64 } // namespace mp2t
65 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp2t/es_parser.h ('k') | media/formats/mp2t/es_parser_adts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698