Utility functions

Utility functions — Miscellaneous useful functions

Synopsis

#include <gst/farsight/fs-utils.h>

                    FsRtpHeaderExtension;
FsRtpHeaderExtension * fs_rtp_header_extension_new      (guint id,
                                                         FsStreamDirection direction,
                                                         const gchar *uri);
FsRtpHeaderExtension * fs_rtp_header_extension_copy     (FsRtpHeaderExtension *extension);
void                fs_rtp_header_extension_destroy     (FsRtpHeaderExtension *extension);
gboolean            fs_rtp_header_extension_are_equal   (FsRtpHeaderExtension *extension1,
                                                         FsRtpHeaderExtension *extension2);
GList *             fs_rtp_header_extension_list_copy   (GList *extensions);
void                fs_rtp_header_extension_list_destroy
                                                        (GList *extensions);
GList *             fs_rtp_header_extension_list_from_keyfile
                                                        (const gchar *filename,
                                                         FsMediaType media_type,
                                                         GError **error);
#define             FS_RTP_HEADER_EXTENSION_FORMAT
#define             FS_RTP_HEADER_EXTENSION_ARGS        (hdrext)
void                fs_utils_set_bitrate                (GstElement *element,
                                                         glong bitrate);
GList *             fs_utils_get_default_codec_preferences
                                                        (GstElement *element);
GKeyFile *          fs_utils_get_default_element_properties
                                                        (GstElement *element);
GList *             fs_utils_get_default_rtp_header_extension_preferences
                                                        (GstElement *element,
                                                         FsMediaType media_type);

Description

Details

FsRtpHeaderExtension

typedef struct {
  guint id;
  FsStreamDirection direction;
  gchar *uri;
} FsRtpHeaderExtension;

Defines a RTP header extension with its negotiated identifier, direction and URI. They should only be created with fs_rtp_header_extension_new().

guint id;

The identifier of the RTP header extension

FsStreamDirection direction;

the direction in which this extension can be used

gchar *uri;

The URI that defines this extension

fs_rtp_header_extension_new ()

FsRtpHeaderExtension * fs_rtp_header_extension_new      (guint id,
                                                         FsStreamDirection direction,
                                                         const gchar *uri);

Creates a new FsRtpHeaderExtension

id :

The identifier of the RTP header extension

direction :

the direction in which this extension can be used

uri :

The URI that defines this extension

Returns :

a new FsRtpHeaderExtension

fs_rtp_header_extension_copy ()

FsRtpHeaderExtension * fs_rtp_header_extension_copy     (FsRtpHeaderExtension *extension);

Copies a FsRtpHeaderExtension

extension :

The RTP header extension definition to copy

Returns :

a new FsRtpHeaderExtension

fs_rtp_header_extension_destroy ()

void                fs_rtp_header_extension_destroy     (FsRtpHeaderExtension *extension);

Frees the passed FsRtpHeaderExtension

extension :

A RTP header extension to free

fs_rtp_header_extension_are_equal ()

gboolean            fs_rtp_header_extension_are_equal   (FsRtpHeaderExtension *extension1,
                                                         FsRtpHeaderExtension *extension2);

Compares two FsRtpHeaderExtension structures

extension1 :

The first FsRtpHeaderExtension

extension2 :

The second FsRtpHeaderExtension

Returns :

TRUE if they are identical, FALSE otherwise

fs_rtp_header_extension_list_copy ()

GList *             fs_rtp_header_extension_list_copy   (GList *extensions);

Does a deep copy of a GList of FsRtpHeaderExtension

extensions :

a GList of FsRtpHeaderExtension

Returns :

a new GList of FsRtpHeaderExtension

fs_rtp_header_extension_list_destroy ()

void                fs_rtp_header_extension_list_destroy
                                                        (GList *extensions);

Frees the passed GList of FsRtpHeaderExtension

extensions :

a GList of FsRtpHeaderExtension

fs_rtp_header_extension_list_from_keyfile ()

GList *             fs_rtp_header_extension_list_from_keyfile
                                                        (const gchar *filename,
                                                         FsMediaType media_type,
                                                         GError **error);

Reads the content of a GKeyFile of the following format into a GList of FsRtpHeaderExtension structures.

The groups have a format "rtp-hdrext:audio:XXX" or "rtp-hdrext:video:XXX" where XXX is a unique string (per media type).

The valid keys are:

  • id: a int between in the 1-255 and 4096-4351 ranges
  • uri: a URI describing the RTP Header Extension
  • direction (optional): To only send or receive a RTP Header Extension, possible values are "send", "receive", "none" or "both". Defaults to "both"

Example:

1
2
3
4
5
6
7
8
[rtp-hdrext:audio:a]
id=1
uri=urn:ietf:params:rtp-hdrext:toffset

[rtp-hdrext:audio:abc]
id=3
uri=urn:ietf:params:rtp-hdrext:ntp-64
direction=receive

filename :

Name of the GKeyFile to read the RTP Header Extensions from

media_type :

The media type for which to get header extensions

error :

location of a GError, or NULL if no error occured

Returns :

a GList of FsRtpHeaderExtension that must be freed with fs_rtp_header_extension_list_destroy()

FS_RTP_HEADER_EXTENSION_FORMAT

#define FS_RTP_HEADER_EXTENSION_FORMAT "%d: (%s) %s"

A format that can be used in printf like format strings to format a FsRtpHeaderExtension


FS_RTP_HEADER_EXTENSION_ARGS()

#define             FS_RTP_HEADER_EXTENSION_ARGS(hdrext)

Formats the codec in args for FS_RTP_HEADER_EXTENSION_ARGS

hdrext :

a FsRtpHeaderExtension

fs_utils_set_bitrate ()

void                fs_utils_set_bitrate                (GstElement *element,
                                                         glong bitrate);

This allows setting the bitrate on all elements that have a "bitrate" property without having to know the type or of the unit used by that element.

This will be obsolete in 0.11 (when all elements use bit/sec for the "bitrate" property.

element :

The GstElement

bitrate :

The bitrate in bits/sec

fs_utils_get_default_codec_preferences ()

GList *             fs_utils_get_default_codec_preferences
                                                        (GstElement *element);

These default codec preferences should work with the elements that are available in the main GStreamer element repositories. They should be suitable for standards based protocols like SIP or XMPP.

element :

Element for which to fetch default codec preferences

Returns :

The default codec preferences for this plugin, this GList should be freed with fs_codec_list_destroy()

fs_utils_get_default_element_properties ()

GKeyFile *          fs_utils_get_default_element_properties
                                                        (GstElement *element);

This function produces a GKeyFile that can be fed to fs_element_added_notifier_set_properties_from_keyfile(). If no default properties have been found, it will return NULL.

element :

Element for which to fetch default element properties

Returns :

a GKeyFile containing the default element properties for this element or NULL if no properties were found. Caller must free the GKeyFile when he is done.

fs_utils_get_default_rtp_header_extension_preferences ()

GList *             fs_utils_get_default_rtp_header_extension_preferences
                                                        (GstElement *element,
                                                         FsMediaType media_type);

These default rtp header extension preferences should work with the elements that are available in the main GStreamer element repositories. They should be suitable for standards based protocols like SIP or XMPP.

element :

Element for which to fetch default RTP Header Extension preferences

media_type :

The FsMediaType for which to get default RTP Header Extension preferences

Returns :

The default rtp header extension preferences for this plugin, this GList should be freed with fs_codec_list_destroy()