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