mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
flacparse: add support for the toc-select event
Select tracks from the CUE sheet by sending a toc-select event based on the uid in the TOC. https://bugzilla.gnome.org/show_bug.cgi?id=540891
This commit is contained in:
parent
b85c5f236b
commit
0f97b6f978
1 changed files with 58 additions and 1 deletions
|
@ -204,6 +204,8 @@ static GstFlowReturn gst_flac_parse_pre_push_frame (GstBaseParse * parse,
|
|||
static gboolean gst_flac_parse_convert (GstBaseParse * parse,
|
||||
GstFormat src_format, gint64 src_value, GstFormat dest_format,
|
||||
gint64 * dest_value);
|
||||
static gboolean gst_flac_parse_src_event (GstBaseParse * parse,
|
||||
GstEvent * event);
|
||||
static GstCaps *gst_flac_parse_get_sink_caps (GstBaseParse * parse,
|
||||
GstCaps * filter);
|
||||
|
||||
|
@ -237,6 +239,7 @@ gst_flac_parse_class_init (GstFlacParseClass * klass)
|
|||
baseparse_class->pre_push_frame =
|
||||
GST_DEBUG_FUNCPTR (gst_flac_parse_pre_push_frame);
|
||||
baseparse_class->convert = GST_DEBUG_FUNCPTR (gst_flac_parse_convert);
|
||||
baseparse_class->src_event = GST_DEBUG_FUNCPTR (gst_flac_parse_src_event);
|
||||
baseparse_class->get_sink_caps =
|
||||
GST_DEBUG_FUNCPTR (gst_flac_parse_get_sink_caps);
|
||||
|
||||
|
@ -1694,7 +1697,6 @@ gst_flac_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||
if (flacparse->toc) {
|
||||
gst_pad_push_event (GST_BASE_PARSE_SRC_PAD (flacparse),
|
||||
gst_event_new_toc (flacparse->toc, FALSE));
|
||||
flacparse->toc = NULL;
|
||||
}
|
||||
|
||||
frame->flags |= GST_BASE_PARSE_FRAME_FLAG_CLIP;
|
||||
|
@ -1734,6 +1736,61 @@ gst_flac_parse_convert (GstBaseParse * parse,
|
|||
src_value, dest_format, dest_value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_flac_parse_src_event (GstBaseParse * parse, GstEvent * event)
|
||||
{
|
||||
GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
|
||||
gboolean res = FALSE;
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_TOC_SELECT:
|
||||
{
|
||||
GstTocEntry *entry = NULL;
|
||||
GstEvent *seek_event;
|
||||
GstToc *toc = NULL;
|
||||
gint64 start_pos;
|
||||
gchar *uid = NULL;
|
||||
|
||||
/* FIXME: some locking would be good */
|
||||
if (flacparse->toc)
|
||||
toc = gst_toc_ref (flacparse->toc);
|
||||
|
||||
if (toc != NULL) {
|
||||
gst_event_parse_toc_select (event, &uid);
|
||||
if (uid != NULL) {
|
||||
entry = gst_toc_find_entry (toc, uid);
|
||||
if (entry != NULL) {
|
||||
gst_toc_entry_get_start_stop_times (entry, &start_pos, NULL);
|
||||
|
||||
/* FIXME: use segment rate here instead? */
|
||||
seek_event = gst_event_new_seek (1.0,
|
||||
GST_FORMAT_TIME,
|
||||
GST_SEEK_FLAG_FLUSH,
|
||||
GST_SEEK_TYPE_SET, start_pos, GST_SEEK_TYPE_NONE, -1);
|
||||
|
||||
res =
|
||||
GST_BASE_PARSE_CLASS (parent_class)->src_event (parse,
|
||||
seek_event);
|
||||
|
||||
g_free (uid);
|
||||
} else {
|
||||
GST_WARNING_OBJECT (parse, "no TOC entry with given UID: %s", uid);
|
||||
}
|
||||
}
|
||||
gst_toc_unref (toc);
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (flacparse, "no TOC to select");
|
||||
}
|
||||
gst_event_unref (event);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = GST_BASE_PARSE_CLASS (parent_class)->src_event (parse, event);
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_flac_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue