Added a size event to optimize buffer sizes make filesrc update its blocksize when it receives a size event

Original commit message from CVS:
Added a size event to optimize buffer sizes
make filesrc update its blocksize when it receives a size event
This commit is contained in:
Wim Taymans 2002-06-13 22:27:40 +00:00
parent 319a6a3672
commit 9286f126e2
4 changed files with 37 additions and 0 deletions

View file

@ -727,6 +727,13 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
src->seek_happened = TRUE;
src->need_flush = GST_EVENT_SEEK_FLAGS(event) & GST_SEEK_FLAG_FLUSH;
break;
case GST_EVENT_SIZE:
if (GST_EVENT_SIZE_FORMAT (event) != GST_FORMAT_BYTES) {
return FALSE;
}
src->block_size = GST_EVENT_SIZE_VALUE (event);
g_object_notify (G_OBJECT (src), "blocksize");
break;
case GST_EVENT_FLUSH:
src->need_flush = TRUE;
break;

View file

@ -235,5 +235,17 @@ gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 *value)
}
GstEvent*
gst_event_new_size (GstFormat format, gint64 value)
{
GstEvent *event;
event = gst_event_new (GST_EVENT_SIZE);
GST_EVENT_SIZE_FORMAT (event) = format;
GST_EVENT_SIZE_VALUE (event) = value;
return event;
}

View file

@ -41,6 +41,7 @@ typedef enum {
GST_EVENT_QOS,
GST_EVENT_SEEK,
GST_EVENT_FILLER,
GST_EVENT_SIZE,
} GstEventType;
extern GType _gst_event_type;
@ -93,6 +94,9 @@ typedef struct
#define GST_EVENT_DISCONT_OFFSET(event,i) (GST_EVENT(event)->event_data.discont.offsets[i])
#define GST_EVENT_DISCONT_OFFSET_LEN(event) (GST_EVENT(event)->event_data.discont.noffsets)
#define GST_EVENT_SIZE_FORMAT(event) (GST_EVENT(event)->event_data.size.format)
#define GST_EVENT_SIZE_VALUE(event) (GST_EVENT(event)->event_data.size.value)
struct _GstEvent {
GstData data;
@ -111,6 +115,10 @@ struct _GstEvent {
gint noffsets;
gboolean new_media;
} discont;
struct {
GstFormat format;
gint64 value;
} size;
} event_data;
};
@ -123,6 +131,9 @@ void gst_event_free (GstEvent *event);
/* seek event */
GstEvent* gst_event_new_seek (GstSeekType type, gint64 offset);
/* size events */
GstEvent* gst_event_new_size (GstFormat format, gint64 value);
/* discontinous event */
GstEvent* gst_event_new_discontinuous (gboolean new_media,
GstFormat format1, ...);

View file

@ -727,6 +727,13 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
src->seek_happened = TRUE;
src->need_flush = GST_EVENT_SEEK_FLAGS(event) & GST_SEEK_FLAG_FLUSH;
break;
case GST_EVENT_SIZE:
if (GST_EVENT_SIZE_FORMAT (event) != GST_FORMAT_BYTES) {
return FALSE;
}
src->block_size = GST_EVENT_SIZE_VALUE (event);
g_object_notify (G_OBJECT (src), "blocksize");
break;
case GST_EVENT_FLUSH:
src->need_flush = TRUE;
break;