Commit bd4c432d authored by hark's avatar hark
Browse files

autodetect width and height

parent 41b4f75f
...@@ -24,7 +24,7 @@ c-player-0.10 : c-player.c ...@@ -24,7 +24,7 @@ c-player-0.10 : c-player.c
c-player-debug : c-player.c c-player-debug : c-player.c
gcc -D TT -DTESTING -DGTK -DGST1 -g c-player.c wraps.c playlist.c snowbin.c teebin.c -o c-player-debug `pkg-config --cflags --libs gtk+-2.0 gstreamer-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0` $(CFLAGS) gcc -D TT -DTESTING -DGTK -DGST1 -g c-player.c wraps.c playlist.c snowbin.c teebin.c -o c-player-debug `pkg-config --cflags --libs gtk+-2.0 gstreamer-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0` $(CFLAGS)
c-player : c-player.c c-player : c-player.c snowbin.c playlist.c teebin.c wraps.c
gcc -DGTK -DGST1 -g c-player.c wraps.c playlist.c snowbin.c teebin.c -o c-player `pkg-config --cflags --libs gtk+-2.0 gstreamer-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0` $(CFLAGS) gcc -DGTK -DGST1 -g c-player.c wraps.c playlist.c snowbin.c teebin.c -o c-player `pkg-config --cflags --libs gtk+-2.0 gstreamer-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0` $(CFLAGS)
c-player-cli : c-player.c c-player-cli : c-player.c
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
static const char *playuri = NULL; static const char *playuri = NULL;
static char *feedname = NULL; static char *feedname = NULL;
static int preview = 0; static int preview = 0;
// CustomData data;
static GstStateChangeReturn ret; static GstStateChangeReturn ret;
static GstBus *bus; static GstBus *bus;
// snowbin or auto // snowbin or auto
...@@ -82,7 +81,7 @@ static gpointer thread_time_func( gpointer data ) ...@@ -82,7 +81,7 @@ static gpointer thread_time_func( gpointer data )
#ifdef GTK #ifdef GTK
static void static void
realize_cb (GtkWidget * widget, CustomData * data) realize_cb (GtkWidget * widget, PlayerData * data)
{ {
GdkWindow *window = gtk_widget_get_window (widget); GdkWindow *window = gtk_widget_get_window (widget);
static guintptr window_handle; static guintptr window_handle;
...@@ -114,7 +113,7 @@ realize_cb (GtkWidget * widget, CustomData * data) ...@@ -114,7 +113,7 @@ realize_cb (GtkWidget * widget, CustomData * data)
/* This function is called when the PLAY button is clicked */ /* This function is called when the PLAY button is clicked */
#ifdef GTK #ifdef GTK
static void static void
play_cb (GtkButton * button, CustomData * data) play_cb (GtkButton * button, PlayerData * data)
{ {
gst_element_set_state (data->playbin2, GST_STATE_PLAYING); gst_element_set_state (data->playbin2, GST_STATE_PLAYING);
...@@ -123,7 +122,7 @@ play_cb (GtkButton * button, CustomData * data) ...@@ -123,7 +122,7 @@ play_cb (GtkButton * button, CustomData * data)
/* This function is called when the PAUSE button is clicked */ /* This function is called when the PAUSE button is clicked */
static void static void
pause_cb (GtkButton * button, CustomData * data) pause_cb (GtkButton * button, PlayerData * data)
{ {
gst_element_set_state (data->playbin2, GST_STATE_PAUSED); gst_element_set_state (data->playbin2, GST_STATE_PAUSED);
...@@ -132,7 +131,7 @@ pause_cb (GtkButton * button, CustomData * data) ...@@ -132,7 +131,7 @@ pause_cb (GtkButton * button, CustomData * data)
/* This function is called when the STOP button is clicked */ /* This function is called when the STOP button is clicked */
static void static void
stop_cb (GtkButton * button, CustomData * data) stop_cb (GtkButton * button, PlayerData * data)
{ {
gst_element_set_state (data->playbin2, GST_STATE_READY); gst_element_set_state (data->playbin2, GST_STATE_READY);
} }
...@@ -142,9 +141,9 @@ stop_cb (GtkButton * button, CustomData * data) ...@@ -142,9 +141,9 @@ stop_cb (GtkButton * button, CustomData * data)
load_uri (const gchar * uri) load_uri (const gchar * uri)
{ {
// this would stop playback, so don't do that // this would stop playback, so don't do that
//gst_element_set_state (globalData.playbin2, GST_STATE_READY); //gst_element_set_state (playerData.playbin2, GST_STATE_READY);
// GstStateChangeReturn ret; // GstStateChangeReturn ret;
g_object_set (globalData.playbin2, "uri", uri, NULL); g_object_set (pData->playbin2, "uri", uri, NULL);
#ifdef GTK #ifdef GTK
markup = markup =
...@@ -152,12 +151,12 @@ load_uri (const gchar * uri) ...@@ -152,12 +151,12 @@ load_uri (const gchar * uri)
("<span foreground=\"red\" size=\"x-large\">%s</span>", uri); ("<span foreground=\"red\" size=\"x-large\">%s</span>", uri);
gtk_label_set_markup (GTK_LABEL (loaded_label), markup); gtk_label_set_markup (GTK_LABEL (loaded_label), markup);
#endif #endif
// gst_element_set_state (globalData.playbin2, GST_STATE_PLAYING); // gst_element_set_state (pData->playbin2, GST_STATE_PLAYING);
} }
#ifdef GTK #ifdef GTK
static void static void
preview_cb (GtkCheckButton * preview_check, CustomData * data) preview_cb (GtkCheckButton * preview_check, PlayerData * data)
{ {
while (TRUE) while (TRUE)
{ {
...@@ -165,15 +164,15 @@ preview_cb (GtkCheckButton * preview_check, CustomData * data) ...@@ -165,15 +164,15 @@ preview_cb (GtkCheckButton * preview_check, CustomData * data)
{ {
g_print ("turning on preview checkcb \n"); g_print ("turning on preview checkcb \n");
teebin_preview_on(data); teebin_preview_on(data);
/* gst_element_set_state (globalData.playbin2, GST_STATE_NULL); /* gst_element_set_state (pData->playbin2, GST_STATE_NULL);
GstElement *videosink, *audiosink; GstElement *videosink, *audiosink;
videosink = gst_element_factory_make ("xvimagesink", "xvimagesink"); videosink = gst_element_factory_make ("xvimagesink", "xvimagesink");
audiosink = audiosink =
gst_element_factory_make ("autoaudiosink", "autoaudiosink"); gst_element_factory_make ("autoaudiosink", "autoaudiosink");
g_object_set (globalData.playbin2, "video-sink", videosink, NULL); g_object_set (pData->playbin2, "video-sink", videosink, NULL);
g_object_set (globalData.playbin2, "audio-sink", audiosink, NULL); g_object_set (pData->playbin2, "audio-sink", audiosink, NULL);
gst_element_set_state (globalData.playbin2, GST_STATE_PLAYING); gst_element_set_state (pData->playbin2, GST_STATE_PLAYING);
*/ */
preview = 1; preview = 1;
break; break;
...@@ -205,7 +204,7 @@ preview_cb (GtkCheckButton * preview_check, CustomData * data) ...@@ -205,7 +204,7 @@ preview_cb (GtkCheckButton * preview_check, CustomData * data)
/* This function is called when the main window is closed */ /* This function is called when the main window is closed */
#ifdef GTK #ifdef GTK
static void static void
delete_event_cb (GtkWidget * widget, GdkEvent * event, CustomData * data) delete_event_cb (GtkWidget * widget, GdkEvent * event, PlayerData * data)
{ {
stop_cb (NULL, data); stop_cb (NULL, data);
gtk_main_quit (); gtk_main_quit ();
...@@ -215,7 +214,7 @@ delete_event_cb (GtkWidget * widget, GdkEvent * event, CustomData * data) ...@@ -215,7 +214,7 @@ delete_event_cb (GtkWidget * widget, GdkEvent * event, CustomData * data)
* rescaling, etc). GStreamer takes care of this in the PAUSED and PLAYING states, otherwise, * rescaling, etc). GStreamer takes care of this in the PAUSED and PLAYING states, otherwise,
* we simply draw a black rectangle to avoid garbage showing up. */ * we simply draw a black rectangle to avoid garbage showing up. */
static gboolean static gboolean
expose_cb (GtkWidget * widget, GdkEventExpose * event, CustomData * data) expose_cb (GtkWidget * widget, GdkEventExpose * event, PlayerData * data)
{ {
if (data->state < GST_STATE_PAUSED) if (data->state < GST_STATE_PAUSED)
...@@ -244,7 +243,7 @@ expose_cb (GtkWidget * widget, GdkEventExpose * event, CustomData * data) ...@@ -244,7 +243,7 @@ expose_cb (GtkWidget * widget, GdkEventExpose * event, CustomData * data)
/* This function is called when the slider changes its position. We perform a seek to the /* This function is called when the slider changes its position. We perform a seek to the
* new position here. */ * new position here. */
static void static void
slider_cb (GtkRange * range, CustomData * data) slider_cb (GtkRange * range, PlayerData * data)
{ {
gdouble value = gtk_range_get_value (GTK_RANGE (data->slider)); gdouble value = gtk_range_get_value (GTK_RANGE (data->slider));
gst_element_seek_simple (data->playbin2, GST_FORMAT_TIME, gst_element_seek_simple (data->playbin2, GST_FORMAT_TIME,
...@@ -256,7 +255,7 @@ slider_cb (GtkRange * range, CustomData * data) ...@@ -256,7 +255,7 @@ slider_cb (GtkRange * range, CustomData * data)
#ifdef GTK #ifdef GTK
/* This creates all the GTK+ widgets that compose our application, and registers the callbacks */ /* This creates all the GTK+ widgets that compose our application, and registers the callbacks */
static void static void
create_ui (CustomData * data) create_ui (PlayerData * data)
{ {
static GtkWidget *main_window; /* The uppermost window, containing all other windows */ static GtkWidget *main_window; /* The uppermost window, containing all other windows */
...@@ -398,7 +397,7 @@ thread_time = g_thread_create( thread_time_func, (gpointer)label_time, FALSE, &e ...@@ -398,7 +397,7 @@ thread_time = g_thread_create( thread_time_func, (gpointer)label_time, FALSE, &e
#ifdef GTK #ifdef GTK
/* This function is called periodically to refresh the GUI */ /* This function is called periodically to refresh the GUI */
static int static int
refresh_ui (CustomData * data) refresh_ui (PlayerData * data)
{ {
GstFormat fmt = GST_FORMAT_TIME; GstFormat fmt = GST_FORMAT_TIME;
gint64 current = -1; gint64 current = -1;
...@@ -469,18 +468,18 @@ refresh_ui (CustomData * data) ...@@ -469,18 +468,18 @@ refresh_ui (CustomData * data)
player_reset_and_play () player_reset_and_play ()
{ {
/* stop playing */ /* stop playing */
gst_element_set_state (globalData.playbin2, GST_STATE_READY); gst_element_set_state (pData->playbin2, GST_STATE_READY);
printf("current uri: %s", playlist_get_current()); printf("current uri: %s", playlist_get_current());
load_uri(playlist_get_current()); load_uri(playlist_get_current());
// static int ret; // static int ret;
/* Start playing */ /* Start playing */
ret = gst_element_set_state (globalData.playbin2, GST_STATE_PLAYING); ret = gst_element_set_state (pData->playbin2, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) if (ret == GST_STATE_CHANGE_FAILURE)
{ {
g_printerr ("state change failure in player_reset_and_play\n"); g_printerr ("state change failure in player_reset_and_play\n");
// gst_object_unref (globalData.playbin2); // gst_object_unref (pData->playbin2);
// return -1; // return -1;
return 1; return 1;
} }
...@@ -490,7 +489,7 @@ player_reset_and_play () ...@@ -490,7 +489,7 @@ player_reset_and_play ()
/* This function is called when new metadata is discovered in the stream */ /* This function is called when new metadata is discovered in the stream */
static void static void
tags_cb (GstElement * playbin2, gint stream, CustomData * data) tags_cb (GstElement * playbin2, gint stream, PlayerData * data)
{ {
/* We are possibly in a GStreamer working thread, so we notify the main /* We are possibly in a GStreamer working thread, so we notify the main
* thread of this event through a message in the bus */ * thread of this event through a message in the bus */
...@@ -508,7 +507,7 @@ tags_cb (GstElement * playbin2, gint stream, CustomData * data) ...@@ -508,7 +507,7 @@ tags_cb (GstElement * playbin2, gint stream, CustomData * data)
/* This function is called when an error message is posted on the bus */ /* This function is called when an error message is posted on the bus */
static void static void
error_cb (GstBus * bus, GstMessage * msg, CustomData * data) error_cb (GstBus * bus, GstMessage * msg, PlayerData * data)
{ {
GError *err; GError *err;
gchar *debug_info; gchar *debug_info;
...@@ -530,7 +529,7 @@ error_cb (GstBus * bus, GstMessage * msg, CustomData * data) ...@@ -530,7 +529,7 @@ error_cb (GstBus * bus, GstMessage * msg, CustomData * data)
* next item in playlist will be loaded now * next item in playlist will be loaded now
* and something should flash*/ * and something should flash*/
static void static void
aeos_cb (GstBus * bus, GstMessage * msg, CustomData * data) aeos_cb (GstBus * bus, GstMessage * msg, PlayerData * data)
{ {
g_print ("Almost finished.\n"); g_print ("Almost finished.\n");
...@@ -541,7 +540,7 @@ aeos_cb (GstBus * bus, GstMessage * msg, CustomData * data) ...@@ -541,7 +540,7 @@ aeos_cb (GstBus * bus, GstMessage * msg, CustomData * data)
/* this function is called after source element is setup */ /* this function is called after source element is setup */
static void static void
source_cb (GstBus * bus, GstMessage * msg, CustomData * data) source_cb (GstBus * bus, GstMessage * msg, PlayerData * data)
{ {
g_print ("Source setup.\n"); g_print ("Source setup.\n");
...@@ -553,7 +552,7 @@ source_cb (GstBus * bus, GstMessage * msg, CustomData * data) ...@@ -553,7 +552,7 @@ source_cb (GstBus * bus, GstMessage * msg, CustomData * data)
/* This function is called when an End-Of-Stream message is posted on the bus. /* This function is called when an End-Of-Stream message is posted on the bus.
* We just set the pipeline to READY (which stops playback) */ * We just set the pipeline to READY (which stops playback) */
static void static void
eos_cb (GstBus * bus, GstMessage * msg, CustomData * data) eos_cb (GstBus * bus, GstMessage * msg, PlayerData * data)
{ {
g_print ("End-Of-Stream reached.\n"); g_print ("End-Of-Stream reached.\n");
gst_element_set_state (data->playbin2, GST_STATE_READY); gst_element_set_state (data->playbin2, GST_STATE_READY);
...@@ -569,7 +568,7 @@ eos_cb (GstBus * bus, GstMessage * msg, CustomData * data) ...@@ -569,7 +568,7 @@ eos_cb (GstBus * bus, GstMessage * msg, CustomData * data)
/* This function is called when the pipeline changes states. We use it to /* This function is called when the pipeline changes states. We use it to
* keep track of the current state. */ * keep track of the current state. */
static void static void
state_changed_cb (GstBus * bus, GstMessage * msg, CustomData * data) state_changed_cb (GstBus * bus, GstMessage * msg, PlayerData * data)
{ {
GstState old_state, new_state, pending_state; GstState old_state, new_state, pending_state;
gst_message_parse_state_changed (msg, &old_state, &new_state, gst_message_parse_state_changed (msg, &old_state, &new_state,
...@@ -686,7 +685,7 @@ state_changed_cb (GstBus * bus, GstMessage * msg, CustomData * data) ...@@ -686,7 +685,7 @@ state_changed_cb (GstBus * bus, GstMessage * msg, CustomData * data)
/* Extract metadata from all the streams and write it to the text widget in the GUI */ /* Extract metadata from all the streams and write it to the text widget in the GUI */
static void static void
analyze_streams (CustomData * data) analyze_streams (PlayerData * data)
{ {
gint i; gint i;
GstTagList *tags; GstTagList *tags;
...@@ -811,7 +810,7 @@ analyze_streams (CustomData * data) ...@@ -811,7 +810,7 @@ analyze_streams (CustomData * data)
/* This function is called when an "application" message is posted on the bus. /* This function is called when an "application" message is posted on the bus.
* Here we retrieve the message posted by the tags_cb callback */ * Here we retrieve the message posted by the tags_cb callback */
static void static void
application_cb (GstBus * bus, GstMessage * msg, CustomData * data) application_cb (GstBus * bus, GstMessage * msg, PlayerData * data)
{ {
/* with gst1 /* with gst1
* player-0.10.c: In function ‘application_cb’: * player-0.10.c: In function ‘application_cb’:
...@@ -837,15 +836,14 @@ static void init_media() ...@@ -837,15 +836,14 @@ static void init_media()
/* Initialize GStreamer */ /* Initialize GStreamer */
gst_init (NULL, NULL); gst_init (NULL, NULL);
/* Initialize our data structure */
memset (&globalData, 0, sizeof (globalData)); pData->duration = GST_CLOCK_TIME_NONE;
globalData.duration = GST_CLOCK_TIME_NONE;
/* Create the elements */ /* Create the elements */
#ifdef GST1 #ifdef GST1
globalData.playbin2 = gst_element_factory_make ("playbin", "playbin2"); pData->playbin2 = gst_element_factory_make ("playbin", "playbin2");
#else #else
globalData.playbin2 = gst_element_factory_make ("playbin2", "playbin2"); pData->playbin2 = gst_element_factory_make ("playbin2", "playbin2");
#endif #endif
...@@ -859,8 +857,8 @@ static void init_media() ...@@ -859,8 +857,8 @@ static void init_media()
xvimagesink = gst_element_factory_make("xvimagesink", "xvimagesink"); xvimagesink = gst_element_factory_make("xvimagesink", "xvimagesink");
gst_element_factory_make("xvimagesink", "xvimagesink"); gst_element_factory_make("xvimagesink", "xvimagesink");
/*set snowvideobin as sink */ /*set snowvideobin as sink */
g_object_set (globalData.playbin2, "video-sink", g_object_set (pData->playbin2, "video-sink",
create_teebin(xvimagesink, get_snowvideobin(feedname)), NULL); create_teebin(xvimagesink, get_snowvideobin(pData->snow)), NULL);
// g_object_set (globalData.playbin2, "video-sink", // g_object_set (globalData.playbin2, "video-sink",
// get_snowvideobin(feedname), NULL); // get_snowvideobin(feedname), NULL);
...@@ -868,8 +866,8 @@ static void init_media() ...@@ -868,8 +866,8 @@ static void init_media()
// create_teebin(xvimagesink, create_rtmpbin()), NULL); // create_teebin(xvimagesink, create_rtmpbin()), NULL);
/*set snowaudiobin as sink */ /*set snowaudiobin as sink */
g_object_set (globalData.playbin2, "audio-sink", g_object_set (pData->playbin2, "audio-sink",
get_snowaudiobin (feedname), NULL); get_snowaudiobin (pData->snow), NULL);
//audiosink = gst_element_factory_make ("jackaudiosink", "jackaudiosink"); //audiosink = gst_element_factory_make ("jackaudiosink", "jackaudiosink");
//g_object_set (globalData.playbin2, "audio-sink", audiosink, NULL); //g_object_set (globalData.playbin2, "audio-sink", audiosink, NULL);
//g_object_set (audiosink, "port-pattern", feedname, NULL); //g_object_set (audiosink, "port-pattern", feedname, NULL);
...@@ -884,8 +882,8 @@ static void init_media() ...@@ -884,8 +882,8 @@ static void init_media()
videosink = gst_element_factory_make ("xvimagesink", "xvimagesink"); videosink = gst_element_factory_make ("xvimagesink", "xvimagesink");
audiosink = gst_element_factory_make ("autoaudiosink", "autoaudiosink"); audiosink = gst_element_factory_make ("autoaudiosink", "autoaudiosink");
g_object_set (globalData.playbin2, "video-sink", videosink, NULL); g_object_set (pData->playbin2, "video-sink", videosink, NULL);
g_object_set (globalData.playbin2, "audio-sink", audiosink, NULL); g_object_set (pData->playbin2, "audio-sink", audiosink, NULL);
} }
...@@ -893,7 +891,7 @@ static void init_media() ...@@ -893,7 +891,7 @@ static void init_media()
g_print (" SNOWBIN is not defined (port it to gst1.0)"); g_print (" SNOWBIN is not defined (port it to gst1.0)");
#endif #endif
if (!globalData.playbin2) if (!pData->playbin2)
{ {
g_printerr ("Not all elements could be created.\n"); g_printerr ("Not all elements could be created.\n");
//return -1; //return -1;
...@@ -903,30 +901,30 @@ static void init_media() ...@@ -903,30 +901,30 @@ static void init_media()
//g_object_set (globalData.playbin2, "uri", "http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL); //g_object_set (globalData.playbin2, "uri", "http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL);
/* Connect to interesting signals in playbin2 */ /* Connect to interesting signals in playbin2 */
g_signal_connect (G_OBJECT (globalData.playbin2), "video-tags-changed", g_signal_connect (G_OBJECT (pData->playbin2), "video-tags-changed",
(GCallback) tags_cb, &globalData); (GCallback) tags_cb, pData);
g_signal_connect (G_OBJECT (globalData.playbin2), "audio-tags-changed", g_signal_connect (G_OBJECT (pData->playbin2), "audio-tags-changed",
(GCallback) tags_cb, &globalData); (GCallback) tags_cb, pData);
g_signal_connect (G_OBJECT (globalData.playbin2), "text-tags-changed", g_signal_connect (G_OBJECT (pData->playbin2), "text-tags-changed",
(GCallback) tags_cb, &globalData); (GCallback) tags_cb, pData);
g_signal_connect (G_OBJECT (globalData.playbin2), "about-to-finish", g_signal_connect (G_OBJECT (pData->playbin2), "about-to-finish",
(GCallback) aeos_cb, &globalData); (GCallback) aeos_cb, pData);
g_signal_connect (G_OBJECT (globalData.playbin2), "source-setup", g_signal_connect (G_OBJECT (pData->playbin2), "source-setup",
(GCallback) source_cb, &globalData); (GCallback) source_cb, pData);
/* Instruct the bus to emit signals for each received message, and connect to the interesting signals */ /* Instruct the bus to emit signals for each received message, and connect to the interesting signals */
bus = gst_element_get_bus (globalData.playbin2); bus = gst_element_get_bus (pData->playbin2);
gst_bus_add_signal_watch (bus); gst_bus_add_signal_watch (bus);
g_signal_connect (G_OBJECT (bus), "message::error", (GCallback) error_cb, g_signal_connect (G_OBJECT (bus), "message::error", (GCallback) error_cb,
&globalData); pData);
g_signal_connect (G_OBJECT (bus), "message::eos", (GCallback) eos_cb, g_signal_connect (G_OBJECT (bus), "message::eos", (GCallback) eos_cb,
&globalData); pData);
g_signal_connect (G_OBJECT (bus), "message::state-changed", g_signal_connect (G_OBJECT (bus), "message::state-changed",
(GCallback) state_changed_cb, &globalData); (GCallback) state_changed_cb, pData);
g_signal_connect (G_OBJECT (bus), "message::application", g_signal_connect (G_OBJECT (bus), "message::application",
(GCallback) application_cb, &globalData); (GCallback) application_cb, pData);
g_signal_connect (G_OBJECT (bus), "message::about-to-finish", g_signal_connect (G_OBJECT (bus), "message::about-to-finish",
(GCallback) application_cb, &globalData); (GCallback) application_cb, pData);
gst_object_unref (bus); gst_object_unref (bus);
...@@ -970,6 +968,12 @@ main (int argc, char *argv[]) ...@@ -970,6 +968,12 @@ main (int argc, char *argv[])
} //while } //while
/* Initialize our data structure */
//memset (&playerData, 0, sizeof (globalData));
pData = (PlayerData*)malloc(sizeof(struct PlayerData));
#ifdef GTK #ifdef GTK
#ifdef TT #ifdef TT
if( ! g_thread_supported() ) if( ! g_thread_supported() )
...@@ -981,21 +985,25 @@ main (int argc, char *argv[]) ...@@ -981,21 +985,25 @@ main (int argc, char *argv[])
/* Initialize GTK */ /* Initialize GTK */
gtk_init (&argc, &argv); gtk_init (&argc, &argv);
#endif #endif
/* initialize snowbin */
snowbin_init_snowData(pData);
/* initialize gstreamer */ /* initialize gstreamer */
init_media(); init_media();
/* Create the GUI */ /* Create the GUI */
#ifdef GTK #ifdef GTK
create_ui (&globalData); create_ui (pData);
#endif #endif
/* Register a function that GLib will call every second */ /* Register a function that GLib will call every second */
#ifdef GTK #ifdef GTK
g_timeout_add_seconds (1, (GSourceFunc)refresh_ui, &globalData); g_timeout_add_seconds (1, (GSourceFunc)refresh_ui, pData);
#endif #endif
/* register a function that will check all items in the playlist for availablitity */ /* register a function that will check all items in the playlist for availablitity */
// g_timeout_add_seconds (15, (GsourceFunc)playlist_refresh, &globalData); // g_timeout_add_seconds (15, (GsourceFunc)playlist_refresh, &pData);
/* Start the GTK main loop. We will not regain control until gtk_main_quit is called. */ /* Start the GTK main loop. We will not regain control until gtk_main_quit is called. */
#ifdef GTK #ifdef GTK
...@@ -1008,7 +1016,7 @@ init_media(); ...@@ -1008,7 +1016,7 @@ init_media();
printf("using this without gtk is on the todo list"); printf("using this without gtk is on the todo list");
#endif #endif
/* Free resources */ /* Free resources */
gst_element_set_state (globalData.playbin2, GST_STATE_NULL); gst_element_set_state (pData->playbin2, GST_STATE_NULL);
gst_object_unref (globalData.playbin2); gst_object_unref (pData->playbin2);
return 0; return 0;
} }
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#include <regex.h>
#include "switchs.h"
//glib stuff //glib stuff
//#include <glib.h> //#include <glib.h>
//#include <glib-2.0/glib/gprintf.h> //#include <glib-2.0/glib/gprintf.h>
...@@ -118,7 +119,8 @@ GtkWidget *loaded_label; ...@@ -118,7 +119,8 @@ GtkWidget *loaded_label;
gboolean playabool; gboolean playabool;
/* Structure to contain all our information, so we can pass it around */ /* Structure to contain all our information, so we can pass it around */
typedef struct _CustomData{ typedef struct PlayerData PlayerData;
struct PlayerData{
GstElement *playbin2; /* Our one and only pipeline */ GstElement *playbin2; /* Our one and only pipeline */
...@@ -130,14 +132,14 @@ typedef struct _CustomData{ ...@@ -130,14 +132,14 @@ typedef struct _CustomData{
GstState state; /* Current state of the pipeline */ GstState state; /* Current state of the pipeline */
gint64 duration; /* Duration of the clip, in nanoseconds */ gint64 duration; /* Duration of the clip, in nanoseconds */
} CustomData; snowData *snow;
};
CustomData globalData; //CustomData globalData;
CustomData *data; PlayerData *pData;
//CustomData *data;
GtkWidget *playlist_view; GtkWidget *playlist_view;
GtkWidget *playlist_box; GtkWidget *playlist_box;
#endif #endif
...@@ -8,8 +8,8 @@ port=9999 ...@@ -8,8 +8,8 @@ port=9999
ip=127.0.0.1 ip=127.0.0.1
# Set video feed # Set video feed
feed_id=1 feed_id=$1
audio_feed_id=1 audio_feed_id=$1
# Check for SM variable and the snowmix and gstreamer settings # Check for SM variable and the snowmix and gstreamer settings
if [ X$SM = X -o ! -f $SM/scripts/gstreamer-settings -o ! -f $SM/scripts/snowmix-settings ] ; then if [ X$SM = X -o ! -f $SM/scripts/gstreamer-settings -o ! -f $SM/scripts/snowmix-settings ] ; then
......