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 	protected bool ownedRef;
43 
44 	/** Get the main Gtk struct */
45 	public GstTypeFind* getTypeFindStruct()
46 	{
47 		return gstTypeFind;
48 	}
49 
50 	/** the main Gtk struct as a void* */
51 	protected void* getStruct()
52 	{
53 		return cast(void*)gstTypeFind;
54 	}
55 
56 	/**
57 	 * Sets our main struct and passes it to the parent class.
58 	 */
59 	public this (GstTypeFind* gstTypeFind, bool ownedRef = false)
60 	{
61 		this.gstTypeFind = gstTypeFind;
62 		this.ownedRef = ownedRef;
63 	}
64 
65 	/**
66 	 * Returns the size bytes of the stream to identify beginning at offset. If
67 	 * offset is a positive number, the offset is relative to the beginning of the
68 	 * stream, if offset is a negative number the offset is relative to the end of
69 	 * the stream. The returned memory is valid until the typefinding function
70 	 * returns and must not be freed.
71 	 * Params:
72 	 *     offset = The offset
73 	 *     size = The number of bytes to return
74 	 * Returns: the requested data, or NULL if that data is not available.
75 	 */
76 	public ubyte[] peek(long offset, uint size)
77 	{
78 		ubyte* buff = gst_type_find_peek(gstTypeFind, offset, size);
79 		
80 		return buff[0 .. size];
81 	}
82 
83 	/**
84 	 */
85 
86 	/**
87 	 * Get the length of the data stream.
88 	 *
89 	 * Return: The length of the data stream, or 0 if it is not available.
90 	 */
91 	public ulong getLength()
92 	{
93 		return gst_type_find_get_length(gstTypeFind);
94 	}
95 
96 	/**
97 	 * If a #GstTypeFindFunction calls this function it suggests the caps with the
98 	 * given probability. A #GstTypeFindFunction may supply different suggestions
99 	 * in one call.
100 	 * It is up to the caller of the #GstTypeFindFunction to interpret these values.
101 	 *
102 	 * Params:
103 	 *     probability = The probability in percent that the suggestion is right
104 	 *     caps = The fixed #GstCaps to suggest
105 	 */
106 	public void suggest(uint probability, Caps caps)
107 	{
108 		gst_type_find_suggest(gstTypeFind, probability, (caps is null) ? null : caps.getCapsStruct());
109 	}
110 
111 	/**
112 	 * Registers a new typefind function to be used for typefinding. After
113 	 * registering this function will be available for typefinding.
114 	 * This function is typically called during an element's plugin initialization.
115 	 *
116 	 * Params:
117 	 *     plugin = A #GstPlugin, or %NULL for a static typefind function
118 	 *     name = The name for registering
119 	 *     rank = The rank (or importance) of this typefind function
120 	 *     func = The #GstTypeFindFunction to use
121 	 *     extensions = Optional comma-separated list of extensions
122 	 *         that could belong to this type
123 	 *     possibleCaps = Optionally the caps that could be returned when typefinding
124 	 *         succeeds
125 	 *     data = Optional user data. This user data must be available until the plugin
126 	 *         is unloaded.
127 	 *     dataNotify = a #GDestroyNotify that will be called on @data when the plugin
128 	 *         is unloaded.
129 	 *
130 	 * Return: %TRUE on success, %FALSE otherwise
131 	 */
132 	public static bool register(Plugin plugin, string name, uint rank, GstTypeFindFunction func, string extensions, Caps possibleCaps, void* data, GDestroyNotify dataNotify)
133 	{
134 		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;
135 	}
136 
137 	/** */
138 	public static GType typeFindGetType()
139 	{
140 		return gst_type_find_get_type();
141 	}
142 }