From ac7d3463551026d8b51eb9afec1107dfa99f2f25 Mon Sep 17 00:00:00 2001 From: "Reynaldo H. Verdejo Pinochet" Date: Tue, 31 Dec 2013 21:31:43 -0300 Subject: [PATCH] shout2send: change audio_format field to format This element and the underlying libshout2 library can handle video media files too. The code already handles video/webm so the name gets confusing. Also add and use DEFAULT_FORMAT macro Instead of hardwiring SHOUT_FORMAT_VORBIS at init https://bugzilla.gnome.org/show_bug.cgi?id=721342 --- ext/shout2/gstshout2.c | 21 +++++++++++---------- ext/shout2/gstshout2.h | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ext/shout2/gstshout2.c b/ext/shout2/gstshout2.c index 186d4c9..a016d0d 100644 --- a/ext/shout2/gstshout2.c +++ b/ext/shout2/gstshout2.c @@ -84,6 +84,7 @@ enum #define DEFAULT_MOUNT "" #define DEFAULT_URL "" #define DEFAULT_PROTOCOL SHOUT2SEND_PROTOCOL_HTTP +#define DEFAULT_FORMAT SHOUT_FORMAT_VORBIS #ifdef SHOUT_FORMAT_WEBM #define WEBM_CAPS "; video/webm; audio/webm" @@ -254,10 +255,10 @@ gst_shout2send_init (GstShout2send * shout2send) shout2send->url = g_strdup (DEFAULT_URL); shout2send->protocol = DEFAULT_PROTOCOL; shout2send->ispublic = DEFAULT_PUBLIC; + shout2send->format = DEFAULT_FORMAT; shout2send->tags = gst_tag_list_new_empty (); shout2send->conn = NULL; - shout2send->audio_format = SHOUT_FORMAT_VORBIS; shout2send->connected = FALSE; shout2send->songmetadata = NULL; shout2send->songartist = NULL; @@ -382,8 +383,8 @@ gst_shout2send_event (GstBaseSink * sink, GstEvent * event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_TAG:{ - /* vorbis audio doesnt need metadata setting on the icecast level, only mp3 */ - if (shout2send->tags && shout2send->audio_format == SHOUT_FORMAT_MP3) { + /* vorbis audio doesn't need metadata setting on the icecast level, only mp3 */ + if (shout2send->tags && shout2send->format == SHOUT_FORMAT_MP3) { GstTagList *list; gst_event_parse_tag (event, &list); @@ -520,15 +521,15 @@ static gboolean gst_shout2send_connect (GstShout2send * sink) { const char *format = - (sink->audio_format == SHOUT_FORMAT_VORBIS) ? "vorbis" : - ((sink->audio_format == SHOUT_FORMAT_MP3) ? "mp3" : "unknown"); + (sink->format == SHOUT_FORMAT_VORBIS) ? "vorbis" : + ((sink->format == SHOUT_FORMAT_MP3) ? "mp3" : "unknown"); #ifdef SHOUT_FORMAT_WEBM - if (sink->audio_format == SHOUT_FORMAT_WEBM) + if (sink->format == SHOUT_FORMAT_WEBM) format = "webm"; #endif GST_DEBUG_OBJECT (sink, "Connection format is: %s", format); - if (shout_set_format (sink->conn, sink->audio_format) != SHOUTERR_SUCCESS) + if (shout_set_format (sink->conn, sink->format) != SHOUTERR_SUCCESS) goto could_not_set_format; if (shout_open (sink->conn) != SHOUTERR_SUCCESS) @@ -796,12 +797,12 @@ gst_shout2send_setcaps (GstBaseSink * basesink, GstCaps * caps) GST_DEBUG_OBJECT (shout2send, "mimetype of caps given is: %s", mimetype); if (!strcmp (mimetype, "audio/mpeg")) { - shout2send->audio_format = SHOUT_FORMAT_MP3; + shout2send->format = SHOUT_FORMAT_MP3; } else if (!strcmp (mimetype, "application/ogg")) { - shout2send->audio_format = SHOUT_FORMAT_VORBIS; + shout2send->format = SHOUT_FORMAT_VORBIS; #ifdef SHOUT_FORMAT_WEBM } else if (!strcmp (mimetype, "video/webm")) { - shout2send->audio_format = SHOUT_FORMAT_WEBM; + shout2send->format = SHOUT_FORMAT_WEBM; #endif } else { ret = FALSE; diff --git a/ext/shout2/gstshout2.h b/ext/shout2/gstshout2.h index eb7b2d9..2b212db 100644 --- a/ext/shout2/gstshout2.h +++ b/ext/shout2/gstshout2.h @@ -60,7 +60,7 @@ struct _GstShout2send { gchar *songmetadata; gchar *songartist; gchar *songtitle; - guint16 audio_format; + guint16 format; GstTagList* tags; }; -- 2.7.4