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