mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
examples/*-metadata-* : Change command line args.
This commit is contained in:
parent
c3e9c10119
commit
b301e43a24
@ -6,6 +6,7 @@
|
|||||||
* examples/sndfile-metadata-set.c examples/sndfile-metadata-get.c
|
* examples/sndfile-metadata-set.c examples/sndfile-metadata-get.c
|
||||||
examples/Makefile.am examples/test-sndfile-bwf-set.py
|
examples/Makefile.am examples/test-sndfile-bwf-set.py
|
||||||
Rename sndfile-bwf-(set|get).c to sndfile-metadata-(set|get).c.
|
Rename sndfile-bwf-(set|get).c to sndfile-metadata-(set|get).c.
|
||||||
|
Change command line args.
|
||||||
|
|
||||||
2008-08-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
2008-08-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ process_args (SNDFILE * file, const SF_BROADCAST_INFO * binfo, int argc, char *
|
|||||||
{ const char * str ;
|
{ const char * str ;
|
||||||
int k, do_all = 0 ;
|
int k, do_all = 0 ;
|
||||||
|
|
||||||
#define HANDLE_BINFO_ARG(cmd,name,field) \
|
#define HANDLE_BEXT_ARG(cmd,name,field) \
|
||||||
if (do_all || strcmp (argv [k], cmd) == 0) \
|
if (do_all || strcmp (argv [k], cmd) == 0) \
|
||||||
{ printf ("%-20s : %.*s\n", name, (int) sizeof (binfo->field), binfo->field) ; \
|
{ printf ("%-20s : %.*s\n", name, (int) sizeof (binfo->field), binfo->field) ; \
|
||||||
if (! do_all) \
|
if (! do_all) \
|
||||||
@ -130,17 +130,17 @@ process_args (SNDFILE * file, const SF_BROADCAST_INFO * binfo, int argc, char *
|
|||||||
{ if (do_all || strcmp (argv [k], "--all") == 0)
|
{ if (do_all || strcmp (argv [k], "--all") == 0)
|
||||||
do_all = 1 ;
|
do_all = 1 ;
|
||||||
|
|
||||||
HANDLE_BINFO_ARG ("--description", "Description", description) ;
|
HANDLE_BEXT_ARG ("--bext-description", "Description", description) ;
|
||||||
HANDLE_BINFO_ARG ("--originator", "Originator", originator) ;
|
HANDLE_BEXT_ARG ("--bext-originator", "Originator", originator) ;
|
||||||
HANDLE_BINFO_ARG ("--orig-ref", "Origination ref", originator_reference) ;
|
HANDLE_BEXT_ARG ("--bext-orig-ref", "Origination ref", originator_reference) ;
|
||||||
HANDLE_BINFO_ARG ("--umid", "UMID", umid) ;
|
HANDLE_BEXT_ARG ("--bext-umid", "UMID", umid) ;
|
||||||
HANDLE_BINFO_ARG ("--orig-date", "Origination date", origination_date) ;
|
HANDLE_BEXT_ARG ("--bext-orig-date", "Origination date", origination_date) ;
|
||||||
HANDLE_BINFO_ARG ("--orig-time", "Origination time", origination_time) ;
|
HANDLE_BEXT_ARG ("--bext-orig-time", "Origination time", origination_time) ;
|
||||||
HANDLE_BINFO_ARG ("--coding-hist", "Coding history", coding_history) ;
|
HANDLE_BEXT_ARG ("--bext-coding-hist", "Coding history", coding_history) ;
|
||||||
|
|
||||||
HANDLE_STR_ARG ("--info-name", "Name", SF_STR_TITLE) ;
|
HANDLE_STR_ARG ("--str-name", "Name", SF_STR_TITLE) ;
|
||||||
HANDLE_STR_ARG ("--info-artist", "Artist", SF_STR_ARTIST) ;
|
HANDLE_STR_ARG ("--str-artist", "Artist", SF_STR_ARTIST) ;
|
||||||
HANDLE_STR_ARG ("--info-create-date", "Create date", SF_STR_DATE) ;
|
HANDLE_STR_ARG ("--str-create-date", "Create date", SF_STR_DATE) ;
|
||||||
|
|
||||||
if (! do_all)
|
if (! do_all)
|
||||||
printf ("Error : Don't know what to do with command line arg '%s'.\n\n", argv [k]) ;
|
printf ("Error : Don't know what to do with command line arg '%s'.\n\n", argv [k]) ;
|
||||||
|
@ -103,7 +103,7 @@ main (int argc, char *argv [])
|
|||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--description") == 0)
|
if (strcmp (argv [k], "--bext-description") == 0)
|
||||||
{ k ++ ;
|
{ k ++ ;
|
||||||
if (k == argc) missing_param (argv [k - 1]) ;
|
if (k == argc) missing_param (argv [k - 1]) ;
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ main (int argc, char *argv [])
|
|||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--originator") == 0)
|
if (strcmp (argv [k], "--bext-originator") == 0)
|
||||||
{ k ++ ;
|
{ k ++ ;
|
||||||
if (k == argc) missing_param (argv [k - 1]) ;
|
if (k == argc) missing_param (argv [k - 1]) ;
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ main (int argc, char *argv [])
|
|||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--orig-ref") == 0)
|
if (strcmp (argv [k], "--bext-orig-ref") == 0)
|
||||||
{ k ++ ;
|
{ k ++ ;
|
||||||
if (k == argc) missing_param (argv [k - 1]) ;
|
if (k == argc) missing_param (argv [k - 1]) ;
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ main (int argc, char *argv [])
|
|||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--umid") == 0)
|
if (strcmp (argv [k], "--bext-umid") == 0)
|
||||||
{ k ++ ;
|
{ k ++ ;
|
||||||
if (k == argc) missing_param (argv [k - 1]) ;
|
if (k == argc) missing_param (argv [k - 1]) ;
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ main (int argc, char *argv [])
|
|||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--orig-date") == 0)
|
if (strcmp (argv [k], "--bext-orig-date") == 0)
|
||||||
{ k ++ ;
|
{ k ++ ;
|
||||||
if (k == argc) missing_param (argv [k - 1]) ;
|
if (k == argc) missing_param (argv [k - 1]) ;
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ main (int argc, char *argv [])
|
|||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--orig-time") == 0)
|
if (strcmp (argv [k], "--bext-orig-time") == 0)
|
||||||
{ k ++ ;
|
{ k ++ ;
|
||||||
if (k == argc) missing_param (argv [k - 1]) ;
|
if (k == argc) missing_param (argv [k - 1]) ;
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ main (int argc, char *argv [])
|
|||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--coding-hist") == 0)
|
if (strcmp (argv [k], "--bext-coding-hist") == 0)
|
||||||
{ k ++ ;
|
{ k ++ ;
|
||||||
if (k == argc) missing_param (argv [k - 1]) ;
|
if (k == argc) missing_param (argv [k - 1]) ;
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ main (int argc, char *argv [])
|
|||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--coding-hist-append") == 0)
|
if (strcmp (argv [k], "--bext-coding-hist-append") == 0)
|
||||||
{ k ++ ;
|
{ k ++ ;
|
||||||
if (k == argc) missing_param (argv [k - 1]) ;
|
if (k == argc) missing_param (argv [k - 1]) ;
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ main (int argc, char *argv [])
|
|||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--info-name") == 0)
|
if (strcmp (argv [k], "--str-name") == 0)
|
||||||
{ k ++ ;
|
{ k ++ ;
|
||||||
if (k == argc) missing_param (argv [k - 1]) ;
|
if (k == argc) missing_param (argv [k - 1]) ;
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ main (int argc, char *argv [])
|
|||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--info-artist") == 0)
|
if (strcmp (argv [k], "--str-artist") == 0)
|
||||||
{ k ++ ;
|
{ k ++ ;
|
||||||
if (k == argc) missing_param (argv [k - 1]) ;
|
if (k == argc) missing_param (argv [k - 1]) ;
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ main (int argc, char *argv [])
|
|||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--info-create-date") == 0)
|
if (strcmp (argv [k], "--str-create-date") == 0)
|
||||||
{ k ++ ;
|
{ k ++ ;
|
||||||
if (k == argc) missing_param (argv [k - 1]) ;
|
if (k == argc) missing_param (argv [k - 1]) ;
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ main (int argc, char *argv [])
|
|||||||
} ;
|
} ;
|
||||||
|
|
||||||
/* Following options do not take an argument. */
|
/* Following options do not take an argument. */
|
||||||
if (strcmp (argv [k], "--auto-time-date") == 0)
|
if (strcmp (argv [k], "--bext-auto-time-date") == 0)
|
||||||
{ char tmp [20] ;
|
{ char tmp [20] ;
|
||||||
snprintf (tmp, sizeof (tmp), "%02d:%02d:%02d", timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
|
snprintf (tmp, sizeof (tmp), "%02d:%02d:%02d", timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
|
||||||
strncpy (binfo.origination_time, tmp, sizeof (binfo.origination_time)) ;
|
strncpy (binfo.origination_time, tmp, sizeof (binfo.origination_time)) ;
|
||||||
@ -206,21 +206,21 @@ main (int argc, char *argv [])
|
|||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--auto-time") == 0)
|
if (strcmp (argv [k], "--bext-auto-time") == 0)
|
||||||
{ char tmp [20] ;
|
{ char tmp [20] ;
|
||||||
snprintf (tmp, sizeof (tmp), "%02d:%02d:%02d", timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
|
snprintf (tmp, sizeof (tmp), "%02d:%02d:%02d", timedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;
|
||||||
strncpy (binfo.origination_time, tmp, sizeof (binfo.origination_time)) ;
|
strncpy (binfo.origination_time, tmp, sizeof (binfo.origination_time)) ;
|
||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--auto-date") == 0)
|
if (strcmp (argv [k], "--bext-auto-date") == 0)
|
||||||
{ char tmp [20] ;
|
{ char tmp [20] ;
|
||||||
snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
|
snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
|
||||||
strncpy (binfo.origination_date, tmp, sizeof (binfo.origination_date)) ;
|
strncpy (binfo.origination_date, tmp, sizeof (binfo.origination_date)) ;
|
||||||
continue ;
|
continue ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
if (strcmp (argv [k], "--info-auto-create-date") == 0)
|
if (strcmp (argv [k], "--str-auto-create-date") == 0)
|
||||||
{ char tmp [20] ;
|
{ char tmp [20] ;
|
||||||
|
|
||||||
snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
|
snprintf (tmp, sizeof (tmp), "%04d-%02d-%02d", timedata.tm_year + 1900, timedata.tm_mon + 1, timedata.tm_mday) ;
|
||||||
|
@ -58,7 +58,7 @@ def check_executable (name):
|
|||||||
|
|
||||||
def test_empty_fail ():
|
def test_empty_fail ():
|
||||||
print_test_name ("Empty fail test")
|
print_test_name ("Empty fail test")
|
||||||
cmd = "./sndfile-metadata-set --description Alpha sine.wav"
|
cmd = "./sndfile-metadata-set --bext-description Alpha sine.wav"
|
||||||
status, output = commands.getstatusoutput (cmd)
|
status, output = commands.getstatusoutput (cmd)
|
||||||
if not status:
|
if not status:
|
||||||
print "\n\nError : command '%s' should have failed." % cmd
|
print "\n\nError : command '%s' should have failed." % cmd
|
||||||
@ -66,11 +66,11 @@ def test_empty_fail ():
|
|||||||
|
|
||||||
def test_copy ():
|
def test_copy ():
|
||||||
print_test_name ("Copy test")
|
print_test_name ("Copy test")
|
||||||
cmd = "./sndfile-metadata-set --description \"First Try\" sine.wav output.wav"
|
cmd = "./sndfile-metadata-set --bext-description \"First Try\" sine.wav output.wav"
|
||||||
status, output = commands.getstatusoutput (cmd)
|
status, output = commands.getstatusoutput (cmd)
|
||||||
if status:
|
if status:
|
||||||
print "\n\nError : command '%s' should not have failed." % cmd
|
print "\n\nError : command '%s' should not have failed." % cmd
|
||||||
assert_info ("output.wav", "--description", "First Try")
|
assert_info ("output.wav", "--bext-description", "First Try")
|
||||||
print "ok"
|
print "ok"
|
||||||
|
|
||||||
def test_update (tests):
|
def test_update (tests):
|
||||||
@ -91,12 +91,12 @@ def test_post_mod (tests):
|
|||||||
|
|
||||||
def test_auto_date ():
|
def test_auto_date ():
|
||||||
print_test_name ("Auto date test")
|
print_test_name ("Auto date test")
|
||||||
cmd = "./sndfile-metadata-set --auto-time-date sine.wav date-time.wav"
|
cmd = "./sndfile-metadata-set --bext-auto-time-date sine.wav date-time.wav"
|
||||||
status, output = commands.getstatusoutput (cmd)
|
status, output = commands.getstatusoutput (cmd)
|
||||||
if status:
|
if status:
|
||||||
print "\n\nError : command '%s' should not have failed." % cmd
|
print "\n\nError : command '%s' should not have failed." % cmd
|
||||||
target = datetime.date.today ().__str__ ()
|
target = datetime.date.today ().__str__ ()
|
||||||
assert_info ("date-time.wav", "--orig-date", target)
|
assert_info ("date-time.wav", "--bext-orig-date", target)
|
||||||
print "ok"
|
print "ok"
|
||||||
|
|
||||||
|
|
||||||
@ -119,16 +119,16 @@ test_empty_fail ()
|
|||||||
test_copy ()
|
test_copy ()
|
||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
("--description", "Alpha"), ("--originator", "Beta"), ("--orig-ref", "Charlie"),
|
("--bext-description", "Alpha"), ("--bext-originator", "Beta"), ("--bext-orig-ref", "Charlie"),
|
||||||
("--umid", "Delta"), ("--orig-date", "2001-10-01"), ("--orig-time", "01:02:03"),
|
("--bext-umid", "Delta"), ("--bext-orig-date", "2001-10-01"), ("--bext-orig-time", "01:02:03"),
|
||||||
("--info-name", "Echo"), ("--info-artist", "Fox trot")
|
("--str-name", "Echo"), ("--str-artist", "Fox trot")
|
||||||
]
|
]
|
||||||
|
|
||||||
test_auto_date ()
|
test_auto_date ()
|
||||||
test_update (tests)
|
test_update (tests)
|
||||||
test_post_mod (tests)
|
test_post_mod (tests)
|
||||||
|
|
||||||
test_update ([ ("--info-artist", "Fox") ])
|
test_update ([ ("--str-artist", "Fox") ])
|
||||||
|
|
||||||
print ""
|
print ""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user