GstSyncServer

GstSyncServer — Provides a server object to publish information that clients on a network can use to play a stream in a synchronised manner.

Functions

Properties

gchar * control-address Read / Write
gint control-port Read / Write
GObject * control-server Read / Write
guint64 latency Read / Write
GVariant * playlist Read / Write
guint64 stream-start-delay Read / Write

Signals

Types and Values

Object Hierarchy

    GObject
    ╰── GstSyncServer

Description

The GstSyncServer object provides API to start a server on one device on a network that other devices (using GstSyncClient) can communicate with to play a stream such that all devices are playing the same stream at the same time.

It also provides API to control these clients and perform tasks such as switching the currently playing stream, pausing/unpausing, etc.

GstSyncServer itself does not implement the network transport for controlling the client, but defers that to an object that implements the GstSyncControlServer interface. A default TCP-based implementation is provided with this library, however.

The stream(s) to play are configured using the “playlist” property, which takes a GVariant that can be constructed using gst_sync_server_playlist_new() and manipulated by related functions.

Functions

gst_sync_server_new ()

GstSyncServer *
gst_sync_server_new (const gchar *control_addr,
                     gint control_port);

Creates a new GstSyncServer object that will listen on the given network address/port pair once started.

Parameters

control_addr

The network address that the server should listen on

 

control_port

The network port that the server should listen on

 

Returns

A new GstSyncServer object.

[transfer full]


gst_sync_server_start ()

gboolean
gst_sync_server_start (GstSyncServer *server,
                       GError **error);

Starts the GstSyncServer so that clients can connect and start synchronised playback.

Parameters

server

The GstSyncServer object

 

error

If non-NULL, will be set to the appropriate GError if starting the server fails.

 

Returns

TRUE on success, and FALSE if the server could not be started.


gst_sync_server_stop ()

void
gst_sync_server_stop (GstSyncServer *server);

Disconnects all existing clients and stops listening for new clients.

Parameters

server

The GstSyncServer object

 

gst_sync_server_set_stopped ()

void
gst_sync_server_set_stopped (GstSyncServer *server,
                             gboolean stopped);

Stops or restarts playback of the current stream on all connected clients.

Parameters

server

The GstSyncServer object

 

stopped

Whether the stream should be stopped (or restarted)

 

gst_sync_server_set_paused ()

void
gst_sync_server_set_paused (GstSyncServer *server,
                            gboolean paused);

Pauses or unpauses playback of the current stream on all connected clients.

Parameters

server

The GstSyncServer object

 

paused

Whether the stream should be paused or unpaused

 

gst_sync_server_playlist_new ()

GVariant *
gst_sync_server_playlist_new (gchar **uris,
                              guint64 *durations,
                              guint64 n_tracks,
                              guint64 current_track);

Creates a playlist object from the given uris, durations and current track.

Parameters

uris

A list of string URIs representing the playlist.

[array length=n_tracks]

durations

A list of durations corresponding to each URI (set to GST_CLOCK_TIME_NONE if unknown).

[array length=n_tracks]

n_tracks

The number of tracks in uris and durations .

 

current_track

The current track to play

 

Returns

The playlist as a GVariant


gst_sync_server_playlist_set_tracks ()

GVariant *
gst_sync_server_playlist_set_tracks (GVariant *playlist,
                                     gchar **uris,
                                     guint64 *durations,
                                     guint64 n_tracks);

Changes the track list in the given playlist and returns a new playlist.

Parameters

playlist

The playlist.

[transfer full]

uris

A list of string URIs representing the playlist.

[array length=n_tracks]

durations

A list of durations corresponding to each URI (set to GST_CLOCK_TIME_NONE if unknown).

[array length=n_tracks]

n_tracks

The number of tracks in uris and durations .

 

Returns

The new playlist as a GVariant.

[transfer full]


gst_sync_server_playlist_set_current_track ()

GVariant *
gst_sync_server_playlist_set_current_track
                               (GVariant *playlist,
                                guint64 current_track);

Changes the currently playing track in the given playlist and returns a new playlist.

Parameters

playlist

The playlist.

[transfer full]

current_track

The current track to play

 

Returns

The new playlist as a GVariant.

[transfer full]


gst_sync_server_playlist_get_tracks ()

void
gst_sync_server_playlist_get_tracks (GVariant *playlist,
                                     gchar ***uris,
                                     guint64 **durations,
                                     guint64 *n_tracks);

Returns the set of tracks and their corresponding durations, if available. Use gst_sync_server_playlist_free_tracks() to free uris and durations .

Parameters

playlist

The playlist

 

uris

A list of string URIs representing the playlist.

[out callee-allocates][array length=n_tracks]

durations

A list of durations corresponding to each URI in uris (set to GST_CLOCK_TIME_NONE if duration for a stream is unknown).

[out callee-allocates][array length=n_tracks]

n_tracks

The number of tracks returned in uris and durations .

[out caller-allocates]

gst_sync_server_playlist_free_tracks ()

void
gst_sync_server_playlist_free_tracks (gchar **uris,
                                      guint64 *durations,
                                      guint64 n_tracks);

Frees the URIs and durations (allocated by gst_sync_server_playlist_get_tracks().

Parameters

uris

A list of string URIs representing the playlist.

[array length=n_tracks]

durations

A list of durations corresponding to each URI.

[array length=n_tracks]

n_tracks

The number of tracks in uris and durations .

 

gst_sync_server_playlist_get_current_track ()

guint64
gst_sync_server_playlist_get_current_track
                               (GVariant *playlist);

Parameters

playlist

The playlist

 

Returns

The currently streaming track

Types and Values

GstSyncServer

typedef struct _GstSyncServer GstSyncServer;

Property Details

The “control-address” property

  “control-address”          gchar *

The network address for the control server to listen on.

Flags: Read / Write

Default value: NULL


The “control-port” property

  “control-port”             gint

The network port for the control server to listen on.

Flags: Read / Write

Allowed values: [0,65535]

Default value: 0


The “control-server” property

  “control-server”           GObject *

The implementation of the control protocol that should be used to communicate with clients. This object must implement the GstSyncControlServer interface. If set to NULL, a built-in TCP implementation is used.

Flags: Read / Write


The “latency” property

  “latency”                  guint64

The pipeline latency that clients should use. This should be large enough to account for any buffering that is expected (network related for HTTP/RTP/... streams, and worst-case audio device latency).

Flags: Read / Write

Default value: 300000000


The “playlist” property

  “playlist”                 GVariant *

A GVariant tuple of the current track index and an array of playlist entries. Each playlist entry, in turn, is a tuple of a URI and its duration. Unknown durations can be set to 0, which might cause a small (network-dependent) delay in swiching tracks.

See gst_sync_server_playlist_new() and related functions for easy manipulation of these playlists.

Flags: Read / Write

Allowed values: GVariant<(ta(st))>

Default value: NULL


The “stream-start-delay” property

  “stream-start-delay”       guint64

The amount of time to wait between streams before starting. This allows for devices which take different amounts of time to load the data (either due to network delays or differing storage speeds) to start smoothly at the same time when switching streams.

Flags: Read / Write

Default value: 500000000

Signal Details

The “end-of-playlist” signal

void
user_function (GstSyncServer *arg0,
               gpointer       user_data)

Emitted when the currently all the songs in the playlist have finished playing.

Parameters

user_data

user data set when the signal handler was connected.

 

Flags: Run First


The “end-of-stream” signal

void
user_function (GstSyncServer *arg0,
               gpointer       user_data)

Emitted when the currently playing URI reaches the end of the stream. This is called for each stream in the current playlist.

Parameters

user_data

user data set when the signal handler was connected.

 

Flags: Run First