1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gstreamer.TypeFind;
26 
27 private import glib.Str;
28 private import gstreamer.Caps;
29 private import gstreamer.Plugin;
30 private import gstreamerc.gstreamer;
31 public  import gstreamerc.gstreamertypes;
32 
33 
34 /**
35  * The following functions allow you to detect the media type of an unknown
36  * stream.
37  */
38 public class TypeFind
39 {
40 	/** the main Gtk struct */
41 	protected GstTypeFind* gstTypeFind;
42 
43 	/** Get the main Gtk struct */
44 	public GstTypeFind* getTypeFindStruct()
45 	{
46 		return gstTypeFind;
47 	}
48 
49 	/** the main Gtk struct as a void* */
50 	protected void* getStruct()
51 	{
52 		return cast(void*)gstTypeFind;
53 	}
54 
55 	/**
56 	 * Sets our main struct and passes it to the parent class.
57 	 */
58 	public this (GstTypeFind* gstTypeFind)
59 	{
60 		this.gstTypeFind = gstTypeFind;
61 	}
62 
63 	/**
64 	 * Returns the size bytes of the stream to identify beginning at offset. If
65 	 * offset is a positive number, the offset is relative to the beginning of the
66 	 * stream, if offset is a negative number the offset is relative to the end of
67 	 * the stream. The returned memory is valid until the typefinding function
68 	 * returns and must not be freed.
69 	 * Params:
70 	 *     offset = The offset
71 	 *     size = The number of bytes to return
72 	 * Returns: the requested data, or NULL if that data is not available.
73 	 */
74 	public ubyte[] peek(long offset, uint size)
75 	{
76 		ubyte* buff = gst_type_find_peek(gstTypeFind, offset, size);
77 		
78 		return buff[0 .. size];
79 	}
80 
81 	/**
82 	 */
83 
84 	/**
85 	 * Get the length of the data stream.
86 	 *
87 	 * Return: The length of the data stream, or 0 if it is not available.
88 	 */
89 	public ulong getLength()
90 	{
91 		return gst_type_find_get_length(gstTypeFind);
92 	}
93 
94 	/**
95 	 * If a #GstTypeFindFunction calls this function it suggests the caps with the
96 	 * given probability. A #GstTypeFindFunction may supply different suggestions
97 	 * in one call.
98 	 * It is up to the caller of the #GstTypeFindFunction to interpret these values.
99 	 *
100 	 * Params:
101 	 *     probability = The probability in percent that the suggestion is right
102 	 *     caps = The fixed #GstCaps to suggest
103 	 */
104 	public void suggest(uint probability, Caps caps)
105 	{
106 		gst_type_find_suggest(gstTypeFind, probability, (caps is null) ? null : caps.getCapsStruct());
107 	}
108 
109 	/**
110 	 * Registers a new typefind function to be used for typefinding. After
111 	 * registering this function will be available for typefinding.
112 	 * This function is typically called during an element's plugin initialization.
113 	 *
114 	 * Params:
115 	 *     plugin = A #GstPlugin, or %NULL for a static typefind function
116 	 *     name = The name for registering
117 	 *     rank = The rank (or importance) of this typefind function
118 	 *     func = The #GstTypeFindFunction to use
119 	 *     extensions = Optional comma-separated list of extensions
120 	 *         that could belong to this type
121 	 *     possibleCaps = Optionally the caps that could be returned when typefinding
122 	 *         succeeds
123 	 *     data = Optional user data. This user data must be available until the plugin
124 	 *         is unloaded.
125 	 *     dataNotify = a #GDestroyNotify that will be called on @data when the plugin
126 	 *         is unloaded.
127 	 *
128 	 * Return: %TRUE on success, %FALSE otherwise
129 	 */
130 	public static bool register(Plugin plugin, string name, uint rank, GstTypeFindFunction func, string extensions, Caps possibleCaps, void* data, GDestroyNotify dataNotify)
131 	{
132 		return gst_type_find_register((plugin is null) ? null : plugin.getPluginStruct(), Str.toStringz(name), rank, func, Str.toStringz(extensions), (possibleCaps is null) ? null : possibleCaps.getCapsStruct(), data, dataNotify) != 0;
133 	}
134 
135 	/** */
136 	public static GType typeFindGetType()
137 	{
138 		return gst_type_find_get_type();
139 	}
140 }