gst/rtpmanager/gstrtpbin.*: Add signal to notify listeners when a sender becomes...
[platform/upstream/gst-plugins-good.git] / gst / rtpmanager / rtpsession.h
index 9082d9d..dd3fbc1 100644 (file)
@@ -1,5 +1,5 @@
 /* GStreamer
- * Copyright (C) <2007> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -72,6 +72,7 @@ typedef GstFlowReturn (*RTPSessionSendRTP) (RTPSession *sess, RTPSource *src, Gs
  * @sess: an #RTPSession
  * @src: the #RTPSource
  * @buffer: the RTCP buffer ready for sending
+ * @eos: if an EOS event should be pushed
  * @user_data: user data specified when registering
  *
  * This callback will be called when @sess has @buffer ready for sending to
@@ -79,31 +80,34 @@ typedef GstFlowReturn (*RTPSessionSendRTP) (RTPSession *sess, RTPSource *src, Gs
  *
  * Returns: a #GstFlowReturn.
  */
-typedef GstFlowReturn (*RTPSessionSendRTCP) (RTPSession *sess, RTPSource *src, GstBuffer *buffer, gpointer user_data);
+typedef GstFlowReturn (*RTPSessionSendRTCP) (RTPSession *sess, RTPSource *src, GstBuffer *buffer, 
+    gboolean eos, gpointer user_data);
 
 /**
- * RTPSessionClockRate:
+ * RTPSessionSyncRTCP:
  * @sess: an #RTPSession
- * @payload: the payload
+ * @src: the #RTPSource
+ * @buffer: the RTCP buffer ready for synchronisation
  * @user_data: user data specified when registering
  *
- * This callback will be called when @sess needs the clock-rate of @payload.
+ * This callback will be called when @sess has an SR @buffer ready for doing
+ * synchronisation between streams.
  *
- * Returns: the clock-rate of @pt.
+ * Returns: a #GstFlowReturn.
  */
-typedef gint (*RTPSessionClockRate) (RTPSession *sess, guint8 payload, gpointer user_data);
+typedef GstFlowReturn (*RTPSessionSyncRTCP) (RTPSession *sess, RTPSource *src, GstBuffer *buffer, gpointer user_data);
 
 /**
- * RTPSessionGetTime:
+ * RTPSessionClockRate:
  * @sess: an #RTPSession
+ * @payload: the payload
  * @user_data: user data specified when registering
  *
- * This callback will be called when @sess needs the current time in
- * nanoseconds.
+ * This callback will be called when @sess needs the clock-rate of @payload.
  *
- * Returns: a #GstClockTime with the current time in nanoseconds.
+ * Returns: the clock-rate of @pt.
  */
-typedef GstClockTime (*RTPSessionGetTime) (RTPSession *sess, gpointer user_data);
+typedef gint (*RTPSessionClockRate) (RTPSession *sess, guint8 payload, gpointer user_data);
 
 /**
  * RTPSessionReconsider:
@@ -121,7 +125,7 @@ typedef void (*RTPSessionReconsider) (RTPSession *sess, gpointer user_data);
  * @RTPSessionProcessRTP: callback to process RTP packets
  * @RTPSessionSendRTP: callback for sending RTP packets
  * @RTPSessionSendRTCP: callback for sending RTCP packets
- * @RTPSessionGetTime: callback for returning the current time
+ * @RTPSessionSyncRTCP: callback for handling SR packets
  * @RTPSessionReconsider: callback for reconsidering the timeout
  *
  * These callbacks can be installed on the session manager to get notification
@@ -131,13 +135,27 @@ typedef void (*RTPSessionReconsider) (RTPSession *sess, gpointer user_data);
 typedef struct {
   RTPSessionProcessRTP  process_rtp;
   RTPSessionSendRTP     send_rtp;
+  RTPSessionSyncRTCP    sync_rtcp;
   RTPSessionSendRTCP    send_rtcp;
   RTPSessionClockRate   clock_rate;
-  RTPSessionGetTime     get_time;
   RTPSessionReconsider  reconsider;
 } RTPSessionCallbacks;
 
 /**
+ * RTPConflictingAddress:
+ * @address: #GstNetAddress which conflicted
+ * @last_conflict_time: time when the last conflict was seen
+ *
+ * This structure is used to account for addresses that have conflicted to find
+ * loops.
+ */
+
+typedef struct {
+  GstNetAddress address;
+  GstClockTime time;
+} RTPConflictingAddress;
+
+/**
  * RTPSession:
  * @lock: lock to protect the session
  * @source: the source of this session
@@ -147,6 +165,8 @@ typedef struct {
  * @activecount: the number of active sources
  * @callbacks: callbacks
  * @user_data: user data passed in callbacks
+ * @stats: session statistics
+ * @conflicting_addresses: GList of conflicting addresses
  *
  * The RTP session manager object
  */
@@ -160,15 +180,6 @@ struct _RTPSession {
 
   RTPSource    *source;
 
-  /* info for creating reports */
-  gchar        *cname;
-  gchar        *name;
-  gchar        *email;
-  gchar        *phone;
-  gchar        *location;
-  gchar        *tool;
-  gchar        *note;
-
   /* for sender/receiver counting */
   guint32       key;
   guint32       mask_idx;
@@ -181,14 +192,21 @@ struct _RTPSession {
   GstClockTime  last_rtcp_send_time;
   gboolean      first_rtcp;
 
-  GstBuffer    *bye_packet;
   gchar        *bye_reason;
   gboolean      sent_bye;
 
-  RTPSessionCallbacks callbacks;
-  gpointer            user_data;
+  RTPSessionCallbacks   callbacks;
+  gpointer              process_rtp_user_data;
+  gpointer              send_rtp_user_data;
+  gpointer              send_rtcp_user_data;
+  gpointer              sync_rtcp_user_data;
+  gpointer              clock_rate_user_data;
+  gpointer              reconsider_user_data;
 
   RTPSessionStats stats;
+
+  GList         *conflicting_addresses;
+  gboolean      change_ssrc;
 };
 
 /**
@@ -205,39 +223,54 @@ struct _RTPSessionClass {
   void (*on_new_ssrc)       (RTPSession *sess, RTPSource *source);
   void (*on_ssrc_collision) (RTPSession *sess, RTPSource *source);
   void (*on_ssrc_validated) (RTPSession *sess, RTPSource *source);
+  void (*on_ssrc_active)    (RTPSession *sess, RTPSource *source);
+  void (*on_ssrc_sdes)      (RTPSession *sess, RTPSource *source);
   void (*on_bye_ssrc)       (RTPSession *sess, RTPSource *source);
   void (*on_bye_timeout)    (RTPSession *sess, RTPSource *source);
   void (*on_timeout)        (RTPSession *sess, RTPSource *source);
+  void (*on_sender_timeout) (RTPSession *sess, RTPSource *source);
 };
 
 GType rtp_session_get_type (void);
 
 /* create and configure */
 RTPSession*     rtp_session_new           (void);
-void            rtp_session_set_callbacks          (RTPSession *sess, 
+void            rtp_session_set_callbacks          (RTPSession *sess,
                                                    RTPSessionCallbacks *callbacks,
                                                     gpointer user_data);
+void            rtp_session_set_process_rtp_callback   (RTPSession * sess,
+                                                    RTPSessionProcessRTP callback,
+                                                    gpointer user_data);
+void            rtp_session_set_send_rtp_callback  (RTPSession * sess,
+                                                    RTPSessionSendRTP callback,
+                                                    gpointer user_data);
+void            rtp_session_set_send_rtcp_callback   (RTPSession * sess,
+                                                    RTPSessionSendRTCP callback,
+                                                    gpointer user_data);
+void            rtp_session_set_sync_rtcp_callback   (RTPSession * sess,
+                                                    RTPSessionSyncRTCP callback,
+                                                    gpointer user_data);
+void            rtp_session_set_clock_rate_callback   (RTPSession * sess,
+                                                    RTPSessionClockRate callback,
+                                                    gpointer user_data);
+void            rtp_session_set_reconsider_callback (RTPSession * sess,
+                                                    RTPSessionReconsider callback,
+                                                    gpointer user_data);
 void            rtp_session_set_bandwidth          (RTPSession *sess, gdouble bandwidth);
 gdouble         rtp_session_get_bandwidth          (RTPSession *sess);
 void            rtp_session_set_rtcp_fraction      (RTPSession *sess, gdouble fraction);
 gdouble         rtp_session_get_rtcp_fraction      (RTPSession *sess);
 
-void            rtp_session_set_cname              (RTPSession *sess, const gchar *cname);
-gchar*          rtp_session_get_cname              (RTPSession *sess);
-void            rtp_session_set_name               (RTPSession *sess, const gchar *name);
-gchar*          rtp_session_get_name               (RTPSession *sess);
-void            rtp_session_set_email              (RTPSession *sess, const gchar *email);
-gchar*          rtp_session_get_email              (RTPSession *sess);
-void            rtp_session_set_phone              (RTPSession *sess, const gchar *phone);
-gchar*          rtp_session_get_phone              (RTPSession *sess);
-void            rtp_session_set_location           (RTPSession *sess, const gchar *location);
-gchar*          rtp_session_get_location           (RTPSession *sess);
-void            rtp_session_set_tool               (RTPSession *sess, const gchar *tool);
-gchar*          rtp_session_get_tool               (RTPSession *sess);
-void            rtp_session_set_note               (RTPSession *sess, const gchar *note);
-gchar*          rtp_session_get_note               (RTPSession *sess);
+gboolean        rtp_session_set_sdes_string        (RTPSession *sess, GstRTCPSDESType type,
+                                                    const gchar *cname);
+gchar*          rtp_session_get_sdes_string        (RTPSession *sess, GstRTCPSDESType type);
 
 /* handling sources */
+RTPSource*      rtp_session_get_internal_source    (RTPSession *sess);
+
+void            rtp_session_set_internal_ssrc      (RTPSession *sess, guint32 ssrc);
+guint32         rtp_session_get_internal_ssrc      (RTPSession *sess);
+
 gboolean        rtp_session_add_source             (RTPSession *sess, RTPSource *src);
 guint           rtp_session_get_num_sources        (RTPSession *sess);
 guint           rtp_session_get_num_active_sources (RTPSession *sess);
@@ -246,17 +279,17 @@ RTPSource*      rtp_session_get_source_by_cname    (RTPSession *sess, const gcha
 RTPSource*      rtp_session_create_source          (RTPSession *sess);
 
 /* processing packets from receivers */
-GstFlowReturn   rtp_session_process_rtp            (RTPSession *sess, GstBuffer *buffer);
-GstFlowReturn   rtp_session_process_rtcp           (RTPSession *sess, GstBuffer *buffer);
+GstFlowReturn   rtp_session_process_rtp            (RTPSession *sess, GstBuffer *buffer, GstClockTime current_time, guint64 ntpnstime);
+GstFlowReturn   rtp_session_process_rtcp           (RTPSession *sess, GstBuffer *buffer, GstClockTime current_time);
 
 /* processing packets for sending */
-GstFlowReturn   rtp_session_send_rtp               (RTPSession *sess, GstBuffer *buffer);
+GstFlowReturn   rtp_session_send_rtp               (RTPSession *sess, GstBuffer *buffer, GstClockTime current_time, guint64 ntpnstime);
 
 /* stopping the session */
-GstFlowReturn   rtp_session_send_bye               (RTPSession *sess, const gchar *reason);
+GstFlowReturn   rtp_session_send_bye               (RTPSession *sess, const gchar *reason, GstClockTime current_time);
 
 /* get interval for next RTCP interval */
-GstClockTime    rtp_session_next_timeout          (RTPSession *sess, GstClockTime time);
-GstFlowReturn   rtp_session_on_timeout            (RTPSession *sess, GstClockTime time);
+GstClockTime    rtp_session_next_timeout           (RTPSession *sess, GstClockTime current_time);
+GstFlowReturn   rtp_session_on_timeout             (RTPSession *sess, GstClockTime current_time, guint64 ntpnstime);
 
 #endif /* __RTP_SESSION_H__ */