gst/base/gstbasesrc.*: Make the newsegment event customizable by subclasses.

Original commit message from CVS:
* gst/base/gstbasesrc.c: (gst_base_src_class_init),
(gst_base_src_init), (gst_base_src_default_newsegment),
(gst_base_src_newsegment), (gst_base_src_do_seek),
(gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Make the newsegment event customizable by subclasses.
This commit is contained in:
Wim Taymans 2005-10-07 18:17:23 +00:00
parent c6ae655d0a
commit 5a74215411
5 changed files with 67 additions and 26 deletions

View file

@ -1,3 +1,12 @@
2005-10-07 Wim Taymans <wim@fluendo.com>
* gst/base/gstbasesrc.c: (gst_base_src_class_init),
(gst_base_src_init), (gst_base_src_default_newsegment),
(gst_base_src_newsegment), (gst_base_src_do_seek),
(gst_base_src_loop), (gst_base_src_start):
* gst/base/gstbasesrc.h:
Make the newsegment event customizable by subclasses.
2005-10-07 Wim Taymans <wim@fluendo.com>
* gst/gstevent.c: (gst_event_new_buffersize),

View file

@ -115,10 +115,8 @@ static gboolean gst_base_src_event_handler (GstPad * pad, GstEvent * event);
static gboolean gst_base_src_query (GstPad * pad, GstQuery * query);
#if 0
static const GstEventMask *gst_base_src_get_event_mask (GstPad * pad);
#endif
static gboolean gst_base_src_default_negotiate (GstBaseSrc * basesrc);
static gboolean gst_base_src_default_newsegment (GstBaseSrc * src);
static gboolean gst_base_src_unlock (GstBaseSrc * basesrc);
static gboolean gst_base_src_get_size (GstBaseSrc * basesrc, guint64 * size);
@ -168,6 +166,7 @@ gst_base_src_class_init (GstBaseSrcClass * klass)
GST_DEBUG_FUNCPTR (gst_base_src_change_state);
klass->negotiate = gst_base_src_default_negotiate;
klass->newsegment = gst_base_src_default_newsegment;
}
static void
@ -214,7 +213,7 @@ gst_base_src_init (GstBaseSrc * basesrc, gpointer g_class)
basesrc->segment_start = -1;
basesrc->segment_end = -1;
basesrc->need_discont = TRUE;
basesrc->need_newsegment = TRUE;
basesrc->blocksize = DEFAULT_BLOCKSIZE;
basesrc->clock_id = NULL;
@ -368,7 +367,7 @@ gst_base_src_query (GstPad * pad, GstQuery * query)
}
static gboolean
gst_base_src_send_discont (GstBaseSrc * src)
gst_base_src_default_newsegment (GstBaseSrc * src)
{
GstEvent *event;
@ -382,6 +381,20 @@ gst_base_src_send_discont (GstBaseSrc * src)
return gst_pad_push_event (src->srcpad, event);
}
static gboolean
gst_base_src_newsegment (GstBaseSrc * src)
{
GstBaseSrcClass *bclass;
gboolean result = FALSE;
bclass = GST_BASE_SRC_GET_CLASS (src);
if (bclass->newsegment)
result = bclass->newsegment (src);
return result;
}
static gboolean
gst_base_src_do_seek (GstBaseSrc * src, GstEvent * event)
{
@ -463,8 +476,8 @@ gst_base_src_do_seek (GstBaseSrc * src, GstEvent * event)
GST_DEBUG_OBJECT (src, "seek pending for segment from %" G_GINT64_FORMAT
" to %" G_GINT64_FORMAT, src->segment_start, src->segment_end);
/* now make sure the discont will be send */
src->need_discont = TRUE;
/* now make sure the newsegment will be send */
src->need_newsegment = TRUE;
/* and restart the task */
gst_pad_start_task (src->srcpad, (GstTaskFunction) gst_base_src_loop,
@ -681,10 +694,10 @@ gst_base_src_loop (GstPad * pad)
src = GST_BASE_SRC (GST_OBJECT_PARENT (pad));
if (src->need_discont) {
/* now send discont */
gst_base_src_send_discont (src);
src->need_discont = FALSE;
if (src->need_newsegment) {
/* now send newsegment */
gst_base_src_newsegment (src);
src->need_newsegment = FALSE;
}
ret = gst_base_src_get_range (pad, src->offset, src->blocksize, &buf);
@ -907,7 +920,7 @@ gst_base_src_start (GstBaseSrc * basesrc)
/* we always run to the end */
basesrc->segment_start = 0;
basesrc->segment_end = basesrc->size;
basesrc->need_discont = TRUE;
basesrc->need_newsegment = TRUE;
/* check if we can seek, updates ->seekable */
gst_base_src_is_seekable (basesrc);

View file

@ -97,7 +97,7 @@ struct _GstBaseSrc {
gint64 segment_start; /* start and end positions for seeking */
gint64 segment_end;
gboolean segment_loop;
gboolean need_discont;
gboolean need_newsegment;
guint64 offset; /* current offset in the resource */
guint64 size; /* total size of the resource */
@ -128,6 +128,9 @@ struct _GstBaseSrcClass {
/* decide on caps */
gboolean (*negotiate) (GstBaseSrc *src);
/* generate and send a newsegment */
gboolean (*newsegment) (GstBaseSrc *src);
/* start and stop processing, ideal for opening/closing the resource */
gboolean (*start) (GstBaseSrc *src);
gboolean (*stop) (GstBaseSrc *src);

View file

@ -115,10 +115,8 @@ static gboolean gst_base_src_event_handler (GstPad * pad, GstEvent * event);
static gboolean gst_base_src_query (GstPad * pad, GstQuery * query);
#if 0
static const GstEventMask *gst_base_src_get_event_mask (GstPad * pad);
#endif
static gboolean gst_base_src_default_negotiate (GstBaseSrc * basesrc);
static gboolean gst_base_src_default_newsegment (GstBaseSrc * src);
static gboolean gst_base_src_unlock (GstBaseSrc * basesrc);
static gboolean gst_base_src_get_size (GstBaseSrc * basesrc, guint64 * size);
@ -168,6 +166,7 @@ gst_base_src_class_init (GstBaseSrcClass * klass)
GST_DEBUG_FUNCPTR (gst_base_src_change_state);
klass->negotiate = gst_base_src_default_negotiate;
klass->newsegment = gst_base_src_default_newsegment;
}
static void
@ -214,7 +213,7 @@ gst_base_src_init (GstBaseSrc * basesrc, gpointer g_class)
basesrc->segment_start = -1;
basesrc->segment_end = -1;
basesrc->need_discont = TRUE;
basesrc->need_newsegment = TRUE;
basesrc->blocksize = DEFAULT_BLOCKSIZE;
basesrc->clock_id = NULL;
@ -368,7 +367,7 @@ gst_base_src_query (GstPad * pad, GstQuery * query)
}
static gboolean
gst_base_src_send_discont (GstBaseSrc * src)
gst_base_src_default_newsegment (GstBaseSrc * src)
{
GstEvent *event;
@ -382,6 +381,20 @@ gst_base_src_send_discont (GstBaseSrc * src)
return gst_pad_push_event (src->srcpad, event);
}
static gboolean
gst_base_src_newsegment (GstBaseSrc * src)
{
GstBaseSrcClass *bclass;
gboolean result = FALSE;
bclass = GST_BASE_SRC_GET_CLASS (src);
if (bclass->newsegment)
result = bclass->newsegment (src);
return result;
}
static gboolean
gst_base_src_do_seek (GstBaseSrc * src, GstEvent * event)
{
@ -463,8 +476,8 @@ gst_base_src_do_seek (GstBaseSrc * src, GstEvent * event)
GST_DEBUG_OBJECT (src, "seek pending for segment from %" G_GINT64_FORMAT
" to %" G_GINT64_FORMAT, src->segment_start, src->segment_end);
/* now make sure the discont will be send */
src->need_discont = TRUE;
/* now make sure the newsegment will be send */
src->need_newsegment = TRUE;
/* and restart the task */
gst_pad_start_task (src->srcpad, (GstTaskFunction) gst_base_src_loop,
@ -681,10 +694,10 @@ gst_base_src_loop (GstPad * pad)
src = GST_BASE_SRC (GST_OBJECT_PARENT (pad));
if (src->need_discont) {
/* now send discont */
gst_base_src_send_discont (src);
src->need_discont = FALSE;
if (src->need_newsegment) {
/* now send newsegment */
gst_base_src_newsegment (src);
src->need_newsegment = FALSE;
}
ret = gst_base_src_get_range (pad, src->offset, src->blocksize, &buf);
@ -907,7 +920,7 @@ gst_base_src_start (GstBaseSrc * basesrc)
/* we always run to the end */
basesrc->segment_start = 0;
basesrc->segment_end = basesrc->size;
basesrc->need_discont = TRUE;
basesrc->need_newsegment = TRUE;
/* check if we can seek, updates ->seekable */
gst_base_src_is_seekable (basesrc);

View file

@ -97,7 +97,7 @@ struct _GstBaseSrc {
gint64 segment_start; /* start and end positions for seeking */
gint64 segment_end;
gboolean segment_loop;
gboolean need_discont;
gboolean need_newsegment;
guint64 offset; /* current offset in the resource */
guint64 size; /* total size of the resource */
@ -128,6 +128,9 @@ struct _GstBaseSrcClass {
/* decide on caps */
gboolean (*negotiate) (GstBaseSrc *src);
/* generate and send a newsegment */
gboolean (*newsegment) (GstBaseSrc *src);
/* start and stop processing, ideal for opening/closing the resource */
gboolean (*start) (GstBaseSrc *src);
gboolean (*stop) (GstBaseSrc *src);