]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_stasis.c: Added video_single option for bridge creation
authorSungtae Kim <pchero21@gmail.com>
Sun, 30 Aug 2020 20:42:06 +0000 (22:42 +0200)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Thu, 10 Sep 2020 14:48:30 +0000 (09:48 -0500)
Currently, it was not possible to create bridge with video_mode single.
This made hard to put the bridge in a vidoe_single mode.
So, added video_single option for Bridge creation using the ARI.
This allows create a bridge with video_mode single.

ASTERISK-29055

Change-Id: I43e720e5c83fc75fafe10fe22808ae7f055da2ae

main/bridge.c
res/ari/resource_bridges.h
res/res_stasis.c
res/stasis/stasis_bridge.c
res/stasis/stasis_bridge.h
rest-api/api-docs/bridges.json

index 351aaf13548fc6a3608494c0c0aac33e74f56a04..d3a87efbbd4b05917841d50adbe06fa950d8119f 100644 (file)
@@ -3792,13 +3792,15 @@ void ast_bridge_set_single_src_video_mode(struct ast_bridge *bridge, struct ast_
        ast_bridge_lock(bridge);
        cleanup_video_mode(bridge);
        bridge->softmix.video_mode.mode = AST_BRIDGE_VIDEO_MODE_SINGLE_SRC;
-       bridge->softmix.video_mode.mode_data.single_src_data.chan_vsrc = ast_channel_ref(video_src_chan);
-       ast_verb(5, "Video source in bridge '%s' (%s) is now '%s' (%s)\n",
-               bridge->name, bridge->uniqueid,
-               ast_channel_name(video_src_chan),
-               ast_channel_uniqueid(video_src_chan));
+       if (video_src_chan) {
+               bridge->softmix.video_mode.mode_data.single_src_data.chan_vsrc = ast_channel_ref(video_src_chan);
+               ast_verb(5, "Video source in bridge '%s' (%s) is now '%s' (%s)\n",
+                       bridge->name, bridge->uniqueid,
+                       ast_channel_name(video_src_chan),
+                       ast_channel_uniqueid(video_src_chan));
+               ast_indicate(video_src_chan, AST_CONTROL_VIDUPDATE);
+       }
        ast_bridge_publish_state(bridge);
-       ast_indicate(video_src_chan, AST_CONTROL_VIDUPDATE);
        ast_bridge_unlock(bridge);
 }
 
index 61fc6bb78da9c665f9ba9fe4bcbcc9505994152f..6dd252f41385e69d82880c9e693e7d4571ede2a6 100644 (file)
@@ -52,7 +52,7 @@ struct ast_ari_bridges_list_args {
 void ast_ari_bridges_list(struct ast_variable *headers, struct ast_ari_bridges_list_args *args, struct ast_ari_response *response);
 /*! Argument struct for ast_ari_bridges_create() */
 struct ast_ari_bridges_create_args {
-       /*! Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media). */
+       /*! Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_single). */
        const char *type;
        /*! Unique ID to give to the bridge being created. */
        const char *bridge_id;
@@ -82,7 +82,7 @@ int ast_ari_bridges_create_parse_body(
 void ast_ari_bridges_create(struct ast_variable *headers, struct ast_ari_bridges_create_args *args, struct ast_ari_response *response);
 /*! Argument struct for ast_ari_bridges_create_with_id() */
 struct ast_ari_bridges_create_with_id_args {
-       /*! Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media) to set. */
+       /*! Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_single) to set. */
        const char *type;
        /*! Unique ID to give to the bridge being created. */
        const char *bridge_id;
index 4850f6af2f0b0cd8985691d988b8636c0ab6590a..4db58faee0803829cda2ea843c12445115bd9063 100644 (file)
@@ -775,6 +775,7 @@ struct ast_bridge *stasis_app_bridge_create(const char *type, const char *name,
        int flags = AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM | AST_BRIDGE_FLAG_MERGE_INHIBIT_TO
                | AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM | AST_BRIDGE_FLAG_SWAP_INHIBIT_TO
                | AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY;
+       enum ast_bridge_video_mode_type video_mode = AST_BRIDGE_VIDEO_MODE_TALKER_SRC;
 
        while ((requested_type = strsep(&requested_types, ","))) {
                requested_type = ast_strip(requested_type);
@@ -787,6 +788,8 @@ struct ast_bridge *stasis_app_bridge_create(const char *type, const char *name,
                } else if (!strcmp(requested_type, "dtmf_events") ||
                        !strcmp(requested_type, "proxy_media")) {
                        capabilities &= ~AST_BRIDGE_CAPABILITY_NATIVE;
+               } else if (!strcmp(requested_type, "video_single")) {
+                       video_mode = AST_BRIDGE_VIDEO_MODE_SINGLE_SRC;
                }
        }
 
@@ -797,7 +800,7 @@ struct ast_bridge *stasis_app_bridge_create(const char *type, const char *name,
                return NULL;
        }
 
-       bridge = bridge_stasis_new(capabilities, flags, name, id);
+       bridge = bridge_stasis_new(capabilities, flags, name, id, video_mode);
        if (bridge) {
                if (!ao2_link(app_bridges, bridge)) {
                        ast_bridge_destroy(bridge, 0);
index 1b87b48a45923b78590d09f843b1ab1a2356ebd3..00dd4b9bea7fa609abac79d3d00b17e9c3262e97 100644 (file)
@@ -299,7 +299,7 @@ static void bridge_stasis_pull(struct ast_bridge *self, struct ast_bridge_channe
        ast_bridge_base_v_table.pull(self, bridge_channel);
 }
 
-struct ast_bridge *bridge_stasis_new(uint32_t capabilities, unsigned int flags, const char *name, const char *id)
+struct ast_bridge *bridge_stasis_new(uint32_t capabilities, unsigned int flags, const char *name, const char *id, enum ast_bridge_video_mode_type video_mode)
 {
        void *bridge;
 
@@ -309,7 +309,12 @@ struct ast_bridge *bridge_stasis_new(uint32_t capabilities, unsigned int flags,
                return NULL;
        }
 
-       ast_bridge_set_talker_src_video_mode(bridge);
+       if (video_mode == AST_BRIDGE_VIDEO_MODE_SINGLE_SRC) {
+               ast_bridge_set_single_src_video_mode(bridge, NULL);
+       } else {
+               ast_bridge_set_talker_src_video_mode(bridge);
+       }
+
        bridge = bridge_register(bridge);
 
        return bridge;
index 2590fd7996cad746f19238e2c63567ab2767a458..6e2a48bb3b7c0b57df3d0edf163c940bfc51e628 100644 (file)
@@ -50,11 +50,12 @@ extern "C" {
  * \param flags Flags that will alter the behavior of the bridge
  * \param name Name given to the bridge by Stasis (optional)
  * \param id Unique ID given to the bridge by Stasis (optional)
+ * \param video_mode Video mode of the bridge
  *
  * \retval a pointer to a new bridge on success
  * \retval NULL on failure
  */
-struct ast_bridge *bridge_stasis_new(uint32_t capabilities, unsigned int flags, const char *name, const char *id);
+struct ast_bridge *bridge_stasis_new(uint32_t capabilities, unsigned int flags, const char *name, const char *id, enum ast_bridge_video_mode_type video_mode);
 
 /*!
  * \internal
index 78bd3afadf55bd019ade3aacd11ee93a9dc1f3d9..6268c49e639fc75d4011754e2bed350e598e1c78 100644 (file)
@@ -26,7 +26,7 @@
                                        "parameters": [
                                                {
                                                        "name": "type",
-                                                       "description": "Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media).",
+                                                       "description": "Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_single).",
                                                        "paramType": "query",
                                                        "required": false,
                                                        "allowMultiple": false,
@@ -65,7 +65,7 @@
                                        "parameters": [
                                                {
                                                        "name": "type",
-                                                       "description": "Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media) to set.",
+                                                       "description": "Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media, video_single) to set.",
                                                        "paramType": "query",
                                                        "required": false,
                                                        "allowMultiple": false,