gst/rtp/README: Update README

Original commit message from CVS:
* gst/rtp/README:
Update README

* gst/rtp/gstrtpamrdec.c: (gst_rtpamrdec_sink_setcaps):
Make extra params as strings.

* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_set_state),
(gst_rtspsrc_parse_rtpmap), (gst_rtspsrc_media_to_caps),
(gst_rtspsrc_stream_setup_rtp), (gst_rtspsrc_send):
Make state change return NO_PREROLL as this is a live
source.

* gst/udp/gstudpsrc.c: (gst_udpsrc_set_property):
Don't unref old caps when NULL.
This commit is contained in:
Wim Taymans 2005-09-21 12:19:24 +00:00
parent eb20f045f8
commit 9dd3929730
6 changed files with 140 additions and 58 deletions

View file

@ -1,3 +1,20 @@
2005-09-21 Wim Taymans <wim@fluendo.com>
* gst/rtp/README:
Update README
* gst/rtp/gstrtpamrdec.c: (gst_rtpamrdec_sink_setcaps):
Make extra params as strings.
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_set_state),
(gst_rtspsrc_parse_rtpmap), (gst_rtspsrc_media_to_caps),
(gst_rtspsrc_stream_setup_rtp), (gst_rtspsrc_send):
Make state change return NO_PREROLL as this is a live
source.
* gst/udp/gstudpsrc.c: (gst_udpsrc_set_property):
Don't unref old caps when NULL.
2005-09-20 Wim Taymans <wim@fluendo.com>
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_get_type),

View file

@ -35,7 +35,8 @@ The following fields can or must (*) be specified in the structure:
extra encoding parameters (as in the SDP a=rtpmap: field). only required
if different from the default of the encoding-name.
Optional parameters as key/value pairs, media type specific.
Optional parameters as key/value pairs, media type specific. The value type
should be of type G_TYPE_STRING.
Example:
@ -45,10 +46,10 @@ The following fields can or must (*) be specified in the structure:
"clock-rate", G_TYPE_INT, 8000, -]
"encoding-name", G_TYPE_STRING, "AMR", -] - required since payload >= 96
"encoding-params", G_TYPE_STRING, "1", -] - optional param for AMR
"octet-align", G_TYPE_BOOLEAN, TRUE, -]
"crc", G_TYPE_BOOLEAN, FALSE, ]
"robust-sorting", G_TYPE_BOOLEAN, FALSE, ] AMR specific params.
"interleaving", G_TYPE_BOOLEAN, FALSE, -]
"octet-align", G_TYPE_STRING, "1", -]
"crc", G_TYPE_STRING, "0", ]
"robust-sorting", G_TYPE_STRING, "0", ] AMR specific params.
"interleaving", G_TYPE_STRING, "0", -]
Mapping of caps to and from SDP fields:

View file

@ -63,10 +63,10 @@ GST_STATIC_PAD_TEMPLATE ("sink",
"clock-rate = (int) 8000, "
"encoding-name = (string) \"AMR\", "
"encoding-params = (string) \"1\", "
"octet-align = (boolean) TRUE, "
"crc = (boolean) FALSE, "
"robust-sorting = (boolean) FALSE, " "interleaving = (boolean) FALSE"
/* following options are not needed for a decoder
"octet-align = (string) 1, "
"crc = (string) 0, "
"robust-sorting = (string) 0, " "interleaving = (string) 0"
/* following options are not needed for a decoder
*
"mode-set = (int) [ 0, 7 ], "
"mode-change-period = (int) [ 1, MAX ], "
@ -180,35 +180,41 @@ gst_rtpamrdec_sink_setcaps (GstPad * pad, GstCaps * caps)
GstCaps *srccaps;
GstRtpAMRDec *rtpamrdec;
const gchar *params;
const gchar *str;
rtpamrdec = GST_RTP_AMR_DEC (GST_OBJECT_PARENT (pad));
structure = gst_caps_get_structure (caps, 0);
if (!gst_structure_get_boolean (structure, "octet-align",
&rtpamrdec->octet_align))
if (!(str = gst_structure_get_string (structure, "octet-align")))
rtpamrdec->octet_align = FALSE;
else
rtpamrdec->octet_align = (atoi (str) == 1);
if (!gst_structure_get_boolean (structure, "crc", &rtpamrdec->crc))
if (!(str = gst_structure_get_string (structure, "crc")))
rtpamrdec->crc = FALSE;
else
rtpamrdec->crc = (atoi (str) == 1);
if (rtpamrdec->crc) {
/* crc mode implies octet aligned mode */
rtpamrdec->octet_align = TRUE;
}
if (!gst_structure_get_boolean (structure, "robust-sorting",
&rtpamrdec->robust_sorting))
if (!(str = gst_structure_get_string (structure, "robust-sorting")))
rtpamrdec->robust_sorting = FALSE;
else
rtpamrdec->robust_sorting = (atoi (str) == 1);
if (rtpamrdec->robust_sorting) {
/* robust_sorting mode implies octet aligned mode */
rtpamrdec->octet_align = TRUE;
}
if (!gst_structure_get_boolean (structure, "interleaving",
&rtpamrdec->interleaving))
if (!(str = gst_structure_get_string (structure, "interleaving")))
rtpamrdec->interleaving = FALSE;
else
rtpamrdec->interleaving = (atoi (str) == 1);
if (rtpamrdec->interleaving) {
/* interleaving mode implies octet aligned mode */

View file

@ -63,10 +63,10 @@ GST_STATIC_PAD_TEMPLATE ("sink",
"clock-rate = (int) 8000, "
"encoding-name = (string) \"AMR\", "
"encoding-params = (string) \"1\", "
"octet-align = (boolean) TRUE, "
"crc = (boolean) FALSE, "
"robust-sorting = (boolean) FALSE, " "interleaving = (boolean) FALSE"
/* following options are not needed for a decoder
"octet-align = (string) 1, "
"crc = (string) 0, "
"robust-sorting = (string) 0, " "interleaving = (string) 0"
/* following options are not needed for a decoder
*
"mode-set = (int) [ 0, 7 ], "
"mode-change-period = (int) [ 1, MAX ], "
@ -180,35 +180,41 @@ gst_rtpamrdec_sink_setcaps (GstPad * pad, GstCaps * caps)
GstCaps *srccaps;
GstRtpAMRDec *rtpamrdec;
const gchar *params;
const gchar *str;
rtpamrdec = GST_RTP_AMR_DEC (GST_OBJECT_PARENT (pad));
structure = gst_caps_get_structure (caps, 0);
if (!gst_structure_get_boolean (structure, "octet-align",
&rtpamrdec->octet_align))
if (!(str = gst_structure_get_string (structure, "octet-align")))
rtpamrdec->octet_align = FALSE;
else
rtpamrdec->octet_align = (atoi (str) == 1);
if (!gst_structure_get_boolean (structure, "crc", &rtpamrdec->crc))
if (!(str = gst_structure_get_string (structure, "crc")))
rtpamrdec->crc = FALSE;
else
rtpamrdec->crc = (atoi (str) == 1);
if (rtpamrdec->crc) {
/* crc mode implies octet aligned mode */
rtpamrdec->octet_align = TRUE;
}
if (!gst_structure_get_boolean (structure, "robust-sorting",
&rtpamrdec->robust_sorting))
if (!(str = gst_structure_get_string (structure, "robust-sorting")))
rtpamrdec->robust_sorting = FALSE;
else
rtpamrdec->robust_sorting = (atoi (str) == 1);
if (rtpamrdec->robust_sorting) {
/* robust_sorting mode implies octet aligned mode */
rtpamrdec->octet_align = TRUE;
}
if (!gst_structure_get_boolean (structure, "interleaving",
&rtpamrdec->interleaving))
if (!(str = gst_structure_get_string (structure, "interleaving")))
rtpamrdec->interleaving = FALSE;
else
rtpamrdec->interleaving = (atoi (str) == 1);
if (rtpamrdec->interleaving) {
/* interleaving mode implies octet aligned mode */

View file

@ -287,6 +287,7 @@ gst_rtspsrc_set_state (GstRTSPSrc * src, GstState state)
state)) == GST_STATE_CHANGE_FAILURE)
goto done;
}
if (stream->rtcpsrc) {
if ((ret =
gst_element_set_state (stream->rtcpsrc,
@ -299,6 +300,36 @@ done:
return ret;
}
#define PARSE_INT(p, del, res) \
G_STMT_START { \
gchar *t = p; \
p = strstr (p, del); \
if (p == NULL) \
res = -1; \
else { \
*p = '\0'; \
p++; \
res = atoi (t); \
} \
} G_STMT_END
#define PARSE_STRING(p, del, res) \
G_STMT_START { \
gchar *t = p; \
p = strstr (p, del); \
if (p == NULL) \
res = NULL; \
else { \
*p = '\0'; \
p++; \
res = t; \
} \
} G_STMT_END
#define SKIP_SPACES(p) \
while (*p && g_ascii_isspace (*p)) \
p++;
static gboolean
gst_rtspsrc_parse_rtpmap (gchar * rtpmap, gint * payload, gchar ** name,
gint * rate, gchar ** params)
@ -307,27 +338,17 @@ gst_rtspsrc_parse_rtpmap (gchar * rtpmap, gint * payload, gchar ** name,
t = p = rtpmap;
p = strstr (p, " ");
if (p == NULL)
PARSE_INT (p, " ", *payload);
if (*payload == -1)
return FALSE;
*p = '\0';
p++;
*payload = atoi (t);
while (*p && g_ascii_isspace (*p))
p++;
SKIP_SPACES (p);
if (*p == '\0')
return FALSE;
t = p;
p = strstr (p, "/");
if (p == NULL)
PARSE_STRING (p, "/", *name);
if (*name == NULL)
return FALSE;
*p = '\0';
p++;
*name = t;
t = p;
p = strstr (p, "/");
@ -360,8 +381,7 @@ gst_rtspsrc_media_to_caps (SDPMedia * media)
GstCaps *caps;
gchar *payload;
gchar *rtpmap;
//gchar *fmtp;
gchar *fmtp;
gint pt;
gchar *name = NULL;
gint rate = -1;
@ -379,21 +399,23 @@ gst_rtspsrc_media_to_caps (SDPMedia * media)
gint payload = 0;
gboolean ret;
rtpmap = sdp_media_get_attribute_val (media, "rtpmap");
if (rtpmap == NULL) {
g_warning ("rtpmap type not given");
if ((rtpmap = sdp_media_get_attribute_val (media, "rtpmap"))) {
if ((ret =
gst_rtspsrc_parse_rtpmap (rtpmap, &payload, &name, &rate,
&params))) {
if (payload != pt) {
g_warning ("rtpmap of wrong payload type");
name = NULL;
rate = -1;
params = NULL;
}
} else {
g_warning ("error parsing rtpmap");
}
} else {
g_warning ("rtpmap type not given fot dynamic payload %d", pt);
return NULL;
}
ret = gst_rtspsrc_parse_rtpmap (rtpmap, &payload, &name, &rate, &params);
if (!ret) {
g_warning ("error parsing rtpmap");
}
if (payload != pt) {
g_warning ("rtpmap of wrong payload type");
name = NULL;
rate = -1;
params = NULL;
}
}
caps = gst_caps_new_simple ("application/x-rtp",
@ -409,6 +431,32 @@ gst_rtspsrc_media_to_caps (SDPMedia * media)
if (params != NULL)
gst_structure_set (s, "encoding-params", G_TYPE_STRING, params, NULL);
/* parse optional fmtp: field */
if ((fmtp = sdp_media_get_attribute_val (media, "fmtp"))) {
gchar *p;
gint payload = 0;
p = fmtp;
PARSE_INT (p, " ", payload);
if (payload != -1 && payload == pt) {
gchar **pairs;
gint i;
pairs = g_strsplit (p, ";", 0);
for (i = 0; pairs[i]; i++) {
gchar **keyval;
keyval = g_strsplit (pairs[i], "=", 0);
if (keyval[0] && keyval[1]) {
gst_structure_set (s, keyval[0], G_TYPE_STRING, keyval[1], NULL);
}
g_strfreev (keyval);
}
g_strfreev (pairs);
}
}
return caps;
}
@ -451,6 +499,9 @@ gst_rtspsrc_stream_setup_rtp (GstRTSPStream * stream, SDPMedia * media,
g_object_get (G_OBJECT (stream->rtpsrc), "port", rtpport, NULL);
g_object_get (G_OBJECT (stream->rtcpsrc), "port", rtcpport, NULL);
gst_element_set_state (stream->rtpsrc, GST_STATE_READY);
gst_element_set_state (stream->rtcpsrc, GST_STATE_READY);
return TRUE;
/* ERRORS, FIXME, cleanup */

View file

@ -407,7 +407,8 @@ gst_udpsrc_set_property (GObject * object, guint prop_id, const GValue * value,
old_caps = udpsrc->caps;
udpsrc->caps = new_caps;
gst_caps_unref (old_caps);
if (old_caps)
gst_caps_unref (old_caps);
gst_pad_set_caps (GST_BASE_SRC (udpsrc)->srcpad, new_caps);
break;
}