microsoft / MixedReality-WebRTC

MixedReality-WebRTC is a collection of components to help mixed reality app developers integrate audio and video real-time communication into their application and improve their collaborative experience
https://microsoft.github.io/MixedReality-WebRTC/
MIT License
898 stars 277 forks source link

Empty audio frames in the TestNetCoreConsole when connected with a Desktop Client #858

Open tghanem opened 2 years ago

tghanem commented 2 years ago

Describe the bug I have run the TestNetCoreConsole example program but with a handler to the AudioTrackAdded event and received the audio frames from the peer. The problem is that I receive empty frames. The same code when run with the webrtc.html JavaScript client (from the TestReceiveAV project) works fine and I receive full frames.

To Reproduce

  1. Open the TestNetCoreConsole example project.
  2. Add the following handler to the PeerConnection object.
    pc.AudioTrackAdded += track =>
    {
    track.AudioFrameReady += frame =>
    {
      byte firstByte = Marshal.ReadByte(frame.audioData); //THIS IS ALWAYS ZERO which means empty frames are received.
    };
    };
  3. Run two instances of the project with one of the instances with the -a switch to add an audio track.
  4. Run the project again but now with the webrtc.html client (from the TestReceiveAV project) and should get frames with data.

Expected behavior I expected to receive data in the audio frames when the audio track is added by a C# (Desktop) client.

Logging (core_audio_input_win.cc:94): webrtc::webrtc_win::CoreAudioInput::InitRecording (datachannel.cc:668): Sent CONTROL message on channel 0 (core_audio_input_win.cc:200): webrtc::webrtc_win::CoreAudioInput::Recording: 0 DataChannel 'data_channel_0f09bfdf-8857-498b-9eb6-84bf0cc4e5c0': StateChanged 'Open' (core_audio_base_win.cc:297): webrtc::webrtc_win::CoreAudioBase::Init[Input] (core_audio_utility_win.cc:611): GetDefaultInputDeviceID (core_audio_utility_win.cc:641): CreateDevice (core_audio_utility_win.cc:266): CreateDeviceInternal: 0 (core_audio_utility_win.cc:625): GetCommunicationsInputDeviceID (core_audio_utility_win.cc:641): CreateDevice (core_audio_utility_win.cc:266): CreateDeviceInternal: 2 (core_audio_base_win.cc:329): Using IAudioClient2 (core_audio_utility_win.cc:772): CreateClient2 (core_audio_utility_win.cc:641): CreateDevice (core_audio_utility_win.cc:266): CreateDeviceInternal: 2 (core_audio_utility_win.cc:287): IMMDeviceEnumerator::GetDevice failed: The parameter is incorrect. (0x80070057) (webrtcvoiceengine.cc:1735): Failed to initialize recording (audio_device_module_win.cc:327): webrtc::webrtc_win::'anonymous-namespace'::WindowsAudioDeviceModule::Recording (core_audio_input_win.cc:230): webrtc::webrtc_win::CoreAudioInput::Restarting (core_audio_input_win.cc:200): webrtc::webrtc_win::CoreAudioInput::Recording: 0 (audio_device_module_win.cc:275): webrtc::webrtc_win::'anonymous-namespace'::WindowsAudioDeviceModule::InitRecording (core_audio_input_win.cc:230): webrtc::webrtc_win::CoreAudioInput::Restarting (core_audio_input_win.cc:88): webrtc::webrtc_win::CoreAudioInput::RecordingIsInitialized: 0 (core_audio_input_win.cc:94): webrtc::webrtc_win::CoreAudioInput::InitRecording (core_audio_input_win.cc:200): webrtc::webrtc_win::CoreAudioInput::Recording: 0 (core_audio_base_win.cc:297): webrtc::webrtc_win::CoreAudioBase::Init[Input] (core_audio_utility_win.cc:611): GetDefaultInputDeviceID (core_audio_utility_win.cc:641): CreateDevice (core_audio_utility_win.cc:266): CreateDeviceInternal: 0 (core_audio_utility_win.cc:625): GetCommunicationsInputDeviceID (core_audio_utility_win.cc:641): CreateDevice (core_audio_utility_win.cc:266): CreateDeviceInternal: 2 (core_audio_base_win.cc:329): Using IAudioClient2 (core_audio_utility_win.cc:772): CreateClient2 (core_audio_utility_win.cc:641): CreateDevice (core_audio_utility_win.cc:266): CreateDeviceInternal: 2 (core_audio_utility_win.cc:287): IMMDeviceEnumerator::GetDevice failed: The parameter is incorrect. (0x80070057) (audio_state.cc:106): webrtc::internal::AudioState::AddSendingStream: Failed to initialize recording.