mirror of
https://github.com/fmang/opustags.git
synced 2025-01-15 20:53:16 +01:00
detect muxed streams
This commit is contained in:
parent
42845e4867
commit
ca06c6fb9d
@ -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
14
t/opustags.t
Normal file → Executable 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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user