[svn-commits] file: branch group/media_formats r407397 - in /team/group/media_formats: incl...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Feb 5 07:09:32 CST 2014


Author: file
Date: Wed Feb  5 07:09:29 2014
New Revision: 407397

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407397
Log:
Move the channel over to storing pointers to formats.

Modified:
    team/group/media_formats/include/asterisk/channel.h
    team/group/media_formats/include/asterisk/data.h
    team/group/media_formats/include/asterisk/frame.h
    team/group/media_formats/main/channel.c
    team/group/media_formats/main/channel_internal_api.c

Modified: team/group/media_formats/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/channel.h?view=diff&rev=407397&r1=407396&r2=407397
==============================================================================
--- team/group/media_formats/include/asterisk/channel.h (original)
+++ team/group/media_formats/include/asterisk/channel.h Wed Feb  5 07:09:29 2014
@@ -1847,14 +1847,6 @@
 int ast_set_read_format(struct ast_channel *chan, struct ast_format *format);
 
 /*!
- * \brief Sets read format on channel chan by id
- * \param chan channel to change
- * \param id format id to set for reading, only used for formats without attributes
- * \return Returns 0 on success, -1 on failure
- */
-int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id);
-
-/*!
  * \brief Sets write format on channel chan
  * Set write format for channel to whichever component of "format" is best.
  * \param chan channel to change
@@ -1870,14 +1862,6 @@
  * \return Returns 0 on success, -1 on failure
  */
 int ast_set_write_format(struct ast_channel *chan, struct ast_format *format);
-
-/*!
- * \brief Sets write format on channel chan
- * \param chan channel to change
- * \param id format id to set for writing, only used for formats without attributes
- * \return Returns 0 on success, -1 on failure
- */
-int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id);
 
 /*!
  * \brief Sends text to a channel
@@ -3942,6 +3926,13 @@
 struct ast_format *ast_channel_readformat(struct ast_channel *chan);
 struct ast_format *ast_channel_writeformat(struct ast_channel *chan);
 
+/* Format setters */
+void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format);
+void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format);
+void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format);
+void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format);
+void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format);
+
 /* Other struct getters */
 struct ast_frame *ast_channel_dtmff(struct ast_channel *chan);
 struct ast_jb *ast_channel_jb(struct ast_channel *chan);

Modified: team/group/media_formats/include/asterisk/data.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/data.h?view=diff&rev=407397&r1=407396&r2=407397
==============================================================================
--- team/group/media_formats/include/asterisk/data.h (original)
+++ team/group/media_formats/include/asterisk/data.h Wed Feb  5 07:09:29 2014
@@ -26,6 +26,7 @@
 #define ASTERISK_DATA_H
 
 #include "asterisk/frame.h"
+#include "asterisk/format_cap.h"
 
 /*!
  * \page AstDataRetrieval The Asterisk DATA retrieval API.

Modified: team/group/media_formats/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/frame.h?view=diff&rev=407397&r1=407396&r2=407397
==============================================================================
--- team/group/media_formats/include/asterisk/frame.h (original)
+++ team/group/media_formats/include/asterisk/frame.h Wed Feb  5 07:09:29 2014
@@ -31,7 +31,6 @@
 
 #include <sys/time.h>
 
-#include "asterisk/format_pref.h"
 #include "asterisk/format.h"
 #include "asterisk/endian.h"
 #include "asterisk/linkedlists.h"

Modified: team/group/media_formats/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/channel.c?view=diff&rev=407397&r1=407396&r2=407397
==============================================================================
--- team/group/media_formats/main/channel.c (original)
+++ team/group/media_formats/main/channel.c Wed Feb  5 07:09:29 2014
@@ -5390,28 +5390,6 @@
 	return res;
 }
 
-int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id)
-{
-	struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
-	struct ast_format tmp_format;
-	int res;
-
-	if (!cap) {
-		return -1;
-	}
-	ast_format_cap_add(cap, ast_format_set(&tmp_format, id, 0));
-
-	res = set_format(chan,
-		cap,
-		ast_channel_rawreadformat(chan),
-		ast_channel_readformat(chan),
-		&set_format_readtrans,
-		0);
-
-	ast_format_cap_destroy(cap);
-	return res;
-}
-
 int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *cap)
 {
 	return set_format(chan,
@@ -5431,28 +5409,6 @@
 		return -1;
 	}
 	ast_format_cap_add(cap, format);
-
-	res = set_format(chan,
-		cap,
-		ast_channel_rawwriteformat(chan),
-		ast_channel_writeformat(chan),
-		&set_format_writetrans,
-		1);
-
-	ast_format_cap_destroy(cap);
-	return res;
-}
-
-int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id)
-{
-	struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
-	struct ast_format tmp_format;
-	int res;
-
-	if (!cap) {
-		return -1;
-	}
-	ast_format_cap_add(cap, ast_format_set(&tmp_format, id, 0));
 
 	res = set_format(chan,
 		cap,

Modified: team/group/media_formats/main/channel_internal_api.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/channel_internal_api.c?view=diff&rev=407397&r1=407396&r2=407397
==============================================================================
--- team/group/media_formats/main/channel_internal_api.c (original)
+++ team/group/media_formats/main/channel_internal_api.c Wed Feb  5 07:09:29 2014
@@ -165,7 +165,7 @@
 	int fdno;					/*!< Which fd had an event detected on */
 	int streamid;					/*!< For streaming playback, the schedule ID */
 	int vstreamid;					/*!< For streaming video playback, the schedule ID */
-	struct ast_format oldwriteformat;  /*!< Original writer format */
+	struct ast_format *oldwriteformat;  /*!< Original writer format */
 	int timingfd;					/*!< Timing fd */
 	enum ast_channel_state state;			/*!< State of line -- Don't write directly, use ast_setstate() */
 	int rings;					/*!< Number of rings so far */
@@ -182,10 +182,10 @@
 	struct ast_flags flags;				/*!< channel flags of AST_FLAG_ type */
 	int alertpipe[2];
 	struct ast_format_cap *nativeformats;         /*!< Kinds of data this channel can natively handle */
-	struct ast_format readformat;            /*!< Requested read format (after translation) */
-	struct ast_format writeformat;           /*!< Requested write format (after translation) */
-	struct ast_format rawreadformat;         /*!< Raw read format (before translation) */
-	struct ast_format rawwriteformat;        /*!< Raw write format (before translation) */
+	struct ast_format *readformat;            /*!< Requested read format (after translation) */
+	struct ast_format *writeformat;           /*!< Requested write format (after translation) */
+	struct ast_format *rawreadformat;         /*!< Raw read format (before translation) */
+	struct ast_format *rawwriteformat;        /*!< Raw write format (before translation) */
 	unsigned int emulate_dtmf_duration;		/*!< Number of ms left to emulate DTMF for */
 #ifdef HAVE_EPOLL
 	int epfd;
@@ -930,25 +930,50 @@
 {
 	chan->state = value;
 }
+void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format)
+{
+	ao2_cleanup(chan->oldwriteformat);
+	chan->oldwriteformat = ao2_bump(format);
+}
+void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
+{
+	ao2_cleanup(chan->rawreadformat);
+	chan->rawreadformat = ao2_bump(format);
+}
+void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
+{
+	ao2_cleanup(chan->rawwriteformat);
+	chan->rawwriteformat = ao2_bump(format);
+}
+void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
+{
+	ao2_cleanup(chan->readformat);
+	chan->readformat = ao2_bump(format);
+}
+void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
+{
+	ao2_cleanup(chan->writeformat);
+	chan->writeformat = ao2_bump(format);
+}
 struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan)
 {
-	return &chan->oldwriteformat;
+	return ao_bump(chan->oldwriteformat);
 }
 struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan)
 {
-	return &chan->rawreadformat;
+	return ao2_bump(chan->rawreadformat);
 }
 struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan)
 {
-	return &chan->rawwriteformat;
+	return ao2_bump(chan->rawwriteformat);
 }
 struct ast_format *ast_channel_readformat(struct ast_channel *chan)
 {
-	return &chan->readformat;
+	return ao2_bump(chan->readformat);
 }
 struct ast_format *ast_channel_writeformat(struct ast_channel *chan)
 {
-	return &chan->writeformat;
+	return ao2_bump(chan->writeformat);
 }
 struct ast_hangup_handler_list *ast_channel_hangup_handlers(struct ast_channel *chan)
 {




More information about the svn-commits mailing list