detect muxed streams

This commit is contained in:
Frédéric Mangano-Tarumi 2018-12-08 12:55:58 -05:00
parent 42845e4867
commit ca06c6fb9d
2 changed files with 21 additions and 1 deletions

View File

@ -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."};

14
t/opustags.t Normal file → Executable file
View File

@ -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');