Commit d90ee5bf authored by David Schleef's avatar David Schleef
Browse files

Port from GstData to GstMiniObject.

Original commit message from CVS:
Port from GstData to GstMiniObject.
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_dispose):
* ext/ogg/gstoggmux.c: (gst_ogg_mux_buffer_from_page),
(gst_ogg_mux_queue_pads), (gst_ogg_mux_set_header_on_caps),
(gst_ogg_mux_collected):
* ext/ogg/gstogmparse.c: (gst_ogm_parse_chain):
* ext/theora/theoradec.c: (theora_handle_comment_packet),
(theora_handle_data_packet):
* ext/theora/theoraenc.c: (theora_buffer_from_packet),
(theora_set_header_on_caps), (theora_enc_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_sink_event),
(vorbis_handle_comment_packet):
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_set_header_on_caps):
* ext/vorbis/vorbisparse.c: (vorbis_parse_set_header_on_caps):
* gst-libs/gst/audio/gstaudiofilter.c: (gst_audiofilter_chain):
* gst-libs/gst/tag/gstvorbistag.c: (gst_vorbis_tag_chain):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_get_buffer):
* gst/playback/gstdecodebin.c: (gst_decode_bin_class_init):
* gst/playback/gstplaybasebin.c: (check_queue), (probe_triggered),
(mute_stream), (silence_stream):
* gst/playback/gstplaybin.c: (gst_play_bin_class_init):
* gst/volume/gstvolume.c: (volume_transform):
* sys/ximage/ximagesink.c: (gst_ximage_buffer_finalize),
(gst_ximage_buffer_init), (gst_ximage_buffer_class_init),
(gst_ximage_buffer_get_type), (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new), (gst_ximagesink_ximage_destroy),
(gst_ximagesink_ximage_put), (gst_ximagesink_imagepool_clear),
(gst_ximagesink_show_frame), (gst_ximagesink_buffer_free),
(gst_ximagesink_buffer_alloc):
* sys/ximage/ximagesink.h:
parent 4c7a8ba0
2005-05-16 David Schleef <ds@schleef.org>
Port from GstData to GstMiniObject.
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_dispose):
* ext/ogg/gstoggmux.c: (gst_ogg_mux_buffer_from_page),
(gst_ogg_mux_queue_pads), (gst_ogg_mux_set_header_on_caps),
(gst_ogg_mux_collected):
* ext/ogg/gstogmparse.c: (gst_ogm_parse_chain):
* ext/theora/theoradec.c: (theora_handle_comment_packet),
(theora_handle_data_packet):
* ext/theora/theoraenc.c: (theora_buffer_from_packet),
(theora_set_header_on_caps), (theora_enc_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_sink_event),
(vorbis_handle_comment_packet):
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_set_header_on_caps):
* ext/vorbis/vorbisparse.c: (vorbis_parse_set_header_on_caps):
* gst-libs/gst/audio/gstaudiofilter.c: (gst_audiofilter_chain):
* gst-libs/gst/tag/gstvorbistag.c: (gst_vorbis_tag_chain):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_get_buffer):
* gst/playback/gstdecodebin.c: (gst_decode_bin_class_init):
* gst/playback/gstplaybasebin.c: (check_queue), (probe_triggered),
(mute_stream), (silence_stream):
* gst/playback/gstplaybin.c: (gst_play_bin_class_init):
* gst/volume/gstvolume.c: (volume_transform):
* sys/ximage/ximagesink.c: (gst_ximage_buffer_finalize),
(gst_ximage_buffer_init), (gst_ximage_buffer_class_init),
(gst_ximage_buffer_get_type), (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new), (gst_ximagesink_ximage_destroy),
(gst_ximagesink_ximage_put), (gst_ximagesink_imagepool_clear),
(gst_ximagesink_show_frame), (gst_ximagesink_buffer_free),
(gst_ximagesink_buffer_alloc):
* sys/ximage/ximagesink.h:
2005-05-12 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init),
......
......@@ -274,7 +274,7 @@ gst_ogg_pad_dispose (GObject * object)
pad->chain = NULL;
pad->ogg = NULL;
g_list_foreach (pad->headers, (GFunc) gst_data_unref, NULL);
g_list_foreach (pad->headers, (GFunc) gst_mini_object_unref, NULL);
g_list_free (pad->headers);
pad->headers = NULL;
......
......@@ -485,7 +485,7 @@ gst_ogg_mux_buffer_from_page (GstOggMux * mux, ogg_page * page, gboolean delta)
mux->offset += GST_BUFFER_SIZE (buffer);
GST_BUFFER_OFFSET_END (buffer) = mux->offset;
if (delta)
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DELTA_UNIT);
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
return buffer;
}
......@@ -577,7 +577,7 @@ gst_ogg_mux_queue_pads (GstOggMux * ogg_mux)
buf = gst_collectpads_pop (ogg_mux->collect, data);
incaps = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_IN_CAPS);
incaps = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
/* if we need headers */
if (pad->state == GST_OGG_PAD_STATE_CONTROL) {
/* and we have one */
......@@ -682,7 +682,7 @@ gst_ogg_mux_set_header_on_caps (GstCaps * caps, GList * buffers)
walk = walk->next;
/* mark buffer */
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_IN_CAPS);
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
g_value_init (&value, GST_TYPE_BUFFER);
g_value_set_boxed (&value, buf);
......@@ -959,7 +959,7 @@ gst_ogg_mux_collected (GstCollectPads * pads, GstOggMux * ogg_mux)
/* now see if we have a buffer */
buf = pad->buffer;
delta_unit = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_DELTA_UNIT);
delta_unit = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
duration = GST_BUFFER_DURATION (buf);
/* create a packet from the buffer */
......
......@@ -667,7 +667,7 @@ gst_ogm_parse_chain (GstPad * pad, GstBuffer * buffer)
gint samples = (ogm->hdr.streamtype[0] == 'v') ? 1 : xsize;
if (!keyframe)
GST_BUFFER_FLAG_SET (sbuf, GST_BUFFER_DELTA_UNIT);
GST_BUFFER_FLAG_SET (sbuf, GST_BUFFER_FLAG_DELTA_UNIT);
GST_BUFFER_TIMESTAMP (sbuf) = (GST_SECOND / 10000000) *
ogm->next_granulepos * ogm->hdr.time_unit;
......
......@@ -634,7 +634,6 @@ theora_handle_comment_packet (GstTheoraDec * dec, ogg_packet * packet)
buf = gst_buffer_new_and_alloc (packet->bytes);
GST_BUFFER_DATA (buf) = packet->packet;
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
list =
gst_tag_list_from_vorbiscomment_buffer (buf, (guint8 *) "\201theora", 7,
......@@ -825,11 +824,11 @@ theora_handle_data_packet (GstTheoraDec * dec, ogg_packet * packet,
* offset or size is odd (see above).
*/
{
char *dest_y, *src_y;
char *dest_u, *src_u;
char *dest_v, *src_v;
guint8 *dest_y, *src_y;
guint8 *dest_u, *src_u;
guint8 *dest_v, *src_v;
dest_y = (char *) GST_BUFFER_DATA (out);
dest_y = (guint8 *) GST_BUFFER_DATA (out);
dest_u = dest_y + stride_y * height;
dest_v = dest_u + stride_uv * cheight;
......
......@@ -377,9 +377,9 @@ theora_buffer_from_packet (GstTheoraEnc * enc, ogg_packet * packet,
/* the second most significant bit of the first data byte is cleared
* for keyframes */
if ((packet->packet[0] & 0x40) == 0) {
GST_BUFFER_FLAG_UNSET (buf, GST_BUFFER_DELTA_UNIT);
GST_BUFFER_FLAG_UNSET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
} else {
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DELTA_UNIT);
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
}
enc->packetno++;
......@@ -425,9 +425,9 @@ theora_set_header_on_caps (GstCaps * caps, GstBuffer * buf1,
structure = gst_caps_get_structure (caps, 0);
/* mark buffers */
GST_BUFFER_FLAG_SET (buf1, GST_BUFFER_IN_CAPS);
GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_IN_CAPS);
GST_BUFFER_FLAG_SET (buf3, GST_BUFFER_IN_CAPS);
GST_BUFFER_FLAG_SET (buf1, GST_BUFFER_FLAG_IN_CAPS);
GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_FLAG_IN_CAPS);
GST_BUFFER_FLAG_SET (buf3, GST_BUFFER_FLAG_IN_CAPS);
/* put buffers in a fixed list */
g_value_init (&list, GST_TYPE_FIXED_LIST);
......@@ -546,15 +546,15 @@ theora_enc_chain (GstPad * pad, GstBuffer * buffer)
/* easy case, no cropping/conversion needed */
pixels = GST_BUFFER_DATA (buffer);
yuv.y = (char *) pixels;
yuv.y = (guint8 *) pixels;
yuv.u = yuv.y + y_size;
yuv.v = yuv.u + y_size / 4;
} else {
GstBuffer *newbuf;
gint i;
char *dest_y, *src_y;
char *dest_u, *src_u;
char *dest_v, *src_v;
guint8 *dest_y, *src_y;
guint8 *dest_u, *src_u;
guint8 *dest_v, *src_v;
gint src_y_stride, src_uv_stride;
gint dst_y_stride, dst_uv_stride;
gint width, height;
......@@ -579,11 +579,11 @@ theora_enc_chain (GstPad * pad, GstBuffer * buffer)
newbuf = gst_pad_alloc_buffer (enc->srcpad,
GST_BUFFER_OFFSET_NONE, y_size * 3 / 2, GST_PAD_CAPS (enc->srcpad));
dest_y = yuv.y = (char *) GST_BUFFER_DATA (newbuf);
dest_y = yuv.y = (guint8 *) GST_BUFFER_DATA (newbuf);
dest_u = yuv.u = yuv.y + y_size;
dest_v = yuv.v = yuv.u + y_size / 4;
src_y = (char *) GST_BUFFER_DATA (buffer);
src_y = (guint8 *) GST_BUFFER_DATA (buffer);
src_u = src_y + src_y_stride * ROUND_UP_2 (height);
src_v = src_u + src_uv_stride * ROUND_UP_2 (height) / 2;
......
......@@ -429,7 +429,7 @@ vorbis_dec_sink_event (GstPad * pad, GstEvent * event)
vorbis_synthesis_restart (&dec->vd);
#endif
}
gst_data_unref (GST_DATA (event));
gst_event_unref (event);
break;
default:
ret = gst_pad_event_default (dec->sinkpad, event);
......@@ -450,7 +450,6 @@ vorbis_handle_comment_packet (GstVorbisDec * vd, ogg_packet * packet)
buf = gst_buffer_new_and_alloc (packet->bytes);
GST_BUFFER_DATA (buf) = packet->packet;
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
list =
gst_tag_list_from_vorbiscomment_buffer (buf, (guint8 *) "\003vorbis", 7,
......
......@@ -795,9 +795,9 @@ gst_vorbisenc_set_header_on_caps (GstCaps * caps, GstBuffer * buf1,
structure = gst_caps_get_structure (caps, 0);
/* mark buffers */
GST_BUFFER_FLAG_SET (buf1, GST_BUFFER_IN_CAPS);
GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_IN_CAPS);
GST_BUFFER_FLAG_SET (buf3, GST_BUFFER_IN_CAPS);
GST_BUFFER_FLAG_SET (buf1, GST_BUFFER_FLAG_IN_CAPS);
GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_FLAG_IN_CAPS);
GST_BUFFER_FLAG_SET (buf3, GST_BUFFER_FLAG_IN_CAPS);
/* put buffers in a fixed list */
g_value_init (&list, GST_TYPE_FIXED_LIST);
......
......@@ -121,9 +121,9 @@ vorbis_parse_set_header_on_caps (GstVorbisParse * parse, GstCaps * caps)
structure = gst_caps_get_structure (caps, 0);
/* mark buffers */
GST_BUFFER_FLAG_SET (buf1, GST_BUFFER_IN_CAPS);
GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_IN_CAPS);
GST_BUFFER_FLAG_SET (buf3, GST_BUFFER_IN_CAPS);
GST_BUFFER_FLAG_SET (buf1, GST_BUFFER_FLAG_IN_CAPS);
GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_FLAG_IN_CAPS);
GST_BUFFER_FLAG_SET (buf3, GST_BUFFER_FLAG_IN_CAPS);
/* put buffers in a fixed list */
g_value_init (&list, GST_TYPE_FIXED_LIST);
......
......@@ -222,7 +222,7 @@ gst_audiofilter_chain (GstPad * pad, GstBuffer * buffer)
audiofilter->size = GST_BUFFER_SIZE (inbuf);
audiofilter->n_samples = audiofilter->size / audiofilter->bytes_per_sample;
if (gst_data_is_writable (GST_DATA (buffer))) {
if (gst_buffer_is_writable (buffer)) {
if (audiofilter_class->filter_inplace) {
(audiofilter_class->filter_inplace) (audiofilter, inbuf);
outbuf = inbuf;
......
......@@ -618,7 +618,7 @@ gst_vorbis_tag_chain (GstPad * pad, GstBuffer * buffer)
7, &vendor);
const GstTagList *found_tags;
gst_data_unref (GST_DATA (buffer));
gst_buffer_unref (buffer);
if (list == NULL) {
GST_ELEMENT_ERROR (tag, CORE, TAG, (NULL),
("invalid data in vorbis comments"));
......@@ -640,7 +640,7 @@ gst_vorbis_tag_chain (GstPad * pad, GstBuffer * buffer)
if (tag->output == OUTPUT_DATA) {
gst_pad_push (tag->srcpad, out);
} else {
gst_data_unref (GST_DATA (out));
gst_buffer_unref (out);
}
return GST_FLOW_OK;
}
......
......@@ -647,21 +647,20 @@ gst_audio_convert_get_buffer (GstBuffer * buf, guint size)
g_assert (GST_IS_BUFFER (buf));
GST_LOG
("new buffer of size %u requested. Current is: data: %p - size: %u - maxsize: %u",
size, buf->data, buf->size, buf->maxsize);
if (buf->maxsize >= size && gst_buffer_is_writable (buf)) {
("new buffer of size %u requested. Current is: data: %p - size: %u",
size, buf->data, buf->size);
if (buf->size >= size && gst_buffer_is_writable (buf)) {
gst_buffer_ref (buf);
buf->size = size;
GST_LOG
("returning same buffer with adjusted values. data: %p - size: %u - maxsize: %u",
buf->data, buf->size, buf->maxsize);
("returning same buffer with adjusted values. data: %p - size: %u",
buf->data, buf->size);
return buf;
} else {
ret = gst_buffer_new_and_alloc (size);
g_assert (ret);
//gst_buffer_stamp (ret, buf);
GST_LOG ("returning new buffer. data: %p - size: %u - maxsize: %u",
ret->data, ret->size, ret->maxsize);
GST_LOG ("returning new buffer. data: %p - size: %u", ret->data, ret->size);
return ret;
}
}
......
......@@ -205,8 +205,8 @@ gst_decode_bin_class_init (GstDecodeBinClass * klass)
gst_decode_bin_signals[SIGNAL_UNKNOWN_TYPE] =
g_signal_new ("unknown-type", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDecodeBinClass, unknown_type),
NULL, NULL, gst_marshal_VOID__OBJECT_BOXED, G_TYPE_NONE, 2,
GST_TYPE_PAD, GST_TYPE_CAPS);
NULL, NULL, gst_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2,
GST_TYPE_PAD, GST_TYPE_MINI_OBJECT);
gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_decode_bin_dispose);
......
......@@ -69,7 +69,7 @@ const GList *gst_play_base_bin_get_streaminfo (GstPlayBaseBin * play_base_bin);
static gboolean prepare_output (GstPlayBaseBin * play_base_bin);
static void set_active_source (GstPlayBaseBin * play_base_bin,
GstStreamType type, gint source_num);
static gboolean probe_triggered (GstProbe * probe, GstData ** data,
static gboolean probe_triggered (GstProbe * probe, GstMiniObject ** data,
gpointer user_data);
static void setup_substreams (GstPlayBaseBin * play_base_bin);
......@@ -446,7 +446,7 @@ fill_buffer (GstPlayBaseBin * play_base_bin, gint percent)
}
static gboolean
check_queue (GstProbe * probe, GstData ** data, gpointer user_data)
check_queue (GstProbe * probe, GstMiniObject ** data, gpointer user_data)
{
GstElement *queue = GST_ELEMENT (user_data);
GstPlayBaseBin *play_base_bin = g_object_get_data (G_OBJECT (queue), "pbb");
......@@ -758,7 +758,7 @@ no_more_pads (GstElement * element, GstPlayBaseBin * play_base_bin)
}
static gboolean
probe_triggered (GstProbe * probe, GstData ** data, gpointer user_data)
probe_triggered (GstProbe * probe, GstMiniObject ** data, gpointer user_data)
{
GstPlayBaseGroup *group;
GstPlayBaseBin *play_base_bin;
......@@ -869,7 +869,7 @@ preroll_unlinked (GstPad * pad, GstPad * peerpad,
/* Mute stream on first data - for header-is-in-stream-stuff
* (vorbis, ogmtext). */
static gboolean
mute_stream (GstProbe * probe, GstData ** d, gpointer data)
mute_stream (GstProbe * probe, GstMiniObject ** d, gpointer data)
{
GstStreamInfo *info = GST_STREAM_INFO (data);
......@@ -885,7 +885,7 @@ mute_stream (GstProbe * probe, GstData ** d, gpointer data)
/* Eat data. */
static gboolean
silence_stream (GstProbe * probe, GstData ** d, gpointer data)
silence_stream (GstProbe * probe, GstMiniObject ** d, gpointer data)
{
/* no data */
return FALSE;
......
......@@ -174,7 +174,7 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
g_param_spec_double ("volume", "volume", "volume",
0.0, VOLUME_MAX_DOUBLE, 1.0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_FRAME,
g_param_spec_boxed ("frame", "Frame",
gst_param_spec_mini_object ("frame", "Frame",
"The last frame (NULL = no video available)",
GST_TYPE_BUFFER, G_PARAM_READABLE));
g_object_class_install_property (gobject_klass, ARG_FONT_DESC,
......
......@@ -346,7 +346,7 @@ volume_transform (GstBaseTransform * base, GstBuffer * inbuf,
}
}
*outbuf = gst_buffer_copy_on_write (gst_buffer_ref (inbuf));
*outbuf = gst_buffer_make_writable (gst_buffer_ref (inbuf));
filter->process (filter, GST_BUFFER_TIMESTAMP (*outbuf),
GST_BUFFER_DATA (*outbuf), GST_BUFFER_SIZE (*outbuf));
......
......@@ -45,9 +45,9 @@ MotifWmHints, MwmHints;
#define MWM_HINTS_DECORATIONS (1L << 1)
static void gst_ximagesink_buffer_free (GstBuffer * buffer);
//static void gst_ximagesink_buffer_free (GstBuffer * buffer);
static void gst_ximagesink_ximage_destroy (GstXImageSink * ximagesink,
GstXImage * ximage);
GstXImageBuffer * ximage);
#if 0
static void gst_ximagesink_send_pending_navigation (GstXImageSink * ximagesink);
#endif
......@@ -88,6 +88,96 @@ static gboolean error_caught = FALSE;
/* */
/* ============================================================= */
/* ximage buffers */
#define GST_TYPE_XIMAGE_BUFFER (gst_ximage_buffer_get_type())
#define GST_IS_XIMAGE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XIMAGE_BUFFER))
#define GST_XIMAGE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XIMAGE_BUFFER, GstXImageBuffer))
static void
gst_ximage_buffer_finalize (GstXImageBuffer * ximage_buffer)
{
GstXImageSink *ximagesink;
g_return_if_fail (ximage_buffer != NULL);
if (ximage_buffer->ximagesink == NULL) {
return;
}
ximagesink = ximage_buffer->ximagesink;
/* If the destroyed image is the current one we destroy our reference too */
if (ximagesink->cur_image == ximage_buffer)
ximagesink->cur_image = NULL;
g_mutex_lock (ximagesink->x_lock);
#ifdef HAVE_XSHM
if (ximagesink->xcontext->use_xshm) {
if (ximage_buffer->SHMInfo.shmaddr != ((void *) -1)) {
XShmDetach (ximagesink->xcontext->disp, &ximage_buffer->SHMInfo);
XSync (ximagesink->xcontext->disp, 0);
shmdt (ximage_buffer->SHMInfo.shmaddr);
}
if (ximage_buffer->SHMInfo.shmid > 0)
shmctl (ximage_buffer->SHMInfo.shmid, IPC_RMID, 0);
if (ximage_buffer->ximage)
XDestroyImage (ximage_buffer->ximage);
} else
#endif /* HAVE_XSHM */
{
if (ximage_buffer->ximage) {
XDestroyImage (ximage_buffer->ximage);
}
}
XSync (ximagesink->xcontext->disp, FALSE);
g_mutex_unlock (ximagesink->x_lock);
}
static void
gst_ximage_buffer_init (GTypeInstance * instance, gpointer g_class)
{
}
static void
gst_ximage_buffer_class_init (gpointer g_class, gpointer class_data)
{
GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
gst_ximage_buffer_finalize;
}
GType
gst_ximage_buffer_get_type (void)
{
static GType _gst_ximage_buffer_type;
if (G_UNLIKELY (_gst_ximage_buffer_type == 0)) {
static const GTypeInfo ximage_buffer_info = {
sizeof (GstBufferClass),
NULL,
NULL,
gst_ximage_buffer_class_init,
NULL,
NULL,
sizeof (GstXImageBuffer),
0,
gst_ximage_buffer_init,
NULL
};
_gst_ximage_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
"GstXImageBuffer", &ximage_buffer_info, 0);
}
return _gst_ximage_buffer_type;
}
/* X11 stuff */
static int
......@@ -109,13 +199,13 @@ gst_ximagesink_check_xshm_calls (GstXContext * xcontext)
#ifndef HAVE_XSHM
return FALSE;
#else
GstXImage *ximage = NULL;
GstXImageBuffer *ximage = NULL;
int (*handler) (Display *, XErrorEvent *);
gboolean result = FALSE;
g_return_val_if_fail (xcontext != NULL, FALSE);
ximage = g_new0 (GstXImage, 1);
ximage = (GstXImageBuffer *) gst_mini_object_new (GST_TYPE_XIMAGE_BUFFER);
g_return_val_if_fail (ximage != NULL, FALSE);
/* Setting an error handler to catch failure */
......@@ -170,25 +260,25 @@ gst_ximagesink_check_xshm_calls (GstXContext * xcontext)
beach:
XSetErrorHandler (handler);
if (ximage->ximage)
XFree (ximage->ximage);
g_free (ximage);
gst_buffer_unref (GST_BUFFER (ximage));
XSync (xcontext->disp, FALSE);
return result;
#endif /* HAVE_XSHM */
}
/* This function handles GstXImage creation depending on XShm availability */
static GstXImage *
/* This function handles GstXImageBuffer creation depending on XShm availability */
static GstXImageBuffer *
gst_ximagesink_ximage_new (GstXImageSink * ximagesink, gint width, gint height)
{
GstXImage *ximage = NULL;
GstXImageBuffer *ximage = NULL;
gboolean succeeded = FALSE;
g_return_val_if_fail (GST_IS_XIMAGESINK (ximagesink), NULL);
GST_DEBUG_OBJECT (ximagesink, "creating %dx%d", width, height);
ximage = g_new0 (GstXImage, 1);
ximage = (GstXImageBuffer *) gst_mini_object_new (GST_TYPE_XIMAGE_BUFFER);
ximage->width = width;
ximage->height = height;
......@@ -263,16 +353,17 @@ gst_ximagesink_ximage_new (GstXImageSink * ximagesink, gint width, gint height)
beach:
if (!succeeded) {
gst_ximagesink_ximage_destroy (ximagesink, ximage);
gst_buffer_unref (GST_BUFFER (ximage));
ximage = NULL;
}
return ximage;
}
/* This function destroys a GstXImage handling XShm availability */
/* This function destroys a GstXImageBuffer handling XShm availability */
static void
gst_ximagesink_ximage_destroy (GstXImageSink * ximagesink, GstXImage * ximage)
gst_ximagesink_ximage_destroy (GstXImageSink * ximagesink,
GstXImageBuffer * ximage)
{
g_return_if_fail (ximage != NULL);
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
......@@ -310,9 +401,9 @@ gst_ximagesink_ximage_destroy (GstXImageSink * ximagesink, GstXImage * ximage)
g_free (ximage);
}
/* This function puts a GstXImage on a GstXImageSink's window */
/* This function puts a GstXImageBuffer on a GstXImageSink's window */
static void
gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstXImage * ximage)
gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstXImageBuffer * ximage)
{
gint x, y;
gint w, h;
......@@ -887,7 +978,7 @@ gst_ximagesink_imagepool_clear (GstXImageSink * ximagesink)
g_mutex_lock (ximagesink->pool_lock);
while (ximagesink->image_pool) {
GstXImage *ximage = ximagesink->image_pool->data;
GstXImageBuffer *ximage = ximagesink->image_pool->data;
ximagesink->image_pool = g_slist_delete_link (ximagesink->image_pool,
ximagesink->image_pool);
......@@ -1133,9 +1224,9 @@ gst_ximagesink_show_frame (GstBaseSink * bsink, GstBuffer * buf)
/* If this buffer has been allocated using our buffer management we simply
put the ximage which is in the PRIVATE pointer */
if (GST_BUFFER_FREE_DATA_FUNC (buf) == gst_ximagesink_buffer_free) {
if (GST_IS_XIMAGE_BUFFER (buf)) {
GST_LOG_OBJECT (ximagesink, "buffer from our pool, writing directly");
gst_ximagesink_ximage_put (ximagesink, GST_BUFFER_PRIVATE (buf));
gst_ximagesink_ximage_put (ximagesink, GST_XIMAGE_BUFFER (buf));
} else {
/* Else we have to copy the data into our private image, */
/* if we have one... */
......@@ -1171,11 +1262,12 @@ gst_ximagesink_show_frame (GstBaseSink * bsink, GstBuffer * buf)
/* Buffer management */
#if 0
static void
gst_ximagesink_buffer_free (GstBuffer * buffer)
{
GstXImageSink *ximagesink;
GstXImage *ximage;
GstXImageBuffer *ximage;
ximage = GST_BUFFER_PRIVATE (buffer);
......@@ -1193,14 +1285,14 @@ gst_ximagesink_buffer_free (GstBuffer * buffer)
g_mutex_unlock (ximagesink->pool_lock);
}
}
#endif
static GstBuffer *
gst_ximagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
GstCaps * caps)
{
GstXImageSink *ximagesink;
GstBuffer *buffer;
GstXImage *ximage = NULL;
GstXImageBuffer *ximage = NULL;
gboolean not_found = TRUE;
ximagesink = GST_XIMAGESINK (bsink);
......@@ -1246,18 +1338,7 @@ gst_ximagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size,
GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
}
if (ximage) {
buffer = gst_buffer_new ();
/* Storing some pointers in the buffer */
GST_BUFFER_PRIVATE (buffer) = ximage;
GST_BUFFER_DATA (buffer) = (guchar *) ximage->ximage->data;
GST_BUFFER_FREE_DATA_FUNC (buffer) = gst_ximagesink_buffer_free;
GST_BUFFER_SIZE (buffer) = ximage->size;
return buffer;
} else
return NULL;
return GST_BUFFER (ximage);
}
/* Interfaces stuff */
......
......@@ -53,7 +53,9 @@ G_BEGIN_DECLS
<