pipewire/pinos/client/pinos.c
Wim Taymans 27bba6f587 Make native protocol
Remove DBus and work towards something like wayland.
Remove more glib stuff from the client code
2016-11-24 17:00:42 +01:00

133 lines
3.4 KiB
C

/* 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.
*/
#include <unistd.h>
#include <stdio.h>
#include "pinos/client/pinos.h"
/**
* pinos_init:
* @argc: pointer to argc
* @argv: pointer to argv
*
* initialize the pinos system, parse and modify any parameters given
* by @argc and @argv.
*/
void
pinos_init (int *argc, char **argv[])
{
}
static char *
pinos_get_application_name (void)
{
return NULL;
}
static char *
pinos_get_prgname (void)
{
return NULL;
}
static char *
pinos_get_user_name (void)
{
return NULL;
}
static char *
pinos_get_host_name (void)
{
return NULL;
}
/**
* pinos_client_name:
*
* Make a new pinos client name that can be used to construct a context.
*/
char *
pinos_client_name (void)
{
char *c;
if ((c = pinos_get_application_name ()))
return strdup (c);
else if ((c = pinos_get_prgname ()))
return strdup (c);
else {
asprintf (&c, "pinos-pid-%zd", (size_t) getpid ());
return c;
}
}
/**
* pinos_fill_context_properties:
* @properties: a #PinosProperties
*
* Fill @properties with a set of default context properties.
*/
void
pinos_fill_context_properties (PinosProperties *properties)
{
if (!pinos_properties_get (properties, "application.name"))
pinos_properties_set (properties, "application.name", pinos_get_application_name ());
if (!pinos_properties_get (properties, "application.prgname"))
pinos_properties_set (properties, "application.prgname", pinos_get_prgname ());
if (!pinos_properties_get (properties, "application.language")) {
pinos_properties_set (properties, "application.language", getenv ("LANG"));
}
if (!pinos_properties_get (properties, "application.process.id")) {
pinos_properties_setf (properties, "application.process.id", "%zd", (size_t) getpid ());
}
if (!pinos_properties_get (properties, "application.process.user"))
pinos_properties_set (properties, "application.process.user", pinos_get_user_name ());
if (!pinos_properties_get (properties, "application.process.host"))
pinos_properties_set (properties, "application.process.host", pinos_get_host_name ());
if (!pinos_properties_get (properties, "application.process.session_id")) {
pinos_properties_set (properties, "application.process.session_id", getenv ("XDG_SESSION_ID"));
}
}
/**
* pinos_fill_stream_properties
* @properties: a #PinosProperties
*
* Fill @properties with a set of default stream properties.
*/
void
pinos_fill_stream_properties (PinosProperties *properties)
{
}
PinosDirection
pinos_direction_reverse (PinosDirection direction)
{
if (direction == PINOS_DIRECTION_INPUT)
return PINOS_DIRECTION_OUTPUT;
else if (direction == PINOS_DIRECTION_OUTPUT)
return PINOS_DIRECTION_INPUT;
return direction;
}