pipewire/pinos/client/stream.c

830 lines
23 KiB
C
Raw Normal View History

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.
*/
#include <sys/socket.h>
#include <string.h>
2015-04-16 16:58:33 +02:00
#include <gio/gunixfdlist.h>
#include <gio/gunixfdmessage.h>
2015-04-16 16:58:33 +02:00
#include "pinos/server/daemon.h"
#include "pinos/client/pinos.h"
#include "pinos/client/context.h"
#include "pinos/client/stream.h"
#include "pinos/client/enumtypes.h"
2015-04-16 16:58:33 +02:00
#include "pinos/client/private.h"
struct _PinosStreamPrivate
2015-04-16 16:58:33 +02:00
{
PinosContext *context;
2015-04-16 16:58:33 +02:00
gchar *name;
PinosProperties *properties;
2015-05-27 18:16:52 +02:00
2015-06-04 16:34:47 +02:00
guint id;
PinosStreamState state;
GError *error;
2015-04-16 16:58:33 +02:00
PinosDirection direction;
gchar *path;
GBytes *possible_formats;
PinosStreamFlags flags;
2015-05-27 18:16:52 +02:00
GBytes *format;
2015-05-27 18:16:52 +02:00
PinosNode *node;
PinosPort *port;
gboolean disconnecting;
2015-04-16 16:58:33 +02:00
PinosStreamMode mode;
2015-04-16 16:58:33 +02:00
};
#define PINOS_STREAM_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_STREAM, PinosStreamPrivate))
2015-04-16 16:58:33 +02:00
G_DEFINE_TYPE (PinosStream, pinos_stream, G_TYPE_OBJECT);
2015-04-16 16:58:33 +02:00
enum
{
PROP_0,
PROP_CONTEXT,
PROP_NAME,
PROP_PROPERTIES,
2015-04-16 16:58:33 +02:00
PROP_STATE,
PROP_POSSIBLE_FORMATS,
PROP_FORMAT,
2015-04-16 16:58:33 +02:00
};
enum
{
SIGNAL_NEW_BUFFER,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
static void
pinos_stream_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
2015-04-16 16:58:33 +02:00
{
PinosStream *stream = PINOS_STREAM (_object);
PinosStreamPrivate *priv = stream->priv;
2015-04-16 16:58:33 +02:00
switch (prop_id) {
case PROP_CONTEXT:
g_value_set_object (value, priv->context);
break;
case PROP_NAME:
g_value_set_string (value, priv->name);
break;
case PROP_PROPERTIES:
g_value_set_boxed (value, priv->properties);
break;
2015-04-16 16:58:33 +02:00
case PROP_STATE:
g_value_set_enum (value, priv->state);
break;
case PROP_POSSIBLE_FORMATS:
g_value_set_boxed (value, priv->possible_formats);
break;
case PROP_FORMAT:
g_value_set_boxed (value, priv->format);
break;
2015-04-16 16:58:33 +02:00
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (stream, prop_id, pspec);
break;
}
}
static void
pinos_stream_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
2015-04-16 16:58:33 +02:00
{
PinosStream *stream = PINOS_STREAM (_object);
PinosStreamPrivate *priv = stream->priv;
2015-04-16 16:58:33 +02:00
switch (prop_id) {
case PROP_CONTEXT:
priv->context = g_value_dup_object (value);
break;
case PROP_NAME:
priv->name = g_value_dup_string (value);
break;
case PROP_PROPERTIES:
if (priv->properties)
pinos_properties_free (priv->properties);
priv->properties = g_value_dup_boxed (value);
break;
case PROP_FORMAT:
if (priv->format)
g_bytes_unref (priv->format);
priv->format = g_value_dup_boxed (value);
break;
2015-04-16 16:58:33 +02:00
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (stream, prop_id, pspec);
break;
}
}
static gboolean
do_notify_state (PinosStream *stream)
{
g_object_notify (G_OBJECT (stream), "state");
g_object_unref (stream);
return FALSE;
}
2015-06-04 16:34:47 +02:00
static void
stream_set_state (PinosStream *stream,
2015-08-26 17:11:10 +02:00
PinosStreamState state,
GError *error)
2015-06-04 16:34:47 +02:00
{
if (stream->priv->state != state) {
2015-08-26 17:11:10 +02:00
if (error) {
g_clear_error (&stream->priv->error);
stream->priv->error = error;
}
2015-06-04 16:34:47 +02:00
stream->priv->state = state;
g_main_context_invoke (stream->priv->context->priv->context,
(GSourceFunc) do_notify_state,
g_object_ref (stream));
2015-08-26 17:11:10 +02:00
} else {
if (error)
g_error_free (error);
2015-06-04 16:34:47 +02:00
}
}
static GDBusProxy *
get_proxy (PinosStream *stream, GList *list, const gchar *path)
{
GList *walk;
for (walk = list; walk; walk = g_list_next (walk)) {
GDBusProxy *proxy = walk->data;
if (!g_strcmp0 (g_dbus_proxy_get_object_path (proxy), path)) {
return proxy;
}
}
return NULL;
}
static GDBusProxy *
get_port_proxy (PinosStream *stream, const gchar *path)
{
return get_proxy (stream, stream->priv->context->priv->ports, path);
}
static GDBusProxy *
get_node_proxy (PinosStream *stream, const gchar *path)
{
return get_proxy (stream, stream->priv->context->priv->nodes, path);
}
static GDBusProxy *
get_peer_port_proxy (PinosStream *stream)
{
PinosStreamPrivate *priv = stream->priv;
GDBusProxy *port_proxy;
GDBusProxy *peer_proxy = NULL;
if (priv->port == NULL)
return NULL;
g_object_get (priv->port, "proxy", &port_proxy, NULL);
if (port_proxy) {
GVariant *v;
v = g_dbus_proxy_get_cached_property (port_proxy, "Peers");
if (v) {
GVariantIter *iter;
gchar *peer_path;
g_variant_get (v, "ao", &iter);
if (g_variant_iter_next (iter, "&o", &peer_path, NULL)) {
peer_proxy = get_port_proxy (stream, peer_path);
}
g_variant_iter_free (iter);
}
}
return peer_proxy;
}
static GDBusProxy *
get_peer_node_proxy (PinosStream *stream)
{
GDBusProxy *peer_port;
GVariant *v;
GDBusProxy *node = NULL;
peer_port = get_peer_port_proxy (stream);
if (peer_port) {
v = g_dbus_proxy_get_cached_property (peer_port, "Node");
if (v) {
const gchar *node_path = g_variant_get_string (v, NULL);
node = get_node_proxy (stream, node_path);
g_variant_unref (v);
}
}
return node;
}
static void
merge_peer_properties (PinosStream *stream)
{
PinosStreamPrivate *priv = stream->priv;
GDBusProxy *peer_node;
peer_node = get_peer_node_proxy (stream);
if (peer_node) {
GVariant *v = g_dbus_proxy_get_cached_property (peer_node, "Properties");
if (v) {
PinosProperties *props = pinos_properties_from_variant (v);
priv->properties = pinos_properties_merge (priv->properties, props);
pinos_properties_free (props);
g_variant_unref (v);
}
}
}
2015-06-04 16:34:47 +02:00
static void
subscription_cb (PinosSubscribe *subscribe,
PinosSubscriptionEvent event,
PinosSubscriptionFlags flags,
GDBusProxy *object,
gpointer user_data)
2015-06-04 16:34:47 +02:00
{
PinosStream *stream = PINOS_STREAM (user_data);
PinosStreamPrivate *priv = stream->priv;
2015-06-04 16:34:47 +02:00
switch (flags) {
case PINOS_SUBSCRIPTION_FLAG_NODE:
if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
if (object == priv->node && !priv->disconnecting) {
2015-08-26 17:11:10 +02:00
stream_set_state (stream,
PINOS_STREAM_STATE_ERROR,
g_error_new_literal (G_IO_ERROR,
G_IO_ERROR_CLOSED,
"Node disappeared"));
2015-06-04 16:34:47 +02:00
}
} else if (event == PINOS_SUBSCRIPTION_EVENT_NEW ||
event == PINOS_SUBSCRIPTION_EVENT_CHANGE) {
if (object == get_peer_node_proxy (stream)) {
merge_peer_properties (stream);
}
2015-06-04 16:34:47 +02:00
}
break;
case PINOS_SUBSCRIPTION_FLAG_PORT:
if (event == PINOS_SUBSCRIPTION_EVENT_NEW ||
event == PINOS_SUBSCRIPTION_EVENT_CHANGE) {
if (object == get_peer_port_proxy (stream)) {
merge_peer_properties (stream);
}
}
break;
2015-06-04 16:34:47 +02:00
default:
break;
}
}
static void
pinos_stream_constructed (GObject * object)
2015-06-04 16:34:47 +02:00
{
PinosStream *stream = PINOS_STREAM (object);
PinosStreamPrivate *priv = stream->priv;
2015-06-04 16:34:47 +02:00
priv->id = g_signal_connect (priv->context->priv->subscribe,
"subscription-event",
(GCallback) subscription_cb,
stream);
G_OBJECT_CLASS (pinos_stream_parent_class)->constructed (object);
2015-06-04 16:34:47 +02:00
}
2015-04-16 16:58:33 +02:00
static void
pinos_stream_finalize (GObject * object)
2015-04-16 16:58:33 +02:00
{
PinosStream *stream = PINOS_STREAM (object);
PinosStreamPrivate *priv = stream->priv;
2015-04-16 16:58:33 +02:00
2015-08-26 17:11:10 +02:00
g_debug ("free stream %p", stream);
g_clear_object (&priv->node);
2015-05-27 18:16:52 +02:00
if (priv->possible_formats)
g_bytes_unref (priv->possible_formats);
if (priv->format)
g_bytes_unref (priv->format);
g_free (priv->path);
if (priv->possible_formats)
g_bytes_unref (priv->possible_formats);
2015-05-27 18:16:52 +02:00
g_clear_error (&priv->error);
if (priv->properties)
pinos_properties_free (priv->properties);
2015-06-04 16:34:47 +02:00
g_signal_handler_disconnect (priv->context->priv->subscribe, priv->id);
2015-05-27 18:16:52 +02:00
g_clear_object (&priv->context);
2015-04-16 16:58:33 +02:00
g_free (priv->name);
G_OBJECT_CLASS (pinos_stream_parent_class)->finalize (object);
2015-04-16 16:58:33 +02:00
}
static void
pinos_stream_class_init (PinosStreamClass * klass)
2015-04-16 16:58:33 +02:00
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (PinosStreamPrivate));
2015-04-16 16:58:33 +02:00
gobject_class->constructed = pinos_stream_constructed;
gobject_class->finalize = pinos_stream_finalize;
gobject_class->set_property = pinos_stream_set_property;
gobject_class->get_property = pinos_stream_get_property;
2015-04-16 16:58:33 +02:00
/**
* PinosStream:context
2015-04-16 16:58:33 +02:00
*
* The context of the stream.
*/
g_object_class_install_property (gobject_class,
PROP_CONTEXT,
g_param_spec_object ("context",
"Context",
"The context",
PINOS_TYPE_CONTEXT,
2015-04-16 16:58:33 +02:00
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* PinosStream:name
2015-04-16 16:58:33 +02:00
*
* The name of the stream as specified at construction time.
*/
g_object_class_install_property (gobject_class,
PROP_NAME,
g_param_spec_string ("name",
"Name",
"The name of the stream",
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* PinosStream:properties
*
* The properties of the stream as specified at construction time.
*/
g_object_class_install_property (gobject_class,
PROP_PROPERTIES,
g_param_spec_boxed ("properties",
"Properties",
"The properties of the stream",
PINOS_TYPE_PROPERTIES,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
2015-04-16 16:58:33 +02:00
/**
* PinosStream:state
2015-04-16 16:58:33 +02:00
*
* The state of the stream. Use the notify::state signal to be notified
* of state changes.
*/
g_object_class_install_property (gobject_class,
PROP_STATE,
g_param_spec_enum ("state",
"State",
"The stream state",
PINOS_TYPE_STREAM_STATE,
PINOS_STREAM_STATE_UNCONNECTED,
2015-04-16 16:58:33 +02:00
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* PinosStream:possible-formats
*
* The possible formats for the stream. this can only be used after connecting
* the stream for capture or provide.
*/
g_object_class_install_property (gobject_class,
PROP_POSSIBLE_FORMATS,
g_param_spec_boxed ("possible-formats",
"Possible Formats",
"The possbile formats of the stream",
G_TYPE_BYTES,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* PinosStream:formats
*
* The format of the stream. This will be set after starting the stream.
*/
g_object_class_install_property (gobject_class,
PROP_FORMAT,
g_param_spec_boxed ("format",
"Format",
"The format of the stream",
G_TYPE_BYTES,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
2015-04-16 16:58:33 +02:00
/**
* PinosStream:new-buffer
2015-04-16 16:58:33 +02:00
*
* When doing pinos_stream_start() with #PINOS_STREAM_MODE_BUFFER, this signal
2015-04-16 16:58:33 +02:00
* will be fired whenever a new buffer can be obtained with
* pinos_stream_capture_buffer().
2015-04-16 16:58:33 +02:00
*/
signals[SIGNAL_NEW_BUFFER] = g_signal_new ("new-buffer",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE,
0,
G_TYPE_NONE);
}
static void
pinos_stream_init (PinosStream * stream)
2015-04-16 16:58:33 +02:00
{
PinosStreamPrivate *priv = stream->priv = PINOS_STREAM_GET_PRIVATE (stream);
2015-04-16 16:58:33 +02:00
2015-08-26 17:11:10 +02:00
g_debug ("new stream %p", stream);
priv->state = PINOS_STREAM_STATE_UNCONNECTED;
2015-04-16 16:58:33 +02:00
}
/**
* pinos_stream_state_as_string:
* @state: a #PinosStreamState
*
* Return the string representation of @state.
*
* Returns: the string representation of @state.
*/
const gchar *
pinos_stream_state_as_string (PinosStreamState state)
{
GEnumValue *val;
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_STREAM_STATE)),
state);
return val == NULL ? "invalid-state" : val->value_nick;
}
2015-04-16 16:58:33 +02:00
/**
* pinos_stream_new:
* @context: a #PinosContext
2015-04-16 16:58:33 +02:00
* @name: a stream name
2015-08-26 15:44:29 +02:00
* @properties: (transfer full): stream properties
2015-04-16 16:58:33 +02:00
*
* Make a new unconnected #PinosStream
2015-04-16 16:58:33 +02:00
*
* Returns: a new unconnected #PinosStream
2015-04-16 16:58:33 +02:00
*/
PinosStream *
pinos_stream_new (PinosContext *context,
const gchar *name,
PinosProperties *props)
2015-04-16 16:58:33 +02:00
{
2015-08-26 15:44:29 +02:00
PinosStream *stream;
g_return_val_if_fail (PINOS_IS_CONTEXT (context), NULL);
2015-04-16 16:58:33 +02:00
g_return_val_if_fail (name != NULL, NULL);
if (props == NULL) {
props = pinos_properties_new ("media.name", name, NULL);
} else if (!pinos_properties_get (props, "media.name")) {
pinos_properties_set (props, "media.name", name);
}
2015-08-26 15:44:29 +02:00
stream = g_object_new (PINOS_TYPE_STREAM,
"context", context,
"name", name,
"properties", props,
NULL);
2015-08-26 15:44:29 +02:00
pinos_properties_free (props);
return stream;
2015-04-16 16:58:33 +02:00
}
/**
* pinos_stream_get_state:
* @stream: a #PinosStream
2015-04-16 16:58:33 +02:00
*
* Get the state of @stream.
*
* Returns: the state of @stream
*/
PinosStreamState
pinos_stream_get_state (PinosStream *stream)
2015-04-16 16:58:33 +02:00
{
g_return_val_if_fail (PINOS_IS_STREAM (stream), PINOS_STREAM_STATE_ERROR);
2015-04-16 16:58:33 +02:00
return stream->priv->state;
}
/**
* pinos_stream_get_error:
* @stream: a #PinosStream
*
* Get the error of @stream.
*
* Returns: the error of @stream or %NULL when there is no error
*/
const GError *
pinos_stream_get_error (PinosStream *stream)
{
g_return_val_if_fail (PINOS_IS_STREAM (stream), NULL);
return stream->priv->error;
}
static gboolean
do_connect (PinosStream *stream)
{
PinosStreamPrivate *priv = stream->priv;
PinosContext *context = priv->context;
return FALSE;
}
2015-04-16 16:58:33 +02:00
/**
* pinos_stream_connect:
* @stream: a #PinosStream
* @direction: the stream direction
* @port_path: the port path to connect to or %NULL to get the default port
* @flags: a #PinosStreamFlags
* @possible_formats: (transfer full): a #GBytes with possible accepted formats
2015-04-16 16:58:33 +02:00
*
* Connect @stream for input or output on @port_path.
2015-04-16 16:58:33 +02:00
*
* Returns: %TRUE on success.
*/
gboolean
pinos_stream_connect (PinosStream *stream,
PinosDirection direction,
const gchar *port_path,
PinosStreamFlags flags,
GBytes *possible_formats)
2015-04-16 16:58:33 +02:00
{
PinosStreamPrivate *priv;
PinosContext *context;
2015-04-16 16:58:33 +02:00
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
g_return_val_if_fail (possible_formats != NULL, FALSE);
2015-04-16 16:58:33 +02:00
priv = stream->priv;
context = priv->context;
g_return_val_if_fail (pinos_context_get_state (context) == PINOS_CONTEXT_STATE_CONNECTED, FALSE);
g_return_val_if_fail (pinos_stream_get_state (stream) == PINOS_STREAM_STATE_UNCONNECTED, FALSE);
2015-04-16 16:58:33 +02:00
priv->direction = direction;
g_free (priv->path);
priv->path = g_strdup (port_path);
if (priv->possible_formats)
g_bytes_unref (priv->possible_formats);
priv->flags = flags;
priv->possible_formats = possible_formats;
2015-08-26 17:11:10 +02:00
stream_set_state (stream, PINOS_STREAM_STATE_CONNECTING, NULL);
2015-05-27 18:16:52 +02:00
g_main_context_invoke (context->priv->context,
(GSourceFunc) do_connect,
g_object_ref (stream));
return TRUE;
}
static gboolean
do_start (PinosStream *stream)
{
stream_set_state (stream, PINOS_STREAM_STATE_STREAMING, NULL);
g_object_unref (stream);
return FALSE;
}
/**
* pinos_stream_start:
* @stream: a #PinosStream
* @format: (transfer full): a #GBytes with format
* @mode: a #PinosStreamMode
*
* Start capturing from @stream in @format.
*
* When @mode is #PINOS_STREAM_MODE_SOCKET, you should connect to the notify::socket
* signal to obtain a readable socket with metadata and data.
*
* When @mode is #PINOS_STREAM_MODE_BUFFER, you should connect to the new-buffer
* signal and use pinos_stream_capture_buffer() to get the latest metadata and
* data.
*
* Returns: %TRUE on success.
*/
gboolean
pinos_stream_start (PinosStream *stream,
GBytes *format,
PinosStreamMode mode)
{
PinosStreamPrivate *priv;
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
priv = stream->priv;
g_return_val_if_fail (priv->state == PINOS_STREAM_STATE_READY, FALSE);
priv->mode = mode;
priv->format = format;
stream_set_state (stream, PINOS_STREAM_STATE_STARTING, NULL);
2015-08-26 17:11:10 +02:00
g_main_context_invoke (priv->context->priv->context,
(GSourceFunc) do_start,
g_object_ref (stream));
return TRUE;
}
static gboolean
do_stop (PinosStream *stream)
{
stream_set_state (stream, PINOS_STREAM_STATE_READY, NULL);
g_object_unref (stream);
return FALSE;
}
/**
* pinos_stream_stop:
* @stream: a #PinosStream
*
* Stop capturing from @stream.
*
* Returns: %TRUE on success.
*/
gboolean
pinos_stream_stop (PinosStream *stream)
{
PinosStreamPrivate *priv;
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
priv = stream->priv;
g_return_val_if_fail (priv->state == PINOS_STREAM_STATE_STREAMING, FALSE);
g_main_context_invoke (priv->context->priv->context,
(GSourceFunc) do_stop,
g_object_ref (stream));
return TRUE;
}
static gboolean
do_disconnect (PinosStream *stream)
{
PinosStreamPrivate *priv = stream->priv;
return FALSE;
}
2015-04-16 16:58:33 +02:00
/**
* pinos_stream_disconnect:
* @stream: a #PinosStream
2015-04-16 16:58:33 +02:00
*
* Disconnect @stream.
*
* Returns: %TRUE on success
*/
gboolean
pinos_stream_disconnect (PinosStream *stream)
2015-04-16 16:58:33 +02:00
{
PinosStreamPrivate *priv;
PinosContext *context;
2015-04-16 16:58:33 +02:00
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
2015-04-16 16:58:33 +02:00
priv = stream->priv;
g_return_val_if_fail (priv->state >= PINOS_STREAM_STATE_READY, FALSE);
g_return_val_if_fail (priv->node != NULL, FALSE);
2015-04-16 16:58:33 +02:00
context = priv->context;
g_return_val_if_fail (pinos_context_get_state (context) >= PINOS_CONTEXT_STATE_CONNECTED, FALSE);
g_return_val_if_fail (!priv->disconnecting, FALSE);
priv->disconnecting = TRUE;
2015-04-16 16:58:33 +02:00
2015-05-27 18:16:52 +02:00
g_main_context_invoke (context->priv->context,
(GSourceFunc) do_disconnect,
g_object_ref (stream));
2015-04-16 16:58:33 +02:00
return TRUE;
}
/**
* pinos_stream_peek_buffer:
* @stream: a #PinosStream
2015-04-16 16:58:33 +02:00
*
* Get the current buffer from @stream. This function should be called from
* the new-buffer signal callback.
2015-04-16 16:58:33 +02:00
*
* Returns: a #PinosBuffer or %NULL when there is no buffer.
2015-04-16 16:58:33 +02:00
*/
PinosBuffer *
pinos_stream_peek_buffer (PinosStream *stream)
2015-04-16 16:58:33 +02:00
{
PinosStreamPrivate *priv;
2015-04-16 16:58:33 +02:00
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
2015-04-16 16:58:33 +02:00
priv = stream->priv;
//g_return_val_if_fail (priv->state == PINOS_STREAM_STATE_STREAMING, FALSE);
2015-04-16 16:58:33 +02:00
2016-07-18 17:40:58 +02:00
return NULL;
}
2015-04-16 16:58:33 +02:00
/**
* pinos_stream_buffer_builder_init:
* @stream: a #PinosStream
* @builder: a #PinosBufferBuilder
*
* Get a #PinosBufferBuilder for @stream.
*
* Returns: a #PinosBuffer or %NULL when there is no buffer.
*/
void
pinos_stream_buffer_builder_init (PinosStream *stream, PinosBufferBuilder *builder)
{
PinosStreamPrivate *priv;
g_return_if_fail (PINOS_IS_STREAM (stream));
priv = stream->priv;
2015-04-16 16:58:33 +02:00
}
/**
* pinos_stream_send_buffer:
* @stream: a #PinosStream
* @buffer: a #PinosBuffer
*
* Send a buffer to @stream.
*
* For provider streams, this function should be called whenever there is a new frame
* available.
*
* For capture streams, this functions should be called for each fd-payload that
* should be released.
*
* Returns: %TRUE when @buffer was handled
*/
gboolean
pinos_stream_send_buffer (PinosStream *stream,
PinosBuffer *buffer)
{
PinosStreamPrivate *priv;
GError *error = NULL;
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
g_return_val_if_fail (buffer != NULL, FALSE);
priv = stream->priv;
g_return_val_if_fail (priv->state == PINOS_STREAM_STATE_STREAMING, FALSE);
return TRUE;
}