Top

How to release a call

Answered

Comments

7 comments

  • Pascal BORSCHNECK

    Hi,

     

    Could you please also provide browser's Debug console ?
    I think there may be an exception somewhere which prevents your

    currentCall = call;

     

    As you are no using Angular, did you see the way to retrieve the "Call" Object described there
    https://hub.openrainbow.com/#/documentation/doc/sdk/web/guides/4-Make_audio_and_video_call ?

    I mean: at top of your code

    var Call = angular.element(document.querySelector('body')).injector().get('Call');

     

    0
    Comment actions Permalink
  • Laila NAJI
     
     
     
    thank you for your reply

    I already tried with the line "var Call = angular.element (document.querySelector ('body')). injector (). get ('Call');"
    when to call the variable "Call"?

    my code is:

     
    var Call = angular.element (document.querySelector ('body')). injector (). get ('Call');
     
    var currentCall = null
    function hang up () {
    alert ( "hanging up");


    var releaseCall = function releaseCall (call) {
    / * Call this API to release the call * /
    rainbowSDK.webRTC.release (currentCall);
    };
    var onWebRTCCallChanged = function onWebRTCCallChanged (event, call) {

                   
    switch (call.status.value) {

                       
    Call.Status.RINGING_INCOMMING.value box:
                           
    if (call.remoteMedia & Call.Media.VIDEO) {
                               
    answerInVideo (call);
                           
    }
                           
    else {
                               
    answerInAudio (call);
                           
    }
                           
    break;

                       
    Call.Status.ACTIVE.value box:
                           
    if (call.remoteMedia & Call.Media.VIDEO) {
                               
    displayRemoteVideo (call);
                           
    }
                           
    else {
                               
    hideRemoteVideo (call);
                           
    }

                           
    if (call.localMedia & Call.Media.VIDEO) {
                               
    displayLocalVideo (call);
                           
    } else {
                               
    hideLocalVideo (call);
                           
    }
                           
    $ scope.isInCommunication = true;
                           
    break;

                       
    Call.Status.UNKNOWN.value box:
                           
    hideLocalVideo ();
                           
    hideRemoteVideo (call);

                           
    break;

                       
    default:
                           
    console.log ("[DEMO] :: Nothing to do with that event ...");
                           
    break;
                   
    }

    currentCall = call;
            
    };
    var answerInVideo = function answerInVideo (call) {
                   
    console.log ("[DEMO] :: Answer in video");
                   
    rainbowSDK.webRTC.answerInVideo (call);
               
    };

               
    var answerInAudio = function answerInAudio (call) {
                   
    console.log ("[DEMO] :: Answer in audio");
                   
    rainbowSDK.webRTC.answerInAudio (call);
               
    };

               
    var displayRemoteVideo = function displayRemoteVideo (call) {
                   
    console.log ("[DEMO] :: Display remote video");
                   
    rainbowSDK.webRTC.showRemoteVideo (call);

               
    };

               
    var hideRemoteVideo = function hideRemoteVideo (call) {
                   
    console.log ("[DEMO] :: Hide remote video");
                   
    rainbowSDK.webRTC.hideRemoteVideo (call);

               
    };

               
    var displayLocalVideo = function displayLocalVideo () {
                   
    console.log ("[DEMO] :: Display local video");
                   
    rainbowSDK.webRTC.showLocalVideo ();

               
    };

               
    var hideLocalVideo = function hideLocalVideo () {
                   
    console.log ("[DEMO] :: Hide local video");
                   
    rainbowSDK.webRTC.hideLocalVideo ();

               
    };
        
    $ (document) .on (rainbowSDK.webRTC.RAINBOW_ONWEBRTCCALLSTATECHANGED, onWebRTCCallChanged);


    }
     
    browser's Debug console:

     
    can you look at my code ?
    0
    Comment actions Permalink
  • Laila NAJI

    Hi

    I'm waiting for your answer, why is the Call variable is always empty ??

    0
    Comment actions Permalink
  • Pascal BORSCHNECK

    Hi,

     

     var Call = angular.element (document.querySelector ('body')). injector (). get ('Call'); 

    will only get the Call object from angular, in ordre to be able to get the constant in the function onWebRTCCallChanged (event, call) 
    Move it perhaps inside the onWebRTCCallChanged (event, call)

     

    What do you mean "it is always empty" ?

     

    I would also move your (remove it forme where it is)

    currentCall = call;

    inside your code

    var answerInVideo = function answerInVideo (call) {

    and

               var answerInAudio = function answerInAudio (call) {

     

    Pascal

    0
    Comment actions Permalink
  • Laila NAJI

    Hi Pascal,

    The call passes, but the identifier of the call, retrieved via the method .... get (call), is not exploitable via the release (call) method called when you release. Yet this is the identifier of the call (call) in progress.


    When I want to display it, it is empty. Is there a way to display it to compare its 2 values (after the get and before the release)?

     

    when to call the function "onWebRTCCallChanged"?

    $(document).on(rainbowSDK.webRTC.RAINBOW_ONWEBRTCCALLSTATECHANGED, onWebRTCCallChanged);


    thank you for your help

    My code is simple (a call button and a hang up button), and it is not angular.

     

    NAJI.

    0
    Comment actions Permalink
  • Pascal BORSCHNECK

    Sorry, bad copy/paste, can you move the

    currentCall = call;

    inside

          case  Call.Status.ACTIVE.value:

     

    And I don't know in your code what is the "box" at the end of the "case" ("case" which are missing in your js code !)
    See example there: https://hub.openrainbow.com/#/documentation/doc/sdk/web/guides/4-Make_audio_and_video_call

    with:

    /* Somewhere in your application... */
    
        var onWebRTCCallChanged = function onWebRTCCallChanged(event, call) {
            /* Listen to WebRTC call state change */
            switch(call.status.value) {
                case call.Status.RINGING_INCOMMING.value:
                    /* Answer or reject the call */
                    rainbowSDK.webRTC.answerInVideo(call);
                    break;
                case call.Status.ACTIVE.value:
                    /* display the local and remote video */
                    rainbowSDK.webRTC.showLocalVideo();
                    rainbowSDK.webRTC.showRemoteVideo(call);
                    break;
                case call.Status.UNKNOWN.value:
                    /* Hiding the local and remote video */
                    rainbowSDK.webRTC.hideLocalVideo();
                    rainbowSDK.webRTC.hideRemoteVideo(call);
                    break;
                default:
                    break;
            }
        }
    0
    Comment actions Permalink
  • Laila NAJI
     
    Hi,
     
    Thank you for your answer, the problem has been solved.
     
    Naji
    0
    Comment actions Permalink

Please sign in to leave a comment.

Still can't find what you need?

  • Contact Us

    Do you have any question about Rainbow? Leave us a message to get more information.

    Contact
  • Ask the Community

    Do you need help? Ask your questions to the Community and get answers from other Rainbow users.

    Post message