How to suppress permisson request to microphone in browsers?

Max

Administrator
Staff member
I had connected the "player" app to the matching stream ("stream78")
The audio only stream should be played in a browser by explicitly constraints setting in player script when stream is created, for example
Code:
session.createStream({constraints:{audio:true,video:false}).play();
So you should modify Player application script /client2/examples/demo/streaming/player/player.js as
Code:
function playStream(session) {
    var streamName = $('#streamName').val();
    var options = {
        name: streamName,
        display: remoteVideo,
        flashShowFullScreenButton: true,
        constraints: {video: false, audio: true}
    };
...
 

marcw

Member
DAMN, IT'S WORKING!!! :):)
I only have some voice quality issues now. My voice, and also the played wav fles, are about 30% too slow.
One other point: When I have played a wav file with the sound_on command I am not able to play any further wav files. Even if I wait until the other payback ended.
However, I am happy so far that I have now all elements to bring them together. :)

Best
Marc
 

Max

Administrator
Staff member
I only have some voice quality issues now
It is audio codecs issue. Try to remove "speex16" from codecs list in flashphoner.properties file.
When I have played a wav file with the sound_on command I am not able to play any further wav files. Even if I wait until the other payback ended.
We try to reproduce and will see what to do with it.
 

marcw

Member
Deleting the speex16 codec didn't help. Also increasing the RAM for Java not. (followed by WCS restart) I will try to check the tweaking hints later today. May be I find something there. I also recognized that the cpu usage for Java is rather high with about 25% only for my test. Okay, 25% listed in "top". That may be down-calculated to one singe cpu. I have a i7-8700 Hexa-Core with 64GB RAM.

Best
Marc
 

Max

Administrator
Staff member
I also recognized that the cpu usage for Java is rather high with about 25% only for my test
In your case we have a transcoding from voice call stream to RTMP stream, that consumes CPU a lot. Physics can not be fooled.
Deleting the speex16 codec didn't help
Try to replace this
Code:
m=audio 0 RTP/AVP 8
a=rtpmap:8 PCMA/8000
with this
Code:
m=audio 0 RTP/AVP 97 8
a=rtpmap:97 PCMA-WB/16000
a=rtpmap:8 PCMA/8000
in media_transponder.sdp file
 

Max

Administrator
Staff member
When I have played a wav file with the sound_on command I am not able to play any further wav files. Even if I wait until the other payback ended.
After /push/sound_on request you should send /push/sound_off, then /push/sound_on to play next file.
As we see, your SIP sends PCMA audio. We added file WCS_HOME/conf/flash_handler_publish.sdp to make sure that RTMP stream will be published with PCMA audio track. This must help to escape unnecessary audio transcoding and to make voice quality better.
 

marcw

Member
Hi Max!
OFF -> ON is working, thank you!
And the other issue: It was my mistake, very sorry for that! When I tried it yesterday for the very first time, it worked like a charme. I could hear my own voice (phone -> web app) in very good quality and with a smallest latency I ever realized! Only sending the wav into the running media session was not played back. (but no error message). Then I changed a little think. I replaced the stream id which I enter on the player app website from "stream80" into "rtmp_stream80". Then the wav playback worked but that too slow playback with gaps begins.
Conclusion:
Great audio quality with "stream80" as stream name but no wav playback
Poor audio quality with "rtmp_stream80" but able to play back the wav file

And sorry again for missing my own stream name change as the reason for the problem. I leave your optimizations anyway. The audio quality couldn't be better. Any idea why the wav blayback doesn't work?

Best
Marc
 

Max

Administrator
Staff member
Good morning, Marc.
Let's clarify your case again.
If you want to:
1. Make a SIP call
2. Play a wav file to SIP call (and callee should hear this file too)
3. Play a SIP call via WebRTC in browser
why don't you use /call/inject_sound REST query, for example
http://www.locophono.com:8081/rest-api/call/startup
{
"callId":"7",
"toStream":"stream77",
"callee":"00491777000001",
"hasAudio":"true",
"hasVideo":"false",
"sipLogin":"marcwaesche",
"sipAuthenticationName":"marcwaesche",
"sipPassword":"xxxxxx",
"sipDomain":"77.72.174.xxx",
"sipOutboundProxy":"77.72.174.xxx",
"sipPort":"6000",
"appKey":"xxx",
"sipRegisterRequired":"true"
}

http://www.locophono.com:8081/rest-api/call/inject_sound
{
"callId":"7",
"fileName":"facebook_5.wav"
}
and then play stream77 in browser with Player example?
 

Max

Administrator
Staff member
/call/inject_sound is not suitable for you, because wav file will be heared by callee only.
But you can make audio quality better. RTMP stream has PCMA audiotrack, but Player example in browser tries to play PCMU, so quality falls due to transcoding from one to another. To make browser play PCMA, you should modify Player application script /client2/examples/demo/streaming/player/player.js as
Code:
function playStream(session) {
    var streamName = $('#streamName').val();
    var options = {
        name: streamName,
        display: remoteVideo,
        flashShowFullScreenButton: true,
        constraints: {video: false, audio: true},
        stripCodecs: "PCMU"
    };
and voice quality will be better.
 

marcw

Member
Hi Max!
Also that didn't help. After adjusting the player.js and using "rtmp_stream80" as the stream instead of "stream80" the wav is again hearable in the browser but again with unacceptable slow playback with gaps. Also it seems that the (bad quality) playback does not mix the stream from the callee into it. Example: The wav is been playing back in the browser and the callee is saying something meanwhile then the browser does not play back also the stream from the callee. That is a must in my scenario.
Undependingly from that I can also use any other audio file format. It must not be wav. On my WCS4 I am using sln files.

Best
Marc
 

Max

Administrator
Staff member
Hello Marc.
We work on RTMP stream playback issue.
And yes, /push/sound_on does not mix the sound from file to stream.
So, in your case you should use mixer function, by this way:
1. Make a call with /call/startup, "toStream": "stream88"
2. Play an MP4 file with /client2/examples/demo/streaming/player/player.js, set streamName to "vod://file.mp4". Modify script as
Code:
function onStarted(stream) {
    $("#playBtn").text("Stop").off('click').click(function(){
        $(this).prop('disabled', true);
        stream.stop();
    }).prop('disabled', false);
    $("#fullScreenBtn").off('click').click(function(){
       stream.fullScreen();
    }).prop('disabled', false);
    $("#volumeControl").slider("enable");
//    stream.setVolume(currentVolumeValue);
    stream.setVolume(0);
}
to not to hear the sound from file.
3. Find a stream with /stream/find_all, get the stream name, this must be sessionId-vod://file.mp4
4. Create a mixer
Code:
/mixer/startup
{
"uri": "mixer://mixer1",
"localStreamName": "mixer_stream",
"hasVideo": "false"
}
5, Add streams to mixer
Code:
/mixer/add
{
"uri": "mixer://mixer1",
"remoteStreamName": "stream88"
}
/mixer/add
{
"uri": "mixer://mixer1",
"remoteStreamName": "sessionId-vod://file.mp4"
}
6. Play mixer output stream mixer_stream in browser (don't forget to set the volume up to hear the sound)
You should set the parameter
Code:
mixer_video_enabled=false
in file flashphoner.properties to mix audio only.
So, you have to convert sound file to MP4 (AAC codec) for VOD capture function to work.
 

marcw

Member
Hi Max!
Unfortunatelly I couldn't hear anything. Is also seems that the player app's volume slider doesn't get the

instruction stream.setVolume(0);
in the modified player.js function. The slider is set in the default position at about 50%. May be this is an indicatior for you for anything. And even if I replace

stream.setVolume(0); with stream.setVolume(currentVolumeValue);
I cannot hear anything. I tried it with http and with https commands. My commands are below.

But two other points to find out if this solution (if working) is suitable for my project.

1. You recommended to set the volume in the player to 0 to surpress audio for so long as the mixed stream is available. For testing purposes okay but in production mode that audio clips must be hearable right away after being started. I think that there will be nothing cut from the audio beginning if I let process the different commands (starting play, starting mixed, adding 2 streams to the mixer) later via script. Then this is not an issue.

2. Is this way with the mixer as described by you (many, many thanks to you by the way for all your input and your kindness for rethinking about totally different solutions!) really suitable if there is not only one but several audio files to be played one after the other? I couldn't test it but it seems a bit that the flow is always completely interrupted when I start a following audio clip because another audio clip created a new session id. I mean that in this solution not the stream between the WCS and the user is established first but the start of an audio file playback creates a unique session where the endpoints are added to in a second step. A creative idea and absolute fine as far as the mergings are fast enough (my point 1) and if the audio stream to the user (and to the callee) is not interrupted when a second audio clip is started.

Best regards
Marc




https://www.locophono.com:8444/rest-api/call/startup

{
"callId":"8",
"callee":"00491777000001",
"hasAudio":"true",
"hasVideo":"false",
"sipLogin":"marcwaesche",
"sipAuthenticationName":"marcwaesche",
"sipPassword":"xxxxxxx",
"sipDomain":"77.72.174.xxx",
"sipOutboundProxy":"77.72.174.xxx",
"sipPort":"6000",
"appKey":"xxxx",
"sipRegisterRequired":"true",
"toStream":"stream88"
}

Player-App -> Stream = vod://facebook_5.mp4




https://www.locophono.com:8444/rest-api/stream/find_all
{}
-> to get the stream name, this must be sessionId vod://facebook_5.mp4



https://www.locophono.com:8444/rest-api/mixer/startup
{
"uri": "mixer://mixer1",
"localStreamName": "mixer_stream",
"hasVideo": "false"
}


https://www.locophono.com:8444/rest-api/mixer/add
{
"uri": "mixer://mixer1",
"remoteStreamName": "stream88"
}

https://www.locophono.com:8444/rest-api/mixer/add
{
"uri": "mixer://mixer1",
"remoteStreamName": "/62.143.33.90:50465/195.201.166.182:8443-vod://facebook_5.mp4"
}
 

marcw

Member
Seems I found the reason in the logs:
AAC - AudioProcessor-49640f93-f6d9-40f6-acfd-e4ea0dc22e76 Dropping AAC frame that starts with 0
[1000s of such entrys]
I'll try to check that out!
 

marcw

Member
Ah, yes! Now it works as you imagined! And great audio quality! :) I'll make some more tests now to find out about the question with the following audio files.

Best
Marc
 

Max

Administrator
Staff member
Good morning, Marc.
Seems I found the reason in the logs
Yes, WCS does not support AAC frames of type 0, so, if audio track in file contains only this type, no sound will be heared.
it seems a bit that the flow is always completely interrupted when I start a following audio clip because another audio clip created a new session id
Yes, when you play the following file, the new session is created. But mixer output stream will not be interrupted in this case, so you should play mixer output stream to the user (and inject it back to the call). If you need to play several files, you just add to mixer the stream from next file, and so on.
 

marcw

Member
Hello Max!
Here I'm back. A bit late. Sorry. To safe you from reading all again I reduce my question to the minimum. You final recommendation how I can handle the audio stream mix between user, callee and the audio files which the user can inject/mix into the existing stream was this way:
1. http://www.locophono.com:8081/rest-api/call/startup
2. playback a stream in the player app i.e. vod://facebook_9.mp4 (muted)
3. http://www.locophono.com:8081/rest-api/stream/find_all // to find stream name of 2.
4. http://www.locophono.com:8081/rest-api/mixer/startup // to start mixer_stream3
5. http://www.locophono.com:8081/rest-api/mixer/add // to add 1.
6. http://www.locophono.com:8081/rest-api/mixer/add // to add 2.
7. playback mixer_stream3 in a second player app

Looks a bit strange but works so far. Just I would like to know it the first stream (vod://facebook_9.mp4) must really be started in the player app? That would mean that I always have to start a new player when I just want to add another audio clip into the mixer. Or not? Because the mixer/startup needs the stream name and that one I can only grab (in the way described) after having started playback in the player.

Best regards
Marc
 

Max

Administrator
Staff member
Hello, Marc

Currently, there is no simpler solution in the case than starting playback as vod for each mp4 file.
Can try using the same display element when creating the streams.
Also, can play only audio.

Code:
session.createStream({
    name: "vod://file1.mp4",
    constraints: {
        audio: true,
        video: false
    },
    display: display
}).play();

session.createStream({
    name: "vod://file2.mp4",
    constraints: {
        audio: true,
        video: false
    },
    display: display
}).play();
 
Top