[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step1 r298328 - in /team/dvossel/f...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 13 17:43:06 CST 2010


Author: dvossel
Date: Mon Dec 13 17:43:02 2010
New Revision: 298328

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=298328
Log:
Introduction of new format id system.

The FORMAT2 tag will be replaced later by the FORMAT tag once the
old AST_FORMAT id system completely goes away.

Modified:
    team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h
    team/dvossel/fixtheworld_phase1_step1/main/format.c

Modified: team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h?view=diff&rev=298328&r1=298327&r2=298328
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h (original)
+++ team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h Mon Dec 13 17:43:02 2010
@@ -24,20 +24,99 @@
  * \author David Vossel <dvossel at digium.com>
  */
 
-#ifndef _AST_FORMAT_H_
-#define _AST_FORMAT_H_
-
-#define AST_FORMAT_ATTR_SIZE 128
+#ifndef _AST_FORMAT2_H_
+#define _AST_FORMAT2_H_
+
+#define AST_FORMAT2_ATTR_SIZE 128
+
+#define AST_FORMAT2_INC 100000
+
+/*! XXX TODO note, the FORMAT2 used in all of the following
+ * enums is temporary and will be replaced by FORMAT once the
+ * conversion from forat_t to ast_format takes place. */
+
+/* \brief Format Categories*/
+enum ast_format_type {
+    AST_FORMAT2_TYPE_AUDIO = 1 * AST_FORMAT2_INC,
+    AST_FORMAT2_TYPE_VIDEO = 2 * AST_FORMAT2_INC,
+    AST_FORMAT2_TYPE_IMAGE = 3 * AST_FORMAT2_INC,
+    AST_FORMAT2_TYPE_TEXT  = 4 * AST_FORMAT2_INC,
+};
+
+enum ast_format_id {
+	/*! G.723.1 compression */
+	AST_FORMAT2_G723_1          = 1 + AST_FORMAT2_TYPE_AUDIO,
+	/*! GSM compression */
+	AST_FORMAT2_GSM             = 2 + AST_FORMAT2_TYPE_AUDIO,
+	/*! Raw mu-law data (G.711) */
+	AST_FORMAT2_ULAW            = 3 + AST_FORMAT2_TYPE_AUDIO,
+	/*! Raw A-law data (G.711) */
+	AST_FORMAT2_ALAW            = 4 + AST_FORMAT2_TYPE_AUDIO,
+	/*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */
+	AST_FORMAT2_G726_AAL2       = 5 + AST_FORMAT2_TYPE_AUDIO,
+	/*! ADPCM (IMA) */
+	AST_FORMAT2_ADPCM           = 6 + AST_FORMAT2_TYPE_AUDIO,
+	/*! Raw 16-bit Signed Linear (8000 Hz) PCM */
+	AST_FORMAT2_SLINEAR         = 7 + AST_FORMAT2_TYPE_AUDIO,
+	/*! LPC10, 180 samples/frame */
+	AST_FORMAT2_LPC10           = 8 + AST_FORMAT2_TYPE_AUDIO,
+	/*! G.729A audio */
+	AST_FORMAT2_G729A           = 9 + AST_FORMAT2_TYPE_AUDIO,
+	/*! SpeeX Free Compression */
+	AST_FORMAT2_SPEEX           = 10 + AST_FORMAT2_TYPE_AUDIO,
+	/*! iLBC Free Compression */
+	AST_FORMAT2_ILBC            = 11 + AST_FORMAT2_TYPE_AUDIO,
+	/*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */
+	AST_FORMAT2_G726            = 12 + AST_FORMAT2_TYPE_AUDIO,
+	/*! G.722 */
+	AST_FORMAT2_G722            = 13 + AST_FORMAT2_TYPE_AUDIO,
+	/*! G.722.1 (also known as Siren7, 32kbps assumed) */
+	AST_FORMAT2_SIREN7          = 14 + AST_FORMAT2_TYPE_AUDIO,
+	/*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */
+	AST_FORMAT2_SIREN14         = 15 + AST_FORMAT2_TYPE_AUDIO,
+	/*! Raw 16-bit Signed Linear (16000 Hz) PCM */
+	AST_FORMAT2_SLINEAR16       = 16 + AST_FORMAT2_TYPE_AUDIO,
+	/*! G.719 (64 kbps assumed) */
+	AST_FORMAT2_G719	           = 17 + AST_FORMAT2_TYPE_AUDIO,
+	/*! SpeeX Wideband (16kHz) Free Compression */
+	AST_FORMAT2_SPEEX16         = 18 + AST_FORMAT2_TYPE_AUDIO,
+	/*! Raw mu-law data (G.711) */
+	AST_FORMAT2_TESTLAW         = 19 + AST_FORMAT2_TYPE_AUDIO,
+
+	/*! H.261 Video */
+	AST_FORMAT2_H261            = 1 + AST_FORMAT2_TYPE_VIDEO,
+	/*! H.263 Video */
+	AST_FORMAT2_H263            = 2 + AST_FORMAT2_TYPE_VIDEO,
+	/*! H.263+ Video */
+	AST_FORMAT2_H263_PLUS       = 3 + AST_FORMAT2_TYPE_VIDEO,
+	/*! H.264 Video */
+	AST_FORMAT2_H264            = 4 + AST_FORMAT2_TYPE_VIDEO,
+	/*! MPEG4 Video */
+	AST_FORMAT2_MP4_VIDEO       = 5 + AST_FORMAT2_TYPE_VIDEO,
+
+	/*! JPEG Images */
+	AST_FORMAT2_JPEG            = 1 + AST_FORMAT2_TYPE_IMAGE,
+	/*! PNG Images */
+	AST_FORMAT2_PNG             = 2 + AST_FORMAT2_TYPE_IMAGE,
+
+	/*! T.140 RED Text format RFC 4103 */
+	AST_FORMAT2_T140RED         = 1 + AST_FORMAT2_TYPE_TEXT,
+	/*! T.140 Text format - ITU T.140, RFC 4103 */
+	AST_FORMAT2_T140            = 2 + AST_FORMAT2_TYPE_TEXT,
+};
+
+/* Determine what category a format type is in */
+#define AST_FORMAT2_GET_TYPE(format) (((enum ast_format_id) (format->uid / AST_FORMAT2_INC)) * AST_FORMAT2_INC)
 
 /*! \brief This structure contains the buffer used for format attributes */
 struct ast_format_attr {
-    uint8_t format_attr[AST_FORMAT_ATTR_SIZE];
+    uint8_t format_attr[AST_FORMAT2_ATTR_SIZE];
 };
 
 /*! \brief Represents a media format within Asterisk. */
 struct ast_format {
     /*! The unique id representing this format from all the other formats. */
-    unsigned int uid;
+    enum ast_format_id uid;
     /*!  Attribute structure used to associate attributes with a format. */
     struct ast_format_attr *fattr;
 };
@@ -45,7 +124,7 @@
 /*! \brief A format must register an attribute interface if it requires the use of the format attributes void pointer */
 struct ast_format_attr_interface {
     /*! format type */
-    unsigned int id;
+    enum ast_format_id id;
 
     /*! \brief Determine if format_attr 1 is a subset of format_attr 2.
      *
@@ -69,24 +148,24 @@
  * with optional format attributes represented by format specific key value pairs.
  *
  * \details Example usage.
- * ast_format_set(format, AST_FORMAT_ULAW); // no capability attributes are needed for ULAW
- *
- * ast_format_set(format, AST_FORMAT_SILK, // SILK has capability attributes.
- *      AST_FORMAT_SILK_RATE, 24000,
- *      AST_FORMAT_SILK_RATE, 16000,
- *      AST_FORMAT_SILK_RATE, 12000,
- *      AST_FORMAT_SILK_RATE, 8000,
- *      AST_FORMAT_ATTR_END);
+ * ast_format_set(format, AST_FORMAT2_ULAW); // no capability attributes are needed for ULAW
+ *
+ * ast_format_set(format, AST_FORMAT2_SILK, // SILK has capability attributes.
+ *      AST_FORMAT2_SILK_RATE, 24000,
+ *      AST_FORMAT2_SILK_RATE, 16000,
+ *      AST_FORMAT2_SILK_RATE, 12000,
+ *      AST_FORMAT2_SILK_RATE, 8000,
+ *      AST_FORMAT2_ATTR_END);
  *
  * \return Pointer to ast_format object.
  */
-struct ast_format *ast_format_set(struct ast_format *format, unsigned int id, va_list ap);
+struct ast_format *ast_format_set(struct ast_format *format, enum ast_format_id id, va_list ap);
 
 /*! \brief This function is used to set an ast_format object to represent a media format
  * 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_FORMAT_SILK_CAP_RATE, 8000);
+ * is_8khz = ast_format_isset(format, AST_FORMAT2_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.
@@ -124,4 +203,4 @@
  */
 int ast_format_attr_unreg_interface(struct ast_format_attr_interface *interface);
 
-#endif /* _AST_FORMAT_H */
+#endif /* _AST_FORMAT2_H */

Modified: team/dvossel/fixtheworld_phase1_step1/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/main/format.c?view=diff&rev=298328&r1=298327&r2=298328
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/main/format.c (original)
+++ team/dvossel/fixtheworld_phase1_step1/main/format.c Mon Dec 13 17:43:02 2010
@@ -31,12 +31,12 @@
 #include "asterisk/version.h"
 #include "asterisk/format.h"
 
-struct ast_format *ast_format_set(struct ast_format *format, unsigned int id, va_list ap)
+struct ast_format *ast_format_set(struct ast_format *format, enum ast_format_id id, va_list ap)
 {
 	return NULL;
 }
 
-int ast_format_isset(struct ast_format *format,  va_list ap)
+int ast_format_isset(struct ast_format *format, va_list ap)
 {
 	return 0;
 }




More information about the asterisk-commits mailing list