]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11280: Allow overriding permissionCallback per Verto dialog
authorChad Phillips <chad@apartmentlines.com>
Thu, 26 Jul 2018 18:37:32 +0000 (13:37 -0500)
committerChad Phillips <chad@apartmentlines.com>
Thu, 26 Jul 2018 18:37:32 +0000 (13:37 -0500)
Currently the 'permissionCallback' object is only available at the Verto
instance level. This is problematic in multi-call scenarios, where an
individual call dialog needs access to the onGranted/onDenied callback
functions.

The patch adds a check for existence of onGranted/onDenied callback functions
at the dialog level, with a fallback to the original behavior of calling
onGranted/onDenied from the Verto instance if it's not available on the dialog.
This preserves backwards compatibility while allowing per-dialog overrides
going forward.

html5/verto/js/src/jquery.verto.js

index c913ca41404ed45275a15b18f2f97e0e22fd99ed..5db7951d7846f1e2071a36a690bb2a48248541d7 100644 (file)
         };
 
         RTCcallbacks.onStream = function(rtc, stream) {
-            if (dialog.verto.options.permissionCallback &&
+            if (dialog.callbacks.permissionCallback &&
+                typeof dialog.callbacks.permissionCallback.onGranted === 'function') {
+                dialog.callbacks.permissionCallback.onGranted(stream);
+            }
+            else if (dialog.verto.options.permissionCallback &&
                 typeof dialog.verto.options.permissionCallback.onGranted === 'function'){
                 dialog.verto.options.permissionCallback.onGranted(stream);
             }
         };
 
         RTCcallbacks.onError = function(e) {
-            if (dialog.verto.options.permissionCallback &&
+            if (dialog.callbacks.permissionCallback &&
+                typeof dialog.callbacks.permissionCallback.onDenied === 'function') {
+                dialog.callbacks.permissionCallback.onDenied();
+            }
+            else if (dialog.verto.options.permissionCallback &&
                 typeof dialog.verto.options.permissionCallback.onDenied === 'function'){
                 dialog.verto.options.permissionCallback.onDenied();
             }