mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
Lots more removal of deprecated things
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@43452 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -54,73 +54,6 @@ static int split_ext(char *filename, char **name, char **ext)
|
||||
}
|
||||
|
||||
/*! \brief Convert a file from one format to another */
|
||||
static int cli_audio_convert_deprecated(int fd, int argc, char *argv[])
|
||||
{
|
||||
int ret = RESULT_FAILURE;
|
||||
struct ast_filestream *fs_in = NULL, *fs_out = NULL;
|
||||
struct ast_frame *f;
|
||||
struct timeval start;
|
||||
int cost;
|
||||
char *file_in = NULL, *file_out = NULL;
|
||||
char *name_in, *ext_in, *name_out, *ext_out;
|
||||
|
||||
/* ugly, can be removed when CLI entries have ast_module pointers */
|
||||
ast_module_ref(ast_module_info->self);
|
||||
|
||||
if (argc != 3 || ast_strlen_zero(argv[1]) || ast_strlen_zero(argv[2])) {
|
||||
ret = RESULT_SHOWUSAGE;
|
||||
goto fail_out;
|
||||
}
|
||||
|
||||
file_in = ast_strdupa(argv[1]);
|
||||
file_out = ast_strdupa(argv[2]);
|
||||
|
||||
if (split_ext(file_in, &name_in, &ext_in)) {
|
||||
ast_cli(fd, "'%s' is an invalid filename!\n", argv[1]);
|
||||
goto fail_out;
|
||||
}
|
||||
if (!(fs_in = ast_readfile(name_in, ext_in, NULL, O_RDONLY, 0, 0))) {
|
||||
ast_cli(fd, "Unable to open input file: %s\n", argv[1]);
|
||||
goto fail_out;
|
||||
}
|
||||
|
||||
if (split_ext(file_out, &name_out, &ext_out)) {
|
||||
ast_cli(fd, "'%s' is an invalid filename!\n", argv[2]);
|
||||
goto fail_out;
|
||||
}
|
||||
if (!(fs_out = ast_writefile(name_out, ext_out, NULL, O_CREAT|O_TRUNC|O_WRONLY, 0, 0644))) {
|
||||
ast_cli(fd, "Unable to open output file: %s\n", argv[2]);
|
||||
goto fail_out;
|
||||
}
|
||||
|
||||
start = ast_tvnow();
|
||||
|
||||
while ((f = ast_readframe(fs_in))) {
|
||||
if (ast_writestream(fs_out, f)) {
|
||||
ast_cli(fd, "Failed to convert %s.%s to %s.%s!\n", name_in, ext_in, name_out, ext_out);
|
||||
goto fail_out;
|
||||
}
|
||||
}
|
||||
|
||||
cost = ast_tvdiff_ms(ast_tvnow(), start);
|
||||
ast_cli(fd, "Converted %s.%s to %s.%s in %dms\n", name_in, ext_in, name_out, ext_out, cost);
|
||||
ret = RESULT_SUCCESS;
|
||||
|
||||
fail_out:
|
||||
if (fs_out) {
|
||||
ast_closestream(fs_out);
|
||||
if (ret != RESULT_SUCCESS)
|
||||
ast_filedelete(name_out, ext_out);
|
||||
}
|
||||
|
||||
if (fs_in)
|
||||
ast_closestream(fs_in);
|
||||
|
||||
ast_module_unref(ast_module_info->self);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cli_audio_convert(int fd, int argc, char *argv[])
|
||||
{
|
||||
int ret = RESULT_FAILURE;
|
||||
@@ -195,15 +128,10 @@ static char usage_audio_convert[] =
|
||||
"Example:\n"
|
||||
" file convert tt-weasels.gsm tt-weasels.ulaw\n";
|
||||
|
||||
static struct ast_cli_entry cli_convert_deprecated = {
|
||||
{ "convert" , NULL },
|
||||
cli_audio_convert_deprecated, NULL,
|
||||
NULL };
|
||||
|
||||
static struct ast_cli_entry cli_convert[] = {
|
||||
{ { "file", "convert" , NULL },
|
||||
cli_audio_convert, "Convert audio file",
|
||||
usage_audio_convert, NULL, &cli_convert_deprecated },
|
||||
usage_audio_convert },
|
||||
};
|
||||
|
||||
static int unload_module(void)
|
||||
|
Reference in New Issue
Block a user