private void ConfigureAudio(AudioMediaFormat format, bool encoder, MediaCodecTypes supportType) { int codecType = (int)format.MimeType & CodecTypeMask; if (!Enum.IsDefined(typeof(SupportedCodecType), codecType)) { throw new NotSupportedException("The format is not supported " + $"mime type : { Enum.GetName(typeof(MediaFormatAudioMimeType), format.MimeType) }"); } DoConfigure(codecType, encoder, supportType); if (encoder) { int ret = Interop.MediaCodec.SetAudioEncoderInfo(_handle, format.SampleRate, format.Channel, format.Bit, format.BitRate); MultimediaDebug.AssertNoError(ret); } else { int ret = Interop.MediaCodec.SetAudioDecoderInfo(_handle, format.SampleRate, format.Channel, format.Bit); MultimediaDebug.AssertNoError(ret); } }
private MediaPacketSourceConfiguration CreateAudioConfiguration(AudioMediaFormat format) { if (format == null) { return(null); } if (!SupportedAudioTypes.Contains <MediaFormatAudioMimeType>(format.MimeType)) { throw new ArgumentException($"The audio format is not supported, Type : {format.MimeType}."); } return(new MediaPacketSourceConfiguration(this)); }
private void ConfigureAudio(AudioMediaFormat format, bool encoder, MediaCodecTypes supportType) { int codecType = (int)format.MimeType & CodecTypeMask; if (!Enum.IsDefined(typeof(SupportedCodecType), codecType)) { throw new NotSupportedException("The format is not supported " + $"mime type : { Enum.GetName(typeof(MediaFormatAudioMimeType), format.MimeType) }"); } DoConfigure(codecType, encoder, supportType); if (encoder) { Native.SetAudioEncoderInfo(_handle, format.SampleRate, format.Channel, format.Bit, format.BitRate). ThrowIfFailed("Failed to set audio encoder information."); } else { Native.SetAudioDecoderInfo(_handle, format.SampleRate, format.Channel, format.Bit). ThrowIfFailed("Failed to set audio decoder information."); } }
/// <summary> /// Initializes a new instance of the MediaPacketSource class with the specified <see cref="AudioMediaFormat"/>. /// </summary> /// <param name="audioMediaFormat">The <see cref="AudioMediaFormat"/> for this source.</param> /// <exception cref="ArgumentNullException"><paramref name="audioMediaFormat"/> is null.</exception> /// <exception cref="ArgumentException"><paramref name="audioMediaFormat"/> is not supported.</exception> /// <seealso cref="SupportedAudioTypes"/> /// <since_tizen> 9 </since_tizen> public MediaPacketSource(AudioMediaFormat audioMediaFormat) : base(MediaType.Audio) { _audioMediaFormat = audioMediaFormat ?? throw new ArgumentNullException(nameof(audioMediaFormat)); AudioConfiguration = CreateAudioConfiguration(audioMediaFormat); }