[farsight2/master] Add UdpStream to the FsRawUdpStreamTransmitter

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:19:23 PST 2008


---
 transmitters/rawudp/fs-rawudp-stream-transmitter.c |   69 ++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/transmitters/rawudp/fs-rawudp-stream-transmitter.c b/transmitters/rawudp/fs-rawudp-stream-transmitter.c
index 289ec28..17bc5fb 100644
--- a/transmitters/rawudp/fs-rawudp-stream-transmitter.c
+++ b/transmitters/rawudp/fs-rawudp-stream-transmitter.c
@@ -36,6 +36,8 @@
 
 #include "fs-rawudp-stream-transmitter.h"
 
+#include <gst/farsight/fs-stream.h>
+
 #include <gst/gst.h>
 
 /* Signals */
@@ -66,6 +68,8 @@ struct _FsRawUdpStreamTransmitterPrivate
 
   gboolean sending;
 
+  UdpStream *udpstream;
+
   gchar *stun_ip;
   guint stun_port;
 
@@ -205,6 +209,12 @@ fs_rawudp_stream_transmitter_finalize (GObject *object)
     self->priv->prefered_local_candidates = NULL;
   }
 
+  if (self->priv->udpstream) {
+    fs_rawudp_transmitter_put_udpstream (self->priv->transmitter,
+      self->priv->udpstream);
+    self->priv->udpstream = NULL;
+  }
+
   parent_class->finalize (object);
 }
 
@@ -263,6 +273,65 @@ fs_rawudp_stream_transmitter_set_property (GObject *object,
   }
 }
 
+static gboolean
+fs_rawudp_stream_transmitter_build (FsRawUdpStreamTransmitter *self,
+  GError **error)
+{
+  const gchar *ip = NULL, *rtcp_ip = NULL;
+  guint port = 0, rtcp_port = 0;
+  GList *item;
+
+  for (item = g_list_first (self->priv->prefered_local_candidates);
+       item;
+       item = g_list_next (item)) {
+    FsCandidate *candidate = item->data;
+
+    if (candidate->proto != FS_NETWORK_PROTOCOL_UDP) {
+      *error = g_error_new (FS_STREAM_ERROR, FS_STREAM_ERROR_INVALID_ARGUMENTS,
+        "You set prefered candidate of a type %d that is not"
+        " FS_NETWORK_PROTOCOL_UDP",
+        candidate->proto);
+      return FALSE;
+    }
+
+    switch (candidate->component_id) {
+      case 1:  /* RTP */
+        if (ip) {
+          *error = g_error_new (FS_STREAM_ERROR,
+            FS_STREAM_ERROR_INVALID_ARGUMENTS,
+            "You set more than one candidate for component 1");
+          return FALSE;
+        }
+        ip = candidate->ip;
+        port = candidate->port;
+        break;
+      case 2:  /* RTCP */
+        if (rtcp_ip) {
+          *error = g_error_new (FS_STREAM_ERROR,
+            FS_STREAM_ERROR_INVALID_ARGUMENTS,
+            "You set more than one candidate for component 2");
+          return FALSE;
+        }
+        rtcp_ip = candidate->ip;
+        rtcp_port = candidate->port;
+        break;
+      default:
+      *error = g_error_new (FS_STREAM_ERROR, FS_STREAM_ERROR_INVALID_ARGUMENTS,
+        "Only components 1 and 2 are supported, %d isnt",
+        candidate->component_id);
+      return FALSE;
+    }
+  }
+
+
+  self->priv->udpstream =
+    fs_rawudp_transmitter_get_udpstream (self->priv->transmitter, ip, port,
+      rtcp_ip, rtcp_port, error);
+  if (!self->priv->udpstream)
+    return FALSE;
+
+  return TRUE;
+}
 
 /**
  * fs_rawudp_stream_transmitter_add_remote_candidate
-- 
1.5.6.5




More information about the farsight-commits mailing list