2016-06-29 16:14:51 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
|
|
|
|
* Copyright (C) <2011> Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
|
|
|
* Copyright (C) <2013> Collabora Ltd.
|
|
|
|
* Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
|
|
|
* Copyright (C) <2015> Jan Schmidt <jan@centricular.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* SECTION:element-playbin3
|
2017-01-23 19:36:11 +00:00
|
|
|
* @title: playbin3
|
2016-06-29 16:14:51 +00:00
|
|
|
*
|
2016-07-22 13:21:36 +00:00
|
|
|
* playbin3 provides a stand-alone everything-in-one abstraction for an
|
|
|
|
* audio and/or video player. It differs from the previous playbin (playbin2)
|
|
|
|
* by supporting publication and selection of available streams via the
|
|
|
|
* #GstStreamCollection message and #GST_EVENT_SELECT_STREAMS event API.
|
2016-06-29 16:14:51 +00:00
|
|
|
*
|
2016-07-22 13:21:36 +00:00
|
|
|
* playbin3 can handle both audio and video files and features
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
|
|
|
* * automatic file type recognition and based on that automatic
|
2016-06-29 16:14:51 +00:00
|
|
|
* selection and usage of the right audio/video/subtitle demuxers/decoders
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
2019-08-29 17:42:39 +00:00
|
|
|
* * auxiliary files - such as external subtitles and audio tracks
|
2017-01-23 19:36:11 +00:00
|
|
|
* * visualisations for audio files
|
|
|
|
* * subtitle support for video files. Subtitles can be store in external
|
|
|
|
* files.
|
|
|
|
* * stream selection between different video/audio/subtitles streams
|
|
|
|
* * meta info (tag) extraction
|
|
|
|
* * easy access to the last video sample
|
|
|
|
* * buffering when playing streams over a network
|
|
|
|
* * volume control with mute option
|
|
|
|
*
|
|
|
|
* ## Usage
|
|
|
|
*
|
2016-07-22 13:21:36 +00:00
|
|
|
* A playbin element can be created just like any other element using
|
2016-06-29 16:14:51 +00:00
|
|
|
* gst_element_factory_make(). The file/URI to play should be set via the #GstPlayBin3:uri
|
|
|
|
* property. This must be an absolute URI, relative file paths are not allowed.
|
|
|
|
* Example URIs are file:///home/joe/movie.avi or http://www.joedoe.com/foo.ogg
|
|
|
|
*
|
2016-07-22 11:52:12 +00:00
|
|
|
* Playbin3 is a #GstPipeline. It will notify the application of everything
|
2016-06-29 16:14:51 +00:00
|
|
|
* that's happening (errors, end of stream, tags found, state changes, etc.)
|
|
|
|
* by posting messages on its #GstBus. The application needs to watch the
|
|
|
|
* bus.
|
|
|
|
*
|
|
|
|
* Playback can be initiated by setting the element to PLAYING state using
|
|
|
|
* gst_element_set_state(). Note that the state change will take place in
|
|
|
|
* the background in a separate thread, when the function returns playback
|
2019-08-29 17:42:39 +00:00
|
|
|
* is probably not happening yet and any errors might not have occurred yet.
|
2016-07-22 11:52:12 +00:00
|
|
|
* Applications using playbin3 should ideally be written to deal with things
|
2016-06-29 16:14:51 +00:00
|
|
|
* completely asynchroneous.
|
|
|
|
*
|
|
|
|
* When playback has finished (an EOS message has been received on the bus)
|
2019-08-29 17:42:39 +00:00
|
|
|
* or an error has occurred (an ERROR message has been received on the bus) or
|
2016-07-22 11:52:12 +00:00
|
|
|
* the user wants to play a different track, playbin3 should be set back to
|
2016-06-29 16:14:51 +00:00
|
|
|
* READY or NULL state, then the #GstPlayBin3:uri property should be set to the
|
2016-07-22 11:52:12 +00:00
|
|
|
* new location and then playbin3 be set to PLAYING state again.
|
2016-06-29 16:14:51 +00:00
|
|
|
*
|
|
|
|
* Seeking can be done using gst_element_seek_simple() or gst_element_seek()
|
2016-07-22 11:52:12 +00:00
|
|
|
* on the playbin3 element. Again, the seek will not be executed
|
2016-06-29 16:14:51 +00:00
|
|
|
* instantaneously, but will be done in a background thread. When the seek
|
|
|
|
* call returns the seek will most likely still be in process. An application
|
|
|
|
* may wait for the seek to finish (or fail) using gst_element_get_state() with
|
|
|
|
* -1 as the timeout, but this will block the user interface and is not
|
|
|
|
* recommended at all.
|
|
|
|
*
|
|
|
|
* Applications may query the current position and duration of the stream
|
|
|
|
* via gst_element_query_position() and gst_element_query_duration() and
|
|
|
|
* setting the format passed to GST_FORMAT_TIME. If the query was successful,
|
|
|
|
* the duration or position will have been returned in units of nanoseconds.
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
2020-07-02 12:25:27 +00:00
|
|
|
* ## Selecting streams
|
|
|
|
*
|
|
|
|
* The recommended way to select streams (instead of the default selection) is
|
|
|
|
* to listen to GST_MESSAGE_STREAM_COLLECTION messages on the GstBus and send a
|
|
|
|
* GST_EVENT_SELECT_STREAMS on the pipeline with the selected streams. This
|
|
|
|
* provides more information and flexibility compared to the legacy #GstPlayBin
|
|
|
|
* property and signal-based mechanism.
|
|
|
|
*
|
|
|
|
* Note: The application should not assume that collections will not change
|
|
|
|
* throughout a single file. If it wishes to modify the default selection, it
|
|
|
|
* should always respond to new collections posted on the bus with a
|
|
|
|
* GST_EVENT_SELECT_STREAMS.
|
|
|
|
*
|
2017-01-23 19:36:11 +00:00
|
|
|
* ## Advanced Usage: specifying the audio and video sink
|
|
|
|
*
|
2016-06-29 16:14:51 +00:00
|
|
|
* By default, if no audio sink or video sink has been specified via the
|
2016-07-22 11:52:12 +00:00
|
|
|
* #GstPlayBin3:audio-sink or #GstPlayBin3:video-sink property, playbin3 will use the autoaudiosink
|
2016-06-29 16:14:51 +00:00
|
|
|
* and autovideosink elements to find the first-best available output method.
|
|
|
|
* This should work in most cases, but is not always desirable. Often either
|
|
|
|
* the user or application might want to specify more explicitly what to use
|
|
|
|
* for audio and video output.
|
|
|
|
*
|
|
|
|
* If the application wants more control over how audio or video should be
|
|
|
|
* output, it may create the audio/video sink elements itself (for example
|
2016-07-22 11:52:12 +00:00
|
|
|
* using gst_element_factory_make()) and provide them to playbin3 using the
|
2016-06-29 16:14:51 +00:00
|
|
|
* #GstPlayBin3:audio-sink or #GstPlayBin3:video-sink property.
|
|
|
|
*
|
|
|
|
* GNOME-based applications, for example, will usually want to create
|
2016-07-22 11:52:12 +00:00
|
|
|
* gconfaudiosink and gconfvideosink elements and make playbin3 use those,
|
2016-06-29 16:14:51 +00:00
|
|
|
* so that output happens to whatever the user has configured in the GNOME
|
|
|
|
* Multimedia System Selector configuration dialog.
|
|
|
|
*
|
|
|
|
* The sink elements do not necessarily need to be ready-made sinks. It is
|
2016-07-22 11:52:12 +00:00
|
|
|
* possible to create container elements that look like a sink to playbin3,
|
2016-06-29 16:14:51 +00:00
|
|
|
* but in reality contain a number of custom elements linked together. This
|
|
|
|
* can be achieved by creating a #GstBin and putting elements in there and
|
|
|
|
* linking them, and then creating a sink #GstGhostPad for the bin and pointing
|
|
|
|
* it to the sink pad of the first element within the bin. This can be used
|
|
|
|
* for a number of purposes, for example to force output to a particular
|
|
|
|
* format or to modify or observe the data before it is output.
|
|
|
|
*
|
|
|
|
* It is also possible to 'suppress' audio and/or video output by using
|
|
|
|
* 'fakesink' elements (or capture it from there using the fakesink element's
|
|
|
|
* "handoff" signal, which, nota bene, is fired from the streaming thread!).
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
|
|
|
* ## Retrieving Tags and Other Meta Data
|
|
|
|
*
|
2016-06-29 16:14:51 +00:00
|
|
|
* Most of the common meta data (artist, title, etc.) can be retrieved by
|
|
|
|
* watching for TAG messages on the pipeline's bus (see above).
|
|
|
|
*
|
|
|
|
* Other more specific meta information like width/height/framerate of video
|
|
|
|
* streams or samplerate/number of channels of audio streams can be obtained
|
|
|
|
* from the negotiated caps on the sink pads of the sinks.
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
|
|
|
* ## Buffering
|
2016-07-22 11:52:12 +00:00
|
|
|
* Playbin3 handles buffering automatically for the most part, but applications
|
|
|
|
* need to handle parts of the buffering process as well. Whenever playbin3 is
|
2016-06-29 16:14:51 +00:00
|
|
|
* buffering, it will post BUFFERING messages on the bus with a percentage
|
|
|
|
* value that shows the progress of the buffering process. Applications need
|
2016-07-22 11:52:12 +00:00
|
|
|
* to set playbin3 to PLAYING or PAUSED state in response to these messages.
|
2016-06-29 16:14:51 +00:00
|
|
|
* They may also want to convey the buffering progress to the user in some
|
|
|
|
* way. Here is how to extract the percentage information from the message:
|
|
|
|
* |[
|
|
|
|
* switch (GST_MESSAGE_TYPE (msg)) {
|
|
|
|
* case GST_MESSAGE_BUFFERING: {
|
|
|
|
* gint percent = 0;
|
|
|
|
* gst_message_parse_buffering (msg, &percent);
|
|
|
|
* g_print ("Buffering (%u percent done)", percent);
|
|
|
|
* break;
|
|
|
|
* }
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
* ]|
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
2016-06-29 16:14:51 +00:00
|
|
|
* Note that applications should keep/set the pipeline in the PAUSED state when
|
|
|
|
* a BUFFERING message is received with a buffer percent value < 100 and set
|
|
|
|
* the pipeline back to PLAYING state when a BUFFERING message with a value
|
|
|
|
* of 100 percent is received (if PLAYING is the desired state, that is).
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
|
|
|
* ## Embedding the video window in your application
|
2016-07-22 11:52:12 +00:00
|
|
|
* By default, playbin3 (or rather the video sinks used) will create their own
|
2016-06-29 16:14:51 +00:00
|
|
|
* window. Applications will usually want to force output to a window of their
|
|
|
|
* own, however. This can be done using the #GstVideoOverlay interface, which most
|
|
|
|
* video sinks implement. See the documentation there for more details.
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
|
|
|
* ## Specifying which CD/DVD device to use
|
2017-09-22 14:58:14 +00:00
|
|
|
*
|
|
|
|
* The device to use for CDs/DVDs needs to be set on the source element playbin3
|
|
|
|
* creates before it is opened. The most generic way of doing this is to connect
|
|
|
|
* to playbin3's "source-setup" signal, which will be emitted by playbin3 when
|
|
|
|
* it has created the source element for a particular URI. In the signal
|
|
|
|
* callback you can check if the source element has a "device" property and set
|
|
|
|
* it appropriately. In some cases the device can also be set as part of the
|
|
|
|
* URI, but it depends on the elements involved if this will work or not. For
|
|
|
|
* example, for DVD menu playback, the following syntax might work (if the
|
|
|
|
* resindvd plugin is used): dvd://[/path/to/device]
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
|
|
|
* ## Handling redirects
|
|
|
|
*
|
2016-06-29 16:14:51 +00:00
|
|
|
* Some elements may post 'redirect' messages on the bus to tell the
|
|
|
|
* application to open another location. These are element messages containing
|
|
|
|
* a structure named 'redirect' along with a 'new-location' field of string
|
|
|
|
* type. The new location may be a relative or an absolute URI. Examples
|
|
|
|
* for such redirects can be found in many quicktime movie trailers.
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
2023-03-22 09:58:59 +00:00
|
|
|
* NOTE: playbin3 (via uridecodebin3) will handle the redirect messages if
|
|
|
|
* possible. The message will only be forwarded if it can't handle it.
|
|
|
|
*
|
2017-01-23 19:36:11 +00:00
|
|
|
* ## Examples
|
2016-06-29 16:14:51 +00:00
|
|
|
* |[
|
2016-07-22 11:52:12 +00:00
|
|
|
* gst-launch-1.0 -v playbin3 uri=file:///path/to/somefile.mp4
|
2017-01-23 19:36:11 +00:00
|
|
|
* ]|
|
|
|
|
* This will play back the given AVI video file, given that the video and
|
2016-06-29 16:14:51 +00:00
|
|
|
* audio decoders required to decode the content are installed. Since no
|
2016-07-22 11:52:12 +00:00
|
|
|
* special audio sink or video sink is supplied (via playbin3's audio-sink or
|
|
|
|
* video-sink properties) playbin3 will try to find a suitable audio and
|
2016-06-29 16:14:51 +00:00
|
|
|
* video sink automatically using the autoaudiosink and autovideosink elements.
|
|
|
|
* |[
|
2016-07-22 11:52:12 +00:00
|
|
|
* gst-launch-1.0 -v playbin3 uri=cdda://4
|
2017-01-23 19:36:11 +00:00
|
|
|
* ]|
|
|
|
|
* This will play back track 4 on an audio CD in your disc drive (assuming
|
2016-06-29 16:14:51 +00:00
|
|
|
* the drive is detected automatically by the plugin).
|
|
|
|
* |[
|
2016-07-22 11:52:12 +00:00
|
|
|
* gst-launch-1.0 -v playbin3 uri=dvd://
|
2017-01-23 19:36:11 +00:00
|
|
|
* ]|
|
|
|
|
* This will play back the DVD in your disc drive (assuming
|
2016-06-29 16:14:51 +00:00
|
|
|
* the drive is detected automatically by the plugin).
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
2016-06-29 16:14:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2022-03-25 13:59:23 +00:00
|
|
|
#include <glib/gi18n-lib.h>
|
2016-06-29 16:14:51 +00:00
|
|
|
#include <gst/pbutils/pbutils.h>
|
|
|
|
#include <gst/audio/streamvolume.h>
|
|
|
|
#include <gst/video/video-info.h>
|
|
|
|
#include <gst/video/video-multiview.h>
|
|
|
|
#include <gst/video/videooverlay.h>
|
|
|
|
#include <gst/video/navigation.h>
|
|
|
|
#include <gst/video/colorbalance.h>
|
|
|
|
#include "gstplay-enum.h"
|
2020-10-22 09:07:26 +00:00
|
|
|
#include "gstplaybackelements.h"
|
2016-06-29 16:14:51 +00:00
|
|
|
#include "gstplaysink.h"
|
|
|
|
#include "gstsubtitleoverlay.h"
|
|
|
|
#include "gstplaybackutils.h"
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_play_bin3_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_play_bin3_debug
|
|
|
|
|
|
|
|
#define GST_TYPE_PLAY_BIN (gst_play_bin3_get_type())
|
|
|
|
#define GST_PLAY_BIN3(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLAY_BIN,GstPlayBin3))
|
|
|
|
#define GST_PLAY_BIN3_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLAY_BIN,GstPlayBin3Class))
|
|
|
|
#define GST_IS_PLAY_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLAY_BIN))
|
|
|
|
#define GST_IS_PLAY_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLAY_BIN))
|
|
|
|
|
|
|
|
#define ULONG_TO_POINTER(number) ((gpointer) (guintptr) (number))
|
|
|
|
#define POINTER_TO_ULONG(number) ((guintptr) (number))
|
|
|
|
|
|
|
|
#define VOLUME_MAX_DOUBLE 10.0
|
|
|
|
|
|
|
|
typedef struct _GstPlayBin3 GstPlayBin3;
|
|
|
|
typedef struct _GstPlayBin3Class GstPlayBin3Class;
|
|
|
|
typedef struct _GstSourceCombine GstSourceCombine;
|
2017-11-09 10:17:13 +00:00
|
|
|
typedef struct _SourcePad SourcePad;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* GstSourceCombine controls all the information regarding a certain
|
|
|
|
* media type.
|
|
|
|
*
|
|
|
|
* It can control a custom combiner element (by default none)
|
|
|
|
*/
|
2016-06-29 16:14:51 +00:00
|
|
|
struct _GstSourceCombine
|
|
|
|
{
|
2017-11-09 10:17:13 +00:00
|
|
|
GstStreamType stream_type; /* The GstStreamType of the combiner */
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
GstElement *combiner; /* the combiner */
|
2022-05-06 07:10:09 +00:00
|
|
|
GPtrArray *inputpads; /* Array of sink request GstPad of the combiner */
|
2017-11-09 10:17:13 +00:00
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
GstPad *srcpad; /* the source pad of the combiner */
|
|
|
|
GstPad *sinkpad; /* the sinkpad of the sink when the combiner
|
2017-11-09 10:17:13 +00:00
|
|
|
* is linked */
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
GPtrArray *streams; /* Sorted array of GstStream for the given type */
|
|
|
|
|
|
|
|
gboolean has_active_pad; /* stream combiner has the "active-pad" property */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PLAYBIN_STREAM_AUDIO = 0,
|
|
|
|
PLAYBIN_STREAM_VIDEO,
|
|
|
|
PLAYBIN_STREAM_TEXT,
|
|
|
|
PLAYBIN_STREAM_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
/* names matching the enum above */
|
|
|
|
static const gchar *stream_type_names[] = {
|
|
|
|
"audio", "video", "text"
|
|
|
|
};
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
|
|
|
|
#define STREAM_TYPES_FORMAT "s%s%s"
|
|
|
|
#define STREAM_TYPES_ARGS(s) (s) & GST_STREAM_TYPE_AUDIO ? "audio " : "", \
|
|
|
|
(s) & GST_STREAM_TYPE_VIDEO ? "video " : "", \
|
|
|
|
(s) & GST_STREAM_TYPE_TEXT ? "text " : ""
|
|
|
|
|
|
|
|
|
|
|
|
/* a structure to hold information about a uridecodebin pad */
|
|
|
|
struct _SourcePad
|
|
|
|
{
|
|
|
|
GstPad *pad; /* The controlled pad */
|
2017-11-10 13:32:13 +00:00
|
|
|
GstStreamType stream_type; /* stream type of the controlled pad */
|
2022-05-06 07:10:09 +00:00
|
|
|
GstPad *combine_sinkpad; /* Combiner request sinkpad linked to pad */
|
2017-11-09 10:17:13 +00:00
|
|
|
gulong event_probe_id;
|
|
|
|
};
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
#define GST_PLAY_BIN3_GET_LOCK(bin) (&((GstPlayBin3*)(bin))->lock)
|
|
|
|
#define GST_PLAY_BIN3_LOCK(bin) (g_rec_mutex_lock (GST_PLAY_BIN3_GET_LOCK(bin)))
|
|
|
|
#define GST_PLAY_BIN3_UNLOCK(bin) (g_rec_mutex_unlock (GST_PLAY_BIN3_GET_LOCK(bin)))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstPlayBin3:
|
|
|
|
*
|
|
|
|
* playbin element structure
|
|
|
|
*/
|
|
|
|
struct _GstPlayBin3
|
|
|
|
{
|
|
|
|
GstPipeline parent;
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
GRecMutex lock; /* to protect various properties */
|
|
|
|
|
|
|
|
/* uridecodebin to handle uri and suburi */
|
|
|
|
GstElement *uridecodebin;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
/* List of SourcePad structures */
|
|
|
|
GList *source_pads;
|
|
|
|
|
|
|
|
/* Active stream collection */
|
|
|
|
GstStreamCollection *collection;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* combiners for different streams */
|
2016-06-29 16:14:51 +00:00
|
|
|
GstSourceCombine combiner[PLAYBIN_STREAM_LAST];
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
/* Bit-wise set of stream types we have requested from uridecodebin3. */
|
2016-06-29 16:14:51 +00:00
|
|
|
GstStreamType selected_stream_types;
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* Bit-wise set of configured output stream types (i.e. active
|
|
|
|
playsink inputs and combiners) */
|
|
|
|
GstStreamType active_stream_types;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
/* properties */
|
|
|
|
gint current_video; /* the currently selected stream */
|
|
|
|
gint current_audio; /* the currently selected stream */
|
|
|
|
gint current_text; /* the currently selected stream */
|
|
|
|
|
|
|
|
gboolean do_stream_selections; /* Set to TRUE when any of current-{video|audio|text} are set to
|
|
|
|
say playbin should do backwards-compatibility behaviours */
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
GstObject *collection_source; /* The element that provided the latest stream collection */
|
2016-06-29 16:14:51 +00:00
|
|
|
gboolean force_aspect_ratio;
|
|
|
|
|
|
|
|
/* Multiview/stereoscopic overrides */
|
|
|
|
GstVideoMultiviewFramePacking multiview_mode;
|
|
|
|
GstVideoMultiviewFlags multiview_flags;
|
|
|
|
|
|
|
|
/* our play sink */
|
|
|
|
GstPlaySink *playsink;
|
|
|
|
|
|
|
|
gboolean async_pending; /* async-start has been emitted */
|
|
|
|
|
|
|
|
gboolean have_selector; /* set to FALSE when we fail to create an
|
|
|
|
* input-selector, so that we only post a
|
|
|
|
* warning once */
|
|
|
|
|
|
|
|
gboolean video_pending_flush_finish; /* whether we are pending to send a custom
|
|
|
|
* custom-video-flush-finish event
|
|
|
|
* on pad activation */
|
|
|
|
gboolean audio_pending_flush_finish; /* whether we are pending to send a custom
|
|
|
|
* custom-audio-flush-finish event
|
|
|
|
* on pad activation */
|
|
|
|
gboolean text_pending_flush_finish; /* whether we are pending to send a custom
|
|
|
|
* custom-subtitle-flush-finish event
|
|
|
|
* on pad activation */
|
|
|
|
|
|
|
|
GstElement *audio_sink; /* configured audio sink, or NULL */
|
|
|
|
GstElement *video_sink; /* configured video sink, or NULL */
|
|
|
|
GstElement *text_sink; /* configured text sink, or NULL */
|
|
|
|
|
|
|
|
GstElement *audio_stream_combiner; /* configured audio stream combiner, or NULL */
|
|
|
|
GstElement *video_stream_combiner; /* configured video stream combiner, or NULL */
|
|
|
|
GstElement *text_stream_combiner; /* configured text stream combiner, or NULL */
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
gboolean is_live; /* Whether we are live */
|
2016-06-29 16:14:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstPlayBin3Class
|
|
|
|
{
|
|
|
|
GstPipelineClass parent_class;
|
|
|
|
|
|
|
|
/* notify app that the current uri finished decoding and it is possible to
|
|
|
|
* queue a new one for gapless playback */
|
|
|
|
void (*about_to_finish) (GstPlayBin3 * playbin);
|
|
|
|
|
|
|
|
/* get the last video sample and convert it to the given caps */
|
|
|
|
GstSample *(*convert_sample) (GstPlayBin3 * playbin, GstCaps * caps);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* props */
|
|
|
|
#define DEFAULT_URI NULL
|
|
|
|
#define DEFAULT_SUBURI NULL
|
|
|
|
#define DEFAULT_FLAGS GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_TEXT | \
|
|
|
|
GST_PLAY_FLAG_SOFT_VOLUME | GST_PLAY_FLAG_DEINTERLACE | \
|
2017-03-07 12:59:36 +00:00
|
|
|
GST_PLAY_FLAG_SOFT_COLORBALANCE | GST_PLAY_FLAG_BUFFERING
|
2016-06-29 16:14:51 +00:00
|
|
|
#define DEFAULT_CURRENT_VIDEO -1
|
|
|
|
#define DEFAULT_CURRENT_AUDIO -1
|
|
|
|
#define DEFAULT_CURRENT_TEXT -1
|
|
|
|
#define DEFAULT_SUBTITLE_ENCODING NULL
|
|
|
|
#define DEFAULT_AUDIO_SINK NULL
|
|
|
|
#define DEFAULT_VIDEO_SINK NULL
|
|
|
|
#define DEFAULT_VIS_PLUGIN NULL
|
|
|
|
#define DEFAULT_TEXT_SINK NULL
|
|
|
|
#define DEFAULT_VOLUME 1.0
|
|
|
|
#define DEFAULT_MUTE FALSE
|
|
|
|
#define DEFAULT_FRAME NULL
|
|
|
|
#define DEFAULT_FONT_DESC NULL
|
|
|
|
#define DEFAULT_CONNECTION_SPEED 0
|
|
|
|
#define DEFAULT_BUFFER_DURATION -1
|
|
|
|
#define DEFAULT_BUFFER_SIZE -1
|
|
|
|
#define DEFAULT_RING_BUFFER_MAX_SIZE 0
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_URI,
|
|
|
|
PROP_CURRENT_URI,
|
|
|
|
PROP_SUBURI,
|
|
|
|
PROP_CURRENT_SUBURI,
|
|
|
|
PROP_FLAGS,
|
|
|
|
PROP_SUBTITLE_ENCODING,
|
|
|
|
PROP_AUDIO_SINK,
|
|
|
|
PROP_VIDEO_SINK,
|
|
|
|
PROP_VIS_PLUGIN,
|
|
|
|
PROP_TEXT_SINK,
|
|
|
|
PROP_VIDEO_STREAM_COMBINER,
|
|
|
|
PROP_AUDIO_STREAM_COMBINER,
|
|
|
|
PROP_TEXT_STREAM_COMBINER,
|
|
|
|
PROP_VOLUME,
|
|
|
|
PROP_MUTE,
|
|
|
|
PROP_SAMPLE,
|
|
|
|
PROP_FONT_DESC,
|
|
|
|
PROP_CONNECTION_SPEED,
|
|
|
|
PROP_BUFFER_SIZE,
|
|
|
|
PROP_BUFFER_DURATION,
|
|
|
|
PROP_AV_OFFSET,
|
2018-10-28 14:45:26 +00:00
|
|
|
PROP_TEXT_OFFSET,
|
2016-06-29 16:14:51 +00:00
|
|
|
PROP_RING_BUFFER_MAX_SIZE,
|
|
|
|
PROP_FORCE_ASPECT_RATIO,
|
|
|
|
PROP_AUDIO_FILTER,
|
|
|
|
PROP_VIDEO_FILTER,
|
|
|
|
PROP_MULTIVIEW_MODE,
|
2022-07-21 14:43:47 +00:00
|
|
|
PROP_MULTIVIEW_FLAGS,
|
|
|
|
PROP_INSTANT_URI
|
2016-06-29 16:14:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* signals */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SIGNAL_ABOUT_TO_FINISH,
|
|
|
|
SIGNAL_CONVERT_SAMPLE,
|
|
|
|
SIGNAL_SOURCE_SETUP,
|
2016-08-08 19:04:11 +00:00
|
|
|
SIGNAL_ELEMENT_SETUP,
|
2016-06-29 16:14:51 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static void gst_play_bin3_finalize (GObject * object);
|
|
|
|
|
|
|
|
static void gst_play_bin3_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * spec);
|
|
|
|
static void gst_play_bin3_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * spec);
|
|
|
|
|
|
|
|
static GstStateChangeReturn gst_play_bin3_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
|
|
|
|
|
|
|
static void gst_play_bin3_handle_message (GstBin * bin, GstMessage * message);
|
2016-08-08 19:04:11 +00:00
|
|
|
static void gst_play_bin3_deep_element_added (GstBin * playbin,
|
|
|
|
GstBin * sub_bin, GstElement * child);
|
2016-06-29 16:14:51 +00:00
|
|
|
static gboolean gst_play_bin3_send_event (GstElement * element,
|
|
|
|
GstEvent * event);
|
|
|
|
|
|
|
|
static GstSample *gst_play_bin3_convert_sample (GstPlayBin3 * playbin,
|
|
|
|
GstCaps * caps);
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
static void reconfigure_output (GstPlayBin3 * playbin);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
/* uridecodebin3 signal callbacks */
|
|
|
|
static void pad_added_cb (GstElement * uridecodebin, GstPad * pad,
|
|
|
|
GstPlayBin3 * playbin);
|
|
|
|
static void pad_removed_cb (GstElement * decodebin, GstPad * pad,
|
|
|
|
GstPlayBin3 * playbin);
|
2016-06-29 16:14:51 +00:00
|
|
|
static gint select_stream_cb (GstElement * decodebin,
|
|
|
|
GstStreamCollection * collection, GstStream * stream,
|
2022-07-21 14:43:47 +00:00
|
|
|
GstPlayBin3 * playbin);
|
|
|
|
static void source_setup_cb (GstElement * element, GstElement * source,
|
|
|
|
GstPlayBin3 * playbin);
|
|
|
|
static void about_to_finish_cb (GstElement * uridecodebin,
|
|
|
|
GstPlayBin3 * playbin);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
static void do_stream_selection (GstPlayBin3 * playbin);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class;
|
|
|
|
|
|
|
|
static guint gst_play_bin3_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
#define REMOVE_SIGNAL(obj,id) \
|
|
|
|
if (id) { \
|
|
|
|
g_signal_handler_disconnect (obj, id); \
|
|
|
|
id = 0; \
|
|
|
|
}
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
static void gst_play_bin3_overlay_init (gpointer g_iface,
|
|
|
|
gpointer g_iface_data);
|
|
|
|
static void gst_play_bin3_navigation_init (gpointer g_iface,
|
|
|
|
gpointer g_iface_data);
|
|
|
|
static void gst_play_bin3_colorbalance_init (gpointer g_iface,
|
|
|
|
gpointer g_iface_data);
|
|
|
|
|
2020-10-22 09:07:26 +00:00
|
|
|
static void
|
|
|
|
_do_init_type (GType type)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
2020-10-22 09:07:26 +00:00
|
|
|
static const GInterfaceInfo svol_info = {
|
|
|
|
NULL, NULL, NULL
|
|
|
|
};
|
|
|
|
static const GInterfaceInfo ov_info = {
|
|
|
|
gst_play_bin3_overlay_init,
|
|
|
|
NULL, NULL
|
|
|
|
};
|
|
|
|
static const GInterfaceInfo nav_info = {
|
|
|
|
gst_play_bin3_navigation_init,
|
|
|
|
NULL, NULL
|
|
|
|
};
|
|
|
|
static const GInterfaceInfo col_info = {
|
|
|
|
gst_play_bin3_colorbalance_init,
|
|
|
|
NULL, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
g_type_add_interface_static (type, GST_TYPE_STREAM_VOLUME, &svol_info);
|
|
|
|
g_type_add_interface_static (type, GST_TYPE_VIDEO_OVERLAY, &ov_info);
|
|
|
|
g_type_add_interface_static (type, GST_TYPE_NAVIGATION, &nav_info);
|
|
|
|
g_type_add_interface_static (type, GST_TYPE_COLOR_BALANCE, &col_info);
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
2020-10-22 09:07:26 +00:00
|
|
|
static GType gst_play_bin3_get_type (void);
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstPlayBin3, gst_play_bin3, GST_TYPE_PIPELINE,
|
|
|
|
_do_init_type (g_define_type_id));
|
|
|
|
|
|
|
|
GST_ELEMENT_REGISTER_DEFINE_CUSTOM (playbin3,
|
|
|
|
gst_play_bin3_custom_element_init);
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
static void
|
|
|
|
gst_play_bin3_class_init (GstPlayBin3Class * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_klass;
|
|
|
|
GstElementClass *gstelement_klass;
|
|
|
|
GstBinClass *gstbin_klass;
|
|
|
|
|
|
|
|
gobject_klass = (GObjectClass *) klass;
|
|
|
|
gstelement_klass = (GstElementClass *) klass;
|
|
|
|
gstbin_klass = (GstBinClass *) klass;
|
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
|
|
|
gobject_klass->set_property = gst_play_bin3_set_property;
|
|
|
|
gobject_klass->get_property = gst_play_bin3_get_property;
|
|
|
|
|
|
|
|
gobject_klass->finalize = gst_play_bin3_finalize;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstPlayBin3:uri
|
|
|
|
*
|
|
|
|
* Set the next URI that playbin will play. This property can be set from the
|
|
|
|
* about-to-finish signal to queue the next media file.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_URI,
|
|
|
|
g_param_spec_string ("uri", "URI", "URI of the media to play",
|
|
|
|
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2017-11-09 10:12:08 +00:00
|
|
|
/**
|
2016-06-29 16:14:51 +00:00
|
|
|
* GstPlayBin3:current-uri
|
|
|
|
*
|
|
|
|
* The currently playing uri.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_CURRENT_URI,
|
|
|
|
g_param_spec_string ("current-uri", "Current URI",
|
|
|
|
"The currently playing URI", NULL,
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstPlayBin3:suburi
|
|
|
|
*
|
|
|
|
* Set the next subtitle URI that playbin will play. This property can be
|
|
|
|
* set from the about-to-finish signal to queue the next subtitle media file.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_SUBURI,
|
|
|
|
g_param_spec_string ("suburi", ".sub-URI", "Optional URI of a subtitle",
|
|
|
|
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstPlayBin3:current-suburi
|
|
|
|
*
|
|
|
|
* The currently playing subtitle uri.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_CURRENT_SUBURI,
|
|
|
|
g_param_spec_string ("current-suburi", "Current .sub-URI",
|
|
|
|
"The currently playing URI of a subtitle",
|
|
|
|
NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstPlayBin3:flags
|
|
|
|
*
|
|
|
|
* Control the behaviour of playbin.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_FLAGS,
|
|
|
|
g_param_spec_flags ("flags", "Flags", "Flags to control behaviour",
|
|
|
|
GST_TYPE_PLAY_FLAGS, DEFAULT_FLAGS,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_SUBTITLE_ENCODING,
|
|
|
|
g_param_spec_string ("subtitle-encoding", "subtitle encoding",
|
|
|
|
"Encoding to assume if input subtitles are not in UTF-8 encoding. "
|
|
|
|
"If not set, the GST_SUBTITLE_ENCODING environment variable will "
|
|
|
|
"be checked for an encoding to use. If that is not set either, "
|
|
|
|
"ISO-8859-15 will be assumed.", NULL,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_VIDEO_FILTER,
|
|
|
|
g_param_spec_object ("video-filter", "Video filter",
|
|
|
|
"the video filter(s) to apply, if possible",
|
|
|
|
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_AUDIO_FILTER,
|
|
|
|
g_param_spec_object ("audio-filter", "Audio filter",
|
|
|
|
"the audio filter(s) to apply, if possible",
|
|
|
|
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2016-07-22 13:21:36 +00:00
|
|
|
/**
|
|
|
|
* GstPlayBin3:video-sink
|
|
|
|
*
|
|
|
|
* Get or set the video sink to use for video output. If set to
|
|
|
|
* NULL, one will be auto-selected. To disable video entirely, unset
|
|
|
|
* the VIDEO flag in the #GstPlayBin3:flags property.
|
|
|
|
*
|
|
|
|
*/
|
2016-06-29 16:14:51 +00:00
|
|
|
g_object_class_install_property (gobject_klass, PROP_VIDEO_SINK,
|
|
|
|
g_param_spec_object ("video-sink", "Video Sink",
|
|
|
|
"the video output element to use (NULL = default sink)",
|
|
|
|
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2016-07-22 13:21:36 +00:00
|
|
|
/**
|
|
|
|
* GstPlayBin3:audio-sink
|
|
|
|
*
|
|
|
|
* Get or set the audio sink to use for audio output. If set to
|
|
|
|
* NULL, one will be auto-selected. To disable audio entirely, unset
|
|
|
|
* the AUDIO flag in the #GstPlayBin3:flags property.
|
|
|
|
*
|
|
|
|
*/
|
2016-06-29 16:14:51 +00:00
|
|
|
g_object_class_install_property (gobject_klass, PROP_AUDIO_SINK,
|
|
|
|
g_param_spec_object ("audio-sink", "Audio Sink",
|
|
|
|
"the audio output element to use (NULL = default sink)",
|
|
|
|
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_VIS_PLUGIN,
|
|
|
|
g_param_spec_object ("vis-plugin", "Vis plugin",
|
|
|
|
"the visualization element to use (NULL = default)",
|
|
|
|
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_TEXT_SINK,
|
|
|
|
g_param_spec_object ("text-sink", "Text plugin",
|
|
|
|
"the text output element to use (NULL = default subtitleoverlay)",
|
|
|
|
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
/**
|
|
|
|
* GstPlayBin3:video-stream-combiner
|
|
|
|
*
|
2017-11-09 10:12:08 +00:00
|
|
|
* Get or set the current video stream combiner. By default, no
|
|
|
|
* element is used and the selected stream is used directly.
|
2016-06-29 16:14:51 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_VIDEO_STREAM_COMBINER,
|
|
|
|
g_param_spec_object ("video-stream-combiner", "Video stream combiner",
|
2017-11-09 10:12:08 +00:00
|
|
|
"Current video stream combiner (default: none)",
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2017-11-09 10:12:08 +00:00
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
/**
|
|
|
|
* GstPlayBin3:audio-stream-combiner
|
|
|
|
*
|
2017-11-09 10:12:08 +00:00
|
|
|
* Get or set the current audio stream combiner. By default, no
|
|
|
|
* element is used and the selected stream is used directly.
|
2016-06-29 16:14:51 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_AUDIO_STREAM_COMBINER,
|
|
|
|
g_param_spec_object ("audio-stream-combiner", "Audio stream combiner",
|
2017-11-09 10:12:08 +00:00
|
|
|
"Current audio stream combiner (default: none))",
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2017-11-09 10:12:08 +00:00
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
/**
|
|
|
|
* GstPlayBin3:text-stream-combiner
|
|
|
|
*
|
2017-11-09 10:12:08 +00:00
|
|
|
* Get or set the current text stream combiner. By default, no
|
|
|
|
* element is used and the selected stream is used directly.
|
2016-06-29 16:14:51 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_TEXT_STREAM_COMBINER,
|
|
|
|
g_param_spec_object ("text-stream-combiner", "Text stream combiner",
|
2017-11-09 10:12:08 +00:00
|
|
|
"Current text stream combiner (default: none)",
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstPlayBin3:volume:
|
|
|
|
*
|
|
|
|
* Get or set the current audio stream volume. 1.0 means 100%,
|
|
|
|
* 0.0 means mute. This uses a linear volume scale.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_VOLUME,
|
|
|
|
g_param_spec_double ("volume", "Volume", "The audio volume, 1.0=100%",
|
|
|
|
0.0, VOLUME_MAX_DOUBLE, 1.0,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_MUTE,
|
|
|
|
g_param_spec_boolean ("mute", "Mute",
|
|
|
|
"Mute the audio channel without changing the volume", FALSE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstPlayBin3:sample:
|
|
|
|
* @playbin: a #GstPlayBin3
|
|
|
|
*
|
|
|
|
* Get the currently rendered or prerolled sample in the video sink.
|
|
|
|
* The #GstCaps in the sample will describe the format of the buffer.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_SAMPLE,
|
|
|
|
g_param_spec_boxed ("sample", "Sample",
|
|
|
|
"The last sample (NULL = no video available)",
|
|
|
|
GST_TYPE_SAMPLE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_FONT_DESC,
|
|
|
|
g_param_spec_string ("subtitle-font-desc",
|
|
|
|
"Subtitle font description",
|
|
|
|
"Pango font description of font "
|
|
|
|
"to be used for subtitle rendering", NULL,
|
|
|
|
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_CONNECTION_SPEED,
|
|
|
|
g_param_spec_uint64 ("connection-speed", "Connection Speed",
|
|
|
|
"Network connection speed in kbps (0 = unknown)",
|
|
|
|
0, G_MAXUINT64 / 1000, DEFAULT_CONNECTION_SPEED,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_BUFFER_SIZE,
|
|
|
|
g_param_spec_int ("buffer-size", "Buffer size (bytes)",
|
|
|
|
"Buffer size when buffering network streams",
|
|
|
|
-1, G_MAXINT, DEFAULT_BUFFER_SIZE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2022-07-21 14:43:47 +00:00
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
g_object_class_install_property (gobject_klass, PROP_BUFFER_DURATION,
|
|
|
|
g_param_spec_int64 ("buffer-duration", "Buffer duration (ns)",
|
|
|
|
"Buffer duration when buffering network streams",
|
|
|
|
-1, G_MAXINT64, DEFAULT_BUFFER_DURATION,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
/**
|
|
|
|
* GstPlayBin3:av-offset:
|
|
|
|
*
|
|
|
|
* Control the synchronisation offset between the audio and video streams.
|
|
|
|
* Positive values make the audio ahead of the video and negative values make
|
|
|
|
* the audio go behind the video.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_AV_OFFSET,
|
|
|
|
g_param_spec_int64 ("av-offset", "AV Offset",
|
|
|
|
"The synchronisation offset between audio and video in nanoseconds",
|
|
|
|
G_MININT64, G_MAXINT64, 0,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2018-10-28 14:45:26 +00:00
|
|
|
/**
|
|
|
|
* GstPlayBin3:text-offset:
|
|
|
|
*
|
|
|
|
* Control the synchronisation offset between the text and video streams.
|
|
|
|
* Positive values make the text ahead of the video and negative values make
|
|
|
|
* the text go behind the video.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_TEXT_OFFSET,
|
|
|
|
g_param_spec_int64 ("text-offset", "Text Offset",
|
|
|
|
"The synchronisation offset between text and video in nanoseconds",
|
|
|
|
G_MININT64, G_MAXINT64, 0,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstPlayBin3:ring-buffer-max-size
|
|
|
|
*
|
|
|
|
* The maximum size of the ring buffer in bytes. If set to 0, the ring
|
|
|
|
* buffer is disabled. Default 0.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_RING_BUFFER_MAX_SIZE,
|
|
|
|
g_param_spec_uint64 ("ring-buffer-max-size",
|
|
|
|
"Max. ring buffer size (bytes)",
|
|
|
|
"Max. amount of data in the ring buffer (bytes, 0 = ring buffer disabled)",
|
|
|
|
0, G_MAXUINT, DEFAULT_RING_BUFFER_MAX_SIZE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstPlayBin3::force-aspect-ratio:
|
|
|
|
*
|
|
|
|
* Requests the video sink to enforce the video display aspect ratio.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_FORCE_ASPECT_RATIO,
|
|
|
|
g_param_spec_boolean ("force-aspect-ratio", "Force Aspect Ratio",
|
|
|
|
"When enabled, scaling will respect original aspect ratio", TRUE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstPlayBin3::video-multiview-mode:
|
|
|
|
*
|
|
|
|
* Set the stereoscopic mode for video streams that don't contain
|
|
|
|
* any information in the stream, so they can be correctly played
|
|
|
|
* as 3D streams. If a video already has multiview information
|
|
|
|
* encoded, this property can override other modes in the set,
|
|
|
|
* but cannot be used to re-interpret MVC or mixed-mono streams.
|
|
|
|
*
|
|
|
|
* See Also: The #GstPlayBin3::video-multiview-flags property
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_MULTIVIEW_MODE,
|
|
|
|
g_param_spec_enum ("video-multiview-mode",
|
|
|
|
"Multiview Mode Override",
|
|
|
|
"Re-interpret a video stream as one of several frame-packed stereoscopic modes.",
|
|
|
|
GST_TYPE_VIDEO_MULTIVIEW_FRAME_PACKING,
|
|
|
|
GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstPlayBin3::video-multiview-flags:
|
|
|
|
*
|
|
|
|
* When overriding the multiview mode of an input stream,
|
|
|
|
* these flags modify details of the view layout.
|
|
|
|
*
|
|
|
|
* See Also: The #GstPlayBin3::video-multiview-mode property
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_MULTIVIEW_FLAGS,
|
|
|
|
g_param_spec_flags ("video-multiview-flags",
|
|
|
|
"Multiview Flags Override",
|
|
|
|
"Override details of the multiview frame layout",
|
|
|
|
GST_TYPE_VIDEO_MULTIVIEW_FLAGS, GST_VIDEO_MULTIVIEW_FLAGS_NONE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
/**
|
|
|
|
* GstPlayBin3:instant-uri:
|
|
|
|
*
|
|
|
|
* Changes to uri are applied immediately, instead of on EOS or when the
|
|
|
|
* element is set back to PLAYING.
|
|
|
|
*
|
|
|
|
* Since: 1.22
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_klass, PROP_INSTANT_URI,
|
|
|
|
g_param_spec_boolean ("instant-uri", "Instantaneous URI change",
|
|
|
|
"When enabled, URI changes are applied immediately", FALSE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
/**
|
|
|
|
* GstPlayBin3::about-to-finish
|
|
|
|
* @playbin: a #GstPlayBin3
|
|
|
|
*
|
|
|
|
* This signal is emitted when the current uri is about to finish. You can
|
|
|
|
* set the uri and suburi to make sure that playback continues.
|
|
|
|
*
|
|
|
|
* This signal is emitted from the context of a GStreamer streaming thread.
|
|
|
|
*/
|
|
|
|
gst_play_bin3_signals[SIGNAL_ABOUT_TO_FINISH] =
|
|
|
|
g_signal_new ("about-to-finish", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstPlayBin3Class, about_to_finish), NULL, NULL,
|
2019-08-26 05:54:48 +00:00
|
|
|
NULL, G_TYPE_NONE, 0, G_TYPE_NONE);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstPlayBin3::source-setup:
|
|
|
|
* @playbin: a #GstPlayBin3
|
|
|
|
* @source: source element
|
|
|
|
*
|
|
|
|
* This signal is emitted after the source element has been created, so
|
|
|
|
* it can be configured by setting additional properties (e.g. set a
|
|
|
|
* proxy server for an http source, or set the device and read speed for
|
|
|
|
* an audio cd source). This is functionally equivalent to connecting to
|
|
|
|
* the notify::source signal, but more convenient.
|
|
|
|
*
|
|
|
|
* This signal is usually emitted from the context of a GStreamer streaming
|
|
|
|
* thread.
|
|
|
|
*/
|
|
|
|
gst_play_bin3_signals[SIGNAL_SOURCE_SETUP] =
|
|
|
|
g_signal_new ("source-setup", G_TYPE_FROM_CLASS (klass),
|
2019-08-26 05:54:48 +00:00
|
|
|
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2016-08-08 19:04:11 +00:00
|
|
|
/**
|
|
|
|
* GstPlayBin3::element-setup:
|
|
|
|
* @playbin: a #GstPlayBin3
|
|
|
|
* @element: an element that was added to the playbin hierarchy
|
|
|
|
*
|
|
|
|
* This signal is emitted when a new element is added to playbin or any of
|
|
|
|
* its sub-bins. This signal can be used to configure elements, e.g. to set
|
|
|
|
* properties on decoders. This is functionally equivalent to connecting to
|
|
|
|
* the deep-element-added signal, but more convenient.
|
|
|
|
*
|
|
|
|
* This signal is usually emitted from the context of a GStreamer streaming
|
|
|
|
* thread, so might be called at the same time as code running in the main
|
|
|
|
* application thread.
|
|
|
|
*
|
|
|
|
* Since: 1.10
|
|
|
|
*/
|
|
|
|
gst_play_bin3_signals[SIGNAL_ELEMENT_SETUP] =
|
|
|
|
g_signal_new ("element-setup", G_TYPE_FROM_CLASS (klass),
|
2019-08-26 05:54:48 +00:00
|
|
|
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
|
2016-08-08 19:04:11 +00:00
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
/**
|
|
|
|
* GstPlayBin3::convert-sample
|
|
|
|
* @playbin: a #GstPlayBin3
|
|
|
|
* @caps: the target format of the frame
|
|
|
|
*
|
|
|
|
* Action signal to retrieve the currently playing video frame in the format
|
|
|
|
* specified by @caps.
|
|
|
|
* If @caps is %NULL, no conversion will be performed and this function is
|
2018-09-21 16:54:39 +00:00
|
|
|
* equivalent to the #GstPlayBin3:sample property.
|
2016-06-29 16:14:51 +00:00
|
|
|
*
|
|
|
|
* Returns: a #GstSample of the current video frame converted to #caps.
|
|
|
|
* The caps on the sample will describe the final layout of the buffer data.
|
|
|
|
* %NULL is returned when no current buffer can be retrieved or when the
|
|
|
|
* conversion failed.
|
|
|
|
*/
|
|
|
|
gst_play_bin3_signals[SIGNAL_CONVERT_SAMPLE] =
|
|
|
|
g_signal_new ("convert-sample", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
|
|
|
G_STRUCT_OFFSET (GstPlayBin3Class, convert_sample), NULL, NULL,
|
2019-08-26 05:54:48 +00:00
|
|
|
NULL, GST_TYPE_SAMPLE, 1, GST_TYPE_CAPS);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
klass->convert_sample = gst_play_bin3_convert_sample;
|
|
|
|
|
|
|
|
gst_element_class_set_static_metadata (gstelement_klass,
|
|
|
|
"Player Bin 3", "Generic/Bin/Player",
|
|
|
|
"Autoplug and play media from an uri",
|
|
|
|
"Wim Taymans <wim.taymans@gmail.com>");
|
|
|
|
|
|
|
|
gstelement_klass->change_state =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_play_bin3_change_state);
|
|
|
|
gstelement_klass->send_event = GST_DEBUG_FUNCPTR (gst_play_bin3_send_event);
|
|
|
|
|
|
|
|
gstbin_klass->handle_message =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_play_bin3_handle_message);
|
2016-08-08 19:04:11 +00:00
|
|
|
gstbin_klass->deep_element_added =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_play_bin3_deep_element_added);
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_async_start (GstPlayBin3 * playbin)
|
|
|
|
{
|
|
|
|
GstMessage *message;
|
|
|
|
|
|
|
|
playbin->async_pending = TRUE;
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin, "posting ASYNC_START");
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
message = gst_message_new_async_start (GST_OBJECT_CAST (playbin));
|
|
|
|
GST_BIN_CLASS (parent_class)->handle_message (GST_BIN_CAST (playbin),
|
|
|
|
message);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_async_done (GstPlayBin3 * playbin)
|
|
|
|
{
|
|
|
|
GstMessage *message;
|
|
|
|
|
|
|
|
if (playbin->async_pending) {
|
|
|
|
GST_DEBUG_OBJECT (playbin, "posting ASYNC_DONE");
|
|
|
|
message =
|
|
|
|
gst_message_new_async_done (GST_OBJECT_CAST (playbin),
|
|
|
|
GST_CLOCK_TIME_NONE);
|
|
|
|
GST_BIN_CLASS (parent_class)->handle_message (GST_BIN_CAST (playbin),
|
|
|
|
message);
|
|
|
|
|
|
|
|
playbin->async_pending = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* init combiners. The combiner is found by finding the first prefix that
|
|
|
|
* matches the media. */
|
|
|
|
static void
|
|
|
|
init_combiners (GstPlayBin3 * playbin)
|
|
|
|
{
|
2017-11-09 10:17:13 +00:00
|
|
|
playbin->combiner[PLAYBIN_STREAM_AUDIO].stream_type = GST_STREAM_TYPE_AUDIO;
|
playbin3: Fix missing pad unref
GST_TRACERS="leaks" GST_DEBUG="GST_TRACER:7,leaks:6" gst-play-1.0 --use-playbin3 test.mkv
When running a pipeline like above, leaks are observed.
0:00:56.882419132 240637 0x5562c528ccc0 TRACE GST_TRACER :0:: object-alive, type-name=(string)GstConcatPad, address=(gpointer)0x7efd7c0d20a0, description=(string)<'':sink_0>, ref-count=(uint)1, trace=(string);
0:00:56.882429131 240637 0x5562c528ccc0 TRACE GST_TRACER :0:: object-alive, type-name=(string)GstConcatPad, address=(gpointer)0x7efd7c0d2be0, description=(string)<'':sink_0>, ref-count=(uint)1, trace=(string);
0:00:56.882437056 240637 0x5562c528ccc0 TRACE GST_TRACER :0:: object-alive, type-name=(string)GstConcatPad, address=(gpointer)0x7efd7c0d3720, description=(string)<'':sink_0>, ref-count=(uint)1, trace=(string);
gst_element_release_request_pad does not unref the pad. It needs to
be followed by gst_object_unref. Doing that fixes the above leaks.
Use g_ptr_array_new_with_free_func with gst_object_unref as the free
function to unref the pad after release.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3177>
2022-10-13 16:45:58 +00:00
|
|
|
playbin->combiner[PLAYBIN_STREAM_AUDIO].inputpads =
|
|
|
|
g_ptr_array_new_with_free_func ((GDestroyNotify) gst_object_unref);
|
2016-06-29 16:14:51 +00:00
|
|
|
playbin->combiner[PLAYBIN_STREAM_AUDIO].streams =
|
|
|
|
g_ptr_array_new_with_free_func ((GDestroyNotify) gst_object_unref);
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
playbin->combiner[PLAYBIN_STREAM_VIDEO].stream_type = GST_STREAM_TYPE_VIDEO;
|
playbin3: Fix missing pad unref
GST_TRACERS="leaks" GST_DEBUG="GST_TRACER:7,leaks:6" gst-play-1.0 --use-playbin3 test.mkv
When running a pipeline like above, leaks are observed.
0:00:56.882419132 240637 0x5562c528ccc0 TRACE GST_TRACER :0:: object-alive, type-name=(string)GstConcatPad, address=(gpointer)0x7efd7c0d20a0, description=(string)<'':sink_0>, ref-count=(uint)1, trace=(string);
0:00:56.882429131 240637 0x5562c528ccc0 TRACE GST_TRACER :0:: object-alive, type-name=(string)GstConcatPad, address=(gpointer)0x7efd7c0d2be0, description=(string)<'':sink_0>, ref-count=(uint)1, trace=(string);
0:00:56.882437056 240637 0x5562c528ccc0 TRACE GST_TRACER :0:: object-alive, type-name=(string)GstConcatPad, address=(gpointer)0x7efd7c0d3720, description=(string)<'':sink_0>, ref-count=(uint)1, trace=(string);
gst_element_release_request_pad does not unref the pad. It needs to
be followed by gst_object_unref. Doing that fixes the above leaks.
Use g_ptr_array_new_with_free_func with gst_object_unref as the free
function to unref the pad after release.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3177>
2022-10-13 16:45:58 +00:00
|
|
|
playbin->combiner[PLAYBIN_STREAM_VIDEO].inputpads =
|
|
|
|
g_ptr_array_new_with_free_func ((GDestroyNotify) gst_object_unref);
|
2016-06-29 16:14:51 +00:00
|
|
|
playbin->combiner[PLAYBIN_STREAM_VIDEO].streams =
|
|
|
|
g_ptr_array_new_with_free_func ((GDestroyNotify) gst_object_unref);
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
playbin->combiner[PLAYBIN_STREAM_TEXT].stream_type = GST_STREAM_TYPE_TEXT;
|
playbin3: Fix missing pad unref
GST_TRACERS="leaks" GST_DEBUG="GST_TRACER:7,leaks:6" gst-play-1.0 --use-playbin3 test.mkv
When running a pipeline like above, leaks are observed.
0:00:56.882419132 240637 0x5562c528ccc0 TRACE GST_TRACER :0:: object-alive, type-name=(string)GstConcatPad, address=(gpointer)0x7efd7c0d20a0, description=(string)<'':sink_0>, ref-count=(uint)1, trace=(string);
0:00:56.882429131 240637 0x5562c528ccc0 TRACE GST_TRACER :0:: object-alive, type-name=(string)GstConcatPad, address=(gpointer)0x7efd7c0d2be0, description=(string)<'':sink_0>, ref-count=(uint)1, trace=(string);
0:00:56.882437056 240637 0x5562c528ccc0 TRACE GST_TRACER :0:: object-alive, type-name=(string)GstConcatPad, address=(gpointer)0x7efd7c0d3720, description=(string)<'':sink_0>, ref-count=(uint)1, trace=(string);
gst_element_release_request_pad does not unref the pad. It needs to
be followed by gst_object_unref. Doing that fixes the above leaks.
Use g_ptr_array_new_with_free_func with gst_object_unref as the free
function to unref the pad after release.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3177>
2022-10-13 16:45:58 +00:00
|
|
|
playbin->combiner[PLAYBIN_STREAM_TEXT].inputpads =
|
|
|
|
g_ptr_array_new_with_free_func ((GDestroyNotify) gst_object_unref);
|
2016-06-29 16:14:51 +00:00
|
|
|
playbin->combiner[PLAYBIN_STREAM_TEXT].streams =
|
|
|
|
g_ptr_array_new_with_free_func ((GDestroyNotify) gst_object_unref);
|
|
|
|
}
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
/* Update the combiner information to be in sync with the current collection */
|
2016-06-29 16:14:51 +00:00
|
|
|
static void
|
2017-11-09 10:17:13 +00:00
|
|
|
update_combiner_info (GstPlayBin3 * playbin, GstStreamCollection * collection)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
|
|
|
guint i, len;
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
if (collection == NULL)
|
2016-06-29 16:14:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Updating combiner info");
|
|
|
|
|
|
|
|
/* Wipe current combiner streams */
|
|
|
|
g_ptr_array_free (playbin->combiner[PLAYBIN_STREAM_AUDIO].streams, TRUE);
|
|
|
|
g_ptr_array_free (playbin->combiner[PLAYBIN_STREAM_VIDEO].streams, TRUE);
|
|
|
|
g_ptr_array_free (playbin->combiner[PLAYBIN_STREAM_TEXT].streams, TRUE);
|
|
|
|
playbin->combiner[PLAYBIN_STREAM_AUDIO].streams =
|
|
|
|
g_ptr_array_new_with_free_func ((GDestroyNotify) gst_object_unref);
|
|
|
|
playbin->combiner[PLAYBIN_STREAM_VIDEO].streams =
|
|
|
|
g_ptr_array_new_with_free_func ((GDestroyNotify) gst_object_unref);
|
|
|
|
playbin->combiner[PLAYBIN_STREAM_TEXT].streams =
|
|
|
|
g_ptr_array_new_with_free_func ((GDestroyNotify) gst_object_unref);
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
len = gst_stream_collection_get_size (collection);
|
2016-06-29 16:14:51 +00:00
|
|
|
for (i = 0; i < len; i++) {
|
2017-11-09 10:17:13 +00:00
|
|
|
GstStream *stream = gst_stream_collection_get_stream (collection, i);
|
2016-06-29 16:14:51 +00:00
|
|
|
GstStreamType stype = gst_stream_get_stream_type (stream);
|
|
|
|
|
2016-10-13 09:42:28 +00:00
|
|
|
if (stype & GST_STREAM_TYPE_AUDIO) {
|
|
|
|
g_ptr_array_add (playbin->combiner[PLAYBIN_STREAM_AUDIO].streams,
|
|
|
|
gst_object_ref (stream));
|
|
|
|
} else if (stype & GST_STREAM_TYPE_VIDEO) {
|
|
|
|
g_ptr_array_add (playbin->combiner[PLAYBIN_STREAM_VIDEO].streams,
|
|
|
|
gst_object_ref (stream));
|
|
|
|
} else if (stype & GST_STREAM_TYPE_TEXT) {
|
|
|
|
g_ptr_array_add (playbin->combiner[PLAYBIN_STREAM_TEXT].streams,
|
|
|
|
gst_object_ref (stream));
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (playbin, "There are %d audio streams",
|
|
|
|
playbin->combiner[PLAYBIN_STREAM_AUDIO].streams->len);
|
|
|
|
GST_DEBUG_OBJECT (playbin, "There are %d video streams",
|
|
|
|
playbin->combiner[PLAYBIN_STREAM_VIDEO].streams->len);
|
|
|
|
GST_DEBUG_OBJECT (playbin, "There are %d text streams",
|
|
|
|
playbin->combiner[PLAYBIN_STREAM_TEXT].streams->len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
notify_volume_cb (GObject * combiner, GParamSpec * pspec, GstPlayBin3 * playbin)
|
|
|
|
{
|
|
|
|
g_object_notify (G_OBJECT (playbin), "volume");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
notify_mute_cb (GObject * combiner, GParamSpec * pspec, GstPlayBin3 * playbin)
|
|
|
|
{
|
|
|
|
g_object_notify (G_OBJECT (playbin), "mute");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
colorbalance_value_changed_cb (GstColorBalance * balance,
|
|
|
|
GstColorBalanceChannel * channel, gint value, GstPlayBin3 * playbin)
|
|
|
|
{
|
|
|
|
gst_color_balance_value_changed (GST_COLOR_BALANCE (playbin), channel, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_init (GstPlayBin3 * playbin)
|
|
|
|
{
|
2024-02-20 15:04:09 +00:00
|
|
|
GstCaps *uridecodebin_caps, *subtitle_caps;
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
g_rec_mutex_init (&playbin->lock);
|
2022-03-01 16:43:00 +00:00
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
/* assume we can create an input-selector */
|
|
|
|
playbin->have_selector = TRUE;
|
|
|
|
|
|
|
|
init_combiners (playbin);
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
/* Create uridecodebin3 */
|
|
|
|
playbin->uridecodebin =
|
|
|
|
gst_element_factory_make ("uridecodebin3", "uridecodebin3");
|
|
|
|
/* Set default property (based on default flags value) */
|
|
|
|
g_object_set (playbin->uridecodebin, "use-buffering", TRUE, NULL);
|
|
|
|
gst_bin_add (GST_BIN_CAST (playbin),
|
|
|
|
GST_ELEMENT_CAST (playbin->uridecodebin));
|
|
|
|
|
2024-02-20 15:04:09 +00:00
|
|
|
/* Make sure uridecodebin3 knows of all the subtitle formats that playsink can
|
|
|
|
* handle as-is */
|
|
|
|
subtitle_caps = gst_subtitle_overlay_create_factory_caps ();
|
|
|
|
g_object_get (playbin->uridecodebin, "caps", &uridecodebin_caps, NULL);
|
|
|
|
uridecodebin_caps = gst_caps_merge (uridecodebin_caps, subtitle_caps);
|
|
|
|
g_object_set (playbin->uridecodebin, "caps", uridecodebin_caps, NULL);
|
|
|
|
gst_caps_unref (uridecodebin_caps);
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
g_signal_connect (playbin->uridecodebin, "pad-added",
|
|
|
|
G_CALLBACK (pad_added_cb), playbin);
|
|
|
|
g_signal_connect (playbin->uridecodebin, "pad-removed",
|
|
|
|
G_CALLBACK (pad_removed_cb), playbin);
|
|
|
|
g_signal_connect (playbin->uridecodebin, "select-stream",
|
|
|
|
G_CALLBACK (select_stream_cb), playbin);
|
|
|
|
g_signal_connect (playbin->uridecodebin, "source-setup",
|
|
|
|
G_CALLBACK (source_setup_cb), playbin);
|
|
|
|
g_signal_connect (playbin->uridecodebin, "about-to-finish",
|
|
|
|
G_CALLBACK (about_to_finish_cb), playbin);
|
2017-11-10 13:32:13 +00:00
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
/* add sink */
|
|
|
|
playbin->playsink =
|
|
|
|
g_object_new (GST_TYPE_PLAY_SINK, "name", "playsink", "send-event-mode",
|
|
|
|
1, NULL);
|
|
|
|
gst_bin_add (GST_BIN_CAST (playbin), GST_ELEMENT_CAST (playbin->playsink));
|
|
|
|
gst_play_sink_set_flags (playbin->playsink, DEFAULT_FLAGS);
|
|
|
|
/* Connect to notify::volume and notify::mute signals for proxying */
|
|
|
|
g_signal_connect (playbin->playsink, "notify::volume",
|
|
|
|
G_CALLBACK (notify_volume_cb), playbin);
|
|
|
|
g_signal_connect (playbin->playsink, "notify::mute",
|
|
|
|
G_CALLBACK (notify_mute_cb), playbin);
|
|
|
|
g_signal_connect (playbin->playsink, "value-changed",
|
|
|
|
G_CALLBACK (colorbalance_value_changed_cb), playbin);
|
|
|
|
|
|
|
|
playbin->current_video = DEFAULT_CURRENT_VIDEO;
|
|
|
|
playbin->current_audio = DEFAULT_CURRENT_AUDIO;
|
|
|
|
playbin->current_text = DEFAULT_CURRENT_TEXT;
|
|
|
|
|
|
|
|
playbin->force_aspect_ratio = TRUE;
|
|
|
|
|
|
|
|
playbin->multiview_mode = GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE;
|
|
|
|
playbin->multiview_flags = GST_VIDEO_MULTIVIEW_FLAGS_NONE;
|
2021-04-12 12:02:46 +00:00
|
|
|
|
|
|
|
playbin->is_live = FALSE;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin;
|
|
|
|
|
|
|
|
playbin = GST_PLAY_BIN3 (object);
|
|
|
|
|
|
|
|
/* Setting states to NULL is safe here because playsink
|
|
|
|
* will already be gone and none of these sinks will be
|
|
|
|
* a child of playsink
|
|
|
|
*/
|
|
|
|
if (playbin->video_sink) {
|
|
|
|
gst_element_set_state (playbin->video_sink, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin->video_sink);
|
|
|
|
}
|
|
|
|
if (playbin->audio_sink) {
|
|
|
|
gst_element_set_state (playbin->audio_sink, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin->audio_sink);
|
|
|
|
}
|
|
|
|
if (playbin->text_sink) {
|
|
|
|
gst_element_set_state (playbin->text_sink, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin->text_sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (playbin->video_stream_combiner) {
|
|
|
|
gst_element_set_state (playbin->video_stream_combiner, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin->video_stream_combiner);
|
|
|
|
}
|
|
|
|
if (playbin->audio_stream_combiner) {
|
|
|
|
gst_element_set_state (playbin->audio_stream_combiner, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin->audio_stream_combiner);
|
|
|
|
}
|
|
|
|
if (playbin->text_stream_combiner) {
|
|
|
|
gst_element_set_state (playbin->text_stream_combiner, GST_STATE_NULL);
|
|
|
|
gst_object_unref (playbin->text_stream_combiner);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_ptr_array_free (playbin->combiner[PLAYBIN_STREAM_AUDIO].streams, TRUE);
|
2022-05-06 07:10:09 +00:00
|
|
|
g_ptr_array_free (playbin->combiner[PLAYBIN_STREAM_AUDIO].inputpads, TRUE);
|
2016-06-29 16:14:51 +00:00
|
|
|
g_ptr_array_free (playbin->combiner[PLAYBIN_STREAM_VIDEO].streams, TRUE);
|
2022-05-06 07:10:09 +00:00
|
|
|
g_ptr_array_free (playbin->combiner[PLAYBIN_STREAM_VIDEO].inputpads, TRUE);
|
2016-06-29 16:14:51 +00:00
|
|
|
g_ptr_array_free (playbin->combiner[PLAYBIN_STREAM_TEXT].streams, TRUE);
|
2022-05-06 07:10:09 +00:00
|
|
|
g_ptr_array_free (playbin->combiner[PLAYBIN_STREAM_TEXT].inputpads, TRUE);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
g_rec_mutex_clear (&playbin->lock);
|
2022-03-01 16:43:00 +00:00
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_playbin_uri_is_valid (GstPlayBin3 * playbin, const gchar * uri)
|
|
|
|
{
|
|
|
|
const gchar *c;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (playbin, "checking uri '%s'", uri);
|
|
|
|
|
|
|
|
/* this just checks the protocol */
|
|
|
|
if (!gst_uri_is_valid (uri))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (c = uri; *c != '\0'; ++c) {
|
|
|
|
if (!g_ascii_isprint (*c))
|
|
|
|
goto invalid;
|
|
|
|
if (*c == ' ')
|
|
|
|
goto invalid;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
invalid:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (playbin, "uri '%s' not valid, character #%u",
|
|
|
|
uri, (guint) ((guintptr) c - (guintptr) uri));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_set_uri (GstPlayBin3 * playbin, const gchar * uri)
|
|
|
|
{
|
2022-07-21 14:43:47 +00:00
|
|
|
if (!gst_playbin_uri_is_valid (playbin, uri)) {
|
2016-06-29 16:14:51 +00:00
|
|
|
if (g_str_has_prefix (uri, "file:")) {
|
|
|
|
GST_WARNING_OBJECT (playbin, "not entirely correct file URI '%s' - make "
|
|
|
|
"sure to escape spaces and non-ASCII characters properly and specify "
|
|
|
|
"an absolute path. Use gst_filename_to_uri() to convert filenames "
|
|
|
|
"to URIs", uri);
|
|
|
|
} else {
|
|
|
|
/* GST_ERROR_OBJECT (playbin, "malformed URI '%s'", uri); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_set (playbin->uridecodebin, "uri", uri, NULL);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2022-04-01 07:25:23 +00:00
|
|
|
GST_DEBUG ("set new uri to %s", GST_STR_NULL (uri));
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_set_suburi (GstPlayBin3 * playbin, const gchar * suburi)
|
|
|
|
{
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_set (playbin->uridecodebin, "suburi", suburi, NULL);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("setting new .sub uri to %s", suburi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_set_flags (GstPlayBin3 * playbin, GstPlayFlags flags)
|
|
|
|
{
|
|
|
|
GstPlayFlags old_flags;
|
|
|
|
old_flags = gst_play_sink_get_flags (playbin->playsink);
|
|
|
|
|
|
|
|
if (flags != old_flags) {
|
|
|
|
gst_play_sink_set_flags (playbin->playsink, flags);
|
|
|
|
gst_play_sink_reconfigure (playbin->playsink);
|
|
|
|
}
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_set (playbin->uridecodebin, "download",
|
|
|
|
((flags & GST_PLAY_FLAG_DOWNLOAD) != 0),
|
|
|
|
/* configure buffering of demuxed/parsed data */
|
|
|
|
"use-buffering", ((flags & GST_PLAY_FLAG_BUFFERING) != 0), NULL);
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstSample *
|
|
|
|
gst_play_bin3_convert_sample (GstPlayBin3 * playbin, GstCaps * caps)
|
|
|
|
{
|
|
|
|
return gst_play_sink_convert_sample (playbin->playsink, caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_play_bin3_send_custom_event (GstObject * combiner, const gchar * event_name)
|
|
|
|
{
|
|
|
|
GstPad *src;
|
|
|
|
GstPad *peer;
|
|
|
|
GstStructure *s;
|
|
|
|
GstEvent *event;
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
src = gst_element_get_static_pad (GST_ELEMENT_CAST (combiner), "src");
|
|
|
|
peer = gst_pad_get_peer (src);
|
|
|
|
if (peer) {
|
|
|
|
s = gst_structure_new_empty (event_name);
|
|
|
|
event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM_OOB, s);
|
|
|
|
gst_pad_send_event (peer, event);
|
|
|
|
gst_object_unref (peer);
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
gst_object_unref (src);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_play_bin3_set_current_stream (GstPlayBin3 * playbin,
|
|
|
|
gint stream_type, gint * current_value, gint stream,
|
|
|
|
gboolean * flush_marker)
|
|
|
|
{
|
|
|
|
GstSourceCombine *combine;
|
|
|
|
GstPad *sinkpad;
|
|
|
|
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
/* This function is only called if the app sets
|
|
|
|
* one of the current-* properties, which means it doesn't
|
|
|
|
* handle collections or select-streams yet */
|
|
|
|
playbin->do_stream_selections = TRUE;
|
|
|
|
|
|
|
|
combine = playbin->combiner + stream_type;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Changing current %s stream %d -> %d",
|
|
|
|
stream_type_names[stream_type], *current_value, stream);
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
if (combine->combiner == NULL) {
|
2016-06-29 16:14:51 +00:00
|
|
|
/* FIXME: Check that the current_value is within range */
|
|
|
|
*current_value = stream;
|
2022-07-21 14:43:47 +00:00
|
|
|
do_stream_selection (playbin);
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Using old style combiner");
|
|
|
|
|
|
|
|
if (!combine->has_active_pad)
|
|
|
|
goto no_active_pad;
|
2022-05-06 07:10:09 +00:00
|
|
|
if (combine->inputpads == NULL)
|
2016-06-29 16:14:51 +00:00
|
|
|
goto no_channels;
|
|
|
|
|
2022-05-06 07:10:09 +00:00
|
|
|
if (stream == -1 || combine->inputpads->len <= stream) {
|
2016-06-29 16:14:51 +00:00
|
|
|
sinkpad = NULL;
|
|
|
|
} else {
|
2022-05-06 07:10:09 +00:00
|
|
|
/* take combiner sink pad for selected stream */
|
|
|
|
sinkpad = g_ptr_array_index (combine->inputpads, stream);
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sinkpad)
|
|
|
|
gst_object_ref (sinkpad);
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
|
|
|
|
if (sinkpad) {
|
|
|
|
GstObject *combiner;
|
|
|
|
|
|
|
|
if ((combiner = gst_pad_get_parent (sinkpad))) {
|
|
|
|
GstPad *old_sinkpad;
|
|
|
|
|
|
|
|
g_object_get (combiner, "active-pad", &old_sinkpad, NULL);
|
|
|
|
|
|
|
|
if (old_sinkpad != sinkpad) {
|
|
|
|
/* FIXME: Is there actually any reason playsink
|
|
|
|
* needs special names for each type of stream we flush? */
|
|
|
|
gchar *flush_event_name = g_strdup_printf ("playsink-custom-%s-flush",
|
|
|
|
stream_type_names[stream_type]);
|
|
|
|
if (gst_play_bin3_send_custom_event (combiner, flush_event_name))
|
|
|
|
*flush_marker = TRUE;
|
|
|
|
g_free (flush_event_name);
|
|
|
|
|
|
|
|
/* activate the selected pad */
|
|
|
|
g_object_set (combiner, "active-pad", sinkpad, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (old_sinkpad)
|
|
|
|
gst_object_unref (old_sinkpad);
|
|
|
|
|
|
|
|
gst_object_unref (combiner);
|
|
|
|
}
|
|
|
|
gst_object_unref (sinkpad);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
no_active_pad:
|
|
|
|
{
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
GST_WARNING_OBJECT (playbin,
|
|
|
|
"can't switch %s, the stream combiner's sink pads don't have the \"active-pad\" property",
|
|
|
|
stream_type_names[stream_type]);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
no_channels:
|
|
|
|
{
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
2022-05-06 07:10:09 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin,
|
|
|
|
"can't switch stream, we have no combiner input pad");
|
2016-06-29 16:14:51 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_play_bin3_set_current_video_stream (GstPlayBin3 * playbin, gint stream)
|
|
|
|
{
|
|
|
|
return gst_play_bin3_set_current_stream (playbin, PLAYBIN_STREAM_VIDEO,
|
|
|
|
&playbin->current_video, stream, &playbin->video_pending_flush_finish);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_play_bin3_set_current_audio_stream (GstPlayBin3 * playbin, gint stream)
|
|
|
|
{
|
|
|
|
return gst_play_bin3_set_current_stream (playbin, PLAYBIN_STREAM_AUDIO,
|
|
|
|
&playbin->current_audio, stream, &playbin->audio_pending_flush_finish);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_play_bin3_set_current_text_stream (GstPlayBin3 * playbin, gint stream)
|
|
|
|
{
|
|
|
|
return gst_play_bin3_set_current_stream (playbin, PLAYBIN_STREAM_TEXT,
|
|
|
|
&playbin->current_text, stream, &playbin->text_pending_flush_finish);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_set_sink (GstPlayBin3 * playbin, GstPlaySinkType type,
|
|
|
|
const gchar * dbg, GstElement ** elem, GstElement * sink)
|
|
|
|
{
|
|
|
|
GST_INFO_OBJECT (playbin, "Setting %s sink to %" GST_PTR_FORMAT, dbg, sink);
|
|
|
|
|
|
|
|
gst_play_sink_set_sink (playbin->playsink, type, sink);
|
|
|
|
|
|
|
|
if (*elem)
|
|
|
|
gst_object_unref (*elem);
|
|
|
|
*elem = sink ? gst_object_ref (sink) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_set_stream_combiner (GstPlayBin3 * playbin, GstElement ** elem,
|
|
|
|
const gchar * dbg, GstElement * combiner)
|
|
|
|
{
|
|
|
|
GST_INFO_OBJECT (playbin, "Setting %s stream combiner to %" GST_PTR_FORMAT,
|
|
|
|
dbg, combiner);
|
|
|
|
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
if (*elem != combiner) {
|
|
|
|
GstElement *old;
|
|
|
|
|
|
|
|
old = *elem;
|
|
|
|
if (combiner)
|
|
|
|
gst_object_ref_sink (combiner);
|
|
|
|
|
|
|
|
*elem = combiner;
|
|
|
|
if (old)
|
|
|
|
gst_object_unref (old);
|
|
|
|
}
|
|
|
|
GST_LOG_OBJECT (playbin, "%s stream combiner now %" GST_PTR_FORMAT, dbg,
|
|
|
|
*elem);
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_set_encoding (GstPlayBin3 * playbin, const gchar * encoding)
|
|
|
|
{
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
gst_play_sink_set_subtitle_encoding (playbin->playsink, encoding);
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_URI:
|
|
|
|
gst_play_bin3_set_uri (playbin, g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
case PROP_SUBURI:
|
|
|
|
gst_play_bin3_set_suburi (playbin, g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
case PROP_FLAGS:
|
|
|
|
gst_play_bin3_set_flags (playbin, g_value_get_flags (value));
|
|
|
|
break;
|
|
|
|
case PROP_SUBTITLE_ENCODING:
|
|
|
|
gst_play_bin3_set_encoding (playbin, g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
case PROP_VIDEO_FILTER:
|
|
|
|
gst_play_sink_set_filter (playbin->playsink, GST_PLAY_SINK_TYPE_VIDEO,
|
|
|
|
GST_ELEMENT (g_value_get_object (value)));
|
|
|
|
break;
|
|
|
|
case PROP_AUDIO_FILTER:
|
|
|
|
gst_play_sink_set_filter (playbin->playsink, GST_PLAY_SINK_TYPE_AUDIO,
|
|
|
|
GST_ELEMENT (g_value_get_object (value)));
|
|
|
|
break;
|
|
|
|
case PROP_VIDEO_SINK:
|
|
|
|
gst_play_bin3_set_sink (playbin, GST_PLAY_SINK_TYPE_VIDEO, "video",
|
|
|
|
&playbin->video_sink, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
case PROP_AUDIO_SINK:
|
|
|
|
gst_play_bin3_set_sink (playbin, GST_PLAY_SINK_TYPE_AUDIO, "audio",
|
|
|
|
&playbin->audio_sink, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
case PROP_VIS_PLUGIN:
|
|
|
|
gst_play_sink_set_vis_plugin (playbin->playsink,
|
|
|
|
g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
case PROP_TEXT_SINK:
|
|
|
|
gst_play_bin3_set_sink (playbin, GST_PLAY_SINK_TYPE_TEXT, "text",
|
|
|
|
&playbin->text_sink, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
case PROP_VIDEO_STREAM_COMBINER:
|
|
|
|
gst_play_bin3_set_stream_combiner (playbin,
|
|
|
|
&playbin->video_stream_combiner, "video", g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
case PROP_AUDIO_STREAM_COMBINER:
|
|
|
|
gst_play_bin3_set_stream_combiner (playbin,
|
|
|
|
&playbin->audio_stream_combiner, "audio", g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
case PROP_TEXT_STREAM_COMBINER:
|
|
|
|
gst_play_bin3_set_stream_combiner (playbin,
|
|
|
|
&playbin->text_stream_combiner, "text", g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
case PROP_VOLUME:
|
|
|
|
gst_play_sink_set_volume (playbin->playsink, g_value_get_double (value));
|
|
|
|
break;
|
|
|
|
case PROP_MUTE:
|
|
|
|
gst_play_sink_set_mute (playbin->playsink, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
case PROP_FONT_DESC:
|
|
|
|
gst_play_sink_set_font_desc (playbin->playsink,
|
|
|
|
g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
case PROP_CONNECTION_SPEED:
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_set_property ((GObject *) playbin->uridecodebin,
|
|
|
|
"connection-speed", value);
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
break;
|
|
|
|
case PROP_BUFFER_SIZE:
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_set_property ((GObject *) playbin->uridecodebin, "buffer-size",
|
|
|
|
value);
|
2016-06-29 16:14:51 +00:00
|
|
|
break;
|
|
|
|
case PROP_BUFFER_DURATION:
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_set_property ((GObject *) playbin->uridecodebin,
|
|
|
|
"buffer-duration", value);
|
2016-06-29 16:14:51 +00:00
|
|
|
break;
|
|
|
|
case PROP_AV_OFFSET:
|
|
|
|
gst_play_sink_set_av_offset (playbin->playsink,
|
|
|
|
g_value_get_int64 (value));
|
|
|
|
break;
|
2018-10-28 14:45:26 +00:00
|
|
|
case PROP_TEXT_OFFSET:
|
|
|
|
gst_play_sink_set_text_offset (playbin->playsink,
|
|
|
|
g_value_get_int64 (value));
|
|
|
|
break;
|
2016-06-29 16:14:51 +00:00
|
|
|
case PROP_RING_BUFFER_MAX_SIZE:
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_set_property ((GObject *) playbin->uridecodebin,
|
|
|
|
"ring-buffer-max-size", value);
|
2016-06-29 16:14:51 +00:00
|
|
|
break;
|
|
|
|
case PROP_FORCE_ASPECT_RATIO:
|
|
|
|
g_object_set (playbin->playsink, "force-aspect-ratio",
|
|
|
|
g_value_get_boolean (value), NULL);
|
|
|
|
break;
|
|
|
|
case PROP_MULTIVIEW_MODE:
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
playbin->multiview_mode = g_value_get_enum (value);
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
break;
|
|
|
|
case PROP_MULTIVIEW_FLAGS:
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
playbin->multiview_flags = g_value_get_flags (value);
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
break;
|
2022-07-21 14:43:47 +00:00
|
|
|
case PROP_INSTANT_URI:
|
|
|
|
g_object_set_property ((GObject *) playbin->uridecodebin,
|
|
|
|
"instant-uri", value);
|
|
|
|
break;
|
2016-06-29 16:14:51 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstElement *
|
|
|
|
gst_play_bin3_get_current_sink (GstPlayBin3 * playbin, GstElement ** elem,
|
|
|
|
const gchar * dbg, GstPlaySinkType type)
|
|
|
|
{
|
|
|
|
GstElement *sink = gst_play_sink_get_sink (playbin->playsink, type);
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (playbin, "play_sink_get_sink() returned %s sink %"
|
|
|
|
GST_PTR_FORMAT ", the originally set %s sink is %" GST_PTR_FORMAT,
|
|
|
|
dbg, sink, dbg, *elem);
|
|
|
|
|
|
|
|
if (sink == NULL) {
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
if ((sink = *elem))
|
|
|
|
gst_object_ref (sink);
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sink;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_URI:
|
|
|
|
{
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_get_property ((GObject *) playbin->uridecodebin, "uri", value);
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_CURRENT_URI:
|
|
|
|
{
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_get_property ((GObject *) playbin->uridecodebin, "current-uri",
|
|
|
|
value);
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_SUBURI:
|
|
|
|
{
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_get_property ((GObject *) playbin->uridecodebin, "suburi",
|
|
|
|
value);
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_CURRENT_SUBURI:
|
|
|
|
{
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_get_property ((GObject *) playbin->uridecodebin,
|
|
|
|
"current-suburi", value);
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_FLAGS:
|
2022-07-21 14:43:47 +00:00
|
|
|
g_value_set_flags (value, gst_play_sink_get_flags (playbin->playsink));
|
2016-06-29 16:14:51 +00:00
|
|
|
break;
|
|
|
|
case PROP_SUBTITLE_ENCODING:
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
g_value_take_string (value,
|
|
|
|
gst_play_sink_get_subtitle_encoding (playbin->playsink));
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
break;
|
|
|
|
case PROP_VIDEO_FILTER:
|
|
|
|
g_value_take_object (value,
|
|
|
|
gst_play_sink_get_filter (playbin->playsink,
|
|
|
|
GST_PLAY_SINK_TYPE_VIDEO));
|
|
|
|
break;
|
|
|
|
case PROP_AUDIO_FILTER:
|
|
|
|
g_value_take_object (value,
|
|
|
|
gst_play_sink_get_filter (playbin->playsink,
|
|
|
|
GST_PLAY_SINK_TYPE_AUDIO));
|
|
|
|
break;
|
|
|
|
case PROP_VIDEO_SINK:
|
|
|
|
g_value_take_object (value,
|
|
|
|
gst_play_bin3_get_current_sink (playbin, &playbin->video_sink,
|
|
|
|
"video", GST_PLAY_SINK_TYPE_VIDEO));
|
|
|
|
break;
|
|
|
|
case PROP_AUDIO_SINK:
|
|
|
|
g_value_take_object (value,
|
|
|
|
gst_play_bin3_get_current_sink (playbin, &playbin->audio_sink,
|
|
|
|
"audio", GST_PLAY_SINK_TYPE_AUDIO));
|
|
|
|
break;
|
|
|
|
case PROP_VIS_PLUGIN:
|
|
|
|
g_value_take_object (value,
|
|
|
|
gst_play_sink_get_vis_plugin (playbin->playsink));
|
|
|
|
break;
|
|
|
|
case PROP_TEXT_SINK:
|
|
|
|
g_value_take_object (value,
|
|
|
|
gst_play_bin3_get_current_sink (playbin, &playbin->text_sink,
|
|
|
|
"text", GST_PLAY_SINK_TYPE_TEXT));
|
|
|
|
break;
|
|
|
|
case PROP_VIDEO_STREAM_COMBINER:
|
2022-07-21 14:43:47 +00:00
|
|
|
g_value_set_object (value, playbin->video_stream_combiner);
|
2016-06-29 16:14:51 +00:00
|
|
|
break;
|
|
|
|
case PROP_AUDIO_STREAM_COMBINER:
|
2022-07-21 14:43:47 +00:00
|
|
|
g_value_set_object (value, playbin->audio_stream_combiner);
|
2016-06-29 16:14:51 +00:00
|
|
|
break;
|
|
|
|
case PROP_TEXT_STREAM_COMBINER:
|
2022-07-21 14:43:47 +00:00
|
|
|
g_value_set_object (value, playbin->text_stream_combiner);
|
2016-06-29 16:14:51 +00:00
|
|
|
break;
|
|
|
|
case PROP_VOLUME:
|
|
|
|
g_value_set_double (value, gst_play_sink_get_volume (playbin->playsink));
|
|
|
|
break;
|
|
|
|
case PROP_MUTE:
|
|
|
|
g_value_set_boolean (value, gst_play_sink_get_mute (playbin->playsink));
|
|
|
|
break;
|
|
|
|
case PROP_SAMPLE:
|
|
|
|
gst_value_take_sample (value,
|
|
|
|
gst_play_sink_get_last_sample (playbin->playsink));
|
|
|
|
break;
|
|
|
|
case PROP_FONT_DESC:
|
|
|
|
g_value_take_string (value,
|
|
|
|
gst_play_sink_get_font_desc (playbin->playsink));
|
|
|
|
break;
|
|
|
|
case PROP_CONNECTION_SPEED:
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_get_property ((GObject *) playbin->uridecodebin,
|
|
|
|
"connection-speed", value);
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
break;
|
|
|
|
case PROP_BUFFER_SIZE:
|
|
|
|
GST_OBJECT_LOCK (playbin);
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_get_property ((GObject *) playbin->uridecodebin, "buffer-size",
|
|
|
|
value);
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_OBJECT_UNLOCK (playbin);
|
|
|
|
break;
|
|
|
|
case PROP_BUFFER_DURATION:
|
|
|
|
GST_OBJECT_LOCK (playbin);
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_get_property ((GObject *) playbin->uridecodebin,
|
|
|
|
"buffer-duration", value);
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_OBJECT_UNLOCK (playbin);
|
|
|
|
break;
|
|
|
|
case PROP_AV_OFFSET:
|
|
|
|
g_value_set_int64 (value,
|
|
|
|
gst_play_sink_get_av_offset (playbin->playsink));
|
|
|
|
break;
|
2018-10-28 14:45:26 +00:00
|
|
|
case PROP_TEXT_OFFSET:
|
|
|
|
g_value_set_int64 (value,
|
|
|
|
gst_play_sink_get_text_offset (playbin->playsink));
|
|
|
|
break;
|
2016-06-29 16:14:51 +00:00
|
|
|
case PROP_RING_BUFFER_MAX_SIZE:
|
2022-07-21 14:43:47 +00:00
|
|
|
g_object_get_property ((GObject *) playbin->uridecodebin,
|
|
|
|
"ring-buffer-max-size", value);
|
2016-06-29 16:14:51 +00:00
|
|
|
break;
|
|
|
|
case PROP_FORCE_ASPECT_RATIO:{
|
|
|
|
gboolean v;
|
|
|
|
|
|
|
|
g_object_get (playbin->playsink, "force-aspect-ratio", &v, NULL);
|
|
|
|
g_value_set_boolean (value, v);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_MULTIVIEW_MODE:
|
|
|
|
GST_OBJECT_LOCK (playbin);
|
|
|
|
g_value_set_enum (value, playbin->multiview_mode);
|
|
|
|
GST_OBJECT_UNLOCK (playbin);
|
|
|
|
break;
|
|
|
|
case PROP_MULTIVIEW_FLAGS:
|
|
|
|
GST_OBJECT_LOCK (playbin);
|
|
|
|
g_value_set_flags (value, playbin->multiview_flags);
|
|
|
|
GST_OBJECT_UNLOCK (playbin);
|
|
|
|
break;
|
2022-07-21 14:43:47 +00:00
|
|
|
case PROP_INSTANT_URI:
|
|
|
|
g_object_get_property ((GObject *) playbin->uridecodebin,
|
|
|
|
"instant-uri", value);
|
|
|
|
break;
|
2016-06-29 16:14:51 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
get_combiner_stream_id (GstPlayBin3 * playbin, GstSourceCombine * combine,
|
|
|
|
GList * full_list)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GList *tmp;
|
|
|
|
|
2017-12-15 01:50:44 +00:00
|
|
|
for (i = 0; i < combine->streams->len; i++) {
|
2016-06-29 16:14:51 +00:00
|
|
|
GstStream *stream = (GstStream *) g_ptr_array_index (combine->streams, i);
|
|
|
|
const gchar *sid = gst_stream_get_stream_id (stream);
|
|
|
|
for (tmp = full_list; tmp; tmp = tmp->next) {
|
|
|
|
gchar *orig = (gchar *) tmp->data;
|
|
|
|
if (!g_strcmp0 (orig, sid))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fallback */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
extend_list_of_streams (GstPlayBin3 * playbin, GstStreamType stype,
|
2017-11-09 10:17:13 +00:00
|
|
|
GList * list, GstStreamCollection * collection)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
|
|
|
GList *tmp, *res;
|
|
|
|
gint i, nb;
|
|
|
|
|
|
|
|
res = list;
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
nb = gst_stream_collection_get_size (collection);
|
2016-06-29 16:14:51 +00:00
|
|
|
for (i = 0; i < nb; i++) {
|
2017-11-09 10:17:13 +00:00
|
|
|
GstStream *stream = gst_stream_collection_get_stream (collection, i);
|
2016-06-29 16:14:51 +00:00
|
|
|
GstStreamType curtype = gst_stream_get_stream_type (stream);
|
|
|
|
if (stype == curtype) {
|
|
|
|
gboolean already_there = FALSE;
|
|
|
|
const gchar *sid = gst_stream_get_stream_id (stream);
|
|
|
|
for (tmp = res; tmp; tmp = tmp->next) {
|
|
|
|
const gchar *other = (const gchar *) tmp->data;
|
|
|
|
if (!g_strcmp0 (sid, other)) {
|
|
|
|
already_there = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!already_there) {
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Adding stream %s", sid);
|
|
|
|
res = g_list_append (res, g_strdup (sid));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstEvent *
|
2022-07-21 14:43:47 +00:00
|
|
|
update_select_streams_event (GstPlayBin3 * playbin, GstEvent * event)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
|
|
|
GList *streams = NULL;
|
|
|
|
GList *to_use;
|
|
|
|
gint combine_id;
|
|
|
|
|
|
|
|
if (!playbin->audio_stream_combiner && !playbin->video_stream_combiner &&
|
|
|
|
!playbin->text_stream_combiner) {
|
|
|
|
/* Nothing to do */
|
|
|
|
GST_DEBUG_OBJECT (playbin,
|
|
|
|
"No custom combiners, no need to modify SELECT_STREAMS event");
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
if (!playbin->collection) {
|
2017-11-09 10:17:13 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin,
|
2022-07-21 14:43:47 +00:00
|
|
|
"No stream collection, no need to modify SELECT_STREAMS event");
|
2017-11-09 10:17:13 +00:00
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
gst_event_parse_select_streams (event, &streams);
|
|
|
|
to_use = g_list_copy_deep (streams, (GCopyFunc) g_strdup, NULL);
|
|
|
|
|
|
|
|
/* For each combiner, we want to add all streams of that type to the
|
|
|
|
* selection */
|
|
|
|
if (playbin->audio_stream_combiner) {
|
2017-11-09 10:17:13 +00:00
|
|
|
to_use =
|
|
|
|
extend_list_of_streams (playbin, GST_STREAM_TYPE_AUDIO, to_use,
|
2022-07-21 14:43:47 +00:00
|
|
|
playbin->collection);
|
2016-06-29 16:14:51 +00:00
|
|
|
combine_id =
|
|
|
|
get_combiner_stream_id (playbin,
|
|
|
|
&playbin->combiner[PLAYBIN_STREAM_AUDIO], streams);
|
|
|
|
if (combine_id != -1)
|
|
|
|
gst_play_bin3_set_current_audio_stream (playbin, combine_id);
|
|
|
|
}
|
|
|
|
if (playbin->video_stream_combiner) {
|
2017-11-09 10:17:13 +00:00
|
|
|
to_use =
|
|
|
|
extend_list_of_streams (playbin, GST_STREAM_TYPE_VIDEO, to_use,
|
2022-07-21 14:43:47 +00:00
|
|
|
playbin->collection);
|
2016-06-29 16:14:51 +00:00
|
|
|
combine_id =
|
|
|
|
get_combiner_stream_id (playbin,
|
|
|
|
&playbin->combiner[PLAYBIN_STREAM_VIDEO], streams);
|
|
|
|
if (combine_id != -1)
|
|
|
|
gst_play_bin3_set_current_video_stream (playbin, combine_id);
|
|
|
|
}
|
|
|
|
if (playbin->text_stream_combiner) {
|
2017-11-09 10:17:13 +00:00
|
|
|
to_use =
|
|
|
|
extend_list_of_streams (playbin, GST_STREAM_TYPE_TEXT, to_use,
|
2022-07-21 14:43:47 +00:00
|
|
|
playbin->collection);
|
2016-06-29 16:14:51 +00:00
|
|
|
combine_id =
|
|
|
|
get_combiner_stream_id (playbin,
|
|
|
|
&playbin->combiner[PLAYBIN_STREAM_TEXT], streams);
|
|
|
|
if (combine_id != -1)
|
|
|
|
gst_play_bin3_set_current_text_stream (playbin, combine_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_event_unref (event);
|
2016-12-03 03:43:22 +00:00
|
|
|
event = gst_event_new_select_streams (to_use);
|
|
|
|
|
|
|
|
if (streams)
|
|
|
|
g_list_free_full (streams, g_free);
|
|
|
|
if (to_use)
|
|
|
|
g_list_free_full (to_use, g_free);
|
|
|
|
|
|
|
|
return event;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_play_bin3_send_event (GstElement * element, GstEvent * event)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (element);
|
|
|
|
|
|
|
|
if (GST_EVENT_TYPE (event) == GST_EVENT_SELECT_STREAMS) {
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
GST_LOG_OBJECT (playbin,
|
|
|
|
"App sent select-streams, we won't do anything ourselves now");
|
|
|
|
/* This is probably already false, but it doesn't hurt to be sure */
|
|
|
|
playbin->do_stream_selections = FALSE;
|
|
|
|
|
|
|
|
/* If we have custom combiners, we need to extend the selection with
|
|
|
|
* the list of all streams for that given type since we will be handling
|
|
|
|
* the selection with that combiner */
|
2022-07-21 14:43:47 +00:00
|
|
|
event = update_select_streams_event (playbin, event);
|
2017-11-09 10:17:13 +00:00
|
|
|
|
2022-01-17 15:52:47 +00:00
|
|
|
/* Don't reconfigure playsink just yet, until the streams-selected
|
|
|
|
* message(s) tell us as streams become active / available */
|
2016-06-29 16:14:51 +00:00
|
|
|
|
playbin3: Fix deadlock while selecting streams going to playing
In the following backtrace for the deadlock, we can see that:
- In T8 `uridecodebin3` is exposing a new pad, in `pad_added_cb`,
`playbin3` is trying to get `GST_PLAY_BIN3_LOCK` in the callback. This
threads holds its `SELECTION_LOCK` in F17 `reconfigure_output_stream`,
which is looks right `decodebin3` is handling its selection state
in that code path
- In T7 `playbin3` holds the `GST_PLAY_BIN3_LOCK` when calling
`gst_element_post_message` in `gst_play_bin3_send_event` which is
not necessary in that section of the code.
``` bt
Thread 8 (Thread 0x7f0b78ee36c0 (LWP 2952467) "multiqueue0:src"):
#0 futex_wait (private=0, expected=2, futex_word=0x1fa6d60) at ../sysdeps/nptl/futex-internal.h:146
#1 __GI___lll_lock_wait (futex=futex@entry=0x1fa6d60, private=0) at lowlevellock.c:49
#2 0x00007f0b858cd46a in lll_mutex_lock_optimized (mutex=0x1fa6d60) at pthread_mutex_lock.c:48
#3 ___pthread_mutex_lock (mutex=0x1fa6d60) at pthread_mutex_lock.c:128
#4 0x00007f0b7e665720 in pad_added_cb (uridecodebin=0x1fb4050, pad=0x7f0b54022060, playbin=0x1fb00e0) at ../subprojects/gst-plugins-base/gst/playback/gstplaybin3.c:2463
#5 0x00007f0b85c00060 in g_closure_invoke (closure=0x1fa9eb0, return_value=0x0, n_param_values=2, param_values=0x7f0b78ee1dd0, invocation_hint=0x7f0b78ee1d50) at ../gobject/gclosure.c:832
#6 0x00007f0b85c2cf66 in signal_emit_unlocked_R.isra.0 (node=node@entry=0x1c5bf30, detail=detail@entry=0, instance=instance@entry=0x1fb4050, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7f0b78ee1dd0) at ../gobject/gsignal.c:3796
#7 0x00007f0b85c1d4da in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7f0b78ee1f90) at ../gobject/gsignal.c:3549
#8 0x00007f0b85c1d6f3 in g_signal_emit (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at ../gobject/gsignal.c:3606
#9 0x00007f0b85e20c3e in gst_element_add_pad (element=0x1fb4050, pad=0x7f0b54022060) at ../subprojects/gstreamer/gst/gstelement.c:802
#10 0x00007f0b7e632620 in add_output_pad (dec=0x1fb4050, target_pad=0x7f0b6400fda0) at ../subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c:717
#11 0x00007f0b7e632788 in db_pad_added_cb (element=0x1fb8020, pad=0x7f0b6400fda0, dec=0x1fb4050) at ../subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c:736
#12 0x00007f0b85c00060 in g_closure_invoke (closure=0x1fb7fc0, return_value=0x0, n_param_values=2, param_values=0x7f0b78ee2300, invocation_hint=0x7f0b78ee2280) at ../gobject/gclosure.c:832
#13 0x00007f0b85c2cf66 in signal_emit_unlocked_R.isra.0 (node=node@entry=0x1c5bf30, detail=detail@entry=0, instance=instance@entry=0x1fb8020, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7f0b78ee2300) at ../gobject/gsignal.c:3796
#14 0x00007f0b85c1d4da in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7f0b78ee24c0) at ../gobject/gsignal.c:3549
#15 0x00007f0b85c1d6f3 in g_signal_emit (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at ../gobject/gsignal.c:3606
#16 0x00007f0b85e20c3e in gst_element_add_pad (element=0x1fb8020, pad=0x7f0b6400fda0) at ../subprojects/gstreamer/gst/gstelement.c:802
#17 0x00007f0b7e6260b4 in reconfigure_output_stream (output=0x7f0b5400def0, slot=0x7f0b64013dd0, msg=0x7f0b78ee26b8) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:3086
#18 0x00007f0b7e623700 in check_slot_reconfiguration (dbin=0x1fb8020, slot=0x7f0b64013dd0) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:2455
#19 0x00007f0b7e623e62 in multiqueue_src_probe (pad=0x7f0b6001e600, info=0x7f0b78ee2930, slot=0x7f0b64013dd0) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:2544
#20 0x00007f0b85e53aaa in probe_hook_marshal (hook=0x7f0b74040500, data=0x7f0b78ee28c0) at ../subprojects/gstreamer/gst/gstpad.c:3669
#21 0x00007f0b85c88a3e in g_hook_list_marshal (hook_list=0x7f0b6001e698, may_recurse=1, marshaller=0x7f0b85e53786 <probe_hook_marshal>, data=0x7f0b78ee28c0) at ../glib/ghook.c:674
#22 0x00007f0b85e541be in do_probe_callbacks (pad=0x7f0b6001e600, info=0x7f0b78ee2930, defaultval=GST_FLOW_OK) at ../subprojects/gstreamer/gst/gstpad.c:3853
#23 0x00007f0b85e5ac9c in gst_pad_push_event_unchecked (pad=0x7f0b6001e600, event=0x7f0b64002120, type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5538
#24 0x00007f0b85e54bc2 in push_sticky (pad=0x7f0b6001e600, ev=0x7f0b78ee2a60, user_data=0x7f0b78ee2ac0) at ../subprojects/gstreamer/gst/gstpad.c:4057
#25 0x00007f0b85e4a13c in events_foreach (pad=0x7f0b6001e600, func=0x7f0b85e54a8e <push_sticky>, user_data=0x7f0b78ee2ac0) at ../subprojects/gstreamer/gst/gstpad.c:613
#26 0x00007f0b85e54f91 in check_sticky (pad=0x7f0b6001e600, event=0x7f0b64002120) at ../subprojects/gstreamer/gst/gstpad.c:4116
#27 0x00007f0b85e5b65e in gst_pad_push_event (pad=0x7f0b6001e600, event=0x7f0b64002120) at ../subprojects/gstreamer/gst/gstpad.c:5706
#28 0x00007f0b7e5888e7 in gst_single_queue_push_one (mq=0x1fbb000, sq=0x7f0b64013b70, object=0x7f0b64002120, allow_drop=0x7f0b78ee2c3c) at ../subprojects/gstreamer/plugins/elements/gstmultiqueue.c:2068
#29 0x00007f0b7e58a1bc in gst_multi_queue_loop (pad=0x7f0b6001e600) at ../subprojects/gstreamer/plugins/elements/gstmultiqueue.c:2347
#30 0x00007f0b85e96a36 in gst_task_func (task=0x7f0b64016050) at ../subprojects/gstreamer/gst/gsttask.c:399
#31 0x00007f0b85e97e41 in default_func (tdata=0x7f0b640138d0, pool=0x1fbe9c0) at ../subprojects/gstreamer/gst/gsttaskpool.c:70
#32 0x00007f0b85cd1ab2 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/gthreadpool.c:352
#33 0x00007f0b85ccc982 in g_thread_proxy (data=0x7f0b6006f640) at ../glib/gthread.c:831
#34 0x00007f0b858ca12d in start_thread (arg=<optimized out>) at pthread_create.c:442
#35 0x00007f0b8594bbc0 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
Thread 7 (Thread 0x7f0b7a7646c0 (LWP 2952434) "multiqueue3:src"):
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f0b85cf470c in g_mutex_lock_slowpath (mutex=0x1fb81d0) at ../glib/gthread-posix.c:1494
#2 0x00007f0b7e6281a2 in gst_decodebin3_send_event (element=0x1fb8020, event=0x7f0b6800a650) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:3561
#3 0x00007f0b85e23ca3 in gst_element_send_event (element=0x1fb8020, event=0x7f0b6800a650) at ../subprojects/gstreamer/gst/gstelement.c:1994
#4 0x00007f0b7e63806b in gst_uri_decodebin3_send_event (element=0x1fb4050, event=0x7f0b6800a650) at ../subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c:2227
#5 0x00007f0b85e23ca3 in gst_element_send_event (element=0x1fb4050, event=0x7f0b6800a650) at ../subprojects/gstreamer/gst/gstelement.c:1994
#6 0x00007f0b7e66375a in gst_play_bin3_send_event (element=0x1fb00e0, event=0x7f0b6800a650) at ../subprojects/gst-plugins-base/gst/playback/gstplaybin3.c:1863
#7 0x00007f0b85e23ca3 in gst_element_send_event (element=0x1fb00e0, event=0x7f0b6800a650) at ../subprojects/gstreamer/gst/gstelement.c:1994
#8 0x00007f0b85f61b5b in stream_selection_cb (bus=0x1dc2d80, message=0x7f0b68008b00, d=0x1d7de30) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c:2235
#9 0x00007f0b85c00060 in g_closure_invoke (closure=0x1d2a5b0, return_value=0x0, n_param_values=2, param_values=0x7f0b7a7627b0, invocation_hint=0x7f0b7a762730) at ../gobject/gclosure.c:832
#10 0x00007f0b85c2cf66 in signal_emit_unlocked_R.isra.0 (node=node@entry=0x1c5e5f0, detail=detail@entry=235, instance=instance@entry=0x1dc2d80, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7f0b7a7627b0) at ../gobject/gsignal.c:3796
#11 0x00007f0b85c1d4da in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7f0b7a762970) at ../gobject/gsignal.c:3549
#12 0x00007f0b85c1d6f3 in g_signal_emit (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at ../gobject/gsignal.c:3606
#13 0x00007f0b85e05be9 in gst_bus_sync_signal_handler (bus=0x1dc2d80, message=0x7f0b68008b00, data=0x0) at ../subprojects/gstreamer/gst/gstbus.c:1307
#14 0x00007f0b85e03834 in gst_bus_post (bus=0x1dc2d80, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbus.c:364
#15 0x00007f0b85e2436c in gst_element_post_message_default (element=0x1fb00e0, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstelement.c:2127
#16 0x00007f0b85df42b1 in gst_bin_post_message (element=0x1fb00e0, msg=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbin.c:2789
#17 0x00007f0b85e24627 in gst_element_post_message (element=0x1fb00e0, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstelement.c:2170
#18 0x00007f0b85df7c12 in gst_bin_handle_message_func (bin=0x1fb00e0, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbin.c:4041
#19 0x00007f0b85e61bd3 in gst_pipeline_handle_message (bin=0x1fb00e0, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstpipeline.c:669
#20 0x00007f0b7e663fa4 in gst_play_bin3_handle_message (bin=0x1fb00e0, msg=0x7f0b68008b00) at ../subprojects/gst-plugins-base/gst/playback/gstplaybin3.c:2030
#21 0x00007f0b85df5a98 in bin_bus_handler (bus=0x1dc2cc0, message=0x7f0b68008b00, bin=0x1fb00e0) at ../subprojects/gstreamer/gst/gstbin.c:3263
#22 0x00007f0b85e037f1 in gst_bus_post (bus=0x1dc2cc0, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbus.c:357
#23 0x00007f0b85e2436c in gst_element_post_message_default (element=0x1fb4050, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstelement.c:2127
#24 0x00007f0b85df42b1 in gst_bin_post_message (element=0x1fb4050, msg=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbin.c:2789
#25 0x00007f0b85e24627 in gst_element_post_message (element=0x1fb4050, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstelement.c:2170
#26 0x00007f0b85df7c12 in gst_bin_handle_message_func (bin=0x1fb4050, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbin.c:4041
#27 0x00007f0b7e638005 in gst_uri_decode_bin3_handle_message (bin=0x1fb4050, msg=0x7f0b68008b00) at ../subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c:2218
#28 0x00007f0b85df5a98 in bin_bus_handler (bus=0x1dc2e40, message=0x7f0b68008b00, bin=0x1fb4050) at ../subprojects/gstreamer/gst/gstbin.c:3263
#29 0x00007f0b85e037f1 in gst_bus_post (bus=0x1dc2e40, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbus.c:357
#30 0x00007f0b85e2436c in gst_element_post_message_default (element=0x1fb8020, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstelement.c:2127
#31 0x00007f0b85df42b1 in gst_bin_post_message (element=0x1fb8020, msg=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbin.c:2789
#32 0x00007f0b85e24627 in gst_element_post_message (element=0x1fb8020, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstelement.c:2170
#33 0x00007f0b7e61ee43 in sink_event_function (sinkpad=0x7f0b6400f8c0, dbin=0x1fb8020, event=0x7f0b6c097870) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:1450
#34 0x00007f0b85f51122 in gst_validate_pad_monitor_downstream_event_check (pad_monitor=0x7f0b6c094a80, parent=0x1fb8020, event=0x7f0b6c097870, handler=0x7f0b7e61e797 <sink_event_function>) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2101
#35 0x00007f0b85f535bf in gst_validate_pad_monitor_sink_event_full_func (pad=0x7f0b6400f8c0, parent=0x1fb8020, event=0x7f0b6c097870) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2406
#36 0x00007f0b85f537fa in gst_validate_pad_monitor_sink_event_func (pad=0x7f0b6400f8c0, parent=0x1fb8020, event=0x7f0b6c097870) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2418
#37 0x00007f0b85e5c523 in gst_pad_send_event_unchecked (pad=0x7f0b6400f8c0, event=0x7f0b6c097870, type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5940
#38 0x00007f0b85e5ae65 in gst_pad_push_event_unchecked (pad=0x7f0b6400f650, event=0x7f0b6c097870, type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5573
#39 0x00007f0b85e54bc2 in push_sticky (pad=0x7f0b6400f650, ev=0x7f0b7a763620, user_data=0x7f0b7a763680) at ../subprojects/gstreamer/gst/gstpad.c:4057
#40 0x00007f0b85e4a13c in events_foreach (pad=0x7f0b6400f650, func=0x7f0b85e54a8e <push_sticky>, user_data=0x7f0b7a763680) at ../subprojects/gstreamer/gst/gstpad.c:613
#41 0x00007f0b85e54f91 in check_sticky (pad=0x7f0b6400f650, event=0x7f0b6c097870) at ../subprojects/gstreamer/gst/gstpad.c:4116
#42 0x00007f0b85e5b65e in gst_pad_push_event (pad=0x7f0b6400f650, event=0x7f0b6c097870) at ../subprojects/gstreamer/gst/gstpad.c:5706
#43 0x00007f0b85e523e7 in event_forward_func (pad=0x7f0b6400f650, data=0x7f0b7a763820) at ../subprojects/gstreamer/gst/gstpad.c:3130
#44 0x00007f0b85e521e3 in gst_pad_forward (pad=0x7f0b6004f180, forward=0x7f0b85e522bd <event_forward_func>, user_data=0x7f0b7a763820) at ../subprojects/gstreamer/gst/gstpad.c:3084
#45 0x00007f0b85e525ab in gst_pad_event_default (pad=0x7f0b6004f180, parent=0x7f0b6400f650, event=0x7f0b6c097870) at ../subprojects/gstreamer/gst/gstpad.c:3181
#46 0x00007f0b85e5c523 in gst_pad_send_event_unchecked (pad=0x7f0b6004f180, event=0x7f0b6c097870, type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5940
#47 0x00007f0b85e5ae65 in gst_pad_push_event_unchecked (pad=0x7f0b64008360, event=0x7f0b6c097870, type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5573
#48 0x00007f0b85e54bc2 in push_sticky (pad=0x7f0b64008360, ev=0x7f0b7a763a60, user_data=0x7f0b7a763ac0) at ../subprojects/gstreamer/gst/gstpad.c:4057
#49 0x00007f0b85e4a13c in events_foreach (pad=0x7f0b64008360, func=0x7f0b85e54a8e <push_sticky>, user_data=0x7f0b7a763ac0) at ../subprojects/gstreamer/gst/gstpad.c:613
#50 0x00007f0b85e54f91 in check_sticky (pad=0x7f0b64008360, event=0x7f0b6c097870) at ../subprojects/gstreamer/gst/gstpad.c:4116
#51 0x00007f0b85e5b65e in gst_pad_push_event (pad=0x7f0b64008360, event=0x7f0b6c097870) at ../subprojects/gstreamer/gst/gstpad.c:5706
#52 0x00007f0b7e5888e7 in gst_single_queue_push_one (mq=0x7f0b60076540, sq=0x7f0b6c093300, object=0x7f0b6c097870, allow_drop=0x7f0b7a763c3c) at ../subprojects/gstreamer/plugins/elements/gstmultiqueue.c:2068
#53 0x00007f0b7e58a1bc in gst_multi_queue_loop (pad=0x7f0b64008360) at ../subprojects/gstreamer/plugins/elements/gstmultiqueue.c:2347
#54 0x00007f0b85e96a36 in gst_task_func (task=0x7f0b6c072050) at ../subprojects/gstreamer/gst/gsttask.c:399
#55 0x00007f0b85e97e41 in default_func (tdata=0x7f0b6c093ef0, pool=0x1fbe9c0) at ../subprojects/gstreamer/gst/gsttaskpool.c:70
#56 0x00007f0b85cd1ab2 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/gthreadpool.c:352
#57 0x00007f0b85ccc982 in g_thread_proxy (data=0x7f0b70033800) at ../glib/gthread.c:831
#58 0x00007f0b858ca12d in start_thread (arg=<optimized out>) at pthread_create.c:442
#59 0x00007f0b8594bbc0 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
```
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5982>
2023-07-30 21:06:41 +00:00
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* Send this event directly to uridecodebin, so it works even
|
|
|
|
* if uridecodebin didn't add any pads yet */
|
2022-07-21 14:43:47 +00:00
|
|
|
res = gst_element_send_event (playbin->uridecodebin, event);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Send event directly to playsink instead of letting GstBin iterate
|
|
|
|
* over all sink elements. The latter might send the event multiple times
|
|
|
|
* in case the SEEK causes a reconfiguration of the pipeline, as can easily
|
|
|
|
* happen with adaptive streaming demuxers.
|
|
|
|
*
|
|
|
|
* What would then happen is that the iterator would be reset, we send the
|
|
|
|
* event again, and on the second time it will fail in the majority of cases
|
|
|
|
* because the pipeline is still being reconfigured
|
|
|
|
*/
|
|
|
|
if (GST_EVENT_IS_UPSTREAM (event)) {
|
|
|
|
return gst_element_send_event (GST_ELEMENT_CAST (playbin->playsink), event);
|
|
|
|
}
|
|
|
|
|
|
|
|
return GST_ELEMENT_CLASS (parent_class)->send_event (element, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called with playbin lock held */
|
|
|
|
static void
|
2022-07-21 14:43:47 +00:00
|
|
|
do_stream_selection (GstPlayBin3 * playbin)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
|
|
|
GstStreamCollection *collection;
|
|
|
|
guint i, nb_streams;
|
|
|
|
GList *streams = NULL;
|
|
|
|
gint nb_video = 0, nb_audio = 0, nb_text = 0;
|
|
|
|
GstStreamType chosen_stream_types = 0;
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
collection = playbin->collection;
|
2016-06-29 16:14:51 +00:00
|
|
|
if (collection == NULL) {
|
|
|
|
GST_LOG_OBJECT (playbin, "No stream collection. Not doing stream-select");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nb_streams = gst_stream_collection_get_size (collection);
|
|
|
|
if (nb_streams == 0) {
|
|
|
|
GST_INFO_OBJECT (playbin, "Empty collection received! Ignoring");
|
|
|
|
}
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin, "Doing selection on collection with %d streams",
|
|
|
|
nb_streams);
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
/* Iterate the collection and choose the streams that match
|
|
|
|
* either the current-* setting, or all streams of a type if there's
|
|
|
|
* a combiner for that type */
|
|
|
|
for (i = 0; i < nb_streams; i++) {
|
|
|
|
GstStream *stream = gst_stream_collection_get_stream (collection, i);
|
|
|
|
GstStreamType stream_type = gst_stream_get_stream_type (stream);
|
|
|
|
const gchar *stream_id = gst_stream_get_stream_id (stream);
|
|
|
|
gint pb_stream_type = -1;
|
|
|
|
gboolean select_this = FALSE;
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
GST_LOG_OBJECT (playbin, "Looking at stream #%d : %s", i, stream_id);
|
|
|
|
|
2016-10-13 09:42:28 +00:00
|
|
|
if (stream_type & GST_STREAM_TYPE_AUDIO) {
|
|
|
|
pb_stream_type = PLAYBIN_STREAM_AUDIO;
|
|
|
|
/* Select the stream if it's the current one or if there's a custom selector */
|
|
|
|
select_this =
|
|
|
|
(nb_audio == playbin->current_audio ||
|
|
|
|
(playbin->current_audio == -1 && nb_audio == 0) ||
|
|
|
|
playbin->audio_stream_combiner != NULL);
|
|
|
|
nb_audio++;
|
|
|
|
} else if (stream_type & GST_STREAM_TYPE_VIDEO) {
|
2018-05-17 04:54:35 +00:00
|
|
|
pb_stream_type = PLAYBIN_STREAM_VIDEO;
|
2016-10-13 09:42:28 +00:00
|
|
|
select_this =
|
|
|
|
(nb_video == playbin->current_video ||
|
|
|
|
(playbin->current_video == -1 && nb_video == 0) ||
|
|
|
|
playbin->video_stream_combiner != NULL);
|
|
|
|
nb_video++;
|
|
|
|
} else if (stream_type & GST_STREAM_TYPE_TEXT) {
|
|
|
|
pb_stream_type = PLAYBIN_STREAM_TEXT;
|
|
|
|
select_this =
|
|
|
|
(nb_text == playbin->current_text ||
|
|
|
|
(playbin->current_text == -1 && nb_text == 0) ||
|
|
|
|
playbin->text_stream_combiner != NULL);
|
|
|
|
nb_text++;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
if (pb_stream_type < 0) {
|
|
|
|
GST_DEBUG_OBJECT (playbin,
|
|
|
|
"Stream %d (id %s) of unhandled type %s. Ignoring", i, stream_id,
|
|
|
|
gst_stream_type_get_name (stream_type));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (select_this) {
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Selecting stream %s of type %s",
|
|
|
|
stream_id, gst_stream_type_get_name (stream_type));
|
|
|
|
/* Don't build the list if we're not in charge of stream selection */
|
|
|
|
if (playbin->do_stream_selections)
|
|
|
|
streams = g_list_append (streams, (gpointer) stream_id);
|
|
|
|
chosen_stream_types |= stream_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (streams) {
|
2022-07-21 14:43:47 +00:00
|
|
|
GstEvent *ev = gst_event_new_select_streams (streams);
|
|
|
|
gst_element_send_event ((GstElement *) playbin->collection_source, ev);
|
2016-06-29 16:14:51 +00:00
|
|
|
g_list_free (streams);
|
|
|
|
}
|
2017-11-09 10:17:13 +00:00
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
playbin->selected_stream_types = chosen_stream_types;
|
2017-11-09 10:17:13 +00:00
|
|
|
if (playbin->active_stream_types != playbin->selected_stream_types)
|
|
|
|
reconfigure_output (playbin);
|
|
|
|
}
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
static void
|
|
|
|
gst_play_bin3_handle_message (GstBin * bin, GstMessage * msg)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (bin);
|
2021-04-12 12:02:46 +00:00
|
|
|
gboolean do_reset_time = FALSE;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAM_COLLECTION) {
|
2016-06-29 16:14:51 +00:00
|
|
|
GstStreamCollection *collection = NULL;
|
|
|
|
|
|
|
|
gst_message_parse_stream_collection (msg, &collection);
|
|
|
|
|
|
|
|
if (collection) {
|
2017-11-09 10:17:13 +00:00
|
|
|
gboolean pstate = playbin->do_stream_selections;
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
GST_DEBUG_OBJECT (playbin,
|
2017-11-09 10:17:13 +00:00
|
|
|
"STREAM_COLLECTION: Got a collection from %" GST_PTR_FORMAT,
|
|
|
|
msg->src);
|
2022-07-21 14:43:47 +00:00
|
|
|
gst_object_replace ((GstObject **) & playbin->collection,
|
|
|
|
(GstObject *) collection);
|
|
|
|
gst_object_replace ((GstObject **) & playbin->collection_source,
|
|
|
|
(GstObject *) GST_MESSAGE_SRC (msg));
|
|
|
|
|
|
|
|
update_combiner_info (playbin, playbin->collection);
|
2016-06-29 16:14:51 +00:00
|
|
|
if (pstate)
|
|
|
|
playbin->do_stream_selections = FALSE;
|
2022-07-21 14:43:47 +00:00
|
|
|
do_stream_selection (playbin);
|
2016-06-29 16:14:51 +00:00
|
|
|
if (pstate)
|
|
|
|
playbin->do_stream_selections = TRUE;
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
|
2016-07-13 14:02:25 +00:00
|
|
|
gst_object_unref (collection);
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
2021-04-12 12:02:46 +00:00
|
|
|
} else if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_RESET_TIME) {
|
|
|
|
if (playbin->is_live && GST_STATE_TARGET (playbin) == GST_STATE_PLAYING) {
|
|
|
|
do_reset_time = TRUE;
|
|
|
|
}
|
2022-01-17 15:52:47 +00:00
|
|
|
} else if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED) {
|
2022-07-21 14:43:47 +00:00
|
|
|
GstStreamType selected_types = 0;
|
|
|
|
guint i, nb;
|
2022-01-17 15:52:47 +00:00
|
|
|
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
nb = gst_message_streams_selected_get_size (msg);
|
|
|
|
for (i = 0; i < nb; i++) {
|
|
|
|
GstStream *stream = gst_message_streams_selected_get_stream (msg, i);
|
|
|
|
selected_types |= gst_stream_get_stream_type (stream);
|
|
|
|
gst_object_unref (stream);
|
|
|
|
}
|
|
|
|
playbin->selected_stream_types = selected_types;
|
|
|
|
if (playbin->active_stream_types != playbin->selected_stream_types) {
|
|
|
|
GST_DEBUG_OBJECT (playbin,
|
|
|
|
"selected stream types changed, reconfiguring output");
|
|
|
|
reconfigure_output (playbin);
|
2022-01-17 15:52:47 +00:00
|
|
|
}
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (msg)
|
|
|
|
GST_BIN_CLASS (parent_class)->handle_message (bin, msg);
|
2021-04-12 12:02:46 +00:00
|
|
|
|
|
|
|
if (do_reset_time) {
|
|
|
|
/* If we are live, sample a new base_time immediately */
|
|
|
|
gst_element_change_state (GST_ELEMENT (playbin),
|
|
|
|
GST_STATE_CHANGE_PAUSED_TO_PLAYING);
|
|
|
|
}
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
2016-08-08 19:04:11 +00:00
|
|
|
static void
|
|
|
|
gst_play_bin3_deep_element_added (GstBin * playbin, GstBin * sub_bin,
|
|
|
|
GstElement * child)
|
|
|
|
{
|
|
|
|
GST_LOG_OBJECT (playbin, "element %" GST_PTR_FORMAT " was added to "
|
|
|
|
"%" GST_PTR_FORMAT, child, sub_bin);
|
|
|
|
|
|
|
|
g_signal_emit (playbin, gst_play_bin3_signals[SIGNAL_ELEMENT_SETUP], 0,
|
|
|
|
child);
|
|
|
|
|
|
|
|
GST_BIN_CLASS (parent_class)->deep_element_added (playbin, sub_bin, child);
|
|
|
|
}
|
|
|
|
|
2017-11-09 10:16:20 +00:00
|
|
|
/* Returns current stream number, or -1 if none has been selected yet */
|
|
|
|
static int
|
2022-05-06 07:10:09 +00:00
|
|
|
get_current_stream_number (GstPlayBin3 * playbin, GstSourceCombine * combine)
|
2017-11-09 10:16:20 +00:00
|
|
|
{
|
|
|
|
/* Internal API cleanup would make this easier... */
|
|
|
|
int i;
|
|
|
|
GstPad *pad, *current;
|
|
|
|
GstObject *combiner = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!combine->has_active_pad) {
|
|
|
|
GST_WARNING_OBJECT (playbin,
|
|
|
|
"combiner doesn't have the \"active-pad\" property");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-05-06 07:10:09 +00:00
|
|
|
for (i = 0; i < combine->inputpads->len; i++) {
|
|
|
|
pad = g_ptr_array_index (combine->inputpads, i);
|
2017-11-09 10:16:20 +00:00
|
|
|
if ((combiner = gst_pad_get_parent (pad))) {
|
|
|
|
g_object_get (combiner, "active-pad", ¤t, NULL);
|
|
|
|
gst_object_unref (combiner);
|
|
|
|
|
|
|
|
if (pad == current) {
|
|
|
|
gst_object_unref (current);
|
|
|
|
ret = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (current)
|
|
|
|
gst_object_unref (current);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
static void
|
|
|
|
combiner_active_pad_changed (GObject * combiner, GParamSpec * pspec,
|
|
|
|
GstPlayBin3 * playbin)
|
|
|
|
{
|
|
|
|
GstSourceCombine *combine = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
|
|
|
|
for (i = 0; i < PLAYBIN_STREAM_LAST; i++) {
|
|
|
|
if (combiner == G_OBJECT (playbin->combiner[i].combiner)) {
|
|
|
|
combine = &playbin->combiner[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We got a pad-change after our group got switched out; no need to notify */
|
|
|
|
if (!combine) {
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-06 07:10:09 +00:00
|
|
|
switch (combine->stream_type) {
|
|
|
|
case GST_STREAM_TYPE_VIDEO:
|
|
|
|
playbin->current_video = get_current_stream_number (playbin, combine);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
if (playbin->video_pending_flush_finish) {
|
|
|
|
playbin->video_pending_flush_finish = FALSE;
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
gst_play_bin3_send_custom_event (GST_OBJECT (combiner),
|
|
|
|
"playsink-custom-video-flush-finish");
|
|
|
|
}
|
|
|
|
break;
|
2022-05-06 07:10:09 +00:00
|
|
|
case GST_STREAM_TYPE_AUDIO:
|
|
|
|
playbin->current_audio = get_current_stream_number (playbin, combine);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
if (playbin->audio_pending_flush_finish) {
|
|
|
|
playbin->audio_pending_flush_finish = FALSE;
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
gst_play_bin3_send_custom_event (GST_OBJECT (combiner),
|
|
|
|
"playsink-custom-audio-flush-finish");
|
|
|
|
}
|
|
|
|
break;
|
2022-05-06 07:10:09 +00:00
|
|
|
case GST_STREAM_TYPE_TEXT:
|
|
|
|
playbin->current_text = get_current_stream_number (playbin, combine);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
if (playbin->text_pending_flush_finish) {
|
|
|
|
playbin->text_pending_flush_finish = FALSE;
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
gst_play_bin3_send_custom_event (GST_OBJECT (combiner),
|
|
|
|
"playsink-custom-subtitle-flush-finish");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2017-11-09 10:16:20 +00:00
|
|
|
break;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstCaps *
|
|
|
|
update_video_multiview_caps (GstPlayBin3 * playbin, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstVideoMultiviewMode mv_mode;
|
|
|
|
GstVideoMultiviewMode cur_mv_mode;
|
2016-11-11 18:38:58 +00:00
|
|
|
guint mv_flags, cur_mv_flags;
|
2016-06-29 16:14:51 +00:00
|
|
|
GstStructure *s;
|
|
|
|
const gchar *mview_mode_str;
|
|
|
|
GstCaps *out_caps;
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (playbin);
|
|
|
|
mv_mode = (GstVideoMultiviewMode) playbin->multiview_mode;
|
|
|
|
mv_flags = playbin->multiview_flags;
|
|
|
|
GST_OBJECT_UNLOCK (playbin);
|
|
|
|
|
|
|
|
if (mv_mode == GST_VIDEO_MULTIVIEW_MODE_NONE)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
cur_mv_mode = GST_VIDEO_MULTIVIEW_MODE_NONE;
|
|
|
|
cur_mv_flags = GST_VIDEO_MULTIVIEW_FLAGS_NONE;
|
|
|
|
|
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
gst_structure_get_flagset (s, "multiview-flags", &cur_mv_flags, NULL);
|
|
|
|
if ((mview_mode_str = gst_structure_get_string (s, "multiview-mode")))
|
|
|
|
cur_mv_mode = gst_video_multiview_mode_from_caps_string (mview_mode_str);
|
|
|
|
|
|
|
|
/* We can't override an existing annotated multiview mode, except
|
|
|
|
* maybe (in the future) we could change some flags. */
|
|
|
|
if ((gint) cur_mv_mode > GST_VIDEO_MULTIVIEW_MAX_FRAME_PACKING) {
|
|
|
|
GST_INFO_OBJECT (playbin, "Cannot override existing multiview mode");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mview_mode_str = gst_video_multiview_mode_to_caps_string (mv_mode);
|
|
|
|
g_assert (mview_mode_str != NULL);
|
|
|
|
out_caps = gst_caps_copy (caps);
|
|
|
|
s = gst_caps_get_structure (out_caps, 0);
|
|
|
|
|
|
|
|
gst_structure_set (s, "multiview-mode", G_TYPE_STRING, mview_mode_str,
|
|
|
|
"multiview-flags", GST_TYPE_VIDEO_MULTIVIEW_FLAGSET, mv_flags,
|
|
|
|
GST_FLAG_SET_MASK_EXACT, NULL);
|
|
|
|
|
|
|
|
return out_caps;
|
|
|
|
}
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
static SourcePad *
|
2022-07-21 14:43:47 +00:00
|
|
|
find_source_pad (GstPlayBin3 * playbin, GstPad * target)
|
2017-11-09 10:17:13 +00:00
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
for (tmp = playbin->source_pads; tmp; tmp = tmp->next) {
|
2017-11-09 10:17:13 +00:00
|
|
|
SourcePad *res = (SourcePad *) tmp->data;
|
|
|
|
if (res->pad == target)
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
static GstPadProbeReturn
|
2022-07-21 14:43:47 +00:00
|
|
|
_decodebin_event_probe (GstPad * pad, GstPadProbeInfo * info,
|
|
|
|
GstPlayBin3 * playbin)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
|
|
|
GstPadProbeReturn ret = GST_PAD_PROBE_OK;
|
|
|
|
GstEvent *event = GST_PAD_PROBE_INFO_DATA (info);
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_CAPS:{
|
|
|
|
GstCaps *caps = NULL;
|
|
|
|
const GstStructure *s;
|
|
|
|
const gchar *name;
|
|
|
|
|
|
|
|
gst_event_parse_caps (event, &caps);
|
|
|
|
/* If video caps, check if we should override multiview flags */
|
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
name = gst_structure_get_name (s);
|
|
|
|
if (g_str_has_prefix (name, "video/")) {
|
|
|
|
caps = update_video_multiview_caps (playbin, caps);
|
|
|
|
if (caps) {
|
|
|
|
gst_event_unref (event);
|
|
|
|
event = gst_event_new_caps (caps);
|
|
|
|
GST_PAD_PROBE_INFO_DATA (info) = event;
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-07-21 14:43:47 +00:00
|
|
|
control_source_pad (GstPlayBin3 * playbin, GstPad * pad,
|
2022-05-06 07:10:09 +00:00
|
|
|
GstPad * combine_pad, GstStreamType stream_type)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
2023-01-08 15:57:42 +00:00
|
|
|
SourcePad *sourcepad = g_new0 (SourcePad, 1);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
sourcepad->pad = pad;
|
|
|
|
sourcepad->event_probe_id =
|
|
|
|
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
|
2022-07-21 14:43:47 +00:00
|
|
|
(GstPadProbeCallback) _decodebin_event_probe, playbin, NULL);
|
2017-11-10 13:32:13 +00:00
|
|
|
sourcepad->stream_type = stream_type;
|
2022-05-06 07:10:09 +00:00
|
|
|
sourcepad->combine_sinkpad = combine_pad;
|
2022-07-21 14:43:47 +00:00
|
|
|
playbin->source_pads = g_list_append (playbin->source_pads, sourcepad);
|
2017-11-09 10:17:13 +00:00
|
|
|
}
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
static void
|
|
|
|
remove_combiner (GstPlayBin3 * playbin, GstSourceCombine * combine)
|
|
|
|
{
|
|
|
|
gint n;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
if (combine->combiner == NULL) {
|
|
|
|
GST_DEBUG_OBJECT (playbin, "No combiner element to remove");
|
|
|
|
return;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* Go over all sink pads and release them ! */
|
2022-05-06 07:10:09 +00:00
|
|
|
for (n = 0; n < combine->inputpads->len; n++) {
|
|
|
|
GstPad *sinkpad = g_ptr_array_index (combine->inputpads, n);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
gst_element_release_request_pad (combine->combiner, sinkpad);
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
2022-05-06 07:10:09 +00:00
|
|
|
g_ptr_array_set_size (combine->inputpads, 0);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
gst_element_set_state (combine->combiner, GST_STATE_NULL);
|
|
|
|
gst_bin_remove (GST_BIN_CAST (playbin), combine->combiner);
|
|
|
|
combine->combiner = NULL;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
}
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* Create the combiner element if needed for the given combine */
|
|
|
|
static void
|
|
|
|
create_combiner (GstPlayBin3 * playbin, GstSourceCombine * combine)
|
|
|
|
{
|
|
|
|
GstElement *custom_combiner = NULL;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
if (combine->combiner) {
|
|
|
|
GST_WARNING_OBJECT (playbin, "Combiner element already exists!");
|
|
|
|
return;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
if (combine->stream_type == GST_STREAM_TYPE_VIDEO)
|
|
|
|
custom_combiner = playbin->video_stream_combiner;
|
|
|
|
else if (combine->stream_type == GST_STREAM_TYPE_AUDIO)
|
|
|
|
custom_combiner = playbin->audio_stream_combiner;
|
|
|
|
else if (combine->stream_type == GST_STREAM_TYPE_TEXT)
|
|
|
|
custom_combiner = playbin->text_stream_combiner;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
combine->combiner = custom_combiner;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
if (!combine->combiner) {
|
2022-07-21 14:43:47 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin, "No custom combiner requested");
|
|
|
|
return;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
combine->srcpad = gst_element_get_static_pad (combine->combiner, "src");
|
|
|
|
|
2017-11-10 13:32:13 +00:00
|
|
|
/* We only want to use 'active-pad' if it's a regular combiner that
|
2022-07-21 14:43:47 +00:00
|
|
|
* will consume all streams */
|
|
|
|
combine->has_active_pad =
|
|
|
|
g_object_class_find_property (G_OBJECT_GET_CLASS (combine->combiner),
|
|
|
|
"active-pad") != NULL;
|
|
|
|
|
|
|
|
if (combine->has_active_pad)
|
|
|
|
g_signal_connect (combine->combiner, "notify::active-pad",
|
|
|
|
G_CALLBACK (combiner_active_pad_changed), playbin);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin, "adding new stream combiner %" GST_PTR_FORMAT,
|
|
|
|
combine->combiner);
|
|
|
|
gst_bin_add (GST_BIN_CAST (playbin), combine->combiner);
|
|
|
|
gst_element_sync_state_with_parent (combine->combiner);
|
|
|
|
}
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2022-05-06 07:10:09 +00:00
|
|
|
static GstPad *
|
2017-11-09 10:17:13 +00:00
|
|
|
combiner_control_pad (GstPlayBin3 * playbin, GstSourceCombine * combine,
|
|
|
|
GstPad * srcpad)
|
|
|
|
{
|
|
|
|
GstPadLinkReturn res;
|
2022-05-06 07:10:09 +00:00
|
|
|
GstPad *combine_pad = NULL;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin, "srcpad %" GST_PTR_FORMAT, srcpad);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
if (combine->combiner) {
|
|
|
|
GstPad *sinkpad =
|
2021-04-20 17:53:01 +00:00
|
|
|
gst_element_request_pad_simple (combine->combiner, "sink_%u");
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
if (sinkpad == NULL)
|
2016-06-29 16:14:51 +00:00
|
|
|
goto request_pad_failed;
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin, "Got new combiner pad %" GST_PTR_FORMAT,
|
|
|
|
sinkpad);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* store the pad in the array */
|
|
|
|
GST_DEBUG_OBJECT (playbin, "pad %" GST_PTR_FORMAT " added to array",
|
|
|
|
sinkpad);
|
2022-05-06 07:10:09 +00:00
|
|
|
g_ptr_array_add (combine->inputpads, sinkpad);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
res = gst_pad_link (srcpad, sinkpad);
|
|
|
|
if (GST_PAD_LINK_FAILED (res))
|
|
|
|
goto failed_combiner_link;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin,
|
|
|
|
"linked pad %" GST_PTR_FORMAT " to combiner %" GST_PTR_FORMAT, srcpad,
|
|
|
|
combine->combiner);
|
2022-05-06 07:10:09 +00:00
|
|
|
combine_pad = sinkpad;
|
2017-11-09 10:17:13 +00:00
|
|
|
} else {
|
|
|
|
GST_LOG_OBJECT (playbin, "combine->sinkpad:%" GST_PTR_FORMAT,
|
|
|
|
combine->sinkpad);
|
|
|
|
g_assert (combine->sinkpad != NULL);
|
|
|
|
/* Connect directly to playsink */
|
|
|
|
if (gst_pad_is_linked (combine->sinkpad))
|
|
|
|
goto sinkpad_already_linked;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Linking new pad straight to playsink");
|
|
|
|
res = gst_pad_link (srcpad, combine->sinkpad);
|
|
|
|
|
|
|
|
if (res != GST_PAD_LINK_OK)
|
|
|
|
goto failed_sinkpad_link;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
2017-11-09 10:17:13 +00:00
|
|
|
|
2022-05-06 07:10:09 +00:00
|
|
|
return combine_pad;
|
2017-11-09 10:17:13 +00:00
|
|
|
|
|
|
|
/* Failure cases */
|
2016-06-29 16:14:51 +00:00
|
|
|
request_pad_failed:
|
|
|
|
GST_ELEMENT_ERROR (playbin, CORE, PAD,
|
|
|
|
("Internal playbin error."),
|
|
|
|
("Failed to get request pad from combiner %p.", combine->combiner));
|
2022-05-06 07:10:09 +00:00
|
|
|
return NULL;
|
2017-11-09 10:17:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
sinkpad_already_linked:
|
|
|
|
GST_ELEMENT_ERROR (playbin, CORE, PAD,
|
|
|
|
("Internal playbin error."), ("playsink pad already used !"));
|
2022-05-06 07:10:09 +00:00
|
|
|
return NULL;
|
2017-11-09 10:17:13 +00:00
|
|
|
|
|
|
|
failed_sinkpad_link:
|
|
|
|
GST_ELEMENT_ERROR (playbin, CORE, PAD,
|
|
|
|
("Internal playbin error."),
|
|
|
|
("Failed to link pad to sink. Error %d", res));
|
2022-05-06 07:10:09 +00:00
|
|
|
return NULL;
|
2017-11-09 10:17:13 +00:00
|
|
|
|
|
|
|
failed_combiner_link:
|
|
|
|
GST_ELEMENT_ERROR (playbin, CORE, PAD,
|
|
|
|
("Internal playbin error."),
|
|
|
|
("Failed to link pad to combiner. Error %d", res));
|
2022-05-06 07:10:09 +00:00
|
|
|
return NULL;
|
2017-11-09 10:17:13 +00:00
|
|
|
}
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
static void
|
2022-07-21 14:43:47 +00:00
|
|
|
release_source_pad (GstPlayBin3 * playbin,
|
2022-05-06 07:10:09 +00:00
|
|
|
GstSourceCombine * combine, GstPad * pad)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
2017-11-09 10:17:13 +00:00
|
|
|
SourcePad *sourcepad;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
sourcepad = find_source_pad (playbin, pad);
|
2017-11-09 10:17:13 +00:00
|
|
|
if (!sourcepad) {
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Not a pad controlled by us ?");
|
2017-07-18 11:04:09 +00:00
|
|
|
return;
|
2017-11-09 10:17:13 +00:00
|
|
|
}
|
2017-07-18 11:04:09 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
if (sourcepad->event_probe_id) {
|
|
|
|
gst_pad_remove_probe (pad, sourcepad->event_probe_id);
|
|
|
|
sourcepad->event_probe_id = 0;
|
|
|
|
}
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2022-05-06 07:10:09 +00:00
|
|
|
if (sourcepad->combine_sinkpad) {
|
|
|
|
gst_element_release_request_pad (combine->combiner,
|
|
|
|
sourcepad->combine_sinkpad);
|
|
|
|
g_ptr_array_remove (combine->inputpads, sourcepad->combine_sinkpad);
|
|
|
|
}
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* Remove from list of controlled pads and check again for EOS status */
|
2022-07-21 14:43:47 +00:00
|
|
|
playbin->source_pads = g_list_remove (playbin->source_pads, sourcepad);
|
2023-01-08 15:57:42 +00:00
|
|
|
g_free (sourcepad);
|
2017-11-09 10:17:13 +00:00
|
|
|
}
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* this function is called when a new pad is added to decodebin. We check the
|
|
|
|
* type of the pad and add it to the combiner element
|
|
|
|
*/
|
|
|
|
static void
|
2022-07-21 14:43:47 +00:00
|
|
|
pad_added_cb (GstElement * uridecodebin, GstPad * pad, GstPlayBin3 * playbin)
|
2017-11-09 10:17:13 +00:00
|
|
|
{
|
|
|
|
GstSourceCombine *combine = NULL;
|
|
|
|
gint pb_stream_type = -1;
|
|
|
|
gchar *pad_name;
|
2022-05-06 07:10:09 +00:00
|
|
|
GstPad *combine_pad;
|
2022-05-24 17:10:30 +00:00
|
|
|
GstStreamType selected, active, cur;
|
2017-11-09 10:17:13 +00:00
|
|
|
|
2016-12-03 11:44:21 +00:00
|
|
|
pad_name = gst_object_get_name (GST_OBJECT (pad));
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin, "decoded pad %s:%s added",
|
|
|
|
GST_DEBUG_PAD_NAME (pad));
|
|
|
|
|
|
|
|
/* major type of the pad, this determines the combiner to use,
|
|
|
|
try exact match first */
|
2016-12-03 11:44:21 +00:00
|
|
|
if (g_str_has_prefix (pad_name, "video")) {
|
2017-11-09 10:17:13 +00:00
|
|
|
pb_stream_type = PLAYBIN_STREAM_VIDEO;
|
2022-05-24 17:10:30 +00:00
|
|
|
cur = GST_STREAM_TYPE_VIDEO;
|
2016-12-03 11:44:21 +00:00
|
|
|
} else if (g_str_has_prefix (pad_name, "audio")) {
|
2017-11-09 10:17:13 +00:00
|
|
|
pb_stream_type = PLAYBIN_STREAM_AUDIO;
|
2022-05-24 17:10:30 +00:00
|
|
|
cur = GST_STREAM_TYPE_AUDIO;
|
2016-12-03 11:44:21 +00:00
|
|
|
} else if (g_str_has_prefix (pad_name, "text")) {
|
2017-11-09 10:17:13 +00:00
|
|
|
pb_stream_type = PLAYBIN_STREAM_TEXT;
|
2022-05-24 17:10:30 +00:00
|
|
|
cur = GST_STREAM_TYPE_TEXT;
|
2016-12-03 11:44:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (pad_name);
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* no stream type found for the media type, don't bother linking it to a
|
|
|
|
* combiner. This will leave the pad unlinked and thus ignored. */
|
|
|
|
if (pb_stream_type < 0) {
|
|
|
|
goto unknown_type;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
2022-01-17 18:48:08 +00:00
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
2017-11-09 10:17:13 +00:00
|
|
|
combine = &playbin->combiner[pb_stream_type];
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2022-05-24 17:10:30 +00:00
|
|
|
/* (uri)decodebin3 will post streams-selected once all pads are expose.
|
|
|
|
* Therefore this stream might not be marked as selected on pad-added,
|
|
|
|
* and associated combiner can be null here.
|
|
|
|
* Marks this stream as selected manually, exposed pad implies it's selected
|
|
|
|
* already */
|
|
|
|
selected = playbin->selected_stream_types | cur;
|
|
|
|
active = playbin->active_stream_types;
|
|
|
|
|
|
|
|
if (selected != active) {
|
|
|
|
GST_DEBUG_OBJECT (playbin,
|
|
|
|
"%s:%s added but not an active stream, marking active",
|
|
|
|
GST_DEBUG_PAD_NAME (pad));
|
|
|
|
playbin->selected_stream_types = selected;
|
|
|
|
reconfigure_output (playbin);
|
|
|
|
}
|
|
|
|
|
2022-05-06 07:10:09 +00:00
|
|
|
combine_pad = combiner_control_pad (playbin, combine, pad);
|
2022-07-21 14:43:47 +00:00
|
|
|
control_source_pad (playbin, pad, combine_pad, combine->stream_type);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2022-01-17 18:48:08 +00:00
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* ERRORS */
|
2017-11-09 10:17:13 +00:00
|
|
|
unknown_type:
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Ignoring pad with unknown type");
|
|
|
|
return;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* called when a pad is removed from the decodebin. We unlink the pad from
|
2017-11-10 13:32:13 +00:00
|
|
|
* the combiner. */
|
2017-11-09 10:17:13 +00:00
|
|
|
static void
|
2022-07-21 14:43:47 +00:00
|
|
|
pad_removed_cb (GstElement * decodebin, GstPad * pad, GstPlayBin3 * playbin)
|
2017-11-09 10:17:13 +00:00
|
|
|
{
|
|
|
|
GstSourceCombine *combine;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (playbin,
|
|
|
|
"decoded pad %s:%s removed", GST_DEBUG_PAD_NAME (pad));
|
|
|
|
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
|
|
|
|
/* Get combiner for pad */
|
|
|
|
if (g_str_has_prefix (GST_PAD_NAME (pad), "video"))
|
|
|
|
combine = &playbin->combiner[PLAYBIN_STREAM_VIDEO];
|
|
|
|
else if (g_str_has_prefix (GST_PAD_NAME (pad), "audio"))
|
|
|
|
combine = &playbin->combiner[PLAYBIN_STREAM_AUDIO];
|
|
|
|
else if (g_str_has_prefix (GST_PAD_NAME (pad), "text"))
|
|
|
|
combine = &playbin->combiner[PLAYBIN_STREAM_TEXT];
|
|
|
|
else
|
2022-04-15 05:03:08 +00:00
|
|
|
goto done;
|
2017-11-09 10:17:13 +00:00
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
release_source_pad (playbin, combine, pad);
|
2017-11-09 10:17:13 +00:00
|
|
|
|
2022-04-15 05:03:08 +00:00
|
|
|
done:
|
2017-11-09 10:17:13 +00:00
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
}
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
static gint
|
|
|
|
select_stream_cb (GstElement * decodebin, GstStreamCollection * collection,
|
2022-07-21 14:43:47 +00:00
|
|
|
GstStream * stream, GstPlayBin3 * playbin)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
|
|
|
GstStreamType stype = gst_stream_get_stream_type (stream);
|
|
|
|
GstElement *combiner = NULL;
|
|
|
|
|
2016-10-13 09:42:28 +00:00
|
|
|
if (stype & GST_STREAM_TYPE_AUDIO)
|
|
|
|
combiner = playbin->audio_stream_combiner;
|
|
|
|
else if (stype & GST_STREAM_TYPE_VIDEO)
|
|
|
|
combiner = playbin->video_stream_combiner;
|
|
|
|
else if (stype & GST_STREAM_TYPE_TEXT)
|
|
|
|
combiner = playbin->text_stream_combiner;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
if (combiner) {
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Got a combiner, requesting stream activation");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Let decodebin3 decide otherwise */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* We get called when the selected stream types change and
|
|
|
|
* reconfiguration of output (i.e. playsink and potential combiners)
|
|
|
|
* are required.
|
2016-06-29 16:14:51 +00:00
|
|
|
*/
|
|
|
|
static void
|
2017-11-09 10:17:13 +00:00
|
|
|
reconfigure_output (GstPlayBin3 * playbin)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
|
|
|
GstPadLinkReturn res;
|
|
|
|
gint i;
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
g_assert (playbin->selected_stream_types != playbin->active_stream_types);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin, "selected_stream_types : %" STREAM_TYPES_FORMAT,
|
|
|
|
STREAM_TYPES_ARGS (playbin->selected_stream_types));
|
|
|
|
GST_DEBUG_OBJECT (playbin, "active_stream_types : %" STREAM_TYPES_FORMAT,
|
|
|
|
STREAM_TYPES_ARGS (playbin->active_stream_types));
|
2016-06-29 16:14:51 +00:00
|
|
|
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* Make sure combiners/playsink are in sync with selected stream types */
|
2016-06-29 16:14:51 +00:00
|
|
|
for (i = 0; i < PLAYBIN_STREAM_LAST; i++) {
|
|
|
|
GstSourceCombine *combine = &playbin->combiner[i];
|
2017-11-09 10:17:13 +00:00
|
|
|
gboolean is_selected =
|
|
|
|
(combine->stream_type & playbin->selected_stream_types) ==
|
|
|
|
combine->stream_type;
|
|
|
|
gboolean is_active =
|
|
|
|
(combine->stream_type & playbin->active_stream_types) ==
|
|
|
|
combine->stream_type;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Stream type status: '%s' %s %s",
|
2022-05-06 07:10:09 +00:00
|
|
|
gst_stream_type_get_name (combine->stream_type),
|
|
|
|
is_selected ? "selected" : "NOT selected",
|
2017-11-09 10:17:13 +00:00
|
|
|
is_active ? "active" : "NOT active");
|
|
|
|
/* FIXME : Remove asserts below once enough testing has been done */
|
|
|
|
|
|
|
|
if (is_selected && is_active) {
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Stream type '%s' already active",
|
2022-05-06 07:10:09 +00:00
|
|
|
gst_stream_type_get_name (combine->stream_type));
|
2017-11-09 10:17:13 +00:00
|
|
|
} else if (is_active && !is_selected) {
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Stream type '%s' is no longer requested",
|
2022-05-06 07:10:09 +00:00
|
|
|
gst_stream_type_get_name (combine->stream_type));
|
2017-11-09 10:17:13 +00:00
|
|
|
|
|
|
|
/* Unlink combiner from sink */
|
|
|
|
if (combine->srcpad) {
|
|
|
|
GST_LOG_OBJECT (playbin, "Unlinking from sink");
|
|
|
|
if (combine->sinkpad)
|
|
|
|
gst_pad_unlink (combine->srcpad, combine->sinkpad);
|
|
|
|
gst_object_unref (combine->srcpad);
|
|
|
|
combine->srcpad = NULL;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
if (combine->sinkpad) {
|
|
|
|
/* Release playsink sink pad */
|
|
|
|
GST_LOG_OBJECT (playbin, "Releasing playsink pad");
|
|
|
|
gst_play_sink_release_pad (playbin->playsink, combine->sinkpad);
|
|
|
|
gst_object_unref (combine->sinkpad);
|
|
|
|
combine->sinkpad = NULL;
|
|
|
|
}
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
/* Release combiner */
|
|
|
|
remove_combiner (playbin, combine);
|
|
|
|
} else if (!is_active && is_selected) {
|
|
|
|
GST_DEBUG_OBJECT (playbin, "Stream type '%s' is now requested",
|
2022-05-06 07:10:09 +00:00
|
|
|
gst_stream_type_get_name (combine->stream_type));
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2024-04-26 08:12:23 +00:00
|
|
|
if (combine->sinkpad) {
|
|
|
|
/* This was previously an assert but is now just a WARNING
|
|
|
|
*
|
|
|
|
* This *theoretically* should never happen, but there is the
|
|
|
|
* possibility where there was a failure within (uri)decodebin3 where
|
|
|
|
* the collection was posted (by demuxer for ex) but the decoding failed
|
|
|
|
* (no decoder, bad stream, etc...).
|
|
|
|
*
|
|
|
|
* in that case, we could have a combiner already prepared for that type
|
|
|
|
* but never got activated.
|
|
|
|
**/
|
|
|
|
GST_WARNING_OBJECT (playbin, "Combiner already configured");
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* Request playsink sink pad */
|
|
|
|
combine->sinkpad =
|
|
|
|
gst_play_sink_request_pad (playbin->playsink,
|
|
|
|
gst_play_sink_type_from_stream_type (combine->stream_type));
|
|
|
|
gst_object_ref (combine->sinkpad);
|
|
|
|
/* Create combiner if needed and link it */
|
|
|
|
create_combiner (playbin, combine);
|
|
|
|
if (combine->combiner) {
|
|
|
|
res = gst_pad_link (combine->srcpad, combine->sinkpad);
|
|
|
|
GST_DEBUG_OBJECT (playbin, "linked type %s, result: %d",
|
|
|
|
gst_stream_type_get_name (combine->stream_type), res);
|
|
|
|
if (res != GST_PAD_LINK_OK) {
|
|
|
|
GST_ELEMENT_ERROR (playbin, CORE, PAD,
|
|
|
|
("Internal playbin error."),
|
|
|
|
("Failed to link combiner to sink. Error %d", res));
|
|
|
|
}
|
2017-11-09 10:17:13 +00:00
|
|
|
|
2024-04-26 08:12:23 +00:00
|
|
|
}
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
playbin->active_stream_types = playbin->selected_stream_types;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
gst_play_sink_reconfigure (playbin->playsink);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
do_async_done (playbin);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-09 10:17:13 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin, "selected_stream_types : %" STREAM_TYPES_FORMAT,
|
|
|
|
STREAM_TYPES_ARGS (playbin->selected_stream_types));
|
|
|
|
GST_DEBUG_OBJECT (playbin, "active_stream_types : %" STREAM_TYPES_FORMAT,
|
|
|
|
STREAM_TYPES_ARGS (playbin->active_stream_types));
|
|
|
|
|
|
|
|
return;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-07-21 14:43:47 +00:00
|
|
|
about_to_finish_cb (GstElement * uridecodebin, GstPlayBin3 * playbin)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
2022-07-21 14:43:47 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin, "about to finish");
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2017-11-10 13:32:13 +00:00
|
|
|
GST_LOG_OBJECT (playbin, "selected_stream_types:%" STREAM_TYPES_FORMAT,
|
2022-07-21 14:43:47 +00:00
|
|
|
STREAM_TYPES_ARGS (playbin->selected_stream_types));
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
GST_DEBUG_OBJECT (playbin, "Emitting about-to-finish");
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
/* after this call, we should have a next group to activate or we EOS */
|
|
|
|
g_signal_emit (G_OBJECT (playbin),
|
|
|
|
gst_play_bin3_signals[SIGNAL_ABOUT_TO_FINISH], 0, NULL);
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
2017-09-22 14:58:14 +00:00
|
|
|
static void
|
|
|
|
source_setup_cb (GstElement * element, GstElement * source,
|
2022-07-21 14:43:47 +00:00
|
|
|
GstPlayBin3 * playbin)
|
2017-09-22 14:58:14 +00:00
|
|
|
{
|
2022-07-21 14:43:47 +00:00
|
|
|
g_signal_emit (playbin, gst_play_bin3_signals[SIGNAL_SOURCE_SETUP], 0,
|
2018-02-14 10:21:49 +00:00
|
|
|
source);
|
2017-09-22 14:58:14 +00:00
|
|
|
}
|
|
|
|
|
2017-11-10 13:32:13 +00:00
|
|
|
static gboolean
|
|
|
|
gst_play_bin3_start (GstPlayBin3 * playbin)
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (playbin, "starting");
|
|
|
|
|
|
|
|
GST_PLAY_BIN3_LOCK (playbin);
|
2022-07-21 14:43:47 +00:00
|
|
|
playbin->active_stream_types = 0;
|
|
|
|
playbin->selected_stream_types = 0;
|
2017-11-10 13:32:13 +00:00
|
|
|
do_async_start (playbin);
|
|
|
|
GST_PLAY_BIN3_UNLOCK (playbin);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_play_bin3_change_state (GstElement * element, GstStateChange transition)
|
|
|
|
{
|
|
|
|
GstStateChangeReturn ret;
|
|
|
|
GstPlayBin3 *playbin;
|
|
|
|
|
|
|
|
playbin = GST_PLAY_BIN3 (element);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2017-11-10 13:32:13 +00:00
|
|
|
if (!gst_play_bin3_start (playbin))
|
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
2016-06-29 16:14:51 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
|
|
|
goto failure;
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
|
|
|
if (ret == GST_STATE_CHANGE_SUCCESS)
|
|
|
|
ret = GST_STATE_CHANGE_ASYNC;
|
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
|
|
|
do_async_done (playbin);
|
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2021-04-12 12:02:46 +00:00
|
|
|
playbin->is_live = FALSE;
|
2022-07-21 14:43:47 +00:00
|
|
|
/* Make sure we reset our state */
|
|
|
|
if (playbin->selected_stream_types) {
|
|
|
|
playbin->selected_stream_types = 0;
|
|
|
|
reconfigure_output (playbin);
|
|
|
|
}
|
2016-06-29 16:14:51 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
|
|
|
{
|
|
|
|
/* Set our sinks back to NULL, they might not be child of playbin */
|
|
|
|
if (playbin->audio_sink)
|
|
|
|
gst_element_set_state (playbin->audio_sink, GST_STATE_NULL);
|
|
|
|
if (playbin->video_sink)
|
|
|
|
gst_element_set_state (playbin->video_sink, GST_STATE_NULL);
|
|
|
|
if (playbin->text_sink)
|
|
|
|
gst_element_set_state (playbin->text_sink, GST_STATE_NULL);
|
|
|
|
|
|
|
|
if (playbin->video_stream_combiner)
|
|
|
|
gst_element_set_state (playbin->video_stream_combiner, GST_STATE_NULL);
|
|
|
|
if (playbin->audio_stream_combiner)
|
|
|
|
gst_element_set_state (playbin->audio_stream_combiner, GST_STATE_NULL);
|
|
|
|
if (playbin->text_stream_combiner)
|
|
|
|
gst_element_set_state (playbin->text_stream_combiner, GST_STATE_NULL);
|
|
|
|
|
2022-07-21 14:43:47 +00:00
|
|
|
gst_object_replace ((GstObject **) & playbin->collection, NULL);
|
|
|
|
gst_object_replace ((GstObject **) & playbin->collection_source, NULL);
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-12 12:02:46 +00:00
|
|
|
if (GST_STATE_TRANSITION_NEXT (transition) == GST_STATE_PAUSED)
|
|
|
|
playbin->is_live = ret == GST_STATE_CHANGE_NO_PREROLL;
|
|
|
|
|
2016-06-29 16:14:51 +00:00
|
|
|
if (ret == GST_STATE_CHANGE_NO_PREROLL)
|
|
|
|
do_async_done (playbin);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
failure:
|
|
|
|
{
|
|
|
|
do_async_done (playbin);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_overlay_expose (GstVideoOverlay * overlay)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (overlay);
|
|
|
|
|
|
|
|
gst_video_overlay_expose (GST_VIDEO_OVERLAY (playbin->playsink));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_overlay_handle_events (GstVideoOverlay * overlay,
|
|
|
|
gboolean handle_events)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (overlay);
|
|
|
|
|
|
|
|
gst_video_overlay_handle_events (GST_VIDEO_OVERLAY (playbin->playsink),
|
|
|
|
handle_events);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_overlay_set_render_rectangle (GstVideoOverlay * overlay, gint x,
|
|
|
|
gint y, gint width, gint height)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (overlay);
|
|
|
|
|
|
|
|
gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (playbin->playsink),
|
|
|
|
x, y, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_overlay_set_window_handle (GstVideoOverlay * overlay,
|
|
|
|
guintptr handle)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (overlay);
|
|
|
|
|
|
|
|
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (playbin->playsink),
|
|
|
|
handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_overlay_init (gpointer g_iface, gpointer g_iface_data)
|
|
|
|
{
|
|
|
|
GstVideoOverlayInterface *iface = (GstVideoOverlayInterface *) g_iface;
|
|
|
|
iface->expose = gst_play_bin3_overlay_expose;
|
|
|
|
iface->handle_events = gst_play_bin3_overlay_handle_events;
|
|
|
|
iface->set_render_rectangle = gst_play_bin3_overlay_set_render_rectangle;
|
|
|
|
iface->set_window_handle = gst_play_bin3_overlay_set_window_handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_navigation_send_event (GstNavigation * navigation,
|
2022-02-14 15:08:23 +00:00
|
|
|
GstEvent * event)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (navigation);
|
|
|
|
|
2022-02-14 15:08:23 +00:00
|
|
|
gst_navigation_send_event_simple (GST_NAVIGATION (playbin->playsink), event);
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_navigation_init (gpointer g_iface, gpointer g_iface_data)
|
|
|
|
{
|
|
|
|
GstNavigationInterface *iface = (GstNavigationInterface *) g_iface;
|
|
|
|
|
2022-02-14 15:08:23 +00:00
|
|
|
iface->send_event_simple = gst_play_bin3_navigation_send_event;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const GList *
|
|
|
|
gst_play_bin3_colorbalance_list_channels (GstColorBalance * balance)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (balance);
|
|
|
|
|
|
|
|
return
|
|
|
|
gst_color_balance_list_channels (GST_COLOR_BALANCE (playbin->playsink));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_colorbalance_set_value (GstColorBalance * balance,
|
|
|
|
GstColorBalanceChannel * channel, gint value)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (balance);
|
|
|
|
|
|
|
|
gst_color_balance_set_value (GST_COLOR_BALANCE (playbin->playsink), channel,
|
|
|
|
value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gst_play_bin3_colorbalance_get_value (GstColorBalance * balance,
|
|
|
|
GstColorBalanceChannel * channel)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (balance);
|
|
|
|
|
|
|
|
return gst_color_balance_get_value (GST_COLOR_BALANCE (playbin->playsink),
|
|
|
|
channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstColorBalanceType
|
|
|
|
gst_play_bin3_colorbalance_get_balance_type (GstColorBalance * balance)
|
|
|
|
{
|
|
|
|
GstPlayBin3 *playbin = GST_PLAY_BIN3 (balance);
|
|
|
|
|
|
|
|
return
|
|
|
|
gst_color_balance_get_balance_type (GST_COLOR_BALANCE
|
|
|
|
(playbin->playsink));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_bin3_colorbalance_init (gpointer g_iface, gpointer g_iface_data)
|
|
|
|
{
|
|
|
|
GstColorBalanceInterface *iface = (GstColorBalanceInterface *) g_iface;
|
|
|
|
|
|
|
|
iface->list_channels = gst_play_bin3_colorbalance_list_channels;
|
|
|
|
iface->set_value = gst_play_bin3_colorbalance_set_value;
|
|
|
|
iface->get_value = gst_play_bin3_colorbalance_get_value;
|
|
|
|
iface->get_balance_type = gst_play_bin3_colorbalance_get_balance_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2020-10-22 09:07:26 +00:00
|
|
|
gst_play_bin3_custom_element_init (GstPlugin * plugin)
|
2016-06-29 16:14:51 +00:00
|
|
|
{
|
2020-10-22 09:07:26 +00:00
|
|
|
gboolean ret = TRUE;
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2020-10-22 09:07:26 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_play_bin3_debug, "playbin3", 0, "play bin3");
|
|
|
|
|
2021-03-16 11:59:14 +00:00
|
|
|
playback_element_init (plugin);
|
2020-10-22 09:07:26 +00:00
|
|
|
|
2021-10-09 14:24:44 +00:00
|
|
|
ret &= gst_element_register (plugin, "playbin3", GST_RANK_NONE,
|
|
|
|
GST_TYPE_PLAY_BIN);
|
2016-06-29 16:14:51 +00:00
|
|
|
|
2020-10-22 09:07:26 +00:00
|
|
|
return ret;
|
2016-06-29 16:14:51 +00:00
|
|
|
}
|