How to close peerConnection in WebRtc - webrtc

WebRtc sample
If I press call, allow/deny menu is shown in the upper screen. When I press allow, Chrome starts displaying red circle in the header which signals that microphone is active. All other sounds in others Chromes tabs are muted (for example youtube video).
When I press hang, red circle does not dissapears, youtube video in second tab is still muted. I have to press F5 to restore state which was before call.
Is there any PeerConnection to stop the call and stop mic recording ?

Yes, the reason the "red light" is still on is that the media tracks in the mediaStream object (called localstream on that particular page) gathered through getusermedia is still playing/active.
To close a media stream and thus release any hold on the local media inputs simply call localstream.stop() that will end the stream and stop accessing the local media input. This will stop all associated media tracks.
You can also do this by calling stop() on the individual media tracks(grabbed from getVideoTracks or getAudioTracks from the mediaStream).
As for other audio being turned down in other pages/apps. Here is the crbug handling that issue.
Side Note: if the media is being pushed through a peerConnection, then you will probably have to renegotiate the connection due to the mediaStream changing.

Related

Vimeo Player SDK - 'playing' event firing prematurely?

I'm having an issue where I'm using Vimeo Player SDK in a project and I don't want the user to see the thumbnail before playback. I'm triggering playback via code and attempting to display the video once it actually starts playing. I'm listening to the 'playing' event and would expect it to only trigger, once the video is actually playing. But I'm still getting the thumbnail. Am I missing something here?
For clarity, I'm listening to the player.on('playing', ..) event, not player.on('play', ..)
Example: https://jsfiddle.net/avt_pj/hqgtram0/31/
Vimeo replied with this:
The playing event is fired by the <video> element itself, so
we don't control the timing of that in our player.
If it's critical to know the precise moment when the first frames of a
video are being played, I'd suggest wrapping this in a
setTimeout or listening to the timeupdate event.

Audio player becomes unresponsive after paused for a minute

Building an audio streaming app using just_audio and audio_service. It uses an HLS url stream to get the audio. When audio is playing and the device is locked the controls will show on the lock screen and work properly using play/pause. However if the audio is paused for around a minute or longer the play button is tapped the lock screen controls will turn grey. I'll then open the app and try tapping play in the view and the Audio processing state will change to idle and nothing else happens.
I'm wonder if it has to do with the HLS stream at all. The amount of time that the player has to be paused before it "breaks" varies, but does seem to be consistent with the amount of audio that has buffered. So play/pause works fine if the amount of time the audio has been paused is less than the buffered amount, but if it passes then I encounter this issue.
As far as I can tell, nothing useful is logged at the time the audio player stops working, nor when tapping play/pause while in this state. I've tried to see if the OS kills the audio player maybe so I could re-init, but that doesn't seem to be the case either.
Figured this out, however, I'm not sure it's best solution.
One part is the provider for our HLS url for the live stream was able to increase the session timeout from 45 seconds to 5 minutes. There doesn't seem to be any negative behavior in doing this. It somehow prevents the background controls from breaking (greying out) when the audio has been paused for more then a minute (this varies and doesn't seem directly related to the session timeout, so maybe some magic iOS is doing too, who knows).
The other part is when a user locks their device and interacts with the background player something breaks to the point where if they go back into the app and try to switch the audio source something fails deep in the audio player. To "fix" this, when switching from the live stream to a non-HLS url I am now calling dispose on the audio player in the handler then re-initializing it.
This has solved my problem, but I think a better solution exists. For my specific case, using the SwitchAudioHandler may be that better solution, but I haven't had the time to try it.

Still pin capture on Linux. Is this possible?

A. I have a general understanding question about the "still pin" or "snapshot" functionality on some web cameras: how does this work ? It must be one of the following possibilities:
The camera is on and video is streaming to the host. When the snap button is pressed, a signal is sent to the host's camera driver (/dev/input/event0 on linux), the driver extracts a frame from the stream, and sends it up in the stack.
The camera is on and video is streaming (or not) to the host. When the snap button is pressed, the on board firmware puts aside the current frame, and tells the host a new "still" is available.
B. I have 4 usb cameras attached on a R-Pi (single usb host). All cameras have a still pin. I don't care about the video, no need for streaming, I want to take 4 simultaneous photos. My idea is to trigger all 4 cams to capture a frame using the still pin. How can I capture those 4 images without streaming video (bandwidth issues) ?
Note: I have already experimented a lot and I am capable of capturing a frame from a video stream. My cameras are unknown brands but exposes "video capture" as device caps. When using AMCap on windows, the snap button triggers a snapshot.
Thanks for any help.

Webcam light stay on when during video call but my video is turn off in tokbox

I am using Tokbox API for making video call application. But I have one problem show. During video call i show my laptop's webcam light stay ON but in call my video is turnoff. It seems like Tokbox API accessing my webcam behind the scene. How can I stop my laptop's webcam light when I turn off my video from call ?
Are you disabling video with OT.initPublisher({ publishVideo: false }) or publisher.publishVideo(false)? If so, then this is expected because we need to capture the camera in case you enable video later on in the call.
If you want to always have video disabled to have an audio only call, then please use OT.initPublisher({ videoSource: null }), this will not capture the camera at all.
See documentation for videoSource at https://tokbox.com/developer/sdks/js/reference/OT.html#initPublisher
If you set this property to null or false, the browser does not
request access to the camera, and no video is published. In a
voice-only call, set this property to null or false for each
Publisher.

background app listen to audio input

Our app knows how to listen to the audio input. Can I open the app in the background (multi-tasking) and still get it to work as if it is open? Or can my app stay in the background and still get audio inputs,and output audio sounds? How i do that?
Set your AudioSessionCategory as AVAudioSessionCategoryRecord. The docs explain here that this category will allow you to record audio input even when the app is in the background. This will allow you to listen to the device input in an AudioQueue recording callback function. However, when this is occurring in the background, the status bar is tinted red by the system to alert the user that a backgrounded app is listening (and possibly recording) device input.
The phone is only allowed to do a few things in the background, like play sounds, and monitor location.
My guess is that this won't work, or if it does, it will be rejected by apple.
You may be able to get it working by playing a sound in the background and using that to keep the app alive to listen to the input. I'm not sure if this will work.