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.Sample;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gstreamer.Buffer;
30 private import gstreamer.BufferList;
31 private import gstreamer.Caps;
32 private import gstreamer.Segment;
33 private import gstreamer.Structure;
34 private import gstreamerc.gstreamer;
35 public  import gstreamerc.gstreamertypes;
36 
37 
38 /**
39  * A #GstSample is a small object containing data, a type, timing and
40  * extra arbitrary information.
41  */
42 public class Sample
43 {
44 	/** the main Gtk struct */
45 	protected GstSample* gstSample;
46 	protected bool ownedRef;
47 
48 	/** Get the main Gtk struct */
49 	public GstSample* getSampleStruct(bool transferOwnership = false)
50 	{
51 		if (transferOwnership)
52 			ownedRef = false;
53 		return gstSample;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected void* getStruct()
58 	{
59 		return cast(void*)gstSample;
60 	}
61 
62 	/**
63 	 * Sets our main struct and passes it to the parent class.
64 	 */
65 	public this (GstSample* gstSample, bool ownedRef = false)
66 	{
67 		this.gstSample = gstSample;
68 		this.ownedRef = ownedRef;
69 	}
70 
71 
72 	/** */
73 	public static GType getType()
74 	{
75 		return gst_sample_get_type();
76 	}
77 
78 	/**
79 	 * Create a new #GstSample with the provided details.
80 	 *
81 	 * Free-function: gst_sample_unref
82 	 *
83 	 * Params:
84 	 *     buffer = a #GstBuffer, or %NULL
85 	 *     caps = a #GstCaps, or %NULL
86 	 *     segment = a #GstSegment, or %NULL
87 	 *     info = a #GstStructure, or %NULL
88 	 *
89 	 * Returns: the new #GstSample. gst_sample_unref()
90 	 *     after usage.
91 	 *
92 	 * Throws: ConstructionException GTK+ fails to create the object.
93 	 */
94 	public this(Buffer buffer, Caps caps, Segment segment, Structure info)
95 	{
96 		auto p = gst_sample_new((buffer is null) ? null : buffer.getBufferStruct(), (caps is null) ? null : caps.getCapsStruct(), (segment is null) ? null : segment.getSegmentStruct(), (info is null) ? null : info.getStructureStruct(true));
97 		
98 		if(p is null)
99 		{
100 			throw new ConstructionException("null returned by new");
101 		}
102 		
103 		this(cast(GstSample*) p);
104 	}
105 
106 	/**
107 	 * Get the buffer associated with @sample
108 	 *
109 	 * Returns: the buffer of @sample or %NULL
110 	 *     when there is no buffer. The buffer remains valid as long as
111 	 *     @sample is valid.  If you need to hold on to it for longer than
112 	 *     that, take a ref to the buffer with gst_buffer_ref().
113 	 */
114 	public Buffer getBuffer()
115 	{
116 		auto p = gst_sample_get_buffer(gstSample);
117 		
118 		if(p is null)
119 		{
120 			return null;
121 		}
122 		
123 		return ObjectG.getDObject!(Buffer)(cast(GstBuffer*) p);
124 	}
125 
126 	/**
127 	 * Get the buffer list associated with @sample
128 	 *
129 	 * Returns: the buffer list of @sample or %NULL
130 	 *     when there is no buffer list. The buffer list remains valid as long as
131 	 *     @sample is valid.  If you need to hold on to it for longer than
132 	 *     that, take a ref to the buffer list with gst_mini_object_ref ().
133 	 *
134 	 * Since: 1.6
135 	 */
136 	public BufferList getBufferList()
137 	{
138 		auto p = gst_sample_get_buffer_list(gstSample);
139 		
140 		if(p is null)
141 		{
142 			return null;
143 		}
144 		
145 		return ObjectG.getDObject!(BufferList)(cast(GstBufferList*) p);
146 	}
147 
148 	/**
149 	 * Get the caps associated with @sample
150 	 *
151 	 * Returns: the caps of @sample or %NULL
152 	 *     when there is no caps. The caps remain valid as long as @sample is
153 	 *     valid.  If you need to hold on to the caps for longer than that,
154 	 *     take a ref to the caps with gst_caps_ref().
155 	 */
156 	public Caps getCaps()
157 	{
158 		auto p = gst_sample_get_caps(gstSample);
159 		
160 		if(p is null)
161 		{
162 			return null;
163 		}
164 		
165 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p);
166 	}
167 
168 	/**
169 	 * Get extra information associated with @sample.
170 	 *
171 	 * Returns: the extra info of @sample.
172 	 *     The info remains valid as long as @sample is valid.
173 	 */
174 	public Structure getInfo()
175 	{
176 		auto p = gst_sample_get_info(gstSample);
177 		
178 		if(p is null)
179 		{
180 			return null;
181 		}
182 		
183 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p);
184 	}
185 
186 	/**
187 	 * Get the segment associated with @sample
188 	 *
189 	 * Returns: the segment of @sample.
190 	 *     The segment remains valid as long as @sample is valid.
191 	 */
192 	public Segment getSegment()
193 	{
194 		auto p = gst_sample_get_segment(gstSample);
195 		
196 		if(p is null)
197 		{
198 			return null;
199 		}
200 		
201 		return ObjectG.getDObject!(Segment)(cast(GstSegment*) p);
202 	}
203 
204 	/**
205 	 * Set the buffer list associated with @sample
206 	 *
207 	 * Params:
208 	 *     bufferList = a #GstBufferList
209 	 *
210 	 * Since: 1.6
211 	 */
212 	public void setBufferList(BufferList bufferList)
213 	{
214 		gst_sample_set_buffer_list(gstSample, (bufferList is null) ? null : bufferList.getBufferListStruct());
215 	}
216 }