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

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: 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..9896e5e78e8f22b7ad4b0c1cf44a3ffde0b4c172
--- /dev/null
+++ b/media/formats/mp2t/es_parser_test_helper.cc
@@ -0,0 +1,59 @@
+// 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 "base/logging.h"
+#include "media/base/buffers.h"
+#include "media/formats/mp2t/es_parser.h"
+
+namespace media {
+namespace mp2t {
+
+Packet::Packet()
+ : offset(0u),
+ size(0u),
+ pts(kNoTimestamp()) {
+}
+
+void ComputePacketSize(std::vector<Packet>* packets, size_t stream_size) {
+ DCHECK(packets);
+ if (packets->size() == 0u)
+ return;
+
+ Packet* cur = &(*packets)[0];
+ for (size_t k = 0; k < packets->size() - 1; k++) {
+ Packet* next = &(*packets)[k + 1];
+ DCHECK_GE(next->offset, cur->offset);
+ cur->size = next->offset - cur->offset;
+ cur = next;
+ }
+ DCHECK_GE(stream_size, cur->offset);
+ cur->size = stream_size - cur->offset;
+}
+
+bool ProcessPesPackets(
+ EsParser* es_parser,
+ const std::vector<uint8>& stream,
+ const std::vector<Packet>& pes_packets,
+ bool force_timing) {
+ DCHECK(es_parser);
+ for (size_t k = 0; k < pes_packets.size(); k++) {
+ 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))
+ return false;
+ }
+ es_parser->Flush();
+ return true;
+}
+
+} // namespace mp2t
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698