Merge "res_calendar: Specialized calendars depend on symbols of general calendar."
[asterisk/asterisk.git] / main / channel_internal_api.c
index 7f32b21..d31ce94 100644 (file)
@@ -40,7 +40,6 @@
 #include "asterisk/paths.h"
 #include "asterisk/channel.h"
 #include "asterisk/channel_internal.h"
-#include "asterisk/data.h"
 #include "asterisk/endpoints.h"
 #include "asterisk/indications.h"
 #include "asterisk/stasis_cache_pattern.h"
@@ -219,217 +218,13 @@ struct ast_channel {
        struct stasis_forward *endpoint_forward;        /*!< Subscription for event forwarding to endpoint's topic */
        struct stasis_forward *endpoint_cache_forward; /*!< Subscription for cache updates to endpoint's topic */
        struct ast_stream_topology *stream_topology; /*!< Stream topology */
+       void *stream_topology_change_source; /*!< Source that initiated a stream topology change */
        struct ast_stream *default_streams[AST_MEDIA_TYPE_END]; /*!< Default streams indexed by media type */
 };
 
 /*! \brief The monotonically increasing integer counter for channel uniqueids */
 static int uniqueint;
 
-/* AST_DATA definitions, which will probably have to be re-thought since the channel will be opaque */
-
-#if 0  /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
-#define DATA_EXPORT_CALLERID(MEMBER)                           \
-       MEMBER(ast_callerid, cid_dnid, AST_DATA_STRING)         \
-       MEMBER(ast_callerid, cid_num, AST_DATA_STRING)          \
-       MEMBER(ast_callerid, cid_name, AST_DATA_STRING)         \
-       MEMBER(ast_callerid, cid_ani, AST_DATA_STRING)          \
-       MEMBER(ast_callerid, cid_pres, AST_DATA_INTEGER)        \
-       MEMBER(ast_callerid, cid_ani2, AST_DATA_INTEGER)        \
-       MEMBER(ast_callerid, cid_tag, AST_DATA_STRING)
-
-AST_DATA_STRUCTURE(ast_callerid, DATA_EXPORT_CALLERID);
-#endif
-
-#define DATA_EXPORT_CHANNEL(MEMBER)                                            \
-       MEMBER(ast_channel, blockproc, AST_DATA_STRING)                         \
-       MEMBER(ast_channel, appl, AST_DATA_STRING)                              \
-       MEMBER(ast_channel, data, AST_DATA_STRING)                              \
-       MEMBER(ast_channel, name, AST_DATA_STRING) \
-       MEMBER(ast_channel, language, AST_DATA_STRING)                          \
-       MEMBER(ast_channel, musicclass, AST_DATA_STRING)                        \
-       MEMBER(ast_channel, accountcode, AST_DATA_STRING)                       \
-       MEMBER(ast_channel, peeraccount, AST_DATA_STRING)                       \
-       MEMBER(ast_channel, userfield, AST_DATA_STRING)                         \
-       MEMBER(ast_channel, call_forward, AST_DATA_STRING)                      \
-       MEMBER(ast_channel, parkinglot, AST_DATA_STRING)                        \
-       MEMBER(ast_channel, hangupsource, AST_DATA_STRING)                      \
-       MEMBER(ast_channel, dialcontext, AST_DATA_STRING)                       \
-       MEMBER(ast_channel, rings, AST_DATA_INTEGER)                            \
-       MEMBER(ast_channel, priority, AST_DATA_INTEGER)                         \
-       MEMBER(ast_channel, macropriority, AST_DATA_INTEGER)                    \
-       MEMBER(ast_channel, adsicpe, AST_DATA_INTEGER)                          \
-       MEMBER(ast_channel, fin, AST_DATA_UNSIGNED_INTEGER)                     \
-       MEMBER(ast_channel, fout, AST_DATA_UNSIGNED_INTEGER)                    \
-       MEMBER(ast_channel, emulate_dtmf_duration, AST_DATA_UNSIGNED_INTEGER)   \
-       MEMBER(ast_channel, visible_indication, AST_DATA_INTEGER)               \
-       MEMBER(ast_channel, context, AST_DATA_STRING)                           \
-       MEMBER(ast_channel, exten, AST_DATA_STRING)                             \
-       MEMBER(ast_channel, macrocontext, AST_DATA_STRING)                      \
-       MEMBER(ast_channel, macroexten, AST_DATA_STRING)
-
-AST_DATA_STRUCTURE(ast_channel, DATA_EXPORT_CHANNEL);
-
-static void channel_data_add_flags(struct ast_data *tree,
-       struct ast_channel *chan)
-{
-       ast_data_add_bool(tree, "DEFER_DTMF", ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF));
-       ast_data_add_bool(tree, "WRITE_INT", ast_test_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT));
-       ast_data_add_bool(tree, "BLOCKING", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING));
-       ast_data_add_bool(tree, "ZOMBIE", ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE));
-       ast_data_add_bool(tree, "EXCEPTION", ast_test_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION));
-       ast_data_add_bool(tree, "MOH", ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH));
-       ast_data_add_bool(tree, "SPYING", ast_test_flag(ast_channel_flags(chan), AST_FLAG_SPYING));
-       ast_data_add_bool(tree, "IN_AUTOLOOP", ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP));
-       ast_data_add_bool(tree, "OUTGOING", ast_test_flag(ast_channel_flags(chan), AST_FLAG_OUTGOING));
-       ast_data_add_bool(tree, "IN_DTMF", ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF));
-       ast_data_add_bool(tree, "EMULATE_DTMF", ast_test_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF));
-       ast_data_add_bool(tree, "END_DTMF_ONLY", ast_test_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY));
-       ast_data_add_bool(tree, "MASQ_NOSTREAM", ast_test_flag(ast_channel_flags(chan), AST_FLAG_MASQ_NOSTREAM));
-       ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_RUN));
-       ast_data_add_bool(tree, "DISABLE_WORKAROUNDS", ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS));
-       ast_data_add_bool(tree, "DISABLE_DEVSTATE_CACHE", ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_DEVSTATE_CACHE));
-       ast_data_add_bool(tree, "BRIDGE_DUAL_REDIRECT_WAIT", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT));
-       ast_data_add_bool(tree, "ORIGINATED", ast_test_flag(ast_channel_flags(chan), AST_FLAG_ORIGINATED));
-       ast_data_add_bool(tree, "DEAD", ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEAD));
-}
-
-int ast_channel_data_add_structure(struct ast_data *tree,
-       struct ast_channel *chan, int add_bridged)
-{
-       struct ast_data *data_bridged;
-       struct ast_data *data_cdr;
-       struct ast_data *data_flags;
-       struct ast_data *data_zones;
-       struct ast_data *enum_node;
-       struct ast_data *data_softhangup;
-#if 0  /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
-       struct ast_data *data_callerid;
-       char value_str[100];
-#endif
-
-       if (!tree) {
-               return -1;
-       }
-
-       ast_data_add_structure(ast_channel, tree, chan);
-
-       if (add_bridged) {
-               RAII_VAR(struct ast_channel *, bc, ast_channel_bridge_peer(chan), ast_channel_cleanup);
-               if (bc) {
-                       data_bridged = ast_data_add_node(tree, "bridged");
-                       if (!data_bridged) {
-                               return -1;
-                       }
-                       ast_channel_data_add_structure(data_bridged, bc, 0);
-               }
-       }
-
-       ast_data_add_str(tree, "uniqueid", ast_channel_uniqueid(chan));
-       ast_data_add_str(tree, "linkedid", ast_channel_linkedid(chan));
-
-       ast_data_add_codec(tree, "oldwriteformat", ast_channel_oldwriteformat(chan));
-       ast_data_add_codec(tree, "readformat", ast_channel_readformat(chan));
-       ast_data_add_codec(tree, "writeformat", ast_channel_writeformat(chan));
-       ast_data_add_codec(tree, "rawreadformat", ast_channel_rawreadformat(chan));
-       ast_data_add_codec(tree, "rawwriteformat", ast_channel_rawwriteformat(chan));
-       ast_data_add_codecs(tree, "nativeformats", ast_channel_nativeformats(chan));
-
-       /* state */
-       enum_node = ast_data_add_node(tree, "state");
-       if (!enum_node) {
-               return -1;
-       }
-       ast_data_add_str(enum_node, "text", ast_state2str(ast_channel_state(chan)));
-       ast_data_add_int(enum_node, "value", ast_channel_state(chan));
-
-       /* hangupcause */
-       enum_node = ast_data_add_node(tree, "hangupcause");
-       if (!enum_node) {
-               return -1;
-       }
-       ast_data_add_str(enum_node, "text", ast_cause2str(ast_channel_hangupcause(chan)));
-       ast_data_add_int(enum_node, "value", ast_channel_hangupcause(chan));
-
-       /* amaflags */
-       enum_node = ast_data_add_node(tree, "amaflags");
-       if (!enum_node) {
-               return -1;
-       }
-       ast_data_add_str(enum_node, "text", ast_channel_amaflags2string(ast_channel_amaflags(chan)));
-       ast_data_add_int(enum_node, "value", ast_channel_amaflags(chan));
-
-       /* transfercapability */
-       enum_node = ast_data_add_node(tree, "transfercapability");
-       if (!enum_node) {
-               return -1;
-       }
-       ast_data_add_str(enum_node, "text", ast_transfercapability2str(ast_channel_transfercapability(chan)));
-       ast_data_add_int(enum_node, "value", ast_channel_transfercapability(chan));
-
-       /* _softphangup */
-       data_softhangup = ast_data_add_node(tree, "softhangup");
-       if (!data_softhangup) {
-               return -1;
-       }
-       ast_data_add_bool(data_softhangup, "dev", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_DEV);
-       ast_data_add_bool(data_softhangup, "asyncgoto", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_ASYNCGOTO);
-       ast_data_add_bool(data_softhangup, "shutdown", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_SHUTDOWN);
-       ast_data_add_bool(data_softhangup, "timeout", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_TIMEOUT);
-       ast_data_add_bool(data_softhangup, "appunload", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_APPUNLOAD);
-       ast_data_add_bool(data_softhangup, "explicit", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_EXPLICIT);
-
-       /* channel flags */
-       data_flags = ast_data_add_node(tree, "flags");
-       if (!data_flags) {
-               return -1;
-       }
-       channel_data_add_flags(data_flags, chan);
-
-       ast_data_add_uint(tree, "timetohangup", ast_channel_whentohangup(chan)->tv_sec);
-
-#if 0  /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
-       /* callerid */
-       data_callerid = ast_data_add_node(tree, "callerid");
-       if (!data_callerid) {
-               return -1;
-       }
-       ast_data_add_structure(ast_callerid, data_callerid, &(chan->cid));
-       /* insert the callerid ton */
-       enum_node = ast_data_add_node(data_callerid, "cid_ton");
-       if (!enum_node) {
-               return -1;
-       }
-       ast_data_add_int(enum_node, "value", chan->cid.cid_ton);
-       snprintf(value_str, sizeof(value_str), "TON: %s/Plan: %s",
-               party_number_ton2str(chan->cid.cid_ton),
-               party_number_plan2str(chan->cid.cid_ton));
-       ast_data_add_str(enum_node, "text", value_str);
-#endif
-
-       /* tone zone */
-       if (ast_channel_zone(chan)) {
-               data_zones = ast_data_add_node(tree, "zone");
-               if (!data_zones) {
-                       return -1;
-               }
-               ast_tone_zone_data_add_structure(data_zones, ast_channel_zone(chan));
-       }
-
-       /* insert cdr */
-       data_cdr = ast_data_add_node(tree, "cdr");
-       if (!data_cdr) {
-               return -1;
-       }
-
-       return 0;
-}
-
-int ast_channel_data_cmp_structure(const struct ast_data_search *tree,
-       struct ast_channel *chan, const char *structure_name)
-{
-       return ast_data_search_cmp_structure(tree, ast_channel, chan, structure_name);
-}
-
 /* ACCESSORS */
 
 #define DEFINE_STRINGFIELD_SETTERS_FOR(field, publish, assert_on_null) \
@@ -838,6 +633,17 @@ void ast_channel_internal_set_stream_topology(struct ast_channel *chan,
        channel_set_default_streams(chan);
 }
 
+void ast_channel_internal_set_stream_topology_change_source(
+       struct ast_channel *chan, void *change_source)
+{
+       chan->stream_topology_change_source = change_source;
+}
+
+void *ast_channel_get_stream_topology_change_source(struct ast_channel *chan)
+{
+       return chan->stream_topology_change_source;
+}
+
 void ast_channel_nativeformats_set(struct ast_channel *chan,
        struct ast_format_cap *value)
 {