Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.
/ kms-core Public archive

Commit

Permalink
KmsBaseRtpEndpoint: Add property "offer-dir"
Browse files Browse the repository at this point in the history
Allows to specify what is the desired direction for a WebRtcEndpoint:
the Clients can now define whether this will be a "sendonly" or
"recvonly". Before, it always was a "sendrecv".
  • Loading branch information
j1elo committed Apr 19, 2018
1 parent 6346a68 commit 0738217
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
41 changes: 38 additions & 3 deletions src/gst-plugins/commons/kmsbasertpendpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "kms-core-enumtypes.h"
#include "kms-core-marshal.h"
#include "sdp_utils.h"
#include "sdpagent/kmssdpmediadirext.h"
#include "sdpagent/kmssdpulpfecext.h"
#include "sdpagent/kmssdpredundantext.h"
#include "sdpagent/kmssdprtpavpfmediahandler.h"
Expand Down Expand Up @@ -208,6 +209,7 @@ struct _KmsBaseRtpEndpointPrivate

GstElement *rtpbin;
KmsMediaState media_state;
GstSDPDirection offer_dir;

gboolean support_fec;
gboolean rtcp_mux;
Expand Down Expand Up @@ -261,6 +263,7 @@ enum

static guint obj_signals[LAST_SIGNAL] = { 0 };

#define DEFAULT_OFFER_DIR GST_SDP_DIRECTION_SENDRECV
#define DEFAULT_RTCP_MUX FALSE
#define DEFAULT_RTCP_NACK FALSE
#define DEFAULT_RTCP_REMB FALSE
Expand All @@ -284,6 +287,7 @@ enum
PROP_MIN_PORT,
PROP_MAX_PORT,
PROP_SUPPORT_FEC,
PROP_OFFER_DIR,
PROP_LAST
};

Expand Down Expand Up @@ -492,6 +496,15 @@ kms_base_rtp_endpoint_config_rtp_hdr_ext (KmsBaseRtpEndpoint * self,

/* Media handler management begin */

static GstSDPDirection
on_offer_media_direction (KmsSdpMediaDirectionExt * ext,
KmsBaseRtpEndpoint * self)
{
GstSDPDirection offer_dir;

g_object_get (self, "offer-dir", &offer_dir, NULL);
}

static gboolean
on_offered_ulp_fec_cb (KmsSdpUlpFecExt * ext, guint pt, guint clock_rate,
gpointer user_data)
Expand All @@ -518,10 +531,21 @@ static void
kms_base_rtp_configure_extensions (KmsBaseRtpEndpoint * self,
const gchar * media, KmsSdpMediaHandler * handler)
{
KmsSdpMediaDirectionExt *mediadirext;
KmsSdpUlpFecExt *ulpfecext;
KmsSdpRedundantExt *redext;
ExtData *edata;

mediadirext = kms_sdp_media_direction_ext_new ();
g_signal_connect (mediadirext, "on-offer-media-direction",
G_CALLBACK (on_offer_media_direction), self);
kms_sdp_media_handler_add_media_extension (handler,
KMS_I_SDP_MEDIA_EXTENSION (mediadirext));

if (!self->priv->support_fec) {
return;
}

edata = ext_data_new ();
kms_list_append (self->priv->prot_medias, g_strdup (media), edata);

Expand Down Expand Up @@ -579,9 +603,7 @@ kms_base_rtp_create_media_handler (KmsBaseSdpEndpoint * base_sdp,
err = NULL;
}

if (self->priv->support_fec) {
kms_base_rtp_configure_extensions (self, media, *handler);
}
kms_base_rtp_configure_extensions (self, media, *handler);
}

/* Media handler management end */
Expand Down Expand Up @@ -2375,6 +2397,9 @@ kms_base_rtp_endpoint_set_property (GObject * object, guint property_id,
self->priv->max_port = v;
break;
}
case PROP_OFFER_DIR:
self->priv->offer_dir = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
Expand Down Expand Up @@ -2415,6 +2440,9 @@ kms_base_rtp_endpoint_get_property (GObject * object, guint property_id,
case PROP_MEDIA_STATE:
g_value_set_enum (value, self->priv->media_state);
break;
case PROP_OFFER_DIR:
g_value_set_enum (value, self->priv->offer_dir);
break;
case PROP_REMB_PARAMS:
if (self->priv->rl != NULL) {
GstStructure *params = gst_structure_new_empty ("remb-params");
Expand Down Expand Up @@ -2823,6 +2851,11 @@ kms_base_rtp_endpoint_class_init (KmsBaseRtpEndpointClass * klass)
KMS_TYPE_MEDIA_STATE, KMS_MEDIA_STATE_DISCONNECTED,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property (object_class, PROP_OFFER_DIR,
g_param_spec_enum ("offer-dir", "Offer direction", "Offer direction",
KMS_TYPE_SDP_DIRECTION, DEFAULT_OFFER_DIR,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property (object_class, PROP_RTCP_MUX,
g_param_spec_boolean ("rtcp-mux", "RTCP mux",
"RTCP mux", DEFAULT_RTCP_MUX,
Expand Down Expand Up @@ -3356,6 +3389,8 @@ kms_base_rtp_endpoint_init (KmsBaseRtpEndpoint * self)

self->priv->min_port = DEFAULT_MIN_PORT;
self->priv->max_port = DEFAULT_MAX_PORT;

self->priv->offer_dir = DEFAULT_OFFER_DIR;
}

GObject *
Expand Down
2 changes: 1 addition & 1 deletion src/gst-plugins/commons/sdpagent/kmssdpmediadirext.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <gst/gst.h>

#include <commons/sdp_utils.h>
#include <sdp_utils.h>

G_BEGIN_DECLS

Expand Down

0 comments on commit 0738217

Please sign in to comment.