2008-10-09 12:29:12 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2009-02-04 16:00:42 +00:00
|
|
|
#include <gst/rtsp/gstrtsprange.h>
|
2008-10-09 12:29:12 +00:00
|
|
|
#include <gst/rtsp/gstrtspurl.h>
|
|
|
|
|
|
|
|
#ifndef __GST_RTSP_MEDIA_H__
|
|
|
|
#define __GST_RTSP_MEDIA_H__
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
/* types for the media */
|
|
|
|
#define GST_TYPE_RTSP_MEDIA (gst_rtsp_media_get_type ())
|
|
|
|
#define GST_IS_RTSP_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_MEDIA))
|
|
|
|
#define GST_IS_RTSP_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_MEDIA))
|
|
|
|
#define GST_RTSP_MEDIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_MEDIA, GstRTSPMediaClass))
|
|
|
|
#define GST_RTSP_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_MEDIA, GstRTSPMedia))
|
|
|
|
#define GST_RTSP_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_MEDIA, GstRTSPMediaClass))
|
|
|
|
#define GST_RTSP_MEDIA_CAST(obj) ((GstRTSPMedia*)(obj))
|
|
|
|
#define GST_RTSP_MEDIA_CLASS_CAST(klass) ((GstRTSPMediaClass*)(klass))
|
2008-10-09 12:29:12 +00:00
|
|
|
|
|
|
|
typedef struct _GstRTSPMediaStream GstRTSPMediaStream;
|
2009-01-22 16:58:19 +00:00
|
|
|
typedef struct _GstRTSPMedia GstRTSPMedia;
|
|
|
|
typedef struct _GstRTSPMediaClass GstRTSPMediaClass;
|
2009-02-03 18:32:38 +00:00
|
|
|
typedef struct _GstRTSPMediaTrans GstRTSPMediaTrans;
|
|
|
|
|
2009-03-11 15:45:12 +00:00
|
|
|
typedef gboolean (*GstRTSPSendFunc) (GstBuffer *buffer, guint8 channel, gpointer user_data);
|
|
|
|
|
2009-02-03 18:32:38 +00:00
|
|
|
/**
|
|
|
|
* GstRTSPMediaTrans:
|
|
|
|
* @idx: a stream index
|
2009-03-11 15:45:12 +00:00
|
|
|
* @send_rtp: callback for sending RTP messages
|
|
|
|
* @send_rtcp: callback for sending RTCP messages
|
|
|
|
* @user_data: user data passed in the callbacks
|
|
|
|
* @notify: free function for the user_data.
|
2009-02-03 18:32:38 +00:00
|
|
|
* @transport: a transport description
|
|
|
|
*
|
|
|
|
* A Transport description for stream @idx
|
|
|
|
*/
|
|
|
|
struct _GstRTSPMediaTrans {
|
|
|
|
guint idx;
|
|
|
|
|
2009-03-11 15:45:12 +00:00
|
|
|
GstRTSPSendFunc send_rtp;
|
|
|
|
GstRTSPSendFunc send_rtcp;
|
|
|
|
gpointer user_data;
|
|
|
|
GDestroyNotify notify;
|
|
|
|
|
2009-02-03 18:32:38 +00:00
|
|
|
GstRTSPTransport *transport;
|
|
|
|
};
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-01-20 18:43:47 +00:00
|
|
|
/**
|
|
|
|
* GstRTSPMediaStream:
|
|
|
|
*
|
|
|
|
* @srcpad: the srcpad of the stream
|
2009-01-22 16:58:19 +00:00
|
|
|
* @payloader: the payloader of the format
|
2009-01-29 12:31:27 +00:00
|
|
|
* @prepared: if the stream is prepared for streaming
|
|
|
|
* @server_port: the server udp ports
|
|
|
|
* @recv_rtp_sink: sinkpad for RTP buffers
|
|
|
|
* @recv_rtcp_sink: sinkpad for RTCP buffers
|
|
|
|
* @recv_rtp_src: srcpad for RTP buffers
|
|
|
|
* @recv_rtcp_src: srcpad for RTCP buffers
|
|
|
|
* @udpsrc: the udp source elements for RTP/RTCP
|
|
|
|
* @udpsink: the udp sink elements for RTP/RTCP
|
2009-03-11 15:45:12 +00:00
|
|
|
* @appsrc: the app source elements for RTP/RTCP
|
|
|
|
* @appsink: the app sink elements for RTP/RTCP
|
|
|
|
* @server_port: the server ports for this stream
|
2009-01-20 18:43:47 +00:00
|
|
|
* @caps_sig: the signal id for detecting caps
|
|
|
|
* @caps: the caps of the stream
|
2009-03-11 15:45:12 +00:00
|
|
|
* @tranports: the current transports being streamed
|
2009-01-20 18:43:47 +00:00
|
|
|
*
|
|
|
|
* The definition of a media stream. The streams are identified by @id.
|
|
|
|
*/
|
2008-10-09 12:29:12 +00:00
|
|
|
struct _GstRTSPMediaStream {
|
2009-01-29 12:31:27 +00:00
|
|
|
GstPad *srcpad;
|
|
|
|
GstElement *payloader;
|
|
|
|
gboolean prepared;
|
|
|
|
|
|
|
|
/* pads on the rtpbin */
|
|
|
|
GstPad *recv_rtcp_sink;
|
|
|
|
GstPad *send_rtp_sink;
|
|
|
|
GstPad *send_rtp_src;
|
|
|
|
GstPad *send_rtcp_src;
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-02-13 18:54:18 +00:00
|
|
|
/* the RTPSession object */
|
|
|
|
GObject *session;
|
|
|
|
|
2009-01-29 12:31:27 +00:00
|
|
|
/* sinks used for sending and receiving RTP and RTCP, they share
|
|
|
|
* sockets */
|
|
|
|
GstElement *udpsrc[2];
|
|
|
|
GstElement *udpsink[2];
|
2009-03-11 15:45:12 +00:00
|
|
|
/* for TCP transport */
|
2009-03-06 18:34:14 +00:00
|
|
|
GstElement *appsrc[2];
|
2009-03-11 15:45:12 +00:00
|
|
|
GstElement *appsink[2];
|
2009-01-29 12:31:27 +00:00
|
|
|
|
2009-01-30 15:24:10 +00:00
|
|
|
/* server ports for sending/receiving */
|
|
|
|
GstRTSPRange server_port;
|
|
|
|
|
2009-01-29 12:31:27 +00:00
|
|
|
/* the caps of the stream */
|
|
|
|
gulong caps_sig;
|
|
|
|
GstCaps *caps;
|
2009-03-11 15:45:12 +00:00
|
|
|
|
|
|
|
/* transports we stream to */
|
|
|
|
GList *transports;
|
2008-10-09 12:29:12 +00:00
|
|
|
};
|
|
|
|
|
2009-01-20 18:43:47 +00:00
|
|
|
/**
|
2009-01-22 16:58:19 +00:00
|
|
|
* GstRTSPMedia:
|
2009-01-29 16:20:27 +00:00
|
|
|
* @shared: if this media can be shared between clients
|
2009-04-03 20:22:30 +00:00
|
|
|
* @reusable: if this media can be reused after an unprepare
|
2009-01-29 12:31:27 +00:00
|
|
|
* @element: the data providing element
|
2009-03-11 15:45:12 +00:00
|
|
|
* @streams: the different streams provided by @element
|
2009-01-29 12:31:27 +00:00
|
|
|
* @prepared: if the media is prepared for streaming
|
|
|
|
* @pipeline: the toplevel pipeline
|
2009-03-11 15:45:12 +00:00
|
|
|
* @source: the bus watch for pipeline messages.
|
|
|
|
* @id: the id of the watch
|
|
|
|
* @is_live: if the pipeline is live
|
|
|
|
* @buffering: if the pipeline is buffering
|
|
|
|
* @target_state: the desired target state of the pipeline
|
2009-01-29 12:31:27 +00:00
|
|
|
* @rtpbin: the rtpbin
|
2009-03-11 15:45:12 +00:00
|
|
|
* @range: the range of the media being streamed
|
2009-01-20 18:43:47 +00:00
|
|
|
*
|
2009-01-22 17:35:17 +00:00
|
|
|
* A class that contains the GStreamer element along with a list of
|
|
|
|
* #GstRTSPediaStream objects that can produce data.
|
|
|
|
*
|
|
|
|
* This object is usually created from a #GstRTSPMediaFactory.
|
2009-01-20 18:43:47 +00:00
|
|
|
*/
|
2009-01-22 16:58:19 +00:00
|
|
|
struct _GstRTSPMedia {
|
2008-10-09 12:29:12 +00:00
|
|
|
GObject parent;
|
|
|
|
|
2009-01-29 16:20:27 +00:00
|
|
|
gboolean shared;
|
2009-04-03 20:22:30 +00:00
|
|
|
gboolean reusable;
|
|
|
|
gboolean reused;
|
2009-01-29 16:20:27 +00:00
|
|
|
|
2009-01-22 14:33:29 +00:00
|
|
|
GstElement *element;
|
2008-10-09 12:29:12 +00:00
|
|
|
GArray *streams;
|
2009-01-29 12:31:27 +00:00
|
|
|
gboolean prepared;
|
2009-04-03 17:44:37 +00:00
|
|
|
gint active;
|
2009-01-29 12:31:27 +00:00
|
|
|
|
|
|
|
/* the pipeline for the media */
|
|
|
|
GstElement *pipeline;
|
2009-02-13 15:39:36 +00:00
|
|
|
GSource *source;
|
|
|
|
guint id;
|
|
|
|
|
|
|
|
gboolean is_live;
|
|
|
|
gboolean buffering;
|
|
|
|
GstState target_state;
|
2009-01-29 12:31:27 +00:00
|
|
|
|
|
|
|
/* RTP session manager */
|
|
|
|
GstElement *rtpbin;
|
|
|
|
|
2009-02-04 16:00:42 +00:00
|
|
|
/* the range of media */
|
|
|
|
GstRTSPTimeRange range;
|
2008-10-09 12:29:12 +00:00
|
|
|
};
|
|
|
|
|
2009-02-13 15:39:36 +00:00
|
|
|
/**
|
|
|
|
* GstRTSPMediaClass:
|
|
|
|
* @context: the main context for dispatching messages
|
|
|
|
* @loop: the mainloop for message.
|
|
|
|
* @thread: the thread dispatching messages.
|
|
|
|
* @handle_message: handle a message
|
|
|
|
*
|
|
|
|
* The RTSP media class
|
|
|
|
*/
|
2009-01-22 16:58:19 +00:00
|
|
|
struct _GstRTSPMediaClass {
|
2008-10-09 12:29:12 +00:00
|
|
|
GObjectClass parent_class;
|
2009-02-13 15:39:36 +00:00
|
|
|
|
|
|
|
/* thread for the mainloop */
|
|
|
|
GMainContext *context;
|
|
|
|
GMainLoop *loop;
|
|
|
|
GThread *thread;
|
|
|
|
|
2009-04-03 20:45:57 +00:00
|
|
|
/* vmethods */
|
2009-02-13 15:39:36 +00:00
|
|
|
gboolean (*handle_message) (GstRTSPMedia *media, GstMessage *message);
|
2009-04-03 20:45:57 +00:00
|
|
|
|
|
|
|
/* signals */
|
|
|
|
gboolean (*unprepared) (GstRTSPMedia *media);
|
2008-10-09 12:29:12 +00:00
|
|
|
};
|
|
|
|
|
2009-01-22 16:58:19 +00:00
|
|
|
GType gst_rtsp_media_get_type (void);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-01-29 12:31:27 +00:00
|
|
|
/* creating the media */
|
|
|
|
GstRTSPMedia * gst_rtsp_media_new (void);
|
|
|
|
|
2009-01-29 16:20:27 +00:00
|
|
|
void gst_rtsp_media_set_shared (GstRTSPMedia *media, gboolean shared);
|
|
|
|
gboolean gst_rtsp_media_is_shared (GstRTSPMedia *media);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-04-03 20:22:30 +00:00
|
|
|
void gst_rtsp_media_set_reusable (GstRTSPMedia *media, gboolean reusable);
|
|
|
|
gboolean gst_rtsp_media_is_reusable (GstRTSPMedia *media);
|
|
|
|
|
2009-01-29 12:31:27 +00:00
|
|
|
/* prepare the media for playback */
|
|
|
|
gboolean gst_rtsp_media_prepare (GstRTSPMedia *media);
|
2009-04-03 20:22:30 +00:00
|
|
|
gboolean gst_rtsp_media_is_prepared (GstRTSPMedia *media);
|
|
|
|
gboolean gst_rtsp_media_unprepare (GstRTSPMedia *media);
|
2009-01-29 12:31:27 +00:00
|
|
|
|
2009-01-29 16:20:27 +00:00
|
|
|
/* dealing with the media */
|
|
|
|
guint gst_rtsp_media_n_streams (GstRTSPMedia *media);
|
|
|
|
GstRTSPMediaStream * gst_rtsp_media_get_stream (GstRTSPMedia *media, guint idx);
|
|
|
|
|
2009-03-12 19:32:14 +00:00
|
|
|
gboolean gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range);
|
|
|
|
|
2009-03-11 15:45:12 +00:00
|
|
|
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 *trans);
|
2009-01-29 12:31:27 +00:00
|
|
|
|
2008-10-09 12:29:12 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_RTSP_MEDIA_H__ */
|