aiortc / aiortc

WebRTC and ORTC implementation for Python using asyncio
BSD 3-Clause "New" or "Revised" License
4.14k stars 750 forks source link

MediaPlayer audio inquiry #739

Closed leeyunjai82 closed 2 years ago

leeyunjai82 commented 2 years ago

Hi, everyone. I use i2s mic, raspberrypi camera and raspberrypi. I want to use my mic and camera in MediaPlayer Function for videocall of janus-gateway

no audio traffic, video ok Please check if I have set MediaPlayer().audio up wrong

Thank you ''' media = {'audio': True, 'video': True}

vplayer = MediaPlayer("/dev/video0", format='v4l2', options={'framerate':'5', 'video_size':'320x240'})
if media['video'] and vplayer and vplayer.video:
    pc.addTrack(vplayer.video)

aplayer = MediaPlayer("sysdefault:CARD=sndrpii2scard", format="alsa", options={'channels':'2', 'sample_rate':'44000'})
if media['audio'] and aplayer and aplayer.audio:
    pc.addTrack(aplayer.audio)
    media['audio'] = True

'''

Result if media['audio'] set True --> no audio traffic video ok

Please check if I have set it up wrong

below sound setting: pi@themaker:~/webrtc-test/client $ arecord -L null Discard all samples (playback) or generate zero samples (capture) dout dmic_hw dmic_sv default sysdefault:CARD=sndrpii2scard snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0 Default Audio Device dmix:CARD=sndrpii2scard,DEV=0 snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0 Direct sample mixing device dsnoop:CARD=sndrpii2scard,DEV=0 snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0 Direct sample snooping device hw:CARD=sndrpii2scard,DEV=0 snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0 Direct hardware device without any conversions plughw:CARD=sndrpii2scard,DEV=0 snd_rpi_i2s_card, simple-card_codec_link snd-soc-dummy-dai-0 Hardware device with all software conversions

leeyunjai82 commented 2 years ago

1) ` audio_player = MediaPlayer("sysdefault:CARD=sndrpii2scard", format="alsa", options={'sample_rate':'48000'}) player = MediaPlayer("/dev/video0", format='v4l2', options={'framerate':'5', 'video_size':'320x240'})

# configure media
media = {'audio': False, 'video': False}
if player and player.video:
    pc.addTrack(player.video)
    media['video'] = True

#if audio_player and audio_player.audio:
#    pc.addTrack(audio_player.audio)
#    print(audio_player.audio)
#    media['audio'] = True`

DATA: {'janus': 'media', 'session_id': 819557512912717, 'sender': 2780613430956354, 'type': 'video', 'receiving': True} Video OK

2) ` audio_player = MediaPlayer("sysdefault:CARD=sndrpii2scard", format="alsa", options={'sample_rate':'48000'}) player = MediaPlayer("/dev/video0", format='v4l2', options={'framerate':'5', 'video_size':'320x240'})

# configure media
media = {'audio': False, 'video': False}
if player and player.video:
    pc.addTrack(player.video)
    media['video'] = True

if audio_player and audio_player.audio:
    pc.addTrack(audio_player.audio)
    print(audio_player.audio)
    media['audio'] = True`

DATA: {'janus': 'webrtcup', 'session_id': 7683125598503758, 'sender': 8611677132979134} DATA: {'janus': 'media', 'session_id': 7683125598503758, 'sender': 8611677132979134, 'type': 'video', 'receiving': True} DATA: {'janus': 'media', 'session_id': 7683125598503758, 'sender': 8611677132979134, 'type': 'audio', 'receiving': True} [video4linux2,v4l2 @ 0x8b9b90] Some buffers are still owned by the caller on close. DATA: {'janus': 'media', 'session_id': 7683125598503758, 'sender': 8611677132979134, 'type': 'audio', 'receiving': False} DATA: {'janus': 'media', 'session_id': 7683125598503758, 'sender': 8611677132979134, 'type': 'video', 'receiving': False}

Video/Audio no traffic