diff --git a/ChangeLog b/ChangeLog index 092208fb04..0fd07ba64b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2007-10-01 Wim Taymans + + * gst-libs/gst/rtp/Makefile.am: + * gst-libs/gst/rtp/gstrtppayloads.c: (gst_rtp_payload_info_for_pt), + (gst_rtp_payload_info_for_name): + * gst-libs/gst/rtp/gstrtppayloads.h: + Added new file and header to deal with payload info. + + * gst-libs/gst/rtp/gstrtpbuffer.c: (gst_rtp_buffer_validate_data), + (gst_rtp_buffer_default_clock_rate): + * gst-libs/gst/rtp/gstrtpbuffer.h: + Payload specific stuff is move to new headers. + Implement _default_clock rate using the new payload function. + + * gst-libs/gst/sdp/gstsdpmessage.c: (is_multicast_address), + (gst_sdp_parse_line): + * gst-libs/gst/sdp/gstsdpmessage.h: + Add some more comments. + 2007-10-01 Wim Taymans * gst/typefind/gsttypefindfunctions.c: (utf8_type_find), diff --git a/gst-libs/gst/rtp/Makefile.am b/gst-libs/gst/rtp/Makefile.am index 32d642c9ca..9886f91685 100644 --- a/gst-libs/gst/rtp/Makefile.am +++ b/gst-libs/gst/rtp/Makefile.am @@ -2,6 +2,7 @@ libgstrtpincludedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/rtp libgstrtpinclude_HEADERS = gstrtpbuffer.h \ gstrtcpbuffer.h \ + gstrtppayloads.h \ gstbasertpaudiopayload.h \ gstbasertppayload.h \ gstbasertpdepayload.h @@ -10,6 +11,7 @@ lib_LTLIBRARIES = libgstrtp-@GST_MAJORMINOR@.la libgstrtp_@GST_MAJORMINOR@_la_SOURCES = gstrtpbuffer.c \ gstrtcpbuffer.c \ + gstrtppayloads.c \ gstbasertpaudiopayload.c \ gstbasertppayload.c \ gstbasertpdepayload.c diff --git a/gst-libs/gst/rtp/gstrtpbuffer.c b/gst-libs/gst/rtp/gstrtpbuffer.c index 174ef75dfb..e6bc817f0a 100644 --- a/gst-libs/gst/rtp/gstrtpbuffer.c +++ b/gst-libs/gst/rtp/gstrtpbuffer.c @@ -962,42 +962,19 @@ gst_rtp_buffer_get_payload (GstBuffer * buffer) guint32 gst_rtp_buffer_default_clock_rate (guint8 payload_type) { - switch (payload_type) { - case GST_RTP_PAYLOAD_PCMU: - case GST_RTP_PAYLOAD_GSM: - case GST_RTP_PAYLOAD_G723: - case GST_RTP_PAYLOAD_DVI4_8000: - case GST_RTP_PAYLOAD_LPC: - case GST_RTP_PAYLOAD_PCMA: - case GST_RTP_PAYLOAD_G722: - case GST_RTP_PAYLOAD_G729: - case GST_RTP_PAYLOAD_QCELP: - case GST_RTP_PAYLOAD_CN: - case GST_RTP_PAYLOAD_G728: - return 8000; - case GST_RTP_PAYLOAD_DVI4_11025: - return 11025; - case GST_RTP_PAYLOAD_DVI4_16000: - return 16000; - case GST_RTP_PAYLOAD_DVI4_22050: - return 22050; - case GST_RTP_PAYLOAD_L16_STEREO: - case GST_RTP_PAYLOAD_L16_MONO: - return 44100; - case GST_RTP_PAYLOAD_MPA: - case GST_RTP_PAYLOAD_CELLB: - case GST_RTP_PAYLOAD_JPEG: - case GST_RTP_PAYLOAD_NV: - case GST_RTP_PAYLOAD_H261: - case GST_RTP_PAYLOAD_MPV: - case GST_RTP_PAYLOAD_MP2T: - case GST_RTP_PAYLOAD_H263: - return 90000; - case GST_RTP_PAYLOAD_1016: - case GST_RTP_PAYLOAD_G721: - default: - return -1; - } + const GstRTPPayloadInfo *info; + guint32 res; + + info = gst_rtp_payload_info_for_pt (payload_type); + if (!info) + return -1; + + res = info->clock_rate; + /* 0 means unknown so we have to return -1 from this function */ + if (res == 0) + res = -1; + + return res; } /** diff --git a/gst-libs/gst/rtp/gstrtpbuffer.h b/gst-libs/gst/rtp/gstrtpbuffer.h index 6695de6ee6..dc8c2ace18 100644 --- a/gst-libs/gst/rtp/gstrtpbuffer.h +++ b/gst-libs/gst/rtp/gstrtpbuffer.h @@ -25,6 +25,7 @@ #define __GST_RTPBUFFER_H__ #include +#include G_BEGIN_DECLS @@ -35,130 +36,6 @@ G_BEGIN_DECLS */ #define GST_RTP_VERSION 2 -/** - * GstRTPPayload: - * @GST_RTP_PAYLOAD_PCMU: ITU-T G.711. mu-law audio (RFC 3551) - * @GST_RTP_PAYLOAD_1016: RFC 3551 says reserved - * @GST_RTP_PAYLOAD_G721: RFC 3551 says reserved - * @GST_RTP_PAYLOAD_GSM: GSM audio - * @GST_RTP_PAYLOAD_G723: ITU G.723.1 audio - * @GST_RTP_PAYLOAD_DVI4_8000: IMA ADPCM wave type (RFC 3551) - * @GST_RTP_PAYLOAD_DVI4_16000: IMA ADPCM wave type (RFC 3551) - * @GST_RTP_PAYLOAD_LPC: experimental linear predictive encoding - * @GST_RTP_PAYLOAD_PCMA: ITU-T G.711 A-law audio (RFC 3551) - * @GST_RTP_PAYLOAD_G722: ITU-T G.722 (RFC 3551) - * @GST_RTP_PAYLOAD_L16_STEREO: stereo PCM - * @GST_RTP_PAYLOAD_L16_MONO: mono PCM - * @GST_RTP_PAYLOAD_QCELP: EIA & TIA standard IS-733 - * @GST_RTP_PAYLOAD_CN: Comfort Noise (RFC 3389) - * @GST_RTP_PAYLOAD_MPA: Audio MPEG 1-3. - * @GST_RTP_PAYLOAD_G728: ITU-T G.728 Speech coder (RFC 3551) - * @GST_RTP_PAYLOAD_DVI4_11025: IMA ADPCM wave type (RFC 3551) - * @GST_RTP_PAYLOAD_DVI4_22050: IMA ADPCM wave type (RFC 3551) - * @GST_RTP_PAYLOAD_G729: ITU-T G.729 Speech coder (RFC 3551) - * @GST_RTP_PAYLOAD_CELLB: See RFC 2029 - * @GST_RTP_PAYLOAD_JPEG: ISO Standards 10918-1 and 10918-2 (RFC 2435) - * @GST_RTP_PAYLOAD_NV: nv encoding by Ron Frederick - * @GST_RTP_PAYLOAD_H261: ITU-T Recommendation H.261 (RFC 2032) - * @GST_RTP_PAYLOAD_MPV: Video MPEG 1 & 2 (RFC 2250) - * @GST_RTP_PAYLOAD_MP2T: MPEG-2 transport stream (RFC 2250) - * @GST_RTP_PAYLOAD_H263: Video H263 (RFC 2190) - * - * - * Standard predefined fixed payload types. - * - * The official list is at: - * http://www.iana.org/assignments/rtp-parameters - * - * Audio: - * reserved: 19 - * unassigned: 20-23, - * - * Video: - * unassigned: 24, 27, 29, 30, 35-71, 77-95 - * Reserved for RTCP conflict avoidance: 72-76 - */ -typedef enum -{ - /* Audio: */ - GST_RTP_PAYLOAD_PCMU = 0, - GST_RTP_PAYLOAD_1016 = 1, /* RFC 3551 says reserved */ - GST_RTP_PAYLOAD_G721 = 2, /* RFC 3551 says reserved */ - GST_RTP_PAYLOAD_GSM = 3, - GST_RTP_PAYLOAD_G723 = 4, - GST_RTP_PAYLOAD_DVI4_8000 = 5, - GST_RTP_PAYLOAD_DVI4_16000 = 6, - GST_RTP_PAYLOAD_LPC = 7, - GST_RTP_PAYLOAD_PCMA = 8, - GST_RTP_PAYLOAD_G722 = 9, - GST_RTP_PAYLOAD_L16_STEREO = 10, - GST_RTP_PAYLOAD_L16_MONO = 11, - GST_RTP_PAYLOAD_QCELP = 12, - GST_RTP_PAYLOAD_CN = 13, - GST_RTP_PAYLOAD_MPA = 14, - GST_RTP_PAYLOAD_G728 = 15, - GST_RTP_PAYLOAD_DVI4_11025 = 16, - GST_RTP_PAYLOAD_DVI4_22050 = 17, - GST_RTP_PAYLOAD_G729 = 18, - - /* Video: */ - - GST_RTP_PAYLOAD_CELLB = 25, - GST_RTP_PAYLOAD_JPEG = 26, - GST_RTP_PAYLOAD_NV = 28, - GST_RTP_PAYLOAD_H261 = 31, - GST_RTP_PAYLOAD_MPV = 32, - GST_RTP_PAYLOAD_MP2T = 33, - GST_RTP_PAYLOAD_H263 = 34, - - /* BOTH */ -} GstRTPPayload; - -/* backward compatibility */ -#define GST_RTP_PAYLOAD_G723_63 16 -#define GST_RTP_PAYLOAD_G723_53 17 -#define GST_RTP_PAYLOAD_TS48 18 -#define GST_RTP_PAYLOAD_TS41 19 - -#define GST_RTP_PAYLOAD_G723_63_STRING "16" -#define GST_RTP_PAYLOAD_G723_53_STRING "17" -#define GST_RTP_PAYLOAD_TS48_STRING "18" -#define GST_RTP_PAYLOAD_TS41_STRING "19" - -/* Defining the above as strings, to make the declaration of pad_templates - * easier. So if please keep these synchronized with the above. - */ -#define GST_RTP_PAYLOAD_PCMU_STRING "0" -#define GST_RTP_PAYLOAD_1016_STRING "1" -#define GST_RTP_PAYLOAD_G721_STRING "2" -#define GST_RTP_PAYLOAD_GSM_STRING "3" -#define GST_RTP_PAYLOAD_G723_STRING "4" -#define GST_RTP_PAYLOAD_DVI4_8000_STRING "5" -#define GST_RTP_PAYLOAD_DVI4_16000_STRING "6" -#define GST_RTP_PAYLOAD_LPC_STRING "7" -#define GST_RTP_PAYLOAD_PCMA_STRING "8" -#define GST_RTP_PAYLOAD_G722_STRING "9" -#define GST_RTP_PAYLOAD_L16_STEREO_STRING "10" -#define GST_RTP_PAYLOAD_L16_MONO_STRING "11" -#define GST_RTP_PAYLOAD_QCELP_STRING "12" -#define GST_RTP_PAYLOAD_CN_STRING "13" -#define GST_RTP_PAYLOAD_MPA_STRING "14" -#define GST_RTP_PAYLOAD_G728_STRING "15" -#define GST_RTP_PAYLOAD_DVI4_11025_STRING "16" -#define GST_RTP_PAYLOAD_DVI4_22050_STRING "17" -#define GST_RTP_PAYLOAD_G729_STRING "18" - -#define GST_RTP_PAYLOAD_CELLB_STRING "25" -#define GST_RTP_PAYLOAD_JPEG_STRING "26" -#define GST_RTP_PAYLOAD_NV_STRING "28" - -#define GST_RTP_PAYLOAD_H261_STRING "31" -#define GST_RTP_PAYLOAD_MPV_STRING "32" -#define GST_RTP_PAYLOAD_MP2T_STRING "33" -#define GST_RTP_PAYLOAD_H263_STRING "34" - -#define GST_RTP_PAYLOAD_DYNAMIC_STRING "[96, 127]" - /* creating buffers */ void gst_rtp_buffer_allocate_data (GstBuffer *buffer, guint payload_len, guint8 pad_len, guint8 csrc_count); diff --git a/gst-libs/gst/rtp/gstrtppayloads.c b/gst-libs/gst/rtp/gstrtppayloads.c new file mode 100644 index 0000000000..63e460e5d6 --- /dev/null +++ b/gst-libs/gst/rtp/gstrtppayloads.c @@ -0,0 +1,213 @@ +/* GStreamer + * Copyright (C) <2007> Wim Taymans + * + * gstrtppayloads.h: various helper functions to deal with RTP payload + * types. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#include "gstrtppayloads.h" + +/* pt, encoding_name, media, rate, params, bitrate */ +static const GstRTPPayloadInfo info[] = { + /* static audio */ + {0, "audio", "PCMU", 8000, "1", 64000}, + /* { 1, "audio", "reserved", 0, NULL, 0 }, */ + /* { 2, "audio", "reserved", 0, NULL, 0 }, */ + {3, "audio", "GSM", 8000, "1", 0}, + {4, "audio", "G723", 8000, "1", 0}, + {5, "audio", "DVI4", 8000, "1", 32000}, + {6, "audio", "DVI4", 16000, "1", 64000}, + {7, "audio", "LPC", 8000, "1", 0}, + {8, "audio", "PCMA", 8000, "1", 64000}, + {9, "audio", "G722", 8000, "1", 64000}, + {10, "audio", "L16", 44100, "2", 1411200}, + {11, "audio", "L16", 44100, "1", 705600}, + {12, "audio", "QCELP", 8000, "1", 0}, + {13, "audio", "CN", 8000, "1", 0}, + {14, "audio", "MPA", 90000, NULL, 0}, + {15, "audio", "G728", 8000, "1", 0}, + {16, "audio", "DVI4", 11025, "1", 44100}, + {17, "audio", "DVI4", 22050, "1", 88200}, + {18, "audio", "G729", 8000, "1", 0}, + /* { 19, "audio", "reserved", 0, NULL, 0 }, */ + /* { 20, "audio", "unassigned", 0, NULL, 0 }, */ + /* { 21, "audio", "unassigned", 0, NULL, 0 }, */ + /* { 22, "audio", "unassigned", 0, NULL, 0 }, */ + /* { 23, "audio", "unassigned", 0, NULL, 0 }, */ + + /* video and video/audio */ + /* { 24, "video", "unassigned", 0, NULL, 0 }, */ + {25, "video", "CelB", 90000, NULL, 0}, + {26, "video", "JPEG", 90000, NULL, 0}, + /* { 27, "video", "unassigned", 0, NULL, 0 }, */ + {28, "video", "nv", 90000, NULL, 0}, + /* { 29, "video", "unassigned", 0, NULL, 0 }, */ + /* { 30, "video", "unassigned", 0, NULL, 0 }, */ + {31, "video", "H261", 90000, NULL, 0}, + {32, "video", "MPV", 90000, NULL, 0}, + {33, "video", "MP2T", 90000, NULL, 0}, + {34, "video", "H263", 90000, NULL, 0}, + /* { 35-71, "unassigned", 0, 0, NULL, 0 }, */ + /* { 72-76, "reserved", 0, 0, NULL, 0 }, */ + /* { 77-95, "unassigned", 0, 0, NULL, 0 }, */ + /* { 96-127, "dynamic", 0, 0, NULL, 0 }, */ + + /* dynamic stuff */ + {-1, "application", "parityfec", 0, NULL, 0}, /* [RFC3009] */ + {-1, "application", "rtx", 0, NULL, 0}, /* [RFC4588] */ + {-1, "audio", "AMR", 8000, NULL, 0}, /* [RFC4867][RFC3267] */ + {-1, "audio", "AMR-WB", 16000, NULL, 0}, /* [RFC4867][RFC3267] */ + {-1, "audio", "DAT12", 0, NULL, 0}, /* [RFC3190] */ + {-1, "audio", "dsr-es201108", 0, NULL, 0}, /* [RFC3557] */ + {-1, "audio", "EVRC", 8000, "1", 0}, /* [RFC4788] */ + {-1, "audio", "EVRC0", 8000, "1", 0}, /* [RFC4788] */ + {-1, "audio", "EVRC1", 8000, "1", 0}, /* [RFC4788] */ + {-1, "audio", "EVRCB", 8000, "1", 0}, /* [RFC4788] */ + {-1, "audio", "EVRCB0", 8000, "1", 0}, /* [RFC4788] */ + {-1, "audio", "EVRCB1", 8000, "1", 0}, /* [RFC4788] */ + {-1, "audio", "G7221", 16000, "1", 0}, /* [RFC3047] */ + {-1, "audio", "G726-16", 8000, "1", 0}, /* [RFC3551][RFC4856] */ + {-1, "audio", "G726-24", 8000, "1", 0}, /* [RFC3551][RFC4856] */ + {-1, "audio", "G726-32", 8000, "1", 0}, /* [RFC3551][RFC4856] */ + {-1, "audio", "G726-40", 8000, "1", 0}, /* [RFC3551][RFC4856] */ + {-1, "audio", "G729D", 8000, "1", 0}, /* [RFC3551][RFC4856] */ + {-1, "audio", "G729E", 8000, "1", 0}, /* [RFC3551][RFC4856] */ + {-1, "audio", "GSM-EFR", 8000, "1", 0}, /* [RFC3551][RFC4856] */ + {-1, "audio", "L8", 0, NULL, 0}, /* [RFC3551][RFC4856] */ + {-1, "audio", "RED", 0, NULL, 0}, /* [RFC2198][RFC3555] */ + {-1, "audio", "rtx", 0, NULL, 0}, /* [RFC4588] */ + {-1, "audio", "VDVI", 0, "1", 0}, /* [RFC3551][RFC4856] */ + {-1, "audio", "L20", 0, NULL, 0}, /* [RFC3190] */ + {-1, "audio", "L24", 0, NULL, 0}, /* [RFC3190] */ + {-1, "audio", "MP4A-LATM", 0, NULL, 0}, /* [RFC3016] */ + {-1, "audio", "mpa-robust", 90000, NULL, 0}, /* [RFC3119] */ + {-1, "audio", "parityfec", 0, NULL, 0}, /* [RFC3009] */ + {-1, "audio", "SMV", 8000, "1", 0}, /* [RFC3558] */ + {-1, "audio", "SMV0", 8000, "1", 0}, /* [RFC3558] */ + {-1, "audio", "t140c", 0, NULL, 0}, /* [RFC4351] */ + {-1, "audio", "t38", 0, NULL, 0}, /* [RFC4612] */ + {-1, "audio", "telephone-event", 0, NULL, 0}, /* [RFC4733] */ + {-1, "audio", "tone", 0, NULL, 0}, /* [RFC4733] */ + {-1, "audio", "DVI4", 0, NULL, 0}, /* [RFC4856] */ + {-1, "audio", "G722", 0, NULL, 0}, /* [RFC4856] */ + {-1, "audio", "G723", 0, NULL, 0}, /* [RFC4856] */ + {-1, "audio", "G728", 0, NULL, 0}, /* [RFC4856] */ + {-1, "audio", "G729", 0, NULL, 0}, /* [RFC4856] */ + {-1, "audio", "GSM", 0, NULL, 0}, /* [RFC4856] */ + {-1, "audio", "L16", 0, NULL, 0}, /* [RFC4856] */ + {-1, "audio", "LPC", 0, NULL, 0}, /* [RFC4856] */ + {-1, "audio", "PCMA", 0, NULL, 0}, /* [RFC4856] */ + {-1, "audio", "PCMU", 0, NULL, 0}, /* [RFC4856] */ + {-1, "text", "parityfec", 0, NULL, 0}, /* [RFC3009] */ + {-1, "text", "red", 1000, NULL, 0}, /* [RFC4102] */ + {-1, "text", "rtx", 0, NULL, 0}, /* [RFC4588] */ + {-1, "text", "t140", 1000, NULL, 0}, /* [RFC4103] */ + {-1, "video", "BMPEG", 90000, NULL, 0}, /* [RFC2343][RFC3555] */ + {-1, "video", "BT656", 90000, NULL, 0}, /* [RFC2431][RFC3555] */ + {-1, "video", "DV", 90000, NULL, 0}, /* [RFC3189] */ + {-1, "video", "H263-1998", 90000, NULL, 0}, /* [RFC2429][RFC3555] */ + {-1, "video", "H263-2000", 90000, NULL, 0}, /* [RFC2429][RFC3555] */ + {-1, "video", "MP1S", 90000, NULL, 0}, /* [RFC2250][RFC3555] */ + {-1, "video", "MP2P", 90000, NULL, 0}, /* [RFC2250][RFC3555] */ + {-1, "video", "MP4V-ES", 90000, NULL, 0}, /* [RFC3016] */ + {-1, "video", "parityfec", 0, NULL, 0}, /* [RFC3009] */ + {-1, "video", "pointer", 90000, NULL, 0}, /* [RFC2862] */ + {-1, "video", "raw", 90000, NULL, 0}, /* [RFC4175] */ + {-1, "video", "rtx", 0, NULL, 0}, /* [RFC4588] */ + {-1, "video", "SMPTE292M", 0, NULL, 0}, /* [RFC3497] */ + {-1, "video", "vc1", 90000, NULL, 0}, /* [RFC4425] */ + + /* not in http://www.iana.org/assignments/rtp-parameters */ + {-1, "audio", "AC3", 0, NULL, 0}, + {-1, "audio", "ILBC", 8000, NULL, 0}, + {-1, "audio", "MPEG4-GENERIC", 0, NULL, 0}, + {-1, "audio", "SPEEX", 0, NULL, 0}, + + {-1, "application", "MPEG4-GENERIC", 0, NULL, 0}, + + {-1, "video", "H264", 90000, NULL, 0}, + {-1, "video", "MPEG4-GENERIC", 90000, NULL, 0}, + {-1, "video", "THEORA", 0, NULL, 0}, + {-1, "video", "VORBIS", 0, NULL, 0}, + {-1, "video", "X-SV3V-ES", 90000, NULL, 0}, + {-1, "video", "X-SORENSON-VIDEO", 90000, NULL, 0}, + + /* real stuff */ + {-1, "video", "x-pn-realvideo", 1000, NULL, 0}, + {-1, "audio", "x-pn-realaudio", 1000, NULL, 0}, + {-1, "application", "x-pn-realmedia", 1000, NULL, 0}, + + /* terminator */ + {-1, NULL, NULL, 0, NULL, 0} +}; + +/** + * gst_rtp_payload_info_for_pt: + * @payload_type: the payload_type to find + * + * Get the #GstRTPPayloadInfo for @payload_type. This function is + * mostly used to get the default clock-rate and bandwidth for static payload + * types specified with @payload_type. + * + * Returns: a #GstRTPPayloadInfo or NULL when no info could be found. + */ +const GstRTPPayloadInfo * +gst_rtp_payload_info_for_pt (guint8 payload_type) +{ + const GstRTPPayloadInfo *result = NULL; + gint i; + + for (i = 0; info[i].media; i++) { + if (info[i].payload_type == payload_type) { + result = &info[i]; + break; + } + } + return result; +} + +/** + * gst_rtp_payload_info_for_name: + * @media: the media to find + * @encoding_name: the encoding name to find + * + * Get the #GstRTPPayloadInfo for @media and @encoding_name. This function is + * mostly used to get the default clock-rate and bandwidth for dynamic payload + * types specified with @media and @encoding name. + * + * The search for @encoding_name will be performed in a case insensitve way. + * + * Returns: a #GstRTPPayloadInfo or NULL when no info could be found. + */ +const GstRTPPayloadInfo * +gst_rtp_payload_info_for_name (const gchar * media, const gchar * encoding_name) +{ + const GstRTPPayloadInfo *result = NULL; + gint i; + + for (i = 0; info[i].media; i++) { + if (strcmp (media, info[i].media) == 0 + && strcasecmp (encoding_name, info[i].encoding_name) == 0) { + result = &info[i]; + break; + } + } + return result; +} diff --git a/gst-libs/gst/rtp/gstrtppayloads.h b/gst-libs/gst/rtp/gstrtppayloads.h new file mode 100644 index 0000000000..3563468b74 --- /dev/null +++ b/gst-libs/gst/rtp/gstrtppayloads.h @@ -0,0 +1,193 @@ +/* GStreamer + * Copyright (C) <2007> Wim Taymans + * + * gstrtppayloads.h: various helper functions to deal with RTP payload + * types. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GST_RTPPAYLOADS_H__ +#define __GST_RTPPAYLOADS_H__ + +#include + +G_BEGIN_DECLS + +/** + * GstRTPPayload: + * @GST_RTP_PAYLOAD_PCMU: ITU-T G.711. mu-law audio (RFC 3551) + * @GST_RTP_PAYLOAD_1016: RFC 3551 says reserved + * @GST_RTP_PAYLOAD_G721: RFC 3551 says reserved + * @GST_RTP_PAYLOAD_GSM: GSM audio + * @GST_RTP_PAYLOAD_G723: ITU G.723.1 audio + * @GST_RTP_PAYLOAD_DVI4_8000: IMA ADPCM wave type (RFC 3551) + * @GST_RTP_PAYLOAD_DVI4_16000: IMA ADPCM wave type (RFC 3551) + * @GST_RTP_PAYLOAD_LPC: experimental linear predictive encoding + * @GST_RTP_PAYLOAD_PCMA: ITU-T G.711 A-law audio (RFC 3551) + * @GST_RTP_PAYLOAD_G722: ITU-T G.722 (RFC 3551) + * @GST_RTP_PAYLOAD_L16_STEREO: stereo PCM + * @GST_RTP_PAYLOAD_L16_MONO: mono PCM + * @GST_RTP_PAYLOAD_QCELP: EIA & TIA standard IS-733 + * @GST_RTP_PAYLOAD_CN: Comfort Noise (RFC 3389) + * @GST_RTP_PAYLOAD_MPA: Audio MPEG 1-3. + * @GST_RTP_PAYLOAD_G728: ITU-T G.728 Speech coder (RFC 3551) + * @GST_RTP_PAYLOAD_DVI4_11025: IMA ADPCM wave type (RFC 3551) + * @GST_RTP_PAYLOAD_DVI4_22050: IMA ADPCM wave type (RFC 3551) + * @GST_RTP_PAYLOAD_G729: ITU-T G.729 Speech coder (RFC 3551) + * @GST_RTP_PAYLOAD_CELLB: See RFC 2029 + * @GST_RTP_PAYLOAD_JPEG: ISO Standards 10918-1 and 10918-2 (RFC 2435) + * @GST_RTP_PAYLOAD_NV: nv encoding by Ron Frederick + * @GST_RTP_PAYLOAD_H261: ITU-T Recommendation H.261 (RFC 2032) + * @GST_RTP_PAYLOAD_MPV: Video MPEG 1 & 2 (RFC 2250) + * @GST_RTP_PAYLOAD_MP2T: MPEG-2 transport stream (RFC 2250) + * @GST_RTP_PAYLOAD_H263: Video H263 (RFC 2190) + * + * + * Standard predefined fixed payload types. + * + * The official list is at: + * http://www.iana.org/assignments/rtp-parameters + * + * Audio: + * reserved: 19 + * unassigned: 20-23, + * + * Video: + * unassigned: 24, 27, 29, 30, 35-71, 77-95 + * Reserved for RTCP conflict avoidance: 72-76 + */ +typedef enum +{ + /* Audio: */ + GST_RTP_PAYLOAD_PCMU = 0, + GST_RTP_PAYLOAD_1016 = 1, /* RFC 3551 says reserved */ + GST_RTP_PAYLOAD_G721 = 2, /* RFC 3551 says reserved */ + GST_RTP_PAYLOAD_GSM = 3, + GST_RTP_PAYLOAD_G723 = 4, + GST_RTP_PAYLOAD_DVI4_8000 = 5, + GST_RTP_PAYLOAD_DVI4_16000 = 6, + GST_RTP_PAYLOAD_LPC = 7, + GST_RTP_PAYLOAD_PCMA = 8, + GST_RTP_PAYLOAD_G722 = 9, + GST_RTP_PAYLOAD_L16_STEREO = 10, + GST_RTP_PAYLOAD_L16_MONO = 11, + GST_RTP_PAYLOAD_QCELP = 12, + GST_RTP_PAYLOAD_CN = 13, + GST_RTP_PAYLOAD_MPA = 14, + GST_RTP_PAYLOAD_G728 = 15, + GST_RTP_PAYLOAD_DVI4_11025 = 16, + GST_RTP_PAYLOAD_DVI4_22050 = 17, + GST_RTP_PAYLOAD_G729 = 18, + + /* Video: */ + + GST_RTP_PAYLOAD_CELLB = 25, + GST_RTP_PAYLOAD_JPEG = 26, + GST_RTP_PAYLOAD_NV = 28, + GST_RTP_PAYLOAD_H261 = 31, + GST_RTP_PAYLOAD_MPV = 32, + GST_RTP_PAYLOAD_MP2T = 33, + GST_RTP_PAYLOAD_H263 = 34, + + /* BOTH */ +} GstRTPPayload; + +/* backward compatibility */ +#define GST_RTP_PAYLOAD_G723_63 16 +#define GST_RTP_PAYLOAD_G723_53 17 +#define GST_RTP_PAYLOAD_TS48 18 +#define GST_RTP_PAYLOAD_TS41 19 + +#define GST_RTP_PAYLOAD_G723_63_STRING "16" +#define GST_RTP_PAYLOAD_G723_53_STRING "17" +#define GST_RTP_PAYLOAD_TS48_STRING "18" +#define GST_RTP_PAYLOAD_TS41_STRING "19" + +/* Defining the above as strings, to make the declaration of pad_templates + * easier. So if please keep these synchronized with the above. + */ +#define GST_RTP_PAYLOAD_PCMU_STRING "0" +#define GST_RTP_PAYLOAD_1016_STRING "1" +#define GST_RTP_PAYLOAD_G721_STRING "2" +#define GST_RTP_PAYLOAD_GSM_STRING "3" +#define GST_RTP_PAYLOAD_G723_STRING "4" +#define GST_RTP_PAYLOAD_DVI4_8000_STRING "5" +#define GST_RTP_PAYLOAD_DVI4_16000_STRING "6" +#define GST_RTP_PAYLOAD_LPC_STRING "7" +#define GST_RTP_PAYLOAD_PCMA_STRING "8" +#define GST_RTP_PAYLOAD_G722_STRING "9" +#define GST_RTP_PAYLOAD_L16_STEREO_STRING "10" +#define GST_RTP_PAYLOAD_L16_MONO_STRING "11" +#define GST_RTP_PAYLOAD_QCELP_STRING "12" +#define GST_RTP_PAYLOAD_CN_STRING "13" +#define GST_RTP_PAYLOAD_MPA_STRING "14" +#define GST_RTP_PAYLOAD_G728_STRING "15" +#define GST_RTP_PAYLOAD_DVI4_11025_STRING "16" +#define GST_RTP_PAYLOAD_DVI4_22050_STRING "17" +#define GST_RTP_PAYLOAD_G729_STRING "18" + +#define GST_RTP_PAYLOAD_CELLB_STRING "25" +#define GST_RTP_PAYLOAD_JPEG_STRING "26" +#define GST_RTP_PAYLOAD_NV_STRING "28" + +#define GST_RTP_PAYLOAD_H261_STRING "31" +#define GST_RTP_PAYLOAD_MPV_STRING "32" +#define GST_RTP_PAYLOAD_MP2T_STRING "33" +#define GST_RTP_PAYLOAD_H263_STRING "34" + +#define GST_RTP_PAYLOAD_DYNAMIC_STRING "[96, 127]" + +/** + * GST_RTP_PAYLOAD_IS_DYNAMIC: + * @pt: a payload type + * + * Check if @pt is a dynamic payload type. + */ +#define GST_RTP_PAYLOAD_IS_DYNAMIC(pt) ((pt) >= 96 && (pt) <= 127) + +typedef struct _GstRTPPayloadInfo GstRTPPayloadInfo; + +/** + * GstRTPPayloadInfo: + * @payload_type: payload type, -1 means dynamic + * @media: the media type(s), usually "audio", "video", "application", "text", + * "message". + * @encoding_name: the encoding name of @pt + * @clock_rate: default clock rate, 0 = unknown/variable + * @encoding_parameters: encoding parameters. For audio this is the number of + * channels. NULL = not applicable. + * @bitrate: the bitrate of the media. 0 = unknown/variable. + * + * Structure holding default payload type information. + */ +struct _GstRTPPayloadInfo +{ + guint8 payload_type; + const gchar *media; + const gchar *encoding_name; + guint clock_rate; + const gchar *encoding_parameters; + guint bitrate; +}; + +const GstRTPPayloadInfo * gst_rtp_payload_info_for_pt (guint8 payload_type); +const GstRTPPayloadInfo * gst_rtp_payload_info_for_name (const gchar *media, const gchar *encoding_name); + +G_END_DECLS + +#endif /* __GST_RTPPAYLOADS_H__ */ + diff --git a/gst-libs/gst/sdp/gstsdpmessage.c b/gst-libs/gst/sdp/gstsdpmessage.c index 35fe26510e..a4e8e5cc1d 100644 --- a/gst-libs/gst/sdp/gstsdpmessage.c +++ b/gst-libs/gst/sdp/gstsdpmessage.c @@ -1759,6 +1759,7 @@ gst_sdp_parse_line (SDPContext * c, gchar type, gchar * buffer) memset (&nmedia, 0, sizeof (nmedia)); gst_sdp_media_init (&nmedia); + /* m= / ... */ READ_STRING (nmedia.media); read_string (str, sizeof (str), &p); slash = g_strrstr (str, "/"); diff --git a/gst-libs/gst/sdp/gstsdpmessage.h b/gst-libs/gst/sdp/gstsdpmessage.h index e63f429483..bb1bbc71d7 100644 --- a/gst-libs/gst/sdp/gstsdpmessage.h +++ b/gst-libs/gst/sdp/gstsdpmessage.h @@ -257,55 +257,66 @@ GstSDPResult gst_sdp_message_parse_buffer (const guint8 *data, gchar* gst_sdp_message_as_text (const GstSDPMessage *msg); +/* v=.. */ const gchar* gst_sdp_message_get_version (const GstSDPMessage *msg); GstSDPResult gst_sdp_message_set_version (GstSDPMessage *msg, const gchar *version); +/* o= */ const GstSDPOrigin* gst_sdp_message_get_origin (const GstSDPMessage *msg); GstSDPResult gst_sdp_message_set_origin (GstSDPMessage *msg, const gchar *username, const gchar *sess_id, const gchar *sess_version, const gchar *nettype, const gchar *addrtype, const gchar *addr); +/* s= */ const gchar* gst_sdp_message_get_session_name (const GstSDPMessage *msg); GstSDPResult gst_sdp_message_set_session_name (GstSDPMessage *msg, const gchar *session_name); +/* i= */ const gchar* gst_sdp_message_get_information (const GstSDPMessage *msg); GstSDPResult gst_sdp_message_set_information (GstSDPMessage *msg, const gchar *information); +/* u= */ const gchar* gst_sdp_message_get_uri (const GstSDPMessage *msg); GstSDPResult gst_sdp_message_set_uri (GstSDPMessage *msg, const gchar *uri); +/* e= */ guint gst_sdp_message_emails_len (const GstSDPMessage *msg); const gchar* gst_sdp_message_get_email (const GstSDPMessage *msg, guint idx); GstSDPResult gst_sdp_message_add_email (GstSDPMessage *msg, const gchar *email); +/* p= */ guint gst_sdp_message_phones_len (const GstSDPMessage *msg); const gchar* gst_sdp_message_get_phone (const GstSDPMessage *msg, guint idx); GstSDPResult gst_sdp_message_add_phone (GstSDPMessage *msg, const gchar *phone); +/* c= [/][/] */ const GstSDPConnection* gst_sdp_message_get_connection (const GstSDPMessage *msg); GstSDPResult gst_sdp_message_set_connection (GstSDPMessage *msg, const gchar *nettype, const gchar *addrtype, const gchar *address, guint ttl, guint addr_number); - +/* b=: */ guint gst_sdp_message_bandwidths_len (const GstSDPMessage *msg); const GstSDPBandwidth* gst_sdp_message_get_bandwidth (const GstSDPMessage *msg, guint idx); GstSDPResult gst_sdp_message_add_bandwidth (GstSDPMessage *msg, const gchar *bwtype, guint bandwidth); - +/* t= and + * r= */ guint gst_sdp_message_times_len (const GstSDPMessage *msg); const GstSDPTime* gst_sdp_message_get_time (const GstSDPMessage *msg, guint idx); GstSDPResult gst_sdp_message_add_time (GstSDPMessage *msg, const gchar *start, const gchar *stop, const gchar **repeat); +/* z= .... */ guint gst_sdp_message_zones_len (const GstSDPMessage *msg); const GstSDPZone* gst_sdp_message_get_zone (const GstSDPMessage *msg, guint idx); GstSDPResult gst_sdp_message_add_zone (GstSDPMessage *msg, const gchar *adj_time, const gchar *typed_time); +/* k=[:] */ const GstSDPKey* gst_sdp_message_get_key (const GstSDPMessage *msg); GstSDPResult gst_sdp_message_set_key (GstSDPMessage *msg, const gchar *type, const gchar *data); - +/* a=... */ guint gst_sdp_message_attributes_len (const GstSDPMessage *msg); const GstSDPAttribute* gst_sdp_message_get_attribute (const GstSDPMessage *msg, guint idx); const gchar* gst_sdp_message_get_attribute_val (const GstSDPMessage *msg, const gchar *key); @@ -314,6 +325,7 @@ const gchar* gst_sdp_message_get_attribute_val_n (const GstSDPMessage GstSDPResult gst_sdp_message_add_attribute (GstSDPMessage *msg, const gchar *key, const gchar *value); +/* m=.. sections */ guint gst_sdp_message_medias_len (const GstSDPMessage *msg); const GstSDPMedia* gst_sdp_message_get_media (const GstSDPMessage *msg, guint idx); GstSDPResult gst_sdp_message_add_media (GstSDPMessage *msg, GstSDPMedia *media); @@ -328,6 +340,7 @@ GstSDPResult gst_sdp_media_free (GstSDPMedia *media) gchar* gst_sdp_media_as_text (const GstSDPMedia *media); +/* m= / ... */ const gchar* gst_sdp_media_get_media (const GstSDPMedia *media); GstSDPResult gst_sdp_media_set_media (GstSDPMedia *media, const gchar *med); @@ -343,28 +356,33 @@ guint gst_sdp_media_formats_len (const GstSDPMedia * const gchar* gst_sdp_media_get_format (const GstSDPMedia *media, guint idx); GstSDPResult gst_sdp_media_add_format (GstSDPMedia *media, const gchar *format); +/* i= */ const gchar* gst_sdp_media_get_information (const GstSDPMedia *media); GstSDPResult gst_sdp_media_set_information (GstSDPMedia *media, const gchar *information); +/* c= [/][/] */ guint gst_sdp_media_connections_len (const GstSDPMedia *media); const GstSDPConnection* gst_sdp_media_get_connection (const GstSDPMedia *media, guint idx); GstSDPResult gst_sdp_media_add_connection (GstSDPMedia *media, const gchar *nettype, const gchar *addrtype, const gchar *address, guint ttl, guint addr_number); +/* b=: */ guint gst_sdp_media_bandwidths_len (const GstSDPMedia *media); const GstSDPBandwidth* gst_sdp_media_get_bandwidth (const GstSDPMedia *media, guint idx); GstSDPResult gst_sdp_media_add_bandwidth (GstSDPMedia *media, const gchar *bwtype, guint bandwidth); +/* k=: */ const GstSDPKey* gst_sdp_media_get_key (const GstSDPMedia *media); GstSDPResult gst_sdp_media_set_key (GstSDPMedia *media, const gchar *type, const gchar *data); - +/* a=... */ guint gst_sdp_media_attributes_len (const GstSDPMedia *media); const GstSDPAttribute * gst_sdp_media_get_attribute (const GstSDPMedia *media, guint idx); const gchar* gst_sdp_media_get_attribute_val (const GstSDPMedia *media, const gchar *key); -const gchar* gst_sdp_media_get_attribute_val_n (const GstSDPMedia *media, const gchar *key, guint nth); +const gchar* gst_sdp_media_get_attribute_val_n (const GstSDPMedia *media, const gchar *key, + guint nth); GstSDPResult gst_sdp_media_add_attribute (GstSDPMedia *media, const gchar *key, const gchar *value);