From 124cf22d5d2ddc5b3c5d1a3e5495e12c193fa9a9 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 7 Jan 2014 14:31:09 +0100 Subject: [PATCH] rtsptransport: add method to get media-type from transport MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a method to make a media-type from the transport. Deprecate the old method that only used the mode. Based on patch from Aleix Conchillo FlaquƩ Fixes https://bugzilla.gnome.org/show_bug.cgi?id=720219 --- gst-libs/gst/rtsp/gstrtsptransport.c | 63 ++++++++++++++++++++++++---- gst-libs/gst/rtsp/gstrtsptransport.h | 3 ++ 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/gst-libs/gst/rtsp/gstrtsptransport.c b/gst-libs/gst/rtsp/gstrtsptransport.c index 56adf2f522..6f834a2540 100644 --- a/gst-libs/gst/rtsp/gstrtsptransport.c +++ b/gst-libs/gst/rtsp/gstrtsptransport.c @@ -77,15 +77,25 @@ typedef struct { const gchar *name; const GstRTSPTransMode mode; - const gchar *gst_mime; + const GstRTSPProfile profile; + const gchar *media_type; const gchar *manager[MAX_MANAGERS]; } GstRTSPTransMap; static const GstRTSPTransMap transports[] = { - {"rtp", GST_RTSP_TRANS_RTP, "application/x-rtp", {"rtpbin", "rtpdec"}}, - {"x-real-rdt", GST_RTSP_TRANS_RDT, "application/x-rdt", {"rdtmanager", NULL}}, - {"x-pn-tng", GST_RTSP_TRANS_RDT, "application/x-rdt", {"rdtmanager", NULL}}, - {NULL, GST_RTSP_TRANS_UNKNOWN, NULL, {NULL, NULL}} + {"rtp", GST_RTSP_TRANS_RTP, GST_RTSP_PROFILE_AVP, "application/x-rtp", + {"rtpbin", "rtpdec"}}, + {"srtp", GST_RTSP_TRANS_RTP, GST_RTSP_PROFILE_SAVP, "application/x-srtp", + {"rtpbin", "rtpdec"}}, + {"rtpf", GST_RTSP_TRANS_RTP, GST_RTSP_PROFILE_AVPF, "application/x-rtp", + {"rtpbin", "rtpdec"}}, + {"srtpf", GST_RTSP_TRANS_RTP, GST_RTSP_PROFILE_SAVPF, "application/x-srtp", + {"rtpbin", "rtpdec"}}, + {"x-real-rdt", GST_RTSP_TRANS_RDT, GST_RTSP_PROFILE_AVP, "application/x-rdt", + {"rdtmanager", NULL}}, + {"x-pn-tng", GST_RTSP_TRANS_RDT, GST_RTSP_PROFILE_AVP, "application/x-rdt", + {"rdtmanager", NULL}}, + {NULL, GST_RTSP_TRANS_UNKNOWN, GST_RTSP_PROFILE_UNKNOWN, NULL, {NULL, NULL}} }; typedef struct @@ -228,9 +238,13 @@ gst_rtsp_transport_init (GstRTSPTransport * transport) * @mime: location to hold the result * * Get the mime type of the transport mode @trans. This mime type is typically - * used to generate #GstCaps on buffers. + * used to generate #GstCaps events. * - * Returns: #GST_RTSP_OK. + * Deprecated: This functions only deals with the GstRTSPTransMode and only + * returns the mime type for #GST_RTSP_PROFILE_AVP. Use + * gst_rtsp_transport_get_media_type() instead. + * + * Returns: #GST_RTSP_OK. */ GstRTSPResult gst_rtsp_transport_get_mime (GstRTSPTransMode trans, const gchar ** mime) @@ -240,9 +254,40 @@ gst_rtsp_transport_get_mime (GstRTSPTransMode trans, const gchar ** mime) g_return_val_if_fail (mime != NULL, GST_RTSP_EINVAL); for (i = 0; transports[i].name; i++) - if (transports[i].mode == trans) + if (transports[i].mode == trans + && transports[i].profile == GST_RTSP_PROFILE_AVP) break; - *mime = transports[i].gst_mime; + *mime = transports[i].media_type; + + return GST_RTSP_OK; +} + +/** + * gst_rtsp_transport_get_media_type: + * @transport: a #GstRTSPTransport + * @mime: location to hold the result + * + * Get the media type of @transport. This media type is typically + * used to generate #GstCaps events. + * + * Since: 1.4 + * + * Returns: #GST_RTSP_OK. + */ +GstRTSPResult +gst_rtsp_transport_get_media_type (GstRTSPTransport * transport, + const gchar ** media_type) +{ + gint i; + + g_return_val_if_fail (transport != NULL, GST_RTSP_EINVAL); + g_return_val_if_fail (media_type != NULL, GST_RTSP_EINVAL); + + for (i = 0; transports[i].name; i++) + if (transports[i].mode == transport->trans + && transports[i].profile == transport->profile) + break; + *media_type = transports[i].media_type; return GST_RTSP_OK; } diff --git a/gst-libs/gst/rtsp/gstrtsptransport.h b/gst-libs/gst/rtsp/gstrtsptransport.h index 33039a5bce..e291a942b5 100644 --- a/gst-libs/gst/rtsp/gstrtsptransport.h +++ b/gst-libs/gst/rtsp/gstrtsptransport.h @@ -179,6 +179,9 @@ gchar* gst_rtsp_transport_as_text (GstRTSPTransport *transport) GstRTSPResult gst_rtsp_transport_get_mime (GstRTSPTransMode trans, const gchar **mime); GstRTSPResult gst_rtsp_transport_get_manager (GstRTSPTransMode trans, const gchar **manager, guint option); +GstRTSPResult gst_rtsp_transport_get_media_type (GstRTSPTransport *transport, + const gchar **media_type); + GstRTSPResult gst_rtsp_transport_free (GstRTSPTransport *transport); G_END_DECLS