diff options
author | George Hazan <ghazan@miranda.im> | 2022-08-03 21:02:36 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-08-03 21:02:36 +0300 |
commit | 5323a782c4e8c42781f22ce2f488962a18f82554 (patch) | |
tree | f71537197b16f0f8fd0d6937f7120d018d220814 /include/gst/sdp | |
parent | 50acf9d37183f86f6f623aad410003392b0af41f (diff) |
Jabber: initial version of Jingle support
Diffstat (limited to 'include/gst/sdp')
-rw-r--r-- | include/gst/sdp/gstmikey.h | 749 | ||||
-rw-r--r-- | include/gst/sdp/gstsdp.h | 58 | ||||
-rw-r--r-- | include/gst/sdp/gstsdpmessage.h | 762 | ||||
-rw-r--r-- | include/gst/sdp/sdp-prelude.h | 33 | ||||
-rw-r--r-- | include/gst/sdp/sdp.h | 31 |
5 files changed, 1633 insertions, 0 deletions
diff --git a/include/gst/sdp/gstmikey.h b/include/gst/sdp/gstmikey.h new file mode 100644 index 0000000000..900bbbf2f8 --- /dev/null +++ b/include/gst/sdp/gstmikey.h @@ -0,0 +1,749 @@ +/* GStreamer + * Copyright (C) <2014> Wim Taymans <wim.taymans@gmail.com> + * + * gstmikey.h: various helper functions to manipulate mikey messages + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_MIKEY_H__ +#define __GST_MIKEY_H__ + +#include <gst/gst.h> +#include <gst/sdp/sdp-prelude.h> + +G_BEGIN_DECLS + +GST_SDP_API +GType gst_mikey_message_get_type(void); +#define GST_TYPE_MIKEY_MESSAGE (gst_mikey_message_get_type()) + +typedef struct _GstMIKEYMessage GstMIKEYMessage; +typedef struct _GstMIKEYEncryptInfo GstMIKEYEncryptInfo; +typedef struct _GstMIKEYDecryptInfo GstMIKEYDecryptInfo; + +/** + * GST_MIKEY_VERSION: + * + * The supported MIKEY version 1. + */ +#define GST_MIKEY_VERSION 1 + +/** + * GstMIKEYType: + * @GST_MIKEY_TYPE_INVALID: Invalid type + * @GST_MIKEY_TYPE_PSK_INIT: Initiator's pre-shared key message + * @GST_MIKEY_TYPE_PSK_VERIFY: Verification message of a Pre-shared key message + * @GST_MIKEY_TYPE_PK_INIT: Initiator's public-key transport message + * @GST_MIKEY_TYPE_PK_VERIFY: Verification message of a public-key message + * @GST_MIKEY_TYPE_DH_INIT: Initiator's DH exchange message + * @GST_MIKEY_TYPE_DH_RESP: Responder's DH exchange message + * @GST_MIKEY_TYPE_ERROR: Error message + * + * Different MIKEY data types. + */ +typedef enum +{ + GST_MIKEY_TYPE_INVALID = -1, + GST_MIKEY_TYPE_PSK_INIT = 0, + GST_MIKEY_TYPE_PSK_VERIFY = 1, + GST_MIKEY_TYPE_PK_INIT = 2, + GST_MIKEY_TYPE_PK_VERIFY = 3, + GST_MIKEY_TYPE_DH_INIT = 4, + GST_MIKEY_TYPE_DH_RESP = 5, + GST_MIKEY_TYPE_ERROR = 6 +} GstMIKEYType; + +/** + * GstMIKEYPayloadType: + * @GST_MIKEY_PT_LAST: Last payload + * @GST_MIKEY_PT_KEMAC: Key data transport payload + * @GST_MIKEY_PT_PKE: Envelope data payload + * @GST_MIKEY_PT_DH: DH data payload + * @GST_MIKEY_PT_SIGN: Signature payload + * @GST_MIKEY_PT_T: Timestamp payload + * @GST_MIKEY_PT_ID: ID payload + * @GST_MIKEY_PT_CERT: Certificate Payload + * @GST_MIKEY_PT_CHASH: Cert hash payload + * @GST_MIKEY_PT_V: Verification message payload + * @GST_MIKEY_PT_SP: Security Policy payload + * @GST_MIKEY_PT_RAND: RAND payload + * @GST_MIKEY_PT_ERR: Error payload + * @GST_MIKEY_PT_KEY_DATA: Key data sub-payload + * @GST_MIKEY_PT_GEN_EXT: General Extension Payload + + * Different MIKEY Payload types. + */ +typedef enum +{ + GST_MIKEY_PT_LAST = 0, + GST_MIKEY_PT_KEMAC = 1, + GST_MIKEY_PT_PKE = 2, + GST_MIKEY_PT_DH = 3, + GST_MIKEY_PT_SIGN = 4, + GST_MIKEY_PT_T = 5, + GST_MIKEY_PT_ID = 6, + GST_MIKEY_PT_CERT = 7, + GST_MIKEY_PT_CHASH = 8, + GST_MIKEY_PT_V = 9, + GST_MIKEY_PT_SP = 10, + GST_MIKEY_PT_RAND = 11, + GST_MIKEY_PT_ERR = 12, + GST_MIKEY_PT_KEY_DATA = 20, + GST_MIKEY_PT_GEN_EXT = 21 +} GstMIKEYPayloadType; + +/** + * GstMIKEYPRFFunc: + * @GST_MIKEY_PRF_MIKEY_1: MIKEY-1 PRF function + * + * The PRF function that has been/will be used for key derivation + */ +typedef enum +{ + GST_MIKEY_PRF_MIKEY_1 = 0 +} GstMIKEYPRFFunc; + +/** + * GstMIKEYMapType: + * @GST_MIKEY_MAP_TYPE_SRTP: SRTP + * + * Specifies the method of uniquely mapping Crypto Sessions to the security + * protocol sessions. + */ +typedef enum +{ + GST_MIKEY_MAP_TYPE_SRTP = 0 +} GstMIKEYMapType; + +/** + * GstMIKEYMapSRTP: + * @policy: The security policy applied for the stream with @ssrc + * @ssrc: the SSRC that must be used for the stream + * @roc: current rollover counter + * + * The Security policy Map item for SRTP + */ +typedef struct { + guint8 policy; + guint32 ssrc; + guint32 roc; +} GstMIKEYMapSRTP; + +typedef struct _GstMIKEYPayload GstMIKEYPayload; + +GST_SDP_API +GType gst_mikey_payload_get_type(void); +#define GST_TYPE_MIKEY_PAYLOAD (gst_mikey_payload_get_type()) + +/** + * GstMIKEYPayload: + * @type: the payload type + * @len: length of the payload + * + * Hold the common fields for all payloads + */ +struct _GstMIKEYPayload { + /* < private > */ + GstMiniObject mini_object; + + /* < public > */ + GstMIKEYPayloadType type; + guint len; +}; + +GST_SDP_API +GstMIKEYPayload * gst_mikey_payload_new (GstMIKEYPayloadType type); + +/** + * gst_mikey_payload_ref: + * @payload: The payload to refcount + * + * Increase the refcount of this payload. + * + * Returns: (transfer full): @payload (for convenience when doing assignments) + * + * Since: 1.4 + */ +static inline GstMIKEYPayload * +gst_mikey_payload_ref (GstMIKEYPayload * payload) +{ + return (GstMIKEYPayload *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (payload)); +} + +/** + * gst_mikey_payload_unref: + * @payload: (transfer full): the payload to refcount + * + * Decrease the refcount of an payload, freeing it if the refcount reaches 0. + * + * Since: 1.4 + */ +static inline void +gst_mikey_payload_unref (GstMIKEYPayload * payload) +{ + gst_mini_object_unref (GST_MINI_OBJECT_CAST (payload)); +} + +/** + * gst_mikey_payload_copy: + * @payload: a #GstMIKEYPayload. + * + * Create a copy of the given payload. + * + * Returns: (transfer full): a new copy of @payload. + * + * Since: 1.4 + */ +static inline GstMIKEYPayload * +gst_mikey_payload_copy (const GstMIKEYPayload * payload) +{ + return (GstMIKEYPayload *) gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (payload)); +} + +/** + * GstMIKEYEncAlg: + * @GST_MIKEY_ENC_NULL: no encryption + * @GST_MIKEY_ENC_AES_CM_128: AES-CM using a 128-bit key + * @GST_MIKEY_ENC_AES_KW_128: AES Key Wrap using a 128-bit key + * @GST_MIKEY_ENC_AES_GCM_128: AES-GCM using a 128-bit key (Since: 1.16) + * + * The encryption algorithm used to encrypt the Encr data field + */ +typedef enum +{ + GST_MIKEY_ENC_NULL = 0, + GST_MIKEY_ENC_AES_CM_128 = 1, + GST_MIKEY_ENC_AES_KW_128 = 2, + GST_MIKEY_ENC_AES_GCM_128 = 6 +} GstMIKEYEncAlg; + +/** + * GstMIKEYMacAlg: + * @GST_MIKEY_MAC_NULL: no authentication + * @GST_MIKEY_MAC_HMAC_SHA_1_160: HMAC-SHA-1-160 + * + * Specifies the authentication algorithm used + */ +typedef enum +{ + GST_MIKEY_MAC_NULL = 0, + GST_MIKEY_MAC_HMAC_SHA_1_160 = 1 +} GstMIKEYMacAlg; + +/** + * GstMIKEYPayloadKEMAC: + * @pt: the common #GstMIKEYPayload + * @enc_alg: the #GstMIKEYEncAlg + * @mac_alg: the #GstMIKEYMacAlg + * @subpayloads: the subpayloads + * + * A structure holding the KEMAC payload + */ +typedef struct { + GstMIKEYPayload pt; + + GstMIKEYEncAlg enc_alg; + GstMIKEYMacAlg mac_alg; + GArray *subpayloads; +} GstMIKEYPayloadKEMAC; + +GST_SDP_API +gboolean gst_mikey_payload_kemac_set (GstMIKEYPayload *payload, + GstMIKEYEncAlg enc_alg, + GstMIKEYMacAlg mac_alg); + +GST_SDP_API +guint gst_mikey_payload_kemac_get_n_sub (const GstMIKEYPayload *payload); + +GST_SDP_API +const GstMIKEYPayload * gst_mikey_payload_kemac_get_sub (const GstMIKEYPayload *payload, guint idx); + +GST_SDP_API +gboolean gst_mikey_payload_kemac_remove_sub (GstMIKEYPayload *payload, guint idx); + +GST_SDP_API +gboolean gst_mikey_payload_kemac_add_sub (GstMIKEYPayload *payload, + GstMIKEYPayload *newpay); + +/** + * GstMIKEYCacheType: + * @GST_MIKEY_CACHE_NONE: The envelope key MUST NOT be cached + * @GST_MIKEY_CACHE_ALWAYS: The envelope key MUST be cached + * @GST_MIKEY_CACHE_FOR_CSB: The envelope key MUST be cached, but only + * to be used for the specific CSB. + * + * The different cache types + */ +typedef enum +{ + GST_MIKEY_CACHE_NONE = 0, + GST_MIKEY_CACHE_ALWAYS = 1, + GST_MIKEY_CACHE_FOR_CSB = 2 +} GstMIKEYCacheType; + +/** + * GstMIKEYPayloadPKE: + * @pt: the common #GstMIKEYPayload + * @C: envelope key cache indicator + * @data_len: length of @data + * @data: the encrypted envelope key + * + * The Envelope data payload contains the encrypted envelope key that is + * used in the public-key transport to protect the data in the Key data + * transport payload. The encryption algorithm used is implicit from + * the certificate/public key used. + */ +typedef struct { + GstMIKEYPayload pt; + + GstMIKEYCacheType C; + guint16 data_len; + guint8 *data; +} GstMIKEYPayloadPKE; + +GST_SDP_API +gboolean gst_mikey_payload_pke_set (GstMIKEYPayload *payload, + GstMIKEYCacheType C, + guint16 data_len, const guint8 *data); + + +/** + * GstMIKEYTSType: + * @GST_MIKEY_TS_TYPE_NTP_UTC: an NTP time in UTC timezone + * @GST_MIKEY_TS_TYPE_NTP: an NTP time + * @GST_MIKEY_TS_TYPE_COUNTER: a counter + * + * Specifies the timestamp type. + */ +typedef enum +{ + GST_MIKEY_TS_TYPE_NTP_UTC = 0, + GST_MIKEY_TS_TYPE_NTP = 1, + GST_MIKEY_TS_TYPE_COUNTER = 2 +} GstMIKEYTSType; + +/** + * GstMIKEYPayloadT: + * @pt: the payload header + * @type: a #GstMIKEYTSType + * @ts_value: the timestamp value + * + * The timestamp payload carries the timestamp information + */ +typedef struct { + GstMIKEYPayload pt; + + GstMIKEYTSType type; + guint8 *ts_value; +} GstMIKEYPayloadT; + +GST_SDP_API +gboolean gst_mikey_payload_t_set (GstMIKEYPayload *payload, + GstMIKEYTSType type, const guint8 *ts_value); + +/** + * GstMIKEYPayloadSPParam: + * @type: specifies the type of the parameter + * @len: specifies the length of @val + * @val: specifies the value of the parameter + * + * A Type/Length/Value field for security parameters + */ +typedef struct { + guint8 type; + guint8 len; + guint8 *val; +} GstMIKEYPayloadSPParam; + +/** + * GstMIKEYSecProto: + * @GST_MIKEY_SEC_PROTO_SRTP: SRTP + * + * Specifies the security protocol + */ +typedef enum +{ + GST_MIKEY_SEC_PROTO_SRTP = 0 +} GstMIKEYSecProto; + +/** + * GstMIKEYSecSRTP: + * @GST_MIKEY_SP_SRTP_ENC_ALG: Encryption algorithm + * @GST_MIKEY_SP_SRTP_ENC_KEY_LEN: Session Encr. key length + * @GST_MIKEY_SP_SRTP_AUTH_ALG: Authentication algorithm + * @GST_MIKEY_SP_SRTP_AUTH_KEY_LEN: Session Auth. key length + * @GST_MIKEY_SP_SRTP_SALT_KEY_LEN: Session Salt key length + * @GST_MIKEY_SP_SRTP_PRF: SRTP Pseudo Random Function + * @GST_MIKEY_SP_SRTP_KEY_DERIV_RATE: Key derivation rate + * @GST_MIKEY_SP_SRTP_SRTP_ENC: SRTP encryption off/on, 0 if off, 1 if on + * @GST_MIKEY_SP_SRTP_SRTCP_ENC: SRTCP encryption off/on, 0 if off, 1 if on + * @GST_MIKEY_SP_SRTP_FEC_ORDER: sender's FEC order + * @GST_MIKEY_SP_SRTP_SRTP_AUTH: SRTP authentication off/on, 0 if off, 1 if on + * @GST_MIKEY_SP_SRTP_AUTH_TAG_LEN: Authentication tag length + * @GST_MIKEY_SP_SRTP_SRTP_PREFIX_LEN: SRTP prefix length + * @GST_MIKEY_SP_SRTP_AEAD_AUTH_TAG_LEN: AEAD authentication tag length (Since: 1.16) + * + * This policy specifies the parameters for SRTP and SRTCP + */ +typedef enum +{ + GST_MIKEY_SP_SRTP_ENC_ALG = 0, + GST_MIKEY_SP_SRTP_ENC_KEY_LEN = 1, + GST_MIKEY_SP_SRTP_AUTH_ALG = 2, + GST_MIKEY_SP_SRTP_AUTH_KEY_LEN = 3, + GST_MIKEY_SP_SRTP_SALT_KEY_LEN = 4, + GST_MIKEY_SP_SRTP_PRF = 5, + GST_MIKEY_SP_SRTP_KEY_DERIV_RATE = 6, + GST_MIKEY_SP_SRTP_SRTP_ENC = 7, + GST_MIKEY_SP_SRTP_SRTCP_ENC = 8, + GST_MIKEY_SP_SRTP_FEC_ORDER = 9, + GST_MIKEY_SP_SRTP_SRTP_AUTH = 10, + GST_MIKEY_SP_SRTP_AUTH_TAG_LEN = 11, + GST_MIKEY_SP_SRTP_SRTP_PREFIX_LEN = 12, + GST_MIKEY_SP_SRTP_AEAD_AUTH_TAG_LEN = 20 +} GstMIKEYSecSRTP; + +/** + * GstMIKEYPayloadSP: + * @pt: the payload header + * @policy: the policy number + * @proto: the security protocol + * @params: array of #GstMIKEYPayloadSPParam + * + * The Security Policy payload defines a set of policies that apply to a + * specific security protocol + */ +typedef struct { + GstMIKEYPayload pt; + + guint policy; + GstMIKEYSecProto proto; + GArray *params; +} GstMIKEYPayloadSP; + +GST_SDP_API +gboolean gst_mikey_payload_sp_set (GstMIKEYPayload *payload, + guint policy, GstMIKEYSecProto proto); +GST_SDP_API +guint gst_mikey_payload_sp_get_n_params (const GstMIKEYPayload *payload); + +GST_SDP_API +const GstMIKEYPayloadSPParam * + gst_mikey_payload_sp_get_param (const GstMIKEYPayload *payload, guint idx); + +GST_SDP_API +gboolean gst_mikey_payload_sp_remove_param (GstMIKEYPayload *payload, guint idx); + +GST_SDP_API +gboolean gst_mikey_payload_sp_add_param (GstMIKEYPayload *payload, + guint8 type, guint8 len, const guint8 *val); + +/** + * GstMIKEYPayloadRAND: + * @pt: the payload header + * @len: the length of @rand + * @rand: random values + * + * The RAND payload consists of a (pseudo-)random bit-string + */ +typedef struct { + GstMIKEYPayload pt; + + guint8 len; + guint8 *rand; +} GstMIKEYPayloadRAND; + +GST_SDP_API +gboolean gst_mikey_payload_rand_set (GstMIKEYPayload *payload, + guint8 len, const guint8 *rand); + +/** + * GstMIKEYKeyDataType: + * @GST_MIKEY_KD_TGK: a TEK Generation Key + * @GST_MIKEY_KD_TEK: Traffic-Encrypting Key + * + * The type of key. + */ +typedef enum +{ + GST_MIKEY_KD_TGK = 0, + GST_MIKEY_KD_TEK = 2, +} GstMIKEYKeyDataType; + +/** + * GstMIKEYKVType: + * @GST_MIKEY_KV_NULL: No specific usage rule + * @GST_MIKEY_KV_SPI: The key is associated with the SPI/MKI + * @GST_MIKEY_KV_INTERVAL: The key has a start and expiration time + * + * The key validity type + */ +typedef enum +{ + GST_MIKEY_KV_NULL = 0, + GST_MIKEY_KV_SPI = 1, + GST_MIKEY_KV_INTERVAL = 2, +} GstMIKEYKVType; + +/** + * GstMIKEYPayloadKeyData: + * @pt: the payload header + * @key_type: the #GstMIKEYKeyDataType of @key_data + * @key_len: length of @key_data + * @key_data: the key data + * @salt_len: the length of @salt_data, can be 0 + * @salt_data: salt data + * @kv_type: the Key Validity type + * @kv_len: length of @kv_data + * @kv_data: key validity data + * + * The Key data payload contains key material. It should be added as sub + * payload to the KEMAC. + */ +typedef struct { + GstMIKEYPayload pt; + + GstMIKEYKeyDataType key_type; + guint16 key_len; + guint8 *key_data; + guint16 salt_len; + guint8 *salt_data; + GstMIKEYKVType kv_type; + guint8 kv_len[2]; + guint8 *kv_data[2]; +} GstMIKEYPayloadKeyData; + +GST_SDP_API +gboolean gst_mikey_payload_key_data_set_key (GstMIKEYPayload *payload, + GstMIKEYKeyDataType key_type, + guint16 key_len, const guint8 *key_data); + +GST_SDP_API +gboolean gst_mikey_payload_key_data_set_salt (GstMIKEYPayload *payload, + guint16 salt_len, const guint8 *salt_data); + +GST_SDP_API +gboolean gst_mikey_payload_key_data_set_spi (GstMIKEYPayload *payload, + guint8 spi_len, const guint8 *spi_data); + +GST_SDP_API +gboolean gst_mikey_payload_key_data_set_interval (GstMIKEYPayload *payload, + guint8 vf_len, const guint8 *vf_data, + guint8 vt_len, const guint8 *vt_data); + +/** + * GstMIKEYMessage: + * @version: the version + * @type: the #GstMIKEYType message type + * @V: verify flag + * @prf_func: a #GstMIKEYPRFFunc + * @CSB_id: Identifies the Crypto Session Bundle + * @map_type: a #GstMIKEYMapType + * @map_info: map info array of type depending on @map_type + * @payloads: the payload array of #GstMIKEYPayload + * + * Structure holding the information of the MIKEY message + */ +struct _GstMIKEYMessage +{ + /* < private > */ + GstMiniObject mini_object; + + /* < public > */ + guint8 version; + GstMIKEYType type; + gboolean V; + GstMIKEYPRFFunc prf_func; + guint32 CSB_id; + GstMIKEYMapType map_type; + GArray *map_info; + GArray *payloads; +}; + + +GST_SDP_API +GstMIKEYMessage * gst_mikey_message_new (void); + +GST_SDP_API +GstMIKEYMessage * gst_mikey_message_new_from_data (gconstpointer data, gsize size, + GstMIKEYDecryptInfo *info, GError **error); + +GST_SDP_API +GstMIKEYMessage * gst_mikey_message_new_from_bytes (GBytes *bytes, GstMIKEYDecryptInfo *info, + GError **error); + +GST_SDP_API +GBytes * gst_mikey_message_to_bytes (GstMIKEYMessage *msg, GstMIKEYEncryptInfo *info, + GError **error); + +GST_SDP_API +GstMIKEYMessage * gst_mikey_message_new_from_caps (GstCaps *caps); + +GST_SDP_API +gboolean gst_mikey_message_to_caps (const GstMIKEYMessage *msg, GstCaps *caps); + +GST_SDP_API +gchar * gst_mikey_message_base64_encode (GstMIKEYMessage* msg); + +/** + * gst_mikey_message_ref: + * @message: The message to refcount + * + * Increase the refcount of this message. + * + * Returns: (transfer full): @message (for convenience when doing assignments) + * + * Since: 1.4 + */ +static inline GstMIKEYMessage * +gst_mikey_message_ref (GstMIKEYMessage * message) +{ + return (GstMIKEYMessage *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (message)); +} + +/** + * gst_mikey_message_unref: + * @message: (transfer full): the message to refcount + * + * Decrease the refcount of an message, freeing it if the refcount reaches 0. + * + * Since: 1.4 + */ +static inline void +gst_mikey_message_unref (GstMIKEYMessage * message) +{ + gst_mini_object_unref (GST_MINI_OBJECT_CAST (message)); +} + +/** + * gst_mikey_message_copy: + * @message: a #GstMIKEYMessage. + * + * Create a copy of the given message. + * + * Returns: (transfer full): a new copy of @message. + * + * Since: 1.4 + */ +static inline GstMIKEYMessage * +gst_mikey_message_copy (const GstMIKEYMessage * message) +{ + return (GstMIKEYMessage *) gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (message)); +} + + +GST_SDP_API +gboolean gst_mikey_message_set_info (GstMIKEYMessage *msg, + guint8 version, GstMIKEYType type, gboolean V, + GstMIKEYPRFFunc prf_func, guint32 CSB_id, + GstMIKEYMapType map_type); + +GST_SDP_API +guint gst_mikey_message_get_n_cs (const GstMIKEYMessage *msg); + +/* SRTP crypto sessions */ + +GST_SDP_API +const GstMIKEYMapSRTP * gst_mikey_message_get_cs_srtp (const GstMIKEYMessage *msg, guint idx); + +GST_SDP_API +gboolean gst_mikey_message_insert_cs_srtp (GstMIKEYMessage *msg, gint idx, + const GstMIKEYMapSRTP *map); + +GST_SDP_API +gboolean gst_mikey_message_replace_cs_srtp (GstMIKEYMessage *msg, gint idx, + const GstMIKEYMapSRTP *map); + +GST_SDP_API +gboolean gst_mikey_message_remove_cs_srtp (GstMIKEYMessage *msg, gint idx); + +GST_SDP_API +gboolean gst_mikey_message_add_cs_srtp (GstMIKEYMessage *msg, + guint8 policy, guint32 ssrc, guint32 roc); + +/* adding/retrieving payloads */ + +GST_SDP_API +guint gst_mikey_message_get_n_payloads (const GstMIKEYMessage *msg); + +GST_SDP_API +const GstMIKEYPayload * gst_mikey_message_get_payload (const GstMIKEYMessage *msg, guint idx); + +GST_SDP_API +const GstMIKEYPayload * gst_mikey_message_find_payload (const GstMIKEYMessage *msg, + GstMIKEYPayloadType type, guint nth); + +GST_SDP_API +gboolean gst_mikey_message_remove_payload (GstMIKEYMessage *msg, guint idx); + +GST_SDP_API +gboolean gst_mikey_message_insert_payload (GstMIKEYMessage *msg, guint idx, + GstMIKEYPayload *payload); + +GST_SDP_API +gboolean gst_mikey_message_add_payload (GstMIKEYMessage *msg, + GstMIKEYPayload *payload); + +GST_SDP_API +gboolean gst_mikey_message_replace_payload (GstMIKEYMessage *msg, guint idx, + GstMIKEYPayload *payload); + + +/* Key data transport payload (KEMAC) */ +/* Envelope data payload (PKE) */ + +GST_SDP_API +gboolean gst_mikey_message_add_pke (GstMIKEYMessage *msg, + GstMIKEYCacheType C, + guint16 data_len, const guint8 *data); +/* DH data payload (DH) */ +/* Signature payload (SIGN) */ + +/* Timestamp payload (T) */ + +GST_SDP_API +gboolean gst_mikey_message_add_t (GstMIKEYMessage *msg, + GstMIKEYTSType type, const guint8 *ts_value); + +GST_SDP_API +gboolean gst_mikey_message_add_t_now_ntp_utc (GstMIKEYMessage *msg); +/* ID payload (ID) */ +/* Certificate Payload (CERT) */ +/* Cert hash payload (CHASH)*/ +/* Ver msg payload (V) */ +/* Security Policy payload (SP)*/ +/* RAND payload (RAND) */ + +GST_SDP_API +gboolean gst_mikey_message_add_rand (GstMIKEYMessage *msg, + guint8 len, const guint8 *rand); + +GST_SDP_API +gboolean gst_mikey_message_add_rand_len (GstMIKEYMessage *msg, guint8 len); + +/* Error payload (ERR) */ +/* Key data sub-payload */ +/* General Extension Payload */ + + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstMIKEYMessage, gst_mikey_message_unref) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstMIKEYPayload, gst_mikey_payload_unref) + +G_END_DECLS + +#endif /* __GST_MIKEY_H__ */ diff --git a/include/gst/sdp/gstsdp.h b/include/gst/sdp/gstsdp.h new file mode 100644 index 0000000000..1eb54836d7 --- /dev/null +++ b/include/gst/sdp/gstsdp.h @@ -0,0 +1,58 @@ +/* GStreamer + * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +/* + * Unless otherwise indicated, Source Code is licensed under MIT license. + * See further explanation attached in License Statement (distributed in the file + * LICENSE). + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef __GST_SDP_H__ +#define __GST_SDP_H__ + +/** + * GstSDPResult: + * @GST_SDP_OK: A successful return value + * @GST_SDP_EINVAL: a function was given invalid parameters + * + * Return values for the SDP functions. + */ +typedef enum { + GST_SDP_OK = 0, + GST_SDP_EINVAL = -1 +} GstSDPResult; + +#endif /* __GST_SDP_H__ */ diff --git a/include/gst/sdp/gstsdpmessage.h b/include/gst/sdp/gstsdpmessage.h new file mode 100644 index 0000000000..378f14938b --- /dev/null +++ b/include/gst/sdp/gstsdpmessage.h @@ -0,0 +1,762 @@ +/* GStreamer + * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +/* + * Unless otherwise indicated, Source Code is licensed under MIT license. + * See further explanation attached in License Statement (distributed in the file + * LICENSE). + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef __GST_SDP_MESSAGE_H__ +#define __GST_SDP_MESSAGE_H__ + +#include "gstmikey.h" + +#include <glib.h> +#include <gst/gst.h> +#include <gst/sdp/sdp.h> + +G_BEGIN_DECLS + +/** + * GstSDPOrigin: + * @username: the user's login on the originating host, or it is "-" + * if the originating host does not support the concept of user ids. + * @sess_id: is a numeric string such that the tuple of @username, @sess_id, + * @nettype, @addrtype and @addr form a globally unique identifier for the + * session. + * @sess_version: a version number for this announcement + * @nettype: the type of network. "IN" is defined to have the meaning + * "Internet". + * @addrtype: the type of @addr. + * @addr: the globally unique address of the machine from which the session was + * created. + * + * The contents of the SDP "o=" field which gives the originator of the session + * (their username and the address of the user's host) plus a session id and + * session version number. + */ +typedef struct { + gchar *username; + gchar *sess_id; + gchar *sess_version; + gchar *nettype; + gchar *addrtype; + gchar *addr; +} GstSDPOrigin; + +/** + * GstSDPConnection: + * @nettype: the type of network. "IN" is defined to have the meaning + * "Internet". + * @addrtype: the type of @address. + * @address: the address + * @ttl: the time to live of the address + * @addr_number: the number of layers + * + * The contents of the SDP "c=" field which contains connection data. + */ +typedef struct { + gchar *nettype; + gchar *addrtype; + gchar *address; + guint ttl; + guint addr_number; +} GstSDPConnection; + +GST_SDP_API +GstSDPResult gst_sdp_connection_set (GstSDPConnection *conn, + const gchar *nettype, + const gchar *addrtype, + const gchar *address, + guint ttl, guint addr_number); + +GST_SDP_API +GstSDPResult gst_sdp_connection_clear (GstSDPConnection *conn); + + +/** + * GST_SDP_BWTYPE_CT: + * + * The Conference Total bandwidth modifier. + */ +#define GST_SDP_BWTYPE_CT "CT" +/** + * GST_SDP_BWTYPE_AS: + * + * The Application-Specific Maximum bandwidth modifier. + */ +#define GST_SDP_BWTYPE_AS "AS" +/** + * GST_SDP_BWTYPE_EXT_PREFIX: + * + * The extension prefix bandwidth modifier. + */ +#define GST_SDP_BWTYPE_EXT_PREFIX "X-" + +/** + * GST_SDP_BWTYPE_RS: + * + * RTCP bandwidth allocated to active data senders (RFC 3556). + */ +#define GST_SDP_BWTYPE_RS "RS" +/** + * GST_SDP_BWTYPE_RR: + * + * RTCP bandwidth allocated to data receivers (RFC 3556). + */ +#define GST_SDP_BWTYPE_RR "RR" +/** + * GST_SDP_BWTYPE_TIAS: + * + * Transport Independent Application Specific Maximum bandwidth (RFC 3890). + */ +#define GST_SDP_BWTYPE_TIAS "TIAS" + + +/** + * GstSDPBandwidth: + * @bwtype: the bandwidth modifier type + * @bandwidth: the bandwidth in kilobits per second + * + * The contents of the SDP "b=" field which specifies the proposed bandwidth to + * be used by the session or media. + */ +typedef struct { + gchar *bwtype; + guint bandwidth; +} GstSDPBandwidth; + +GST_SDP_API +GstSDPResult gst_sdp_bandwidth_set (GstSDPBandwidth *bw, const gchar *bwtype, + guint bandwidth); + +GST_SDP_API +GstSDPResult gst_sdp_bandwidth_clear (GstSDPBandwidth *bw); + +/** + * GstSDPTime: + * @start: start time for the conference. The value is the decimal + * representation of Network Time Protocol (NTP) time values in seconds + * @stop: stop time for the conference. The value is the decimal + * representation of Network Time Protocol (NTP) time values in seconds + * @repeat: repeat times for a session + * + * The contents of the SDP "t=" field which specify the start and stop times for + * a conference session. + */ +typedef struct { + gchar *start; + gchar *stop; + GArray *repeat; +} GstSDPTime; + +GST_SDP_API +GstSDPResult gst_sdp_time_set (GstSDPTime *t, const gchar *start, + const gchar *stop, const gchar **repeat); + +GST_SDP_API +GstSDPResult gst_sdp_time_clear (GstSDPTime *t); + +/** + * GstSDPZone: + * @time: the NTP time that a time zone adjustment happens + * @typed_time: the offset from the time when the session was first scheduled + * + * The contents of the SDP "z=" field which allows the sender to + * specify a list of time zone adjustments and offsets from the base + * time. + */ +typedef struct { + gchar *time; + gchar *typed_time; +} GstSDPZone; + +GST_SDP_API +GstSDPResult gst_sdp_zone_set (GstSDPZone *zone, const gchar *adj_time, + const gchar *typed_time); + +GST_SDP_API +GstSDPResult gst_sdp_zone_clear (GstSDPZone *zone); + + +/** + * GstSDPKey: + * @type: the encryption type + * @data: the encryption data + * + * The contents of the SDP "k=" field which is used to convey encryption + * keys. + */ +typedef struct { + gchar *type; + gchar *data; +} GstSDPKey; + +/** + * GstSDPAttribute: + * @key: the attribute key + * @value: the attribute value or NULL when it was a property attribute + * + * The contents of the SDP "a=" field which contains a key/value pair. + */ +typedef struct { + gchar *key; + gchar *value; +} GstSDPAttribute; + +GST_SDP_API +GstSDPResult gst_sdp_attribute_set (GstSDPAttribute *attr, const gchar *key, + const gchar *value); + +GST_SDP_API +GstSDPResult gst_sdp_attribute_clear (GstSDPAttribute *attr); + +/** + * GstSDPMedia: + * @media: the media type + * @port: the transport port to which the media stream will be sent + * @num_ports: the number of ports or -1 if only one port was specified + * @proto: the transport protocol + * @fmts: an array of #gchar formats + * @information: the media title + * @connections: array of #GstSDPConnection with media connection information + * @bandwidths: array of #GstSDPBandwidth with media bandwidth information + * @key: the encryption key + * @attributes: array of #GstSDPAttribute with the additional media attributes + * + * The contents of the SDP "m=" field with all related fields. + */ +typedef struct { + gchar *media; + guint port; + guint num_ports; + gchar *proto; + GArray *fmts; + gchar *information; + GArray *connections; + GArray *bandwidths; + GstSDPKey key; + GArray *attributes; +} GstSDPMedia; + +/** + * GstSDPMessage: + * @version: the protocol version + * @origin: owner/creator and session identifier + * @session_name: session name + * @information: session information + * @uri: URI of description + * @emails: array of #gchar with email addresses + * @phones: array of #gchar with phone numbers + * @connection: connection information for the session + * @bandwidths: array of #GstSDPBandwidth with bandwidth information + * @times: array of #GstSDPTime with time descriptions + * @zones: array of #GstSDPZone with time zone adjustments + * @key: encryption key + * @attributes: array of #GstSDPAttribute with session attributes + * @medias: array of #GstSDPMedia with media descriptions + * + * The contents of the SDP message. + */ +typedef struct { + gchar *version; + GstSDPOrigin origin; + gchar *session_name; + gchar *information; + gchar *uri; + GArray *emails; + GArray *phones; + GstSDPConnection connection; + GArray *bandwidths; + GArray *times; + GArray *zones; + GstSDPKey key; + GArray *attributes; + GArray *medias; +} GstSDPMessage; + + +GST_SDP_API +GType gst_sdp_message_get_type (void); + +#define GST_TYPE_SDP_MESSAGE (gst_sdp_message_get_type()) +#define GST_SDP_MESSAGE_CAST(object) ((GstSDPMessage *)(object)) +#define GST_SDP_MESSAGE(object) (GST_SDP_MESSAGE_CAST(object)) + +/* Session descriptions */ + +GST_SDP_API +GstSDPResult gst_sdp_message_new (GstSDPMessage **msg); + +GST_SDP_API +GstSDPResult gst_sdp_message_init (GstSDPMessage *msg); + +GST_SDP_API +GstSDPResult gst_sdp_message_uninit (GstSDPMessage *msg); + +GST_SDP_API +GstSDPResult gst_sdp_message_free (GstSDPMessage *msg); + +GST_SDP_API +GstSDPResult gst_sdp_message_copy (const GstSDPMessage *msg, GstSDPMessage **copy); + +GST_SDP_API +GstSDPResult gst_sdp_message_parse_buffer (const guint8 *data, guint size, GstSDPMessage *msg); + +GST_SDP_API +gchar* gst_sdp_message_as_text (const GstSDPMessage *msg); + +GST_SDP_API +GstSDPResult gst_sdp_message_new_from_text (const gchar *text, GstSDPMessage ** msg); + +/* convert from/to uri */ + +GST_SDP_API +GstSDPResult gst_sdp_message_parse_uri (const gchar *uri, GstSDPMessage *msg); + +GST_SDP_API +gchar* gst_sdp_message_as_uri (const gchar *scheme, const GstSDPMessage *msg); + +/* utils */ + +GST_SDP_API +gboolean gst_sdp_address_is_multicast (const gchar *nettype, const gchar *addrtype, + const gchar *addr); +/* v=.. */ + +GST_SDP_API +const gchar* gst_sdp_message_get_version (const GstSDPMessage *msg); + +GST_SDP_API +GstSDPResult gst_sdp_message_set_version (GstSDPMessage *msg, const gchar *version); + +/* o=<username> <sess-id> <sess-version> <nettype> <addrtype> <unicast-address> */ + +GST_SDP_API +const GstSDPOrigin* gst_sdp_message_get_origin (const GstSDPMessage *msg); + +GST_SDP_API +GstSDPResult gst_sdp_message_set_origin (GstSDPMessage *msg, const gchar *username, + const gchar *sess_id, const gchar *sess_version, + const gchar *nettype, const gchar *addrtype, + const gchar *addr); + +/* s=<session name> */ + +GST_SDP_API +const gchar* gst_sdp_message_get_session_name (const GstSDPMessage *msg); + +GST_SDP_API +GstSDPResult gst_sdp_message_set_session_name (GstSDPMessage *msg, const gchar *session_name); + +/* i=<session description> */ + +GST_SDP_API +const gchar* gst_sdp_message_get_information (const GstSDPMessage *msg); + +GST_SDP_API +GstSDPResult gst_sdp_message_set_information (GstSDPMessage *msg, const gchar *information); + +/* u=<uri> */ + +GST_SDP_API +const gchar* gst_sdp_message_get_uri (const GstSDPMessage *msg); + +GST_SDP_API +GstSDPResult gst_sdp_message_set_uri (GstSDPMessage *msg, const gchar *uri); + +/* e=<email-address> */ + +GST_SDP_API +guint gst_sdp_message_emails_len (const GstSDPMessage *msg); + +GST_SDP_API +const gchar* gst_sdp_message_get_email (const GstSDPMessage *msg, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_message_insert_email (GstSDPMessage *msg, gint idx, + const gchar *email); + +GST_SDP_API +GstSDPResult gst_sdp_message_replace_email (GstSDPMessage *msg, guint idx, + const gchar *email); + +GST_SDP_API +GstSDPResult gst_sdp_message_remove_email (GstSDPMessage *msg, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_message_add_email (GstSDPMessage *msg, const gchar *email); + +/* p=<phone-number> */ + +GST_SDP_API +guint gst_sdp_message_phones_len (const GstSDPMessage *msg); + +GST_SDP_API +const gchar* gst_sdp_message_get_phone (const GstSDPMessage *msg, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_message_insert_phone (GstSDPMessage *msg, gint idx, + const gchar *phone); + +GST_SDP_API +GstSDPResult gst_sdp_message_replace_phone (GstSDPMessage *msg, guint idx, + const gchar *phone); + +GST_SDP_API +GstSDPResult gst_sdp_message_remove_phone (GstSDPMessage *msg, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_message_add_phone (GstSDPMessage *msg, const gchar *phone); + +/* c=<nettype> <addrtype> <connection-address>[/<ttl>][/<number of addresses>] */ + +GST_SDP_API +const GstSDPConnection* gst_sdp_message_get_connection (const GstSDPMessage *msg); + +GST_SDP_API +GstSDPResult gst_sdp_message_set_connection (GstSDPMessage *msg, const gchar *nettype, + const gchar *addrtype, const gchar *address, + guint ttl, guint addr_number); +/* b=<bwtype>:<bandwidth> */ + +GST_SDP_API +guint gst_sdp_message_bandwidths_len (const GstSDPMessage *msg); + +GST_SDP_API +const GstSDPBandwidth* gst_sdp_message_get_bandwidth (const GstSDPMessage *msg, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_message_insert_bandwidth (GstSDPMessage * msg, gint idx, + GstSDPBandwidth * bw); + +GST_SDP_API +GstSDPResult gst_sdp_message_replace_bandwidth (GstSDPMessage * msg, guint idx, + GstSDPBandwidth * bw); + +GST_SDP_API +GstSDPResult gst_sdp_message_remove_bandwidth (GstSDPMessage * msg, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_message_add_bandwidth (GstSDPMessage *msg, const gchar *bwtype, + guint bandwidth); + +/* t=<start-time> <stop-time> and + * r=<repeat interval> <active duration> <offsets from start-time> */ + +GST_SDP_API +guint gst_sdp_message_times_len (const GstSDPMessage *msg); + +GST_SDP_API +const GstSDPTime* gst_sdp_message_get_time (const GstSDPMessage *msg, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_message_insert_time (GstSDPMessage *msg, gint idx, + GstSDPTime *t); + +GST_SDP_API +GstSDPResult gst_sdp_message_replace_time (GstSDPMessage *msg, guint idx, + GstSDPTime *t); + +GST_SDP_API +GstSDPResult gst_sdp_message_remove_time (GstSDPMessage *msg, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_message_add_time (GstSDPMessage *msg, const gchar *start, + const gchar *stop, const gchar **repeat); + +/* z=<adjustment time> <offset> <adjustment time> <offset> .... */ + +GST_SDP_API +guint gst_sdp_message_zones_len (const GstSDPMessage *msg); + +GST_SDP_API +const GstSDPZone* gst_sdp_message_get_zone (const GstSDPMessage *msg, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_message_insert_zone (GstSDPMessage *msg, gint idx, + GstSDPZone *zone); + +GST_SDP_API +GstSDPResult gst_sdp_message_replace_zone (GstSDPMessage *msg, guint idx, + GstSDPZone *zone); + +GST_SDP_API +GstSDPResult gst_sdp_message_remove_zone (GstSDPMessage *msg, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_message_add_zone (GstSDPMessage *msg, const gchar *adj_time, + const gchar *typed_time); + +/* k=<method>[:<encryption key>] */ + +GST_SDP_API +const GstSDPKey* gst_sdp_message_get_key (const GstSDPMessage *msg); + +GST_SDP_API +GstSDPResult gst_sdp_message_set_key (GstSDPMessage *msg, const gchar *type, + const gchar *data); +/* a=... */ + +GST_SDP_API +guint gst_sdp_message_attributes_len (const GstSDPMessage *msg); + +GST_SDP_API +const GstSDPAttribute* gst_sdp_message_get_attribute (const GstSDPMessage *msg, guint idx); + +GST_SDP_API +const gchar* gst_sdp_message_get_attribute_val (const GstSDPMessage *msg, + const gchar *key); + +GST_SDP_API +const gchar* gst_sdp_message_get_attribute_val_n (const GstSDPMessage *msg, + const gchar *key, guint nth); + +GST_SDP_API +GstSDPResult gst_sdp_message_insert_attribute (GstSDPMessage *msg, gint idx, + GstSDPAttribute *attr); + +GST_SDP_API +GstSDPResult gst_sdp_message_replace_attribute (GstSDPMessage *msg, guint idx, + GstSDPAttribute *attr); + +GST_SDP_API +GstSDPResult gst_sdp_message_remove_attribute (GstSDPMessage *msg, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_message_add_attribute (GstSDPMessage *msg, const gchar *key, + const gchar *value); + +/* m=.. sections */ + +GST_SDP_API +guint gst_sdp_message_medias_len (const GstSDPMessage *msg); + +GST_SDP_API +const GstSDPMedia* gst_sdp_message_get_media (const GstSDPMessage *msg, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_message_add_media (GstSDPMessage *msg, GstSDPMedia *media); + +GST_SDP_API +GstSDPResult gst_sdp_message_dump (const GstSDPMessage *msg); + +/* Media descriptions */ + +GST_SDP_API +GstSDPResult gst_sdp_media_new (GstSDPMedia **media); + +GST_SDP_API +GstSDPResult gst_sdp_media_init (GstSDPMedia *media); + +GST_SDP_API +GstSDPResult gst_sdp_media_uninit (GstSDPMedia *media); + +GST_SDP_API +GstSDPResult gst_sdp_media_free (GstSDPMedia *media); + +GST_SDP_API +GstSDPResult gst_sdp_media_copy (const GstSDPMedia *media, GstSDPMedia **copy); + +GST_SDP_API +gchar* gst_sdp_media_as_text (const GstSDPMedia *media); + +/* m=<media> <port>/<number of ports> <proto> <fmt> ... */ + +GST_SDP_API +const gchar* gst_sdp_media_get_media (const GstSDPMedia *media); + +GST_SDP_API +GstSDPResult gst_sdp_media_set_media (GstSDPMedia *media, const gchar *med); + +GST_SDP_API +guint gst_sdp_media_get_port (const GstSDPMedia *media); + +GST_SDP_API +guint gst_sdp_media_get_num_ports (const GstSDPMedia *media); + +GST_SDP_API +GstSDPResult gst_sdp_media_set_port_info (GstSDPMedia *media, guint port, + guint num_ports); + +GST_SDP_API +const gchar* gst_sdp_media_get_proto (const GstSDPMedia *media); + +GST_SDP_API +GstSDPResult gst_sdp_media_set_proto (GstSDPMedia *media, const gchar *proto); + +GST_SDP_API +guint gst_sdp_media_formats_len (const GstSDPMedia *media); + +GST_SDP_API +const gchar* gst_sdp_media_get_format (const GstSDPMedia *media, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_media_insert_format (GstSDPMedia *media, gint idx, + const gchar *format); + +GST_SDP_API +GstSDPResult gst_sdp_media_replace_format (GstSDPMedia *media, guint idx, + const gchar *format); + +GST_SDP_API +GstSDPResult gst_sdp_media_remove_format (GstSDPMedia *media, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_media_add_format (GstSDPMedia *media, const gchar *format); + +/* i=<session description> */ + +GST_SDP_API +const gchar* gst_sdp_media_get_information (const GstSDPMedia *media); + +GST_SDP_API +GstSDPResult gst_sdp_media_set_information (GstSDPMedia *media, const gchar *information); + +/* c=<nettype> <addrtype> <connection-address>[/<ttl>][/<number of addresses>] */ + +GST_SDP_API +guint gst_sdp_media_connections_len (const GstSDPMedia *media); + +GST_SDP_API +const GstSDPConnection* gst_sdp_media_get_connection (const GstSDPMedia *media, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_media_insert_connection (GstSDPMedia *media, gint idx, + GstSDPConnection *conn); + +GST_SDP_API +GstSDPResult gst_sdp_media_replace_connection (GstSDPMedia *media, guint idx, + GstSDPConnection *conn); + +GST_SDP_API +GstSDPResult gst_sdp_media_remove_connection (GstSDPMedia *media, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_media_add_connection (GstSDPMedia *media, + const gchar *nettype, + const gchar *addrtype, + const gchar *address, + guint ttl, guint addr_number); + +/* b=<bwtype>:<bandwidth> */ + +GST_SDP_API +guint gst_sdp_media_bandwidths_len (const GstSDPMedia *media); + +GST_SDP_API +const GstSDPBandwidth* gst_sdp_media_get_bandwidth (const GstSDPMedia *media, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_media_insert_bandwidth (GstSDPMedia *media, gint idx, + GstSDPBandwidth *bw); + +GST_SDP_API +GstSDPResult gst_sdp_media_replace_bandwidth (GstSDPMedia *media, guint idx, + GstSDPBandwidth *bw); + +GST_SDP_API +GstSDPResult gst_sdp_media_remove_bandwidth (GstSDPMedia *media, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_media_add_bandwidth (GstSDPMedia *media, const gchar *bwtype, + guint bandwidth); + +/* k=<method>:<encryption key> */ + +GST_SDP_API +const GstSDPKey* gst_sdp_media_get_key (const GstSDPMedia *media); + +GST_SDP_API +GstSDPResult gst_sdp_media_set_key (GstSDPMedia *media, const gchar *type, + const gchar *data); +/* a=... */ + +GST_SDP_API +guint gst_sdp_media_attributes_len (const GstSDPMedia *media); + +GST_SDP_API +const GstSDPAttribute * gst_sdp_media_get_attribute (const GstSDPMedia *media, guint idx); + +GST_SDP_API +const gchar* gst_sdp_media_get_attribute_val (const GstSDPMedia *media, const gchar *key); + +GST_SDP_API +const gchar* gst_sdp_media_get_attribute_val_n (const GstSDPMedia *media, const gchar *key, + guint nth); + +GST_SDP_API +GstSDPResult gst_sdp_media_insert_attribute (GstSDPMedia *media, gint idx, + GstSDPAttribute *attr); + +GST_SDP_API +GstSDPResult gst_sdp_media_replace_attribute (GstSDPMedia *media, guint idx, + GstSDPAttribute *attr); + +GST_SDP_API +GstSDPResult gst_sdp_media_remove_attribute (GstSDPMedia *media, guint idx); + +GST_SDP_API +GstSDPResult gst_sdp_media_add_attribute (GstSDPMedia *media, const gchar *key, + const gchar *value); + +GST_SDP_API +GstCaps* gst_sdp_media_get_caps_from_media (const GstSDPMedia *media, gint pt); + +GST_SDP_API +GstSDPResult gst_sdp_media_set_media_from_caps (const GstCaps* caps, GstSDPMedia *media); + +GST_SDP_API +gchar * gst_sdp_make_keymgmt (const gchar *uri, const gchar *base64); + +GST_SDP_API +GstSDPResult gst_sdp_message_parse_keymgmt (const GstSDPMessage *msg, GstMIKEYMessage **mikey); + +GST_SDP_API +GstSDPResult gst_sdp_media_parse_keymgmt (const GstSDPMedia *media, GstMIKEYMessage **mikey); + +GST_SDP_API +GstSDPResult gst_sdp_message_attributes_to_caps (const GstSDPMessage *msg, GstCaps *caps); + +GST_SDP_API +GstSDPResult gst_sdp_media_attributes_to_caps (const GstSDPMedia *media, GstCaps *caps); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstSDPMessage, gst_sdp_message_free) + +G_END_DECLS + +#endif /* __GST_SDP_MESSAGE_H__ */ diff --git a/include/gst/sdp/sdp-prelude.h b/include/gst/sdp/sdp-prelude.h new file mode 100644 index 0000000000..cecdfd0d31 --- /dev/null +++ b/include/gst/sdp/sdp-prelude.h @@ -0,0 +1,33 @@ +/* GStreamer SDP Library + * Copyright (C) 2018 GStreamer developers + * + * sdp-prelude.h: prelude include header for gst-sdp library + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_SDP_PRELUDE_H__ +#define __GST_SDP_PRELUDE_H__ + +#include <gst/gst.h> + +#ifdef BUILDING_GST_SDP +#define GST_SDP_API GST_API_EXPORT /* from config.h */ +#else +#define GST_SDP_API GST_API_IMPORT +#endif + +#endif /* __GST_SDP_PRELUDE_H__ */ diff --git a/include/gst/sdp/sdp.h b/include/gst/sdp/sdp.h new file mode 100644 index 0000000000..f7dd52740a --- /dev/null +++ b/include/gst/sdp/sdp.h @@ -0,0 +1,31 @@ +/* GStreamer + * Copyright (C) 2012 GStreamer developers + * + * gstsdp.h: single include header for gst-sdp library + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_SDP__H__ +#define __GST_SDP__H__ + +#include <gst/sdp/sdp-prelude.h> + +#include <gst/sdp/gstsdp.h> +#include <gst/sdp/gstsdpmessage.h> +#include <gst/sdp/gstmikey.h> + +#endif /* __GST_SDP__H__ */ |