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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 4 21:43:07 UTC 2011


Author: dvossel
Date: Tue Jan  4 15:43:03 2011
New Revision: 300519

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=300519
Log:
changes required to get audiohook.c to compile with ast_format conversion

Modified:
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/audiohook.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/callerid.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/slinfactory.h
    team/dvossel/fixtheworld_phase1_step3/main/audiohook.c

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/audiohook.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/audiohook.h?view=diff&rev=300519&r1=300518&r2=300519
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/audiohook.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/audiohook.h Tue Jan  4 15:43:03 2011
@@ -30,7 +30,6 @@
 /* these two are used in struct ast_audiohook */
 #include "asterisk/lock.h"
 #include "asterisk/linkedlists.h"
-#include "asterisk/frame_defs.h"
 #include "asterisk/slinfactory.h"
 
 enum ast_audiohook_type {
@@ -104,7 +103,7 @@
 	struct ast_slinfactory write_factory;                  /*!< Factory where frames written to the channel will go through */
 	struct timeval read_time;                              /*!< Last time read factory was fed */
 	struct timeval write_time;                             /*!< Last time write factory was fed */
-	int format;                                            /*!< Format translation path is setup as */
+	struct ast_format format;                              /*!< Format translation path is setup as */
 	struct ast_trans_pvt *trans_pvt;                       /*!< Translation path for reading frames */
 	ast_audiohook_manipulate_callback manipulate_callback; /*!< Manipulation callback */
 	struct ast_audiohook_options options;                  /*!< Applicable options */
@@ -142,7 +141,7 @@
  * \param format Format of frame remote side wants back
  * \return Returns frame on success, NULL on failure
  */
-struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, format_t format);
+struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, struct ast_format *format);
 
 /*! \brief Attach audiohook to channel
  * \param chan Channel

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/callerid.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/callerid.h?view=diff&rev=300519&r1=300518&r2=300519
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/callerid.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/callerid.h Tue Jan  4 15:43:03 2011
@@ -101,7 +101,7 @@
  * \return It returns the size
  * (in bytes) of the data (if it returns a size of 0, there is probably an error)
  */
-int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, format_t codec);
+int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, struct ast_format *codec);
 
 /*! \brief Create a callerID state machine
  * \param cid_signalling Type of signalling in use
@@ -124,7 +124,7 @@
  * \retval 0 for "needs more samples"
  * \retval 1 if the CallerID spill reception is complete.
  */
-int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples, format_t codec);
+int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples, struct ast_format *codec);
 
 /*! \brief Read samples into the state machine.
  * \param cid Which state machine to act upon
@@ -138,7 +138,7 @@
  * \retval 0 for "needs more samples"
  * \retval 1 if the CallerID spill reception is complete.
  */
-int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int samples, format_t codec);
+int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int samples, struct ast_format *codec);
 
 /*! \brief Extract info out of callerID state machine.  Flags are listed above
  * \param cid Callerid state machine to act upon
@@ -177,7 +177,7 @@
  * \details
  * Acts like callerid_generate except uses an asterisk format callerid string.
  */
-int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, format_t codec);
+int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec);
 
 /*!
  * \brief Generate message waiting indicator
@@ -192,13 +192,13 @@
  * \see callerid_generate() for more info as it uses the same encoding
  * \version 1.6.1 changed mdmf parameter to type, added name, number and flags for caller id message generation
  */
-int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, format_t codec, const char *name,
+int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, struct ast_format *codec, const char *name,
 	const char *number, int flags);
 
 /*! \brief Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm)
  * \see ast_callerid_generate() for other details
  */
-int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, format_t codec);
+int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec);
 
 /*! \brief Destructively parse inbuf into name and location (or number)
  * \details
@@ -223,7 +223,7 @@
  * \param codec Which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW)
  * \return Returns -1 on error (if len is less than 2400), 0 on success.
  */
-int ast_gen_cas(unsigned char *outbuf, int sas, int len, format_t codec);
+int ast_gen_cas(unsigned char *outbuf, int sas, int len, struct ast_format *codec);
 
 /*!
  * \brief Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/slinfactory.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/slinfactory.h?view=diff&rev=300519&r1=300518&r2=300519
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/slinfactory.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/slinfactory.h Tue Jan  4 15:43:03 2011
@@ -37,8 +37,8 @@
 	short *offset;                           /*!< Offset into the hold where audio begins */
 	size_t holdlen;                          /*!< Number of samples currently in the hold */
 	unsigned int size;                       /*!< Number of samples currently in the factory */
-	format_t format;                         /*!< Current format the translation path is converting from */
-	format_t output_format;                  /*!< The output format desired */
+	struct ast_format format;                /*!< Current format the translation path is converting from */
+	struct ast_format output_format;         /*!< The output format desired */
 };
 
 /*!

Modified: team/dvossel/fixtheworld_phase1_step3/main/audiohook.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/audiohook.c?view=diff&rev=300519&r1=300518&r2=300519
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/audiohook.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/audiohook.c Tue Jan  4 15:43:03 2011
@@ -40,7 +40,7 @@
 
 struct ast_audiohook_translate {
 	struct ast_trans_pvt *trans_pvt;
-	format_t format;
+	struct ast_format format;
 };
 
 struct ast_audiohook_list {
@@ -185,11 +185,11 @@
 	short buf[samples];
 	struct ast_frame frame = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass.codec = AST_FORMAT_SLINEAR,
 		.data.ptr = buf,
 		.datalen = sizeof(buf),
 		.samples = samples,
 	};
+	ast_format_set(&frame.subclass.format, AST_FORMAT_SLINEAR, 0);
 
 	/* Ensure the factory is able to give us the samples we want */
 	if (samples > ast_slinfactory_available(factory))
@@ -212,11 +212,11 @@
 	short buf1[samples], buf2[samples], *read_buf = NULL, *write_buf = NULL, *final_buf = NULL, *data1 = NULL, *data2 = NULL;
 	struct ast_frame frame = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass.codec = AST_FORMAT_SLINEAR,
 		.data.ptr = NULL,
 		.datalen = sizeof(buf1),
 		.samples = samples,
 	};
+	ast_format_set(&frame.subclass.format, AST_FORMAT_SLINEAR, 0);
 
 	/* Make sure both factories have the required samples */
 	usable_read = (ast_slinfactory_available(&audiohook->read_factory) >= samples ? 1 : 0);
@@ -304,23 +304,24 @@
  * \param format Format of frame remote side wants back
  * \return Returns frame on success, NULL on failure
  */
-struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, format_t format)
+struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, struct ast_format *format)
 {
 	struct ast_frame *read_frame = NULL, *final_frame = NULL;
+	struct ast_format tmp_fmt;
 
 	if (!(read_frame = (direction == AST_AUDIOHOOK_DIRECTION_BOTH ? audiohook_read_frame_both(audiohook, samples) : audiohook_read_frame_single(audiohook, samples, direction))))
 		return NULL;
 
 	/* If they don't want signed linear back out, we'll have to send it through the translation path */
-	if (format != AST_FORMAT_SLINEAR) {
+	if (format->id != AST_FORMAT_SLINEAR) {
 		/* Rebuild translation path if different format then previously */
-		if (audiohook->format != format) {
+		if (ast_format_cmp(&audiohook->format, format) == AST_FORMAT_CMP_NOT_EQUAL) {
 			if (audiohook->trans_pvt) {
 				ast_translator_free_path(audiohook->trans_pvt);
 				audiohook->trans_pvt = NULL;
 			}
 			/* Setup new translation path for this format... if we fail we can't very well return signed linear so free the frame and return nothing */
-			if (!(audiohook->trans_pvt = ast_translator_build_path(format, AST_FORMAT_SLINEAR))) {
+			if (!(audiohook->trans_pvt = ast_translator_build_path(format, ast_format_set(&tmp_fmt, AST_FORMAT_SLINEAR, 0)))) {
 				ast_frfree(read_frame);
 				return NULL;
 			}
@@ -619,17 +620,18 @@
 	struct ast_audiohook_translate *out_translate = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook_list->out_translate[0] : &audiohook_list->out_translate[1]);
 	struct ast_frame *start_frame = frame, *middle_frame = frame, *end_frame = frame;
 	struct ast_audiohook *audiohook = NULL;
+	struct ast_format tmp_fmt;
 	int samples = frame->samples;
 
 	/* ---Part_1. translate start_frame to SLINEAR if necessary. */
 	/* If the frame coming in is not signed linear we have to send it through the in_translate path */
-	if (frame->subclass.codec != AST_FORMAT_SLINEAR) {
-		if (in_translate->format != frame->subclass.codec) {
+	if (frame->subclass.format.id != AST_FORMAT_SLINEAR) {
+		if (ast_format_cmp(&in_translate->format, &frame->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {
 			if (in_translate->trans_pvt)
 				ast_translator_free_path(in_translate->trans_pvt);
-			if (!(in_translate->trans_pvt = ast_translator_build_path(AST_FORMAT_SLINEAR, frame->subclass.codec)))
+			if (!(in_translate->trans_pvt = ast_translator_build_path(ast_format_set(&tmp_fmt, AST_FORMAT_SLINEAR, 0), &frame->subclass.format)))
 				return frame;
-			in_translate->format = frame->subclass.codec;
+			ast_format_copy(&frame->subclass.format, &in_translate->format);
 		}
 		if (!(middle_frame = ast_translate(in_translate->trans_pvt, frame, 0)))
 			return frame;
@@ -707,16 +709,16 @@
 	/* ---Part_3: Decide what to do with the end_frame (whether to transcode or not) */
 	if (middle_frame == end_frame) {
 		/* Middle frame was modified and became the end frame... let's see if we need to transcode */
-		if (end_frame->subclass.codec != start_frame->subclass.codec) {
-			if (out_translate->format != start_frame->subclass.codec) {
+		if (ast_format_cmp(&end_frame->subclass.format, &start_frame->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {
+			if (ast_format_cmp(&out_translate->format, &start_frame->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {
 				if (out_translate->trans_pvt)
 					ast_translator_free_path(out_translate->trans_pvt);
-				if (!(out_translate->trans_pvt = ast_translator_build_path(start_frame->subclass.codec, AST_FORMAT_SLINEAR))) {
+				if (!(out_translate->trans_pvt = ast_translator_build_path(&start_frame->subclass.format, ast_format_set(&tmp_fmt, AST_FORMAT_SLINEAR, 0)))) {
 					/* We can't transcode this... drop our middle frame and return the original */
 					ast_frfree(middle_frame);
 					return start_frame;
 				}
-				out_translate->format = start_frame->subclass.codec;
+				ast_format_copy(&start_frame->subclass.format, &out_translate->format);
 			}
 			/* Transcode from our middle (signed linear) frame to new format of the frame that came in */
 			if (!(end_frame = ast_translate(out_translate->trans_pvt, middle_frame, 0))) {




More information about the asterisk-commits mailing list