summaryrefslogtreecommitdiff
path: root/farstream
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2014-05-02 15:54:58 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2014-09-18 13:38:00 -0400
commit7a68e77830e4c8472f52bdf39272b86da35bc4aa (patch)
tree5ce6f70c356216ea11d76e9600c93a1c967a48ee /farstream
parent9c7aa550ed0ea0b6962c7e3c1f42d7af253ea0fa (diff)
downloadfarstream-7a68e77830e4c8472f52bdf39272b86da35bc4aa.tar.gz
lib: Add parameters to set encryption and decryption parameters
Diffstat (limited to 'farstream')
-rw-r--r--farstream/Makefile.am1
-rw-r--r--farstream/fs-session.c64
-rw-r--r--farstream/fs-session.h8
-rw-r--r--farstream/fs-stream.c64
-rw-r--r--farstream/fs-stream.h9
5 files changed, 133 insertions, 13 deletions
diff --git a/farstream/Makefile.am b/farstream/Makefile.am
index 8cb9d569..0e156bb6 100644
--- a/farstream/Makefile.am
+++ b/farstream/Makefile.am
@@ -95,7 +95,6 @@ Farstream_@FS_API_VERSION@_gir_SCANNERFLAGS = --identifier-prefix=fs_ \
--identifier-prefix=Fs --add-init-section="gst_init(NULL,NULL);"
Farstream_@FS_API_VERSION@_gir_LDFLAGS = $(GST_LIBS)
-
girdir = $(datadir)/gir-1.0
dist_gir_DATA = Farstream-@FS_APIVERSION@.gir
typelibdir = $(libdir)/girepository-1.0
diff --git a/farstream/fs-session.c b/farstream/fs-session.c
index eaa1b9e0..2289c3e4 100644
--- a/farstream/fs-session.c
+++ b/farstream/fs-session.c
@@ -171,7 +171,8 @@ enum
PROP_CURRENT_SEND_CODEC,
PROP_TYPE_OF_SERVICE,
PROP_ALLOWED_SRC_CAPS,
- PROP_ALLOWED_SINK_CAPS
+ PROP_ALLOWED_SINK_CAPS,
+ PROP_ENCRYPTION_PARAMETERS
};
/*
@@ -419,6 +420,19 @@ fs_session_class_init (FsSessionClass *klass)
GST_TYPE_CAPS,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ /**
+ * FsSession:encryption-parameters:
+ *
+ * Retrieves previously set encryption parameters
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_ENCRYPTION_PARAMETERS,
+ g_param_spec_boxed ("encryption-parameters",
+ "Encryption parameters",
+ "Parameters used to encrypt the stream",
+ GST_TYPE_STRUCTURE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
/**
* FsSession::error:
@@ -451,10 +465,18 @@ fs_session_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GST_WARNING ("Subclass %s of FsSession does not override the %s property"
- " getter",
- G_OBJECT_TYPE_NAME(object),
- g_param_spec_get_name (pspec));
+ switch (prop_id) {
+ case PROP_ENCRYPTION_PARAMETERS:
+ g_value_set_boxed (value, NULL);
+ /* Not having parameters is valid, in this case set nothing */
+ break;
+ default:
+ GST_WARNING ("Subclass %s of FsSession does not override the %s property"
+ " getter",
+ G_OBJECT_TYPE_NAME(object),
+ g_param_spec_get_name (pspec));
+ break;
+ }
}
static void
@@ -773,6 +795,38 @@ fs_session_codecs_need_resend (FsSession *session,
}
/**
+ * fs_session_set_encryption_parameters:
+ * @session: a #FsSession
+ * @parameters: (transfer none) (allow-none): a #GstStructure containing the
+ * encryption parameters or %NULL to disable encryption
+ * @error: the location where to store a #GError or %NULL
+ *
+ * Sets encryption parameters. The exact parameters depend on the type of
+ * plugin being used.
+ *
+ * Returns: %TRUE if the encryption parameters could be set, %FALSE otherwise
+ * Since: UNRELEASED
+ */
+gboolean
+fs_session_set_encryption_parameters (FsSession *session,
+ GstStructure *parameters, GError **error)
+{
+ FsSessionClass *klass;
+
+ g_return_val_if_fail (session, FALSE);
+ g_return_val_if_fail (FS_IS_SESSION (session), FALSE);
+ klass = FS_SESSION_GET_CLASS (session);
+
+ if (klass->set_encryption_parameters)
+ return klass->set_encryption_parameters (session, parameters, error);
+
+ g_set_error (error, FS_ERROR, FS_ERROR_NOT_IMPLEMENTED,
+ "Does not support encryption");
+
+ return FALSE;
+}
+
+/**
* fs_session_destroy:
* @session: a #FsSession
*
diff --git a/farstream/fs-session.h b/farstream/fs-session.h
index c3fe4a50..52b62f76 100644
--- a/farstream/fs-session.h
+++ b/farstream/fs-session.h
@@ -110,6 +110,7 @@ typedef enum _FsDTMFMethod
* @get_stream_transmitter_type: Returns the GType of the stream transmitter
* @codecs_need_resend: Returns the list of codecs that need resending
* @set_allowed_caps: Set the possible allowed src and sink caps
+ * @set_encryption_parameters: Set encryption parameters
*
* You must override at least new_stream in a subclass.
*/
@@ -146,6 +147,9 @@ struct _FsSessionClass
gboolean (* set_allowed_caps) (FsSession *session, GstCaps *sink_caps,
GstCaps *src_caps, GError **error);
+ gboolean (* set_encryption_parameters) (FsSession *session,
+ GstStructure *parameters, GError **error);
+
/*< private >*/
gpointer _padding[7];
};
@@ -200,6 +204,9 @@ GList* fs_session_codecs_need_resend (FsSession *session,
gboolean fs_session_set_allowed_caps (FsSession *session, GstCaps *sink_caps,
GstCaps *src_caps, GError **error);
+gboolean fs_session_set_encryption_parameters (FsSession *session,
+ GstStructure *parameters, GError **error);
+
void fs_session_destroy (FsSession *session);
@@ -222,7 +229,6 @@ gboolean fs_session_parse_telephony_event_stopped (FsSession *session,
FsDTMFMethod *method);
-
G_END_DECLS
#endif /* __FS_SESSION_H__ */
diff --git a/farstream/fs-stream.c b/farstream/fs-stream.c
index c3b92176..2b05a9c3 100644
--- a/farstream/fs-stream.c
+++ b/farstream/fs-stream.c
@@ -129,7 +129,8 @@ enum
PROP_CURRENT_RECV_CODECS,
PROP_DIRECTION,
PROP_PARTICIPANT,
- PROP_SESSION
+ PROP_SESSION,
+ PROP_DECRYPTION_PARAMETERS
};
@@ -286,6 +287,19 @@ fs_stream_class_init (FsStreamClass *klass)
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
+ * FsStream:decryption-parameters:
+ *
+ * Retrieves previously set decryption parameters
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_DECRYPTION_PARAMETERS,
+ g_param_spec_boxed ("decryption-parameters",
+ "Decryption parameters",
+ "Parameters used to decrypt the stream",
+ GST_TYPE_STRUCTURE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+ /**
* FsStream::error:
* @self: #FsStream that emitted the signal
* @errorno: The number of the error
@@ -366,10 +380,18 @@ fs_stream_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GST_WARNING ("Subclass %s of FsStream does not override the %s property"
- " getter",
- G_OBJECT_TYPE_NAME(object),
- g_param_spec_get_name (pspec));
+ switch (prop_id) {
+ case PROP_DECRYPTION_PARAMETERS:
+ g_value_set_boxed (value, NULL);
+ /* Not having parameters is valid, in this case set nothing */
+ break;
+ default:
+ GST_WARNING ("Subclass %s of FsStream does not override the %s property"
+ " getter",
+ G_OBJECT_TYPE_NAME(object),
+ g_param_spec_get_name (pspec));
+ break;
+ }
}
static void
@@ -747,6 +769,38 @@ end:
}
/**
+ * fs_stream_set_decryption_parameters:
+ * @stream: a #FsStream
+ * @parameters: (transfer none): a #GstStructure containing the decryption
+ * parameters
+ * @error: the location where to store a #GError or %NULL
+ *
+ * Sets decryption parameters. The exact parameters depend on the type of
+ * plugin being used.
+ *
+ * Returns: %TRUE if the decryption parameters could be set, %FALSE otherwise
+ * Since: UNRELEASED
+ */
+gboolean
+fs_stream_set_decryption_parameters (FsStream *stream,
+ GstStructure *parameters, GError **error)
+{
+ FsStreamClass *klass;
+
+ g_return_val_if_fail (stream, FALSE);
+ g_return_val_if_fail (FS_IS_STREAM (stream), FALSE);
+ klass = FS_STREAM_GET_CLASS (stream);
+
+ if (klass->set_decryption_parameters)
+ return klass->set_decryption_parameters (stream, parameters, error);
+
+ g_set_error (error, FS_ERROR, FS_ERROR_NOT_IMPLEMENTED,
+ "Does not support decryption");
+
+ return FALSE;
+}
+
+/**
* fs_stream_destroy:
* @stream: a #FsStream
*
diff --git a/farstream/fs-stream.h b/farstream/fs-stream.h
index 5239fddf..38650d83 100644
--- a/farstream/fs-stream.h
+++ b/farstream/fs-stream.h
@@ -104,6 +104,7 @@ typedef struct _FsStreamPrivate FsStreamPrivate;
* @set_remote_codecs: Sets the list of remote codecs
* @add_id: Add a known id to be associated with this stream
* @set_transmitter: Set the transmitter to use for this stream
+ * @set_decryption_parameters: Set decryption parameters
*
* You must override add_remote_candidate in a subclass.
* If you have to negotiate codecs, then you must override set_remote_codecs too
@@ -134,8 +135,11 @@ struct _FsStreamClass
guint stream_transmitter_n_parameters,
GError **error);
+ gboolean (* set_decryption_parameters) (FsStream *stream,
+ GstStructure *parameters, GError **error);
+
/*< private >*/
- gpointer _padding[8];
+ gpointer _padding[7];
};
/**
@@ -190,6 +194,9 @@ gboolean fs_stream_set_transmitter_ht (FsStream *stream,
GHashTable *stream_transmitter_parameters,
GError **error);
+gboolean fs_stream_set_decryption_parameters (FsStream *stream,
+ GstStructure *parameters, GError **error);
+
void fs_stream_destroy (FsStream *stream);
gboolean fs_stream_parse_new_local_candidate (FsStream *stream,