2015-06-30 18:06:36 +02:00
|
|
|
/* Pinos
|
2015-04-16 16:58:33 +02:00
|
|
|
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.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.
|
|
|
|
|
*/
|
|
|
|
|
|
2015-05-14 17:46:12 +02:00
|
|
|
#include <string.h>
|
2015-04-16 16:58:33 +02:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
#include <gio/gio.h>
|
|
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
#include "gst-source.h"
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
#define PINOS_GST_SOURCE_GET_PRIVATE(obj) \
|
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_GST_SOURCE, PinosGstSourcePrivate))
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
struct _PinosGstSourcePrivate
|
2015-04-16 16:58:33 +02:00
|
|
|
{
|
|
|
|
|
GstElement *pipeline;
|
2015-05-21 16:49:26 +02:00
|
|
|
GstElement *element;
|
2015-04-28 17:36:44 +02:00
|
|
|
GstElement *filter;
|
2015-04-16 16:58:33 +02:00
|
|
|
GstElement *sink;
|
|
|
|
|
|
2015-05-14 17:46:12 +02:00
|
|
|
GstCaps *possible_formats;
|
2015-04-16 16:58:33 +02:00
|
|
|
};
|
|
|
|
|
|
2015-05-21 16:49:26 +02:00
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_ELEMENT,
|
|
|
|
|
};
|
|
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
G_DEFINE_TYPE (PinosGstSource, pinos_gst_source, PINOS_TYPE_SOURCE);
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2015-04-28 17:36:44 +02:00
|
|
|
static gboolean
|
2015-07-07 16:46:23 +02:00
|
|
|
bus_handler (GstBus *bus,
|
|
|
|
|
GstMessage *message,
|
|
|
|
|
gpointer user_data)
|
2015-04-28 17:36:44 +02:00
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
PinosSource *source = user_data;
|
|
|
|
|
PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (source)->priv;
|
2015-04-28 17:36:44 +02:00
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (message)) {
|
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
|
{
|
|
|
|
|
GError *error;
|
|
|
|
|
gchar *debug;
|
|
|
|
|
|
|
|
|
|
gst_message_parse_error (message, &error, &debug);
|
2015-05-21 10:18:21 +02:00
|
|
|
g_warning ("got error %s (%s)\n", error->message, debug);
|
2015-04-28 17:36:44 +02:00
|
|
|
g_free (debug);
|
|
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
pinos_source_report_error (source, error);
|
2015-04-28 17:36:44 +02:00
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-16 16:58:33 +02:00
|
|
|
static void
|
2015-07-07 16:46:23 +02:00
|
|
|
setup_pipeline (PinosGstSource *source)
|
2015-04-16 16:58:33 +02:00
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
PinosGstSourcePrivate *priv = source->priv;
|
2015-04-28 17:36:44 +02:00
|
|
|
GstBus *bus;
|
2015-05-21 16:49:26 +02:00
|
|
|
GstElement *elem;
|
2015-07-16 17:19:32 +02:00
|
|
|
GstCaps *res;
|
|
|
|
|
GstQuery *query;
|
2015-05-21 16:49:26 +02:00
|
|
|
|
|
|
|
|
priv->pipeline = gst_pipeline_new (NULL);
|
|
|
|
|
|
|
|
|
|
gst_bin_add (GST_BIN (priv->pipeline), priv->element);
|
|
|
|
|
|
|
|
|
|
priv->filter = gst_element_factory_make ("capsfilter", NULL);
|
|
|
|
|
gst_bin_add (GST_BIN (priv->pipeline), priv->filter);
|
|
|
|
|
gst_element_link (priv->element, priv->filter);
|
|
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
elem = gst_element_factory_make ("pinosfdpay", NULL);
|
2015-05-21 16:49:26 +02:00
|
|
|
gst_bin_add (GST_BIN (priv->pipeline), elem);
|
|
|
|
|
gst_element_link (priv->filter, elem);
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2015-05-21 16:49:26 +02:00
|
|
|
priv->sink = gst_element_factory_make ("multisocketsink", NULL);
|
|
|
|
|
g_object_set (priv->sink, "buffers-max", 2,
|
|
|
|
|
"buffers-soft-max", 1,
|
|
|
|
|
"recover-policy", 1, /* latest */
|
|
|
|
|
"sync-method", 0, /* latest */
|
|
|
|
|
"sync", TRUE,
|
|
|
|
|
"enable-last-sample", FALSE,
|
|
|
|
|
NULL);
|
|
|
|
|
gst_bin_add (GST_BIN (priv->pipeline), priv->sink);
|
|
|
|
|
gst_element_link (elem, priv->sink);
|
2015-04-28 17:36:44 +02:00
|
|
|
|
|
|
|
|
bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
|
|
|
|
|
gst_bus_add_watch (bus, bus_handler, source);
|
|
|
|
|
gst_object_unref (bus);
|
2015-05-15 13:34:32 +02:00
|
|
|
|
|
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
2015-07-16 17:19:32 +02:00
|
|
|
query = gst_query_new_caps (NULL);
|
|
|
|
|
gst_element_query (priv->element, query);
|
|
|
|
|
gst_query_parse_caps_result (query, &res);
|
|
|
|
|
priv->possible_formats = gst_caps_ref (res);
|
|
|
|
|
gst_query_unref (query);
|
|
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
2015-04-27 09:05:14 +02:00
|
|
|
}
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2015-05-21 16:49:26 +02:00
|
|
|
static void
|
2015-07-07 16:46:23 +02:00
|
|
|
destroy_pipeline (PinosGstSource *source)
|
2015-05-21 16:49:26 +02:00
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
PinosGstSourcePrivate *priv = source->priv;
|
2015-05-21 16:49:26 +02:00
|
|
|
|
|
|
|
|
if (priv->pipeline) {
|
|
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
|
|
|
|
gst_object_unref (priv->pipeline);
|
|
|
|
|
priv->pipeline = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-27 09:05:14 +02:00
|
|
|
static gboolean
|
2015-07-07 16:46:23 +02:00
|
|
|
set_state (PinosSource *source,
|
|
|
|
|
PinosSourceState state)
|
2015-04-27 09:05:14 +02:00
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (source)->priv;
|
2015-04-27 09:05:14 +02:00
|
|
|
|
|
|
|
|
switch (state) {
|
2015-07-07 16:46:23 +02:00
|
|
|
case PINOS_SOURCE_STATE_SUSPENDED:
|
2015-04-27 09:05:14 +02:00
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
|
|
|
|
break;
|
|
|
|
|
|
2015-07-09 11:34:34 +02:00
|
|
|
case PINOS_SOURCE_STATE_INITIALIZING:
|
2015-04-27 09:05:14 +02:00
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
|
|
|
|
break;
|
|
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
case PINOS_SOURCE_STATE_IDLE:
|
2015-04-27 09:05:14 +02:00
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
|
|
|
|
break;
|
|
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
case PINOS_SOURCE_STATE_RUNNING:
|
2015-04-27 09:05:14 +02:00
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
|
|
|
|
|
break;
|
|
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
case PINOS_SOURCE_STATE_ERROR:
|
2015-04-27 09:05:14 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2015-07-07 16:46:23 +02:00
|
|
|
pinos_source_update_state (source, state);
|
2015-04-27 09:05:14 +02:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-14 17:46:12 +02:00
|
|
|
static GBytes *
|
2015-07-07 16:46:23 +02:00
|
|
|
get_formats (PinosSource *source,
|
|
|
|
|
GBytes *filter)
|
2015-04-27 09:05:14 +02:00
|
|
|
{
|
2015-07-16 17:19:32 +02:00
|
|
|
PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (source)->priv;
|
|
|
|
|
GstCaps *caps;
|
2015-05-15 15:58:13 +02:00
|
|
|
gchar *str;
|
|
|
|
|
|
2015-07-09 17:36:17 +02:00
|
|
|
if (filter) {
|
2015-07-16 17:19:32 +02:00
|
|
|
GstCaps *cfilter;
|
|
|
|
|
|
2015-07-09 17:36:17 +02:00
|
|
|
cfilter = gst_caps_from_string (g_bytes_get_data (filter, NULL));
|
|
|
|
|
if (cfilter == NULL)
|
|
|
|
|
return NULL;
|
2015-07-16 17:19:32 +02:00
|
|
|
|
|
|
|
|
caps = gst_caps_intersect (priv->possible_formats, cfilter);
|
|
|
|
|
gst_caps_unref (cfilter);
|
|
|
|
|
|
|
|
|
|
if (caps == NULL)
|
|
|
|
|
return NULL;
|
2015-07-09 17:36:17 +02:00
|
|
|
} else {
|
2015-07-16 17:19:32 +02:00
|
|
|
caps = gst_caps_ref (priv->possible_formats);
|
2015-07-09 17:36:17 +02:00
|
|
|
}
|
2015-07-16 17:19:32 +02:00
|
|
|
if (gst_caps_is_empty (caps)) {
|
|
|
|
|
gst_caps_unref (caps);
|
2015-05-15 15:58:13 +02:00
|
|
|
return NULL;
|
2015-07-16 17:19:32 +02:00
|
|
|
}
|
2015-05-15 15:58:13 +02:00
|
|
|
str = gst_caps_to_string (caps);
|
2015-07-16 17:19:32 +02:00
|
|
|
gst_caps_unref (caps);
|
2015-05-15 15:58:13 +02:00
|
|
|
|
|
|
|
|
return g_bytes_new_take (str, strlen (str) + 1);
|
2015-04-16 16:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_socket_notify (GObject *gobject,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
PinosGstSource *source = user_data;
|
|
|
|
|
PinosGstSourcePrivate *priv = source->priv;
|
2015-04-16 16:58:33 +02:00
|
|
|
GSocket *socket;
|
|
|
|
|
guint num_handles;
|
2015-05-14 17:46:12 +02:00
|
|
|
GstCaps *caps;
|
2015-05-15 13:34:32 +02:00
|
|
|
GBytes *requested_format, *format;
|
2015-04-16 16:58:33 +02:00
|
|
|
|
|
|
|
|
g_object_get (gobject, "socket", &socket, NULL);
|
|
|
|
|
|
|
|
|
|
if (socket == NULL) {
|
2015-05-15 13:34:32 +02:00
|
|
|
GSocket *prev_socket = g_object_get_data (gobject, "last-socket");
|
|
|
|
|
if (prev_socket) {
|
|
|
|
|
g_signal_emit_by_name (priv->sink, "remove", prev_socket);
|
|
|
|
|
}
|
2015-04-16 16:58:33 +02:00
|
|
|
} else {
|
2015-07-16 17:19:32 +02:00
|
|
|
pinos_source_report_busy (PINOS_SOURCE (source));
|
2015-04-16 16:58:33 +02:00
|
|
|
g_signal_emit_by_name (priv->sink, "add", socket);
|
|
|
|
|
}
|
2015-05-15 13:34:32 +02:00
|
|
|
g_object_set_data (gobject, "last-socket", socket);
|
2015-05-14 17:46:12 +02:00
|
|
|
|
2015-04-16 16:58:33 +02:00
|
|
|
g_object_get (priv->sink, "num-handles", &num_handles, NULL);
|
|
|
|
|
if (num_handles == 0) {
|
2015-07-16 17:19:32 +02:00
|
|
|
pinos_source_report_idle (PINOS_SOURCE (source));
|
2015-05-15 13:34:32 +02:00
|
|
|
g_object_set (priv->filter, "caps", NULL, NULL);
|
|
|
|
|
} else if (socket) {
|
|
|
|
|
/* what client requested */
|
|
|
|
|
g_object_get (gobject, "requested-format", &requested_format, NULL);
|
|
|
|
|
g_assert (requested_format != NULL);
|
|
|
|
|
|
|
|
|
|
if (num_handles == 1) {
|
|
|
|
|
/* first client, we set the requested format as the format */
|
|
|
|
|
format = requested_format;
|
|
|
|
|
|
|
|
|
|
/* set on the filter */
|
|
|
|
|
caps = gst_caps_from_string (g_bytes_get_data (format, NULL));
|
|
|
|
|
g_assert (caps != NULL);
|
|
|
|
|
g_object_set (priv->filter, "caps", caps, NULL);
|
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
} else {
|
|
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
|
|
/* we already have a client, format is whatever is configured already */
|
|
|
|
|
g_bytes_unref (requested_format);
|
|
|
|
|
|
|
|
|
|
g_object_get (priv->filter, "caps", &caps, NULL);
|
|
|
|
|
str = gst_caps_to_string (caps);
|
|
|
|
|
format = g_bytes_new (str, strlen (str) + 1);
|
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
}
|
|
|
|
|
/* this is what we use as the final format for the output */
|
|
|
|
|
g_object_set (gobject, "format", format, NULL);
|
|
|
|
|
g_bytes_unref (format);
|
2015-04-16 16:58:33 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
static PinosSourceOutput *
|
2015-07-28 17:05:03 +02:00
|
|
|
create_source_output (PinosSource *source,
|
|
|
|
|
const gchar *client_path,
|
|
|
|
|
GBytes *format_filter,
|
|
|
|
|
PinosProperties *props,
|
|
|
|
|
const gchar *prefix,
|
|
|
|
|
GError **error)
|
2015-04-16 16:58:33 +02:00
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
PinosSourceOutput *output;
|
2015-07-16 17:19:32 +02:00
|
|
|
PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (source)->priv;
|
|
|
|
|
GstCaps *caps;
|
2015-05-14 17:46:12 +02:00
|
|
|
gchar *str;
|
2015-04-28 17:36:44 +02:00
|
|
|
|
2015-07-09 17:36:17 +02:00
|
|
|
if (format_filter) {
|
2015-07-16 17:19:32 +02:00
|
|
|
GstCaps *cfilter;
|
|
|
|
|
|
2015-07-09 17:36:17 +02:00
|
|
|
str = (gchar *) g_bytes_get_data (format_filter, NULL);
|
2015-07-16 17:19:32 +02:00
|
|
|
cfilter = gst_caps_from_string (str);
|
|
|
|
|
if (cfilter == NULL)
|
2015-07-09 17:36:17 +02:00
|
|
|
goto invalid_caps;
|
2015-07-16 17:19:32 +02:00
|
|
|
|
|
|
|
|
caps = gst_caps_intersect (priv->possible_formats, cfilter);
|
|
|
|
|
gst_caps_unref (cfilter);
|
|
|
|
|
|
|
|
|
|
if (caps == NULL || gst_caps_is_empty (caps))
|
|
|
|
|
goto no_format;
|
2015-07-09 17:36:17 +02:00
|
|
|
} else {
|
2015-07-16 17:19:32 +02:00
|
|
|
caps = gst_caps_ref (priv->possible_formats);
|
2015-07-09 17:36:17 +02:00
|
|
|
}
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2015-07-16 17:19:32 +02:00
|
|
|
str = gst_caps_to_string (caps);
|
|
|
|
|
gst_caps_unref (caps);
|
2015-05-14 17:46:12 +02:00
|
|
|
|
|
|
|
|
format_filter = g_bytes_new_take (str, strlen (str) + 1);
|
|
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
output = PINOS_SOURCE_CLASS (pinos_gst_source_parent_class)
|
2015-05-15 13:34:32 +02:00
|
|
|
->create_source_output (source,
|
|
|
|
|
client_path,
|
|
|
|
|
format_filter,
|
2015-07-28 17:05:03 +02:00
|
|
|
props,
|
2015-05-15 13:34:32 +02:00
|
|
|
prefix,
|
|
|
|
|
error);
|
2015-07-09 17:36:17 +02:00
|
|
|
g_bytes_unref (format_filter);
|
|
|
|
|
|
2015-05-15 13:34:32 +02:00
|
|
|
if (error == NULL)
|
|
|
|
|
return NULL;
|
2015-05-14 17:46:12 +02:00
|
|
|
|
2015-04-16 16:58:33 +02:00
|
|
|
g_signal_connect (output, "notify::socket", (GCallback) on_socket_notify, source);
|
|
|
|
|
|
|
|
|
|
return output;
|
2015-04-28 17:36:44 +02:00
|
|
|
|
|
|
|
|
/* ERRORS */
|
2015-05-14 17:46:12 +02:00
|
|
|
invalid_caps:
|
|
|
|
|
{
|
2015-05-15 13:34:32 +02:00
|
|
|
if (error)
|
|
|
|
|
*error = g_error_new (G_IO_ERROR,
|
|
|
|
|
G_IO_ERROR_INVALID_DATA,
|
|
|
|
|
"Input filter data invalid");
|
2015-05-14 17:46:12 +02:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
no_format:
|
2015-04-28 17:36:44 +02:00
|
|
|
{
|
2015-07-16 17:19:32 +02:00
|
|
|
if (caps)
|
|
|
|
|
gst_caps_unref (caps);
|
2015-05-15 13:34:32 +02:00
|
|
|
if (error)
|
|
|
|
|
*error = g_error_new (G_IO_ERROR,
|
|
|
|
|
G_IO_ERROR_NOT_FOUND,
|
|
|
|
|
"No format available that matches input filter");
|
2015-04-28 17:36:44 +02:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2015-04-16 16:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2015-07-07 16:46:23 +02:00
|
|
|
release_source_output (PinosSource *source,
|
|
|
|
|
PinosSourceOutput *output)
|
2015-04-16 16:58:33 +02:00
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
return PINOS_SOURCE_CLASS (pinos_gst_source_parent_class)->release_source_output (source, output);
|
2015-04-16 16:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-05-21 16:49:26 +02:00
|
|
|
get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2015-04-16 16:58:33 +02:00
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
PinosGstSource *source = PINOS_GST_SOURCE (object);
|
|
|
|
|
PinosGstSourcePrivate *priv = source->priv;
|
2015-05-21 16:49:26 +02:00
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_ELEMENT:
|
|
|
|
|
g_value_set_object (value, priv->element);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-04-16 16:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-05-21 16:49:26 +02:00
|
|
|
set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
PinosGstSource *source = PINOS_GST_SOURCE (object);
|
|
|
|
|
PinosGstSourcePrivate *priv = source->priv;
|
2015-05-21 16:49:26 +02:00
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_ELEMENT:
|
|
|
|
|
priv->element = g_value_dup_object (value);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
source_constructed (GObject * object)
|
|
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
PinosGstSource *source = PINOS_GST_SOURCE (object);
|
2015-05-21 16:49:26 +02:00
|
|
|
|
|
|
|
|
setup_pipeline (source);
|
|
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
G_OBJECT_CLASS (pinos_gst_source_parent_class)->constructed (object);
|
2015-05-21 16:49:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
source_finalize (GObject * object)
|
|
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
PinosGstSource *source = PINOS_GST_SOURCE (object);
|
2015-05-21 16:49:26 +02:00
|
|
|
|
|
|
|
|
destroy_pipeline (source);
|
|
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
G_OBJECT_CLASS (pinos_gst_source_parent_class)->finalize (object);
|
2015-05-21 16:49:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-07-07 16:46:23 +02:00
|
|
|
pinos_gst_source_class_init (PinosGstSourceClass * klass)
|
2015-04-16 16:58:33 +02:00
|
|
|
{
|
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2015-07-07 16:46:23 +02:00
|
|
|
PinosSourceClass *source_class = PINOS_SOURCE_CLASS (klass);
|
2015-04-16 16:58:33 +02:00
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
g_type_class_add_private (klass, sizeof (PinosGstSourcePrivate));
|
2015-05-21 16:49:26 +02:00
|
|
|
|
|
|
|
|
gobject_class->constructed = source_constructed;
|
|
|
|
|
gobject_class->finalize = source_finalize;
|
|
|
|
|
gobject_class->get_property = get_property;
|
|
|
|
|
gobject_class->set_property = set_property;
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_ELEMENT,
|
|
|
|
|
g_param_spec_object ("element",
|
|
|
|
|
"Element",
|
|
|
|
|
"The element",
|
|
|
|
|
GST_TYPE_ELEMENT,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2015-04-16 16:58:33 +02:00
|
|
|
|
|
|
|
|
|
2015-05-21 16:49:26 +02:00
|
|
|
source_class->get_formats = get_formats;
|
|
|
|
|
source_class->set_state = set_state;
|
|
|
|
|
source_class->create_source_output = create_source_output;
|
|
|
|
|
source_class->release_source_output = release_source_output;
|
2015-04-16 16:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-07-07 16:46:23 +02:00
|
|
|
pinos_gst_source_init (PinosGstSource * source)
|
2015-04-16 16:58:33 +02:00
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
source->priv = PINOS_GST_SOURCE_GET_PRIVATE (source);
|
2015-04-16 16:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
2015-07-07 16:46:23 +02:00
|
|
|
PinosSource *
|
|
|
|
|
pinos_gst_source_new (PinosDaemon *daemon,
|
|
|
|
|
const gchar *name,
|
2015-07-17 16:57:01 +02:00
|
|
|
PinosProperties *properties,
|
2015-07-07 16:46:23 +02:00
|
|
|
GstElement *element)
|
2015-04-16 16:58:33 +02:00
|
|
|
{
|
2015-07-07 16:46:23 +02:00
|
|
|
return g_object_new (PINOS_TYPE_GST_SOURCE,
|
|
|
|
|
"daemon", daemon,
|
|
|
|
|
"name", name,
|
2015-07-17 16:57:01 +02:00
|
|
|
"properties", properties,
|
|
|
|
|
"element", element,
|
|
|
|
|
NULL);
|
2015-04-16 16:58:33 +02:00
|
|
|
}
|