audio playback issue

prateek_sharma

New Member
function participantStream(session) {
var streamName = participantname;
publishStream = session.createStream({
name: streamName,
display: document.getElementById("participantview"),
constraints : {
audio : {deviceId : paudioid},
video : {deviceId : pcameraid}
}
}).on(STREAM_STATUS.PUBLISHING, function (publishStream) {
playStream(session)
});
publishStream.publish();
}

//MCU
function playStream(session) {
var streamName = roomname;
conferenceStream = session.createStream({
name: streamName,
display: document.getElementById("MCUview"),

}).on(STREAM_STATUS.PLAYING, function (stream) {
console.log("playing");
});
conferenceStream.play();
}



hello Max
i am facing an issue with audio
when i start the MCU and add my localstream in the MCU my audio falls back to me
please help me out.
 

Max

Administrator
Staff member
Good day.
Please check if the problem is reproducing in MCU Client example https://wcs:8444/client2/examples/demo/streaming/mcu_client/mcu_client.html
You can also try to implement a minimal MCU conference example as described here.
 

prateek_sharma

New Member
Good day.
Please check if the problem is reproducing in MCU Client example https://wcs:8444/client2/examples/demo/streaming/mcu_client/mcu_client.html
You can also try to implement a minimal MCU conference example as described here.
hello max
no problem face in MCU_client.html
i also set the
mixer_auto_start=true
mixer_mcu_audio=true
mixer_mcu_video=true

properties in flasphoner.properties file

when my application start, i create the mixer using REST API

var roomname = "room1";
var username = "abc";
const options = {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"uri": "mixer://"+roomname,
"localStreamName": roomname,
"mixerDisplayStreamName":true
}),
}
fetch(fetchUrl, options)

and then i add the stream using REST API

function addStream() {
fetchUrl = url + "/add";
const options = {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"uri": "mixer://"+roomname,
"remoteStreamName": username
}),
}
fetch(fetchUrl, options);
}

but the problem still occur
please help me out
 

Max

Administrator
Staff member
When using MCU mixer, you should play the stream named roomname-username, like
Code:
function playStream(session) {
var streamName = roomname + "-" + username;
conferenceStream = session.createStream({
name: streamName,
display: document.getElementById("MCUview"),

}).on(STREAM_STATUS.PLAYING, function (stream) {
console.log("playing");
});
conferenceStream.play();
}
This stream named room1-abc in your example contains all the video and audio tracks in mixer except abc users audio track. This is done to prevent echo. So you will not hear your own audion when playing it.
The mixer output stream room1 contains all the video and audio tracks mixed, so you can hear your own audio when playing it.
 

prateek_sharma

New Member
When using MCU mixer, you should play the stream named roomname-username, like
Code:
function playStream(session) {
var streamName = roomname + "-" + username;
conferenceStream = session.createStream({
name: streamName,
display: document.getElementById("MCUview"),

}).on(STREAM_STATUS.PLAYING, function (stream) {
console.log("playing");
});
conferenceStream.play();
}
This stream named room1-abc in your example contains all the video and audio tracks in mixer except abc users audio track. This is done to prevent echo. So you will not hear your own audion when playing it.
The mixer output stream room1 contains all the video and audio tracks mixed, so you can hear your own audio when playing it.
hello max


i did the above now i cannot see my MCU

//when localstreampublishing i call playStreamfunction like this

function startStreaming(session) {
var streamName = username;
var constraints =
{
audio : {deviceId : audioid},
video : {deviceId : cameraid,
}
}
publishStream = session.createStream({
name: streamName,
display: document.getElementById("host"),
constraints : constraints,
receiveVideo: false,
receiveAudio: false,
}) .on(STREAM_STATUS.PUBLISHING, function (publishStream) {
playStream(); //HERE I AM CALLING playstream function
console.log("publishing host stream", constraints);
});
publishStream.publish();
}

//MCU
function playStream() {
var session = Flashphoner.getSessions()[0];
console.log(session,"sesseion MCU");
var remoteVideo = document.getElementById("remoteVideo");
var streamName = roomname + "-" + username;
constraints = {
audio:true,
video:true
}
conferenceStream = session.createStream({
name: streamName,
display: remoteVideo,
constraints : constraints
}).play();
}

my mixer code
const options = {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"uri": "mixer://"+roomname,
"localStreamName": roomname,
"mixerDisplayStreamName":true
}),
}
fetch(fetchUrl, options)
 
Last edited:

Max

Administrator
Staff member
i did the above now i cannot see my MCU
Seems you're trying to play MCU mixer strea right after participants stream publishing. At the moment, mixer is not created yet, so playback fails.
You have to:
1. Publish participants stream
2. Call REST API to create a mixer and add participants stream to the mixer as you already do
3. Check if MCU stream is publishing by REST API query /stream/find
Code:
fetchUrl="http://wcs:8081/rest-api/stream/find"
const options = {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"name": roomname + "-" + username,
"published": true
}),
}
fetch(fetchUrl, options)
4. When /stream/find returns 200 OK, call playStream()
 

prateek_sharma

New Member
Seems you're trying to play MCU mixer strea right after participants stream publishing. At the moment, mixer is not created yet, so playback fails.
You have to:
1. Publish participants stream
2. Call REST API to create a mixer and add participants stream to the mixer as you already do
3. Check if MCU stream is publishing by REST API query /stream/find
Code:
fetchUrl="http://wcs:8081/rest-api/stream/find"
const options = {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"name": roomname + "-" + username,
"published": true
}),
}
fetch(fetchUrl, options)
4. When /stream/find returns 200 OK, call playStream()
thanks max
but i have one more query
suppose In MCU there are 2 stream are playing ,one is host and other is participant.
now,if i remove the localstream from the MCU(for ex : i removed host stream from the MCU),
then my stream of MCU that is PLAYING (on my page )is also removed and in this case i cannot see participant stream which is still playing in MCU

can you tell me how i can see other participant stream when i removed my stream from MCU.
 

Max

Administrator
Staff member
suppose In MCU there are 2 stream are playing ,one is host and other is participant.
now,if i remove the localstream from the MCU(for ex : i removed host stream from the MCU),
then my stream of MCU that is PLAYING (on my page )is also removed and in this case i cannot see participant stream which is still playing in MCU

can you tell me how i can see other participant stream when i removed my stream from MCU.
If you're host, and you stop the stream or removed it from mixer, then only participants stream remains in mixer. So if you need to see all the participants streams, you should play the main mixer output stream (roomname in your examples above):
1. Remove your stream host from mixer or stop publishing it
2. Then roomname-host stream playback is stopped
3. Play roomname instead of roomname-host
4. When host needs to be published again, stop playing roomname, publish host, add it to mixer and play roomname-host.
 

prateek_sharma

New Member
If you're host, and you stop the stream or removed it from mixer, then only participants stream remains in mixer. So if you need to see all the participants streams, you should play the main mixer output stream (roomname in your examples above):
1. Remove your stream host from mixer or stop publishing it
2. Then roomname-host stream playback is stopped
3. Play roomname instead of roomname-host
4. When host needs to be published again, stop playing roomname, publish host, add it to mixer and play roomname-host.
hello max
thank you
now i am facing issue when i stop the roomname-host and play roomname stream then my div element makes duplicate (makes duplicate when i trigger REST Api stream/terminate or playing stream)
i attached my screenshot please look at it ?
 

Attachments

Max

Administrator
Staff member
now i am facing issue when i stop the roomname-host and play roomname stream then my div element makes duplicate (makes duplicate when i trigger REST Api stream/terminate or playing stream)
Please look at Two Way Streaming example code, it shows how to play streams with a various names.
Also, you should not use /stream/terminate in this case. Stream.stop() method seems enough to stop playback or publishing at client side.
 

prateek_sharma

New Member
If you're host, and you stop the stream or removed it from mixer, then only participants stream remains in mixer. So if you need to see all the participants streams, you should play the main mixer output stream (roomname in your examples above):
1. Remove your stream host from mixer or stop publishing it
2. Then roomname-host stream playback is stopped
3. Play roomname instead of roomname-host
4. When host needs to be published again, stop playing roomname, publish host, add it to mixer and play roomname-host.
hey max this seems not reliable
if i am switching between this two mixer(1st mixer - "room1" and 2nd mixer - "room1-prateek"(without my own audio) )then there is a some delay
is there any alternate way of doing same thing without any delayed & dont playback my audio

thanks
 

prateek_sharma

New Member
hey max this seems not reliable
if i am switching between this two mixer(1st mixer - "room1" and 2nd mixer - "room1-prateek"(without my own audio) )then there is a some delay
is there any alternate way of doing same thing without any delayed & dont playback my audio

thanks
i want to use only one mixer where audio dont fallback to me and also see other participant when i removed my stream from the mixer
 

Max

Administrator
Staff member
if i am switching between this two mixer(1st mixer - "room1" and 2nd mixer - "room1-prateek"(without my own audio) )then there is a some delay
is there any alternate way of doing same thing without any delayed & dont playback my audio
i want to use only one mixer where audio dont fallback to me and also see other participant when i removed my stream from the mixer
Unfortunately, this is not possible. If you're playing main mixer stream, you will always hear all the participants audios including yours. That's why MCU mixer should be used if you want to hear all the others, but not yourself. But, if you remove your own stream from mixer, the corresponding MCU stream is also removed because no data to mix.
So you have to switch between two streams in your case.
Another option is to use RoomApi instead of mixer, but in this case channel bandwith should be wide enough: more participants, more streams, more channel load.
We also working on SFU functions which allows to add and remove video and audio smoothly, but it is not ready for production yet, and channel requirements are the same as for RoomApi: more participants, more bandwidth.
 

prateek_sharma

New Member
Unfortunately, this is not possible. If you're playing main mixer stream, you will always hear all the participants audios including yours. That's why MCU mixer should be used if you want to hear all the others, but not yourself. But, if you remove your own stream from mixer, the corresponding MCU stream is also removed because no data to mix.
So you have to switch between two streams in your case.
Another option is to use RoomApi instead of mixer, but in this case channel bandwith should be wide enough: more participants, more streams, more channel load.
We also working on SFU functions which allows to add and remove video and audio smoothly, but it is not ready for production yet, and channel requirements are the same as for RoomApi: more participants, more bandwidth.
Thank you max for this information
You said use roomapi for that but as per my application requirements is roomapi functionally able to add or remove and mute or unmute participant stream at host side?
can we do that
 

Max

Administrator
Staff member
You said use roomapi for that but as per my application requirements is roomapi functionally able to add or remove and mute or unmute participant stream at host side?
In RoomApi, streams published by participants are usual streams, so they can be muted/umuted on publisher side only. So you should provide some signaling messaging from host to participant to mute.
 

prateek_sharma

New Member
Unfortunately, this is not possible. If you're playing main mixer stream, you will always hear all the participants audios including yours. That's why MCU mixer should be used if you want to hear all the others, but not yourself. But, if you remove your own stream from mixer, the corresponding MCU stream is also removed because no data to mix.
So you have to switch between two streams in your case.
Another option is to use RoomApi instead of mixer, but in this case channel bandwith should be wide enough: more participants, more streams, more channel load.
We also working on SFU functions which allows to add and remove video and audio smoothly, but it is not ready for production yet, and channel requirements are the same as for RoomApi: more participants, more bandwidth.
hi max
i am trying to achieve use single mixer by giving my local stream name "room1-prateek" and then add it to the mixer but now mixer create "room1-room1-prateek"
is it possible to override it by "room1-prateek" or mixer use my stream name "room1-prateek" as it as without my own audio ?
because if it possible then it will be great for my application
 

Max

Administrator
Staff member
i am trying to achieve use single mixer by giving my local stream name "room1-prateek" and then add it to the mixer but now mixer create "room1-room1-prateek"
It is normal. MCU stream name without participants audio is formed as
Code:
{mixerName}-{incomingStreamName}
is it possible to override it by "room1-prateek" or mixer use my stream name "room1-prateek" as it as without my own audio ?
No. Two streams with the same name cannot be published on server.
 
Top