CLI: Remove compatibility code.
[asterisk/asterisk.git] / main / sdp_options.c
index 1162f69..79efbaf 100644 (file)
 
 #include "sdp_private.h"
 
+#define DEFAULT_DTMF AST_SDP_DTMF_NONE
 #define DEFAULT_ICE AST_SDP_ICE_DISABLED
-#define DEFAULT_TELEPHONE_EVENT 0
 #define DEFAULT_IMPL AST_SDP_IMPL_STRING
 #define DEFAULT_ENCRYPTION AST_SDP_ENCRYPTION_DISABLED
+#define DEFAULT_MAX_STREAMS 16 /* Set to match our PJPROJECT PJMEDIA_MAX_SDP_MEDIA. */
 
 #define DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(field, assert_on_null) \
 void ast_sdp_options_set_##field(struct ast_sdp_options *options, const char *value) \
@@ -55,13 +56,21 @@ type ast_sdp_options_get_##field(const struct ast_sdp_options *options) \
 } \
 
 DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(media_address, 0);
+DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(interface_address, 0);
 DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(sdpowner, 0);
 DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(sdpsession, 0);
 DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(rtp_engine, 0);
 
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, bind_rtp_to_media_address);
+DEFINE_GETTERS_SETTERS_FOR(void *, state_context);
+DEFINE_GETTERS_SETTERS_FOR(ast_sdp_answerer_modify_cb, answerer_modify_cb);
+DEFINE_GETTERS_SETTERS_FOR(ast_sdp_offerer_modify_cb, offerer_modify_cb);
+DEFINE_GETTERS_SETTERS_FOR(ast_sdp_offerer_config_cb, offerer_config_cb);
+DEFINE_GETTERS_SETTERS_FOR(ast_sdp_preapply_cb, preapply_cb);
+DEFINE_GETTERS_SETTERS_FOR(ast_sdp_postapply_cb, postapply_cb);
 DEFINE_GETTERS_SETTERS_FOR(unsigned int, rtp_symmetric);
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, telephone_event);
+DEFINE_GETTERS_SETTERS_FOR(unsigned int, udptl_symmetric);
+DEFINE_GETTERS_SETTERS_FOR(enum ast_t38_ec_modes, udptl_error_correction);
+DEFINE_GETTERS_SETTERS_FOR(unsigned int, udptl_far_max_datagram);
 DEFINE_GETTERS_SETTERS_FOR(unsigned int, rtp_ipv6);
 DEFINE_GETTERS_SETTERS_FOR(unsigned int, g726_non_standard);
 DEFINE_GETTERS_SETTERS_FOR(unsigned int, rtcp_mux);
@@ -69,16 +78,127 @@ DEFINE_GETTERS_SETTERS_FOR(unsigned int, tos_audio);
 DEFINE_GETTERS_SETTERS_FOR(unsigned int, cos_audio);
 DEFINE_GETTERS_SETTERS_FOR(unsigned int, tos_video);
 DEFINE_GETTERS_SETTERS_FOR(unsigned int, cos_video);
+DEFINE_GETTERS_SETTERS_FOR(unsigned int, max_streams);
+DEFINE_GETTERS_SETTERS_FOR(enum ast_sdp_options_dtmf, dtmf);
 DEFINE_GETTERS_SETTERS_FOR(enum ast_sdp_options_ice, ice);
 DEFINE_GETTERS_SETTERS_FOR(enum ast_sdp_options_impl, impl);
 DEFINE_GETTERS_SETTERS_FOR(enum ast_sdp_options_encryption, encryption);
+DEFINE_GETTERS_SETTERS_FOR(unsigned int, ssrc);
+
+struct ast_sched_context *ast_sdp_options_get_sched_type(const struct ast_sdp_options *options, enum ast_media_type type)
+{
+       struct ast_sched_context *sched = NULL;
+
+       switch (type) {
+       case AST_MEDIA_TYPE_AUDIO:
+       case AST_MEDIA_TYPE_VIDEO:
+       case AST_MEDIA_TYPE_IMAGE:
+       case AST_MEDIA_TYPE_TEXT:
+               sched = options->sched[type];
+               break;
+       case AST_MEDIA_TYPE_UNKNOWN:
+       case AST_MEDIA_TYPE_END:
+               break;
+       }
+       return sched;
+}
+
+void ast_sdp_options_set_sched_type(struct ast_sdp_options *options, enum ast_media_type type, struct ast_sched_context *sched)
+{
+       switch (type) {
+       case AST_MEDIA_TYPE_AUDIO:
+       case AST_MEDIA_TYPE_VIDEO:
+       case AST_MEDIA_TYPE_IMAGE:
+       case AST_MEDIA_TYPE_TEXT:
+               options->sched[type] = sched;
+               break;
+       case AST_MEDIA_TYPE_UNKNOWN:
+       case AST_MEDIA_TYPE_END:
+               break;
+       }
+}
+
+struct ast_format_cap *ast_sdp_options_get_format_cap_type(const struct ast_sdp_options *options,
+       enum ast_media_type type)
+{
+       struct ast_format_cap *cap = NULL;
+
+       switch (type) {
+       case AST_MEDIA_TYPE_AUDIO:
+       case AST_MEDIA_TYPE_VIDEO:
+       case AST_MEDIA_TYPE_IMAGE:
+       case AST_MEDIA_TYPE_TEXT:
+               cap = options->caps[type];
+               break;
+       case AST_MEDIA_TYPE_UNKNOWN:
+       case AST_MEDIA_TYPE_END:
+               break;
+       }
+       return cap;
+}
+
+void ast_sdp_options_set_format_cap_type(struct ast_sdp_options *options,
+       enum ast_media_type type, struct ast_format_cap *cap)
+{
+       switch (type) {
+       case AST_MEDIA_TYPE_AUDIO:
+       case AST_MEDIA_TYPE_VIDEO:
+       case AST_MEDIA_TYPE_IMAGE:
+       case AST_MEDIA_TYPE_TEXT:
+               ao2_cleanup(options->caps[type]);
+               options->caps[type] = NULL;
+               if (cap && !ast_format_cap_empty(cap)) {
+                       ao2_ref(cap, +1);
+                       options->caps[type] = cap;
+               }
+               break;
+       case AST_MEDIA_TYPE_UNKNOWN:
+       case AST_MEDIA_TYPE_END:
+               break;
+       }
+}
+
+void ast_sdp_options_set_format_caps(struct ast_sdp_options *options,
+       struct ast_format_cap *cap)
+{
+       enum ast_media_type type;
+
+       for (type = AST_MEDIA_TYPE_UNKNOWN; type < AST_MEDIA_TYPE_END; ++type) {
+               ao2_cleanup(options->caps[type]);
+               options->caps[type] = NULL;
+       }
+
+       if (!cap || ast_format_cap_empty(cap)) {
+               return;
+       }
+
+       for (type = AST_MEDIA_TYPE_UNKNOWN + 1; type < AST_MEDIA_TYPE_END; ++type) {
+               struct ast_format_cap *type_cap;
+
+               type_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+               if (!type_cap) {
+                       continue;
+               }
+
+               ast_format_cap_set_framing(type_cap, ast_format_cap_get_framing(cap));
+               if (ast_format_cap_append_from_cap(type_cap, cap, type)
+                       || ast_format_cap_empty(type_cap)) {
+                       ao2_ref(type_cap, -1);
+                       continue;
+               }
+
+               /* This takes the allocation reference */
+               options->caps[type] = type_cap;
+       }
+}
 
 static void set_defaults(struct ast_sdp_options *options)
 {
+       options->dtmf = DEFAULT_DTMF;
        options->ice = DEFAULT_ICE;
-       options->telephone_event = DEFAULT_TELEPHONE_EVENT;
        options->impl = DEFAULT_IMPL;
        options->encryption = DEFAULT_ENCRYPTION;
+       options->max_streams = DEFAULT_MAX_STREAMS;
 }
 
 struct ast_sdp_options *ast_sdp_options_alloc(void)
@@ -101,6 +221,15 @@ struct ast_sdp_options *ast_sdp_options_alloc(void)
 
 void ast_sdp_options_free(struct ast_sdp_options *options)
 {
+       enum ast_media_type type;
+
+       if (!options) {
+               return;
+       }
+
+       for (type = AST_MEDIA_TYPE_UNKNOWN; type < AST_MEDIA_TYPE_END; ++type) {
+               ao2_cleanup(options->caps[type]);
+       }
        ast_string_field_free_memory(options);
        ast_free(options);
 }