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.Context; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gstreamer.Structure; 31 private import gstreamer.c.functions; 32 public import gstreamer.c.types; 33 public import gstreamerc.gstreamertypes; 34 35 36 /** 37 * #GstContext is a container object used to store contexts like a device 38 * context, a display server connection and similar concepts that should 39 * be shared between multiple elements. 40 * 41 * Applications can set a context on a complete pipeline by using 42 * gst_element_set_context(), which will then be propagated to all 43 * child elements. Elements can handle these in #GstElementClass.set_context() 44 * and merge them with the context information they already have. 45 * 46 * When an element needs a context it will do the following actions in this 47 * order until one step succeeds: 48 * 1. Check if the element already has a context 49 * 2. Query downstream with GST_QUERY_CONTEXT for the context 50 * 3. Query upstream with GST_QUERY_CONTEXT for the context 51 * 4. Post a GST_MESSAGE_NEED_CONTEXT message on the bus with the required 52 * context types and afterwards check if a usable context was set now 53 * 5. Create a context by itself and post a GST_MESSAGE_HAVE_CONTEXT message 54 * on the bus. 55 * 56 * Bins will catch GST_MESSAGE_NEED_CONTEXT messages and will set any previously 57 * known context on the element that asks for it if possible. Otherwise the 58 * application should provide one if it can. 59 * 60 * #GstContext<!-- -->s can be persistent. 61 * A persistent #GstContext is kept in elements when they reach 62 * %GST_STATE_NULL, non-persistent ones will be removed. 63 * Also, a non-persistent context won't override a previous persistent 64 * context set to an element. 65 */ 66 public class Context 67 { 68 /** the main Gtk struct */ 69 protected GstContext* gstContext; 70 protected bool ownedRef; 71 72 /** Get the main Gtk struct */ 73 public GstContext* getContextStruct(bool transferOwnership = false) 74 { 75 if (transferOwnership) 76 ownedRef = false; 77 return gstContext; 78 } 79 80 /** the main Gtk struct as a void* */ 81 protected void* getStruct() 82 { 83 return cast(void*)gstContext; 84 } 85 86 /** 87 * Sets our main struct and passes it to the parent class. 88 */ 89 public this (GstContext* gstContext, bool ownedRef = false) 90 { 91 this.gstContext = gstContext; 92 this.ownedRef = ownedRef; 93 } 94 95 96 /** */ 97 public static GType getType() 98 { 99 return gst_context_get_type(); 100 } 101 102 /** 103 * Create a new context. 104 * 105 * Params: 106 * contextType = Context type 107 * persistent = Persistent context 108 * 109 * Returns: The new context. 110 * 111 * Since: 1.2 112 * 113 * Throws: ConstructionException GTK+ fails to create the object. 114 */ 115 public this(string contextType, bool persistent) 116 { 117 auto p = gst_context_new(Str.toStringz(contextType), persistent); 118 119 if(p is null) 120 { 121 throw new ConstructionException("null returned by new"); 122 } 123 124 this(cast(GstContext*) p); 125 } 126 127 /** 128 * Get the type of @context. 129 * 130 * Returns: The type of the context. 131 * 132 * Since: 1.2 133 */ 134 public string getContextType() 135 { 136 return Str.toString(gst_context_get_context_type(gstContext)); 137 } 138 139 /** 140 * Access the structure of the context. 141 * 142 * Returns: The structure of the context. The structure is 143 * still owned by the context, which means that you should not modify it, 144 * free it and that the pointer becomes invalid when you free the context. 145 * 146 * Since: 1.2 147 */ 148 public Structure getStructure() 149 { 150 auto p = gst_context_get_structure(gstContext); 151 152 if(p is null) 153 { 154 return null; 155 } 156 157 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p); 158 } 159 160 /** 161 * Checks if @context has @context_type. 162 * 163 * Params: 164 * contextType = Context type to check. 165 * 166 * Returns: %TRUE if @context has @context_type. 167 * 168 * Since: 1.2 169 */ 170 public bool hasContextType(string contextType) 171 { 172 return gst_context_has_context_type(gstContext, Str.toStringz(contextType)) != 0; 173 } 174 175 /** 176 * Check if @context is persistent. 177 * 178 * Returns: %TRUE if the context is persistent. 179 * 180 * Since: 1.2 181 */ 182 public bool isPersistent() 183 { 184 return gst_context_is_persistent(gstContext) != 0; 185 } 186 187 /** 188 * Get a writable version of the structure. 189 * 190 * Returns: The structure of the context. The structure is still 191 * owned by the context, which means that you should not free it and 192 * that the pointer becomes invalid when you free the context. 193 * This function checks if @context is writable. 194 * 195 * Since: 1.2 196 */ 197 public Structure writableStructure() 198 { 199 auto p = gst_context_writable_structure(gstContext); 200 201 if(p is null) 202 { 203 return null; 204 } 205 206 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p, true); 207 } 208 }