examples/gstplay/player.c: Adding some new lines in g_print calls.

Original commit message from CVS:
* examples/gstplay/player.c: (got_time_tick), (got_stream_length),
(got_video_size): Adding some new lines in g_print calls.
* sys/ximage/ximagesink.c: (gst_ximagesink_xwindow_new),
(gst_ximagesink_xwindow_destroy), (gst_ximagesink_xwindow_resize),
(gst_ximagesink_handle_xevents), (gst_ximagesink_fixate),
(gst_ximagesink_sinkconnect), (gst_ximagesink_change_state),
(gst_ximagesink_chain), (gst_ximagesink_buffer_new),
(gst_ximagesink_set_xwindow_id), (gst_ximagesink_get_desired_size):
Complete code review, reverting some stuff i disagree with, adding
some fixes : time synchronization on invalid timestamps, renegotiation
of private window.
* sys/ximage/ximagesink.h:
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_xwindow_destroy),
(gst_xvimagesink_xwindow_resize), (gst_xvimagesink_handle_xevents),
(gst_xvimagesink_get_xv_support), (gst_xvimagesink_xcontext_get),
(gst_xvimagesink_fixate), (gst_xvimagesink_sinkconnect),
(gst_xvimagesink_change_state), (gst_xvimagesink_chain),
(gst_xvimagesink_buffer_new),
(gst_xvimagesink_navigation_send_event),
(gst_xvimagesink_set_xwindow_id),
(gst_xvimagesink_get_desired_size),
(gst_xvimagesink_xoverlay_init): Complete code review, reverting some
stuff i disagree with, adding some fixes : Renegotiation of private
window, implementing get_desired_size.
This commit is contained in:
Julien Moutte 2004-01-07 15:33:42 +00:00
parent 37ee652c46
commit 07b37e4c6d
6 changed files with 283 additions and 157 deletions

View file

@ -1,3 +1,30 @@
2004-01-07 Julien MOUTTE,,, <julien@moutte.net>
* examples/gstplay/player.c: (got_time_tick), (got_stream_length),
(got_video_size): Adding some new lines in g_print calls.
* sys/ximage/ximagesink.c: (gst_ximagesink_xwindow_new),
(gst_ximagesink_xwindow_destroy), (gst_ximagesink_xwindow_resize),
(gst_ximagesink_handle_xevents), (gst_ximagesink_fixate),
(gst_ximagesink_sinkconnect), (gst_ximagesink_change_state),
(gst_ximagesink_chain), (gst_ximagesink_buffer_new),
(gst_ximagesink_set_xwindow_id), (gst_ximagesink_get_desired_size):
Complete code review, reverting some stuff i disagree with, adding
some fixes : time synchronization on invalid timestamps, renegotiation
of private window.
* sys/ximage/ximagesink.h:
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_xwindow_destroy),
(gst_xvimagesink_xwindow_resize), (gst_xvimagesink_handle_xevents),
(gst_xvimagesink_get_xv_support), (gst_xvimagesink_xcontext_get),
(gst_xvimagesink_fixate), (gst_xvimagesink_sinkconnect),
(gst_xvimagesink_change_state), (gst_xvimagesink_chain),
(gst_xvimagesink_buffer_new),
(gst_xvimagesink_navigation_send_event),
(gst_xvimagesink_set_xwindow_id),
(gst_xvimagesink_get_desired_size),
(gst_xvimagesink_xoverlay_init): Complete code review, reverting some
stuff i disagree with, adding some fixes : Renegotiation of private
window, implementing get_desired_size.
2004-01-07 Ronald Bultje <rbultje@ronald.bitfreak.net> 2004-01-07 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/audiofile/gstafsink.c: (gst_afsink_init), (gst_afsink_chain), * ext/audiofile/gstafsink.c: (gst_afsink_init), (gst_afsink_chain),

View file

@ -58,20 +58,20 @@ got_found_tag (GstPlay *play,GstElement *source, GstTagList *tag_list)
static void static void
got_time_tick (GstPlay *play, gint64 time_nanos) got_time_tick (GstPlay *play, gint64 time_nanos)
{ {
g_print ("time tick %llu", time_nanos); g_print ("time tick %llu\n", time_nanos);
} }
static void static void
got_stream_length (GstPlay *play, gint64 length_nanos) got_stream_length (GstPlay *play, gint64 length_nanos)
{ {
g_print ("got length %llu", length_nanos); g_print ("got length %llu\n", length_nanos);
length = length_nanos; length = length_nanos;
} }
static void static void
got_video_size (GstPlay *play, gint width, gint height) got_video_size (GstPlay *play, gint width, gint height)
{ {
g_print ("got video size %d, %d", width, height); g_print ("got video size %d, %d\n", width, height);
} }
static void static void

View file

@ -216,19 +216,17 @@ gst_ximagesink_xwindow_new (GstXImageSink *ximagesink, gint width, gint height)
xwindow->width = width; xwindow->width = width;
xwindow->height = height; xwindow->height = height;
xwindow->internal = TRUE;
g_mutex_lock (ximagesink->x_lock); g_mutex_lock (ximagesink->x_lock);
if (ximagesink->embed_into == 0) {
xwindow->win = XCreateSimpleWindow (ximagesink->xcontext->disp, xwindow->win = XCreateSimpleWindow (ximagesink->xcontext->disp,
ximagesink->xcontext->root, ximagesink->xcontext->root,
0, 0, xwindow->width, xwindow->height, 0, 0, xwindow->width, xwindow->height,
0, 0, ximagesink->xcontext->black); 0, 0, ximagesink->xcontext->black);
XMapRaised (ximagesink->xcontext->disp, xwindow->win); XMapRaised (ximagesink->xcontext->disp, xwindow->win);
} else {
xwindow->win = ximagesink->embed_into;
}
XSelectInput (ximagesink->xcontext->disp, xwindow->win, ExposureMask | XSelectInput (ximagesink->xcontext->disp, xwindow->win, ExposureMask |
StructureNotifyMask | PointerMotionMask | KeyPressMask | StructureNotifyMask | PointerMotionMask | KeyPressMask |
KeyReleaseMask | ButtonPressMask | ButtonReleaseMask); KeyReleaseMask | ButtonPressMask | ButtonReleaseMask);
@ -236,7 +234,6 @@ gst_ximagesink_xwindow_new (GstXImageSink *ximagesink, gint width, gint height)
xwindow->gc = XCreateGC (ximagesink->xcontext->disp, xwindow->gc = XCreateGC (ximagesink->xcontext->disp,
xwindow->win, 0, NULL); xwindow->win, 0, NULL);
g_mutex_unlock (ximagesink->x_lock); g_mutex_unlock (ximagesink->x_lock);
return xwindow; return xwindow;
@ -253,11 +250,10 @@ gst_ximagesink_xwindow_destroy (GstXImageSink *ximagesink, GstXWindow *xwindow)
g_mutex_lock (ximagesink->x_lock); g_mutex_lock (ximagesink->x_lock);
/* If we did not create that window we just free the GC and let it live */ /* If we did not create that window we just free the GC and let it live */
if (ximagesink->embed_into == 0) { if (xwindow->internal)
XDestroyWindow (ximagesink->xcontext->disp, xwindow->win); XDestroyWindow (ximagesink->xcontext->disp, xwindow->win);
} else { else
XSelectInput (ximagesink->xcontext->disp, xwindow->win, 0); XSelectInput (ximagesink->xcontext->disp, xwindow->win, 0);
}
XFreeGC (ximagesink->xcontext->disp, xwindow->gc); XFreeGC (ximagesink->xcontext->disp, xwindow->gc);
@ -266,6 +262,26 @@ gst_ximagesink_xwindow_destroy (GstXImageSink *ximagesink, GstXWindow *xwindow)
g_free (xwindow); g_free (xwindow);
} }
/* This function resizes a GstXWindow */
static void
gst_ximagesink_xwindow_resize (GstXImageSink *ximagesink, GstXWindow *xwindow,
guint width, guint height)
{
g_return_if_fail (xwindow != NULL);
g_return_if_fail (ximagesink != NULL);
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
g_mutex_lock (ximagesink->x_lock);
xwindow->width = width;
xwindow->height = height;
XResizeWindow (ximagesink->xcontext->disp, xwindow->win,
xwindow->width, xwindow->height);
g_mutex_unlock (ximagesink->x_lock);
}
/* This function handles XEvents that might be in the queue. It generates /* This function handles XEvents that might be in the queue. It generates
GstEvent that will be sent upstream in the pipeline to handle interactivity GstEvent that will be sent upstream in the pipeline to handle interactivity
and navigation. It will also listen for configure events on the window to and navigation. It will also listen for configure events on the window to
@ -352,11 +368,12 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
GST_DEBUG ("ximagesink pointer moved over window at %d,%d", GST_DEBUG ("ximagesink pointer moved over window at %d,%d",
e.xmotion.x, e.xmotion.y); e.xmotion.x, e.xmotion.y);
gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink), gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
"mouse-move", "mouse-move", 0,
0,
e.xmotion.x, e.xmotion.y); e.xmotion.x, e.xmotion.y);
break; break;
case ButtonPress: case ButtonPress:
/* Mouse button pressed/released over our window. We send upstream
events for interactivity/navigation */
GST_DEBUG ("ximagesink button %d pressed over window at %d,%d", GST_DEBUG ("ximagesink button %d pressed over window at %d,%d",
e.xbutton.button, e.xbutton.x, e.xbutton.x); e.xbutton.button, e.xbutton.x, e.xbutton.x);
gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink), gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
@ -365,8 +382,6 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
e.xbutton.x, e.xbutton.y); e.xbutton.x, e.xbutton.y);
break; break;
case ButtonRelease: case ButtonRelease:
/* Mouse button pressed/released over our window. We send upstream
events for interactivity/navigation */
GST_DEBUG ("ximagesink button %d release over window at %d,%d", GST_DEBUG ("ximagesink button %d release over window at %d,%d",
e.xbutton.button, e.xbutton.x, e.xbutton.x); e.xbutton.button, e.xbutton.x, e.xbutton.x);
gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink), gst_navigation_send_mouse_event (GST_NAVIGATION (ximagesink),
@ -389,7 +404,6 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
XKeysymToString (keysym)); XKeysymToString (keysym));
} }
else { else {
/* FIXME : What's that ? */
gst_navigation_send_key_event (GST_NAVIGATION (ximagesink), gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
e.type == KeyPress ? e.type == KeyPress ?
"key-press" : "key-release", "key-press" : "key-release",
@ -614,10 +628,12 @@ gst_ximagesink_sinkconnect (GstPad *pad, const GstCaps *caps)
GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_WIDTH (ximagesink),
GST_VIDEOSINK_HEIGHT (ximagesink)); GST_VIDEOSINK_HEIGHT (ximagesink));
else else
XResizeWindow (ximagesink->xcontext->disp, {
ximagesink->xwindow->win, if (ximagesink->xwindow->internal)
gst_ximagesink_xwindow_resize (ximagesink, ximagesink->xwindow,
GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_WIDTH (ximagesink),
GST_VIDEOSINK_HEIGHT (ximagesink)); GST_VIDEOSINK_HEIGHT (ximagesink));
}
if ( (ximagesink->ximage) && if ( (ximagesink->ximage) &&
( (GST_VIDEOSINK_WIDTH (ximagesink) != ximagesink->ximage->width) || ( (GST_VIDEOSINK_WIDTH (ximagesink) != ximagesink->ximage->width) ||
@ -660,12 +676,14 @@ gst_ximagesink_change_state (GstElement *element)
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
break; break;
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
ximagesink->time = 0;
break; break;
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
break; break;
case GST_STATE_PLAYING_TO_PAUSED: case GST_STATE_PLAYING_TO_PAUSED:
break; break;
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
ximagesink->framerate = 0;
GST_VIDEOSINK_WIDTH (ximagesink) = 0; GST_VIDEOSINK_WIDTH (ximagesink) = 0;
GST_VIDEOSINK_HEIGHT (ximagesink) = 0; GST_VIDEOSINK_HEIGHT (ximagesink) = 0;
break; break;
@ -680,10 +698,9 @@ gst_ximagesink_change_state (GstElement *element)
} }
static void static void
gst_ximagesink_chain (GstPad *pad, GstData *_data) gst_ximagesink_chain (GstPad *pad, GstData *data)
{ {
GstBuffer *buf = GST_BUFFER (_data); GstBuffer *buf = GST_BUFFER (data);
GstClockTime time = GST_BUFFER_TIMESTAMP (buf);
GstXImageSink *ximagesink; GstXImageSink *ximagesink;
g_return_if_fail (pad != NULL); g_return_if_fail (pad != NULL);
@ -692,9 +709,9 @@ gst_ximagesink_chain (GstPad *pad, GstData *_data)
ximagesink = GST_XIMAGESINK (gst_pad_get_parent (pad)); ximagesink = GST_XIMAGESINK (gst_pad_get_parent (pad));
if (GST_IS_EVENT (buf)) if (GST_IS_EVENT (data))
{ {
GstEvent *event = GST_EVENT (buf); GstEvent *event = GST_EVENT (data);
gint64 offset; gint64 offset;
switch (GST_EVENT_TYPE (event)) switch (GST_EVENT_TYPE (event))
@ -711,11 +728,17 @@ gst_ximagesink_chain (GstPad *pad, GstData *_data)
return; return;
} }
GST_DEBUG ("videosink: clock wait: %" G_GUINT64_FORMAT, time); buf = GST_BUFFER (data);
/* update time */
if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
ximagesink->time = GST_BUFFER_TIMESTAMP (buf);
}
GST_DEBUG ("videosink: clock wait: %" G_GUINT64_FORMAT, ximagesink->time);
if (GST_VIDEOSINK_CLOCK (ximagesink)) { if (GST_VIDEOSINK_CLOCK (ximagesink)) {
GstClockID id; GstClockID id;
id = gst_clock_new_single_shot_id (GST_VIDEOSINK_CLOCK (ximagesink), time); id = gst_clock_new_single_shot_id (GST_VIDEOSINK_CLOCK (ximagesink),
ximagesink->time);
gst_element_clock_wait (GST_ELEMENT (ximagesink), id, NULL); gst_element_clock_wait (GST_ELEMENT (ximagesink), id, NULL);
gst_clock_id_free (id); gst_clock_id_free (id);
} }
@ -744,6 +767,10 @@ gst_ximagesink_chain (GstPad *pad, GstData *_data)
#if 0 #if 0
} }
#endif #endif
/* set correct time for next buffer */
if (!GST_BUFFER_TIMESTAMP_IS_VALID (buf) && ximagesink->framerate > 0) {
ximagesink->time += GST_SECOND / ximagesink->framerate;
}
gst_buffer_unref (buf); gst_buffer_unref (buf);
@ -910,17 +937,14 @@ static void
gst_ximagesink_set_xwindow_id (GstXOverlay *overlay, XID xwindow_id) gst_ximagesink_set_xwindow_id (GstXOverlay *overlay, XID xwindow_id)
{ {
GstXImageSink *ximagesink = GST_XIMAGESINK (overlay); GstXImageSink *ximagesink = GST_XIMAGESINK (overlay);
GstXWindow *xwindow = NULL;
XWindowAttributes attr;
g_return_if_fail (ximagesink != NULL); g_return_if_fail (ximagesink != NULL);
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink)); g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
if (ximagesink->embed_into == xwindow_id)
return;
if (!ximagesink->xcontext) if (!ximagesink->xcontext)
{
ximagesink->xcontext = gst_ximagesink_xcontext_get (ximagesink); ximagesink->xcontext = gst_ximagesink_xcontext_get (ximagesink);
}
if ( (ximagesink->xwindow) && (ximagesink->ximage) ) if ( (ximagesink->xwindow) && (ximagesink->ximage) )
{ /* If we are replacing a window we destroy pictures and window as they { /* If we are replacing a window we destroy pictures and window as they
@ -930,16 +954,30 @@ gst_ximagesink_set_xwindow_id (GstXOverlay *overlay, XID xwindow_id)
gst_ximagesink_xwindow_destroy (ximagesink, ximagesink->xwindow); gst_ximagesink_xwindow_destroy (ximagesink, ximagesink->xwindow);
} }
ximagesink->embed_into = xwindow_id; xwindow = g_new0 (GstXWindow, 1);
ximagesink->xwindow = gst_ximagesink_xwindow_new (ximagesink, GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink)); xwindow->win = xwindow_id;
ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink)); /* We get window geometry, set the event we want to receive, and create a GC */
gst_x_overlay_got_xwindow_id (overlay, xwindow_id); g_mutex_lock (ximagesink->x_lock);
XGetWindowAttributes (ximagesink->xcontext->disp, xwindow->win, &attr);
xwindow->width = attr.width;
xwindow->height = attr.height;
xwindow->internal = FALSE;
XSelectInput (ximagesink->xcontext->disp, xwindow->win, ExposureMask |
StructureNotifyMask | PointerMotionMask | KeyPressMask |
KeyReleaseMask);
xwindow->gc = XCreateGC (ximagesink->xcontext->disp,
xwindow->win, 0, NULL);
g_mutex_unlock (ximagesink->x_lock);
ximagesink->xwindow = xwindow;
} }
static void static void
gst_ximagesink_get_desired_size (GstXOverlay *overlay, guint *width, guint *height) gst_ximagesink_get_desired_size (GstXOverlay *overlay,
guint *width, guint *height)
{ {
GstXImageSink *ximagesink = GST_XIMAGESINK (overlay); GstXImageSink *ximagesink = GST_XIMAGESINK (overlay);

View file

@ -83,6 +83,7 @@ struct _GstXContext {
struct _GstXWindow { struct _GstXWindow {
Window win; Window win;
gint width, height; gint width, height;
gboolean internal;
GC gc; GC gc;
}; };
@ -102,8 +103,6 @@ struct _GstXImageSink {
/* Our element stuff */ /* Our element stuff */
GstVideoSink videosink; GstVideoSink videosink;
XID embed_into;
GstXContext *xcontext; GstXContext *xcontext;
GstXWindow *xwindow; GstXWindow *xwindow;
GstXImage *ximage; GstXImage *ximage;
@ -114,6 +113,8 @@ struct _GstXImageSink {
/* Unused */ /* Unused */
gint pixel_width, pixel_height; gint pixel_width, pixel_height;
GstClockTime time;
GMutex *pool_lock; GMutex *pool_lock;
GSList *image_pool; GSList *image_pool;
}; };

View file

@ -263,6 +263,8 @@ gst_xvimagesink_xwindow_destroy (GstXvImageSink *xvimagesink, GstXWindow *xwindo
/* If we did not create that window we just free the GC and let it live */ /* If we did not create that window we just free the GC and let it live */
if (xwindow->internal) if (xwindow->internal)
XDestroyWindow (xvimagesink->xcontext->disp, xwindow->win); XDestroyWindow (xvimagesink->xcontext->disp, xwindow->win);
else
XSelectInput (xvimagesink->xcontext->disp, xwindow->win, 0);
XFreeGC (xvimagesink->xcontext->disp, xwindow->gc); XFreeGC (xvimagesink->xcontext->disp, xwindow->gc);
@ -271,6 +273,26 @@ gst_xvimagesink_xwindow_destroy (GstXvImageSink *xvimagesink, GstXWindow *xwindo
g_free (xwindow); g_free (xwindow);
} }
/* This function resizes a GstXWindow */
static void
gst_xvimagesink_xwindow_resize (GstXvImageSink *xvimagesink,
GstXWindow *xwindow, guint width, guint height)
{
g_return_if_fail (xwindow != NULL);
g_return_if_fail (xvimagesink != NULL);
g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
g_mutex_lock (xvimagesink->x_lock);
xwindow->width = width;
xwindow->height = height;
XResizeWindow (xvimagesink->xcontext->disp, xwindow->win,
xwindow->width, xwindow->height);
g_mutex_unlock (xvimagesink->x_lock);
}
/* This function handles XEvents that might be in the queue. It generates /* This function handles XEvents that might be in the queue. It generates
GstEvent that will be sent upstream in the pipeline to handle interactivity GstEvent that will be sent upstream in the pipeline to handle interactivity
and navigation. It will also listen for configure events on the window to and navigation. It will also listen for configure events on the window to
@ -301,7 +323,7 @@ gst_xvimagesink_handle_xevents (GstXvImageSink *xvimagesink, GstPad *pad)
{ {
case ConfigureNotify: case ConfigureNotify:
/* Window got resized or moved. We update our data. */ /* Window got resized or moved. We update our data. */
GST_DEBUG ("ximagesink window is at %d, %d with geometry : %d,%d", GST_DEBUG ("xvimagesink window is at %d, %d with geometry : %d,%d",
e.xconfigure.x, e.xconfigure.y, e.xconfigure.x, e.xconfigure.y,
e.xconfigure.width, e.xconfigure.height); e.xconfigure.width, e.xconfigure.height);
xvimagesink->xwindow->width = e.xconfigure.width; xvimagesink->xwindow->width = e.xconfigure.width;
@ -366,6 +388,9 @@ gst_xvimagesink_handle_xevents (GstXvImageSink *xvimagesink, GstPad *pad)
g_mutex_unlock (xvimagesink->x_lock); g_mutex_unlock (xvimagesink->x_lock);
} }
/* This function generates a caps with all supported format by the first
Xv grabable port we find. We store each one of the supported formats in a
format list and append the format to a newly created caps that we return */
static GstCaps * static GstCaps *
gst_xvimagesink_get_xv_support (GstXContext *xcontext) gst_xvimagesink_get_xv_support (GstXContext *xcontext)
{ {
@ -564,12 +589,18 @@ gst_xvimagesink_xcontext_get (GstXvImageSink *xvimagesink)
} }
#endif /* HAVE_XSHM */ #endif /* HAVE_XSHM */
if (xcontext->endianness == G_LITTLE_ENDIAN && xcontext->depth == 24) /* our caps system handles 24/32bpp RGB as big-endian. */
{ if ((xcontext->bpp == 24 || xcontext->bpp == 32) &&
xcontext->endianness == G_LITTLE_ENDIAN) {
xcontext->endianness = G_BIG_ENDIAN; xcontext->endianness = G_BIG_ENDIAN;
xcontext->visual->red_mask = GUINT32_SWAP_LE_BE (xcontext->visual->red_mask); xcontext->visual->red_mask = GUINT32_TO_BE (xcontext->visual->red_mask);
xcontext->visual->green_mask = GUINT32_SWAP_LE_BE (xcontext->visual->green_mask); xcontext->visual->green_mask = GUINT32_TO_BE (xcontext->visual->green_mask);
xcontext->visual->blue_mask = GUINT32_SWAP_LE_BE (xcontext->visual->blue_mask); xcontext->visual->blue_mask = GUINT32_TO_BE (xcontext->visual->blue_mask);
if (xcontext->bpp == 24) {
xcontext->visual->red_mask >>= 8;
xcontext->visual->green_mask >>= 8;
xcontext->visual->blue_mask >>= 8;
}
} }
xcontext->caps = gst_xvimagesink_get_xv_support (xcontext); xcontext->caps = gst_xvimagesink_get_xv_support (xcontext);
@ -652,6 +683,8 @@ gst_xvimagesink_fixate (GstPad *pad, const GstCaps *caps)
return NULL; return NULL;
} }
/* This function tries to get a format matching with a given caps in the
supported list of formats we generated in gst_xvimagesink_get_xv_support */
static gint static gint
gst_xvimagesink_get_fourcc_from_caps (GstXvImageSink *xvimagesink, gst_xvimagesink_get_fourcc_from_caps (GstXvImageSink *xvimagesink,
GstCaps *caps) GstCaps *caps)
@ -720,9 +753,12 @@ gst_xvimagesink_sinkconnect (GstPad *pad, const GstCaps *caps)
g_free (caps_str2); g_free (caps_str2);
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "width", &(GST_VIDEOSINK_WIDTH (xvimagesink))); ret = gst_structure_get_int (structure, "width",
ret &= gst_structure_get_int (structure, "height", &(GST_VIDEOSINK_HEIGHT (xvimagesink))); &(GST_VIDEOSINK_WIDTH (xvimagesink)));
ret &= gst_structure_get_double (structure, "framerate", &xvimagesink->framerate); ret &= gst_structure_get_int (structure, "height",
&(GST_VIDEOSINK_HEIGHT (xvimagesink)));
ret &= gst_structure_get_double (structure, "framerate",
&xvimagesink->framerate);
if (!ret) return GST_PAD_LINK_REFUSED; if (!ret) return GST_PAD_LINK_REFUSED;
xvimagesink->xcontext->im_format = 0; xvimagesink->xcontext->im_format = 0;
@ -739,13 +775,21 @@ gst_xvimagesink_sinkconnect (GstPad *pad, const GstCaps *caps)
gst_structure_get_int (structure, "pixel_width", &xvimagesink->pixel_width); gst_structure_get_int (structure, "pixel_width", &xvimagesink->pixel_width);
xvimagesink->pixel_height = 1; xvimagesink->pixel_height = 1;
gst_structure_get_int (structure, "pixel_height", &xvimagesink->pixel_height); gst_structure_get_int (structure, "pixel_height",
&xvimagesink->pixel_height);
/* Creating our window and our image */ /* Creating our window and our image */
if (!xvimagesink->xwindow) if (!xvimagesink->xwindow)
xvimagesink->xwindow = gst_xvimagesink_xwindow_new (xvimagesink, xvimagesink->xwindow = gst_xvimagesink_xwindow_new (xvimagesink,
GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_WIDTH (xvimagesink),
GST_VIDEOSINK_HEIGHT (xvimagesink)); GST_VIDEOSINK_HEIGHT (xvimagesink));
else
{
if (xvimagesink->xwindow->internal)
gst_xvimagesink_xwindow_resize (xvimagesink, xvimagesink->xwindow,
GST_VIDEOSINK_WIDTH (xvimagesink),
GST_VIDEOSINK_HEIGHT (xvimagesink));
}
if ( (xvimagesink->xvimage) && if ( (xvimagesink->xvimage) &&
( (GST_VIDEOSINK_WIDTH (xvimagesink) != xvimagesink->xvimage->width) || ( (GST_VIDEOSINK_WIDTH (xvimagesink) != xvimagesink->xvimage->width) ||
@ -762,6 +806,9 @@ gst_xvimagesink_sinkconnect (GstPad *pad, const GstCaps *caps)
GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_WIDTH (xvimagesink),
GST_VIDEOSINK_HEIGHT (xvimagesink)); GST_VIDEOSINK_HEIGHT (xvimagesink));
gst_x_overlay_got_desired_size (GST_X_OVERLAY (xvimagesink),
GST_VIDEOSINK_WIDTH (xvimagesink),
GST_VIDEOSINK_HEIGHT (xvimagesink));
gst_video_sink_got_video_size (GST_VIDEOSINK (xvimagesink), gst_video_sink_got_video_size (GST_VIDEOSINK (xvimagesink),
GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_WIDTH (xvimagesink),
GST_VIDEOSINK_HEIGHT (xvimagesink)); GST_VIDEOSINK_HEIGHT (xvimagesink));
@ -793,6 +840,8 @@ gst_xvimagesink_change_state (GstElement *element)
break; break;
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
xvimagesink->framerate = 0; xvimagesink->framerate = 0;
GST_VIDEOSINK_WIDTH (xvimagesink) = 0;
GST_VIDEOSINK_HEIGHT (xvimagesink) = 0;
break; break;
case GST_STATE_READY_TO_NULL: case GST_STATE_READY_TO_NULL:
break; break;
@ -844,7 +893,8 @@ gst_xvimagesink_chain (GstPad *pad, GstData *data)
if (GST_VIDEOSINK_CLOCK (xvimagesink)) { if (GST_VIDEOSINK_CLOCK (xvimagesink)) {
GstClockID id; GstClockID id;
id = gst_clock_new_single_shot_id (GST_VIDEOSINK_CLOCK (xvimagesink), xvimagesink->time); id = gst_clock_new_single_shot_id (GST_VIDEOSINK_CLOCK (xvimagesink),
xvimagesink->time);
gst_element_clock_wait (GST_ELEMENT (xvimagesink), id, NULL); gst_element_clock_wait (GST_ELEMENT (xvimagesink), id, NULL);
gst_clock_id_free (id); gst_clock_id_free (id);
} }
@ -1024,7 +1074,8 @@ gst_xvimagesink_navigation_send_event (GstNavigation *navigation,
gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, y, NULL); gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
} }
gst_pad_send_event (gst_pad_get_peer (GST_VIDEOSINK_PAD (xvimagesink)), event); gst_pad_send_event (gst_pad_get_peer (GST_VIDEOSINK_PAD (xvimagesink)),
event);
} }
static void static void
@ -1044,9 +1095,7 @@ gst_xvimagesink_set_xwindow_id (GstXOverlay *overlay, XID xwindow_id)
g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink)); g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
if (!xvimagesink->xcontext) if (!xvimagesink->xcontext)
{
xvimagesink->xcontext = gst_xvimagesink_xcontext_get (xvimagesink); xvimagesink->xcontext = gst_xvimagesink_xcontext_get (xvimagesink);
}
if ( (xvimagesink->xwindow) && (xvimagesink->xvimage) ) if ( (xvimagesink->xwindow) && (xvimagesink->xvimage) )
{ /* If we are replacing a window we destroy pictures and window as they { /* If we are replacing a window we destroy pictures and window as they
@ -1077,10 +1126,21 @@ gst_xvimagesink_set_xwindow_id (GstXOverlay *overlay, XID xwindow_id)
xvimagesink->xwindow = xwindow; xvimagesink->xwindow = xwindow;
} }
static void
gst_xvimagesink_get_desired_size (GstXOverlay *overlay,
guint *width, guint *height)
{
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (overlay);
*width = GST_VIDEOSINK_WIDTH (xvimagesink);
*height = GST_VIDEOSINK_HEIGHT (xvimagesink);
}
static void static void
gst_xvimagesink_xoverlay_init (GstXOverlayClass *iface) gst_xvimagesink_xoverlay_init (GstXOverlayClass *iface)
{ {
iface->set_xwindow_id = gst_xvimagesink_set_xwindow_id; iface->set_xwindow_id = gst_xvimagesink_set_xwindow_id;
iface->get_desired_size = gst_xvimagesink_get_desired_size;
} }
/* =========================================== */ /* =========================================== */

View file

@ -58,20 +58,20 @@ got_found_tag (GstPlay *play,GstElement *source, GstTagList *tag_list)
static void static void
got_time_tick (GstPlay *play, gint64 time_nanos) got_time_tick (GstPlay *play, gint64 time_nanos)
{ {
g_print ("time tick %llu", time_nanos); g_print ("time tick %llu\n", time_nanos);
} }
static void static void
got_stream_length (GstPlay *play, gint64 length_nanos) got_stream_length (GstPlay *play, gint64 length_nanos)
{ {
g_print ("got length %llu", length_nanos); g_print ("got length %llu\n", length_nanos);
length = length_nanos; length = length_nanos;
} }
static void static void
got_video_size (GstPlay *play, gint width, gint height) got_video_size (GstPlay *play, gint width, gint height)
{ {
g_print ("got video size %d, %d", width, height); g_print ("got video size %d, %d\n", width, height);
} }
static void static void