Giter Club home page Giter Club logo

sipsorcerymedia.windows's Introduction

SIPSorceryMedia.Windows

This project is an example of developing a C# library that can access Windows audio and video devices and that inegrates with the SIPSorcery real-time communications library.

The classes in this project provide functions to:

  • Supply audio samples from Windows audio capture devices.
  • Render audio samples to Windows audio output devices.
  • Supply video samples from Windows video capture devices.

sipsorcerymedia.windows's People

Contributors

christophei avatar fred-peters avatar sipsorcery avatar ynborokh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sipsorcerymedia.windows's Issues

windows platform It's too demanding

Any way to run it with Win7/Win8/Win8.1?
Other packages can use witth netstandard but this can not.

<TargetFramework>net6.0-windows10.0.22000</TargetFramework>

Shall we use NAudio for audio? or MediaFoundatiion for both video/video?

PauseAudio and ResumeAudio are only pausing waveIn

PauseAudio() and ResumeAudio() are only pausing _waveInEvent in WindowsAudioEndPoint.

        public Task PauseAudio()
        {
            _isPaused = true;
            _waveInEvent?.StopRecording();
            return Task.CompletedTask;
        }

        public Task ResumeAudio()
        {
            _isPaused = false;
            _waveInEvent?.StartRecording();
            return Task.CompletedTask;
        }

What if I want to pause _waveOutEvent as well?

does it make sense to do a PR, adding an option for that (that defaults to the old behaviour)? like this:


        public Task PauseAudio(bool affectWaveOut = false)
        {
            _isPaused = true;
            _waveInEvent?.StopRecording();
		if(affectWaveOut)
		{
			_waveOutEvent?.Pause();
		}

            return Task.CompletedTask;
        }

        public Task ResumeAudio(bool affectWaveOut = false)
        {
            _isPaused = false;
            _waveInEvent?.StartRecording();
		if(affectWaveOut)
		{
			_waveOutEvent?.Play();
		}
            return Task.CompletedTask;
        }

Or am I missing something?

Program crash problem

During the process of sending the video, decoding failed and the program crashed. The following is the error stack information:

System.ApplicationException: VP8 encode attempt failed, Unspecified internal error.
at SIPSorceryMedia.Encoders.Codecs.Vp8Codec.Encode(Byte[] frame, VpxImgFmt inputPixelFormat, Boolean forceKeyFrame)
at SIPSorceryMedia.Encoders.VpxVideoEncoder.EncodeVideo(Int32 width, Int32 height, Byte[] sample, VideoPixelFormatsEnum pixelFormat, VideoCodecsEnum codec)
at SIPSorceryMedia.Windows.WindowsVideoEndPoint.FrameArrivedHandler(MediaFrameReader sender, MediaFrameArrivedEventArgs e)
at System.Threading.Tasks.Task.<>c.b__128_1(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()

net 7.0

Hi there
How can I use lib with net 7.0?

Excessive CPU usage

image
When I use WebRTC for audio and video communication, the audiodg.exe program takes up too much CPU, causing the program to crash. What could be the reason? The picture above shows my system version, CPU, memory and other information. Looking forward to hearing from you!

Audio cannot be received in versions 6.0.4 and 6.0.5, but can be received in 6.0.3-pre

Part of the code is as follows:
WindowsAudioEndPoint _winAudioEP = new WindowsAudioEndPoint(new AudioEncoder());
RTCConfiguration config = new() { iceServers = _iceServers, X_UseRtpFeedbackProfile = true };
_pc = new RTCPeerConnection(config);
MediaStreamTrack audioTrack = new(_winAudioEP.GetAudioSinkFormats(), MediaStreamStatusEnum.SendRecv);
_pc.addTrack(audioTrack);
_pc.OnAudioFormatsNegotiated += (audioFormats) =>
{
AudioVideoSendService.AudioFormat = audioFormats.First();
_winAudioEP.SetAudioSinkFormat(audioFormats.First());
};
_pc.OnRtpPacketReceived += (IPEndPoint rep, SDPMediaTypesEnum media, RTPPacket rtpPkt) =>
{
if (media == SDPMediaTypesEnum.audio)
{
_winAudioEP.GotAudioRtp(rep, rtpPkt.Header.SyncSource, rtpPkt.Header.SequenceNumber, rtpPkt.Header.Timestamp, rtpPkt.Header.PayloadType, rtpPkt.Header.MarkerBit == 1, rtpPkt.Payload);
}
};

crash problem

image
System.Runtime.InteropServices.COMException (0xC00D36B2)
at WinRT.ExceptionHelpers.g__Throw|39_0(Int32 hr)
at ABI.Windows.Media.Capture.Frames.IMediaFrameReaderMethods.StopAsync(IObjectReference _obj)
at SIPSorceryMedia.Windows.WindowsVideoEndPoint.CloseVideoCaptureDevice()
at SIPSorceryMedia.Windows.WindowsVideoEndPoint.VideoCaptureDevice_Failed(MediaCapture sender, MediaCaptureFailedEventArgs errorEventArgs)
at System.Threading.Tasks.Task.<>c.b__128_1(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

only one way communication

target framework net472

Depending on the device I am trying to call, I can either only hear what the person on the other side is saying, or only they can hear what I am saying. I am trying to call "regular" telephone numbers (via my AVM Fritz Box as a SIP server). My wife on her Iphone and my colleage on the landline at work can talk to me but not hear me, my brother on his android phone can hear me (sort of) but not talk to me.

Null Reference Exception in WindowsAudioEndpoint

Hello all, I'm fairly new to the world of SIP and I'm running into a bit of a bind with this library. My goal is fairly straightforward, I want to create a little .NET service that sends audio to SIP endpoints. I'm trying to use a WindowsAudioEndpoint declared like it is in the SIPExamples project Play Sounds.

var windowsAudio = new WindowsAudioEndPoint(new AudioEncoder());
windowsAudio.RestrictFormats(format => format.Codec == AudioCodecsEnum.G722);
var voipMediaSession = new VoIPMediaSession(windowsAudio.ToMediaEndPoints());

This is a result of trying to improve the audio quality produced by a VoIPMediaSession declared like this:

VoIPMediaSession voipMediaSession = new VoIPMediaSession(null, formats => formats.Codec == AudioCodecsEnum.G722);

The audio coming out of my softphone and speakers is much more consistent and clear with the former declaration rather than the latter. The latter is basically unlistenable for some reason?

Now the problem is, and this is a problem even running the stock PlaySounds example against my endpoints, that an exception is thrown while the call task is awaited.
The debugger takes me to line 141 of WindowsAudioEndPoint.cs:
if (!_disableSource && _waveSourceFormat.SampleRate != _audioFormatManager.SelectedFormat.ClockRate)
where it seems like _waveSourceFormat is null.

The naïve fix I'm using is to add a null conditional operator to said _waveSourceFormat on line 141 and on line 143.

Any help or advice would be much appreciated, thanks!

Nuget install package fails.

I get this error message when trying to add the SIPSorceryMedia.Windows nuget package to my .net6 project, latest windows 11 SDK installed.

"NU1202 Package SIPSorceryMedia.Windows 6.0.1-pre is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package SIPSorceryMedia.Windows 6.0.1-pre supports: net6.0-windows10.0.22000 (.NETCoreApp,Version=v6.0)"

Any Ideas?

Hardcoded values of channels number and sample rate for WindowsAudioEndPoint

Currently WindowsAudioEndPoint class uses the hardcoded values of the channels number and the sample rate for source and sink devices:

private const int DEVICE_CHANNELS = 1;
...
public readonly static AudioSamplingRatesEnum DefaultAudioSourceSamplingRate = AudioSamplingRatesEnum.Rate8KHz;
public readonly static AudioSamplingRatesEnum DefaultAudioPlaybackRate = AudioSamplingRatesEnum.Rate8KHz;

Is it done on purpose? Why do we stick to minimal values if we can determine the devices capabilities?

For example, on my PC I have captureChannels=1, captureSampleRate=48000 and renderChannels=2, renderSampleRate=48000 (see code below).

NAudio.CoreAudioApi.MMDeviceEnumerator enumerator = new NAudio.CoreAudioApi.MMDeviceEnumerator();

NAudio.CoreAudioApi.MMDevice captureDevice = enumerator.GetDefaultAudioEndpoint(
    NAudio.CoreAudioApi.DataFlow.Capture, NAudio.CoreAudioApi.Role.Communications);
var captureChannels = captureDevice.AudioClient.MixFormat.Channels;
var captureSampleRate = captureDevice.AudioClient.MixFormat.SampleRate;

NAudio.CoreAudioApi.MMDevice renderDevice = enumerator.GetDefaultAudioEndpoint(
    NAudio.CoreAudioApi.DataFlow.Render, NAudio.CoreAudioApi.Role.Communications);
var renderChannels = renderDevice.AudioClient.MixFormat.Channels;
var renderSampleRate = renderDevice.AudioClient.MixFormat.SampleRate;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.