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

Unified 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: Update ComputePacketSize prototype. 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 side-by-side diff with in-line comments
Download patch
Index: media/formats/mp2t/es_parser_test_helper.cc
diff --git a/media/formats/mp2t/es_parser_test_helper.cc b/media/formats/mp2t/es_parser_test_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..96ebae7e3c634a04fda662d448e6122aa5bed4f8
--- /dev/null
+++ b/media/formats/mp2t/es_parser_test_helper.cc
@@ -0,0 +1,56 @@
+// 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_test_helper.h"
+
+#include "media/base/buffers.h"
+#include "media/formats/mp2t/es_parser.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace media {
+namespace mp2t {
+
+Packet::Packet()
+ : offset(0u),
+ size(0u) {
wolenetz 2014/07/16 00:21:03 I'm not sure, but you might want to default-initia
damienv1 2014/07/16 02:34:33 Done.
+}
+
+void ComputePacketSize(std::vector<Packet>* packets, size_t stream_size) {
wolenetz 2014/07/16 00:21:03 nit: Following convention in media/base/test_helpe
damienv1 2014/07/16 02:34:33 In fact, I checked at this file and not all functi
+ ASSERT_TRUE(packets);
+ if (packets->size() == 0u)
+ return;
+
+ Packet* cur = &packets->at(0);
wolenetz 2014/07/16 00:21:03 nit: I'm not convinced you need to use at(k) or at
damienv1 2014/07/16 02:34:33 Done.
+ for (size_t k = 0; k < packets->size() - 1; k++) {
+ Packet* next = &packets->at(k + 1);
+ DCHECK_GE(next->offset, cur->offset);
+ cur->size = next->offset - cur->offset;
+ cur = next;
+ }
+ cur->size = stream_size - cur->offset;
wolenetz 2014/07/16 00:21:03 nit: First, DCHECK_GE(stream_size, cur->offset); ?
damienv1 2014/07/16 02:34:33 Done.
+}
+
+bool ProcessPesPackets(
+ EsParser* es_parser,
+ const std::vector<uint8>& stream,
+ const std::vector<Packet>& pes_packets,
+ bool force_timing) {
+ for (size_t k = 0; k < pes_packets.size(); k++) {
wolenetz 2014/07/16 00:21:04 nit: First, ASSERT_TRUE(es_parser); ?
+ size_t cur_pes_offset = pes_packets[k].offset;
+ size_t cur_pes_size = pes_packets[k].size;
+
+ base::TimeDelta pts = kNoTimestamp();
+ base::TimeDelta dts = kNoTimestamp();
+ if (pes_packets[k].pts >= base::TimeDelta() || force_timing)
+ pts = pes_packets[k].pts;
+
+ if (!es_parser->Parse(&stream[cur_pes_offset], cur_pes_size, pts, dts))
wolenetz 2014/07/16 00:21:04 nit: just pass kNoTimestamp() here instead of dts
damienv1 2014/07/16 02:34:33 I was finding it more explicit to pass a variable
wolenetz 2014/07/16 20:35:30 I have no strong feeling here. Maybe s/dts/no_time
+ return false;
+ }
+ es_parser->Flush();
+ return true;
+}
+
+} // namespace mp2t
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698