Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Peter Hutterer
pipewire
Commits
d374f50d
Commit
d374f50d
authored
Jul 25, 2016
by
Wim Taymans
Browse files
channel: remove the channel
Remove the channel, the functionality is now in the client-node.
parent
907bd7bf
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
pinos/Makefile.am
View file @
d374f50d
...
...
@@ -205,7 +205,6 @@ lib_LTLIBRARIES += libpinoscore-@PINOS_MAJORMINOR@.la
# Pure core stuff
libpinoscore_@PINOS_MAJORMINOR@
_la_SOURCES
=
\
server/channel.c server/channel.h
\
server/client.c server/client.h
\
server/client-node.c server/client-node.h
\
server/daemon.c server/daemon.h
\
...
...
pinos/client/stream.c
View file @
d374f50d
...
...
@@ -786,7 +786,7 @@ do_connect (PinosStream *stream)
g_variant_builder_add
(
&
b
,
"u"
,
0
);
g_variant_builder_add
(
&
b
,
"s"
,
g_bytes_get_data
(
priv
->
possible_formats
,
NULL
));
g_variant_builder_add_value
(
&
b
,
pinos_properties_to_variant
(
priv
->
properties
));
g_variant_builder_add
(
&
b
,
"s"
,
priv
->
path
);
g_variant_builder_add
(
&
b
,
"s"
,
priv
->
path
==
NULL
?
""
:
priv
->
path
);
g_variant_builder_close
(
&
b
);
ports
=
g_variant_builder_end
(
&
b
);
...
...
pinos/dbus/org.pinos.xml
View file @
d374f50d
...
...
@@ -23,27 +23,6 @@
<!-- Properties: Extra properties of the daemon -->
<property
name=
'Properties'
type=
'a{sv}'
access=
'read'
/>
<!-- CreateChannel:
@node: the Node1 object path or / for default
@direction: the direction of the channel
0 = input channel
1 = output channel
@possible_formats: the possible formats that can be accepted
@properties: extra properties
@channel: the Channel object path
@fd: a file descriptor for data transfer
Create a new channel to communicate with @node with given @possible_formats
-->
<method
name=
'CreateChannel'
>
<arg
type=
's'
name=
'node'
direction=
'in'
/>
<arg
type=
'u'
name=
'direction'
direction=
'in'
/>
<arg
type=
's'
name=
'possible_formats'
direction=
'in'
/>
<arg
type=
'a{sv}'
name=
'properties'
direction=
'in'
/>
<arg
type=
'o'
name=
'channel'
direction=
'out'
/>
<arg
type=
'h'
name=
'fd'
direction=
'out'
/>
</method>
<!-- CreateNode:
@factory_name: the factory name to use for the node
@name: the name of the node
...
...
@@ -59,6 +38,14 @@
<arg
type=
'o'
name=
'node'
direction=
'out'
/>
</method>
<!-- CreateClientNode:
@name: the name of the node
@Properties: extra properties
@ports: the port descriptions
@node: the Node1 object path
Create a new Node with given name and properties and ports.
-->
<method
name=
'CreateClientNode'
>
<arg
type=
's'
name=
'name'
direction=
'in'
/>
<arg
type=
'a{sv}'
name=
'properties'
direction=
'in'
/>
...
...
@@ -83,54 +70,12 @@
<property
name=
'Sender'
type=
's'
access=
'read'
/>
<!-- Name: Properties of the client -->
<property
name=
'Properties'
type=
'a{sv}'
access=
'read'
/>
</interface>
<!--
org.pinos.Channel:
@short_description: Interface for input/output channel
This interface is used to control the input/output of a
node and start/stop the media transport.
-->
<interface
name=
'org.pinos.Channel1'
>
<!-- Owner: the owner node of this channel -->
<property
name=
'Owner'
type=
'o'
access=
'read'
/>
<!-- type: type of the channel
0 = input channel
1 = output channel
-->
<property
name=
'Direction'
type=
'u'
access=
'read'
/>
<property
name=
'Node'
type=
'o'
access=
'read'
/>
<!-- Properties: extra channel properties -->
<property
name=
'Properties'
type=
'a{sv}'
access=
'read'
/>
<!-- state: state of the channel
-1 = the channel is in error
0 = the channel is idle
1 = the channel is starting
2 = the channel is streaming
-->
<property
name=
'State'
type=
'u'
access=
'read'
/>
<!-- PossibleFormats:
all possible formats of the channel. This is filtered
against the accepted_formats when creating the channel.
-->
<property
name=
'PossibleFormats'
type=
's'
access=
'read'
/>
<!-- Format: the current streaming format -->
<property
name=
'Format'
type=
's'
access=
'read'
/>
<!-- Remove:
Remove the channel
-->
<method
name=
'Remove'
/>
</interface>
<!--
org.pinos.Node1:
@short_description: A processing node
...
...
pinos/server/channel.c
deleted
100644 → 0
View file @
907bd7bf
This diff is collapsed.
Click to expand it.
pinos/server/channel.h
deleted
100644 → 0
View file @
907bd7bf
/* Pinos
* 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.
*/
#ifndef __PINOS_CHANNEL_H__
#define __PINOS_CHANNEL_H__
#include <glib-object.h>
G_BEGIN_DECLS
#define PINOS_TYPE_CHANNEL (pinos_channel_get_type ())
#define PINOS_IS_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_CHANNEL))
#define PINOS_IS_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_CHANNEL))
#define PINOS_CHANNEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_CHANNEL, PinosChannelClass))
#define PINOS_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_CHANNEL, PinosChannel))
#define PINOS_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_CHANNEL, PinosChannelClass))
#define PINOS_CHANNEL_CAST(obj) ((PinosChannel*)(obj))
#define PINOS_CHANNEL_CLASS_CAST(klass) ((PinosChannelClass*)(klass))
typedef
struct
_PinosChannel
PinosChannel
;
typedef
struct
_PinosChannelClass
PinosChannelClass
;
typedef
struct
_PinosChannelPrivate
PinosChannelPrivate
;
/**
* PinosChannel:
*
* Pinos source channel object class.
*/
struct
_PinosChannel
{
GObject
object
;
PinosChannelPrivate
*
priv
;
};
/**
* PinosChannelClass:
*
* Pinos source channel object class.
*/
struct
_PinosChannelClass
{
GObjectClass
parent_class
;
};
/* normal GObject stuff */
GType
pinos_channel_get_type
(
void
);
void
pinos_channel_remove
(
PinosChannel
*
channel
);
const
gchar
*
pinos_channel_get_client_path
(
PinosChannel
*
channel
);
const
gchar
*
pinos_channel_get_object_path
(
PinosChannel
*
channel
);
GSocket
*
pinos_channel_get_socket_pair
(
PinosChannel
*
channel
,
GError
**
error
);
G_END_DECLS
#endif
/* __PINOS_CHANNEL_H__ */
pinos/server/client-node.c
View file @
d374f50d
...
...
@@ -68,7 +68,7 @@ enum
LAST_SIGNAL
};
static
guint
signals
[
LAST_SIGNAL
]
=
{
0
};
//
static guint signals[LAST_SIGNAL] = { 0 };
static
void
pinos_client_node_get_property
(
GObject
*
_object
,
...
...
@@ -175,6 +175,26 @@ parse_buffer (PinosClientNode *cnode,
}
case
PINOS_PACKET_TYPE_STOP
:
{
PinosBufferBuilder
builder
;
PinosBuffer
obuf
;
guint8
buffer
[
1024
];
GError
*
error
=
NULL
;
GList
*
ports
,
*
walk
;
pinos_buffer_builder_init_into
(
&
builder
,
buffer
,
1024
,
NULL
,
0
);
ports
=
pinos_node_get_ports
(
node
);
for
(
walk
=
ports
;
walk
;
walk
=
g_list_next
(
walk
))
{
port
=
walk
->
data
;
pinos_port_deactivate
(
port
);
}
pinos_buffer_builder_add_empty
(
&
builder
,
PINOS_PACKET_TYPE_STOPPED
);
pinos_buffer_builder_end
(
&
builder
,
&
obuf
);
if
(
!
pinos_io_write_buffer
(
priv
->
fd
,
&
obuf
,
&
error
))
{
g_warning
(
"client-node %p: error writing buffer: %s"
,
node
,
error
->
message
);
g_clear_error
(
&
error
);
}
break
;
}
case
PINOS_PACKET_TYPE_REUSE_MEM
:
...
...
@@ -359,7 +379,6 @@ static void
pinos_client_node_dispose
(
GObject
*
object
)
{
PinosClientNode
*
node
=
PINOS_CLIENT_NODE
(
object
);
PinosClientNodePrivate
*
priv
=
node
->
priv
;
g_debug
(
"client-node %p: dispose"
,
node
);
unhandle_socket
(
node
);
...
...
@@ -371,7 +390,6 @@ static void
pinos_client_node_finalize
(
GObject
*
object
)
{
PinosClientNode
*
node
=
PINOS_CLIENT_NODE
(
object
);
PinosClientNodePrivate
*
priv
=
node
->
priv
;
g_debug
(
"client-node %p: finalize"
,
node
);
...
...
@@ -409,7 +427,7 @@ pinos_client_node_class_init (PinosClientNodeClass * klass)
static
void
pinos_client_node_init
(
PinosClientNode
*
node
)
{
PinosClientNodePrivate
*
priv
=
node
->
priv
=
PINOS_CLIENT_NODE_GET_PRIVATE
(
node
);
node
->
priv
=
PINOS_CLIENT_NODE_GET_PRIVATE
(
node
);
g_debug
(
"client-node %p: new"
,
node
);
}
pinos/server/daemon.c
View file @
d374f50d
...
...
@@ -30,7 +30,6 @@
#include "pinos/server/node.h"
#include "pinos/server/client-node.h"
#include "pinos/server/client.h"
#include "pinos/server/channel.h"
#include "pinos/server/link.h"
#include "pinos/dbus/org-pinos.h"
...
...
@@ -106,117 +105,6 @@ sender_get_client (PinosDaemon *daemon,
return
client
;
}
static
void
handle_remove_channel
(
PinosChannel
*
channel
,
gpointer
user_data
)
{
PinosClient
*
client
=
user_data
;
g_debug
(
"client %p: remove channel %p"
,
client
,
channel
);
pinos_client_remove_object
(
client
,
G_OBJECT
(
channel
));
}
static
gboolean
handle_create_channel
(
PinosDaemon1
*
interface
,
GDBusMethodInvocation
*
invocation
,
const
gchar
*
arg_node
,
PinosDirection
direction
,
const
gchar
*
arg_possible_formats
,
GVariant
*
arg_properties
,
gpointer
user_data
)
{
PinosDaemon
*
daemon
=
user_data
;
const
gchar
*
sender
,
*
object_path
;
PinosProperties
*
props
;
PinosClient
*
client
;
PinosPort
*
port
;
PinosChannel
*
channel
;
GBytes
*
formats
;
GError
*
error
=
NULL
;
GUnixFDList
*
fdlist
;
GSocket
*
socket
;
gint
fdidx
;
sender
=
g_dbus_method_invocation_get_sender
(
invocation
);
g_debug
(
"daemon %p: %s create channel"
,
daemon
,
sender
);
formats
=
g_bytes_new
(
arg_possible_formats
,
strlen
(
arg_possible_formats
)
+
1
);
props
=
pinos_properties_from_variant
(
arg_properties
);
port
=
pinos_daemon_find_port
(
daemon
,
direction
,
arg_node
,
props
,
formats
,
&
error
);
if
(
port
==
NULL
)
goto
no_port
;
g_debug
(
"daemon %p: matched port %p"
,
daemon
,
port
);
client
=
sender_get_client
(
daemon
,
sender
);
channel
=
pinos_port_create_channel
(
port
,
pinos_client_get_object_path
(
client
),
formats
,
props
,
&
error
);
pinos_properties_free
(
props
);
g_bytes_unref
(
formats
);
if
(
channel
==
NULL
)
goto
no_channel
;
pinos_client_add_object
(
client
,
G_OBJECT
(
channel
));
g_signal_connect
(
channel
,
"remove"
,
(
GCallback
)
handle_remove_channel
,
client
);
socket
=
pinos_channel_get_socket_pair
(
channel
,
&
error
);
if
(
socket
==
NULL
)
goto
no_socket
;
object_path
=
pinos_channel_get_object_path
(
channel
);
g_debug
(
"daemon %p: add channel %p, %s"
,
daemon
,
channel
,
object_path
);
fdlist
=
g_unix_fd_list_new
();
fdidx
=
g_unix_fd_list_append
(
fdlist
,
g_socket_get_fd
(
socket
),
NULL
);
g_dbus_method_invocation_return_value_with_unix_fd_list
(
invocation
,
g_variant_new
(
"(oh)"
,
object_path
,
fdidx
),
fdlist
);
g_object_unref
(
fdlist
);
return
TRUE
;
/* ERRORS */
no_port:
{
g_debug
(
"daemon %p: could not find port %s, %s"
,
daemon
,
arg_node
,
error
->
message
);
pinos_properties_free
(
props
);
g_bytes_unref
(
formats
);
goto
exit_error
;
}
no_channel:
{
g_debug
(
"daemon %p: could not create channel %s"
,
daemon
,
error
->
message
);
goto
exit_error
;
}
no_socket:
{
g_debug
(
"daemon %p: could not create channel %s"
,
daemon
,
error
->
message
);
goto
exit_error
;
}
exit_error:
{
g_dbus_method_invocation_return_gerror
(
invocation
,
error
);
g_clear_error
(
&
error
);
return
TRUE
;
}
}
static
void
handle_remove_node
(
PinosNode
*
node
,
gpointer
user_data
)
...
...
@@ -356,8 +244,13 @@ handle_create_client_node (PinosDaemon1 *interface,
pprops
,
formats
,
&
error
);
if
(
target
==
NULL
)
if
(
target
==
NULL
)
{
g_warning
(
"daemon %p: can't find port target: %s"
,
daemon
,
error
->
message
);
g_clear_error
(
&
error
);
continue
;
}
pinos_client_add_object
(
client
,
G_OBJECT
(
target
));
link
=
pinos_link_new
(
daemon
,
port
,
target
,
NULL
);
pinos_client_add_object
(
client
,
G_OBJECT
(
link
));
...
...
@@ -653,7 +546,7 @@ pinos_daemon_find_port (PinosDaemon *daemon,
have_name
=
name
?
strlen
(
name
)
>
0
:
FALSE
;
g_debug
(
"name %s, format %s"
,
name
,
(
gchar
*
)
g_bytes_get_data
(
format_filter
,
NULL
));
g_debug
(
"name %s, format %s
, %d
"
,
name
,
(
gchar
*
)
g_bytes_get_data
(
format_filter
,
NULL
)
,
have_name
);
for
(
nodes
=
priv
->
nodes
;
nodes
;
nodes
=
g_list_next
(
nodes
))
{
PinosNode
*
n
=
nodes
->
data
;
...
...
@@ -662,7 +555,10 @@ pinos_daemon_find_port (PinosDaemon *daemon,
g_debug
(
"node path %s"
,
pinos_node_get_object_path
(
n
));
/* we found the node */
if
(
have_name
&&
g_str_has_suffix
(
pinos_node_get_object_path
(
n
),
name
))
{
if
(
have_name
)
{
if
(
!
g_str_has_suffix
(
pinos_node_get_object_path
(
n
),
name
))
continue
;
g_debug
(
"name
\"
%s
\"
matches node %p"
,
name
,
n
);
node_found
=
TRUE
;
}
...
...
@@ -842,7 +738,6 @@ pinos_daemon_init (PinosDaemon * daemon)
priv
->
iface
=
pinos_daemon1_skeleton_new
();
g_signal_connect
(
priv
->
iface
,
"handle-create-node"
,
(
GCallback
)
handle_create_node
,
daemon
);
g_signal_connect
(
priv
->
iface
,
"handle-create-client-node"
,
(
GCallback
)
handle_create_client_node
,
daemon
);
g_signal_connect
(
priv
->
iface
,
"handle-create-channel"
,
(
GCallback
)
handle_create_channel
,
daemon
);
g_signal_connect
(
priv
->
iface
,
"handle-link-nodes"
,
(
GCallback
)
handle_link_nodes
,
daemon
);
priv
->
server_manager
=
g_dbus_object_manager_server_new
(
PINOS_DBUS_OBJECT_PREFIX
);
...
...
pinos/server/link.c
View file @
d374f50d
...
...
@@ -39,6 +39,8 @@ struct _PinosLinkPrivate
gchar
*
object_path
;
gulong
input_id
,
output_id
;
gboolean
active
;
PinosPort
*
output
;
PinosPort
*
input
;
GBytes
*
possible_formats
;
...
...
@@ -203,10 +205,14 @@ on_activate (PinosPort *port, gpointer user_data)
PinosLink
*
link
=
user_data
;
PinosLinkPrivate
*
priv
=
link
->
priv
;
if
(
priv
->
active
)
return
TRUE
;
if
(
priv
->
input
==
port
)
pinos_port_activate
(
priv
->
output
);
else
pinos_port_activate
(
priv
->
input
);
priv
->
active
=
TRUE
;
return
TRUE
;
}
...
...
@@ -217,10 +223,14 @@ on_deactivate (PinosPort *port, gpointer user_data)
PinosLink
*
link
=
user_data
;
PinosLinkPrivate
*
priv
=
link
->
priv
;
if
(
!
priv
->
active
)
return
TRUE
;
if
(
priv
->
input
==
port
)
pinos_port_deactivate
(
priv
->
output
);
else
pinos_port_deactivate
(
priv
->
input
);
priv
->
active
=
FALSE
;
return
TRUE
;
}
...
...
@@ -232,18 +242,20 @@ pinos_link_constructed (GObject * object)
PinosLinkPrivate
*
priv
=
link
->
priv
;
GBytes
*
formats
;
pinos_port_add_send_buffer_cb
(
priv
->
output
,
priv
->
output_id
=
pinos_port_add_send_buffer_cb
(
priv
->
output
,
on_output_send
,
link
,
NULL
);
pinos_port_add_send_buffer_cb
(
priv
->
input
,
priv
->
input_id
=
pinos_port_add_send_buffer_cb
(
priv
->
input
,
on_input_send
,
link
,
NULL
);
g_object_get
(
priv
->
input
,
"possible-formats"
,
&
formats
,
NULL
);
g_object_set
(
priv
->
output
,
"possible-formats"
,
formats
,
NULL
);
g_object_get
(
priv
->
output
,
"format"
,
&
formats
,
NULL
);
g_object_set
(
priv
->
input
,
"format"
,
formats
,
NULL
);
g_signal_connect
(
priv
->
input
,
"activate"
,
(
GCallback
)
on_activate
,
link
);
g_signal_connect
(
priv
->
input
,
"deactivate"
,
(
GCallback
)
on_deactivate
,
link
);
...
...
@@ -260,8 +272,19 @@ static void
pinos_link_dispose
(
GObject
*
object
)
{
PinosLink
*
link
=
PINOS_LINK
(
object
);
PinosLinkPrivate
*
priv
=
link
->
priv
;
g_debug
(
"link %p: dispose"
,
link
);
pinos_port_remove_send_buffer_cb
(
priv
->
input
,
priv
->
input_id
);
pinos_port_remove_send_buffer_cb
(
priv
->
output
,
priv
->
output_id
);
if
(
priv
->
active
)
{
priv
->
active
=
FALSE
;
pinos_port_deactivate
(
priv
->
input
);
pinos_port_deactivate
(
priv
->
output
);
}
g_clear_object
(
&
priv
->
input
);
g_clear_object
(
&
priv
->
output
);
link_unregister_object
(
link
);
G_OBJECT_CLASS
(
pinos_link_parent_class
)
->
dispose
(
object
);
...
...
pinos/server/port.c
View file @
d374f50d
...
...
@@ -625,66 +625,6 @@ parse_control_buffer (PinosPort *port, PinosBuffer *buffer)
}
}
/**
* pinos_port_create_channel:
* @port: a #PinosPort
* @client_path: the client path
* @format_filter: a #GBytes
* @props: #PinosProperties
* @prefix: a prefix
* @error: a #GError or %NULL
*
* Create a new #PinosChannel for @port.
*
* Returns: a new #PinosChannel or %NULL, in wich case @error will contain
* more information about the error.
*/
PinosChannel
*
pinos_port_create_channel
(
PinosPort
*
port
,
const
gchar
*
client_path
,
GBytes
*
format_filter
,
PinosProperties
*
props
,
GError
**
error
)
{
PinosPortPrivate
*
priv
;
PinosChannel
*
channel
;
GBytes
*
possible_formats
;
g_return_val_if_fail
(
PINOS_IS_PORT
(
port
),
NULL
);
priv
=
port
->
priv
;
possible_formats
=
pinos_port_filter_formats
(
port
,
format_filter
,
error
);
if
(
possible_formats
==
NULL
)
return
NULL
;
g_debug
(
"port %p: make channel with formats %s"
,
port
,
(
gchar
*
)
g_bytes_get_data
(
possible_formats
,
NULL
));
channel
=
g_object_new
(
PINOS_TYPE_CHANNEL
,
"daemon"
,
priv
->
daemon
,
"port"
,
port
,
"client-path"
,
client_path
,
"direction"
,
priv
->
direction
,
"possible-formats"
,
possible_formats
,
"properties"
,
props
,
NULL
);
g_bytes_unref
(
possible_formats
);
if
(
channel
==
NULL
)
goto
no_channel
;
return
channel
;
/* ERRORS */
no_channel:
{
if
(
error
)
*
error
=
g_error_new
(
G_IO_ERROR
,
G_IO_ERROR_FAILED
,
"Could not create channel"
);
return
NULL
;
}
}
void
pinos_port_activate
(
PinosPort
*
port
)
{
...
...
pinos/server/port.h
View file @
d374f50d
...
...
@@ -30,7 +30,6 @@ typedef struct _PinosPortPrivate PinosPortPrivate;
#include <pinos/client/introspect.h>
#include <pinos/client/buffer.h>
#include <pinos/server/channel.h>
#include <pinos/server/daemon.h>
#define PINOS_TYPE_PORT (pinos_port_get_type ())
...
...
@@ -95,12 +94,6 @@ GBytes * pinos_port_get_format (PinosPort *port);
void
pinos_port_activate
(
PinosPort
*
port
);
void
pinos_port_deactivate
(
PinosPort
*
port
);
PinosChannel
*
pinos_port_create_channel
(
PinosPort
*
port
,
const
gchar
*
client_path
,
GBytes
*
format_filter
,
PinosProperties
*
props
,
GError
**
error
);
gboolean
pinos_port_send_buffer
(
PinosPort
*
port
,
PinosBuffer
*
buffer
,
GError
**
error
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment