mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
typefindelement: use new typefind function
Refactor a little. Use the new typefind helper function that uses the extension to speed up typefinding.
This commit is contained in:
parent
8fff434835
commit
fc2f4ae37a
1 changed files with 31 additions and 15 deletions
|
@ -613,15 +613,13 @@ gst_type_find_element_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static gchar *
|
||||||
gst_type_find_guess_by_extension (GstTypeFindElement * typefind, GstPad * pad,
|
gst_type_find_get_extension (GstTypeFindElement * typefind, GstPad * pad)
|
||||||
GstTypeFindProbability * probability)
|
|
||||||
{
|
{
|
||||||
GstQuery *query;
|
GstQuery *query;
|
||||||
gchar *uri;
|
gchar *uri, *result;
|
||||||
size_t len;
|
size_t len;
|
||||||
gint find;
|
gint find;
|
||||||
GstCaps *caps;
|
|
||||||
|
|
||||||
query = gst_query_new_uri ();
|
query = gst_query_new_uri ();
|
||||||
|
|
||||||
|
@ -647,17 +645,12 @@ gst_type_find_guess_by_extension (GstTypeFindElement * typefind, GstPad * pad,
|
||||||
if (find < 0)
|
if (find < 0)
|
||||||
goto no_extension;
|
goto no_extension;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (typefind, "found extension %s", &uri[find + 1]);
|
result = g_strdup (&uri[find + 1]);
|
||||||
|
|
||||||
caps =
|
|
||||||
gst_type_find_helper_for_extension (GST_OBJECT_CAST (typefind),
|
|
||||||
&uri[find + 1]);
|
|
||||||
if (caps)
|
|
||||||
*probability = GST_TYPE_FIND_MAXIMUM;
|
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (typefind, "found extension %s", result);
|
||||||
gst_query_unref (query);
|
gst_query_unref (query);
|
||||||
|
|
||||||
return caps;
|
return result;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
peer_query_failed:
|
peer_query_failed:
|
||||||
|
@ -680,6 +673,26 @@ no_extension:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstCaps *
|
||||||
|
gst_type_find_guess_by_extension (GstTypeFindElement * typefind, GstPad * pad,
|
||||||
|
GstTypeFindProbability * probability)
|
||||||
|
{
|
||||||
|
gchar *ext;
|
||||||
|
GstCaps *caps;
|
||||||
|
|
||||||
|
ext = gst_type_find_get_extension (typefind, pad);
|
||||||
|
if (!ext)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
caps = gst_type_find_helper_for_extension (GST_OBJECT_CAST (typefind), ext);
|
||||||
|
if (caps)
|
||||||
|
*probability = GST_TYPE_FIND_MAXIMUM;
|
||||||
|
|
||||||
|
g_free (ext);
|
||||||
|
|
||||||
|
return caps;
|
||||||
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_type_find_element_chain (GstPad * pad, GstBuffer * buffer)
|
gst_type_find_element_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
|
@ -848,6 +861,7 @@ gst_type_find_element_activate (GstPad * pad)
|
||||||
if (peer) {
|
if (peer) {
|
||||||
gint64 size;
|
gint64 size;
|
||||||
GstFormat format = GST_FORMAT_BYTES;
|
GstFormat format = GST_FORMAT_BYTES;
|
||||||
|
gchar *ext;
|
||||||
|
|
||||||
if (!gst_pad_query_duration (peer, &format, &size)) {
|
if (!gst_pad_query_duration (peer, &format, &size)) {
|
||||||
GST_WARNING_OBJECT (typefind, "Could not query upstream length!");
|
GST_WARNING_OBJECT (typefind, "Could not query upstream length!");
|
||||||
|
@ -863,10 +877,12 @@ gst_type_find_element_activate (GstPad * pad)
|
||||||
gst_object_unref (peer);
|
gst_object_unref (peer);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
ext = gst_type_find_get_extension (typefind, pad);
|
||||||
|
|
||||||
found_caps = gst_type_find_helper_get_range (GST_OBJECT_CAST (peer),
|
found_caps = gst_type_find_helper_get_range_ext (GST_OBJECT_CAST (peer),
|
||||||
(GstTypeFindHelperGetRangeFunction) (GST_PAD_GETRANGEFUNC (peer)),
|
(GstTypeFindHelperGetRangeFunction) (GST_PAD_GETRANGEFUNC (peer)),
|
||||||
(guint64) size, &probability);
|
(guint64) size, ext, &probability);
|
||||||
|
g_free (ext);
|
||||||
|
|
||||||
gst_object_unref (peer);
|
gst_object_unref (peer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue