11/*
2- * Copyright (c) 2019 Neil C Smith
2+ * Copyright (c) 2021 Neil C Smith
33 * Copyright (c) 2014 Tom Greenwood <[email protected] > 44 * Copyright (c) 2009 Andres Colubri
55 * Copyright (c) 2007 Wayne Meissner
2222
2323import java .io .File ;
2424import java .net .URI ;
25+ import java .util .EnumSet ;
26+ import java .util .Set ;
2527import org .freedesktop .gstreamer .Bus ;
2628
2729import org .freedesktop .gstreamer .Element ;
2830import org .freedesktop .gstreamer .Format ;
31+ import org .freedesktop .gstreamer .Gst ;
2932import org .freedesktop .gstreamer .Pad ;
3033import org .freedesktop .gstreamer .Pipeline ;
3134import org .freedesktop .gstreamer .TagList ;
35+ import org .freedesktop .gstreamer .glib .NativeFlags ;
3236import org .freedesktop .gstreamer .lowlevel .GstAPI .GstCallback ;
3337
3438/**
3741 * and/or video player.
3842 * <p>
3943 * See upstream documentation at
40- * <a href="https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gst-plugins-base-plugins/html/gst-plugins-base-plugins- playbin.html"
41- * >https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gst-plugins-base-plugins/html/gst-plugins-base-plugins- playbin.html</a>
44+ * <a href="https://gstreamer.freedesktop.org/documentation/playback/ playbin.html"
45+ * >https://gstreamer.freedesktop.org/documentation/playback/ playbin.html</a>
4246 * <p>
4347 * <p>
4448 * It can handle both audio and video files and features
@@ -205,6 +209,37 @@ private void setElement(String key, Element element) {
205209 set (key , element );
206210 }
207211
212+ /**
213+ * Set the flags to control the behaviour of this PlayBin.
214+ * <p>
215+ * The default value is
216+ * soft-colorbalance+deinterlace+soft-volume+text+audio+video
217+ * <p>
218+ * See individual {@link PlayFlags} value descriptions for more information.
219+ *
220+ * @param flags set of {@link PlayFlags}
221+ */
222+ public void setFlags (Set <PlayFlags > flags ) {
223+ set ("flags" , NativeFlags .toInt (flags ));
224+ }
225+
226+ /**
227+ * Get the current flags set on this PlayBin. The returned set will be
228+ * writable so that it can be altered and passed back to
229+ * {@link #setFlags(java.util.Set)}.
230+ *
231+ * @return set of current {@link PlayFlags}
232+ */
233+ public Set <PlayFlags > getFlags () {
234+ Object flags = get ("flags" );
235+ if (flags instanceof Number ) {
236+ return NativeFlags .fromInt (PlayFlags .class ,
237+ ((Number ) flags ).intValue ());
238+ } else {
239+ return EnumSet .noneOf (PlayFlags .class );
240+ }
241+ }
242+
208243 /**
209244 * Sets the audio playback volume.
210245 *
@@ -330,17 +365,6 @@ public TagList getTextTags(int textStreamIndex) {
330365 return emit (TagList .class , "get-text-tags" , textStreamIndex );
331366 }
332367
333- /**
334- * Signal emitted when the current uri is about to finish. You can set the
335- * uri and suburi to make sure that playback continues.
336- */
337- public static interface ABOUT_TO_FINISH {
338-
339- /**
340- */
341- public void aboutToFinish (PlayBin element );
342- }
343-
344368 /**
345369 * Adds a listener for the <code>about-to-finish</code> signal
346370 */
@@ -362,18 +386,6 @@ public void disconnect(ABOUT_TO_FINISH listener) {
362386 disconnect (ABOUT_TO_FINISH .class , listener );
363387 }
364388
365- /**
366- * Signal is emitted whenever the number or order of the video streams has
367- * changed. The application will most likely want to select a new video
368- * stream.
369- */
370- public static interface VIDEO_CHANGED {
371-
372- /**
373- */
374- public void videoChanged (PlayBin element );
375- }
376-
377389 /**
378390 * Adds a listener for the <code>video-changed</code> signal
379391 */
@@ -395,18 +407,6 @@ public void disconnect(VIDEO_CHANGED listener) {
395407 disconnect (VIDEO_CHANGED .class , listener );
396408 }
397409
398- /**
399- * Signal is emitted whenever the number or order of the audio streams has
400- * changed. The application will most likely want to select a new audio
401- * stream.
402- */
403- public static interface AUDIO_CHANGED {
404-
405- /**
406- */
407- public void audioChanged (PlayBin element );
408- }
409-
410410 /**
411411 * Adds a listener for the <code>audio-changed</code> signal
412412 */
@@ -428,18 +428,6 @@ public void disconnect(AUDIO_CHANGED listener) {
428428 disconnect (AUDIO_CHANGED .class , listener );
429429 }
430430
431- /**
432- * Signal is emitted whenever the number or order of the audio streams has
433- * changed. The application will most likely want to select a new audio
434- * stream.
435- */
436- public static interface TEXT_CHANGED {
437-
438- /**
439- */
440- public void textChanged (PlayBin element );
441- }
442-
443431 /**
444432 * Adds a listener for the <code>audio-changed</code> signal
445433 */
@@ -461,18 +449,6 @@ public void disconnect(TEXT_CHANGED listener) {
461449 disconnect (TEXT_CHANGED .class , listener );
462450 }
463451
464- /**
465- * Signal is emitted whenever the tags of a video stream have changed. The
466- * application will most likely want to get the new tags.
467- */
468- public static interface VIDEO_TAGS_CHANGED {
469-
470- /**
471- * @param stream stream index with changed tags
472- */
473- public void videoTagsChanged (PlayBin element , int stream );
474- }
475-
476452 /**
477453 * Adds a listener for the <code>video-tags-changed</code> signal
478454 */
@@ -494,18 +470,6 @@ public void disconnect(VIDEO_TAGS_CHANGED listener) {
494470 disconnect (VIDEO_TAGS_CHANGED .class , listener );
495471 }
496472
497- /**
498- * Signal is emitted whenever the tags of an audio stream have changed. The
499- * application will most likely want to get the new tags.
500- */
501- public static interface AUDIO_TAGS_CHANGED {
502-
503- /**
504- * @param stream stream index with changed tags
505- */
506- public void audioTagsChanged (PlayBin element , int stream );
507- }
508-
509473 /**
510474 * Adds a listener for the <code>audio-tags-changed</code> signal
511475 */
@@ -527,18 +491,6 @@ public void disconnect(AUDIO_TAGS_CHANGED listener) {
527491 disconnect (AUDIO_TAGS_CHANGED .class , listener );
528492 }
529493
530- /**
531- * Signal is emitted whenever the tags of a text stream have changed. The
532- * application will most likely want to get the new tags.
533- */
534- public static interface TEXT_TAGS_CHANGED {
535-
536- /**
537- * @param stream stream index with changed tags
538- */
539- public void textTagsChanged (PlayBin element , int stream );
540- }
541-
542494 /**
543495 * Adds a listener for the <code>audio-tags-changed</code> signal
544496 */
@@ -559,4 +511,180 @@ public void callback(PlayBin elem, int stream) {
559511 public void disconnect (TEXT_TAGS_CHANGED listener ) {
560512 disconnect (TEXT_TAGS_CHANGED .class , listener );
561513 }
514+
515+ /**
516+ * Add a listener for the <code>element-setup</code> signal.
517+ *
518+ * @param listener listener to add
519+ */
520+ @ Gst .Since (minor = 10 )
521+ public void connect (final ELEMENT_SETUP listener ) {
522+ Gst .checkVersion (1 , 10 );
523+ connect (ELEMENT_SETUP .class , listener , new GstCallback () {
524+ @ SuppressWarnings ("unused" )
525+ public void callback (PlayBin playbin , Element element ) {
526+ listener .elementSetup (playbin , element );
527+ }
528+ });
529+ }
530+
531+ /**
532+ * Remove listener for the <code>element-setup</code> signal.
533+ *
534+ * @param listener listener to remove
535+ */
536+ @ Gst .Since (minor = 10 )
537+ public void disconnect (ELEMENT_SETUP listener ) {
538+ disconnect (ELEMENT_SETUP .class , listener );
539+ }
540+
541+ /**
542+ * Add a listener for the <code>source-setup</code> signal.
543+ *
544+ * @param listener listener to add
545+ */
546+ public void connect (final SOURCE_SETUP listener ) {
547+ connect (SOURCE_SETUP .class , listener , new GstCallback () {
548+ @ SuppressWarnings ("unused" )
549+ public void callback (PlayBin playbin , Element element ) {
550+ listener .sourceSetup (playbin , element );
551+ }
552+ });
553+ }
554+
555+ /**
556+ * Remove listener for the <code>source-setup</code> signal.
557+ *
558+ * @param listener listener to remove
559+ */
560+ public void disconnect (SOURCE_SETUP listener ) {
561+ disconnect (SOURCE_SETUP .class , listener );
562+ }
563+
564+ /**
565+ * Signal emitted when the current uri is about to finish. You can set the
566+ * uri and suburi to make sure that playback continues.
567+ */
568+ public static interface ABOUT_TO_FINISH {
569+
570+ /**
571+ */
572+ public void aboutToFinish (PlayBin element );
573+ }
574+
575+ /**
576+ * Signal is emitted whenever the number or order of the video streams has
577+ * changed. The application will most likely want to select a new video
578+ * stream.
579+ */
580+ public static interface VIDEO_CHANGED {
581+
582+ /**
583+ */
584+ public void videoChanged (PlayBin element );
585+ }
586+
587+ /**
588+ * Signal is emitted whenever the number or order of the audio streams has
589+ * changed. The application will most likely want to select a new audio
590+ * stream.
591+ */
592+ public static interface AUDIO_CHANGED {
593+
594+ /**
595+ */
596+ public void audioChanged (PlayBin element );
597+ }
598+
599+ /**
600+ * Signal is emitted whenever the number or order of the audio streams has
601+ * changed. The application will most likely want to select a new audio
602+ * stream.
603+ */
604+ public static interface TEXT_CHANGED {
605+
606+ /**
607+ */
608+ public void textChanged (PlayBin element );
609+ }
610+
611+ /**
612+ * Signal is emitted whenever the tags of a video stream have changed. The
613+ * application will most likely want to get the new tags.
614+ */
615+ public static interface VIDEO_TAGS_CHANGED {
616+
617+ /**
618+ * @param stream stream index with changed tags
619+ */
620+ public void videoTagsChanged (PlayBin element , int stream );
621+ }
622+
623+ /**
624+ * Signal is emitted whenever the tags of an audio stream have changed. The
625+ * application will most likely want to get the new tags.
626+ */
627+ public static interface AUDIO_TAGS_CHANGED {
628+
629+ /**
630+ * @param stream stream index with changed tags
631+ */
632+ public void audioTagsChanged (PlayBin element , int stream );
633+ }
634+
635+ /**
636+ * Signal is emitted whenever the tags of a text stream have changed. The
637+ * application will most likely want to get the new tags.
638+ */
639+ public static interface TEXT_TAGS_CHANGED {
640+
641+ /**
642+ * @param stream stream index with changed tags
643+ */
644+ public void textTagsChanged (PlayBin element , int stream );
645+ }
646+
647+ /**
648+ * This signal is emitted when a new element is added to playbin or any of
649+ * its sub-bins. This signal can be used to configure elements, e.g. to set
650+ * properties on decoders. This is functionally equivalent to connecting to
651+ * the deep-element-added signal, but more convenient.
652+ * <p>
653+ * This signal is usually emitted from the context of a GStreamer streaming
654+ * thread, so might be called at the same time as code running in the main
655+ * application thread.
656+ */
657+ @ Gst .Since (minor = 10 )
658+ public static interface ELEMENT_SETUP {
659+
660+ /**
661+ * Element setup signal callback.
662+ *
663+ * @param playbin signal source
664+ * @param element added element
665+ */
666+ public void elementSetup (PlayBin playbin , Element element );
667+ }
668+
669+ /**
670+ * This signal is emitted after the source element has been created, so it
671+ * can be configured by setting additional properties (e.g. set a proxy
672+ * server for an http source, or set the device and read speed for an audio
673+ * cd source). This is functionally equivalent to connecting to the
674+ * notify::source signal, but more convenient.
675+ * <p>
676+ * This signal is usually emitted from the context of a GStreamer streaming
677+ * thread.
678+ */
679+ public static interface SOURCE_SETUP {
680+
681+ /**
682+ * Source setup signal callback.
683+ *
684+ * @param playbin signal source
685+ * @param element source element added
686+ */
687+ public void sourceSetup (PlayBin playbin , Element element );
688+ }
689+
562690}
0 commit comments