Aim: 2 users should be able to talk over audio and only one of them publishing video as well.
Assume 2 users are in session. Lets call the first user as operator and the second user as caller one.
Operator initiates a session and asks caller to join the session. Operator wants to see the video of caller and well as hear what the caller is speaking and for self it only wants to share audio and not video
I have tried implementing this but I can only hear callers audio and see callers video at operator but caller is not able to hear operators audio. Can anyone please help here
Below is the pulblisher configuration for operator
function getPublisherData() {
//Checking if the video is being streamed by caller or operator and publishing data on the basis of devices
//Publisher data for operator
$parameters.PublisherData = OV.initPublisher($parameters.Selector, {
audioSource: $parameters.IsAudioCapability ==true? undefined : false, // The source of audio. If undefined default microphone
videoSource: $parameters.IsVideoCapability == true ? undefined : false, // The source of video. If undefined default webcam
publishAudio: $parameters.IsAudioCapability ==true? true : false, // Whether you want to start publishing with your audio unmuted or not
publishVideo: true, // Whether you want to start publishing with your video enabled or not
resolution: '640x480', // The resolution of your video
frameRate: 30, // The frame rate of your video
insertMode: 'APPEND', // How the video is inserted in the target element 'video-container'
mirror: $parameters.IsFrontCamera
});
$resolve();
joinSession();
session.unpublish($parameters.PublisherData);
}
Below is the streamcreatedhandler for operator
function streamCreatedHandler(event) {
// if(event.target.streamManagers.length ===0 && $parameters.Recording){
// $actions.StartRecording();
// }
//$('#ShareWith').prop('disabled', false);
noofCallers++;
var subscriber = session.subscribe(event.stream, $parameters.Selector);
subscriber.on('videoElementCreated', function(event) {
loader(false);
$actions.CallerStreamed();
$("#muteUnmute").show();
EndedCall(false);
// Add a new HTML element for the user's name and nickname over its video
appendUserData(event.element, subscriber.stream.connection, event.stream);
$parameters.NumOfVideos++;
updateLayout();
//document.getElementById("SwitchStatus").value = true;
//document.getElementById("ShareWith").value = true;
});
}
Below is the publisher data configuration for caller:
function getPublisherData() {
//Getting device available on the caller side
//Publisher data for caller
$parameters.PublisherData = OV.initPublisher($parameters.Selector, {
audioSource: $parameters.IsAudioCapability ? undefined : false, // The source of audio. If undefined default microphone
videoSource: videoDevices.length > 0 ? videoDevices[videoDevices.length - 1].deviceId : undefined, // The source of video. If undefined default webcam
// videoSource: $parameters.IsFrontCamera ? videoDevices[0].deviceId : videoDevices[1].deviceId,
publishAudio: false, // Whether you want to start publishing with your audio unmuted or not
publishVideo: true, // Whether you want to start publishing with your video enabled or not
resolution: '640x480', // The resolution of your video
frameRate: 30, // The frame rate of your video
insertMode: 'APPEND', // How the video is inserted in the target element 'video-container'
mirror: $parameters.IsFrontCamera
});
$resolve();
joinSession();
}
Below is the streamcreatehandler for caller:
function streamCreatedHandler(event) {
if(event.stream.connection.data === '{"clientData":"Operator"}'){
var subscriber = session.subscribe(event.stream, $parameters.Selector);
subscriber.on('videoElementCreated', function(event) {
noOfCallers = 1;
// Add a new HTML element for the user's name and nickname over its video
appendUserData(event.element, subscriber.stream.connection, event.stream);
$parameters.NumOfVideos++;
updateLayout();
});
// When the HTML video has been appended to DOM...
}
//$actions.ActivateLiveChat()
}