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

Added the microphone support for 2-way audio #579

Closed
wants to merge 1 commit into from
Closed

Added the microphone support for 2-way audio #579

wants to merge 1 commit into from

Conversation

slydiman
Copy link

@slydiman slydiman commented Oct 13, 2023

The config sample is following

type: 'custom:webrtc-camera'
streams:
- url: cam_stream_wo_mic
  name: '😶 Mic off'
- url: cam_stream_with_mic
  mode: webrtc
  name: '🎙️ Mic on'
  mic: true
ui: true

The config sample is following
```
type: 'custom:webrtc-camera'
streams:
- url: cam_stream_wo_mic
  mode: webrtc
  name: '😶 Mic off'
- url: cam_stream_with_mic
  mode: webrtc
  name: '🎙️ Mic on'
  mic: true
```
@felipecrs
Copy link
Contributor

I think this was now implemented by 8beab52.

@AlexxIT
Copy link
Owner

AlexxIT commented Oct 14, 2023

Yes. Thanks to @slydiman. Done with little another way

@AlexxIT AlexxIT closed this Oct 14, 2023
@dm82m
Copy link

dm82m commented Oct 14, 2023

Great you guys added that directly. Two questions:

  1. after the new version I do not get audio from the cam.

  2. if I put two streams - one with mic and one without: how can I switch between these streams?

@dm82m
Copy link

dm82m commented Oct 14, 2023

Okay, found something:

If I put ui: true I can switch the streams on the lower left corner. And I can also unmute on the lower right corner.
without ui: true this is both not possible.
also muted: false does not change the behavior.

bit good message is: two way audio works!!!

@AlexxIT
Copy link
Owner

AlexxIT commented Oct 15, 2023

You can change stream by click on mode label

@felipecrs
Copy link
Contributor

Great you guys added that directly.

lol, just to be fair it was @AlexxIT alone.

@felipecrs
Copy link
Contributor

Also, maybe you are affected by #529.

@dm82m
Copy link

dm82m commented Oct 15, 2023

You can change stream by click on mode label

Yes but the Mode Label is overlayed with the mute button. So it’s just a gamble what action will be executed.

IMG_5738

@AlexxIT
Copy link
Owner

AlexxIT commented Oct 15, 2023

You can move mode label via style param if you want.

@dm82m
Copy link

dm82m commented Oct 15, 2023

And additional info: this issue is only on iOS. On wifeys Android all is good.

@slydiman
Copy link
Author

slydiman commented Oct 15, 2023

lol, just to be fair it was @AlexxIT alone.

@felipecrs, just to be clear
The beginning of the story is AlexxIT/go2rtc#633 and it was your issue, thanks.
But we should not only report problems, but help developers whenever possible.
I have found the complete DVRIP talk command implementation on Perl and many thanks to its author @667bdrm too.
After adding the 2-way audio to go2rtc for DVRIP I have faced that there is no good UI to use it in HA.
AlexxIT said that he has no time for now to investigate this issue.
Then I have updated WebRTC Camera myself to support the microphone based on frigate-card code.
Then AlexxIT have updated WebRTC Camera its own way based on my PR and improved the disabling microphone when switch back to the stream w/o mic.
Many thanks to @AlexxIT for agreeing to delay the release to make and include these improvements.

@pergolafabio
Copy link

Thnx for making this possible!!

Is it also possible to add custom buttons/elements like we can do with the frigate card... That's would be perfect for door intercom buttons, like adding an icon for opening door or whatever custom action

@felipecrs
Copy link
Contributor

@pergolafabio you can put as many buttons you want, search for "shortcuts" in the README.

@felipecrs
Copy link
Contributor

Ok, I see now. Thanks to all of you and also thanks for compiling the credits.

@dm82m
Copy link

dm82m commented Oct 15, 2023

Any idea how to fix the position of buttons based on percent instead of px?

.shortcuts {left: unset; top: 140px; right: 40px;}

IMG_5745
IMG_5744

@pergolafabio
Copy link

@felipecrs , i wasnt aware of shortcuts! thnx
But is there also a shortcut to toggle the mode?

@felipecrs
Copy link
Contributor

But is there also a shortcut to toggle the mode?

Well, you can create multiple substreams with the modes you want and then cycle though them.

@pergolafabio
Copy link

by clicking in the right top corner?

i also see this on my android mobile , not sure why:

image

@felipecrs
Copy link
Contributor

I think you need:

ui: true

@AlexxIT
Copy link
Owner

AlexxIT commented Oct 15, 2023

@pergolafabio you using old outdated card. Probably browser cache.

@pergolafabio
Copy link

Hmm; i deleted cache on companion app, even tried logging out :-(

@slydiman
Copy link
Author

Try to open that HA page in the desktop browser.
If you are using Chrome, you can press F12 to open the dev console, right click on the refresh button and select Empty Cache and Hard Reload.
See more details here https://www.swic.edu/knowledgebase/clear-your-browser-cache/

To check the WebRTC Camera card version in the Chrome press F12 to open the dev console, select the tab Sources and find webrtc folder. You must see webrtc-camera.js?v=v3.4.0 and video-rtc.js?v=1.8.0.

@pergolafabio
Copy link

pergolafabio commented Oct 15, 2023

on desktop everything is fine, the issue is o Android Companion app :-)

I now tried as resource to add version , so it should be reloaded, but doesnt help :-(

  - url: /hacsfiles/webrtc/webrtc-camera.js?v=v3.4.0
    type: module

@pergolafabio
Copy link

ok, now deleted cache AND storage in android, in HA app settings, that seems to worrk!

@pergolafabio
Copy link

hmm, cant get it to work, i see video, i can switch modes, i see the mic active on my browser when i switch mode, but it doesnt start the two way audio, i howevere see this :

@pergolafabio
Copy link

image

Do i also need to add that file as a resource?

i only have this one now:

  - url: /hacsfiles/webrtc/webrtc-camera.js
    type: module

@AlexxIT
Copy link
Owner

AlexxIT commented Oct 15, 2023

/hacsfiles/webrtc/webrtc-camera.js this is dummy url, doesn't doing anything.

@pergolafabio
Copy link

a dummy? no, the file is actually there, i need to add it to the resources, otherwhise the card doesnt load at all
I use YAML mode

@pergolafabio
Copy link

pergolafabio commented Oct 15, 2023

but for me, the two way audio doesnt work on the webrtc card
i have frigate and webrtc card now configured both, they use the same go2rtc.yaml file
Frigate works, but webrtc doesnt

this is my config for webrtc:

            - url: deurbel_mic_on
            - url: deurbel_mic_off
              mode: webrtc
              media: video,audio,microphone
              ui: true
              muted: false

and:

streams:
  deurbel_mic_on:
    - rtsp://syno:xxx@192.168.0.14:554/Sms=24.unicast
    - isapi://admin:xxx@192.168.0.70:80/
  deurbel_mic_off:
    - rtsp://syno:xxx@192.168.0.14:554/Sms=24.unicast

@AlexxIT
Copy link
Owner

AlexxIT commented Oct 15, 2023

I don't know why file there. It shouldn't be there. If you put it yourself - you may break something.

@pergolafabio
Copy link

Ok, deleted it , removed webrtc from hacs , reinstalled again, deleted the pointer from resources, and indeed now the file doesn't come back, it still loads correct, but still no two way audio on the card

@slydiman
Copy link
Author

  • url: /hacsfiles/webrtc/webrtc-camera.js?v=v3.4.0

The path /hacsfiles/webrtc/ in resources.yaml means /config/www/community/webrtc/. I'm sure you have no such folder.

The integration WebRTC Camera uses a virtual URL. Try the following instead:

  - url: /webrtc/webrtc-camera.js
    type: module

And click 3 dots in the right top corner, click Reload resources, then click Refresh.

@pergolafabio
Copy link

Seems it's not needed to add it to my resources, the card now loads just fine...

But I don't have any two way audio on it

@slydiman
Copy link
Author

slydiman commented Oct 15, 2023

- url: deurbel_mic_on
- url: deurbel_mic_off
  media: video,audio,microphone

You need to swap deurbel_mic_on and deurbel_mic_off.

The correct sample is

type: 'custom:webrtc-camera'
streams:
- url: cam_stream_wo_mic
  name: '😶 Mic off'
- url: cam_stream_with_mic
  mode: webrtc
  name: '🎙️ Mic on'
  media: video,audio,microphone
ui: true

Note ui: true has the same padding as streams:. I recommend to read more about yaml.

@pergolafabio
Copy link

Aha, that's interesting! Gonna try it..

The docs were not clear...

It was 2 times the same URL?
This is in readme:

type: 'custom:webrtc-camera'
streams:
  - url: go2rtc_stream
  - url: go2rtc_stream
    mode: webrtc
    media: video,audio,microphone

@pergolafabio
Copy link

Cool now it works :-)

@slydiman
Copy link
Author

You can use the same stream with mic, but first one has the default media: video,audio which means no microphone transmission.

@pergolafabio
Copy link

Ah ,ok makes sense now, appreciated all the help!!

@calisro
Copy link

calisro commented Oct 27, 2023

Just saw this and added it. What a great addition!! Thanks. Now I don't need an iframe. :-| Just wanted to say thanks.

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

Successfully merging this pull request may close these issues.

6 participants