summaryrefslogtreecommitdiffstats
path: root/ext/shout2
diff options
context:
space:
mode:
authorZaheer Abbas Merali <zaheerabbas@merali.org>2006-02-07 13:39:08 +0000
committerZaheer Abbas Merali <zaheerabbas@merali.org>2006-02-07 13:39:08 +0000
commit02a1c7994cb1d7c0e97a72bfba3f0511270c4f75 (patch)
tree401a907a9d813f58cc08e144172dc16849d0b3ab /ext/shout2
parent21dbd4eb9a41c9d7ba5b5ba7f7c43f7599ec82c8 (diff)
ext/shout2/gstshout2.c: Make shout2 work for non ogg streams
Original commit message from CVS: 2006-02-07 Zaheer Abbas Merali <zaheerabbas at merali dot org> * ext/shout2/gstshout2.c: (gst_shout2send_render), (gst_shout2send_setcaps), (gst_shout2send_change_state): Make shout2 work for non ogg streams
Diffstat (limited to 'ext/shout2')
-rw-r--r--ext/shout2/gstshout2.c58
1 files changed, 32 insertions, 26 deletions
diff --git a/ext/shout2/gstshout2.c b/ext/shout2/gstshout2.c
index e87da679..5ede7de4 100644
--- a/ext/shout2/gstshout2.c
+++ b/ext/shout2/gstshout2.c
@@ -366,6 +366,32 @@ gst_shout2send_render (GstBaseSink * sink, GstBuffer * buf)
shout2send = GST_SHOUT2SEND (sink);
+ if (!shout2send->started) {
+/* connect */
+ GST_DEBUG ("Connection format is: %s",
+ shout2send->audio_format == SHOUT_FORMAT_VORBIS ? "vorbis" :
+ (shout2send->audio_format == SHOUT_FORMAT_MP3 ? "mp3" : "unknown"));
+ if (shout_set_format (shout2send->conn,
+ shout2send->audio_format) != SHOUTERR_SUCCESS) {
+ GST_ERROR ("Error setting connection format: %s\n",
+ shout_get_error (shout2send->conn));
+ }
+
+ if (shout_open (shout2send->conn) == SHOUTERR_SUCCESS) {
+ g_print ("connected to server...\n");
+ /* lets set metadata */
+ gst_shout2send_set_metadata (shout2send);
+ shout2send->started = TRUE;
+
+ } else {
+ GST_ERROR ("Couldn't connect to server: %s",
+ shout_get_error (shout2send->conn));
+ shout2send->conn = FALSE;
+
+ }
+ }
+
+
if (shout2send->clock && shout2send->sync) {
//GST_DEBUG("using GStreamer clock to sync");
//gst_element_wait (GST_ELEMENT (shout2send), GST_BUFFER_TIMESTAMP (buf));
@@ -520,7 +546,7 @@ gst_shout2send_setcaps (GstPad * pad, GstCaps * caps)
shout2send->audio_format = SHOUT_FORMAT_MP3;
}
- if (!strcmp (mimetype, "application/ogg")) {
+ else if (!strcmp (mimetype, "application/ogg")) {
shout2send->audio_format = SHOUT_FORMAT_VORBIS;
} else {
ret = FALSE;
@@ -638,28 +664,6 @@ gst_shout2send_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
-
- /* connect */
- GST_DEBUG ("Connection format is: %s",
- shout2send->audio_format == SHOUT_FORMAT_VORBIS ? "vorbis" :
- (shout2send->audio_format == SHOUT_FORMAT_MP3 ? "mp3" : "unknown"));
- if (shout_set_format (shout2send->conn,
- shout2send->audio_format) != SHOUTERR_SUCCESS) {
- GST_ERROR ("Error setting connection format: %s\n",
- shout_get_error (shout2send->conn));
- }
-
- if (shout_open (shout2send->conn) == SHOUTERR_SUCCESS) {
- g_print ("connected to server...\n");
- /* lets set metadata */
- gst_shout2send_set_metadata (shout2send);
-
- } else {
- GST_ERROR ("Couldn't connect to server: %s",
- shout_get_error (shout2send->conn));
- shout2send->conn = FALSE;
- return GST_STATE_CHANGE_FAILURE;
- }
break;
@@ -673,9 +677,11 @@ gst_shout2send_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
- shout_close (shout2send->conn);
- shout_free (shout2send->conn);
- shout2send->started = FALSE;
+ if (shout2send->started) {
+ shout_close (shout2send->conn);
+ shout_free (shout2send->conn);
+ shout2send->started = FALSE;
+ }
break;
case GST_STATE_CHANGE_READY_TO_NULL:
break;