-/*** typefinding **************************************************************/
-/* ogg supports its own typefinding because the ogg spec defines that the first
- * packet of an ogg stream must identify the stream. Therefore ogg can use a
- * simplified approach at typefinding.
- */
-typedef struct
-{
- ogg_packet *packet;
- guint best_probability;
- GstCaps *caps;
-}
-OggTypeFind;
-
-static guint8 *
-ogg_find_peek (gpointer data, gint64 offset, guint size)
-{
- OggTypeFind *find = (OggTypeFind *) data;
-
- /* We don't support negative offset (from stream end); nothing embedded in ogg
- * ever needs them */
- if (offset >= 0 && offset + size <= find->packet->bytes) {
- return ((guint8 *) find->packet->packet) + offset;
- } else {
- return NULL;
- }
-}
-static void
-ogg_find_suggest (gpointer data, guint probability, const GstCaps * caps)
-{
- OggTypeFind *find = (OggTypeFind *) data;
-
- if (probability > find->best_probability) {
- GstCaps *copy = gst_caps_copy (caps);
-
- gst_caps_replace (&find->caps, copy);
- gst_caps_unref (copy);
-
- find->best_probability = probability;
- }
-}
-static GstCaps *
-gst_ogg_type_find (ogg_packet * packet)
-{
- GstTypeFind gst_find;
- OggTypeFind find;
- GList *walk, *type_list = NULL;
-
- walk = type_list = gst_type_find_factory_get_list ();
-
- find.packet = packet;
- find.best_probability = 0;
- find.caps = NULL;
- gst_find.data = &find;
- gst_find.peek = ogg_find_peek;
- gst_find.suggest = ogg_find_suggest;
- gst_find.get_length = NULL;
-
- while (walk) {
- GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (walk->data);
-
- gst_type_find_factory_call_function (factory, &gst_find);
- if (find.best_probability >= GST_TYPE_FIND_MAXIMUM)
- break;
- walk = g_list_next (walk);
- }
-
- gst_plugin_feature_list_free (type_list);
-
- if (find.best_probability > 0)
- return find.caps;
-
- return NULL;
-}
-