rtsptransport: add method to get media-type from transport

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é <aleix@oblong.com>

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=720219
This commit is contained in:
Wim Taymans 2014-01-07 14:31:09 +01:00
parent 5b13c5b464
commit 124cf22d5d
2 changed files with 57 additions and 9 deletions

View file

@ -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;
}

View file

@ -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