gst/elements/gstmultifilesrc.*: Added newmedia property so it generates newmedia events between each file when proper...

Original commit message from CVS:
2004-07-23  Zaheer Abbas Merali  <zaheerabbas at merali dot org>

* gst/elements/gstmultifilesrc.c: (gst_multifilesrc_class_init),
(gst_multifilesrc_init), (gst_multifilesrc_set_property),
(gst_multifilesrc_get_property), (gst_multifilesrc_get):
* gst/elements/gstmultifilesrc.h:
Added newmedia property so it generates newmedia events between each
file when property is set, as well as fixed eos handling
This commit is contained in:
Zaheer Abbas Merali 2004-07-23 13:09:27 +00:00
parent 4fa4267105
commit 13905b113e
5 changed files with 173 additions and 70 deletions

View file

@ -1,3 +1,12 @@
2004-07-23 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* gst/elements/gstmultifilesrc.c: (gst_multifilesrc_class_init),
(gst_multifilesrc_init), (gst_multifilesrc_set_property),
(gst_multifilesrc_get_property), (gst_multifilesrc_get):
* gst/elements/gstmultifilesrc.h:
Added newmedia property so it generates newmedia events between each
file when property is set, as well as fixed eos handling
2004-07-22 David Schleef <ds@schleef.org> 2004-07-22 David Schleef <ds@schleef.org>
* gst/gststructure.c: (gst_structure_id_empty_new), * gst/gststructure.c: (gst_structure_id_empty_new),

View file

@ -56,7 +56,8 @@ enum
enum enum
{ {
ARG_0, ARG_0,
ARG_LOCATIONS ARG_LOCATIONS,
ARG_HAVENEWMEDIA
}; };
#define _do_init(bla) \ #define _do_init(bla) \
@ -105,7 +106,13 @@ gst_multifilesrc_class_init (GstMultiFileSrcClass * klass)
G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL, G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL,
g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATIONS, g_param_spec_pointer ("locations", "locations", "locations", G_PARAM_READWRITE)); /* CHECKME */ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATIONS, g_param_spec_pointer ("locations", "locations", "locations", G_PARAM_READWRITE)); /* CHECKME */
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HAVENEWMEDIA,
g_param_spec_boolean ("newmedia", "newmedia",
"generate new media events?", FALSE, G_PARAM_READWRITE));
gobject_class->set_property = gst_multifilesrc_set_property; gobject_class->set_property = gst_multifilesrc_set_property;
gobject_class->get_property = gst_multifilesrc_get_property; gobject_class->get_property = gst_multifilesrc_get_property;
@ -129,6 +136,7 @@ gst_multifilesrc_init (GstMultiFileSrc * multifilesrc)
multifilesrc->size = 0; multifilesrc->size = 0;
multifilesrc->map = NULL; multifilesrc->map = NULL;
multifilesrc->new_seek = FALSE; multifilesrc->new_seek = FALSE;
multifilesrc->have_newmedia_events = FALSE;
} }
static void static void
@ -156,6 +164,9 @@ gst_multifilesrc_set_property (GObject * object, guint prop_id,
src->listptr = g_value_get_pointer (value); src->listptr = g_value_get_pointer (value);
} }
break; break;
case ARG_HAVENEWMEDIA:
src->have_newmedia_events = g_value_get_boolean (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -177,6 +188,9 @@ gst_multifilesrc_get_property (GObject * object, guint prop_id, GValue * value,
case ARG_LOCATIONS: case ARG_LOCATIONS:
g_value_set_pointer (value, src->listptr); g_value_set_pointer (value, src->listptr);
break; break;
case ARG_HAVENEWMEDIA:
g_value_set_boolean (value, src->have_newmedia_events);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -194,15 +208,24 @@ gst_multifilesrc_get (GstPad * pad)
{ {
GstMultiFileSrc *src; GstMultiFileSrc *src;
GstBuffer *buf; GstBuffer *buf;
GstEvent *newmedia;
GSList *list; GSList *list;
g_return_val_if_fail (pad != NULL, NULL); g_return_val_if_fail (pad != NULL, NULL);
src = GST_MULTIFILESRC (gst_pad_get_parent (pad)); src = GST_MULTIFILESRC (gst_pad_get_parent (pad));
GST_DEBUG ("curfileindex = %d newmedia flag = %s", src->curfileindex,
GST_FLAG_IS_SET (src, GST_MULTIFILESRC_NEWFILE) ? "true" : "false");
switch (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_NEWFILE)) {
case FALSE:
if (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN)) if (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN))
gst_multifilesrc_close_file (src); gst_multifilesrc_close_file (src);
if (!src->listptr) { if (!src->listptr) {
GST_DEBUG ("sending EOS event");
gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS)); return GST_DATA (gst_event_new (GST_EVENT_EOS));
} }
@ -212,10 +235,22 @@ gst_multifilesrc_get (GstPad * pad)
if (!gst_multifilesrc_open_file (src, pad)) if (!gst_multifilesrc_open_file (src, pad))
return NULL; return NULL;
src->curfileindex++;
/* emitted after the open, as the user may free the list and string from here */ /* emitted after the open, as the user may free the list and string from here */
g_signal_emit (G_OBJECT (src), gst_multifilesrc_signals[NEW_FILE], 0, list); g_signal_emit (G_OBJECT (src), gst_multifilesrc_signals[NEW_FILE], 0,
list);
if (src->have_newmedia_events) {
newmedia =
gst_event_new_discontinuous (TRUE, GST_FORMAT_TIME, (gint64) 0,
GST_FORMAT_UNDEFINED);
GST_FLAG_SET (src, GST_MULTIFILESRC_NEWFILE);
GST_DEBUG ("sending new media event");
return GST_DATA (newmedia);
}
default:
if (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_NEWFILE))
GST_FLAG_UNSET (src, GST_MULTIFILESRC_NEWFILE);
/* create the buffer */ /* create the buffer */
/* FIXME: should eventually use a bufferpool for this */ /* FIXME: should eventually use a bufferpool for this */
buf = gst_buffer_new (); buf = gst_buffer_new ();
@ -234,9 +269,15 @@ gst_multifilesrc_get (GstPad * pad)
} }
/* we're done, return the buffer */ /* we're done, return the buffer */
GST_DEBUG ("sending buffer");
return GST_DATA (buf); return GST_DATA (buf);
} }
/* should not reach here */
g_assert_not_reached ();
return NULL;
}
/* open the file and mmap it, necessary to go to READY state */ /* open the file and mmap it, necessary to go to READY state */
static gboolean static gboolean
gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad) gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad)

View file

@ -42,8 +42,9 @@ G_BEGIN_DECLS
typedef enum { typedef enum {
GST_MULTIFILESRC_OPEN = GST_ELEMENT_FLAG_LAST, GST_MULTIFILESRC_OPEN = GST_ELEMENT_FLAG_LAST,
GST_MULTIFILESRC_NEWFILE = GST_ELEMENT_FLAG_LAST + 2,
GST_MULTIFILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 GST_MULTIFILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 4
} GstMultiFileSrcFlags; } GstMultiFileSrcFlags;
typedef struct _GstMultiFileSrc GstMultiFileSrc; typedef struct _GstMultiFileSrc GstMultiFileSrc;
@ -63,6 +64,11 @@ struct _GstMultiFileSrc {
gulong size; /* how long is the file? */ gulong size; /* how long is the file? */
guchar *map; /* where the file is mapped to */ guchar *map; /* where the file is mapped to */
gint curfileindex; /* how many files have we done so far */
gboolean have_newmedia_events; /* tunable parameter to say whether new media
disconts should be generated */
gboolean new_seek; gboolean new_seek;
}; };

View file

@ -56,7 +56,8 @@ enum
enum enum
{ {
ARG_0, ARG_0,
ARG_LOCATIONS ARG_LOCATIONS,
ARG_HAVENEWMEDIA
}; };
#define _do_init(bla) \ #define _do_init(bla) \
@ -105,7 +106,13 @@ gst_multifilesrc_class_init (GstMultiFileSrcClass * klass)
G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL, G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL,
g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATIONS, g_param_spec_pointer ("locations", "locations", "locations", G_PARAM_READWRITE)); /* CHECKME */ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATIONS, g_param_spec_pointer ("locations", "locations", "locations", G_PARAM_READWRITE)); /* CHECKME */
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HAVENEWMEDIA,
g_param_spec_boolean ("newmedia", "newmedia",
"generate new media events?", FALSE, G_PARAM_READWRITE));
gobject_class->set_property = gst_multifilesrc_set_property; gobject_class->set_property = gst_multifilesrc_set_property;
gobject_class->get_property = gst_multifilesrc_get_property; gobject_class->get_property = gst_multifilesrc_get_property;
@ -129,6 +136,7 @@ gst_multifilesrc_init (GstMultiFileSrc * multifilesrc)
multifilesrc->size = 0; multifilesrc->size = 0;
multifilesrc->map = NULL; multifilesrc->map = NULL;
multifilesrc->new_seek = FALSE; multifilesrc->new_seek = FALSE;
multifilesrc->have_newmedia_events = FALSE;
} }
static void static void
@ -156,6 +164,9 @@ gst_multifilesrc_set_property (GObject * object, guint prop_id,
src->listptr = g_value_get_pointer (value); src->listptr = g_value_get_pointer (value);
} }
break; break;
case ARG_HAVENEWMEDIA:
src->have_newmedia_events = g_value_get_boolean (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -177,6 +188,9 @@ gst_multifilesrc_get_property (GObject * object, guint prop_id, GValue * value,
case ARG_LOCATIONS: case ARG_LOCATIONS:
g_value_set_pointer (value, src->listptr); g_value_set_pointer (value, src->listptr);
break; break;
case ARG_HAVENEWMEDIA:
g_value_set_boolean (value, src->have_newmedia_events);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -194,15 +208,24 @@ gst_multifilesrc_get (GstPad * pad)
{ {
GstMultiFileSrc *src; GstMultiFileSrc *src;
GstBuffer *buf; GstBuffer *buf;
GstEvent *newmedia;
GSList *list; GSList *list;
g_return_val_if_fail (pad != NULL, NULL); g_return_val_if_fail (pad != NULL, NULL);
src = GST_MULTIFILESRC (gst_pad_get_parent (pad)); src = GST_MULTIFILESRC (gst_pad_get_parent (pad));
GST_DEBUG ("curfileindex = %d newmedia flag = %s", src->curfileindex,
GST_FLAG_IS_SET (src, GST_MULTIFILESRC_NEWFILE) ? "true" : "false");
switch (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_NEWFILE)) {
case FALSE:
if (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN)) if (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN))
gst_multifilesrc_close_file (src); gst_multifilesrc_close_file (src);
if (!src->listptr) { if (!src->listptr) {
GST_DEBUG ("sending EOS event");
gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS)); return GST_DATA (gst_event_new (GST_EVENT_EOS));
} }
@ -212,10 +235,22 @@ gst_multifilesrc_get (GstPad * pad)
if (!gst_multifilesrc_open_file (src, pad)) if (!gst_multifilesrc_open_file (src, pad))
return NULL; return NULL;
src->curfileindex++;
/* emitted after the open, as the user may free the list and string from here */ /* emitted after the open, as the user may free the list and string from here */
g_signal_emit (G_OBJECT (src), gst_multifilesrc_signals[NEW_FILE], 0, list); g_signal_emit (G_OBJECT (src), gst_multifilesrc_signals[NEW_FILE], 0,
list);
if (src->have_newmedia_events) {
newmedia =
gst_event_new_discontinuous (TRUE, GST_FORMAT_TIME, (gint64) 0,
GST_FORMAT_UNDEFINED);
GST_FLAG_SET (src, GST_MULTIFILESRC_NEWFILE);
GST_DEBUG ("sending new media event");
return GST_DATA (newmedia);
}
default:
if (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_NEWFILE))
GST_FLAG_UNSET (src, GST_MULTIFILESRC_NEWFILE);
/* create the buffer */ /* create the buffer */
/* FIXME: should eventually use a bufferpool for this */ /* FIXME: should eventually use a bufferpool for this */
buf = gst_buffer_new (); buf = gst_buffer_new ();
@ -234,9 +269,15 @@ gst_multifilesrc_get (GstPad * pad)
} }
/* we're done, return the buffer */ /* we're done, return the buffer */
GST_DEBUG ("sending buffer");
return GST_DATA (buf); return GST_DATA (buf);
} }
/* should not reach here */
g_assert_not_reached ();
return NULL;
}
/* open the file and mmap it, necessary to go to READY state */ /* open the file and mmap it, necessary to go to READY state */
static gboolean static gboolean
gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad) gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad)

View file

@ -42,8 +42,9 @@ G_BEGIN_DECLS
typedef enum { typedef enum {
GST_MULTIFILESRC_OPEN = GST_ELEMENT_FLAG_LAST, GST_MULTIFILESRC_OPEN = GST_ELEMENT_FLAG_LAST,
GST_MULTIFILESRC_NEWFILE = GST_ELEMENT_FLAG_LAST + 2,
GST_MULTIFILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 GST_MULTIFILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 4
} GstMultiFileSrcFlags; } GstMultiFileSrcFlags;
typedef struct _GstMultiFileSrc GstMultiFileSrc; typedef struct _GstMultiFileSrc GstMultiFileSrc;
@ -63,6 +64,11 @@ struct _GstMultiFileSrc {
gulong size; /* how long is the file? */ gulong size; /* how long is the file? */
guchar *map; /* where the file is mapped to */ guchar *map; /* where the file is mapped to */
gint curfileindex; /* how many files have we done so far */
gboolean have_newmedia_events; /* tunable parameter to say whether new media
disconts should be generated */
gboolean new_seek; gboolean new_seek;
}; };