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

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

Issue 399433003: Mpeg2 TS - Fail when no valid timestamp in the ADTS parser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
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_test_helper.h"
6
7 #include "base/logging.h"
8 #include "media/base/buffers.h"
9 #include "media/formats/mp2t/es_parser.h"
10
11 namespace media {
12 namespace mp2t {
13
14 Packet::Packet()
15 : offset(0u),
16 size(0u),
17 pts(kNoTimestamp()) {
18 }
19
20 void ComputePacketSize(std::vector<Packet>* packets, size_t stream_size) {
21 DCHECK(packets);
22 if (packets->size() == 0u)
23 return;
24
25 Packet* cur = &(*packets)[0];
26 for (size_t k = 0; k < packets->size() - 1; k++) {
27 Packet* next = &(*packets)[k + 1];
28 DCHECK_GE(next->offset, cur->offset);
29 cur->size = next->offset - cur->offset;
30 cur = next;
31 }
32 DCHECK_GE(stream_size, cur->offset);
33 cur->size = stream_size - cur->offset;
34 }
35
36 bool ProcessPesPackets(
37 EsParser* es_parser,
38 const std::vector<uint8>& stream,
39 const std::vector<Packet>& pes_packets,
40 bool force_timing) {
41 DCHECK(es_parser);
42 for (size_t k = 0; k < pes_packets.size(); k++) {
43 size_t cur_pes_offset = pes_packets[k].offset;
44 size_t cur_pes_size = pes_packets[k].size;
45
46 base::TimeDelta pts = kNoTimestamp();
47 base::TimeDelta dts = kNoTimestamp();
48 if (pes_packets[k].pts >= base::TimeDelta() || force_timing)
49 pts = pes_packets[k].pts;
50
51 if (!es_parser->Parse(&stream[cur_pes_offset], cur_pes_size, pts, dts))
52 return false;
53 }
54 es_parser->Flush();
55 return true;
56 }
57
58 } // namespace mp2t
59 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698