From fe3e26bee4e9736f8c65aa872750e43261a7a3fa Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Sun, 24 Oct 2010 14:22:39 +0200 Subject: [PATCH] realmedia: Get codec name from pbutils instead of harcoding them --- gst/realmedia/Makefile.am | 2 +- gst/realmedia/rademux.c | 8 +++----- gst/realmedia/rmdemux.c | 19 +++++-------------- gst/realmedia/rmdemux.h | 1 + 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/gst/realmedia/Makefile.am b/gst/realmedia/Makefile.am index 5ee101d..6fe3977 100644 --- a/gst/realmedia/Makefile.am +++ b/gst/realmedia/Makefile.am @@ -9,7 +9,7 @@ libgstrmdemux_la_SOURCES = rademux.c rmdemux.c \ libgstrmdemux_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) libgstrmdemux_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS)\ - -lgstrtsp-@GST_MAJORMINOR@ -lgstsdp-@GST_MAJORMINOR@ + -lgstrtsp-@GST_MAJORMINOR@ -lgstsdp-@GST_MAJORMINOR@ -lgstpbutils-@GST_MAJORMINOR@ libgstrmdemux_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstrmdemux_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/gst/realmedia/rademux.c b/gst/realmedia/rademux.c index 4fc135b..6cc9bd1 100644 --- a/gst/realmedia/rademux.c +++ b/gst/realmedia/rademux.c @@ -301,8 +301,8 @@ gst_real_audio_demux_get_data_offset_from_header (GstRealAudioDemux * demux) static GstFlowReturn gst_real_audio_demux_parse_header (GstRealAudioDemux * demux) { - const gchar *codec_name = NULL; const guint8 *data; + gchar *codec_name = NULL; GstCaps *caps = NULL; guint avail; @@ -378,7 +378,6 @@ gst_real_audio_demux_parse_header (GstRealAudioDemux * demux) case GST_RM_AUD_14_4: caps = gst_caps_new_simple ("audio/x-pn-realaudio", "raversion", G_TYPE_INT, 1, NULL); - codec_name = "Real Audio 14.4kbps"; demux->byterate_num = 1000; demux->byterate_denom = 1; break; @@ -387,11 +386,9 @@ gst_real_audio_demux_parse_header (GstRealAudioDemux * demux) /* FIXME: needs descrambling */ caps = gst_caps_new_simple ("audio/x-pn-realaudio", "raversion", G_TYPE_INT, 2, NULL); - codec_name = "Real Audio 28.8kbps"; break; case GST_RM_AUD_DNET: - codec_name = "AC-3 audio"; caps = gst_caps_new_simple ("audio/x-ac3", "rate", G_TYPE_INT, demux->sample_rate, NULL); if (demux->packet_size == 0 || demux->sample_rate == 0) @@ -402,7 +399,6 @@ gst_real_audio_demux_parse_header (GstRealAudioDemux * demux) /* Sipro/ACELP.NET Voice Codec (MIME unknown) */ case GST_RM_AUD_SIPR: - codec_name = "Sipro Voice"; caps = gst_caps_new_simple ("audio/x-sipro", NULL); break; @@ -427,6 +423,7 @@ gst_real_audio_demux_parse_header (GstRealAudioDemux * demux) demux->srcpad = gst_pad_new_from_static_template (&src_template, "src"); gst_pad_use_fixed_caps (demux->srcpad); gst_pad_set_caps (demux->srcpad, caps); + codec_name = gst_pb_utils_get_codec_description (caps); gst_caps_unref (caps); gst_pad_set_event_function (demux->srcpad, GST_DEBUG_FUNCPTR (gst_real_audio_demux_src_event)); @@ -462,6 +459,7 @@ gst_real_audio_demux_parse_header (GstRealAudioDemux * demux) gst_tag_list_add (demux->pending_tags, GST_TAG_MERGE_REPLACE, GST_TAG_AUDIO_CODEC, codec_name, NULL); + g_free (codec_name); } gst_adapter_flush (demux->adapter, demux->data_offset - 6); diff --git a/gst/realmedia/rmdemux.c b/gst/realmedia/rmdemux.c index 2cc8c47..91070c1 100644 --- a/gst/realmedia/rmdemux.c +++ b/gst/realmedia/rmdemux.c @@ -1281,7 +1281,7 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) { GstCaps *stream_caps = NULL; const gchar *codec_tag = NULL; - const gchar *codec_name = NULL; + gchar *codec_name = NULL; int version = 0; if (stream->subtype == GST_RMDEMUX_STREAM_VIDEO) { @@ -1295,19 +1295,15 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) switch (stream->fourcc) { case GST_RM_VDO_RV10: - codec_name = "Real Video 1.0"; version = 1; break; case GST_RM_VDO_RV20: - codec_name = "Real Video 2.0"; version = 2; break; case GST_RM_VDO_RV30: - codec_name = "Real Video 3.0"; version = 3; break; case GST_RM_VDO_RV40: - codec_name = "Real Video 4.0"; version = 4; break; default: @@ -1349,18 +1345,15 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) switch (stream->fourcc) { /* Older RealAudio Codecs */ case GST_RM_AUD_14_4: - codec_name = "Real Audio 14.4kbps"; version = 1; break; case GST_RM_AUD_28_8: - codec_name = "Real Audio 28.8kbps"; version = 2; break; /* DolbyNet (Dolby AC3, low bitrate) */ case GST_RM_AUD_DNET: - codec_name = "AC-3 audio"; stream_caps = gst_caps_new_simple ("audio/x-ac3", "rate", G_TYPE_INT, (int) stream->rate, NULL); @@ -1372,7 +1365,6 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) /* MPEG-4 based */ case GST_RM_AUD_RAAC: case GST_RM_AUD_RACP: - codec_name = "MPEG4 audio"; stream_caps = gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT, (int) 4, "framed", G_TYPE_BOOLEAN, TRUE, NULL); @@ -1388,7 +1380,6 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) /* Sony ATRAC3 */ case GST_RM_AUD_ATRC: - codec_name = "Sony ATRAC3"; stream_caps = gst_caps_new_simple ("audio/x-vnd.sony.atrac3", NULL); stream->needs_descrambling = TRUE; stream->subpackets_needed = stream->height; @@ -1397,7 +1388,6 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) /* RealAudio G2 audio */ case GST_RM_AUD_COOK: - codec_name = "Real Audio G2 (Cook)"; version = 8; stream->needs_descrambling = TRUE; stream->subpackets_needed = stream->height; @@ -1406,7 +1396,6 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) /* RALF is lossless */ case GST_RM_AUD_RALF: - codec_name = "Real Audio Lossless (RALF)"; GST_DEBUG_OBJECT (rmdemux, "RALF"); stream_caps = gst_caps_new_simple ("audio/x-ralf-mpeg4-generic", NULL); break; @@ -1420,7 +1409,6 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) goto beach; } - codec_name = "Sipro/ACELP.NET Voice"; GST_DEBUG_OBJECT (rmdemux, "SIPR"); stream_caps = gst_caps_new_simple ("audio/x-sipro", NULL); stream->needs_descrambling = TRUE; @@ -1506,12 +1494,15 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) gst_pad_set_active (stream->pad, TRUE); gst_element_add_pad (GST_ELEMENT_CAST (rmdemux), stream->pad); + codec_name = gst_pb_utils_get_codec_description (stream_caps); + /* save for later, we must send the tags after the newsegment event */ - if (codec_name != NULL && codec_tag != NULL) { + if (codec_tag != NULL && codec_name != NULL) { if (stream->pending_tags == NULL) stream->pending_tags = gst_tag_list_new (); gst_tag_list_add (stream->pending_tags, GST_TAG_MERGE_KEEP, codec_tag, codec_name, NULL); + g_free (codec_name); } } diff --git a/gst/realmedia/rmdemux.h b/gst/realmedia/rmdemux.h index 4ebe6b0..7a26741 100644 --- a/gst/realmedia/rmdemux.h +++ b/gst/realmedia/rmdemux.h @@ -23,6 +23,7 @@ #include #include +#include G_BEGIN_DECLS -- 2.7.4