| 1 | /* GStreamer |
| 2 | * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de> |
| 3 | * |
| 4 | * gsttypefind.h: typefinding subsystem |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Library General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Library General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Library General Public |
| 17 | * License along with this library; if not, write to the |
| 18 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
| 19 | * Boston, MA 02110-1301, USA. |
| 20 | */ |
| 21 | |
| 22 | |
| 23 | #ifndef __GST_TYPE_FIND_H__ |
| 24 | #define __GST_TYPE_FIND_H__ |
| 25 | |
| 26 | #include <gst/gstcaps.h> |
| 27 | #include <gst/gstplugin.h> |
| 28 | #include <gst/gstpluginfeature.h> |
| 29 | |
| 30 | G_BEGIN_DECLS |
| 31 | |
| 32 | #define GST_TYPE_TYPE_FIND (gst_type_find_get_type()) |
| 33 | |
| 34 | typedef struct _GstTypeFind GstTypeFind; |
| 35 | |
| 36 | /** |
| 37 | * GstTypeFindFunction: |
| 38 | * @find: A #GstTypeFind structure |
| 39 | * @user_data: optional data to pass to the function |
| 40 | * |
| 41 | * A function that will be called by typefinding. |
| 42 | */ |
| 43 | typedef void (* GstTypeFindFunction) (GstTypeFind *find, gpointer user_data); |
| 44 | |
| 45 | /** |
| 46 | * GstTypeFindProbability: |
| 47 | * @GST_TYPE_FIND_NONE: type undetected. |
| 48 | * @GST_TYPE_FIND_MINIMUM: unlikely typefind. |
| 49 | * @GST_TYPE_FIND_POSSIBLE: possible type detected. |
| 50 | * @GST_TYPE_FIND_LIKELY: likely a type was detected. |
| 51 | * @GST_TYPE_FIND_NEARLY_CERTAIN: nearly certain that a type was detected. |
| 52 | * @GST_TYPE_FIND_MAXIMUM: very certain a type was detected. |
| 53 | * |
| 54 | * The probability of the typefind function. Higher values have more certainty |
| 55 | * in doing a reliable typefind. |
| 56 | */ |
| 57 | typedef enum { |
| 58 | GST_TYPE_FIND_NONE = 0, |
| 59 | GST_TYPE_FIND_MINIMUM = 1, |
| 60 | GST_TYPE_FIND_POSSIBLE = 50, |
| 61 | GST_TYPE_FIND_LIKELY = 80, |
| 62 | GST_TYPE_FIND_NEARLY_CERTAIN = 99, |
| 63 | GST_TYPE_FIND_MAXIMUM = 100 |
| 64 | } GstTypeFindProbability; |
| 65 | |
| 66 | /** |
| 67 | * GstTypeFind: |
| 68 | * @peek: Method to peek data. |
| 69 | * @suggest: Method to suggest #GstCaps with a given probability. |
| 70 | * @data: The data used by the caller of the typefinding function. |
| 71 | * @get_length: Returns the length of current data. |
| 72 | * |
| 73 | * Object that stores typefind callbacks. To use with #GstTypeFindFactory. |
| 74 | */ |
| 75 | struct _GstTypeFind { |
| 76 | /* private to the caller of the typefind function */ |
| 77 | const guint8 * (* peek) (gpointer data, |
| 78 | gint64 offset, |
| 79 | guint size); |
| 80 | |
| 81 | void (* suggest) (gpointer data, |
| 82 | guint probability, |
| 83 | GstCaps *caps); |
| 84 | |
| 85 | gpointer data; |
| 86 | |
| 87 | /* optional */ |
| 88 | guint64 (* get_length) (gpointer data); |
| 89 | |
| 90 | /* <private> */ |
| 91 | gpointer _gst_reserved[GST_PADDING]; |
| 92 | }; |
| 93 | |
| 94 | GST_API |
| 95 | GType gst_type_find_get_type (void); |
| 96 | |
| 97 | /* typefind function interface */ |
| 98 | |
| 99 | GST_API |
| 100 | const guint8 * gst_type_find_peek (GstTypeFind * find, |
| 101 | gint64 offset, |
| 102 | guint size); |
| 103 | GST_API |
| 104 | void gst_type_find_suggest (GstTypeFind * find, |
| 105 | guint probability, |
| 106 | GstCaps * caps); |
| 107 | GST_API |
| 108 | void gst_type_find_suggest_simple (GstTypeFind * find, |
| 109 | guint probability, |
| 110 | const char * media_type, |
| 111 | const char * fieldname, ...); |
| 112 | GST_API |
| 113 | guint64 gst_type_find_get_length (GstTypeFind * find); |
| 114 | |
| 115 | /* registration interface */ |
| 116 | |
| 117 | GST_API |
| 118 | gboolean gst_type_find_register (GstPlugin * plugin, |
| 119 | const gchar * name, |
| 120 | guint rank, |
| 121 | GstTypeFindFunction func, |
| 122 | const gchar * extensions, |
| 123 | GstCaps * possible_caps, |
| 124 | gpointer data, |
| 125 | GDestroyNotify data_notify); |
| 126 | |
| 127 | G_END_DECLS |
| 128 | |
| 129 | #endif /* __GST_TYPE_FIND_H__ */ |
| 130 | |