libngf: libngf/client.h File Reference

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. More...
typedef void(* | NgfCallback) (NgfClient *client, uint32_t id, NgfEventState state, void *userdata)
| Event state callback for receiving event completion status (failed, completed) More...

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

## 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

typedef enum _NgfEventState NgfEventState

## ◆ NgfTransport

typedef enum _NgfTransport NgfTransport

## Enumeration Type Documentation

## ◆ _NgfEventState

enum _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

enum _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

  transport | NgfTransport. 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);
NgfClient *client = ngf_client_create (NGF_TRANSPORT_DBUS, conn);
if (!client) {
fprintf (stderr, "Failed to create client!");
}
ngf_client_create
NgfClient * ngf_client_create(NgfTransport transport,...)
Create a client instance to play events.
NgfClient
struct _NgfClient NgfClient
Internal client structure.
Definition: client.h:57
NGF_TRANSPORT_DBUS
@ 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

  client | NgfClient instance

## ◆ ngf_client_pause_event()

void ngf_client_pause_event | ( | NgfClient * | client,
|  | uint32_t | id
| ) |  |

Pause active event.

Parameters

  client | NgfClient instance
  id | Event id.

## ◆ ngf_client_play_event()

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

Play event with optional properties.

Parameters

  client | NgfClient instance
  event | Event identifier
  proplist | NgfProplist or NULL.

Returns
  Id of the event

NgfProplist *p = NULL;
uint32_t id = 0;
p = ngf_proplist_new ();
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!");
}
ngf_proplist_free (p);
ngf_client_play_event
uint32_t ngf_client_play_event(NgfClient *client, const char *event, NgfProplist *proplist)
Play event with optional properties.
NgfProplist
struct _NgfProplist NgfProplist
Internal property list instance.
Definition: proplist.h:39
ngf_proplist_new
NgfProplist * ngf_proplist_new(void)
Create a new property list instance.
ngf_proplist_sets
int ngf_proplist_sets(NgfProplist *proplist, const char *key, const char *value)
Set a string value to property list.
ngf_proplist_free
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

  client | NgfClient instance
  id | Event 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

  client | NgfClient instance
  callback | Callback function,

See also
  NgfCallback

Parameters

  userdata | Userdata

## ◆ ngf_client_stop_event()

void ngf_client_stop_event | ( | NgfClient * | client,
|  | uint32_t | id
| ) |  |

Stop an active event.

Parameters

  client | NgfClient instance
  id | Event id. If no such event, nothing is done.