From ca06c6fb9d1fbe02082946adec7a1389cd0f7f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano-Tarumi?= Date: Sat, 8 Dec 2018 12:55:58 -0500 Subject: [PATCH] detect muxed streams --- src/cli.cc | 8 ++++++++ t/opustags.t | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) mode change 100644 => 100755 t/opustags.t diff --git a/src/cli.cc b/src/cli.cc index b19604e..b4ec54a 100644 --- a/src/cli.cc +++ b/src/cli.cc @@ -184,6 +184,8 @@ static ot::status edit_tags(ot::opus_tags& tags, const ot::options& opt) */ static ot::status process(ot::ogg_reader& reader, ot::ogg_writer* writer, const ot::options &opt) { + bool focused = false; /*< the stream on which we operate is defined */ + int focused_serialno; /*< when focused, the serialno of the focused stream */ /** \todo Become stream-aware instead of counting the pages of all streams together. */ int absolute_page_no = -1; /*< page number in the physical stream, not logical */ for (;;) { @@ -197,6 +199,12 @@ static ot::status process(ot::ogg_reader& reader, ot::ogg_writer* writer, const ++absolute_page_no; auto serialno = ogg_page_serialno(&reader.page); auto pageno = ogg_page_pageno(&reader.page); + if (!focused) { + focused = true; + focused_serialno = serialno; + } else if (serialno != focused_serialno) { + return {ot::st::error, "Muxed streams are not supported yet."}; + } if (absolute_page_no == 0) { // Identification header if (!ot::is_opus_stream(reader.page)) return {ot::st::error, "Not an Opus stream."}; diff --git a/t/opustags.t b/t/opustags.t old mode 100644 new mode 100755 index bf9f6a2..7a3205e --- a/t/opustags.t +++ b/t/opustags.t @@ -4,7 +4,7 @@ use strict; use warnings; use utf8; -use Test::More tests => 28; +use Test::More tests => 29; use Digest::MD5; use File::Basename; @@ -190,3 +190,15 @@ my $data = slurp 'out.opus'; is_deeply(opustags('-', '-o', '-', {in => $data, mode => ':raw'}), [$data, '', 0], 'read opus from stdin and write to stdout'); unlink('out.opus'); + +#################################################################################################### +# Test muxed streams + +system('ffmpeg -loglevel error -y -i gobble.opus -c copy -map 0:0 -map 0:0 -shortest muxed.ogg') == 0 + or BAIL_OUT('could not create a muxed stream'); + +is_deeply(opustags('muxed.ogg'), ['', <<'END_ERR', 256], 'muxed streams detection'); +error: Muxed streams are not supported yet. +END_ERR + +unlink('muxed.ogg');