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