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