GstRTSPMedia

GstRTSPMedia — The media pipeline

Functions

GstRTSPMedia * gst_rtsp_media_new ()
GstElement * gst_rtsp_media_get_element ()
void gst_rtsp_media_take_pipeline ()
void gst_rtsp_media_set_permissions ()
GstRTSPPermissions * gst_rtsp_media_get_permissions ()
void gst_rtsp_media_set_shared ()
gboolean gst_rtsp_media_is_shared ()
void gst_rtsp_media_set_reusable ()
gboolean gst_rtsp_media_is_reusable ()
void gst_rtsp_media_set_profiles ()
GstRTSPProfile gst_rtsp_media_get_profiles ()
void gst_rtsp_media_set_protocols ()
GstRTSPLowerTrans gst_rtsp_media_get_protocols ()
void gst_rtsp_media_set_eos_shutdown ()
gboolean gst_rtsp_media_is_eos_shutdown ()
void gst_rtsp_media_set_address_pool ()
GstRTSPAddressPool * gst_rtsp_media_get_address_pool ()
void gst_rtsp_media_set_buffer_size ()
guint gst_rtsp_media_get_buffer_size ()
gboolean gst_rtsp_media_setup_sdp ()
gboolean gst_rtsp_media_prepare ()
gboolean gst_rtsp_media_unprepare ()
GstRTSPMediaStatus gst_rtsp_media_get_status ()
void gst_rtsp_media_set_suspend_mode ()
GstRTSPSuspendMode gst_rtsp_media_get_suspend_mode ()
gboolean gst_rtsp_media_suspend ()
gboolean gst_rtsp_media_unsuspend ()
void gst_rtsp_media_collect_streams ()
GstRTSPStream * gst_rtsp_media_create_stream ()
guint gst_rtsp_media_n_streams ()
GstRTSPStream * gst_rtsp_media_get_stream ()
GstRTSPStream * gst_rtsp_media_find_stream ()
gboolean gst_rtsp_media_seek ()
gchar * gst_rtsp_media_get_range_string ()
gboolean gst_rtsp_media_set_state ()
void gst_rtsp_media_set_pipeline_state ()
GstClock * gst_rtsp_media_get_clock ()
GstClockTime gst_rtsp_media_get_base_time ()
void gst_rtsp_media_use_time_provider ()
gboolean gst_rtsp_media_is_time_provider ()
GstNetTimeProvider * gst_rtsp_media_get_time_provider ()

Properties

guint buffer-size Read / Write
GstElement * element Read / Write / Construct Only
gboolean eos-shutdown Read / Write
GstRTSPProfile profiles Read / Write
GstRTSPLowerTrans protocols Read / Write
gboolean reusable Read / Write
gboolean shared Read / Write
GstRTSPSuspendMode suspend-mode Read / Write
gboolean time-provider Read / Write

Signals

void new-state Run Last
void new-stream Run Last
void prepared Run Last
void removed-stream Run Last
void target-state Run Last
void unprepared Run Last

Types and Values

Object Hierarchy

    GObject
    ╰── GstRTSPMedia

Description

a GstRTSPMedia contains the complete GStreamer pipeline to manage the streaming to the clients. The actual data transfer is done by the GstRTSPStream objects that are created and exposed by the GstRTSPMedia.

The GstRTSPMedia is usually created from a GstRTSPMediaFactory when the client does a DESCRIBE or SETUP of a resource.

A media is created with gst_rtsp_media_new() that takes the element that will provide the streaming elements. For each of the streams, a new GstRTSPStream object needs to be made with the gst_rtsp_media_create_stream() which takes the payloader element and the source pad that produces the RTP stream.

The pipeline of the media is set to PAUSED with gst_rtsp_media_prepare(). The prepare method will add rtpbin and sinks and sources to send and receive RTP and RTCP packets from the clients. Each stream srcpad is connected to an input into the internal rtpbin.

It is also possible to dynamically create GstRTSPStream objects during the prepare phase. With gst_rtsp_media_get_status() you can check the status of the prepare phase.

After the media is prepared, it is ready for streaming. It will usually be managed in a session with gst_rtsp_session_manage_media(). See GstRTSPSession and GstRTSPSessionMedia.

The state of the media can be controlled with gst_rtsp_media_set_state(). Seeking can be done with gst_rtsp_media_seek().

With gst_rtsp_media_unprepare() the pipeline is stopped and shut down. When gst_rtsp_media_set_eos_shutdown() an EOS will be sent to the pipeline to cleanly shut down.

With gst_rtsp_media_set_shared(), the media can be shared between multiple clients. With gst_rtsp_media_set_reusable() you can control if the pipeline can be prepared again after an unprepare.

Last reviewed on 2013-07-11 (1.0.0)

Functions

gst_rtsp_media_new ()

GstRTSPMedia *
gst_rtsp_media_new (GstElement *element);

Create a new GstRTSPMedia instance. element is the bin element that provides the different streams. The GstRTSPMedia object contains the element to produce RTP data for one or more related (audio/video/..) streams.

Ownership is taken of element .

Parameters

element

a GstElement.

[transfer full]

Returns

a new GstRTSPMedia object.

[transfer full]


gst_rtsp_media_get_element ()

GstElement *
gst_rtsp_media_get_element (GstRTSPMedia *media);

Get the element that was used when constructing media .

Parameters

media

a GstRTSPMedia

 

Returns

a GstElement. Unref after usage.

[transfer full]


gst_rtsp_media_take_pipeline ()

void
gst_rtsp_media_take_pipeline (GstRTSPMedia *media,
                              GstPipeline *pipeline);

Set pipeline as the GstPipeline for media . Ownership is taken of pipeline .

Parameters

media

a GstRTSPMedia

 

pipeline

a GstPipeline.

[transfer full]

gst_rtsp_media_set_permissions ()

void
gst_rtsp_media_set_permissions (GstRTSPMedia *media,
                                GstRTSPPermissions *permissions);

Set permissions on media .

Parameters

media

a GstRTSPMedia

 

permissions

a GstRTSPPermissions.

[transfer none]

gst_rtsp_media_get_permissions ()

GstRTSPPermissions *
gst_rtsp_media_get_permissions (GstRTSPMedia *media);

Get the permissions object from media .

Parameters

media

a GstRTSPMedia

 

Returns

a GstRTSPPermissions object, unref after usage.

[transfer full]


gst_rtsp_media_set_shared ()

void
gst_rtsp_media_set_shared (GstRTSPMedia *media,
                           gboolean shared);

Set or unset if the pipeline for media can be shared will multiple clients. When shared is TRUE, client requests for this media will share the media pipeline.

Parameters

media

a GstRTSPMedia

 

shared

the new value

 

gst_rtsp_media_is_shared ()

gboolean
gst_rtsp_media_is_shared (GstRTSPMedia *media);

Check if the pipeline for media can be shared between multiple clients.

Parameters

media

a GstRTSPMedia

 

Returns

TRUE if the media can be shared between clients.


gst_rtsp_media_set_reusable ()

void
gst_rtsp_media_set_reusable (GstRTSPMedia *media,
                             gboolean reusable);

Set or unset if the pipeline for media can be reused after the pipeline has been unprepared.

Parameters

media

a GstRTSPMedia

 

reusable

the new value

 

gst_rtsp_media_is_reusable ()

gboolean
gst_rtsp_media_is_reusable (GstRTSPMedia *media);

Check if the pipeline for media can be reused after an unprepare.

Parameters

media

a GstRTSPMedia

 

Returns

TRUE if the media can be reused


gst_rtsp_media_set_profiles ()

void
gst_rtsp_media_set_profiles (GstRTSPMedia *media,
                             GstRTSPProfile profiles);

Configure the allowed lower transport for media .

Parameters

media

a GstRTSPMedia

 

profiles

the new flags

 

gst_rtsp_media_get_profiles ()

GstRTSPProfile
gst_rtsp_media_get_profiles (GstRTSPMedia *media);

Get the allowed profiles of media .

Parameters

media

a GstRTSPMedia

 

Returns

a GstRTSPProfile


gst_rtsp_media_set_protocols ()

void
gst_rtsp_media_set_protocols (GstRTSPMedia *media,
                              GstRTSPLowerTrans protocols);

Configure the allowed lower transport for media .

Parameters

media

a GstRTSPMedia

 

protocols

the new flags

 

gst_rtsp_media_get_protocols ()

GstRTSPLowerTrans
gst_rtsp_media_get_protocols (GstRTSPMedia *media);

Get the allowed protocols of media .

Parameters

media

a GstRTSPMedia

 

Returns

a GstRTSPLowerTrans


gst_rtsp_media_set_eos_shutdown ()

void
gst_rtsp_media_set_eos_shutdown (GstRTSPMedia *media,
                                 gboolean eos_shutdown);

Set or unset if an EOS event will be sent to the pipeline for media before it is unprepared.

Parameters

media

a GstRTSPMedia

 

eos_shutdown

the new value

 

gst_rtsp_media_is_eos_shutdown ()

gboolean
gst_rtsp_media_is_eos_shutdown (GstRTSPMedia *media);

Check if the pipeline for media will send an EOS down the pipeline before unpreparing.

Parameters

media

a GstRTSPMedia

 

Returns

TRUE if the media will send EOS before unpreparing.


gst_rtsp_media_set_address_pool ()

void
gst_rtsp_media_set_address_pool (GstRTSPMedia *media,
                                 GstRTSPAddressPool *pool);

configure pool to be used as the address pool of media .

Parameters

media

a GstRTSPMedia

 

pool

a GstRTSPAddressPool.

[transfer none]

gst_rtsp_media_get_address_pool ()

GstRTSPAddressPool *
gst_rtsp_media_get_address_pool (GstRTSPMedia *media);

Get the GstRTSPAddressPool used as the address pool of media .

Parameters

media

a GstRTSPMedia

 

Returns

the GstRTSPAddressPool of media . g_object_unref() after usage.

[transfer full]


gst_rtsp_media_set_buffer_size ()

void
gst_rtsp_media_set_buffer_size (GstRTSPMedia *media,
                                guint size);

Set the kernel UDP buffer size.

Parameters

media

a GstRTSPMedia

 

size

the new value

 

gst_rtsp_media_get_buffer_size ()

guint
gst_rtsp_media_get_buffer_size (GstRTSPMedia *media);

Get the kernel UDP buffer size.

Parameters

media

a GstRTSPMedia

 

Returns

the kernel UDP buffer size.


gst_rtsp_media_setup_sdp ()

gboolean
gst_rtsp_media_setup_sdp (GstRTSPMedia *media,
                          GstSDPMessage *sdp,
                          GstSDPInfo *info);

Add media specific info to sdp . info is used to configure the connection information in the SDP.

Parameters

media

a GstRTSPMedia

 

sdp

a GstSDPMessage.

[transfer none]

info

a GstSDPInfo.

[transfer none]

Returns

TRUE on success.


gst_rtsp_media_prepare ()

gboolean
gst_rtsp_media_prepare (GstRTSPMedia *media,
                        GstRTSPThread *thread);

Prepare media for streaming. This function will create the objects to manage the streaming. A pipeline must have been set on media with gst_rtsp_media_take_pipeline().

It will preroll the pipeline and collect vital information about the streams such as the duration.

Parameters

media

a GstRTSPMedia

 

thread

a GstRTSPThread to run the bus handler or NULL.

[transfer full][allow-none]

Returns

TRUE on success.


gst_rtsp_media_unprepare ()

gboolean
gst_rtsp_media_unprepare (GstRTSPMedia *media);

Unprepare media . After this call, the media should be prepared again before it can be used again. If the media is set to be non-reusable, a new instance must be created.

Parameters

media

a GstRTSPMedia

 

Returns

TRUE on success.


gst_rtsp_media_get_status ()

GstRTSPMediaStatus
gst_rtsp_media_get_status (GstRTSPMedia *media);

Get the status of media . When media is busy preparing, this function waits until media is prepared or in error.

Parameters

media

a GstRTSPMedia

 

Returns

the status of media .


gst_rtsp_media_set_suspend_mode ()

void
gst_rtsp_media_set_suspend_mode (GstRTSPMedia *media,
                                 GstRTSPSuspendMode mode);

Control how @ media will be suspended after the SDP has been generated and after a PAUSE request has been performed.

Media must be unprepared when setting the suspend mode.

Parameters

media

a GstRTSPMedia

 

mode

the new GstRTSPSuspendMode

 

gst_rtsp_media_get_suspend_mode ()

GstRTSPSuspendMode
gst_rtsp_media_get_suspend_mode (GstRTSPMedia *media);

Get how media will be suspended.

Parameters

media

a GstRTSPMedia

 

gst_rtsp_media_suspend ()

gboolean
gst_rtsp_media_suspend (GstRTSPMedia *media);

Suspend media . The state of the pipeline managed by media is set to GST_STATE_NULL but all streams are kept. media can be prepared again with gst_rtsp_media_unsuspend()

media must be prepared with gst_rtsp_media_prepare();

Parameters

media

a GstRTSPMedia

 

Returns

TRUE on success.


gst_rtsp_media_unsuspend ()

gboolean
gst_rtsp_media_unsuspend (GstRTSPMedia *media);

Unsuspend media if it was in a suspended state. This method does nothing when the media was not in the suspended state.

Parameters

media

a GstRTSPMedia

 

Returns

TRUE on success.


gst_rtsp_media_collect_streams ()

void
gst_rtsp_media_collect_streams (GstRTSPMedia *media);

Find all payloader elements, they should be named pay%d in the element of media , and create GstRTSPStreams for them.

Collect all dynamic elements, named dynpay%d, and add them to the list of dynamic elements.

Parameters

media

a GstRTSPMedia

 

gst_rtsp_media_create_stream ()

GstRTSPStream *
gst_rtsp_media_create_stream (GstRTSPMedia *media,
                              GstElement *payloader,
                              GstPad *srcpad);

Create a new stream in media that provides RTP data on srcpad . srcpad should be a pad of an element inside media->element .

Parameters

media

a GstRTSPMedia

 

payloader

a GstElement

 

srcpad

a source GstPad

 

Returns

a new GstRTSPStream that remains valid for as long as media exists.

[transfer none]


gst_rtsp_media_n_streams ()

guint
gst_rtsp_media_n_streams (GstRTSPMedia *media);

Get the number of streams in this media.

Parameters

media

a GstRTSPMedia

 

Returns

The number of streams.


gst_rtsp_media_get_stream ()

GstRTSPStream *
gst_rtsp_media_get_stream (GstRTSPMedia *media,
                           guint idx);

Retrieve the stream with index idx from media .

Parameters

media

a GstRTSPMedia

 

idx

the stream index

 

Returns

the GstRTSPStream at index idx or NULL when a stream with that index did not exist.

[nullable][transfer none]


gst_rtsp_media_find_stream ()

GstRTSPStream *
gst_rtsp_media_find_stream (GstRTSPMedia *media,
                            const gchar *control);

Find a stream in media with control as the control uri.

Parameters

media

a GstRTSPMedia

 

control

the control of the stream

 

Returns

the GstRTSPStream with control uri control or NULL when a stream with that control did not exist.

[nullable][transfer none]


gst_rtsp_media_seek ()

gboolean
gst_rtsp_media_seek (GstRTSPMedia *media,
                     GstRTSPTimeRange *range);

Seek the pipeline of media to range . media must be prepared with gst_rtsp_media_prepare().

Parameters

media

a GstRTSPMedia

 

range

a GstRTSPTimeRange.

[transfer none]

Returns

TRUE on success.


gst_rtsp_media_get_range_string ()

gchar *
gst_rtsp_media_get_range_string (GstRTSPMedia *media,
                                 gboolean play,
                                 GstRTSPRangeUnit unit);

Get the current range as a string. media must be prepared with gst_rtsp_media_prepare().

Parameters

media

a GstRTSPMedia

 

play

for the PLAY request

 

unit

the unit to use for the string

 

Returns

The range as a string, g_free() after usage.

[transfer full]


gst_rtsp_media_set_state ()

gboolean
gst_rtsp_media_set_state (GstRTSPMedia *media,
                          GstState state,
                          GPtrArray *transports);

Set the state of media to state and for the transports in transports .

media must be prepared with gst_rtsp_media_prepare();

Parameters

media

a GstRTSPMedia

 

state

the target state of the media

 

transports

a GPtrArray of GstRTSPStreamTransport pointers.

[transfer none][element-type GstRtspServer.RTSPStreamTransport]

Returns

TRUE on success.


gst_rtsp_media_set_pipeline_state ()

void
gst_rtsp_media_set_pipeline_state (GstRTSPMedia *media,
                                   GstState state);

Set the state of the pipeline managed by media to state

Parameters

media

a GstRTSPMedia

 

state

the target state of the pipeline

 

gst_rtsp_media_get_clock ()

GstClock *
gst_rtsp_media_get_clock (GstRTSPMedia *media);

Get the clock that is used by the pipeline in media .

media must be prepared before this method returns a valid clock object.

Parameters

media

a GstRTSPMedia

 

Returns

the GstClock used by media . unref after usage.

[transfer full]


gst_rtsp_media_get_base_time ()

GstClockTime
gst_rtsp_media_get_base_time (GstRTSPMedia *media);

Get the base_time that is used by the pipeline in media .

media must be prepared before this method returns a valid base_time.

Parameters

media

a GstRTSPMedia

 

Returns

the base_time used by media .


gst_rtsp_media_use_time_provider ()

void
gst_rtsp_media_use_time_provider (GstRTSPMedia *media,
                                  gboolean time_provider);

Set media to provide a GstNetTimeProvider.

Parameters

media

a GstRTSPMedia

 

time_provider

if a GstNetTimeProvider should be used

 

gst_rtsp_media_is_time_provider ()

gboolean
gst_rtsp_media_is_time_provider (GstRTSPMedia *media);

Check if media can provide a GstNetTimeProvider for its pipeline clock.

Use gst_rtsp_media_get_time_provider() to get the network clock.

Parameters

media

a GstRTSPMedia

 

Returns

TRUE if media can provide a GstNetTimeProvider.


gst_rtsp_media_get_time_provider ()

GstNetTimeProvider *
gst_rtsp_media_get_time_provider (GstRTSPMedia *media,
                                  const gchar *address,
                                  guint16 port);

Get the GstNetTimeProvider for the clock used by media . The time provider will listen on address and port for client time requests.

Parameters

media

a GstRTSPMedia

 

address

an address or NULL.

[allow-none]

port

a port or 0

 

Returns

the GstNetTimeProvider of media .

[transfer full]

Types and Values

struct GstRTSPMedia

struct GstRTSPMedia;

A class that contains the GStreamer element along with a list of GstRTSPStream objects that can produce data.

This object is usually created from a GstRTSPMediaFactory.


struct GstRTSPMediaClass

struct GstRTSPMediaClass {
  GObjectClass  parent_class;

  /* vmethods */
  gboolean        (*handle_message)  (GstRTSPMedia *media, GstMessage *message);
  gboolean        (*prepare)         (GstRTSPMedia *media, GstRTSPThread *thread);
  gboolean        (*unprepare)       (GstRTSPMedia *media);
  gboolean        (*suspend)         (GstRTSPMedia *media);
  gboolean        (*unsuspend)       (GstRTSPMedia *media);
  gboolean        (*convert_range)   (GstRTSPMedia *media, GstRTSPTimeRange *range,
                                      GstRTSPRangeUnit unit);
  gboolean        (*query_position)  (GstRTSPMedia *media, gint64 *position);
  gboolean        (*query_stop)      (GstRTSPMedia *media, gint64 *stop);
  GstElement *    (*create_rtpbin)   (GstRTSPMedia *media);
  gboolean        (*setup_rtpbin)    (GstRTSPMedia *media, GstElement *rtpbin);
  gboolean        (*setup_sdp)       (GstRTSPMedia *media, GstSDPMessage *sdp, GstSDPInfo *info);

  /* signals */
  void            (*new_stream)      (GstRTSPMedia *media, GstRTSPStream * stream);
  void            (*removed_stream)  (GstRTSPMedia *media, GstRTSPStream * stream);

  void            (*prepared)        (GstRTSPMedia *media);
  void            (*unprepared)      (GstRTSPMedia *media);

  void            (*target_state)    (GstRTSPMedia *media, GstState state);
  void            (*new_state)       (GstRTSPMedia *media, GstState state);
};

The RTSP media class

Members

GObjectClass parent_class;

   

handle_message ()

handle a message

 

prepare ()

the default implementation adds all elements and sets the pipeline's state to GST_STATE_PAUSED (or GST_STATE_PLAYING in case of NO_PREROLL elements).

 

unprepare ()

the default implementation sets the pipeline's state to GST_STATE_NULL and removes all elements.

 

suspend ()

the default implementation sets the pipeline's state to GST_STATE_NULL GST_STATE_PAUSED depending on the selected suspend mode.

 

unsuspend ()

the default implementation reverts the suspend operation. The pipeline will be prerolled again if it's state was set to GST_STATE_NULL in suspend.

 

convert_range ()

convert a range to the given unit

 

query_position ()

query the current position in the pipeline

 

query_stop ()

query when playback will stop

 

create_rtpbin ()

   

setup_rtpbin ()

   

setup_sdp ()

   

new_stream ()

   

removed_stream ()

   

prepared ()

   

unprepared ()

   

target_state ()

   

new_state ()

   

enum GstRTSPMediaStatus

The state of the media pipeline.

Members

GST_RTSP_MEDIA_STATUS_UNPREPARED

media pipeline not prerolled

 

GST_RTSP_MEDIA_STATUS_UNPREPARING

media pipeline is busy doing a clean shutdown.

 

GST_RTSP_MEDIA_STATUS_PREPARING

media pipeline is prerolling

 

GST_RTSP_MEDIA_STATUS_PREPARED

media pipeline is prerolled

 

GST_RTSP_MEDIA_STATUS_SUSPENDED

media is suspended

 

GST_RTSP_MEDIA_STATUS_ERROR

media pipeline is in error

 

enum GstRTSPSuspendMode

The suspend mode of the media pipeline. A media pipeline is suspended right after creating the SDP and when the client performs a PAUSED request.

Members

GST_RTSP_SUSPEND_MODE_NONE

Media is not suspended

 

GST_RTSP_SUSPEND_MODE_PAUSE

Media is PAUSED in suspend

 

GST_RTSP_SUSPEND_MODE_RESET

The media is set to NULL when suspended

 

Property Details

The “buffer-size” property

  “buffer-size”              guint

The kernel UDP buffer size to use.

Flags: Read / Write

Default value: 524288


The “element” property

  “element”                  GstElement *

The GstBin to use for streaming the media.

Flags: Read / Write / Construct Only


The “eos-shutdown” property

  “eos-shutdown”             gboolean

Send an EOS event to the pipeline before unpreparing.

Flags: Read / Write

Default value: FALSE


The “profiles” property

  “profiles”                 GstRTSPProfile

Allowed transfer profiles.

Flags: Read / Write

Default value: GST_RTSP_PROFILE_AVP


The “protocols” property

  “protocols”                GstRTSPLowerTrans

Allowed lower transport protocols.

Flags: Read / Write

Default value: GST_RTSP_LOWER_TRANS_UDP | GST_RTSP_LOWER_TRANS_UDP_MCAST | GST_RTSP_LOWER_TRANS_TCP


The “reusable” property

  “reusable”                 gboolean

If this media pipeline can be reused after an unprepare.

Flags: Read / Write

Default value: FALSE


The “shared” property

  “shared”                   gboolean

If this media pipeline can be shared.

Flags: Read / Write

Default value: FALSE


The “suspend-mode” property

  “suspend-mode”             GstRTSPSuspendMode

How to suspend the media in PAUSED.

Flags: Read / Write

Default value: GST_RTSP_SUSPEND_MODE_NONE


The “time-provider” property

  “time-provider”            gboolean

Use a NetTimeProvider for clients.

Flags: Read / Write

Default value: FALSE

Signal Details

The “new-state” signal

void
user_function (GstRTSPMedia *gstrtspmedia,
               gint          arg1,
               gpointer      user_data)

Flags: Run Last


The “new-stream” signal

void
user_function (GstRTSPMedia  *gstrtspmedia,
               GstRTSPStream *arg1,
               gpointer       user_data)

Flags: Run Last


The “prepared” signal

void
user_function (GstRTSPMedia *gstrtspmedia,
               gpointer      user_data)

Flags: Run Last


The “removed-stream” signal

void
user_function (GstRTSPMedia  *gstrtspmedia,
               GstRTSPStream *arg1,
               gpointer       user_data)

Flags: Run Last


The “target-state” signal

void
user_function (GstRTSPMedia *gstrtspmedia,
               gint          arg1,
               gpointer      user_data)

Flags: Run Last


The “unprepared” signal

void
user_function (GstRTSPMedia *gstrtspmedia,
               gpointer      user_data)

Flags: Run Last

See Also

GstRTSPMediaFactory, GstRTSPStream, GstRTSPSession, GstRTSPSessionMedia