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 gst.mpegts.Section;
26 
27 private import glib.Bytes;
28 private import glib.ConstructionException;
29 private import glib.PtrArray;
30 private import gobject.ObjectG;
31 private import gst.mpegts.AtscEIT;
32 private import gst.mpegts.AtscETT;
33 private import gst.mpegts.AtscMGT;
34 private import gst.mpegts.AtscRRT;
35 private import gst.mpegts.AtscSTT;
36 private import gst.mpegts.AtscVCT;
37 private import gst.mpegts.BAT;
38 private import gst.mpegts.EIT;
39 private import gst.mpegts.NIT;
40 private import gst.mpegts.PMT;
41 private import gst.mpegts.PatProgram;
42 private import gst.mpegts.SCTESIT;
43 private import gst.mpegts.SDT;
44 private import gst.mpegts.TOT;
45 private import gst.mpegts.c.functions;
46 public  import gst.mpegts.c.types;
47 private import gstreamer.DateTime;
48 private import gstreamer.Element;
49 private import gstreamer.Event;
50 private import gstreamer.Message;
51 private import gstreamer.ObjectGst;
52 
53 
54 /**
55  * For more details, refer to the ITU H.222.0 or ISO/IEC 13818-1 specifications
56  * and other specifications mentioned in the documentation.
57  */
58 public class Section
59 {
60 	/** the main Gtk struct */
61 	protected GstMpegtsSection* gstMpegtsSection;
62 	protected bool ownedRef;
63 
64 	/** Get the main Gtk struct */
65 	public GstMpegtsSection* getSectionStruct(bool transferOwnership = false)
66 	{
67 		if (transferOwnership)
68 			ownedRef = false;
69 		return gstMpegtsSection;
70 	}
71 
72 	/** the main Gtk struct as a void* */
73 	protected void* getStruct()
74 	{
75 		return cast(void*)gstMpegtsSection;
76 	}
77 
78 	/**
79 	 * Sets our main struct and passes it to the parent class.
80 	 */
81 	public this (GstMpegtsSection* gstMpegtsSection, bool ownedRef = false)
82 	{
83 		this.gstMpegtsSection = gstMpegtsSection;
84 		this.ownedRef = ownedRef;
85 	}
86 
87 
88 	/** */
89 	public static GType getType()
90 	{
91 		return gst_mpegts_section_get_type();
92 	}
93 
94 	/**
95 	 * Creates a new #GstMpegtsSection from the provided @data.
96 	 *
97 	 * Note: Ensuring @data is big enough to contain the full section is the
98 	 * responsibility of the caller. If it is not big enough, %NULL will be
99 	 * returned.
100 	 *
101 	 * Note: it is the responsibility of the caller to ensure @data does point
102 	 * to the beginning of the section.
103 	 *
104 	 * Params:
105 	 *     pid = the PID to which this section belongs
106 	 *     data = a pointer to the beginning of the section (i.e. the first byte
107 	 *         should contain the table_id field).
108 	 *
109 	 * Returns: A new #GstMpegtsSection if the data was valid,
110 	 *     else %NULL
111 	 *
112 	 * Throws: ConstructionException GTK+ fails to create the object.
113 	 */
114 	public this(ushort pid, ubyte[] data)
115 	{
116 		auto __p = gst_mpegts_section_new(pid, data.ptr, cast(size_t)data.length);
117 
118 		if(__p is null)
119 		{
120 			throw new ConstructionException("null returned by new");
121 		}
122 
123 		this(cast(GstMpegtsSection*) __p);
124 	}
125 
126 	/**
127 	 * Returns the #GstMpegtsAtscVCT contained in the @section
128 	 *
129 	 * Returns: The #GstMpegtsAtscVCT contained in the section, or %NULL if an error
130 	 *     happened.
131 	 */
132 	public AtscVCT getAtscCvct()
133 	{
134 		auto __p = gst_mpegts_section_get_atsc_cvct(gstMpegtsSection);
135 
136 		if(__p is null)
137 		{
138 			return null;
139 		}
140 
141 		return ObjectG.getDObject!(AtscVCT)(cast(GstMpegtsAtscVCT*) __p);
142 	}
143 
144 	/**
145 	 * Returns the #GstMpegtsAtscEIT contained in the @section.
146 	 *
147 	 * Returns: The #GstMpegtsAtscEIT contained in the section, or %NULL if an error
148 	 *     happened.
149 	 */
150 	public AtscEIT getAtscEit()
151 	{
152 		auto __p = gst_mpegts_section_get_atsc_eit(gstMpegtsSection);
153 
154 		if(__p is null)
155 		{
156 			return null;
157 		}
158 
159 		return ObjectG.getDObject!(AtscEIT)(cast(GstMpegtsAtscEIT*) __p);
160 	}
161 
162 	/**
163 	 * Returns the #GstMpegtsAtscETT contained in the @section.
164 	 *
165 	 * Returns: The #GstMpegtsAtscETT contained in the section, or %NULL if an error
166 	 *     happened.
167 	 */
168 	public AtscETT getAtscEtt()
169 	{
170 		auto __p = gst_mpegts_section_get_atsc_ett(gstMpegtsSection);
171 
172 		if(__p is null)
173 		{
174 			return null;
175 		}
176 
177 		return ObjectG.getDObject!(AtscETT)(cast(GstMpegtsAtscETT*) __p);
178 	}
179 
180 	/**
181 	 * Returns the #GstMpegtsAtscMGT contained in the @section.
182 	 *
183 	 * Returns: The #GstMpegtsAtscMGT contained in the section, or %NULL if an error
184 	 *     happened.
185 	 */
186 	public AtscMGT getAtscMgt()
187 	{
188 		auto __p = gst_mpegts_section_get_atsc_mgt(gstMpegtsSection);
189 
190 		if(__p is null)
191 		{
192 			return null;
193 		}
194 
195 		return ObjectG.getDObject!(AtscMGT)(cast(GstMpegtsAtscMGT*) __p);
196 	}
197 
198 	/**
199 	 * Returns the #GstMpegtsAtscRRT contained in the @section.
200 	 *
201 	 * Returns: The #GstMpegtsAtscRRT contained in the section, or %NULL if an error
202 	 *     happened.
203 	 *
204 	 * Since: 1.18
205 	 */
206 	public AtscRRT getAtscRrt()
207 	{
208 		auto __p = gst_mpegts_section_get_atsc_rrt(gstMpegtsSection);
209 
210 		if(__p is null)
211 		{
212 			return null;
213 		}
214 
215 		return ObjectG.getDObject!(AtscRRT)(cast(GstMpegtsAtscRRT*) __p);
216 	}
217 
218 	/**
219 	 * Returns the #GstMpegtsAtscSTT contained in the @section.
220 	 *
221 	 * Returns: The #GstMpegtsAtscSTT contained in the section, or %NULL if an error
222 	 *     happened.
223 	 */
224 	public AtscSTT getAtscStt()
225 	{
226 		auto __p = gst_mpegts_section_get_atsc_stt(gstMpegtsSection);
227 
228 		if(__p is null)
229 		{
230 			return null;
231 		}
232 
233 		return ObjectG.getDObject!(AtscSTT)(cast(GstMpegtsAtscSTT*) __p);
234 	}
235 
236 	/**
237 	 * Returns the #GstMpegtsAtscVCT contained in the @section
238 	 *
239 	 * Returns: The #GstMpegtsAtscVCT contained in the section, or %NULL if an error
240 	 *     happened.
241 	 */
242 	public AtscVCT getAtscTvct()
243 	{
244 		auto __p = gst_mpegts_section_get_atsc_tvct(gstMpegtsSection);
245 
246 		if(__p is null)
247 		{
248 			return null;
249 		}
250 
251 		return ObjectG.getDObject!(AtscVCT)(cast(GstMpegtsAtscVCT*) __p);
252 	}
253 
254 	/**
255 	 * Returns the #GstMpegtsBAT contained in the @section.
256 	 *
257 	 * Returns: The #GstMpegtsBAT contained in the section, or %NULL if an error
258 	 *     happened.
259 	 */
260 	public BAT getBat()
261 	{
262 		auto __p = gst_mpegts_section_get_bat(gstMpegtsSection);
263 
264 		if(__p is null)
265 		{
266 			return null;
267 		}
268 
269 		return ObjectG.getDObject!(BAT)(cast(GstMpegtsBAT*) __p);
270 	}
271 
272 	/**
273 	 * Returns the array of #GstMpegtsDescriptor contained in the Conditional
274 	 * Access Table.
275 	 *
276 	 * Returns: The
277 	 *     #GstMpegtsDescriptor contained in the section, or %NULL if an error
278 	 *     happened. Release with #g_array_unref when done.
279 	 */
280 	public PtrArray getCat()
281 	{
282 		auto __p = gst_mpegts_section_get_cat(gstMpegtsSection);
283 
284 		if(__p is null)
285 		{
286 			return null;
287 		}
288 
289 		return new PtrArray(cast(GPtrArray*) __p);
290 	}
291 
292 	/**
293 	 * Gets the original unparsed section data.
294 	 *
295 	 * Returns: The original unparsed section data.
296 	 */
297 	public Bytes getData()
298 	{
299 		auto __p = gst_mpegts_section_get_data(gstMpegtsSection);
300 
301 		if(__p is null)
302 		{
303 			return null;
304 		}
305 
306 		return new Bytes(cast(GBytes*) __p, true);
307 	}
308 
309 	/**
310 	 * Returns the #GstMpegtsEIT contained in the @section.
311 	 *
312 	 * Returns: The #GstMpegtsEIT contained in the section, or %NULL if an error
313 	 *     happened.
314 	 */
315 	public EIT getEit()
316 	{
317 		auto __p = gst_mpegts_section_get_eit(gstMpegtsSection);
318 
319 		if(__p is null)
320 		{
321 			return null;
322 		}
323 
324 		return ObjectG.getDObject!(EIT)(cast(GstMpegtsEIT*) __p);
325 	}
326 
327 	/**
328 	 * Returns the #GstMpegtsNIT contained in the @section.
329 	 *
330 	 * Returns: The #GstMpegtsNIT contained in the section, or %NULL if an error
331 	 *     happened.
332 	 */
333 	public NIT getNit()
334 	{
335 		auto __p = gst_mpegts_section_get_nit(gstMpegtsSection);
336 
337 		if(__p is null)
338 		{
339 			return null;
340 		}
341 
342 		return ObjectG.getDObject!(NIT)(cast(GstMpegtsNIT*) __p);
343 	}
344 
345 	/**
346 	 * Parses a Program Association Table (ITU H.222.0, ISO/IEC 13818-1).
347 	 *
348 	 * Returns the array of #GstMpegtsPatProgram contained in the section.
349 	 *
350 	 * Note: The PAT "transport_id" field corresponds to the "subtable_extension"
351 	 * field of the provided @section.
352 	 *
353 	 * Returns: The
354 	 *     #GstMpegtsPatProgram contained in the section, or %NULL if an error
355 	 *     happened. Release with #g_ptr_array_unref when done.
356 	 */
357 	public PtrArray getPat()
358 	{
359 		auto __p = gst_mpegts_section_get_pat(gstMpegtsSection);
360 
361 		if(__p is null)
362 		{
363 			return null;
364 		}
365 
366 		return new PtrArray(cast(GPtrArray*) __p);
367 	}
368 
369 	/**
370 	 * Returns the #GstMpegtsPMT contained in the @section.
371 	 *
372 	 * Returns: The #GstMpegtsPMT contained in the section, or %NULL if an error
373 	 *     happened.
374 	 */
375 	public PMT getPmt()
376 	{
377 		auto __p = gst_mpegts_section_get_pmt(gstMpegtsSection);
378 
379 		if(__p is null)
380 		{
381 			return null;
382 		}
383 
384 		return ObjectG.getDObject!(PMT)(cast(GstMpegtsPMT*) __p);
385 	}
386 
387 	/**
388 	 * Returns the #GstMpegtsSCTESIT contained in the @section.
389 	 *
390 	 * Returns: The #GstMpegtsSCTESIT contained in the section, or %NULL if an error
391 	 *     happened.
392 	 */
393 	public SCTESIT getScteSit()
394 	{
395 		auto __p = gst_mpegts_section_get_scte_sit(gstMpegtsSection);
396 
397 		if(__p is null)
398 		{
399 			return null;
400 		}
401 
402 		return ObjectG.getDObject!(SCTESIT)(cast(GstMpegtsSCTESIT*) __p);
403 	}
404 
405 	/**
406 	 * Returns the #GstMpegtsSDT contained in the @section.
407 	 *
408 	 * Returns: The #GstMpegtsSDT contained in the section, or %NULL if an error
409 	 *     happened.
410 	 */
411 	public SDT getSdt()
412 	{
413 		auto __p = gst_mpegts_section_get_sdt(gstMpegtsSection);
414 
415 		if(__p is null)
416 		{
417 			return null;
418 		}
419 
420 		return ObjectG.getDObject!(SDT)(cast(GstMpegtsSDT*) __p);
421 	}
422 
423 	/**
424 	 * Returns the #GstDateTime of the TDT
425 	 *
426 	 * Returns: The #GstDateTime contained in the section, or %NULL
427 	 *     if an error happened. Release with #gst_date_time_unref when done.
428 	 */
429 	public DateTime getTdt()
430 	{
431 		auto __p = gst_mpegts_section_get_tdt(gstMpegtsSection);
432 
433 		if(__p is null)
434 		{
435 			return null;
436 		}
437 
438 		return ObjectG.getDObject!(DateTime)(cast(GstDateTime*) __p, true);
439 	}
440 
441 	/**
442 	 * Returns the #GstMpegtsTOT contained in the @section.
443 	 *
444 	 * Returns: The #GstMpegtsTOT contained in the section, or %NULL if an error
445 	 *     happened.
446 	 */
447 	public TOT getTot()
448 	{
449 		auto __p = gst_mpegts_section_get_tot(gstMpegtsSection);
450 
451 		if(__p is null)
452 		{
453 			return null;
454 		}
455 
456 		return ObjectG.getDObject!(TOT)(cast(GstMpegtsTOT*) __p);
457 	}
458 
459 	/**
460 	 * Returns the array of #GstMpegtsDescriptor contained in the section
461 	 *
462 	 * Returns: The
463 	 *     #GstMpegtsDescriptor contained in the section, or %NULL if an error
464 	 *     happened. Release with #g_array_unref when done.
465 	 */
466 	public PtrArray getTsdt()
467 	{
468 		auto __p = gst_mpegts_section_get_tsdt(gstMpegtsSection);
469 
470 		if(__p is null)
471 		{
472 			return null;
473 		}
474 
475 		return new PtrArray(cast(GPtrArray*) __p);
476 	}
477 
478 	/**
479 	 * If the data in @section has already been packetized, the data pointer is returned
480 	 * immediately. Otherwise, the data field is allocated and populated.
481 	 *
482 	 * Returns: pointer to section data, or %NULL on fail
483 	 */
484 	public ubyte[] packetize()
485 	{
486 		size_t outputSize;
487 
488 		auto __p = gst_mpegts_section_packetize(gstMpegtsSection, &outputSize);
489 
490 		return __p[0 .. outputSize];
491 	}
492 
493 	/**
494 	 * Creates a custom #GstEvent with a @GstMpegtsSection.
495 	 * The #GstEvent is sent to the @element #GstElement.
496 	 *
497 	 * Params:
498 	 *     element = The #GstElement to send to section event to
499 	 *
500 	 * Returns: %TRUE if the event is sent
501 	 */
502 	public bool sendEvent(Element element)
503 	{
504 		return gst_mpegts_section_send_event(gstMpegtsSection, (element is null) ? null : element.getElementStruct()) != 0;
505 	}
506 
507 	/**
508 	 *
509 	 * Params:
510 	 *     mgt = a #GstMpegtsAtscMGT to create the #GstMpegtsSection from
511 	 * Returns: the #GstMpegtsSection
512 	 *
513 	 * Since: 1.18
514 	 */
515 	public static Section fromAtscMgt(AtscMGT mgt)
516 	{
517 		auto __p = gst_mpegts_section_from_atsc_mgt((mgt is null) ? null : mgt.getAtscMGTStruct());
518 
519 		if(__p is null)
520 		{
521 			return null;
522 		}
523 
524 		return ObjectG.getDObject!(Section)(cast(GstMpegtsSection*) __p, true);
525 	}
526 
527 	/** */
528 	public static Section fromAtscRrt(AtscRRT rrt)
529 	{
530 		auto __p = gst_mpegts_section_from_atsc_rrt((rrt is null) ? null : rrt.getAtscRRTStruct());
531 
532 		if(__p is null)
533 		{
534 			return null;
535 		}
536 
537 		return ObjectG.getDObject!(Section)(cast(GstMpegtsSection*) __p, true);
538 	}
539 
540 	/** */
541 	public static Section fromAtscStt(AtscSTT stt)
542 	{
543 		auto __p = gst_mpegts_section_from_atsc_stt((stt is null) ? null : stt.getAtscSTTStruct());
544 
545 		if(__p is null)
546 		{
547 			return null;
548 		}
549 
550 		return ObjectG.getDObject!(Section)(cast(GstMpegtsSection*) __p, true);
551 	}
552 
553 	/**
554 	 * Ownership of @nit is taken. The data in @nit is managed by the #GstMpegtsSection
555 	 *
556 	 * Params:
557 	 *     nit = a #GstMpegtsNIT to create the #GstMpegtsSection from
558 	 *
559 	 * Returns: the #GstMpegtsSection
560 	 */
561 	public static Section fromNit(NIT nit)
562 	{
563 		auto __p = gst_mpegts_section_from_nit((nit is null) ? null : nit.getNITStruct());
564 
565 		if(__p is null)
566 		{
567 			return null;
568 		}
569 
570 		return ObjectG.getDObject!(Section)(cast(GstMpegtsSection*) __p, true);
571 	}
572 
573 	/**
574 	 * Creates a PAT #GstMpegtsSection from the @programs array of #GstMpegtsPatPrograms
575 	 *
576 	 * Params:
577 	 *     programs = an array of #GstMpegtsPatProgram
578 	 *     tsId = Transport stream ID of the PAT
579 	 *
580 	 * Returns: a #GstMpegtsSection
581 	 */
582 	public static Section fromPat(PtrArray programs, ushort tsId)
583 	{
584 		auto __p = gst_mpegts_section_from_pat((programs is null) ? null : programs.getPtrArrayStruct(), tsId);
585 
586 		if(__p is null)
587 		{
588 			return null;
589 		}
590 
591 		return ObjectG.getDObject!(Section)(cast(GstMpegtsSection*) __p, true);
592 	}
593 
594 	/**
595 	 * Creates a #GstMpegtsSection from @pmt that is bound to @pid
596 	 *
597 	 * Params:
598 	 *     pmt = a #GstMpegtsPMT to create a #GstMpegtsSection from
599 	 *     pid = The PID that the #GstMpegtsPMT belongs to
600 	 *
601 	 * Returns: #GstMpegtsSection
602 	 */
603 	public static Section fromPmt(PMT pmt, ushort pid)
604 	{
605 		auto __p = gst_mpegts_section_from_pmt((pmt is null) ? null : pmt.getPMTStruct(), pid);
606 
607 		if(__p is null)
608 		{
609 			return null;
610 		}
611 
612 		return ObjectG.getDObject!(Section)(cast(GstMpegtsSection*) __p, true);
613 	}
614 
615 	/**
616 	 * Ownership of @sit is taken. The data in @sit is managed by the #GstMpegtsSection
617 	 *
618 	 * Params:
619 	 *     sit = a #GstMpegtsSCTESIT to create the #GstMpegtsSection from
620 	 *
621 	 * Returns: the #GstMpegtsSection
622 	 */
623 	public static Section fromScteSit(SCTESIT sit, ushort pid)
624 	{
625 		auto __p = gst_mpegts_section_from_scte_sit((sit is null) ? null : sit.getSCTESITStruct(), pid);
626 
627 		if(__p is null)
628 		{
629 			return null;
630 		}
631 
632 		return ObjectG.getDObject!(Section)(cast(GstMpegtsSection*) __p, true);
633 	}
634 
635 	/**
636 	 * Ownership of @sdt is taken. The data in @sdt is managed by the #GstMpegtsSection
637 	 *
638 	 * Params:
639 	 *     sdt = a #GstMpegtsSDT to create the #GstMpegtsSection from
640 	 *
641 	 * Returns: the #GstMpegtsSection
642 	 */
643 	public static Section fromSdt(SDT sdt)
644 	{
645 		auto __p = gst_mpegts_section_from_sdt((sdt is null) ? null : sdt.getSDTStruct());
646 
647 		if(__p is null)
648 		{
649 			return null;
650 		}
651 
652 		return ObjectG.getDObject!(Section)(cast(GstMpegtsSection*) __p, true);
653 	}
654 
655 	/**
656 	 * Extracts the #GstMpegtsSection contained in the @event #GstEvent
657 	 *
658 	 * Params:
659 	 *     event = #GstEvent containing a #GstMpegtsSection
660 	 *
661 	 * Returns: The extracted #GstMpegtsSection
662 	 */
663 	public static Section eventParseMpegtsSection(Event event)
664 	{
665 		auto __p = gst_event_parse_mpegts_section((event is null) ? null : event.getEventStruct());
666 
667 		if(__p is null)
668 		{
669 			return null;
670 		}
671 
672 		return ObjectG.getDObject!(Section)(cast(GstMpegtsSection*) __p, true);
673 	}
674 
675 	/**
676 	 * Creates a new #GstMessage for a @GstMpegtsSection.
677 	 *
678 	 * Params:
679 	 *     parent = The creator of the message
680 	 *     section = The #GstMpegtsSection to put in a message
681 	 *
682 	 * Returns: The new #GstMessage to be posted, or %NULL if the
683 	 *     section is not valid.
684 	 */
685 	public static Message messageNewMpegtsSection(ObjectGst parent, Section section)
686 	{
687 		auto __p = gst_message_new_mpegts_section((parent is null) ? null : parent.getObjectGstStruct(), (section is null) ? null : section.getSectionStruct());
688 
689 		if(__p is null)
690 		{
691 			return null;
692 		}
693 
694 		return ObjectG.getDObject!(Message)(cast(GstMessage*) __p, true);
695 	}
696 
697 	/**
698 	 * Returns the #GstMpegtsSection contained in a message.
699 	 *
700 	 * Params:
701 	 *     message = a #GstMessage
702 	 *
703 	 * Returns: the contained #GstMpegtsSection, or %NULL.
704 	 */
705 	public static Section messageParseMpegtsSection(Message message)
706 	{
707 		auto __p = gst_message_parse_mpegts_section((message is null) ? null : message.getMessageStruct());
708 
709 		if(__p is null)
710 		{
711 			return null;
712 		}
713 
714 		return ObjectG.getDObject!(Section)(cast(GstMpegtsSection*) __p, true);
715 	}
716 }