X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Frtsp-server%2Frtsp-media.h;h=0050addcd44d204b2a3f5f967b7fb6310507ec51;hb=348befdfd2e731a38c8638dc8ab96a7734c5692d;hp=8abf05fa44f98bf349ac386e1e71ad34c69d28f7;hpb=e866345f15291f60ece13bca98e36373810541a4;p=platform%2Fupstream%2Fgst-rtsp-server.git diff --git a/gst/rtsp-server/rtsp-media.h b/gst/rtsp-server/rtsp-media.h index 8abf05f..0050add 100644 --- a/gst/rtsp-server/rtsp-media.h +++ b/gst/rtsp-server/rtsp-media.h @@ -13,13 +13,13 @@ * * 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. + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. */ #include -#include -#include +#include +#include #ifndef __GST_RTSP_MEDIA_H__ #define __GST_RTSP_MEDIA_H__ @@ -36,241 +36,236 @@ G_BEGIN_DECLS #define GST_RTSP_MEDIA_CAST(obj) ((GstRTSPMedia*)(obj)) #define GST_RTSP_MEDIA_CLASS_CAST(klass) ((GstRTSPMediaClass*)(klass)) -typedef struct _GstRTSPMediaStream GstRTSPMediaStream; typedef struct _GstRTSPMedia GstRTSPMedia; typedef struct _GstRTSPMediaClass GstRTSPMediaClass; -typedef struct _GstRTSPMediaTrans GstRTSPMediaTrans; - -typedef gboolean (*GstRTSPSendFunc) (GstBuffer *buffer, guint8 channel, gpointer user_data); -typedef void (*GstRTSPKeepAliveFunc) (gpointer user_data); +typedef struct _GstRTSPMediaPrivate GstRTSPMediaPrivate; /** - * GstRTSPMediaTrans: - * @idx: a stream index - * @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. - * @keep_alive: keep alive callback - * @ka_user_data: data passed to @keep_alive - * @ka_notify: called when @ka_user_data is freed - * @active: if we are actively sending - * @timeout: if we timed out - * @transport: a transport description - * @rtpsource: the receiver rtp source object + * GstRTSPMediaStatus: + * @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 * - * A Transport description for stream @idx + * The state of the media pipeline. */ -struct _GstRTSPMediaTrans { - guint idx; - - GstRTSPSendFunc send_rtp; - GstRTSPSendFunc send_rtcp; - gpointer user_data; - GDestroyNotify notify; - - GstRTSPKeepAliveFunc keep_alive; - gpointer ka_user_data; - GDestroyNotify ka_notify; - gboolean active; - gboolean timeout; - - GstRTSPTransport *transport; - - GObject *rtpsource; -}; +typedef enum { + GST_RTSP_MEDIA_STATUS_UNPREPARED = 0, + GST_RTSP_MEDIA_STATUS_UNPREPARING = 1, + GST_RTSP_MEDIA_STATUS_PREPARING = 2, + GST_RTSP_MEDIA_STATUS_PREPARED = 3, + GST_RTSP_MEDIA_STATUS_SUSPENDED = 4, + GST_RTSP_MEDIA_STATUS_ERROR = 5 +} GstRTSPMediaStatus; /** - * GstRTSPMediaStream: - * - * @srcpad: the srcpad of the stream - * @payloader: the payloader of the format - * @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 - * @appsrc: the app source elements for RTP/RTCP - * @appsink: the app sink elements for RTP/RTCP - * @server_port: the server ports for this stream - * @caps_sig: the signal id for detecting caps - * @caps: the caps of the stream - * @tranports: the current transports being streamed + * GstRTSPSuspendMode: + * @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 * - * The definition of a media stream. The streams are identified by @id. + * 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. */ -struct _GstRTSPMediaStream { - 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; -}; +typedef enum { + GST_RTSP_SUSPEND_MODE_NONE = 0, + GST_RTSP_SUSPEND_MODE_PAUSE = 1, + GST_RTSP_SUSPEND_MODE_RESET = 2 +} GstRTSPSuspendMode; /** - * GstRTSPMediaStatus: - * @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 + * GstRTSPTransportMode: + * @GST_RTSP_TRANSPORT_MODE_PLAY: Transport supports PLAY mode + * @GST_RTSP_TRANSPORT_MODE_RECORD: Transport supports RECORD mode * - * The state of the media pipeline. + * The supported modes of the media. */ 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; + GST_RTSP_TRANSPORT_MODE_PLAY = 1, + GST_RTSP_TRANSPORT_MODE_RECORD = 2, +} GstRTSPTransportMode; + +#define GST_TYPE_RTSP_TRANSPORT_MODE (gst_rtsp_transport_mode_get_type()) +GType gst_rtsp_transport_mode_get_type (void); + +#define GST_TYPE_RTSP_SUSPEND_MODE (gst_rtsp_suspend_mode_get_type()) +GType gst_rtsp_suspend_mode_get_type (void); + +#include "rtsp-stream.h" +#include "rtsp-thread-pool.h" +#include "rtsp-permissions.h" +#include "rtsp-address-pool.h" +#include "rtsp-sdp.h" /** * GstRTSPMedia: - * @lock: for protecting the object - * @cond: for signaling the object - * @shared: if this media can be shared between clients - * @reusable: if this media can be reused after an unprepare - * @reused: if this media has been reused - * @element: the data providing element - * @streams: the different streams provided by @element - * @dynamic: list of dynamic elements managed by @element - * @status: the status of the media pipeline - * @active: the number of active connections - * @pipeline: the toplevel pipeline - * @fakesink: for making state changes async - * @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 - * @rtpbin: the rtpbin - * @range: the range of the media being streamed * * A class that contains the GStreamer element along with a list of - * #GstRTSPediaStream objects that can produce data. + * #GstRTSPStream objects that can produce data. * * This object is usually created from a #GstRTSPMediaFactory. */ struct _GstRTSPMedia { GObject parent; - GMutex *lock; - GCond *cond; - - gboolean shared; - gboolean reusable; - gboolean reused; - gboolean is_ipv6; - - GstElement *element; - GArray *streams; - GList *dynamic; - GstRTSPMediaStatus status; - gint active; - - /* the pipeline for the media */ - GstElement *pipeline; - GstElement *fakesink; - GSource *source; - guint id; - - gboolean is_live; - gboolean buffering; - GstState target_state; - - /* RTP session manager */ - GstElement *rtpbin; - - /* the range of media */ - GstRTSPTimeRange range; + /*< private >*/ + GstRTSPMediaPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; }; /** * GstRTSPMediaClass: - * @context: the main context for dispatching messages - * @loop: the mainloop for message. - * @thread: the thread dispatching messages. * @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. + * 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 * * The RTSP media class */ struct _GstRTSPMediaClass { 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); + gboolean (*handle_message) (GstRTSPMedia *media, GstMessage *message); + gboolean (*prepare) (GstRTSPMedia *media, GstRTSPThread *thread); + gboolean (*start_preroll) (GstRTSPMedia *media); + 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); + gboolean (*start_prepare) (GstRTSPMedia *media); /* signals */ - gboolean (*unprepared) (GstRTSPMedia *media); + 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); + + gboolean (*handle_sdp) (GstRTSPMedia *media, GstSDPMessage *sdp); + + void (*preparing) (GstRTSPMedia *media, GstRTSPStream * stream, guint idx); + void (*unpreparing) (GstRTSPMedia *media, GstRTSPStream * stream, guint idx); + /*< private >*/ + gpointer _gst_reserved[GST_PADDING_LARGE-1]; }; GType gst_rtsp_media_get_type (void); /* creating the media */ -GstRTSPMedia * gst_rtsp_media_new (void); +GstRTSPMedia * gst_rtsp_media_new (GstElement *element); +GstElement * gst_rtsp_media_get_element (GstRTSPMedia *media); + +void gst_rtsp_media_take_pipeline (GstRTSPMedia *media, GstPipeline *pipeline); + +GstRTSPMediaStatus gst_rtsp_media_get_status (GstRTSPMedia *media); + +void gst_rtsp_media_set_permissions (GstRTSPMedia *media, + GstRTSPPermissions *permissions); +GstRTSPPermissions * gst_rtsp_media_get_permissions (GstRTSPMedia *media); void gst_rtsp_media_set_shared (GstRTSPMedia *media, gboolean shared); gboolean gst_rtsp_media_is_shared (GstRTSPMedia *media); +void gst_rtsp_media_set_transport_mode (GstRTSPMedia *media, GstRTSPTransportMode mode); +GstRTSPTransportMode gst_rtsp_media_get_transport_mode (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_profiles (GstRTSPMedia *media, GstRTSPProfile profiles); +GstRTSPProfile gst_rtsp_media_get_profiles (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); + +void gst_rtsp_media_set_address_pool (GstRTSPMedia *media, GstRTSPAddressPool *pool); +GstRTSPAddressPool * gst_rtsp_media_get_address_pool (GstRTSPMedia *media); + +void gst_rtsp_media_set_buffer_size (GstRTSPMedia *media, guint size); +guint gst_rtsp_media_get_buffer_size (GstRTSPMedia *media); + +void gst_rtsp_media_set_retransmission_time (GstRTSPMedia *media, GstClockTime time); +GstClockTime gst_rtsp_media_get_retransmission_time (GstRTSPMedia *media); + +void gst_rtsp_media_set_latency (GstRTSPMedia *media, guint latency); +guint gst_rtsp_media_get_latency (GstRTSPMedia *media); + +void gst_rtsp_media_use_time_provider (GstRTSPMedia *media, gboolean time_provider); +gboolean gst_rtsp_media_is_time_provider (GstRTSPMedia *media); +GstNetTimeProvider * gst_rtsp_media_get_time_provider (GstRTSPMedia *media, + const gchar *address, guint16 port); + /* prepare the media for playback */ -gboolean gst_rtsp_media_prepare (GstRTSPMedia *media); -gboolean gst_rtsp_media_is_prepared (GstRTSPMedia *media); +gboolean gst_rtsp_media_prepare (GstRTSPMedia *media, GstRTSPThread *thread); gboolean gst_rtsp_media_unprepare (GstRTSPMedia *media); -/* dealing with the media */ -guint gst_rtsp_media_n_streams (GstRTSPMedia *media); -GstRTSPMediaStream * gst_rtsp_media_get_stream (GstRTSPMedia *media, guint idx); +void gst_rtsp_media_set_suspend_mode (GstRTSPMedia *media, GstRTSPSuspendMode mode); +GstRTSPSuspendMode gst_rtsp_media_get_suspend_mode (GstRTSPMedia *media); -gboolean gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range); +gboolean gst_rtsp_media_suspend (GstRTSPMedia *media); +gboolean gst_rtsp_media_unsuspend (GstRTSPMedia *media); -GstFlowReturn gst_rtsp_media_stream_rtp (GstRTSPMediaStream *stream, GstBuffer *buffer); -GstFlowReturn gst_rtsp_media_stream_rtcp (GstRTSPMediaStream *stream, GstBuffer *buffer); +gboolean gst_rtsp_media_setup_sdp (GstRTSPMedia * media, GstSDPMessage * sdp, + GstSDPInfo * info); -gboolean gst_rtsp_media_set_state (GstRTSPMedia *media, GstState state, GArray *trans); +gboolean gst_rtsp_media_handle_sdp (GstRTSPMedia * media, GstSDPMessage * sdp); -void gst_rtsp_media_remove_elements (GstRTSPMedia *media); + +/* creating streams */ +void gst_rtsp_media_collect_streams (GstRTSPMedia *media); +GstRTSPStream * gst_rtsp_media_create_stream (GstRTSPMedia *media, + GstElement *payloader, + GstPad *pad); + +/* dealing with the media */ +GstClock * gst_rtsp_media_get_clock (GstRTSPMedia *media); +GstClockTime gst_rtsp_media_get_base_time (GstRTSPMedia *media); + +guint gst_rtsp_media_n_streams (GstRTSPMedia *media); +GstRTSPStream * gst_rtsp_media_get_stream (GstRTSPMedia *media, guint idx); +GstRTSPStream * gst_rtsp_media_find_stream (GstRTSPMedia *media, const gchar * control); + +gboolean gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range); +gchar * gst_rtsp_media_get_range_string (GstRTSPMedia *media, + gboolean play, + GstRTSPRangeUnit unit); + +gboolean gst_rtsp_media_set_state (GstRTSPMedia *media, GstState state, + GPtrArray *transports); +void gst_rtsp_media_set_pipeline_state (GstRTSPMedia * media, + GstState state); +GstStateChangeReturn gst_rtsp_media_set_target_state (GstRTSPMedia * media, GstState state, gboolean do_state); +void gst_rtsp_media_set_status (GstRTSPMedia * media, GstRTSPMediaStatus status); + +GstElement * gst_rtsp_media_get_pipeline (GstRTSPMedia * media); +GstElement * gst_rtsp_media_get_rtpbin (GstRTSPMedia * media); G_END_DECLS