[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r300383 - in /team/dvossel/f...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 4 19:39:38 UTC 2011


Author: dvossel
Date: Tue Jan  4 13:39:32 2011
New Revision: 300383

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=300383
Log:
format_t to ast_format conversion update

Modified:
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/abstract_jb.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/channel.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/data.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_pref.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/frame.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/frame_defs.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/mod_format.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/pbx.h
    team/dvossel/fixtheworld_phase1_step3/main/abstract_jb.c
    team/dvossel/fixtheworld_phase1_step3/main/app.c
    team/dvossel/fixtheworld_phase1_step3/main/channel.c
    team/dvossel/fixtheworld_phase1_step3/main/file.c
    team/dvossel/fixtheworld_phase1_step3/main/format.c
    team/dvossel/fixtheworld_phase1_step3/main/frame.c

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/abstract_jb.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/abstract_jb.h?view=diff&rev=300383&r1=300382&r2=300383
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/abstract_jb.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/abstract_jb.h Tue Jan  4 13:39:32 2011
@@ -32,7 +32,7 @@
 
 #include <sys/time.h>
 
-#include "asterisk/frame_defs.h"
+#include "asterisk/format.h"
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
@@ -97,7 +97,7 @@
 	/*! \brief The time the next frame should be played. */
 	long next;
 	/*! \brief Voice format of the last frame in. */
-	format_t last_format;
+	struct ast_format last_format;
 	/*! \brief File for frame timestamp tracing. */
 	FILE *logfile;
 	/*! \brief Jitterbuffer internal state flags. */

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/channel.h?view=diff&rev=300383&r1=300382&r2=300383
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/channel.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/channel.h Tue Jan  4 13:39:32 2011
@@ -507,12 +507,12 @@
 	const char * const type;
 	const char * const description;
 
-	format_t capabilities;  /*!< Bitmap of formats this channel can handle */
+	struct ast_cap *capabilities;  /*!< format capabilities this channel can handle */
 
 	int properties;         /*!< Technology Properties */
 
 	/*! \brief Requester - to set up call data structures (pvt's) */
-	struct ast_channel *(* const requester)(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
+	struct ast_channel *(* const requester)(const char *type, struct ast_cap *cap, const struct ast_channel *requestor, void *data, int *cause);
 
 	int (* const devicestate)(void *data);	/*!< Devicestate call back */
 
@@ -824,7 +824,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 */
-	format_t 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 */
@@ -839,11 +839,11 @@
 	int hangupcause;				/*!< Why is the channel hanged up. See causes.h */
 	unsigned int flags;				/*!< channel flags of AST_FLAG_ type */
 	int alertpipe[2];
-	format_t nativeformats;         /*!< Kinds of data this channel can natively handle */
-	format_t readformat;            /*!< Requested read format (after translation) */
-	format_t writeformat;           /*!< Requested write format (after translation) */
-	format_t rawreadformat;         /*!< Raw read format (before translation) */
-	format_t rawwriteformat;        /*!< Raw write format (before translation) */
+	struct ast_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) */
 	unsigned int emulate_dtmf_duration;		/*!< Number of ms left to emulate DTMF for */
 #ifdef HAVE_EPOLL
 	int epfd;
@@ -1243,7 +1243,7 @@
  * \brief Requests a channel
  *
  * \param type type of channel to request
- * \param format requested channel format (codec)
+ * \param format capabilities for requested channel
  * \param requestor channel asking for data
  * \param data data to pass to the channel requester
  * \param status status
@@ -1255,14 +1255,14 @@
  * \retval NULL failure
  * \retval non-NULL channel on success
  */
-struct ast_channel *ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status);
+struct ast_channel *ast_request(const char *type, struct ast_cap *cap, const struct ast_channel *requestor, void *data, int *status);
 
 /*!
  * \brief Request a channel of a given type, with data as optional information used
  *        by the low level module and attempt to place a call on it
  *
  * \param type type of channel to request
- * \param format requested channel format
+ * \param format capabilities for requested channel
  * \param requestor channel asking for data
  * \param data data to pass to the channel requester
  * \param timeout maximum amount of time to wait for an answer
@@ -1273,14 +1273,14 @@
  * \return Returns an ast_channel on success or no answer, NULL on failure.  Check the value of chan->_state
  * to know if the call was answered or not.
  */
-struct ast_channel *ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data,
+struct ast_channel *ast_request_and_dial(const char *type, struct ast_cap *cap, const struct ast_channel *requestor, void *data,
 	int timeout, int *reason, const char *cid_num, const char *cid_name);
 
 /*!
  * \brief Request a channel of a given type, with data as optional information used
  * by the low level module and attempt to place a call on it
  * \param type type of channel to request
- * \param format requested channel format
+ * \param format capabilities for requested channel
  * \param requestor channel requesting data
  * \param data data to pass to the channel requester
  * \param timeout maximum amount of time to wait for an answer
@@ -1291,7 +1291,7 @@
  * \return Returns an ast_channel on success or no answer, NULL on failure.  Check the value of chan->_state
  * to know if the call was answered or not.
  */
-struct ast_channel *__ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data,
+struct ast_channel *__ast_request_and_dial(const char *type, struct ast_cap *cap, const struct ast_channel *requestor, void *data,
 	int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
 
 /*!
@@ -1299,12 +1299,12 @@
  * \param caller in channel that requested orig
  * \param orig channel being replaced by the call forward channel
  * \param timeout maximum amount of time to wait for setup of new forward channel
- * \param format requested channel format
+ * \param format capabilities for requested channel
  * \param oh outgoing helper used with original channel
  * \param outstate reason why unsuccessful (if uncuccessful)
  * \return Returns the forwarded call's ast_channel on success or NULL on failure
  */
-struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, format_t format, struct outgoing_helper *oh, int *outstate);
+struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_cap *cap, struct outgoing_helper *oh, int *outstate);
 
 /*!
  * \brief Register a channel technology (a new channel driver)
@@ -1720,22 +1720,54 @@
 int ast_prod(struct ast_channel *chan);
 
 /*!
- * \brief Sets read format on channel chan
+ * \brief Sets read format on channel chan from capabilities
  * Set read format for channel to whichever component of "format" is best.
  * \param chan channel to change
- * \param format format to change to
+ * \param formats new formats to pick from for reading
  * \return Returns 0 on success, -1 on failure
  */
-int ast_set_read_format(struct ast_channel *chan, format_t format);
+int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_cap *formats);
+
+/*!
+ * \brief Sets read format on channel chan
+ * \param chan channel to change
+ * \param formats, format to set for reading
+ * \return Returns 0 on success, -1 on failure
+ */
+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 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
- * \param format new format for writing
+ * \param formats new formats to pick from for writing
  * \return Returns 0 on success, -1 on failure
  */
-int ast_set_write_format(struct ast_channel *chan, format_t format);
+int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_cap *formats);
+
+/*!
+ * \brief Sets write format on channel chan
+ * \param chan channel to change
+ * \param formats, format to set for writing
+ * \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 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
@@ -2000,9 +2032,15 @@
  */
 int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
 
-/*! Pick the best codec
- * Choose the best codec...  Uhhh...   Yah. */
-format_t ast_best_codec(format_t fmts);
+/*!
+ * \brief Pick the best codec
+ *
+ * \param capabilities to pick best codec out of
+ * \param result stucture to store the best codec in.
+ * \retval on success, pointer to result structure 
+ * \retval on failure, NULL
+ */
+struct ast_format *ast_best_codec(struct ast_cap *cap, struct ast_format *result);
 
 
 /*!

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/data.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/data.h?view=diff&rev=300383&r1=300382&r2=300383
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/data.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/data.h Tue Jan  4 13:39:32 2011
@@ -808,7 +808,7 @@
  * \return < 0 on error.
  * \return 0 on success.
  */
-int ast_data_add_codecs(struct ast_data *root, const char *node_name, format_t capability);
+int ast_data_add_codecs(struct ast_data *root, const char *node_name, struct ast_cap *capability);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h?view=diff&rev=300383&r1=300382&r2=300383
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h Tue Jan  4 13:39:32 2011
@@ -23,97 +23,93 @@
  * \author David Vossel <dvossel at digium.com>
  */
 
-#ifndef _AST_FORMATNEW_H_
-#define _AST_FORMATNEW_H_
-
-#define AST_FORMATNEW_ATTR_SIZE 128
-
-#define AST_FORMATNEW_INC 100000
+#ifndef _AST_FORMAT_H_
+#define _AST_FORMAT_H_
+
+#define AST_FORMAT_ATTR_SIZE 128
+
+#define AST_FORMAT_INC 100000
 
 /*! This is the value that ends a var list of format attribute
  * key value pairs. */
-#define AST_FORMATNEW_ATTR_END -1
-
-/*! XXX TODO note, the FORMATNEW tag used in all of the following
- * enums and defines is temporary and will be replaced by FORMAT once the
- * conversion from format_t to ast_format takes place. */
+#define AST_FORMAT_ATTR_END -1
 
 /* \brief Format Categories*/
 enum ast_format_type {
-	AST_FORMATNEW_TYPE_AUDIO = 1 * AST_FORMATNEW_INC,
-	AST_FORMATNEW_TYPE_VIDEO = 2 * AST_FORMATNEW_INC,
-	AST_FORMATNEW_TYPE_IMAGE = 3 * AST_FORMATNEW_INC,
-	AST_FORMATNEW_TYPE_TEXT  = 4 * AST_FORMATNEW_INC,
+	AST_FORMAT_TYPE_AUDIO = 1 * AST_FORMAT_INC,
+	AST_FORMAT_TYPE_VIDEO = 2 * AST_FORMAT_INC,
+	AST_FORMAT_TYPE_IMAGE = 3 * AST_FORMAT_INC,
+	AST_FORMAT_TYPE_TEXT  = 4 * AST_FORMAT_INC,
 };
 
 enum ast_format_id {
 	/*! G.723.1 compression */
-	AST_FORMATNEW_G723_1			= 1 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_G723_1			= 1 + AST_FORMAT_TYPE_AUDIO,
 	/*! GSM compression */
-	AST_FORMATNEW_GSM				= 2 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_GSM				= 2 + AST_FORMAT_TYPE_AUDIO,
 	/*! Raw mu-law data (G.711) */
-	AST_FORMATNEW_ULAW				= 3 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_ULAW				= 3 + AST_FORMAT_TYPE_AUDIO,
 	/*! Raw A-law data (G.711) */
-	AST_FORMATNEW_ALAW				= 4 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_ALAW				= 4 + AST_FORMAT_TYPE_AUDIO,
 	/*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */
-	AST_FORMATNEW_G726_AAL2			= 5 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_G726_AAL2			= 5 + AST_FORMAT_TYPE_AUDIO,
 	/*! ADPCM (IMA) */
-	AST_FORMATNEW_ADPCM				= 6 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_ADPCM				= 6 + AST_FORMAT_TYPE_AUDIO,
 	/*! Raw 16-bit Signed Linear (8000 Hz) PCM */
-	AST_FORMATNEW_SLINEAR			= 7 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_SLINEAR			= 7 + AST_FORMAT_TYPE_AUDIO,
 	/*! LPC10, 180 samples/frame */
-	AST_FORMATNEW_LPC10				= 8 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_LPC10				= 8 + AST_FORMAT_TYPE_AUDIO,
 	/*! G.729A audio */
-	AST_FORMATNEW_G729A				= 9 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_G729A				= 9 + AST_FORMAT_TYPE_AUDIO,
 	/*! SpeeX Free Compression */
-	AST_FORMATNEW_SPEEX				= 10 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_SPEEX				= 10 + AST_FORMAT_TYPE_AUDIO,
 	/*! iLBC Free Compression */
-	AST_FORMATNEW_ILBC				= 11 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_ILBC				= 11 + AST_FORMAT_TYPE_AUDIO,
 	/*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */
-	AST_FORMATNEW_G726				= 12 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_G726				= 12 + AST_FORMAT_TYPE_AUDIO,
 	/*! G.722 */
-	AST_FORMATNEW_G722				= 13 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_G722				= 13 + AST_FORMAT_TYPE_AUDIO,
 	/*! G.722.1 (also known as Siren7, 32kbps assumed) */
-	AST_FORMATNEW_SIREN7			= 14 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_SIREN7			= 14 + AST_FORMAT_TYPE_AUDIO,
 	/*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */
-	AST_FORMATNEW_SIREN14			= 15 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_SIREN14			= 15 + AST_FORMAT_TYPE_AUDIO,
 	/*! Raw 16-bit Signed Linear (16000 Hz) PCM */
-	AST_FORMATNEW_SLINEAR16			= 16 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_SLINEAR16			= 16 + AST_FORMAT_TYPE_AUDIO,
 	/*! G.719 (64 kbps assumed) */
-	AST_FORMATNEW_G719				= 17 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_G719				= 17 + AST_FORMAT_TYPE_AUDIO,
 	/*! SpeeX Wideband (16kHz) Free Compression */
-	AST_FORMATNEW_SPEEX16			= 18 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_SPEEX16			= 18 + AST_FORMAT_TYPE_AUDIO,
 	/*! Raw mu-law data (G.711) */
-	AST_FORMATNEW_TESTLAW			= 19 + AST_FORMATNEW_TYPE_AUDIO,
+	AST_FORMAT_TESTLAW			= 19 + AST_FORMAT_TYPE_AUDIO,
 
 	/*! H.261 Video */
-	AST_FORMATNEW_H261				= 1 + AST_FORMATNEW_TYPE_VIDEO,
+	AST_FORMAT_H261				= 1 + AST_FORMAT_TYPE_VIDEO,
 	/*! H.263 Video */
-	AST_FORMATNEW_H263				= 2 + AST_FORMATNEW_TYPE_VIDEO,
+	AST_FORMAT_H263				= 2 + AST_FORMAT_TYPE_VIDEO,
 	/*! H.263+ Video */
-	AST_FORMATNEW_H263_PLUS			= 3 + AST_FORMATNEW_TYPE_VIDEO,
+	AST_FORMAT_H263_PLUS			= 3 + AST_FORMAT_TYPE_VIDEO,
 	/*! H.264 Video */
-	AST_FORMATNEW_H264				= 4 + AST_FORMATNEW_TYPE_VIDEO,
+	AST_FORMAT_H264				= 4 + AST_FORMAT_TYPE_VIDEO,
 	/*! MPEG4 Video */
-	AST_FORMATNEW_MP4_VIDEO			= 5 + AST_FORMATNEW_TYPE_VIDEO,
+	AST_FORMAT_MP4_VIDEO			= 5 + AST_FORMAT_TYPE_VIDEO,
 
 	/*! JPEG Images */
-	AST_FORMATNEW_JPEG				= 1 + AST_FORMATNEW_TYPE_IMAGE,
+	AST_FORMAT_JPEG				= 1 + AST_FORMAT_TYPE_IMAGE,
 	/*! PNG Images */
-	AST_FORMATNEW_PNG				= 2 + AST_FORMATNEW_TYPE_IMAGE,
+	AST_FORMAT_PNG				= 2 + AST_FORMAT_TYPE_IMAGE,
 
 	/*! T.140 RED Text format RFC 4103 */
-	AST_FORMATNEW_T140RED			= 1 + AST_FORMATNEW_TYPE_TEXT,
+	AST_FORMAT_T140RED			= 1 + AST_FORMAT_TYPE_TEXT,
 	/*! T.140 Text format - ITU T.140, RFC 4103 */
-	AST_FORMATNEW_T140				= 2 + AST_FORMATNEW_TYPE_TEXT,
+	AST_FORMAT_T140				= 2 + AST_FORMAT_TYPE_TEXT,
 };
 
 /*! Determine what type of media a ast_format_id is. */
-#define AST_FORMATNEW_GET_TYPE(id) (((enum ast_format_id) (id / AST_FORMATNEW_INC)) * AST_FORMATNEW_INC)
+#define AST_FORMAT_GET_TYPE(id) (((enum ast_format_id) (id / AST_FORMAT_INC)) * AST_FORMAT_INC)
 
 /*! \brief This structure contains the buffer used for format attributes */
 struct ast_format_attr {
-	uint8_t format_attr[AST_FORMATNEW_ATTR_SIZE];
+	uint8_t format_attr[AST_FORMAT_ATTR_SIZE];
 };
 
 /*! \brief Represents a media format within Asterisk. */
@@ -163,17 +159,17 @@
  * \param format to set
  * \param id, format id to set on format
  * \param set_attributes, are there attributes to set on this format. 0 == false, 1 == True.
- * \param var list of attribute key value pairs, must end with AST_FORMATNEW_ATTR_END;
+ * \param var list of attribute key value pairs, must end with AST_FORMAT_ATTR_END;
  *
  * \details Example usage.
- * ast_format_set(format, AST_FORMATNEW_ULAW, 0); // no capability attributes are needed for ULAW
- *
- * ast_format_set(format, AST_FORMATNEW_SILK, 1, // SILK has capability attributes.
- *	  AST_FORMATNEW_SILK_ATTR_RATE, 24000,
- *	  AST_FORMATNEW_SILK_ATTR_RATE, 16000,
- *	  AST_FORMATNEW_SILK_ATTR_RATE, 12000,
- *	  AST_FORMATNEW_SILK_ATTR_RATE, 8000,
- *	  AST_FORMATNEW_ATTR_END);
+ * ast_format_set(format, AST_FORMAT_ULAW, 0); // no capability attributes are needed for ULAW
+ *
+ * ast_format_set(format, AST_FORMAT_SILK, 1, // SILK has capability attributes.
+ *	  AST_FORMAT_SILK_ATTR_RATE, 24000,
+ *	  AST_FORMAT_SILK_ATTR_RATE, 16000,
+ *	  AST_FORMAT_SILK_ATTR_RATE, 12000,
+ *	  AST_FORMAT_SILK_ATTR_RATE, 8000,
+ *	  AST_FORMAT_ATTR_END);
  *
  * \return Pointer to ast_format object, same pointer that is passed in
  * by the first argument.
@@ -185,7 +181,7 @@
  * with optional capability attributes represented by format specific key value pairs.
  *
  * \details Example usage. Is this SILK format capable of 8khz
- * is_8khz = ast_format_isset(format, AST_FORMATNEW_SILK_CAP_RATE, 8000);
+ * is_8khz = ast_format_isset(format, AST_FORMAT_SILK_CAP_RATE, 8000);
  *
  * \return 0, The format key value pairs are within the capabilities defined in this structure.
  * \return -1, The format key value pairs are _NOT_ within the capabilities of this structure.
@@ -254,4 +250,4 @@
  */
 int ast_format_attr_init(void);
 
-#endif /* _AST_FORMATNEW_H */
+#endif /* _AST_FORMAT_H */

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_pref.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_pref.h?view=diff&rev=300383&r1=300382&r2=300383
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_pref.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_pref.h Tue Jan  4 13:39:32 2011
@@ -24,7 +24,8 @@
 #ifndef _AST_FORMATPREF_H_
 #define _AST_FORMATPREF_H_
 
-#include "asterisk/frame_defs.h"
+#include "asterisk/format.h"
+#include "asterisk/format_cap.h"
 
 #define AST_CODEC_PREF_SIZE 64
 struct ast_codec_pref {
@@ -59,33 +60,36 @@
 
 /*!
  * \brief Codec located at a particular place in the preference index.
- * \arg \ref AudioCodecPref
+ * \param preference structure to get the codec out of
+ * \param index to retrieve from
+ * \param retult ast_format structure to store the index value in
+ * \return pointer to input ast_format on success, NULL on failure
 */
-format_t ast_codec_pref_index(struct ast_codec_pref *pref, int index);
+struct ast_format *ast_codec_pref_index(struct ast_codec_pref *pref, int index, struct ast_format *result);
 
 /*! \brief Remove audio a codec from a preference list */
-void ast_codec_pref_remove(struct ast_codec_pref *pref, format_t format);
+void ast_codec_pref_remove(struct ast_codec_pref *pref, struct ast_format *format);
 
 /*! \brief Append a audio codec to a preference list, removing it first if it was already there
 */
-int ast_codec_pref_append(struct ast_codec_pref *pref, format_t format);
+int ast_codec_pref_append(struct ast_codec_pref *pref, struct ast_format *format);
 
 /*! \brief Prepend an audio codec to a preference list, removing it first if it was already there
 */
-void ast_codec_pref_prepend(struct ast_codec_pref *pref, format_t format, int only_if_existing);
+void ast_codec_pref_prepend(struct ast_codec_pref *pref, struct ast_format *format, int only_if_existing);
 
 /*! \brief Select the best audio format according to preference list from supplied options.
    If "find_best" is non-zero then if nothing is found, the "Best" format of
    the format list is selected, otherwise 0 is returned. */
-format_t ast_codec_choose(struct ast_codec_pref *pref, format_t formats, int find_best);
+struct ast_format *ast_codec_choose(struct ast_codec_pref *pref, struct ast_cap *cap, int find_best, struct ast_format *result);
 
 /*! \brief Set packet size for codec
 */
-int ast_codec_pref_setsize(struct ast_codec_pref *pref, format_t format, int framems);
+int ast_codec_pref_setsize(struct ast_codec_pref *pref, struct ast_format *format, int framems);
 
 /*! \brief Get packet size for codec
 */
-struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, format_t format);
+struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, struct ast_format *format);
 
 /*! \brief Dump audio codec preference list into a string */
 int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size);

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/frame.h?view=diff&rev=300383&r1=300382&r2=300383
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/frame.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/frame.h Tue Jan  4 13:39:32 2011
@@ -31,8 +31,8 @@
 
 #include <sys/time.h>
 
-#include "asterisk/frame_defs.h"
 #include "asterisk/format_pref.h"
+#include "asterisk/format.h"
 #include "asterisk/endian.h"
 #include "asterisk/linkedlists.h"
 
@@ -130,7 +130,7 @@
 
 union ast_frame_subclass {
 	int integer;
-	format_t codec;
+	struct ast_format format;
 };
 
 /*! \brief Data structure associated with a single frame of data
@@ -233,78 +233,6 @@
 /*! Reject link request */
 #define AST_HTML_LINKREJECT	20
 
-/* Data formats for capabilities and frames alike */
-/*! G.723.1 compression */
-#define AST_FORMAT_G723_1     (1ULL << 0)
-/*! GSM compression */
-#define AST_FORMAT_GSM        (1ULL << 1)
-/*! Raw mu-law data (G.711) */
-#define AST_FORMAT_ULAW       (1ULL << 2)
-/*! Raw A-law data (G.711) */
-#define AST_FORMAT_ALAW       (1ULL << 3)
-/*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */
-#define AST_FORMAT_G726_AAL2  (1ULL << 4)
-/*! ADPCM (IMA) */
-#define AST_FORMAT_ADPCM      (1ULL << 5)
-/*! Raw 16-bit Signed Linear (8000 Hz) PCM */
-#define AST_FORMAT_SLINEAR    (1ULL << 6)
-/*! LPC10, 180 samples/frame */
-#define AST_FORMAT_LPC10      (1ULL << 7)
-/*! G.729A audio */
-#define AST_FORMAT_G729A      (1ULL << 8)
-/*! SpeeX Free Compression */
-#define AST_FORMAT_SPEEX      (1ULL << 9)
-/*! iLBC Free Compression */
-#define AST_FORMAT_ILBC       (1ULL << 10)
-/*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */
-#define AST_FORMAT_G726       (1ULL << 11)
-/*! G.722 */
-#define AST_FORMAT_G722       (1ULL << 12)
-/*! G.722.1 (also known as Siren7, 32kbps assumed) */
-#define AST_FORMAT_SIREN7     (1ULL << 13)
-/*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */
-#define AST_FORMAT_SIREN14    (1ULL << 14)
-/*! Raw 16-bit Signed Linear (16000 Hz) PCM */
-#define AST_FORMAT_SLINEAR16  (1ULL << 15)
-/*! Maximum audio mask */
-#define AST_FORMAT_AUDIO_MASK 0xFFFF0000FFFFULL
-/*! JPEG Images */
-#define AST_FORMAT_JPEG       (1ULL << 16)
-/*! PNG Images */
-#define AST_FORMAT_PNG        (1ULL << 17)
-/*! H.261 Video */
-#define AST_FORMAT_H261       (1ULL << 18)
-/*! H.263 Video */
-#define AST_FORMAT_H263       (1ULL << 19)
-/*! H.263+ Video */
-#define AST_FORMAT_H263_PLUS  (1ULL << 20)
-/*! H.264 Video */
-#define AST_FORMAT_H264       (1ULL << 21)
-/*! MPEG4 Video */
-#define AST_FORMAT_MP4_VIDEO  (1ULL << 22)
-#define AST_FORMAT_VIDEO_MASK ((((1ULL << 25)-1) & ~(AST_FORMAT_AUDIO_MASK)) | 0x7FFF000000000000ULL)
-/*! T.140 RED Text format RFC 4103 */
-#define AST_FORMAT_T140RED    (1ULL << 26)
-/*! T.140 Text format - ITU T.140, RFC 4103 */
-#define AST_FORMAT_T140       (1ULL << 27)
-/*! Maximum text mask */
-#define AST_FORMAT_MAX_TEXT   (1ULL << 28)
-#define AST_FORMAT_TEXT_MASK  (((1ULL << 30)-1) & ~(AST_FORMAT_AUDIO_MASK) & ~(AST_FORMAT_VIDEO_MASK))
-/*! G.719 (64 kbps assumed) */
-#define AST_FORMAT_G719	      (1ULL << 32)
-/*! SpeeX Wideband (16kHz) Free Compression */
-#define AST_FORMAT_SPEEX16    (1ULL << 33)
-/*! Raw mu-law data (G.711) */
-#define AST_FORMAT_TESTLAW    (1ULL << 47)
-/*! Reserved bit - do not use
- * \warning We use this bit internally for iteration.  Additionally, using this
- * bit will severely break the implementation of codec prefs within IAX2, as we
- * rely on the equivalence of UTF-8 and ASCII.  The codec represented by this
- * bit should use the first two-byte encoding of UTF-8, which is not presently
- * accounted for.  Hence, we reserve this bit as unused.
- */
-#define AST_FORMAT_RESERVED   (1ULL << 63)
-
 enum ast_control_frame_type {
 	AST_CONTROL_HANGUP = 1,		/*!< Other end has hungup */
 	AST_CONTROL_RING = 2,		/*!< Local ring */
@@ -501,7 +429,7 @@
 
 /*! \brief Definition of supported media formats (codecs) */
 struct ast_format_list {
-	format_t bits;	/*!< bitmask value */
+	enum ast_format_id id;    /*!< The format unique id */
 	char *name;	/*!< short name */
 	int samplespersecond; /*!< Number of samples per second (8000/16000) */
 	char *desc;	/*!< Description */
@@ -570,17 +498,17 @@
 #endif
 
 /*! \brief Parse an "allow" or "deny" line in a channel or device configuration
-        and update the capabilities mask and pref if provided.
+        and update the capabilities and pref if provided.
 	Video codecs are not added to codec preference lists, since we can not transcode
 	\return Returns number of errors encountered during parsing
  */
-int ast_parse_allow_disallow(struct ast_codec_pref *pref, format_t *mask, const char *list, int allowing);
+int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_cap *cap, const char *list, int allowing);
 
 /*! \brief Get the name of a format
  * \param format id of format
  * \return A static string containing the name of the format or "unknown" if unknown.
  */
-char* ast_getformatname(format_t format);
+char* ast_getformatname(struct ast_format *format);
 
 /*! \brief Get the names of a set of formats
  * \param buf a buffer for the output string
@@ -590,21 +518,22 @@
  * ex: for format=AST_FORMAT_GSM|AST_FORMAT_SPEEX|AST_FORMAT_ILBC it will return "0x602 (GSM|SPEEX|ILBC)"
  * \return The return value is buf.
  */
-char* ast_getformatname_multiple(char *buf, size_t size, format_t format);
+char* ast_getformatname_multiple(char *buf, size_t size, struct ast_cap *cap);
 
 /*!
  * \brief Gets a format from a name.
  * \param name string of format
- * \return This returns the form of the format in binary on success, 0 on error.
- */
-format_t ast_getformatbyname(const char *name);
+ * \param format structure to return the format in.
+ * \return This returns the format pointer given to it on success and NULL on failure
+ */
+struct ast_format *ast_getformatbyname(const char *name, struct ast_format *format);
 
 /*! \brief Get a name from a format 
  * Gets a name from a format
- * \param codec codec number (1,2,4,8,16,etc.)
+ * \param format to get name of
  * \return This returns a static string identifying the format on success, 0 on error.
  */
-char *ast_codec2str(format_t codec);
+char *ast_codec2str(struct ast_format *format);
 
 /*! \name AST_Smoother 
 */
@@ -660,16 +589,16 @@
 int ast_codec_get_samples(struct ast_frame *f);
 
 /*! \brief Returns the number of bytes for the number of samples of the given format */
-int ast_codec_get_len(format_t format, int samples);
+int ast_codec_get_len(struct ast_format *format, int samples);
 
 /*! \brief Appends a frame to the end of a list of frames, truncating the maximum length of the list */
 struct ast_frame *ast_frame_enqueue(struct ast_frame *head, struct ast_frame *f, int maxlen, int dupe);
 
 
 /*! \brief Gets duration in ms of interpolation frame for a format */
-static inline int ast_codec_interp_len(format_t format) 
+static inline int ast_codec_interp_len(struct ast_format *format)
 { 
-	return (format == AST_FORMAT_ILBC) ? 30 : 20;
+	return (format->id == AST_FORMAT_ILBC) ? 30 : 20;
 }
 
 /*!
@@ -694,9 +623,9 @@
 /*!
  * \brief Get the sample rate for a given format.
  */
-static force_inline int ast_format_rate(format_t format)
+static force_inline int ast_format_rate(struct ast_format *format)
 {
-	switch (format) {
+	switch (format->id) {
 	case AST_FORMAT_G722:
 	case AST_FORMAT_SLINEAR16:
 	case AST_FORMAT_SIREN7:

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/frame_defs.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/frame_defs.h?view=diff&rev=300383&r1=300382&r2=300383
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/frame_defs.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/frame_defs.h Tue Jan  4 13:39:32 2011
@@ -29,7 +29,7 @@
 extern "C" {
 #endif
 
-typedef int64_t format_t;
+typedef int64_t format_lol;
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/mod_format.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/mod_format.h?view=diff&rev=300383&r1=300382&r2=300383
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/mod_format.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/mod_format.h Tue Jan  4 13:39:32 2011
@@ -40,7 +40,7 @@
  * fields, and then calls ast_format_register() with the (readonly)
  * structure as an argument.
  */
-struct ast_format {
+struct ast_format_def {
 	char name[80];		/*!< Name of format */
 	char exts[80];		/*!< Extensions (separated by | if more than one) 
 	    			this format can read.  First is assumed for writing (e.g. .mp3) */
@@ -99,7 +99,7 @@
  */
 struct ast_filestream {
 	/*! Everybody reserves a block of AST_RESERVED_POINTERS pointers for us */
-	struct ast_format *fmt;	/* need to write to the lock and usecnt */
+	struct ast_format_def *fmt;	/* need to write to the lock and usecnt */
 	int flags;
 	mode_t mode;
 	char *open_filename;
@@ -127,7 +127,7 @@
  * \retval 0 on success
  * \retval -1 on failure
  */
-int __ast_format_register(const struct ast_format *f, struct ast_module *mod);
+int __ast_format_register(const struct ast_format_def *f, struct ast_module *mod);
 #define ast_format_register(f) __ast_format_register(f, ast_module_info->self)
 
 /*! 

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/pbx.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/pbx.h?view=diff&rev=300383&r1=300382&r2=300383
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/pbx.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/pbx.h Tue Jan  4 13:39:32 2011
@@ -887,11 +887,11 @@
 
 /*! Synchronously or asynchronously make an outbound call and send it to a
    particular extension */
-int ast_pbx_outgoing_exten(const char *type, format_t format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_exten(const char *type, struct ast_format *format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
 
 /*! Synchronously or asynchronously make an outbound call and send it to a
    particular application with given extension */
-int ast_pbx_outgoing_app(const char *type, format_t format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_app(const char *type, struct ast_format *format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
 
 /*!
  * \brief Evaluate a condition

Modified: team/dvossel/fixtheworld_phase1_step3/main/abstract_jb.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/abstract_jb.c?view=diff&rev=300383&r1=300382&r2=300383
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/abstract_jb.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/abstract_jb.c Tue Jan  4 13:39:32 2011
@@ -398,7 +398,7 @@
 	}
 
 	while (now >= jb->next) {
-		interpolation_len = ast_codec_interp_len(jb->last_format);
+		interpolation_len = ast_codec_interp_len(&jb->last_format);
 
 		res = jbimpl->get(jbobj, &f, now, interpolation_len);
 
@@ -409,13 +409,13 @@
 		case JB_IMPL_DROP:
 			jb_framelog("\tJB_GET {now=%ld}: %s frame with ts=%ld and len=%ld\n",
 				now, jb_get_actions[res], f->ts, f->len);
-			jb->last_format = f->subclass.codec;
+			ast_format_copy(&f->subclass.format, &jb->last_format);
 			ast_frfree(f);
 			break;
 		case JB_IMPL_INTERP:
 			/* interpolate a frame */
 			f = &finterp;
-			f->subclass.codec = jb->last_format;
+			ast_format_copy(&jb->last_format, &f->subclass.format);
 			f->samples  = interpolation_len * 8;
 			f->src  = "JB interpolation";
 			f->delivery = ast_tvadd(jb->timebase, ast_samp2tv(jb->next, 1000));
@@ -476,7 +476,7 @@
 	jb->next = jbimpl->next(jbobj);
 
 	/* Init last format for a first time. */
-	jb->last_format = frr->subclass.codec;
+	ast_format_copy(&frr->subclass.format, &jb->last_format);
 
 	/* Create a frame log file */
 	if (ast_test_flag(jbconf, AST_JB_LOG)) {

Modified: team/dvossel/fixtheworld_phase1_step3/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/app.c?view=diff&rev=300383&r1=300382&r2=300383
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/app.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/app.c Tue Jan  4 13:39:32 2011
@@ -405,15 +405,15 @@
 	int fd;
 	int autoclose;
 	int allowoverride;
-	int origwfmt;
+	struct ast_format origwfmt;
 };
 
 static void linear_release(struct ast_channel *chan, void *params)
 {
 	struct linear_state *ls = params;
 
-	if (ls->origwfmt && ast_set_write_format(chan, ls->origwfmt)) {
-		ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, ls->origwfmt);
+	if (ls->origwfmt.id && ast_set_write_format(chan, &ls->origwfmt)) {
+		ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, ls->origwfmt.id);
 	}
 
 	if (ls->autoclose) {
@@ -429,11 +429,12 @@
 	struct linear_state *ls = data;
 	struct ast_frame f = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass.codec = AST_FORMAT_SLINEAR,
 		.data.ptr = buf + AST_FRIENDLY_OFFSET / 2,
 		.offset = AST_FRIENDLY_OFFSET,
 	};
 	int res;
+
+	ast_format_set(&f.subclass.format, AST_FORMAT_SLINEAR, 0);
 
 	len = samples * 2;
 	if (len > sizeof(buf) - AST_FRIENDLY_OFFSET) {
@@ -467,7 +468,7 @@
 		ast_clear_flag(chan, AST_FLAG_WRITE_INT);
 	}
 
-	ls->origwfmt = chan->writeformat;
+	ast_format_copy(&chan->writeformat, &ls->origwfmt);
 
 	if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
 		ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", chan->name);

Modified: team/dvossel/fixtheworld_phase1_step3/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/channel.c?view=diff&rev=300383&r1=300382&r2=300383
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/channel.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/channel.c Tue Jan  4 13:39:32 2011
@@ -989,12 +989,11 @@
 }
 
 /*! \brief Pick the best audio codec */
-format_t ast_best_codec(format_t fmts)
+struct ast_format *ast_best_codec(struct ast_cap *cap, struct ast_format *result)
 {
 	/* This just our opinion, expressed in code.  We are asked to choose
 	   the best codec to use, given no information */
-	int x;
-	static const format_t prefs[] =
+	static const enum ast_format_id prefs[] =
 	{
 		/*! Okay, ulaw is used by all telephony equipment, so start with it */
 		AST_FORMAT_ULAW,
@@ -1033,18 +1032,19 @@
 	};
 	char buf[512];
 
-	/* Strip out video */
-	fmts &= AST_FORMAT_AUDIO_MASK;
-	
-	/* Find the first preferred codec in the format given */
-	for (x = 0; x < ARRAY_LEN(prefs); x++) {
-		if (fmts & prefs[x])
-			return prefs[x];
-	}
-
-	ast_log(LOG_WARNING, "Don't know any of %s formats\n", ast_getformatname_multiple(buf, sizeof(buf), fmts));
-
-	return 0;
+	ast_cap_iter_start(cap);
+	while (!ast_cap_iter_next(cap, result)) {
+		if (result->id == prefs[x]) {
+			ast_cap_iter_end(cap);
+			return result;
+		}
+	}
+	ast_cap_iter_end(cap);
+

[... 444 lines stripped ...]



More information about the asterisk-commits mailing list