Merge "core/frame: Fix ast_frdup() and ast_frisolate() for empty text frames"
[asterisk/asterisk.git] / main / core_unreal.c
index 1f5c202..763be4f 100644 (file)
@@ -32,8 +32,6 @@
 
 #include "asterisk.h"
 
-ASTERISK_REGISTER_FILE()
-
 #include "asterisk/causes.h"
 #include "asterisk/channel.h"
 #include "asterisk/stasis_channels.h"
@@ -325,6 +323,20 @@ int ast_unreal_write(struct ast_channel *ast, struct ast_frame *f)
                return -1;
        }
 
+       /* If we are told to write a frame with a type that has no corresponding
+        * stream on the channel then drop it.
+        */
+       if (f->frametype == AST_FRAME_VOICE) {
+               if (!ast_channel_get_default_stream(ast, AST_MEDIA_TYPE_AUDIO)) {
+                       return 0;
+               }
+       } else if (f->frametype == AST_FRAME_VIDEO ||
+               (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_VIDUPDATE)) {
+               if (!ast_channel_get_default_stream(ast, AST_MEDIA_TYPE_VIDEO)) {
+                       return 0;
+               }
+       }
+
        /* Just queue for delivery to the other side */
        ao2_ref(p, 1);
        ao2_lock(p);
@@ -566,6 +578,11 @@ int ast_unreal_indicate(struct ast_channel *ast, int condition, const void *data
                        res = -1;
                }
                break;
+       case AST_CONTROL_PVT_CAUSE_CODE:
+               /* Return -1 so that asterisk core will correctly set up hangupcauses. */
+               unreal_queue_indicate(p, ast, condition, data, datalen);
+               res = -1;
+               break;
        default:
                res = unreal_queue_indicate(p, ast, condition, data, datalen);
                break;
@@ -800,7 +817,6 @@ int ast_unreal_channel_push_to_bridge(struct ast_channel *ast, struct ast_bridge
        /* Impart the semi2 channel into the bridge */
        if (ast_bridge_impart(bridge, chan, NULL, features,
                AST_BRIDGE_IMPART_CHAN_INDEPENDENT)) {
-               ast_bridge_features_destroy(features);
                ast_channel_unref(chan);
                return -1;
        }