Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for latest master, code style fixes required by hook #2

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
6 changes: 6 additions & 0 deletions src/gst-plugins/rtpendpoint/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ set(KMS_RTPENDPOINT_SOURCES
kmsrtpendpoint.c
kmssocketutils.c
kmsrandom.c
kmsrtpfilterutils.c
kmssiprtpendpoint.c
kmssiprtpsession.c
kmssipsrtpsession.c
kmsrtpendpoint-plugin-init.c
)

set(KMS_RTPENDPOINT_HEADERS
kmsrtpendpoint.h
kmssocketutils.h
kmssiprtpendpoint.h
)

set(ENUM_HEADERS
Expand Down
14 changes: 14 additions & 0 deletions src/gst-plugins/rtpendpoint/kms-rtp-enumtypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef __KMS_KMS_RTP_ENUMTYPES_ENUM_TYPES_H__
#define __KMS_KMS_RTP_ENUMTYPES_ENUM_TYPES_H__

#include <glib-object.h>

G_BEGIN_DECLS

/* enumerations from "kmsrtpsdescryptosuite.h" */
GType kms_rtp_sdes_crypto_suite_get_type (void);
#define KMS_TYPE_RTP_SDES_CRYPTO_SUITE (kms_rtp_sdes_crypto_suite_get_type())

G_END_DECLS

#endif /* __KMS_KMS_RTP_ENUMTYPES_ENUM_TYPES_H__ */
133 changes: 133 additions & 0 deletions src/gst-plugins/rtpendpoint/kmsrtpconnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include "kmsrtpconnection.h"
#include "kmssocketutils.h"
#include "kmsrtpfilterutils.h"
#include <commons/constants.h>

#define GST_CAT_DEFAULT kmsrtpconnection
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
Expand Down Expand Up @@ -388,3 +390,134 @@ kms_rtp_connection_interface_init (KmsIRtpConnectionInterface * iface)
iface->set_latency_callback = kms_rtp_base_connection_set_latency_callback;
iface->collect_latency_stats = kms_rtp_connection_collect_latency_stats;
}


void
kms_sip_rtp_connection_retrieve_sockets (KmsRtpConnection *conn, GSocket **rtp, GSocket **rtcp)
{
if (conn != NULL) {
// Retrieve the sockets
*rtcp = g_object_ref (conn->priv->rtcp_socket);
*rtp = g_object_ref (conn->priv->rtp_socket);

// remove sockets from multiudpsink and udpsrc so that they are disconnected from previous endpoint
// so that they are not released on previoues endpoint finalization
g_object_set (conn->priv->rtp_udpsink, "close-socket", FALSE, NULL);
g_object_set (conn->priv->rtcp_udpsink, "close-socket", FALSE, NULL);
g_object_set (conn->priv->rtp_udpsrc, "close-socket", FALSE, NULL);
g_object_set (conn->priv->rtcp_udpsrc, "close-socket", FALSE, NULL);

// g_object_set (conn->priv->rtp_udpsink, "socket", NULL);
// g_object_set (conn->priv->rtp_udpsrc, "socket", NULL);
// g_object_set (conn->priv->rtcp_udpsink, "socket", NULL);
// g_object_set (conn->priv->rtcp_udpsrc, "socket", NULL);

conn->priv->rtcp_socket = NULL;
conn->priv->rtp_socket = NULL;
}
}


void
kms_sip_rtp_connection_add_probes (KmsRtpConnection *conn, SipFilterSsrcInfo* filter_info, gulong *rtp_probe_id, gulong *rtcp_probe_id)
{
KmsRtpConnectionPrivate *priv = conn->priv;

// If we are reusing sockets, it is possible that packets from old connection (old ssrcs) arrive to the sockets
// They should be avoided as they may auto setup the new connection for old SSRCs, preventing the new connection to succed
GstPad *pad;

pad = gst_element_get_static_pad (priv->rtcp_udpsrc, "src");

*rtcp_probe_id = kms_sip_rtp_filter_setup_probe_rtcp (pad, filter_info);
gst_object_unref (pad);

pad = gst_element_get_static_pad (priv->rtp_udpsrc, "src");
*rtp_probe_id = kms_sip_rtp_filter_setup_probe_rtp (pad, filter_info);
gst_object_unref (pad);
}


KmsRtpConnection *
kms_sip_rtp_connection_new (guint16 min_port, guint16 max_port, gboolean use_ipv6, GSocket *rtp_sock, GSocket *rtcp_sock,
SipFilterSsrcInfo* filter_info, gulong *rtp_probe_id, gulong *rtcp_probe_id)
{
// TODO: When this integrated in kms-elements we can modify kms_rtp_connection_new to allow espcifying
// the gstreamer object factory for the connection, so that we can simplify this function
GObject *obj;
KmsRtpConnection *conn;
KmsRtpConnectionPrivate *priv;
GSocketFamily socket_family;

obj = g_object_new (KMS_TYPE_RTP_CONNECTION, NULL);
conn = KMS_RTP_CONNECTION (obj);
priv = conn->priv;

if (use_ipv6) {
socket_family = G_SOCKET_FAMILY_IPV6;
} else {
socket_family = G_SOCKET_FAMILY_IPV4;
}

// TODO: This is what we need to update on kms_rtp_connection-new
if ((rtp_sock != NULL) && (rtcp_sock != NULL)) {
priv->rtp_socket = rtp_sock;
priv->rtcp_socket = rtcp_sock;
} else {
// ^^^^^^^^^^^^^^^^^^^^^^^^^
// TODO: Up to here
if (!kms_rtp_connection_get_rtp_rtcp_sockets
(&priv->rtp_socket, &priv->rtcp_socket, min_port, max_port,
socket_family)) {
GST_ERROR_OBJECT (obj, "Cannot get ports");
g_object_unref (obj);
return NULL;
}
}

priv->rtp_udpsink = gst_element_factory_make ("multiudpsink", NULL);
priv->rtp_udpsrc = gst_element_factory_make ("udpsrc", NULL);

priv->rtcp_udpsink = gst_element_factory_make ("multiudpsink", NULL);
priv->rtcp_udpsrc = gst_element_factory_make ("udpsrc", NULL);

kms_sip_rtp_connection_add_probes (conn, filter_info, rtp_probe_id, rtcp_probe_id);

g_object_set (priv->rtp_udpsink, "socket", priv->rtp_socket,
"sync", FALSE, "async", FALSE, NULL);
g_object_set (priv->rtp_udpsrc, "socket", priv->rtp_socket, "auto-multicast",
FALSE, NULL);

g_object_set (priv->rtcp_udpsink, "socket", priv->rtcp_socket,
"sync", FALSE, "async", FALSE, NULL);
g_object_set (priv->rtcp_udpsrc, "socket", priv->rtcp_socket,
"auto-multicast", FALSE, NULL);


kms_i_rtp_connection_connected_signal (KMS_I_RTP_CONNECTION (conn));



return conn;
}

void
kms_sip_rtp_connection_release_probes (KmsRtpConnection *conn, gulong rtp_probe_id, gulong rtcp_probe_id)
{
KmsRtpConnectionPrivate *priv;
GstPad *pad;

priv = conn->priv;

// Release RTCP probe
pad = gst_element_get_static_pad (priv->rtcp_udpsrc, "src");
kms_sip_rtp_filter_release_probe_rtcp (pad, rtcp_probe_id);
gst_object_unref (pad);

// Release RTP probe
pad = gst_element_get_static_pad (priv->rtp_udpsrc, "src");
kms_sip_rtp_filter_release_probe_rtp (pad, rtp_probe_id);
gst_object_unref (pad);
}


16 changes: 16 additions & 0 deletions src/gst-plugins/rtpendpoint/kmsrtpconnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#define __KMS_RTP_CONNECTION_H__

#include "kmsrtpbaseconnection.h"
#include "kmsrtpfilterutils.h"
#include <gst/sdp/gstsdpmessage.h>
#include <gio/gio.h>

G_BEGIN_DECLS
#define KMS_TYPE_RTP_CONNECTION \
Expand Down Expand Up @@ -53,5 +56,18 @@ GType kms_rtp_connection_get_type (void);
KmsRtpConnection *kms_rtp_connection_new (guint16 min_port, guint16 max_port,
gboolean use_ipv6);

KmsRtpConnection *
kms_sip_rtp_connection_new (guint16 min_port, guint16 max_port, gboolean use_ipv6, GSocket *rtp_sock, GSocket *rtcp_sock,
SipFilterSsrcInfo* filter_info, gulong *rtp_probe_id, gulong *rtcp_probe_id);

void
kms_sip_rtp_connection_add_probes (KmsRtpConnection *conn, SipFilterSsrcInfo* filter_info, gulong *rtp_probe_id, gulong *rtcp_probe_id);

void
kms_sip_rtp_connection_release_probes (KmsRtpConnection *conn, gulong rtp_probe_id, gulong rtcp_probe_id);

void kms_sip_rtp_connection_retrieve_sockets (KmsRtpConnection *conn, GSocket **rtp, GSocket **rtcp);


G_END_DECLS
#endif /* __KMS_RTP_CONNECTION_H__ */
41 changes: 41 additions & 0 deletions src/gst-plugins/rtpendpoint/kmsrtpendpoint-plugin-init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* (C) Copyright 2013 Kurento (http://kurento.org/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif


#include "kmsrtpendpoint.h"
#include "kmssiprtpendpoint.h"

#define RTP_PLUGIN_NAME "rtpendpoint"
#define SIP_RTP_PLUGIN_NAME "siprtpendpoint"

gboolean
kms_rtp_endpoint_plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, RTP_PLUGIN_NAME, GST_RANK_NONE, KMS_TYPE_RTP_ENDPOINT) &&
gst_element_register (plugin, SIP_RTP_PLUGIN_NAME, GST_RANK_NONE, KMS_TYPE_SIP_RTP_ENDPOINT);
}


GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
kmsrtpendpoint,
"Kurento rtp endpoint",
kms_rtp_endpoint_plugin_init, VERSION, GST_LICENSE_UNKNOWN,
"Kurento Elements", "http://kurento.com/")
16 changes: 1 addition & 15 deletions src/gst-plugins/rtpendpoint/kmsrtpendpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ kms_rtp_endpoint_class_init (KmsRtpEndpointClass * klass)
"RtpEndpoint",
"RTP/Stream/RtpEndpoint",
"Rtp Endpoint element",
"José Antonio Santos Cadenas <[email protected]>");
"Jose Antonio Santos Cadenas <[email protected]>");
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, PLUGIN_NAME, 0, PLUGIN_NAME);

base_sdp_endpoint_class = KMS_BASE_SDP_ENDPOINT_CLASS (klass);
Expand Down Expand Up @@ -1171,17 +1171,3 @@ kms_rtp_endpoint_init (KmsRtpEndpoint * self)
"max-video-recv-bandwidth", 0, NULL);
/* FIXME: remove max-video-recv-bandwidth when it b=AS:X is in the SDP offer */
}

gboolean
kms_rtp_endpoint_plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, PLUGIN_NAME, GST_RANK_NONE,
KMS_TYPE_RTP_ENDPOINT);
}

GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
kmsrtpendpoint,
"Kurento rtp endpoint",
kms_rtp_endpoint_plugin_init, VERSION, GST_LICENSE_UNKNOWN,
"Kurento Elements", "http://kurento.com/")
Loading