]>
code.delx.au - pulseaudio/blob - polyp/module-protocol-stub.c
6a0f88a28b8e8d5274670d4d13bb11142f7ab714
4 This file is part of polypaudio.
6 polypaudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
11 polypaudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
30 #include <arpa/inet.h>
32 #include <netinet/in.h>
35 #include "socket-server.h"
36 #include "socket-util.h"
40 #include "native-common.h"
43 #ifdef USE_TCP_SOCKETS
44 #define SOCKET_DESCRIPTION "(TCP sockets)"
45 #define SOCKET_USAGE "port=<TCP port number> loopback=<listen on loopback device only?>"
46 #elif defined(USE_TCP6_SOCKETS)
47 #define SOCKET_DESCRIPTION "(TCP/IPv6 sockets)"
48 #define SOCKET_USAGE "port=<TCP port number> loopback=<listen on loopback device only?>"
50 #define SOCKET_DESCRIPTION "(UNIX sockets)"
51 #define SOCKET_USAGE "socket=<path to UNIX socket>"
54 #if defined(USE_PROTOCOL_SIMPLE)
55 #include "protocol-simple.h"
56 #define protocol_new pa_protocol_simple_new
57 #define protocol_free pa_protocol_simple_free
58 #define TCPWRAP_SERVICE "polypaudio-simple"
59 #define IPV4_PORT 4711
60 #define UNIX_SOCKET "simple"
61 #define MODULE_ARGUMENTS "rate" , "format" , "channels" , "sink" , "source" , "playback" , "record" ,
62 #if defined(USE_TCP_SOCKETS)
63 #include "module-simple-protocol-tcp-symdef.h"
64 #elif defined(USE_TCP6_SOCKETS)
65 #include "module-simple-protocol-tcp6-symdef.h"
67 #include "module-simple-protocol-unix-symdef.h"
69 PA_MODULE_DESCRIPTION ( "Simple protocol " SOCKET_DESCRIPTION
)
70 PA_MODULE_USAGE ( "rate=<sample rate> format=<sample format> channels=<number of channels> sink=<sink to connect to> source=<source to connect to> playback=<enable playback?> record=<enable record?> " SOCKET_USAGE
)
71 #elif defined(USE_PROTOCOL_CLI)
72 #include "protocol-cli.h"
73 #define protocol_new pa_protocol_cli_new
74 #define protocol_free pa_protocol_cli_free
75 #define TCPWRAP_SERVICE "polypaudio-cli"
76 #define IPV4_PORT 4712
77 #define UNIX_SOCKET "cli"
78 #define MODULE_ARGUMENTS
79 #ifdef USE_TCP_SOCKETS
80 #include "module-cli-protocol-tcp-symdef.h"
81 #elif defined(USE_TCP6_SOCKETS)
82 #include "module-cli-protocol-tcp6-symdef.h"
84 #include "module-cli-protocol-unix-symdef.h"
86 PA_MODULE_DESCRIPTION ( "Command line interface protocol " SOCKET_DESCRIPTION
)
87 PA_MODULE_USAGE ( SOCKET_USAGE
)
88 #elif defined(USE_PROTOCOL_NATIVE)
89 #include "protocol-native.h"
90 #define protocol_new pa_protocol_native_new
91 #define protocol_free pa_protocol_native_free
92 #define TCPWRAP_SERVICE "polypaudio-native"
93 #define IPV4_PORT PA_NATIVE_DEFAULT_PORT
94 #define UNIX_SOCKET PA_NATIVE_DEFAULT_UNIX_SOCKET
95 #define MODULE_ARGUMENTS "public" , "cookie" ,
96 #ifdef USE_TCP_SOCKETS
97 #include "module-native-protocol-tcp-symdef.h"
98 #elif defined(USE_TCP6_SOCKETS)
99 #include "module-native-protocol-tcp6-symdef.h"
101 #include "module-native-protocol-unix-symdef.h"
103 PA_MODULE_DESCRIPTION ( "Native protocol " SOCKET_DESCRIPTION
)
104 PA_MODULE_USAGE ( "public=<don't check for cookies?> cookie=<path to cookie file> " SOCKET_USAGE
)
105 #elif defined(USE_PROTOCOL_ESOUND)
106 #include "protocol-esound.h"
108 #define protocol_new pa_protocol_esound_new
109 #define protocol_free pa_protocol_esound_free
110 #define TCPWRAP_SERVICE "esound"
111 #define IPV4_PORT ESD_DEFAULT_PORT
112 #define UNIX_SOCKET ESD_UNIX_SOCKET_NAME
113 #define MODULE_ARGUMENTS "sink" , "source" , "public" , "cookie" ,
114 #ifdef USE_TCP_SOCKETS
115 #include "module-esound-protocol-tcp-symdef.h"
116 #elif defined(USE_TCP6_SOCKETS)
117 #include "module-esound-protocol-tcp6-symdef.h"
119 #include "module-esound-protocol-unix-symdef.h"
121 PA_MODULE_DESCRIPTION ( "EsounD protocol " SOCKET_DESCRIPTION
)
122 PA_MODULE_USAGE ( "sink=<sink to connect to> source=<source to connect to> public=<don't check for cookies?> cookie=<path to cookie file> " SOCKET_USAGE
)
124 #error "Broken build system"
127 PA_MODULE_AUTHOR ( "Lennart Poettering" )
128 PA_MODULE_VERSION ( PACKAGE_VERSION
)
130 static const char * const valid_modargs
[] = {
132 #if defined(USE_TCP_SOCKETS) || defined(USE_TCP6_SOCKETS)
141 static struct pa_socket_server
* create_socket_server ( struct pa_core
* c
, struct pa_modargs
* ma
) {
142 struct pa_socket_server
* s
;
143 #if defined(USE_TCP_SOCKETS) || defined(USE_TCP6_SOCKETS)
145 uint32_t port
= IPV4_PORT
;
147 if ( pa_modargs_get_value_boolean ( ma
, "loopback" , & loopback
) < 0 ) {
148 pa_log ( __FILE__
": loopback= expects a numerical argument. \n " );
152 if ( pa_modargs_get_value_u32 ( ma
, "port" , & port
) < 0 || port
< 1 || port
> 0xFFFF ) {
153 pa_log ( __FILE__
": port= expects a numerical argument between 1 and 65535. \n " );
157 #ifdef USE_TCP6_SOCKETS
158 if (!( s
= pa_socket_server_new_ipv6 ( c
-> mainloop
, loopback
? ( uint8_t *) & in6addr_loopback
: ( uint8_t *) & in6addr_any
, port
)))
161 if (!( s
= pa_socket_server_new_ipv4 ( c
-> mainloop
, loopback
? INADDR_LOOPBACK
: INADDR_ANY
, port
, TCPWRAP_SERVICE
)))
170 v
= pa_modargs_get_value ( ma
, "socket" , UNIX_SOCKET
);
173 pa_runtime_path ( v
, tmp
, sizeof ( tmp
));
175 if ( pa_make_secure_parent_dir ( tmp
) < 0 ) {
176 pa_log ( __FILE__
": Failed to create secure socket directory. \n " );
180 if (( r
= pa_unix_socket_remove_stale ( tmp
)) < 0 ) {
181 pa_log ( __FILE__
": Failed to remove stale UNIX socket '%s': %s \n " , tmp
, strerror ( errno
));
186 pa_log ( __FILE__
": Removed stale UNIX socket '%s'." , tmp
);
188 if (!( s
= pa_socket_server_new_unix ( c
-> mainloop
, tmp
)))
195 int pa__init ( struct pa_core
* c
, struct pa_module
* m
) {
196 struct pa_socket_server
* s
;
197 struct pa_modargs
* ma
= NULL
;
201 if (!( ma
= pa_modargs_new ( m
-> argument
, valid_modargs
))) {
202 pa_log ( __FILE__
": Failed to parse module arguments \n " );
206 if (!( s
= create_socket_server ( c
, ma
)))
209 if (!( m
-> userdata
= protocol_new ( c
, s
, m
, ma
))) {
210 pa_socket_server_unref ( s
);
223 void pa__done ( struct pa_core
* c
, struct pa_module
* m
) {
226 protocol_free ( m
-> userdata
);