mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 08:11:16 +00:00
ext/ffmpeg/gstffmpegmux.c: Port tag-writing support in the muxers.
Original commit message from CVS: * ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_request_new_pad), (gst_ffmpegmux_sink_event), (gst_ffmpegmux_collected): Port tag-writing support in the muxers.
This commit is contained in:
parent
5312e1f777
commit
9e06696cca
2 changed files with 44 additions and 31 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2006-09-08 Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
|
* ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_request_new_pad),
|
||||||
|
(gst_ffmpegmux_sink_event), (gst_ffmpegmux_collected):
|
||||||
|
Port tag-writing support in the muxers.
|
||||||
|
|
||||||
2006-09-08 Edward Hervey <edward@fluendo.com>
|
2006-09-08 Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
Patch by: Michal Benes <michal dot benes at xeris dot cz>
|
Patch by: Michal Benes <michal dot benes at xeris dot cz>
|
||||||
|
|
|
@ -42,9 +42,6 @@ struct _GstFFMpegMuxPad
|
||||||
GstCollectData collect; /* we extend the CollectData */
|
GstCollectData collect; /* we extend the CollectData */
|
||||||
|
|
||||||
gint padnum;
|
gint padnum;
|
||||||
|
|
||||||
/*< private >*/
|
|
||||||
gpointer _gst_reserved[GST_PADDING];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstFFMpegMux
|
struct _GstFFMpegMux
|
||||||
|
@ -63,7 +60,8 @@ struct _GstFFMpegMux
|
||||||
gint videopads, audiopads;
|
gint videopads, audiopads;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
gpointer _gst_reserved[GST_PADDING];
|
/* event_function is the collectpads default eventfunction */
|
||||||
|
GstPadEventFunction event_function;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _GstFFMpegMuxClassParams
|
typedef struct _GstFFMpegMuxClassParams
|
||||||
|
@ -117,6 +115,8 @@ static GstPad *gst_ffmpegmux_request_new_pad (GstElement * element,
|
||||||
GstPadTemplate * templ, const gchar * name);
|
GstPadTemplate * templ, const gchar * name);
|
||||||
static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data);
|
static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data);
|
||||||
|
|
||||||
|
static gboolean gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event);
|
||||||
|
|
||||||
static GstStateChangeReturn gst_ffmpegmux_change_state (GstElement * element,
|
static GstStateChangeReturn gst_ffmpegmux_change_state (GstElement * element,
|
||||||
GstStateChange transition);
|
GstStateChange transition);
|
||||||
|
|
||||||
|
@ -263,6 +263,10 @@ gst_ffmpegmux_request_new_pad (GstElement * element,
|
||||||
gst_collect_pads_add_pad (ffmpegmux->collect, pad, sizeof (GstFFMpegMuxPad));
|
gst_collect_pads_add_pad (ffmpegmux->collect, pad, sizeof (GstFFMpegMuxPad));
|
||||||
collect_pad->padnum = ffmpegmux->context->nb_streams;
|
collect_pad->padnum = ffmpegmux->context->nb_streams;
|
||||||
|
|
||||||
|
/* small hack to put our own event pad function and chain up to collect pad */
|
||||||
|
ffmpegmux->event_function = GST_PAD_EVENTFUNC(pad);
|
||||||
|
gst_pad_set_event_function (pad, gst_ffmpegmux_sink_event);
|
||||||
|
|
||||||
gst_pad_set_setcaps_function (pad, gst_ffmpegmux_setcaps);
|
gst_pad_set_setcaps_function (pad, gst_ffmpegmux_setcaps);
|
||||||
gst_element_add_pad (element, pad);
|
gst_element_add_pad (element, pad);
|
||||||
|
|
||||||
|
@ -313,21 +317,32 @@ gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This is old tags handling code. It is not yet ported to 0.10 because
|
static gboolean
|
||||||
collectpads do not support events easily. */
|
gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event)
|
||||||
|
{
|
||||||
|
GstFFMpegMux * ffmpegmux = (GstFFMpegMux*) gst_pad_get_parent(pad);
|
||||||
|
gboolean res = TRUE;
|
||||||
|
|
||||||
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
|
case GST_EVENT_TAG: {
|
||||||
|
GstTagList * taglist = NULL;
|
||||||
|
|
||||||
|
gst_event_parse_tag (event, &taglist);
|
||||||
|
ffmpegmux->tags = gst_tag_list_merge(ffmpegmux->tags, taglist,
|
||||||
|
GST_TAG_MERGE_PREPEND);
|
||||||
|
|
||||||
#if 0
|
|
||||||
case GST_EVENT_TAG:
|
|
||||||
if (ffmpegmux->tags) {
|
|
||||||
gst_tag_list_insert (ffmpegmux->tags,
|
|
||||||
gst_event_tag_get_list (event), GST_TAG_MERGE_PREPEND);
|
|
||||||
} else {
|
|
||||||
ffmpegmux->tags =
|
|
||||||
gst_tag_list_copy (gst_event_tag_get_list (event));
|
|
||||||
}
|
|
||||||
gst_event_unref (event);
|
|
||||||
break;
|
break;
|
||||||
#endif
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* chaining up to collectpads default event function */
|
||||||
|
res = ffmpegmux->event_function (pad, event);
|
||||||
|
|
||||||
|
gst_object_unref (ffmpegmux);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
|
gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
|
||||||
|
@ -336,6 +351,7 @@ gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
|
||||||
GSList *collected;
|
GSList *collected;
|
||||||
GstFFMpegMuxPad *best_pad;
|
GstFFMpegMuxPad *best_pad;
|
||||||
GstClockTime best_time;
|
GstClockTime best_time;
|
||||||
|
const GstTagList *iface_tags;
|
||||||
|
|
||||||
/* open "file" (gstreamer protocol to next element) */
|
/* open "file" (gstreamer protocol to next element) */
|
||||||
if (!ffmpegmux->opened) {
|
if (!ffmpegmux->opened) {
|
||||||
|
@ -371,23 +387,15 @@ gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* TODO: tags not ported to gst 0.10 */
|
|
||||||
/* tags */
|
/* tags */
|
||||||
iface_tags = gst_tag_setter_get_list (GST_TAG_SETTER (ffmpegmux));
|
iface_tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (ffmpegmux));
|
||||||
if (ffmpegmux->tags || iface_tags) {
|
if (ffmpegmux->tags || iface_tags) {
|
||||||
GstTagList *tags;
|
GstTagList *tags;
|
||||||
gint i;
|
gint i;
|
||||||
gchar *s;
|
gchar *s;
|
||||||
|
|
||||||
if (iface_tags && ffmpegmux->tags) {
|
tags = gst_tag_list_merge (iface_tags, ffmpegmux->tags,
|
||||||
gst_tag_list_merge (iface_tags, ffmpegmux->tags,
|
|
||||||
GST_TAG_MERGE_APPEND);
|
GST_TAG_MERGE_APPEND);
|
||||||
} else if (iface_tags) {
|
|
||||||
tags = gst_tag_list_copy (iface_tags);
|
|
||||||
} else {
|
|
||||||
tags = gst_tag_list_copy (ffmpegmux->tags);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get the interesting ones */
|
/* get the interesting ones */
|
||||||
if (gst_tag_list_get_string (tags, GST_TAG_TITLE, &s)) {
|
if (gst_tag_list_get_string (tags, GST_TAG_TITLE, &s)) {
|
||||||
|
@ -414,12 +422,11 @@ gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
|
||||||
strncpy (ffmpegmux->context->genre, s,
|
strncpy (ffmpegmux->context->genre, s,
|
||||||
sizeof (ffmpegmux->context->genre));
|
sizeof (ffmpegmux->context->genre));
|
||||||
}
|
}
|
||||||
if (gst_tag_list_get_uint (tags, GST_TAG_TRACK_NUMBER, &i)) {
|
if (gst_tag_list_get_int (tags, GST_TAG_TRACK_NUMBER, &i)) {
|
||||||
ffmpegmux->context->track = i;
|
ffmpegmux->context->track = i;
|
||||||
}
|
}
|
||||||
gst_tag_list_free (tags);
|
gst_tag_list_free (tags);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* set the streamheader flag for gstffmpegprotocol if codec supports it */
|
/* set the streamheader flag for gstffmpegprotocol if codec supports it */
|
||||||
if (!strcmp (ffmpegmux->context->oformat->name, "flv") ) {
|
if (!strcmp (ffmpegmux->context->oformat->name, "flv") ) {
|
||||||
|
|
Loading…
Reference in a new issue