RygelDataSource

RygelDataSource — Interface for all data streams provided by a RygelMediaEngine.

Object Hierarchy

    GInterface
    ╰── RygelDataSource

Prerequisites

RygelDataSource requires GObject.

Description

When Rygel receives a HTTP request to stream a given file, it creates a RygelDataSource object for this new file and instructs the RygelDataSource to begin streaming. The RygelDataSource object will duly pass this request on to the underlying media framework, which will in turn pass streamed bytes back to the RygelDataSource object. The RygelDataSource passes these bytes to Rygel which adds them to the response it sends to the original HTTP request received from the client.

The data source is responsible for providing response header information describing the content being produced and a streamable byte-stream via its data_available signal. End-of-stream is signalled by the done signal, while errors are signalled by the error signal.

Implementations should fulfil at least these requirements:

  1. It should support at least the file:// URI scheme.

  2. It should be able to stream any kind of binary data, regardless of the format.

RygelDataSource instances are provided by rygel_media_engine_create_data_source() which will return a derived RygelDataSource that uses a specific IO backend and/or multimedia backend to stream the multimedia data at the URI.

The derived RygelDataSource may provide additional API for use by the derived media engine. For instance, rygel_media_engine_get_transcoders() may return derived RygelTranscoder instances, and these may use that additional API in their create_source() implementations, for instance to access resources or data structures of the specific multimedia backend.

Functions

rygel_data_source_preroll ()

GeeList *
rygel_data_source_preroll (RygelDataSource *self,
                           RygelHTTPSeekRequest *seek,
                           RygelPlaySpeedRequest *playspeed,
                           GError **error);

Preroll the data with the given seek and playspeed.

GError will be returned in error

if anything goes wrong while prerolling the stream. Throws DataSourceError.SEEK_FAILED if a seek method is not supported or the range is not fulfillable. Throws PLAYSPEED_FAILED if the rate is not supported or fulfillable.

Parameters

self

the RygelDataSource instance

 

seek

 .

optional seek/range specifier

.

[in][allow-none]

playspeed

 .

optional playback rate specifier. This will only be provided when a scaled rate is requested (the speed will not be 0.0 or 1.0)

.

[in][allow-none]

error

location to store the error occuring, or NULL to ignore

 

Returns

List of HTTPResponseElements appropriate for the content request and optional seek/playspeed (e.g. Content-Range, TimeSeekRange.dlna.org, etc) or null/empty list if none are appropriate. Note: the list will be processed in-order by the caller.


rygel_data_source_start ()

void
rygel_data_source_start (RygelDataSource *self,
                         GError **error);

Start producing the data.

GError will be returned in error

if anything goes wrong while starting the stream.

Parameters

self

the RygelDataSource instance

 

error

location to store the error occuring, or NULL to ignore

 

rygel_data_source_freeze ()

void
rygel_data_source_freeze (RygelDataSource *self);

Temporarily stop data generation.

May be called multiple times. If the source is already frozen, the following calles to freeze are ignored. After callging freeze(), so data_available() signal should be emitted.

Parameters

self

the RygelDataSource instance

 

rygel_data_source_thaw ()

void
rygel_data_source_thaw (RygelDataSource *self);

Resume data generation from a previous freeze call.

May be called multiple times, will be ignored if the source is not frozen.

Parameters

self

the RygelDataSource instance

 

rygel_data_source_stop ()

void
rygel_data_source_stop (RygelDataSource *self);

Stop producing data. After calling stop(), calling start() should produce data from the beginning and not resume streaming.

Parameters

self

the RygelDataSource instance

 

Types and Values

enum RygelDataSourceError

Members

RYGEL_DATA_SOURCE_ERROR_GENERAL

   

RYGEL_DATA_SOURCE_ERROR_SEEK_FAILED

   

RYGEL_DATA_SOURCE_ERROR_PLAYSPEED_FAILED

   

RygelDataSource

typedef struct _RygelDataSource RygelDataSource;

Interface for all data streams provided by a RygelMediaEngine.

When Rygel receives a HTTP request to stream a given file, it creates a RygelDataSource object for this new file and instructs the RygelDataSource to begin streaming. The RygelDataSource object will duly pass this request on to the underlying media framework, which will in turn pass streamed bytes back to the RygelDataSource object. The RygelDataSource passes these bytes to Rygel which adds them to the response it sends to the original HTTP request received from the client.

The data source is responsible for providing response header information describing the content being produced and a streamable byte-stream via its data_available signal. End-of-stream is signalled by the done signal, while errors are signalled by the error signal.

Implementations should fulfil at least these requirements:

  1. It should support at least the file:// URI scheme.

  2. It should be able to stream any kind of binary data, regardless of the format.

RygelDataSource instances are provided by rygel_media_engine_create_data_source() which will return a derived RygelDataSource that uses a specific IO backend and/or multimedia backend to stream the multimedia data at the URI.

The derived RygelDataSource may provide additional API for use by the derived media engine. For instance, rygel_media_engine_get_transcoders() may return derived RygelTranscoder instances, and these may use that additional API in their create_source() implementations, for instance to access resources or data structures of the specific multimedia backend.


struct RygelDataSourceIface

struct RygelDataSourceIface {
	GTypeInterface parent_iface;
	GeeList* (*preroll) (RygelDataSource* self, RygelHTTPSeekRequest* seek, RygelPlaySpeedRequest* playspeed, GError** error);
	void (*start) (RygelDataSource* self, GError** error);
	void (*freeze) (RygelDataSource* self);
	void (*thaw) (RygelDataSource* self);
	void (*stop) (RygelDataSource* self);
};

Interface for creating RygelDataSource implementations.

Members

GTypeInterface parent_iface;

the parent interface structure

 

preroll ()

virtual method called by rygel_data_source_preroll()

 

start ()

virtual method called by rygel_data_source_start()

 

freeze ()

virtual method called by rygel_data_source_freeze()

 

thaw ()

virtual method called by rygel_data_source_thaw()

 

stop ()

virtual method called by rygel_data_source_stop()

 

Signal Details

The “data-available” signal

void
user_function (RygelDataSource *data_source,
               gpointer         data_length1,
               gint             data,
               gpointer         user_data)

Emitted when the source has produced some data.

This signal has to be emitted in the main thread.

Parameters

data_source

the RygelDataSource instance that received the signal

 

data_length1

length of the data array

 

data

 

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “done” signal

void
user_function (RygelDataSource *data_source,
               gpointer         user_data)

Emitted when the source does not have data anymore.

This signal has to be emitted in the main thread.

Parameters

data_source

the RygelDataSource instance that received the signal

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “error” signal

void
user_function (RygelDataSource *data_source,
               gpointer         error,
               gpointer         user_data)

Emitted when the source encounters a problem during data generation.

This signal has to be emitted in the main thread.

Parameters

data_source

the RygelDataSource instance that received the signal

 

error

 

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last