Example #1
0
 internal OpusEncoder(IOpusApi api, int samplingRate, int channels, Application application)
 {
     _api          = api;
     _channels     = channels;
     _encoderState = api.opus_encoder_create(samplingRate, channels, application, out var error);
     if ((Error)error != Error.OK)
     {
         throw new Exception("Exception occured while creating encoder");
     }
 }
Example #2
0
        internal OpusDecoder(IOpusApi api, int samplingRate, int channels)
        {
            _api      = api;
            _channels = channels;

            _decoderState = api.opus_decoder_create(samplingRate, channels, out var error);
            if (error != Error.OK)
            {
                throw new Exception("Exception occured while creating encoder");
            }
        }
Example #3
0
        private static IOpusApi GetApi()
        {
            if (_api == null)
            {
                lock (CreateLock)
                {
                    if (_api == null)
                    {
                        string libraryPath;
                        if (Environment.OSVersion.Platform == PlatformID.Unix)
                        {
                            libraryPath = "libopus.so.0";
                        }
                        else
                        {
                            libraryPath = "opus";
                        }
                        _api = NativeLibraryBuilder.Default.ActivateInterface <IOpusApi>(libraryPath);
                    }
                }
            }

            return(_api);
        }
Example #4
0
 internal OpusPacketApi(IOpusApi api)
 {
     _api = api;
 }