rendered paste bodystatic voidcb_newpad (GstElement *decodebin, GstPad *pad, gboolean last, gpointer data){ GstCaps *caps; GstStructure *str; GstPad *audiopad, *videopad; /* check media type */ caps = gst_pad_get_caps (pad); str = gst_caps_get_structure (caps, 0); printf("string = %s\n",gst_structure_get_name (str)); gchar *name = gst_structure_get_name (str); if (g_strrstr (name, "audio")) { /* only link once */ audiopad = gst_element_get_pad (audio, "sink"); if (GST_PAD_IS_LINKED (audiopad)) { g_object_unref (audiopad); return; } /* link'n'play */ gst_pad_link (pad, audiopad); // Link audiopad to pad or other way around, dunno gst_element_link (volume, dec); //Doesn't seem to work... volume_changed_callback (vol_scale, volume); //Change volume to default } if (g_strrstr (name, "video")) { // only link once videopad = gst_element_get_pad (video, "sink"); if (GST_PAD_IS_LINKED (videopad)) { g_object_unref (videopad); return; } gst_caps_unref (caps); // link'n'play gst_pad_link (pad, videopad); set_video_mode (TRUE); } gst_caps_unref (caps);}static void *playsong_real (void *ptr){ int a = 0; gchar *str; l = ptr; while (l) { Track *tr = l->data; g_return_val_if_fail(tr, (void*)-1);//printf("%d\n",a++); str = get_file_name_from_source(tr, SOURCE_PREFER_LOCAL);//printf("%d\n",a++); //printf("%d\n",a++); if (str) { //printf("%d\n",a++); gtk_label_set_text(GTK_LABEL (song_label), tr->title); // set label to title g_object_set_data (G_OBJECT (song_label), "tr_title", tr->title); // set label to title...again?wtf? gtk_widget_set_sensitive (vol_scale, TRUE); //set volume scale sensitivity to true /* init GStreamer */ loop = g_main_loop_new (NULL, FALSE); // make new loop /* setup */ pipeline = gst_pipeline_new ("pipeline"); //Create our pipeline volume = gst_element_factory_make ("volume", "volume"); // Create volume element bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); // get pipeline's bus gst_bus_add_watch (bus, my_bus_callback, loop); //Add a watch to the bus gst_object_unref (bus); //unref the bus src = gst_element_factory_make ("filesrc", "source"); //create the file source g_object_set (G_OBJECT (src), "location", str, NULL); //set location to the file location dec = gst_element_factory_make ("decodebin", "decoder"); //create our decodebin g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad), NULL); //signal to the new-decoded-pad(same as new-pad) gst_bin_add_many (GST_BIN (pipeline), src, dec, NULL); //add src and dec to pipeline gst_element_link (src, dec); //link src and dec together /* create audio output */ audio = gst_bin_new ("audiobin"); //create our audio bin conv = gst_element_factory_make ("audioconvert", "aconv"); //Create audioconvert element audiopad = gst_element_get_pad (conv, "sink"); //get the audioconvert pad sink = gst_element_factory_make ("alsasink", "sink"); //create our alsasink gst_bin_add_many (GST_BIN (audio), volume, conv, sink, NULL); //add volume, conv, and sink to audio gst_element_link (conv, sink); // link sink and conv gst_element_add_pad (audio, gst_ghost_pad_new ("sink", audiopad)); // add pad to audio...? gst_object_unref (audiopad); //unref audiopad gst_bin_add (GST_BIN (pipeline), audio); //add audio to pipeline /*create video output*/ video = gst_bin_new ("videobin"); //create videobin videoconv = gst_element_factory_make ("ffmpegcolorspace", "vconv"); //make ffmpegcolorspace videopad = gst_element_get_pad (videoconv, "sink"); //get videoconv pad videosink = gst_element_factory_make ("xvimagesink", "sink"); //create video sink g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL); //force aspect ratio gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), gdk_x11_drawable_get_xid (drawing_area->window)); //set the overlay to our drawing area gst_bin_add_many (GST_BIN (video),videoconv, videosink, NULL); //add videoconv and videosink to video gst_element_link (videoconv, videosink); //link videoconv and videosink gst_element_add_pad (video, gst_ghost_pad_new ("sink", videopad)); //add pad to video...? gst_object_unref (videopad); //unref videopad //gst_bin_add(GST_BIN (pipeline), video); //If file doesn't contain video, it crashes the program, so commented out /* Volume Control */ //volume_changed_callback (vol_scale, volume); g_signal_connect (vol_scale, "value-changed", G_CALLBACK (volume_changed_callback), volume); //connect volume-changed signal // gst_bin_add_many (GST_BIN (pipeline), src, dec, volume, audio, NULL); /* run */ gst_element_set_state (pipeline, GST_STATE_PLAYING);// set state g_timeout_add (250, (GSourceFunc) set_scale_range, GST_PIPELINE (pipeline)); g_timeout_add (1000, (GSourceFunc) set_scale_position, GST_PIPELINE (pipeline)); //g_timeout_add (500, (GSourceFunc) checkinfo, gst_pipeline_get_bus (GST_PIPELINE (pipeline))); g_main_loop_run (loop); /* cleanup */ gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (GST_OBJECT (pipeline)); #ifndef NEW_PIPE_PER_FILE /*if (GST_STATE_CHANGE_ASYNC == sret) { if (gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, GST_CLOCK_TIME_NONE) == GST_STATE_CHANGE_FAILURE) { g_print ("State change failed. Aborting"); break; } }*/ #endif if(pipeline != NULL) gst_object_unref (GST_OBJECT (pipeline)); g_main_loop_unref (loop); //START OLD! D:< } if (stopall) break; if (!prevbut) l = g_list_next(l); else prevbut = FALSE; } thread = NULL; stopall = FALSE; g_thread_exit (0); return (void*)-1;}