GstRTSPMedia

GstRTSPMedia

Synopsis

                    GstRTSPMediaStream;
                    GstRTSPMedia;
                    GstRTSPMediaClass;
                    GstRTSPMediaTrans;
gboolean            (*GstRTSPSendFunc)                  (GstBuffer *buffer,
                                                         guint8 channel,
                                                         gpointer user_data);
gboolean            (*GstRTSPSendListFunc)              (GstBufferList *blist,
                                                         guint8 channel,
                                                         gpointer user_data);
void                (*GstRTSPKeepAliveFunc)             (gpointer user_data);
enum                GstRTSPMediaStatus;
GstRTSPMedia *      gst_rtsp_media_new                  (void);
void                gst_rtsp_media_set_shared           (GstRTSPMedia *media,
                                                         gboolean shared);
gboolean            gst_rtsp_media_is_shared            (GstRTSPMedia *media);
void                gst_rtsp_media_set_reusable         (GstRTSPMedia *media,
                                                         gboolean reusable);
gboolean            gst_rtsp_media_is_reusable          (GstRTSPMedia *media);
void                gst_rtsp_media_set_protocols        (GstRTSPMedia *media,
                                                         GstRTSPLowerTrans protocols);
GstRTSPLowerTrans   gst_rtsp_media_get_protocols        (GstRTSPMedia *media);
void                gst_rtsp_media_set_eos_shutdown     (GstRTSPMedia *media,
                                                         gboolean eos_shutdown);
gboolean            gst_rtsp_media_is_eos_shutdown      (GstRTSPMedia *media);
gboolean            gst_rtsp_media_prepare              (GstRTSPMedia *media);
gboolean            gst_rtsp_media_is_prepared          (GstRTSPMedia *media);
gboolean            gst_rtsp_media_unprepare            (GstRTSPMedia *media);
guint               gst_rtsp_media_n_streams            (GstRTSPMedia *media);
GstRTSPMediaStream * gst_rtsp_media_get_stream          (GstRTSPMedia *media,
                                                         guint idx);
gboolean            gst_rtsp_media_seek                 (GstRTSPMedia *media,
                                                         GstRTSPTimeRange *range);
gchar *             gst_rtsp_media_get_range_string     (GstRTSPMedia *media,
                                                         gboolean play);
GstFlowReturn       gst_rtsp_media_stream_rtp           (GstRTSPMediaStream *stream,
                                                         GstBuffer *buffer);
GstFlowReturn       gst_rtsp_media_stream_rtcp          (GstRTSPMediaStream *stream,
                                                         GstBuffer *buffer);
gboolean            gst_rtsp_media_set_state            (GstRTSPMedia *media,
                                                         GstState state,
                                                         GArray *transports);
void                gst_rtsp_media_remove_elements      (GstRTSPMedia *media);
void                gst_rtsp_media_trans_cleanup        (GstRTSPMediaTrans *trans);

Object Hierarchy

  GObject
   +----GstRTSPMedia

Properties

  "eos-shutdown"             gboolean              : Read / Write
  "protocols"                GstRTSPLowerTrans     : Read / Write
  "reusable"                 gboolean              : Read / Write
  "shared"                   gboolean              : Read / Write

Signals

  "new-state"                                      : Run Last
  "prepared"                                       : Run Last
  "unprepared"                                     : Run Last

Description

Details

GstRTSPMediaStream

typedef struct {
  GstPad       *srcpad;
  GstElement   *payloader;
  gboolean      prepared;

  /* pads on the rtpbin */
  GstPad       *recv_rtcp_sink;
  GstPad       *recv_rtp_sink;
  GstPad       *send_rtp_sink;
  GstPad       *send_rtp_src;
  GstPad       *send_rtcp_src;

  /* the RTPSession object */
  GObject      *session;

  /* sinks used for sending and receiving RTP and RTCP, they share
   * sockets */
  GstElement   *udpsrc[2];
  GstElement   *udpsink[2];
  /* for TCP transport */
  GstElement   *appsrc[2];
  GstElement   *appsink[2];

  GstElement   *tee[2];
  GstElement   *selector[2];

  /* server ports for sending/receiving */
  GstRTSPRange  server_port;

  /* the caps of the stream */
  gulong        caps_sig;
  GstCaps      *caps;

  /* transports we stream to */
  GList        *transports;

  /* to filter out duplicate destinations in case multiudpsink is too old to do
   * this for us */
  gboolean      filter_duplicates;
  GList        *destinations;
} GstRTSPMediaStream;

The definition of a media stream. The streams are identified by id.

GstPad *srcpad;

the srcpad of the stream

GstElement *payloader;

the payloader of the format

gboolean prepared;

if the stream is prepared for streaming

GstPad *recv_rtcp_sink;

sinkpad for RTCP buffers

GstPad *recv_rtp_sink;

sinkpad for RTP buffers

GstPad *send_rtp_sink;

GstPad *send_rtp_src;

srcpad for RTP buffers

GstPad *send_rtcp_src;

srcpad for RTCP buffers

GObject *session;

GstElement *udpsrc[2];

the udp source elements for RTP/RTCP

GstElement *udpsink[2];

the udp sink elements for RTP/RTCP

GstElement *appsrc[2];

the app source elements for RTP/RTCP

GstElement *appsink[2];

the app sink elements for RTP/RTCP

GstElement *tee[2];

GstElement *selector[2];

GstRTSPRange server_port;

the server ports for this stream

gulong caps_sig;

the signal id for detecting caps

GstCaps *caps;

the caps of the stream

GList *transports;

gboolean filter_duplicates;

GList *destinations;


GstRTSPMedia

typedef struct _GstRTSPMedia GstRTSPMedia;

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

This object is usually created from a GstRTSPMediaFactory.


GstRTSPMediaClass

typedef struct {
  GObjectClass  parent_class;

  /* thread for the mainloop */
  GMainContext *context;
  GMainLoop    *loop;
  GThread      *thread;

  /* vmethods */
  gboolean     (*handle_message)  (GstRTSPMedia *media, GstMessage *message);
  gboolean     (*unprepare)       (GstRTSPMedia *media);

  /* signals */
  gboolean     (*prepared)        (GstRTSPMedia *media);
  gboolean     (*unprepared)      (GstRTSPMedia *media);

  gboolean     (*new_state)       (GstRTSPMedia *media, GstState state);
} GstRTSPMediaClass;

The RTSP media class

GObjectClass parent_class;

GMainContext *context;

the main context for dispatching messages

GMainLoop *loop;

the mainloop for message.

GThread *thread;

the thread dispatching messages.

handle_message ()

handle a message

unprepare ()

the default implementation sets the pipeline's state to GST_STATE_NULL.

prepared ()

unprepared ()

new_state ()


GstRTSPMediaTrans

typedef struct {
  guint idx;

  GstRTSPSendFunc      send_rtp;
  GstRTSPSendFunc      send_rtcp;
  GstRTSPSendListFunc  send_rtp_list;
  GstRTSPSendListFunc  send_rtcp_list;
  gpointer             user_data;
  GDestroyNotify       notify;

  GstRTSPKeepAliveFunc keep_alive;
  gpointer             ka_user_data;
  GDestroyNotify       ka_notify;
  gboolean             active;
  gboolean             timeout;

  GstRTSPTransport    *transport;

  GObject             *rtpsource;
} GstRTSPMediaTrans;

A Transport description for stream idx

guint idx;

a stream index

GstRTSPSendFunc send_rtp;

callback for sending RTP messages

GstRTSPSendFunc send_rtcp;

callback for sending RTCP messages

GstRTSPSendListFunc send_rtp_list;

callback for sending RTP messages

GstRTSPSendListFunc send_rtcp_list;

callback for sending RTCP messages

gpointer user_data;

user data passed in the callbacks

GDestroyNotify notify;

free function for the user_data.

GstRTSPKeepAliveFunc keep_alive;

keep alive callback

gpointer ka_user_data;

data passed to keep_alive

GDestroyNotify ka_notify;

called when ka_user_data is freed

gboolean active;

if we are actively sending

gboolean timeout;

if we timed out

GstRTSPTransport *transport;

a transport description

GObject *rtpsource;

the receiver rtp source object

GstRTSPSendFunc ()

gboolean            (*GstRTSPSendFunc)                  (GstBuffer *buffer,
                                                         guint8 channel,
                                                         gpointer user_data);

GstRTSPSendListFunc ()

gboolean            (*GstRTSPSendListFunc)              (GstBufferList *blist,
                                                         guint8 channel,
                                                         gpointer user_data);

GstRTSPKeepAliveFunc ()

void                (*GstRTSPKeepAliveFunc)             (gpointer user_data);

enum GstRTSPMediaStatus

typedef enum {
  GST_RTSP_MEDIA_STATUS_UNPREPARED = 0,
  GST_RTSP_MEDIA_STATUS_PREPARING  = 1,
  GST_RTSP_MEDIA_STATUS_PREPARED   = 2,
  GST_RTSP_MEDIA_STATUS_ERROR      = 3
} GstRTSPMediaStatus;

The state of the media pipeline.

GST_RTSP_MEDIA_STATUS_UNPREPARED

media pipeline not prerolled

GST_RTSP_MEDIA_STATUS_PREPARING

media pipeline is prerolling

GST_RTSP_MEDIA_STATUS_PREPARED

media pipeline is prerolled

GST_RTSP_MEDIA_STATUS_ERROR

media pipeline is in error

gst_rtsp_media_new ()

GstRTSPMedia *      gst_rtsp_media_new                  (void);

Create a new GstRTSPMedia instance. The GstRTSPMedia object contains the element to produde RTP data for one or more related (audio/video/..) streams.

Returns :

a new GstRTSPMedia object.

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.

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.

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.

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.

media :

a GstRTSPMedia

Returns :

TRUE if the media can be reused

gst_rtsp_media_set_protocols ()

void                gst_rtsp_media_set_protocols        (GstRTSPMedia *media,
                                                         GstRTSPLowerTrans protocols);

Configure the allowed lower transport for media.

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.

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.

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.

media :

a GstRTSPMedia

Returns :

TRUE if the media will send EOS before unpreparing.

gst_rtsp_media_prepare ()

gboolean            gst_rtsp_media_prepare              (GstRTSPMedia *media);

Prepare media for streaming. This function will create the pipeline and other objects to manage the streaming.

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

media :

a GstRTSPMedia

Returns :

TRUE on success.

gst_rtsp_media_is_prepared ()

gboolean            gst_rtsp_media_is_prepared          (GstRTSPMedia *media);

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.

media :

a GstRTSPMedia

Returns :

TRUE on success.

gst_rtsp_media_n_streams ()

guint               gst_rtsp_media_n_streams            (GstRTSPMedia *media);

Get the number of streams in this media.

media :

a GstRTSPMedia

Returns :

The number of streams.

gst_rtsp_media_get_stream ()

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

Retrieve the stream with index idx from media.

media :

a GstRTSPMedia

idx :

the stream index

Returns :

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

gst_rtsp_media_seek ()

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

Seek the pipeline to range.

media :

a GstRTSPMedia

range :

a GstRTSPTimeRange

Returns :

TRUE on success.

gst_rtsp_media_get_range_string ()

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

Get the current range as a string.

media :

a GstRTSPMedia

play :

for the PLAY request

Returns :

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

gst_rtsp_media_stream_rtp ()

GstFlowReturn       gst_rtsp_media_stream_rtp           (GstRTSPMediaStream *stream,
                                                         GstBuffer *buffer);

Handle an RTP buffer for the stream. This method is usually called when a message has been received from a client using the TCP transport.

This function takes ownership of buffer.

stream :

a GstRTSPMediaStream

buffer :

a GstBuffer

Returns :

a GstFlowReturn.

gst_rtsp_media_stream_rtcp ()

GstFlowReturn       gst_rtsp_media_stream_rtcp          (GstRTSPMediaStream *stream,
                                                         GstBuffer *buffer);

Handle an RTCP buffer for the stream. This method is usually called when a message has been received from a client using the TCP transport.

This function takes ownership of buffer.

stream :

a GstRTSPMediaStream

buffer :

a GstBuffer

Returns :

a GstFlowReturn.

gst_rtsp_media_set_state ()

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

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

media :

a GstRTSPMedia

state :

the target state of the media

transports :

a GArray of GstRTSPMediaTrans pointers

Returns :

TRUE on success.

gst_rtsp_media_remove_elements ()

void                gst_rtsp_media_remove_elements      (GstRTSPMedia *media);

Remove all elements and the pipeline controlled by media.

media :

a GstRTSPMedia

gst_rtsp_media_trans_cleanup ()

void                gst_rtsp_media_trans_cleanup        (GstRTSPMediaTrans *trans);

Property Details

The "eos-shutdown" property

  "eos-shutdown"             gboolean              : Read / Write

Send an EOS event to the pipeline before unpreparing.

Default value: FALSE


The "protocols" property

  "protocols"                GstRTSPLowerTrans     : Read / Write

Allowed lower transport protocols.

Default value: GST_RTSP_LOWER_TRANS_UDP|GST_RTSP_LOWER_TRANS_TCP


The "reusable" property

  "reusable"                 gboolean              : Read / Write

If this media pipeline can be reused after an unprepare.

Default value: FALSE


The "shared" property

  "shared"                   gboolean              : Read / Write

If this media pipeline can be shared.

Default value: FALSE

Signal Details

The "new-state" signal

void                user_function                      (GstRTSPMedia *gstrtspmedia,
                                                        gpointer      user_data)         : Run Last

The "prepared" signal

void                user_function                      (GstRTSPMedia *gstrtspmedia,
                                                        gpointer      user_data)         : Run Last

The "unprepared" signal

void                user_function                      (GstRTSPMedia *gstrtspmedia,
                                                        gpointer      user_data)         : Run Last