aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-13 13:35:24 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-13 13:35:24 +0000
commita46dd55034bbf45b2e45a62559f9b9a2c075e8c6 (patch)
tree51f8bb89740396001e20f9f64d9044733305193c /include
parent01f6911d4a307b66ee955ad6c09a54c05ac27fa6 (diff)
Add basic (passthrough, playback, record) support for ITU G.722.1 and G.722.1C (also known as Siren7 and Siren14)
This patch adds passthrough, file recording and file playback support for the codecs listed above, with negotiation over SIP/SDP supported. Due to Asterisk's current limitation of treating a codec/bitrate combination as a unique codec, only G.722.1 at 32 kbps and G.722.1C at 48 kbps are supported. Along the way, some related work was done: 1) The rtpPayloadType structure definition, used as a return result for an API call in rtp.h, was moved from rtp.c to rtp.h so that the API call was actually usable. The only previous used of the API all was chan_h323.c, which had a duplicate of the structure definition instead of doing it the right way. 2) The hardcoded SDP sample rates for various codecs in chan_sip.c were removed, in favor of storing these sample rates in rtp.c along with the codec definitions there. A new API call was added to allow retrieval of the sample rate for a given codec. 3) Some basic 'a=fmtp' parsing for SDP was added to chan_sip, because chan_sip *must* decline any media streams offered for these codecs that are not at the bitrates that we support (otherwise Bad Things (TM) would result). Review: http://reviewboard.digium.com/r/158/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@175508 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/frame.h20
-rw-r--r--include/asterisk/rtp.h58
2 files changed, 69 insertions, 9 deletions
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index 267a820e8..4a18bdbac 100644
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -259,6 +259,10 @@ extern struct ast_frame ast_null_frame;
#define AST_FORMAT_G726 (1 << 11)
/*! G.722 */
#define AST_FORMAT_G722 (1 << 12)
+/*! G.722.1 (also known as Siren7, 32kbps assumed) */
+#define AST_FORMAT_SIREN7 (1 << 13)
+/*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */
+#define AST_FORMAT_SIREN14 (1 << 14)
/*! Raw 16-bit Signed Linear (16000 Hz) PCM */
#define AST_FORMAT_SLINEAR16 (1 << 15)
/*! Maximum audio mask */
@@ -523,8 +527,8 @@ struct ast_frame *ast_smoother_read(struct ast_smoother *s);
#endif
/*@} Doxygen marker */
-struct ast_format_list *ast_get_format_list_index(int index);
-struct ast_format_list *ast_get_format_list(size_t *size);
+const struct ast_format_list *ast_get_format_list_index(int index);
+const struct ast_format_list *ast_get_format_list(size_t *size);
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix);
/*! \page AudioCodecPref Audio Codec Preferences
@@ -630,10 +634,16 @@ int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2);
*/
static force_inline int ast_format_rate(int format)
{
- if (format == AST_FORMAT_G722 || format == AST_FORMAT_SLINEAR16)
+ switch (format) {
+ case AST_FORMAT_G722:
+ case AST_FORMAT_SLINEAR16:
+ case AST_FORMAT_SIREN7:
return 16000;
-
- return 8000;
+ case AST_FORMAT_SIREN14:
+ return 32000;
+ default:
+ return 8000;
+ }
}
#if defined(__cplusplus) || defined(c_plusplus)
diff --git a/include/asterisk/rtp.h b/include/asterisk/rtp.h
index 800519572..4648a2a34 100644
--- a/include/asterisk/rtp.h
+++ b/include/asterisk/rtp.h
@@ -84,6 +84,12 @@ struct ast_rtp;
/*! T.140 Redundancy structure*/
struct rtp_red;
+/*! \brief The value of each payload format mapping: */
+struct rtpPayloadType {
+ int isAstFormat; /*!< whether the following code is an AST_FORMAT */
+ int code;
+};
+
/*! \brief This is the structure that binds a channel (SIP/Jingle/H.323) to the RTP subsystem
*/
struct ast_rtp_protocol {
@@ -136,7 +142,7 @@ size_t ast_rtp_alloc_size(void);
* \param io
* \param rtcpenable
* \param callbackmode
- * \returns A representation (structure) of an RTP session.
+ * \return A representation (structure) of an RTP session.
*/
struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode);
@@ -150,7 +156,7 @@ struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io,
* \param rtcpenable
* \param callbackmode
* \param in
- * \returns A representation (structure) of an RTP session.
+ * \return A representation (structure) of an RTP session.
*/
struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode, struct in_addr in);
@@ -209,22 +215,66 @@ void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt);
/*! \brief clear payload type */
void ast_rtp_unset_m_type(struct ast_rtp* rtp, int pt);
-/*! \brief Initiate payload type to a known MIME media type for a codec */
+/*! \brief Set payload type to a known MIME media type for a codec
+ *
+ * \param rtp RTP structure to modify
+ * \param pt Payload type entry to modify
+ * \param mimeType top-level MIME type of media stream (typically "audio", "video", "text", etc.)
+ * \param mimeSubtype MIME subtype of media stream (typically a codec name)
+ * \param options Zero or more flags from the ast_rtp_options enum
+ *
+ * This function 'fills in' an entry in the list of possible formats for
+ * a media stream associated with an RTP structure.
+ *
+ * \retval 0 on success
+ * \retval -1 if the payload type is out of range
+ * \retval -2 if the mimeType/mimeSubtype combination was not found
+ */
int ast_rtp_set_rtpmap_type(struct ast_rtp* rtp, int pt,
char *mimeType, char *mimeSubtype,
enum ast_rtp_options options);
+/*! \brief Set payload type to a known MIME media type for a codec with a specific sample rate
+ *
+ * \param rtp RTP structure to modify
+ * \param pt Payload type entry to modify
+ * \param mimeType top-level MIME type of media stream (typically "audio", "video", "text", etc.)
+ * \param mimeSubtype MIME subtype of media stream (typically a codec name)
+ * \param options Zero or more flags from the ast_rtp_options enum
+ * \param sample_rate The sample rate of the media stream
+ *
+ * This function 'fills in' an entry in the list of possible formats for
+ * a media stream associated with an RTP structure.
+ *
+ * \retval 0 on success
+ * \retval -1 if the payload type is out of range
+ * \retval -2 if the mimeType/mimeSubtype combination was not found
+ */
+int ast_rtp_set_rtpmap_type_rate(struct ast_rtp* rtp, int pt,
+ char *mimeType, char *mimeSubtype,
+ enum ast_rtp_options options,
+ unsigned int sample_rate);
+
/*! \brief Mapping between RTP payload format codes and Asterisk codes: */
struct rtpPayloadType ast_rtp_lookup_pt(struct ast_rtp* rtp, int pt);
int ast_rtp_lookup_code(struct ast_rtp* rtp, int isAstFormat, int code);
void ast_rtp_get_current_formats(struct ast_rtp* rtp,
- int* astFormats, int* nonAstFormats);
+ int* astFormats, int* nonAstFormats);
/*! \brief Mapping an Asterisk code into a MIME subtype (string): */
const char *ast_rtp_lookup_mime_subtype(int isAstFormat, int code,
enum ast_rtp_options options);
+/*! \brief Get the sample rate associated with known RTP payload types
+ *
+ * \param isAstFormat True if the value in the 'code' parameter is an AST_FORMAT value
+ * \param code Format code, either from AST_FORMAT list or from AST_RTP list
+ *
+ * \return the sample rate if the format was found, zero if it was not found
+ */
+unsigned int ast_rtp_lookup_sample_rate(int isAstFormat, int code);
+
/*! \brief Build a string of MIME subtype names from a capability list */
char *ast_rtp_lookup_mime_multiple(char *buf, size_t size, const int capability,
const int isAstFormat, enum ast_rtp_options options);