[gst-devel] sdlvideosink structure

Edgard Lima edgard.lima at indt.org.br
Tue Jun 6 20:20:02 CEST 2006


Hi Corent,

I'm still not sure how to do that. But I guess we have to change 
GST_VIDEO_SINK_HEIGHT/WIDTH in gstvideosink.c to something more clever 
like (in suppose) in xvimagesink and ximagesink. I ll have a look in it 
some day this week.

I you want to do it before (your personalized version - but clever than 
'explicit') I think you could send me it and I could comit it.

[]s
Edgard


ext Corentin BARON wrote:

> Hi,
>
> That's what I'm doing actually. What I'd like to do is get a direct 
> pointer to the SDL_Overlay in the structure of the element (but if 
> xvimagesink had worked on the Nokia 770 that'd have solved my 
> problem). My problem is that the video doesn't fit in my view. Maybe I 
> should make a personalized version of sdlvideosink with explicit 
> height / width parameters.
>
> Thx,
> Corentin.
>
> Le 6 juin 06 à 15:20, Edgard Lima a écrit :
>
>>
>> try the code attached code is attached
>>
>> unfortunatelly sdlvideosink (I have to try fix that) still doens't 
>> work 100% fine  :-(
>>
>> you can see how it works with 100% with ximagesink and xvimagesink 
>> insteadof sdlvideosink
>>
>> video_sink = gst_element_factory_make("sdlvideosink", NULL);
>>
>> gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(video_sink, 
>> GDK_WINDOW_XWINDOW(widgetGst->window));
>>
>> http://gstreamer.freedesktop.org/media/large/matrix.avi
>>
>> compile with
>>
>> gcc  -Wall `pkg-config --cflags --libs gstreamer-plugins-base-0.10` 
>> `pkg-config --cflags --libs gstreamer-0.10` `pkg-config --cflags 
>> --libs gstreamer-base-0.10`  `pkg-config --cflags --libs gtk+-2.0` 
>> /home/edlima/Projects/gstreamer/v0010/alex/gst-plugins-base-0.10.0/gst-libs/gst/interfaces/xoverlay.c 
>> seek.c
>>
>> btw: code is ugly but you can see how some things work.
>>
>> BR,
>> Edgard
>>
>>
>>
>>
>> ext Corentin BARON wrote:
>>
>>> Hello,
>>>
>>> Does anyone know how I could get a pointer to the SDL_Overlay stuff  
>>> in the sdlvideosink? That would be very useful.
>>>
>>> Thx,
>>> Corentin.
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> gstreamer-devel mailing list
>>> gstreamer-devel at lists.sourceforge.net 
>>> <mailto:gstreamer-devel at lists.sourceforge.net>
>>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>>
>>>  
>>>
>>
>> <babytux.png>
>> /*
>>  * Copyright (C) <2006> Edgard Lima <edgard.lima at indt.org.br 
>> <mailto:edgard.lima at indt.org.br>>
>>  *
>>  * License: do all you want with this code.
>>  */
>>
>>
>> #include <gtk/gtk.h>
>> #include <gdk/gdkx.h>
>> #include <gst/gst.h>
>> #include <gst/interfaces/xoverlay.h>
>>
>> GtkWindow *window; 
>> GtkWidget *box;
>> GtkWidget *widget;
>> GtkWidget *widgetGst;
>> GtkWidget *button; 
>> GtkWidget *hscale; 
>>
>> GstElement *pipeline;
>> GstElement *source;
>> GstElement *demuxer;
>>
>> GstElement *video_queue;
>> GstElement *video_dec;
>> GstElement *video_conv;
>> GstElement *video_scale;
>> GstElement *video_sink;
>>
>> GstElement *audio_queue;
>> GstElement *audio_dec;
>> GstElement *audio_conv;
>> GstElement *audio_sink;
>>
>> GMutex* mutex;
>> gboolean update_pos_flag = TRUE;
>>
>> gint64 duration;
>> gint64 position;
>>
>> static void
>> new_pad (GstElement *element,
>> GstPad     *pad,
>> gpointer    data)
>> {
>>   GstPad *sinkpad;
>>   gchar* name;
>>   /* We can now link this pad with the audio decoder */
>>   g_print ("Dynamic pad created, linking parser/decoder\n");
>>
>>   name = gst_pad_get_name(pad);
>>
>>   if ( name[0] == 'a' ) // audio_00
>>     sinkpad = gst_element_get_pad (audio_queue, "sink");
>>   else // video_00
>>     sinkpad = gst_element_get_pad (video_queue, "sink");
>>
>>   gst_pad_link (pad, sinkpad);
>>
>>   g_free(name);
>>   gst_object_unref (sinkpad);
>> }
>>
>> static gboolean
>> bus_call (GstBus     *bus, GstMessage *msg, gpointer    data)
>> {
>>
>>   printf("message from %s\n", GST_OBJECT_NAME(GST_MESSAGE_SRC(msg)));
>>
>>   switch (GST_MESSAGE_TYPE (msg)) {
>>   case GST_MESSAGE_EOS:
>>     printf ("End-of-stream\n");
>>     break;
>>   case GST_MESSAGE_ERROR: {
>>     gchar *debug;
>>     GError *err;
>>
>>     
>>
>>     gst_message_parse_error (msg, &err, &debug);
>>     g_free (debug);
>>
>>     
>>
>>     printf ("Error: %s\n", err->message);
>>     g_error_free (err);
>>
>>     
>>
>>
>>   }
>>     break;
>>   case GST_MESSAGE_STATE_CHANGED: {
>>     GstState oldstate;
>>     GstState newstate;
>>     GstState pending;
>>
>>     gst_message_parse_state_changed (msg,
>>     &oldstate,
>>     &newstate,
>>     &pending);
>>     /*
>>     printf("oldstate = %s, newstate = %s, pendingstate = %s",
>>   gst_element_state_get_name (oldstate),
>>   gst_element_state_get_name (newstate),
>>   gst_element_state_get_name (pending));
>>     */
>>
>>     if ( newstate == GST_STATE_PAUSED ) {
>>       GstFormat format = GST_FORMAT_TIME;
>>       gst_element_query_duration (pipeline, &format, &duration);
>>       gst_element_query_position (pipeline, &format, &position);
>>       printf("duration = %lld, position = %lld\n", duration, position);
>>       gtk_range_set_range((GtkRange*)hscale, 0, duration);
>>       gtk_range_set_value((GtkRange*)hscale, position);
>>     }
>>
>>
>>   }
>>     break;
>>   default:
>>     printf(gst_message_type_get_name (GST_MESSAGE_TYPE (msg)));
>>     printf("\n");
>>     break;
>>   }
>>
>>   printf("\n");
>>   fflush(stdout);
>>
>>   return TRUE;
>> }
>>
>> gboolean start_seek (GtkWidget *widget, GdkEventButton *event, 
>> gpointer user_data) {
>>   g_mutex_lock(mutex);
>>   update_pos_flag = FALSE;
>>   g_mutex_unlock(mutex);
>>   return FALSE;
>> }
>>
>> gboolean stop_seek (GtkWidget *widget, GdkEventButton *event, 
>> gpointer user_data) {
>>   g_mutex_lock(mutex);
>>   update_pos_flag = TRUE;
>>   g_mutex_unlock(mutex);
>>   return FALSE;
>> }
>>
>>
>> gboolean update_pos (gpointer data) {
>>   GstFormat format = GST_FORMAT_TIME;
>>
>>   g_mutex_lock(mutex);
>>   if ( ! update_pos_flag ) {
>>     g_mutex_unlock(mutex);
>>     return TRUE;
>>   }
>>   g_mutex_unlock(mutex);
>>
>>   gst_element_query_duration (pipeline, &format, &duration);
>>   gst_element_query_position (pipeline, &format, &position);
>>   printf("duration = %lld, position = %lld\n", duration, position);
>>   gtk_range_set_range((GtkRange*)hscale, 0, duration);
>>   gtk_range_set_value((GtkRange*)hscale, position);
>>   return TRUE;
>> }
>>
>> gboolean seek (GtkRange *range, GtkScrollType scroll, gdouble value, 
>> gpointer user_data) {
>>     printf("value = %lf\n", value);
>>     if ( scroll == GTK_SCROLL_JUMP ) {
>>       gst_element_seek(pipeline, 1.0, GST_FORMAT_TIME,
>>       GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
>>       GST_SEEK_TYPE_SET, value,
>>       GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
>>       return FALSE;
>>     }
>>     return TRUE;
>> }
>>
>> void change_null(GtkWidget *locwidget, gpointer data) 
>> { 
>>   gst_element_set_state (pipeline, GST_STATE_NULL);
>>   gtk_widget_hide(widgetGst);
>>   gtk_widget_show(widget);
>> }
>>
>> void change_ready(GtkWidget *locwidget, gpointer data) 
>> { 
>>   gst_element_set_state (pipeline, GST_STATE_READY);
>>   gtk_widget_hide(widgetGst);
>>   gtk_widget_show(widget);
>> }
>>
>> void change_paused(GtkWidget *locwidget, gpointer data) 
>> { 
>>   gtk_widget_hide(widget);
>>   gtk_widget_show(widgetGst);
>>   gst_element_set_state (pipeline, GST_STATE_PAUSED);
>> }
>>
>> void change_playing(GtkWidget *locwidget, gpointer data) 
>> { 
>>   gtk_widget_hide(widget);
>>   gtk_widget_show(widgetGst);
>>   gst_element_set_state (pipeline, GST_STATE_PLAYING);
>> }
>>
>>
>> gint delete_event(GtkWidget *widget, GdkEvent event, gpointer data) 
>> { 
>>   /* when this function returns FALSE, the delete-event 
>>      signal becomes a destroy signal */ 
>>   return FALSE; 
>> }
>>
>>  
>>
>> void end_program(GtkWidget *widget, gpointer data) 
>> { 
>>   /* End the main loop */
>>   printf ("Returned, stopping playback\n");  fflush(stdout);
>>   gst_element_set_state (pipeline, GST_STATE_NULL);
>>   gtk_main_quit(); 
>> } 
>>
>>
>> gboolean expose (GtkWidget *widget,
>> GdkEventExpose *event,
>> gpointer user_data)
>> {
>>   printf("expose1\n"); fflush(stdout);
>>   gst_x_overlay_set_xwindow_id (GST_X_OVERLAY(video_sink), 
>> GDK_WINDOW_XWINDOW(widgetGst->window));
>>   printf("expose2\n"); fflush(stdout);
>>   return TRUE;
>> }
>>
>> int main(int argc, char **argv) 
>> { 
>>
>>   /* Initialize GTK+ */ 
>>   gtk_init(&argc, &argv); 
>>   gst_init(&argc, &argv); 
>>   /* create window, set default height and width to 200 pixels */ 
>>
>>   window = g_object_new(GTK_TYPE_WINDOW, 
>>                         "default-height", 200, 
>>                         "default-width", 200, 
>>                         "border-width", 12, 
>>                         "title", "GtkHello", 
>>                         NULL); 
>>
>>   /* add signal handlers for window */ 
>>   g_signal_connect(window, 
>>                    "delete-event", G_CALLBACK(delete_event), 
>>                    NULL); 
>>   g_signal_connect(window, 
>>                    "destroy", G_CALLBACK(end_program), 
>>                    NULL); 
>>
>>   box = gtk_vbox_new(FALSE, 0);
>>
>>   widget = gtk_image_new_from_file("babytux.png");
>>   widgetGst = gtk_drawing_area_new();
>>   gtk_widget_set_size_request (widgetGst, 352, 288);
>>
>>   g_signal_connect(widgetGst, 
>>                    "expose-event", G_CALLBACK(expose), 
>>                    window);
>>
>>   gtk_box_pack_start (GTK_BOX(box), widget, FALSE, FALSE, 0);
>>   gtk_box_pack_start (GTK_BOX(box), widgetGst, FALSE, FALSE, 0);
>>   gtk_widget_hide(widgetGst);
>>
>>   /* create a button */ 
>>   button = gtk_button_new_with_label("state to null!");
>>   gtk_box_pack_end (GTK_BOX(box), button, FALSE, FALSE, 0);
>>   /* install signal handlers for button */ 
>>   g_signal_connect(button, 
>>                    "clicked", G_CALLBACK(change_null), 
>>                    window);
>>
>>
>>   /* create a button */ 
>>   button = gtk_button_new_with_label("state to ready!");
>>   gtk_box_pack_end (GTK_BOX(box), button, FALSE, FALSE, 0);
>>   /* install signal handlers for button */ 
>>   g_signal_connect(button, 
>>                    "clicked", G_CALLBACK(change_ready), 
>>                    window);
>>
>>   /* create a button */ 
>>   button = gtk_button_new_with_label("state to paused!");
>>   gtk_box_pack_end (GTK_BOX(box), button, FALSE, FALSE, 0);
>>   /* install signal handlers for button */ 
>>   g_signal_connect(button, 
>>                    "clicked", G_CALLBACK(change_paused), 
>>                    window);
>>
>>
>>   /* create a button */ 
>>   button = gtk_button_new_with_label("state to playing!");
>>   gtk_box_pack_end (GTK_BOX(box), button, FALSE, FALSE, 0);
>>   /* install signal handlers for button */ 
>>   g_signal_connect(button, 
>>                    "clicked", G_CALLBACK(change_playing), 
>>                    window);
>>
>>
>>   /* create a button */ 
>>   hscale = gtk_hscale_new_with_range(0.0, 100.0, 1);
>>   gtk_box_pack_end (GTK_BOX(box), hscale, FALSE, FALSE, 0);
>>   /* install signal handlers for button */ 
>>   g_signal_connect(hscale, 
>>                    "change-value", G_CALLBACK(seek), 
>>                    window);
>>   g_signal_connect(hscale, 
>>                    "button-press-event", G_CALLBACK(start_seek), 
>>                    window);
>>   g_signal_connect(hscale, 
>>                    "button-release-event", G_CALLBACK(stop_seek), 
>>                    window);
>>
>>   gtk_range_set_value((GtkRange*)hscale, 0.0);
>>
>>
>>   gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(box)); 
>>
>>   gtk_widget_show_all(GTK_WIDGET(window));
>>
>>   /* create elements */
>>   pipeline = gst_pipeline_new ("audio-player");
>>   source = gst_element_factory_make ("filesrc", NULL);
>>   demuxer = gst_element_factory_make ("avidemux", NULL);
>>
>>   video_queue = gst_element_factory_make ("queue", NULL);
>>   video_dec = gst_element_factory_make ("ffdec_msmpeg4", NULL);
>>   video_conv = gst_element_factory_make ("ffmpegcolorspace", NULL);
>>   video_scale = gst_element_factory_make ("videoscale", NULL);
>>   video_sink = gst_element_factory_make ("sdlvideosink", NULL);
>>
>>   audio_queue = gst_element_factory_make ("queue", NULL);
>>   audio_dec = gst_element_factory_make ("mad", NULL);
>>   audio_conv = gst_element_factory_make ("audioconvert", NULL);
>>   audio_sink = gst_element_factory_make ("alsasink", NULL);
>>
>>   
>>
>>
>>   if (!pipeline || !source || !demuxer ||
>>       !video_queue || !video_dec || !video_conv || !video_scale || 
>> !video_sink ||
>>       !audio_queue || !audio_dec || !audio_conv || !audio_sink )  {
>>     printf ("One element could not be created\n");
>>     return -1;
>>   }
>>
>>   /* set filename property on the file source. Also add a message
>>    * handler. */
>>   g_object_set (G_OBJECT (source), "location", "matrix.avi", NULL);  
>>   //g_object_set (G_OBJECT (scaler), "method", 1, NULL);  
>>   //  g_object_set (G_OBJECT (sink), "fullscreen", TRUE, NULL);  
>>   gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (pipeline)),
>>     bus_call, NULL);
>>
>>   /* put all elements in a bin */
>>   gst_bin_add_many (GST_BIN (pipeline),
>>     source, demuxer,
>>     video_queue, video_dec, video_conv, video_scale, video_sink,
>>     audio_queue, audio_dec, audio_conv, audio_sink, NULL);
>>
>>   /* link together - note that we cannot link the parser and
>>    * decoder yet, becuse the parser uses dynamic pads. For that,
>>    * we set a pad-added signal handler. */
>>   gst_element_link_many (source, demuxer, NULL);
>>   g_signal_connect (demuxer, "pad-added", G_CALLBACK (new_pad), NULL);
>>   gst_element_link_many (video_queue, video_dec, video_conv, 
>> video_scale, video_sink, NULL);
>>   gst_element_link_many (audio_queue, audio_dec, audio_conv, 
>> audio_sink, NULL);
>>
>>
>>   mutex = g_mutex_new();
>>
>>   g_timeout_add (100, update_pos, NULL);
>>
>>   printf ("Running\n"); fflush(stdout);
>>   gtk_main();
>>
>>   /* clean up nicely */
>>   printf ("Returned, stopping playback\n");  fflush(stdout);
>>   gst_element_set_state (pipeline, GST_STATE_NULL);
>>   printf ("Deleting pipeline\n");
>>   gst_object_unref (GST_OBJECT (pipeline));
>>
>>   g_mutex_free(mutex);  
>>
>>   return 0; 
>> }
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.sourceforge.net 
>> <mailto:gstreamer-devel at lists.sourceforge.net>
>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
> =
> ------------------------------------------------------------------------
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>gstreamer-devel mailing list
>gstreamer-devel at lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>





More information about the gstreamer-devel mailing list