/// <summary> /// Initializes a new <see cref="OpusEncoder"/> instance, with the specified codec usage tuning, sample rate and channels. /// </summary> /// <param name="optimized">The codec usage tuning.</param> /// <param name="sampleRate">The sample rate in the input audio.</param> /// <param name="audioChannels">The channels in the input audio - mono or stereo.</param> public OpusEncoder(OpusOptimizer optimized, OpusSampleRate sampleRate, OpusAudioChannels audioChannels) { if (!Enum.IsDefined(typeof(OpusOptimizer), optimized)) { throw new ArgumentException("Value is not defined in the enumeration.", nameof(optimized)); } if (!Enum.IsDefined(typeof(OpusSampleRate), sampleRate)) { throw new ArgumentException("Value is not defined in the enumeration.", nameof(sampleRate)); } if (!Enum.IsDefined(typeof(OpusAudioCHannels), audioChannels)) { throw new ArgumentException("Value is not defined in the enumeration.", nameof(audioChannels)); } _handle = FFI.opus_encoder_create((int)sampleRate, (int)audioChannels, (int)optimized, out int error); ThrowIfError(error); Optimized = optimized; SampleRate = sampleRate; AudioChannels = audioChannels; Bitrate = -1; }
public static extern int opus_encoder_ctl(SafeEncoderHandle st, int request, int value);
public static extern int opus_encode(SafeEncoderHandle st, IntPtr pcm, int frame_size, IntPtr data, int max_data_bytes);