Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to know whether its a audio or video call? #42

Open
itsazzad opened this issue Aug 16, 2017 · 2 comments
Open

How to know whether its a audio or video call? #42

itsazzad opened this issue Aug 16, 2017 · 2 comments

Comments

@itsazzad
Copy link

itsazzad commented Aug 16, 2017

How to know whether the caller requested a video/audio call?
Or, How to know the remote media constraint?

@itsazzad itsazzad reopened this Aug 27, 2017
@ramneekhanda
Copy link

did you get an answer for this? we are currently using react native xmpp with ejabberd for chat and would like to use the same connection for call init and negotiations..

@itsazzad
Copy link
Author

I had solved in a very much hacky way but I still hope that there having a better way:

            localMedia.start({
                mirror: true,
                audio: true,
                video: true,
            }, (err, stream) => {
                    session.addStream(localStream);
                    session.start();

                    if (!call.audio) {
                        localMedia.mute();
                    }
                    if (!call.video) {
                        localMedia.pauseVideo();
                    }

            });
        },

You can see that I am starting the call with both of audio and video media enabled and later after starting the session I am turning off Audio/Video.
So here I am starting the callee session similarly:

        client.on('jingle:incoming', (session, arg1) => {
            if (!session.isInitiator) {
                localMedia.start({
                    mirror: true,
                    audio: true,
                    video: true,
                });
            }
        });

And then the callee UI is getting the signal of Audio/Video off and turning off its Audio/Video accordingly for the very first time:

const callerMediaChangeCount = {
    audio: 0,
    video: 0,
};
function needCalleePrecedingMediaAction(mediaType, session) {
    return callerMediaChangeCount[mediaType] <= 1 && !session.isInitiator && session.connectionState === 'starting' && session.state === 'pending';
}
        client.on('jingle:mute', (session, arg1) => {
            callerMediaChangeCount.audio += 1;

            if (needCalleePrecedingMediaAction('audio', session)) {
                session.mute();
            }
        });
        client.on('jingle:unmute', (session, arg1) => {
            callerMediaChangeCount.audio += 1;

            if (needCalleePrecedingMediaAction('audio', session)) {
                session.unmute();
            }
        });
        client.on('jingle:hold', (session, arg1) => {
            callerMediaChangeCount.video += 1;

            if (needCalleePrecedingMediaAction('video', session)) {
                session.hold();
            }
        });
        client.on('jingle:resumed', (session, arg1) => {
            callerMediaChangeCount.video += 1;

            if (needCalleePrecedingMediaAction('video', session)) {
                session.resume();
            }
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants