libngf
Typedefs | Enumerations | Functions
client.h File Reference
#include <stdint.h>
#include <libngf/proplist.h>

Go to the source code of this file.

Typedefs

typedef enum _NgfTransport NgfTransport
 
typedef enum _NgfEventState NgfEventState
 
typedef struct _NgfClient NgfClient
 Internal client structure.
 
typedef void(* NgfCallback) (NgfClient *client, uint32_t id, NgfEventState state, void *userdata)
 Event state callback for receiving event completion status (failed, completed)
 

Enumerations

enum  _NgfTransport { NGF_TRANSPORT_DBUS , NGF_TRANSPORT_INTERNAL }
 
enum  _NgfEventState { NGF_EVENT_FAILED = 0 , NGF_EVENT_COMPLETED = 1 , NGF_EVENT_PLAYING = 2 , NGF_EVENT_PAUSED = 3 }
 

Functions

NgfClientngf_client_create (NgfTransport transport,...)
 Create a client instance to play events.
 
void ngf_client_destroy (NgfClient *client)
 Free the clients resources.
 
void ngf_client_set_callback (NgfClient *client, NgfCallback callback, void *userdata)
 Set a callback to receive event completion updates.
 
uint32_t ngf_client_play_event (NgfClient *client, const char *event, NgfProplist *proplist)
 Play event with optional properties.
 
void ngf_client_stop_event (NgfClient *client, uint32_t id)
 Stop an active event.
 
void ngf_client_pause_event (NgfClient *client, uint32_t id)
 Pause active event.
 
void ngf_client_resume_event (NgfClient *client, uint32_t id)
 Resume paused event.
 

Typedef Documentation

◆ NgfCallback

typedef void(* NgfCallback) (NgfClient *client, uint32_t id, NgfEventState state, void *userdata)

Event state callback for receiving event completion status (failed, completed)

◆ NgfClient

typedef struct _NgfClient NgfClient

Internal client structure.

◆ NgfEventState

◆ NgfTransport

Enumeration Type Documentation

◆ _NgfEventState

Enumerator
NGF_EVENT_FAILED 

Event fails when we are unable to get resources for it or we just can't play it.

NGF_EVENT_COMPLETED 

Event is completed when the event has been played or cancelled by higher priority event.

NGF_EVENT_PLAYING 

Event is in playing state when playback is successfully started or continued.

NGF_EVENT_PAUSED 

Event is in paused state when pause is called.

◆ _NgfTransport

Enumerator
NGF_TRANSPORT_DBUS 

DBus transport is the only supported transport currently.

NGF_TRANSPORT_INTERNAL 

Reserved for internal use.

Function Documentation

◆ ngf_client_create()

NgfClient * ngf_client_create ( NgfTransport transport,
... )

Create a client instance to play events.

Parameters
transportNgfTransport. Currently only NGF_TRANSPORT_DBUS supported.
...Variable arguments passed to transports.
Returns
NgfClient instance or NULL on error.
DBusConnection *conn = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
dbus_connection_setup_with_g_main (conn, NULL);
if (!client) {
fprintf (stderr, "Failed to create client!");
}
NgfClient * ngf_client_create(NgfTransport transport,...)
Create a client instance to play events.
struct _NgfClient NgfClient
Internal client structure.
Definition client.h:57
@ NGF_TRANSPORT_DBUS
DBus transport is the only supported transport currently.
Definition client.h:34

◆ ngf_client_destroy()

void ngf_client_destroy ( NgfClient * client)

Free the clients resources.

Parameters
clientNgfClient instance

◆ ngf_client_pause_event()

void ngf_client_pause_event ( NgfClient * client,
uint32_t id )

Pause active event.

Parameters
clientNgfClient instance
idEvent id.

◆ ngf_client_play_event()

uint32_t ngf_client_play_event ( NgfClient * client,
const char * event,
NgfProplist * proplist )

Play event with optional properties.

Parameters
clientNgfClient instance
eventEvent identifier
proplistNgfProplist or NULL.
Returns
Id of the event
NgfProplist *p = NULL;
uint32_t id = 0;
ngf_proplist_sets (p, "audio", "/usr/share/sounds/beep.wav");
id = ngf_client_play_event (client, "my.event", p);
if (id == 0) {
fprintf (stderr, "Failed to play event!");
}
uint32_t ngf_client_play_event(NgfClient *client, const char *event, NgfProplist *proplist)
Play event with optional properties.
struct _NgfProplist NgfProplist
Internal property list instance.
Definition proplist.h:39
NgfProplist * ngf_proplist_new(void)
Create a new property list instance.
int ngf_proplist_sets(NgfProplist *proplist, const char *key, const char *value)
Set a string value to property list.
void ngf_proplist_free(NgfProplist *proplist)
Free property list.

◆ ngf_client_resume_event()

void ngf_client_resume_event ( NgfClient * client,
uint32_t id )

Resume paused event.

Parameters
clientNgfClient instance
idEvent id.

◆ ngf_client_set_callback()

void ngf_client_set_callback ( NgfClient * client,
NgfCallback callback,
void * userdata )

Set a callback to receive event completion updates.

Parameters
clientNgfClient instance
callbackCallback function,
See also
NgfCallback
Parameters
userdataUserdata

◆ ngf_client_stop_event()

void ngf_client_stop_event ( NgfClient * client,
uint32_t id )

Stop an active event.

Parameters
clientNgfClient instance
idEvent id. If no such event, nothing is done.