[asterisk-commits] coreyfarrell: branch group/media_formats-reviewed r416997 - in /team/group/me...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Jun 22 14:00:49 CDT 2014
Author: coreyfarrell
Date: Sun Jun 22 14:00:44 2014
New Revision: 416997
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416997
Log:
Move most of the core to media formats
Review: https://reviewboard.asterisk.org/r/3625/
Removed:
team/group/media_formats-reviewed/include/asterisk/format_pref.h
team/group/media_formats-reviewed/main/format_pref.c
Modified:
team/group/media_formats-reviewed/channels/chan_phone.c
team/group/media_formats-reviewed/include/asterisk/codec.h
team/group/media_formats-reviewed/include/asterisk/file.h
team/group/media_formats-reviewed/include/asterisk/format.h
team/group/media_formats-reviewed/include/asterisk/format_cache.h
team/group/media_formats-reviewed/include/asterisk/format_compatibility.h
team/group/media_formats-reviewed/include/asterisk/rtp_engine.h
team/group/media_formats-reviewed/include/asterisk/slinfactory.h
team/group/media_formats-reviewed/main/codec.c
team/group/media_formats-reviewed/main/core_local.c
team/group/media_formats-reviewed/main/core_unreal.c
team/group/media_formats-reviewed/main/data.c
team/group/media_formats-reviewed/main/dial.c
team/group/media_formats-reviewed/main/file.c
team/group/media_formats-reviewed/main/format.c
team/group/media_formats-reviewed/main/format_compatibility.c
team/group/media_formats-reviewed/main/frame.c
team/group/media_formats-reviewed/main/image.c
team/group/media_formats-reviewed/main/indications.c
team/group/media_formats-reviewed/main/manager.c
team/group/media_formats-reviewed/main/media_index.c
team/group/media_formats-reviewed/main/slinfactory.c
team/group/media_formats-reviewed/main/sorcery.c
team/group/media_formats-reviewed/main/sounds_index.c
team/group/media_formats-reviewed/main/stasis_channels.c
Modified: team/group/media_formats-reviewed/channels/chan_phone.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/channels/chan_phone.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/channels/chan_phone.c (original)
+++ team/group/media_formats-reviewed/channels/chan_phone.c Sun Jun 22 14:00:44 2014
@@ -789,12 +789,12 @@
if (!p->lastformat || (ast_format_cmp(p->lastformat, frame->subclass.format) != AST_FORMAT_CMP_EQUAL)) {
ioctl(p->fd, PHONE_PLAY_STOP);
ioctl(p->fd, PHONE_REC_STOP);
- if (ioctl(p->fd, PHONE_PLAY_CODEC, ast_format_get_original_id(frame->subclass.format))) {
+ if (ioctl(p->fd, PHONE_PLAY_CODEC, ast_format_compatibility_get_original_id(frame->subclass.format))) {
ast_log(LOG_WARNING, "Unable to set %s mode\n",
ast_format_get_name(frame->subclass.format));
return -1;
}
- if (ioctl(p->fd, PHONE_REC_CODEC, ast_format_get_original_id(frame->subclass.format))) {
+ if (ioctl(p->fd, PHONE_REC_CODEC, ast_format_compatibility_get_original_id(frame->subclass.format))) {
ast_log(LOG_WARNING, "Unable to set %s mode\n",
ast_format_get_name(frame->subclass.format));
return -1;
Modified: team/group/media_formats-reviewed/include/asterisk/codec.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/include/asterisk/codec.h?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/include/asterisk/codec.h (original)
+++ team/group/media_formats-reviewed/include/asterisk/codec.h Sun Jun 22 14:00:44 2014
@@ -53,6 +53,8 @@
unsigned int maximum_ms;
/*! \brief Default length of media carried (in milliseconds) in a frame */
unsigned int default_ms;
+ /*! \brief Length in bytes of the data payload of a minimum_ms frame */
+ unsigned int minimum_bytes;
/*!
* \brief Retrieve the number of samples in a frame
*
Modified: team/group/media_formats-reviewed/include/asterisk/file.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/include/asterisk/file.h?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/include/asterisk/file.h (original)
+++ team/group/media_formats-reviewed/include/asterisk/file.h Sun Jun 22 14:00:44 2014
@@ -385,7 +385,7 @@
* \retval NULL if not found
* \retval A pointer to the ast_format associated with this file extension
*/
-const struct ast_format *ast_get_format_for_file_ext(const char *file_ext);
+struct ast_format *ast_get_format_for_file_ext(const char *file_ext);
#if defined(__cplusplus) || defined(c_plusplus)
}
Modified: team/group/media_formats-reviewed/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/include/asterisk/format.h?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/include/asterisk/format.h (original)
+++ team/group/media_formats-reviewed/include/asterisk/format.h Sun Jun 22 14:00:44 2014
@@ -222,15 +222,6 @@
unsigned int ast_format_get_codec_id(const struct ast_format *format);
/*!
- * \brief Get the original Asterisk identifier associated with a format
- *
- * \param format The media format
- *
- * \return original identifier
- */
-uint64_t ast_format_get_original_id(const struct ast_format *format);
-
-/*!
* \brief Get the codec name associated with a format
*
* \param format The media format
@@ -293,6 +284,16 @@
* \return length of media (in milliseconds)
*/
unsigned int ast_format_determine_length(const struct ast_format *format, unsigned int samples);
+
+/*!
+ * \brief Check if the format is signed linear
+ *
+ * \param format The media format
+ *
+ * \retval 1 format is signed linear
+ * \retval 0 format is not signed linear
+ */
+int ast_format_is_slinear(const struct ast_format *format);
/*!
* \since 12
Modified: team/group/media_formats-reviewed/include/asterisk/format_cache.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/include/asterisk/format_cache.h?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/include/asterisk/format_cache.h (original)
+++ team/group/media_formats-reviewed/include/asterisk/format_cache.h Sun Jun 22 14:00:44 2014
@@ -84,6 +84,11 @@
extern struct ast_format *ast_format_alaw;
/*!
+ * \brief Built-in cached testlaw format.
+ */
+extern struct ast_format *ast_format_testlaw;
+
+/*!
* \brief Built-in cached gsm format.
*/
extern struct ast_format *ast_format_gsm;
@@ -134,6 +139,11 @@
extern struct ast_format *ast_format_speex16;
/*!
+ * \brief Built-in cached speex at 32kHz format.
+ */
+extern struct ast_format *ast_format_speex32;
+
+/*!
* \brief Built-in cached g723.1 format.
*/
extern struct ast_format *ast_format_g723;
@@ -159,11 +169,21 @@
extern struct ast_format *ast_format_h263;
/*!
+ * \brief Built-in cached h263 plus format.
+ */
+extern struct ast_format *ast_format_h263p;
+
+/*!
* \brief Built-in cached h264 format.
*/
extern struct ast_format *ast_format_h264;
/*!
+ * \brief Built-in cached mp4 format.
+ */
+extern struct ast_format *ast_format_mp4;
+
+/*!
* \brief Built-in cached vp8 format.
*/
extern struct ast_format *ast_format_vp8;
@@ -172,6 +192,11 @@
* \brief Built-in cached jpeg format.
*/
extern struct ast_format *ast_format_jpeg;
+
+/*!
+ * \brief Built-in cached png format.
+ */
+extern struct ast_format *ast_format_png;
/*!
* \brief Built-in cached siren14 format.
Modified: team/group/media_formats-reviewed/include/asterisk/format_compatibility.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/include/asterisk/format_compatibility.h?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/include/asterisk/format_compatibility.h (original)
+++ team/group/media_formats-reviewed/include/asterisk/format_compatibility.h Sun Jun 22 14:00:44 2014
@@ -94,6 +94,15 @@
int ast_format_compatibility_bitfield2cap(uint64_t bitfield, struct ast_format_cap *cap);
/*!
+ * \brief Get the original Asterisk identifier associated with a format
+ *
+ * \param format The media format
+ *
+ * \return original identifier
+ */
+uint64_t ast_format_compatibility_get_original_id(const struct ast_format *format);
+
+/*!
* \brief Codec located at a particular place in the preference index.
* \param pref preference structure to get the codec out of
* \param index to retrieve from
Modified: team/group/media_formats-reviewed/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/include/asterisk/rtp_engine.h?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/include/asterisk/rtp_engine.h (original)
+++ team/group/media_formats-reviewed/include/asterisk/rtp_engine.h Sun Jun 22 14:00:44 2014
@@ -71,6 +71,7 @@
#include "asterisk/astobj2.h"
#include "asterisk/frame.h"
+#include "asterisk/format_cap.h"
#include "asterisk/netsock2.h"
#include "asterisk/sched.h"
#include "asterisk/res_srtp.h"
@@ -2083,12 +2084,12 @@
/*! \brief Custom formats declared in codecs.conf at startup must be communicated to the rtp_engine
* so their mime type can payload number can be initialized. */
-int ast_rtp_engine_load_format(const struct ast_format *format);
+int ast_rtp_engine_load_format(struct ast_format *format);
/*! \brief Formats requiring the use of a format attribute interface must have that
* interface registered in order for the rtp engine to handle it correctly. If an
* attribute interface is unloaded, this function must be called to notify the rtp_engine. */
-int ast_rtp_engine_unload_format(const struct ast_format *format);
+int ast_rtp_engine_unload_format(struct ast_format *format);
/*!
* \brief Obtain a pointer to the ICE support present on an RTP instance
Modified: team/group/media_formats-reviewed/include/asterisk/slinfactory.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/include/asterisk/slinfactory.h?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/include/asterisk/slinfactory.h (original)
+++ team/group/media_formats-reviewed/include/asterisk/slinfactory.h Sun Jun 22 14:00:44 2014
@@ -60,7 +60,7 @@
*
* \return 0 on success, non-zero on failure
*/
-int ast_slinfactory_init_with_format(struct ast_slinfactory *sf, const struct ast_format *slin_out);
+int ast_slinfactory_init_with_format(struct ast_slinfactory *sf, struct ast_format *slin_out);
/*!
* \brief Destroy the contents of a slinfactory
Modified: team/group/media_formats-reviewed/main/codec.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/codec.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/codec.c (original)
+++ team/group/media_formats-reviewed/main/codec.c Sun Jun 22 14:00:44 2014
@@ -33,6 +33,8 @@
#include "asterisk/logger.h"
#include "asterisk/codec.h"
+#include "asterisk/format.h"
+#include "asterisk/frame.h"
#include "asterisk/astobj2.h"
#include "asterisk/strings.h"
#include "asterisk/module.h"
@@ -328,19 +330,26 @@
unsigned int ast_codec_samples_count(struct ast_frame *frame)
{
+ struct ast_codec *codec;
+ unsigned int samples = 0;
+
if ((frame->frametype != AST_FRAME_VOICE) &&
(frame->frametype != AST_FRAME_VIDEO) &&
(frame->frametype != AST_FRAME_IMAGE)) {
return 0;
}
- if (!frame->subclass.format->codec->get_samples) {
+ codec = ast_codec_get_by_id(ast_format_get_codec_id(frame->subclass.format));
+
+ if (codec->samples_count) {
+ samples = codec->samples_count(frame);
+ } else {
ast_log(LOG_WARNING, "Unable to calculate samples for codec %s\n",
ast_format_get_name(frame->subclass.format));
- return 0;
- }
-
- return frame->subclass.format->codec->get_samples(frame);
+ }
+
+ ao2_ref(codec, -1);
+ return samples;
}
unsigned int ast_codec_determine_length(const struct ast_codec *codec, unsigned int samples)
@@ -350,4 +359,4 @@
}
return codec->get_length(samples);
-}
+}
Modified: team/group/media_formats-reviewed/main/core_local.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/core_local.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/core_local.c (original)
+++ team/group/media_formats-reviewed/main/core_local.c Sun Jun 22 14:00:44 2014
@@ -1008,7 +1008,8 @@
ao2_ref(locals, -1);
locals = NULL;
- ast_format_cap_destroy(local_tech.capabilities);
+ ao2_cleanup(local_tech.capabilities);
+ local_tech.capabilities = NULL;
STASIS_MESSAGE_TYPE_CLEANUP(ast_local_optimization_begin_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_local_optimization_end_type);
@@ -1030,14 +1031,15 @@
return -1;
}
- if (!(local_tech.capabilities = ast_format_cap_alloc(0))) {
+ if (!(local_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
return -1;
}
- ast_format_cap_add_all(local_tech.capabilities);
+ ast_format_cap_add_all_by_type(local_tech.capabilities, AST_MEDIA_TYPE_UNKNOWN);
locals = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, locals_cmp_cb);
if (!locals) {
- ast_format_cap_destroy(local_tech.capabilities);
+ ao2_cleanup(local_tech.capabilities);
+ local_tech.capabilities = NULL;
return -1;
}
@@ -1045,7 +1047,8 @@
if (ast_channel_register(&local_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class 'Local'\n");
ao2_ref(locals, -1);
- ast_format_cap_destroy(local_tech.capabilities);
+ ao2_cleanup(local_tech.capabilities);
+ local_tech.capabilities = NULL;
return -1;
}
ast_cli_register_multiple(cli_local, ARRAY_LEN(cli_local));
Modified: team/group/media_formats-reviewed/main/core_unreal.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/core_unreal.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/core_unreal.c (original)
+++ team/group/media_formats-reviewed/main/core_unreal.c Sun Jun 22 14:00:44 2014
@@ -856,7 +856,8 @@
{
struct ast_unreal_pvt *doomed = vdoomed;
- doomed->reqcap = ast_format_cap_destroy(doomed->reqcap);
+ ao2_cleanup(doomed->reqcap);
+ doomed->reqcap = NULL;
}
struct ast_unreal_pvt *ast_unreal_alloc(size_t size, ao2_destructor_fn destructor, struct ast_format_cap *cap)
@@ -875,11 +876,13 @@
if (!unreal) {
return NULL;
}
- unreal->reqcap = ast_format_cap_dup(cap);
+
+ unreal->reqcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
if (!unreal->reqcap) {
ao2_ref(unreal, -1);
return NULL;
}
+ ast_format_cap_append_by_type(unreal->reqcap, cap, AST_MEDIA_TYPE_UNKNOWN);
memcpy(&unreal->jb_conf, &jb_conf, sizeof(unreal->jb_conf));
@@ -894,7 +897,7 @@
struct ast_channel *owner;
struct ast_channel *chan;
const char *linkedid = requestor ? ast_channel_linkedid(requestor) : NULL;
- struct ast_format fmt;
+ RAII_VAR(struct ast_format *, fmt, NULL, ao2_cleanup);
int generated_seqno = ast_atomic_fetchadd_int((int *) &name_sequence, +1);
/*
@@ -919,27 +922,37 @@
ao2_ref(p, +1);
ast_channel_tech_pvt_set(owner, p);
- ast_format_cap_copy(ast_channel_nativeformats(owner), p->reqcap);
+ ast_channel_nativeformats_set(owner, p->reqcap);
/* Determine our read/write format and set it on each channel */
ast_best_codec(p->reqcap, &fmt);
- ast_format_copy(ast_channel_writeformat(owner), &fmt);
- ast_format_copy(ast_channel_rawwriteformat(owner), &fmt);
- ast_format_copy(ast_channel_readformat(owner), &fmt);
- ast_format_copy(ast_channel_rawreadformat(owner), &fmt);
-
- ast_set_flag(ast_channel_flags(owner), AST_FLAG_DISABLE_DEVSTATE_CACHE);
-
- ast_jb_configure(owner, &p->jb_conf);
-
- if (ast_channel_cc_params_init(owner, requestor
- ? ast_channel_get_cc_config_params((struct ast_channel *) requestor) : NULL)) {
+
+ if (!fmt) {
+ ast_channel_tech_pvt_set(owner, NULL);
ao2_ref(p, -1);
ast_channel_unlock(owner);
ast_channel_release(owner);
return NULL;
}
+ ast_channel_set_writeformat(owner, fmt);
+ ast_channel_set_rawwriteformat(owner, fmt);
+ ast_channel_set_readformat(owner, fmt);
+ ast_channel_set_rawreadformat(owner, fmt);
+
+ ast_set_flag(ast_channel_flags(owner), AST_FLAG_DISABLE_DEVSTATE_CACHE);
+
+ ast_jb_configure(owner, &p->jb_conf);
+
+ if (ast_channel_cc_params_init(owner, requestor
+ ? ast_channel_get_cc_config_params((struct ast_channel *) requestor) : NULL)) {
+ ast_channel_tech_pvt_set(owner, NULL);
+ ao2_ref(p, -1);
+ ast_channel_unlock(owner);
+ ast_channel_release(owner);
+ return NULL;
+ }
+
p->owner = owner;
ast_channel_unlock(owner);
@@ -947,6 +960,7 @@
exten, context, ast_channel_linkedid(owner), 0,
"%s/%s-%08x;2", tech->type, p->name, generated_seqno))) {
ast_log(LOG_WARNING, "Unable to allocate chan channel structure\n");
+ ast_channel_tech_pvt_set(owner, NULL);
ao2_ref(p, -1);
ast_channel_release(owner);
return NULL;
@@ -960,13 +974,13 @@
ao2_ref(p, +1);
ast_channel_tech_pvt_set(chan, p);
- ast_format_cap_copy(ast_channel_nativeformats(chan), p->reqcap);
+ ast_channel_nativeformats_set(chan, p->reqcap);
/* Format was already determined when setting up owner */
- ast_format_copy(ast_channel_writeformat(chan), &fmt);
- ast_format_copy(ast_channel_rawwriteformat(chan), &fmt);
- ast_format_copy(ast_channel_readformat(chan), &fmt);
- ast_format_copy(ast_channel_rawreadformat(chan), &fmt);
+ ast_channel_set_writeformat(chan, fmt);
+ ast_channel_set_rawwriteformat(chan, fmt);
+ ast_channel_set_readformat(chan, fmt);
+ ast_channel_set_rawreadformat(chan, fmt);
ast_set_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_DEVSTATE_CACHE);
Modified: team/group/media_formats-reviewed/main/data.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/data.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/data.c (original)
+++ team/group/media_formats-reviewed/main/data.c Sun Jun 22 14:00:44 2014
@@ -45,6 +45,7 @@
#include "asterisk/manager.h"
#include "asterisk/test.h"
#include "asterisk/frame.h"
+#include "asterisk/codec.h"
/*** DOCUMENTATION
<manager name="DataGet" language="en_US">
@@ -3096,62 +3097,69 @@
return RESULT_SUCCESS;
}
+static int data_add_codec(struct ast_data *codecs, struct ast_format *format) {
+ struct ast_data *codec;
+ struct ast_codec *tmp;
+
+ tmp = ast_codec_get_by_id(ast_format_get_codec_id(format));
+ if (!tmp) {
+ return -1;
+ }
+
+ codec = ast_data_add_node(codecs, "codec");
+ if (!codec) {
+ ao2_ref(tmp, -1);
+ return -1;
+ }
+
+ ast_data_add_str(codec, "name", tmp->name);
+ ast_data_add_int(codec, "samplespersecond", tmp->sample_rate);
+ ast_data_add_str(codec, "description", tmp->description);
+ ast_data_add_int(codec, "frame_length", tmp->minimum_bytes);
+ ao2_ref(tmp, -1);
+
+ return 0;
+}
+
int ast_data_add_codec(struct ast_data *root, const char *node_name, struct ast_format *format)
{
- struct ast_data *codecs, *codec;
- size_t fmlist_size;
- const struct ast_format_list *fmlist;
- int x;
+ struct ast_data *codecs;
codecs = ast_data_add_node(root, node_name);
if (!codecs) {
return -1;
}
- fmlist = ast_format_list_get(&fmlist_size);
- for (x = 0; x < fmlist_size; x++) {
- if (ast_format_cmp(&fmlist[x].format, format) == AST_FORMAT_CMP_EQUAL) {
- codec = ast_data_add_node(codecs, "codec");
- if (!codec) {
- ast_format_list_destroy(fmlist);
- return -1;
- }
- ast_data_add_str(codec, "name", fmlist[x].name);
- ast_data_add_int(codec, "samplespersecond", fmlist[x].samplespersecond);
- ast_data_add_str(codec, "description", fmlist[x].desc);
- ast_data_add_int(codec, "frame_length", fmlist[x].fr_len);
- }
- }
- ast_format_list_destroy(fmlist);
-
- return 0;
+
+ return data_add_codec(codecs, format);
}
int ast_data_add_codecs(struct ast_data *root, const char *node_name, struct ast_format_cap *cap)
{
- struct ast_data *codecs, *codec;
- size_t fmlist_size;
- const struct ast_format_list *fmlist;
- int x;
+ struct ast_data *codecs;
+ size_t i;
+ size_t count;
codecs = ast_data_add_node(root, node_name);
if (!codecs) {
return -1;
}
- fmlist = ast_format_list_get(&fmlist_size);
- for (x = 0; x < fmlist_size; x++) {
- if (ast_format_cap_iscompatible(cap, &fmlist[x].format)) {
- codec = ast_data_add_node(codecs, "codec");
- if (!codec) {
- ast_format_list_destroy(fmlist);
- return -1;
- }
- ast_data_add_str(codec, "name", fmlist[x].name);
- ast_data_add_int(codec, "samplespersecond", fmlist[x].samplespersecond);
- ast_data_add_str(codec, "description", fmlist[x].desc);
- ast_data_add_int(codec, "frame_length", fmlist[x].fr_len);
- }
- }
- ast_format_list_destroy(fmlist);
+
+ count = ast_format_cap_count(cap);
+ for (i = 1; i <= count; ++i) {
+ struct ast_format *fmt;
+
+ fmt = ast_format_cap_get_format(cap, i);
+ if (!fmt) {
+ return -1;
+ }
+
+ if (data_add_codec(codecs, fmt)) {
+ ao2_ref(fmt, -1);
+ return -1;
+ }
+
+ ao2_ref(fmt, -1);
+ }
return 0;
}
Modified: team/group/media_formats-reviewed/main/dial.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/dial.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/dial.c (original)
+++ team/group/media_formats-reviewed/main/dial.c Sun Jun 22 14:00:44 2014
@@ -268,23 +268,23 @@
/* Copy device string over */
ast_copy_string(numsubst, channel->device, sizeof(numsubst));
- if (!ast_format_cap_is_empty(cap)) {
+ if (ast_format_cap_count(cap)) {
cap_request = cap;
} else if (chan) {
cap_request = ast_channel_nativeformats(chan);
} else {
- cap_all_audio = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
- ast_format_cap_add_all_by_type(cap_all_audio, AST_FORMAT_TYPE_AUDIO);
+ cap_all_audio = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+ ast_format_cap_add_all_by_type(cap_all_audio, AST_MEDIA_TYPE_AUDIO);
cap_request = cap_all_audio;
}
/* If we fail to create our owner channel bail out */
if (!(channel->owner = ast_request(channel->tech, cap_request, chan, numsubst, &channel->cause))) {
- cap_all_audio = ast_format_cap_destroy(cap_all_audio);
+ ao2_cleanup(cap_all_audio);
return -1;
}
cap_request = NULL;
- cap_all_audio = ast_format_cap_destroy(cap_all_audio);
+ ao2_cleanup(cap_all_audio);
ast_channel_lock(channel->owner);
ast_channel_stage_snapshot(channel->owner);
Modified: team/group/media_formats-reviewed/main/file.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/file.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/file.c (original)
+++ team/group/media_formats-reviewed/main/file.c Sun Jun 22 14:00:44 2014
@@ -1745,7 +1745,7 @@
#undef FORMAT2
}
-const struct ast_format *ast_get_format_for_file_ext(const char *file_ext)
+struct ast_format *ast_get_format_for_file_ext(const char *file_ext)
{
struct ast_format_def *f;
SCOPED_RDLOCK(lock, &formats.lock);
Modified: team/group/media_formats-reviewed/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/format.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/format.c (original)
+++ team/group/media_formats-reviewed/main/format.c Sun Jun 22 14:00:44 2014
@@ -260,11 +260,6 @@
return format->codec->id;
}
-uint64_t ast_format_get_original_id(const struct ast_format *format)
-{
- return format->codec->original_id;
-}
-
const char *ast_format_get_name(const struct ast_format *format)
{
return format->codec->name;
@@ -298,4 +293,4 @@
unsigned int ast_format_determine_length(const struct ast_format *format, unsigned int samples)
{
return ast_codec_determine_length(format->codec, samples);
-}
+}
Modified: team/group/media_formats-reviewed/main/format_compatibility.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/format_compatibility.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/format_compatibility.c (original)
+++ team/group/media_formats-reviewed/main/format_compatibility.c Sun Jun 22 14:00:44 2014
@@ -336,6 +336,46 @@
return 0;
}
+#if 0
+#error BUGBUG: these procedures need to be converted
+void ast_codec_pref_convert(struct ast_codec_pref *pref, char *buf, size_t size, int right)
+{
+ size_t f_len;
+ const struct ast_format_list *f_list = ast_format_list_get(&f_len);
+ int x, differential = (int) 'A', mem;
+ char *from, *to;
+
+ /* TODO re-evaluate this function. It is using the order of the formats specified
+ * in the global format list in a way that may not be safe. */
+ if (right) {
+ from = pref->order;
+ to = buf;
+ mem = size;
+ } else {
+ to = pref->order;
+ from = buf;
+ mem = AST_CODEC_PREF_SIZE;
+ }
+
+ memset(to, 0, mem);
+ for (x = 0; x < AST_CODEC_PREF_SIZE; x++) {
+ if (!from[x]) {
+ break;
+ }
+ to[x] = right ? (from[x] + differential) : (from[x] - differential);
+ if (!right && to[x] && (to[x] < f_len)) {
+ ast_format_copy(&pref->formats[x], &f_list[to[x]-1].format);
+ }
+ }
+ ast_format_list_destroy(f_list);
+}
+
+uint64_t ast_format_compatibility_get_original_id(const struct ast_format *format)
+{
+ return format->codec->original_id;
+}
+#endif
+
struct ast_format *ast_codec_pref_index(struct ast_codec_pref *pref, int idx, struct ast_format **result)
{
if ((idx >= 0) && (idx < sizeof(pref->order)) && pref->order[idx]) {
Modified: team/group/media_formats-reviewed/main/frame.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/frame.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/frame.c (original)
+++ team/group/media_formats-reviewed/main/frame.c Sun Jun 22 14:00:44 2014
@@ -34,6 +34,7 @@
#include "asterisk/_private.h"
#include "asterisk/lock.h"
#include "asterisk/frame.h"
+#include "asterisk/format_cache.h"
#include "asterisk/channel.h"
#include "asterisk/cli.h"
#include "asterisk/term.h"
@@ -201,7 +202,7 @@
return NULL;
}
out->frametype = fr->frametype;
- ast_format_copy(&out->subclass.format, &fr->subclass.format);
+ out->subclass.format = ast_format_copy(fr->subclass.format);
out->datalen = fr->datalen;
out->samples = fr->samples;
out->offset = fr->offset;
@@ -460,7 +461,7 @@
}
break;
case AST_FRAME_IMAGE:
- snprintf(subclass, slen, "Image format %s\n", ast_getformatname(&f->subclass.format));
+ snprintf(subclass, slen, "Image format %s\n", ast_format_get_name(f->subclass.format));
break;
case AST_FRAME_HTML:
switch (f->subclass.integer) {
@@ -628,7 +629,7 @@
short *fdata = f->data.ptr;
short adjust_value = abs(adjustment);
- if ((f->frametype != AST_FRAME_VOICE) || !(ast_format_is_slinear(&f->subclass.format))) {
+ if ((f->frametype != AST_FRAME_VOICE) || !(ast_format_is_slinear(f->subclass.format))) {
return -1;
}
@@ -652,10 +653,10 @@
int count;
short *data1, *data2;
- if ((f1->frametype != AST_FRAME_VOICE) || (f1->subclass.format.id != AST_FORMAT_SLINEAR))
+ if ((f1->frametype != AST_FRAME_VOICE) || (ast_format_cmp(f1->subclass.format, ast_format_slin) != AST_FORMAT_CMP_NOT_EQUAL))
return -1;
- if ((f2->frametype != AST_FRAME_VOICE) || (f2->subclass.format.id != AST_FORMAT_SLINEAR))
+ if ((f2->frametype != AST_FRAME_VOICE) || (ast_format_cmp(f2->subclass.format, ast_format_slin) != AST_FORMAT_CMP_NOT_EQUAL))
return -1;
if (f1->samples != f2->samples)
Modified: team/group/media_formats-reviewed/main/image.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/image.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/image.c (original)
+++ team/group/media_formats-reviewed/main/image.c Sun Jun 22 14:00:44 2014
@@ -114,7 +114,7 @@
AST_RWLIST_RDLOCK(&imagers);
AST_RWLIST_TRAVERSE(&imagers, i, list) {
/* if NULL image format, just pick the first one, otherwise match it. */
- if (!format || (ast_format_cmp(&i->format, format) == AST_FORMAT_CMP_EQUAL)) {
+ if (!format || (ast_format_cmp(i->format, format) == AST_FORMAT_CMP_EQUAL)) {
char *stringp=NULL;
ast_copy_string(tmp, i->exts, sizeof(tmp));
stringp = tmp;
@@ -194,7 +194,7 @@
ast_cli(a->fd, FORMAT, "----", "----------", "-----------", "------");
AST_RWLIST_RDLOCK(&imagers);
AST_RWLIST_TRAVERSE(&imagers, i, list) {
- ast_cli(a->fd, FORMAT2, i->name, i->exts, i->desc, ast_getformatname(&i->format));
+ ast_cli(a->fd, FORMAT2, i->name, i->exts, i->desc, ast_format_get_name(i->format));
count_fmt++;
}
AST_RWLIST_UNLOCK(&imagers);
Modified: team/group/media_formats-reviewed/main/indications.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/indications.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/indications.c (original)
+++ team/group/media_formats-reviewed/main/indications.c Sun Jun 22 14:00:44 2014
@@ -37,6 +37,7 @@
#include "asterisk/linkedlists.h"
#include "asterisk/indications.h"
#include "asterisk/frame.h"
+#include "asterisk/format_cache.h"
#include "asterisk/channel.h"
#include "asterisk/utils.h"
#include "asterisk/cli.h"
@@ -120,7 +121,7 @@
int npos;
int oldnpos;
int pos;
- struct ast_format origwfmt;
+ struct ast_format *origwfmt;
struct ast_frame f;
unsigned char offset[AST_FRIENDLY_OFFSET];
short data[4000];
@@ -131,13 +132,11 @@
struct playtones_state *ps = params;
if (chan) {
- ast_set_write_format(chan, &ps->origwfmt);
- }
-
- if (ps->items) {
- ast_free(ps->items);
- ps->items = NULL;
- }
+ ast_set_write_format(chan, ps->origwfmt);
+ }
+
+ ao2_cleanup(ps->origwfmt);
+ ast_free(ps->items);
ast_free(ps);
}
@@ -151,9 +150,9 @@
return NULL;
}
- ast_format_copy(&ps->origwfmt, ast_channel_writeformat(chan));
-
- if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
+ ps->origwfmt = ast_format_copy(ast_channel_writeformat(chan));
+
+ if (ast_set_write_format(chan, ast_format_slin)) {
ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", ast_channel_name(chan));
playtones_release(NULL, ps);
ps = NULL;
@@ -227,7 +226,7 @@
}
ps->f.frametype = AST_FRAME_VOICE;
- ast_format_set(&ps->f.subclass.format, AST_FORMAT_SLINEAR, 0);
+ ps->f.subclass.format = ast_format_slin;
ps->f.datalen = len;
ps->f.samples = samples;
ps->f.offset = AST_FRIENDLY_OFFSET;
Modified: team/group/media_formats-reviewed/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/manager.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/manager.c (original)
+++ team/group/media_formats-reviewed/main/manager.c Sun Jun 22 14:00:44 2014
@@ -99,6 +99,7 @@
#include "asterisk/bridge.h"
#include "asterisk/features_config.h"
#include "asterisk/rtp_engine.h"
+#include "asterisk/format_cache.h"
/*** DOCUMENTATION
<manager name="Ping" language="en_US">
@@ -4400,7 +4401,7 @@
*/
static void destroy_fast_originate_helper(struct fast_originate_helper *doomed)
{
- ast_format_cap_destroy(doomed->cap);
+ ao2_cleanup(doomed->cap);
ast_variables_destroy(doomed->vars);
ast_string_field_free_memory(doomed);
ast_free(doomed);
@@ -4715,8 +4716,7 @@
int reason = 0;
char tmp[256];
char tmp2[256];
- struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
- struct ast_format tmp_fmt;
+ struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
pthread_t th;
int bridge_early = 0;
@@ -4724,7 +4724,7 @@
astman_send_error(s, m, "Internal Error. Memory allocation failure.");
return 0;
}
- ast_format_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_SLINEAR, 0));
+ ast_format_cap_add(cap, ast_format_slin, 0);
if (ast_strlen_zero(name)) {
astman_send_error(s, m, "Channel not specified");
@@ -4766,8 +4766,8 @@
}
}
if (!ast_strlen_zero(codecs)) {
- ast_format_cap_remove_all(cap);
- ast_parse_allow_disallow(NULL, cap, codecs, 1);
+ ast_format_cap_remove_bytype(cap, AST_MEDIA_TYPE_UNKNOWN);
+ ast_parse_allow_disallow(cap, codecs, 1);
}
if (!ast_strlen_zero(app) && s->session) {
@@ -4881,7 +4881,7 @@
}
fast_orig_cleanup:
- ast_format_cap_destroy(cap);
+ ao2_cleanup(cap);
return 0;
}
Modified: team/group/media_formats-reviewed/main/media_index.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/media_index.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/media_index.c (original)
+++ team/group/media_formats-reviewed/main/media_index.c Sun Jun 22 14:00:44 2014
@@ -56,7 +56,7 @@
struct media_variant *variant = obj;
ast_string_field_free_memory(variant);
- variant->formats = ast_format_cap_destroy(variant->formats);
+ ao2_cleanup(variant->formats);
}
static struct media_variant *media_variant_alloc(const char *variant_str)
@@ -67,7 +67,7 @@
return NULL;
}
- variant->formats = ast_format_cap_alloc(0);
+ variant->formats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
if (!variant->formats) {
return NULL;
}
@@ -239,6 +239,7 @@
struct ast_format_cap *ast_media_get_format_cap(struct ast_media_index *index, const char *filename, const char *variant_str)
{
+ struct ast_format_cap *dupcap;
RAII_VAR(struct media_variant *, variant, NULL, ao2_cleanup);
if (ast_strlen_zero(filename) || ast_strlen_zero(variant_str)) {
return NULL;
@@ -249,7 +250,11 @@
return NULL;
}
- return ast_format_cap_dup(variant->formats);
+ dupcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+ if (dupcap) {
+ ast_format_cap_append_by_type(dupcap, variant->formats, AST_MEDIA_TYPE_UNKNOWN);
+ }
+ return dupcap;
}
/*! \brief Add the variant to the list of variants requested */
@@ -317,7 +322,7 @@
}
/*! \brief Update an index with new format/variant information */
-static int update_file_format_info(struct ast_media_index *index, const char *filename, const char *variant_str, const struct ast_format *file_format)
+static int update_file_format_info(struct ast_media_index *index, const char *filename, const char *variant_str, struct ast_format *file_format)
{
RAII_VAR(struct media_variant *, variant, find_variant(index, filename, variant_str), ao2_cleanup);
if (!variant) {
@@ -327,14 +332,14 @@
}
}
- ast_format_cap_add(variant->formats, file_format);
+ ast_format_cap_add(variant->formats, file_format, 0);
return 0;
}
/*! \brief Process a media file into the index */
static int process_media_file(struct ast_media_index *index, const char *variant, const char *subdir, const char *filename_stripped, const char *ext)
{
- const struct ast_format *file_format;
+ struct ast_format *file_format;
const char *file_identifier = filename_stripped;
RAII_VAR(struct ast_str *, file_id_str, NULL, ast_free);
Modified: team/group/media_formats-reviewed/main/slinfactory.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/slinfactory.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/slinfactory.c (original)
+++ team/group/media_formats-reviewed/main/slinfactory.c Sun Jun 22 14:00:44 2014
@@ -35,22 +35,23 @@
#include "asterisk/frame.h"
#include "asterisk/slinfactory.h"
#include "asterisk/translate.h"
+#include "asterisk/astobj2.h"
void ast_slinfactory_init(struct ast_slinfactory *sf)
{
memset(sf, 0, sizeof(*sf));
sf->offset = sf->hold;
- ast_format_set(&sf->output_format, AST_FORMAT_SLINEAR, 0);
-}
-
-int ast_slinfactory_init_with_format(struct ast_slinfactory *sf, const struct ast_format *slin_out)
+ sf->output_format = ast_format_copy(ast_format_slin);
+}
+
+int ast_slinfactory_init_with_format(struct ast_slinfactory *sf, struct ast_format *slin_out)
{
memset(sf, 0, sizeof(*sf));
sf->offset = sf->hold;
if (!ast_format_is_slinear(slin_out)) {
return -1;
}
- ast_format_copy(&sf->output_format, slin_out);
+ sf->output_format = ast_format_copy(slin_out);
return 0;
}
@@ -64,8 +65,12 @@
sf->trans = NULL;
}
- while ((f = AST_LIST_REMOVE_HEAD(&sf->queue, frame_list)))
+ while ((f = AST_LIST_REMOVE_HEAD(&sf->queue, frame_list))) {
ast_frfree(f);
+ }
+
+ ao2_cleanup(sf->output_format);
+ ao2_cleanup(sf->format);
}
int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f)
@@ -83,22 +88,23 @@
return 0;
}
- if (ast_format_cmp(&f->subclass.format, &sf->output_format) == AST_FORMAT_CMP_NOT_EQUAL) {
- if (sf->trans && (ast_format_cmp(&f->subclass.format, &sf->format) == AST_FORMAT_CMP_NOT_EQUAL)) {
+ if (ast_format_cmp(f->subclass.format, sf->output_format) == AST_FORMAT_CMP_NOT_EQUAL) {
+ if (sf->trans && (ast_format_cmp(f->subclass.format, sf->format) == AST_FORMAT_CMP_NOT_EQUAL)) {
ast_translator_free_path(sf->trans);
sf->trans = NULL;
}
if (!sf->trans) {
- if (!(sf->trans = ast_translator_build_path(&sf->output_format, &f->subclass.format))) {
+ if (!(sf->trans = ast_translator_build_path(sf->output_format, f->subclass.format))) {
ast_log(LOG_WARNING, "Cannot build a path from %s (%d)to %s (%d)\n",
- ast_getformatname(&f->subclass.format),
- f->subclass.format.id,
- ast_getformatname(&sf->output_format),
- sf->output_format.id);
+ ast_format_get_name(f->subclass.format),
+ ast_format_get_codec_id(f->subclass.format),
+ ast_format_get_name(sf->output_format),
+ ast_format_get_codec_id(sf->output_format));
return 0;
}
- ast_format_copy(&sf->format, &f->subclass.format);
+ ao2_cleanup(sf->format);
+ sf->format = ast_format_copy(f->subclass.format);
}
if (!(begin_frame = ast_translate(sf->trans, f, 0))) {
Modified: team/group/media_formats-reviewed/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/sorcery.c?view=diff&rev=416997&r1=416996&r2=416997
==============================================================================
--- team/group/media_formats-reviewed/main/sorcery.c (original)
+++ team/group/media_formats-reviewed/main/sorcery.c Sun Jun 22 14:00:44 2014
@@ -43,7 +43,6 @@
#include "asterisk/taskprocessor.h"
#include "asterisk/threadpool.h"
#include "asterisk/json.h"
-#include "asterisk/format_pref.h"
[... 70 lines stripped ...]
More information about the asterisk-commits
mailing list