diff options
Diffstat (limited to 'main/asterisk/ASTERISK-18995.patch')
-rw-r--r-- | main/asterisk/ASTERISK-18995.patch | 85 |
1 files changed, 66 insertions, 19 deletions
diff --git a/main/asterisk/ASTERISK-18995.patch b/main/asterisk/ASTERISK-18995.patch index 2613176305..03f796dd79 100644 --- a/main/asterisk/ASTERISK-18995.patch +++ b/main/asterisk/ASTERISK-18995.patch @@ -1,10 +1,45 @@ ---- /dev/null 2014-10-31 08:01:35.193329595 -0200 -+++ asterisk-13.0.0/formats/format_ogg_speex.c 2014-10-31 09:19:34.010493106 -0200 -@@ -0,0 +1,336 @@ +From 56bdf048d2c873d0ddfad3672a07e7a08f0b706e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi> +Date: Fri, 3 Jun 2016 09:20:39 +0300 +Subject: [PATCH] Add support for OGG/Speex file format + +ASTERISK-18995 #close + +Change-Id: I98518bd28fc8f95668b3fe27d2cab45045ff3f7a +--- + CHANGES | 7 + + formats/format_ogg_speex.c | 345 +++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 352 insertions(+) + create mode 100644 formats/format_ogg_speex.c + +diff --git a/CHANGES b/CHANGES +index 43dc18f..175138a 100644 +--- a/CHANGES ++++ b/CHANGES +@@ -249,6 +249,13 @@ Functions + * The func_odbc global option "single_db_connection" default value has been + changed to 'no'. + ++ ++Formats ++------------------ ++ * New module format_ogg_speex added which supports Speex codec inside ++ Ogg containers (filename extension .spx). ++ ++ + CHANNEL + ------------------ + * Added CHANNEL(onhold) item that returns 1 (onhold) and 0 (not-onhold) for +diff --git a/formats/format_ogg_speex.c b/formats/format_ogg_speex.c +new file mode 100644 +index 0000000..6152e9c +--- /dev/null ++++ b/formats/format_ogg_speex.c +@@ -0,0 +1,345 @@ +/* + * Asterisk -- An open source telephony toolkit. + * -+ * Copyright (C) 2011-2014, Timo Teräs ++ * Copyright (C) 2011-2016, Timo Teräs + * + * See http://www.asterisk.org for more information about + * the Asterisk project. Please do not directly contact @@ -32,7 +67,7 @@ + +#include "asterisk.h" + -+ASTERISK_FILE_VERSION(__FILE__, "$Revision$") ++ASTERISK_REGISTER_FILE() + +#include "asterisk/mod_format.h" +#include "asterisk/module.h" @@ -68,16 +103,19 @@ + /* Get one packet */ + result = ogg_stream_packetout(&s->os, &s->op); + if (result > 0) { -+ if (s->op.bytes>=5 && !memcmp(s->op.packet, "Speex", 5)) ++ if (s->op.bytes >= 5 && !memcmp(s->op.packet, "Speex", 5)) { + s->serialno = s->os.serialno; -+ if (s->serialno == -1 || s->os.serialno != s->serialno) ++ } ++ if (s->serialno == -1 || s->os.serialno != s->serialno) { + continue; ++ } + return 0; + } + -+ if (result < 0) ++ if (result < 0) { + ast_log(LOG_WARNING, + "Corrupt or missing data at this page position; continuing...\n"); ++ } + + /* No more packets left in the current page... */ + if (s->eos) { @@ -90,13 +128,14 @@ + result = ogg_sync_pageout(&s->oy, &s->og); + if (result > 0) { + /* Read all streams. */ -+ if (ogg_page_serialno(&s->og) != s->os.serialno) ++ if (ogg_page_serialno(&s->og) != s->os.serialno) { + ogg_stream_reset_serialno(&s->os, ogg_page_serialno(&s->og)); ++ } + /* Yes, OGG has more pages in it's internal buffers, + add the page to the stream state */ + result = ogg_stream_pagein(&s->os, &s->og); + if (result == 0) { -+ /* Yes, got a new,valid page */ ++ /* Yes, got a new, valid page */ + if (ogg_page_eos(&s->og) && + ogg_page_serialno(&s->og) == s->serialno) + s->eos = 1; @@ -106,17 +145,19 @@ + "Invalid page in the bitstream; continuing...\n"); + } + -+ if (result < 0) ++ if (result < 0) { + ast_log(LOG_WARNING, + "Corrupt or missing data in bitstream; continuing...\n"); ++ } + + /* No, we need to read more data from the file descrptor */ + /* get a buffer from OGG to read the data into */ + buffer = ogg_sync_buffer(&s->oy, BLOCK_SIZE); + bytes = fread(buffer, 1, BLOCK_SIZE, fs->f); + ogg_sync_wrote(&s->oy, bytes); -+ if (bytes == 0) ++ if (bytes == 0) { + s->eos = 1; ++ } + } + } +} @@ -154,7 +195,7 @@ + } + + ogg_stream_init(&s->os, ogg_page_serialno(&s->og)); -+ if (ogg_stream_pagein(&s->os, &s->og) < 0) { ++ if (ogg_stream_pagein(&s->os, &s->og) < 0) { + ast_log(LOG_ERROR, "Error reading first page of Ogg bitstream data.\n"); + goto error; + } @@ -194,12 +235,13 @@ + goto error; + } + } -+ free(hdr); ++ speex_header_free(hdr); + + return 0; +error: -+ if (hdr) -+ free(hdr); ++ if (hdr) { ++ speex_header_free(hdr); ++ } + ogg_stream_clear(&s->os); + ogg_sync_clear(&s->oy); + return -1; @@ -228,8 +270,9 @@ +{ + struct speex_desc *s = (struct speex_desc *)fs->_private; + -+ if (read_packet(fs) < 0) ++ if (read_packet(fs) < 0) { + return NULL; ++ } + + AST_FRAME_SET_BUFFER(&fs->fr, fs->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); + memcpy(fs->fr.data.ptr, s->op.packet, s->op.bytes); @@ -255,7 +298,7 @@ + * \brief Seek to a specific position in an OGG/Speex filestream. + * \param s The filestream to truncate. + * \param sample_offset New position for the filestream, measured in 8KHz samples. -+ * \param whence Location to measure ++ * \param whence Location to measure + * \return 0 on success, -1 on failure. + */ +static int ogg_speex_seek(struct ast_filestream *s, off_t sample_offset, int whence) @@ -317,8 +360,9 @@ + + if (ast_format_def_register(&speex_f) || + ast_format_def_register(&speex16_f) || -+ ast_format_def_register(&speex32_f)) ++ ast_format_def_register(&speex32_f)) { + return AST_MODULE_LOAD_FAILURE; ++ } + + return AST_MODULE_LOAD_SUCCESS; +} @@ -337,3 +381,6 @@ + .unload = unload_module, + .load_pri = AST_MODPRI_APP_DEPEND +); +-- +2.10.0 + |