/// <summary> /// Initializes a new instance of the AudioMediaFormat class with the specified mime type, /// channel, sample rate, bit, bit rate, bit depth, and audio channel map. /// </summary> /// <remarks> /// If <paramref name="audioChannelMap"/> contains <see cref="MediaFormatAudioChannelPosition.None"/>, /// <paramref name="channel"/> should be set greater than 0.<br/> /// If <paramref name="audioChannelMap"/> contains <see cref="MediaFormatAudioChannelPosition.Mono"/>, /// <paramref name="channel"/> should be set 1.<br/> /// User can not set <see cref="MediaFormatAudioChannelPosition.None"/> with another channel positions.<br/> /// User can not set <see cref="MediaFormatAudioChannelPosition.Mono"/> with another channel positions.<br/> /// If same channel position is added in <paramref name="audioChannelMap"/> more than twice, its duplicaiton will be removed. /// </remarks> /// <param name="mimeType">The mime type of the format.</param> /// <param name="channel">The channel value of the format.</param> /// <param name="sampleRate">The sample rate value of the format.</param> /// <param name="bit">The bit value of the format.</param> /// <param name="bitRate">The bit rate value of the format.</param> /// <param name="aacType">The AAC bitstream format(ADIF or ADTS).</param> /// <param name="bitDepth">The bit depth value of the PCM audio format.</param> /// <param name="audioChannelMap">The loudspeaker position in PCM audio format.</param> /// <exception cref="ArgumentException"> /// <paramref name="mimeType"/> or <paramref name="aacType"/> is invalid (i.e. undefined value).<br/> /// -or-<br/> /// <paramref name="aacType"/> is not <see cref="MediaFormatAacType.None"/>, but <paramref name="mimeType"/> is one of the AAC types. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="audioChannelMap"/> is invalid or mismatched with <paramref name="channel"/> like the following:<br/> /// <paramref name="audioChannelMap"/> is not matched correctly with <paramref name="channel"/>. /// -or-<br/> /// <paramref name="audioChannelMap"/> is set to <see cref="MediaFormatAudioChannelPosition.Invaild"/>. /// -or-<br/> /// <see cref="MediaFormatAudioChannelPosition.Mono"/> or <see cref="MediaFormatAudioChannelPosition.None"/> is set with another channel position. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="channel"/>, <paramref name="sampleRate"/>, <paramref name="bit"/>, or <paramref name="bitRate"/>, /// <paramref name="bitDepth"/> is less than zero. /// </exception> /// <since_tizen> 6 </since_tizen> public AudioMediaFormat(MediaFormatAudioMimeType mimeType, int channel, int sampleRate, int bit, int bitRate, MediaFormatAacType aacType, int bitDepth, IList <MediaFormatAudioChannelPosition> audioChannelMap) : base(MediaFormatType.Audio) { ValidationUtil.ValidateEnum(typeof(MediaFormatAudioMimeType), mimeType, nameof(mimeType)); if (channel < 0) { throw new ArgumentOutOfRangeException(nameof(channel), channel, "Channel value can't be negative."); } if (sampleRate < 0) { throw new ArgumentOutOfRangeException(nameof(sampleRate), sampleRate, "Sample rate value can't be negative."); } if (bit < 0) { throw new ArgumentOutOfRangeException(nameof(bit), bit, "Bit value can't be negative."); } if (bitRate < 0) { throw new ArgumentOutOfRangeException(nameof(bitRate), bitRate, "Bit rate value can't be negative."); } if (bitDepth < 0) { throw new ArgumentOutOfRangeException(nameof(bitDepth), bitDepth, "Bit depth value can't be negative."); } ValidationUtil.ValidateEnum(typeof(MediaFormatAacType), aacType, nameof(aacType)); if (!IsAacSupportedMimeType(mimeType) && aacType != MediaFormatAacType.None) { throw new ArgumentException("Aac is supported only with aac mime types."); } MimeType = mimeType; AacType = aacType; Channel = channel; SampleRate = sampleRate; Bit = bit; BitRate = bitRate; BitDepth = bitDepth; if (audioChannelMap != null) { audioChannelMap = audioChannelMap.Distinct().OrderBy(p => p).ToList(); ValidateAudioChannelMap(audioChannelMap); AudioChannelMap = new ReadOnlyCollection <MediaFormatAudioChannelPosition>(audioChannelMap); } }
/// <summary> /// Retrieves the AAC type value from a native handle. /// </summary> /// <param name="handle">A native handle that the properties are retrieved from.</param> /// <param name="aacType">An out parameter for tha AAC type.</param> private static void GetAacType(IntPtr handle, out MediaFormatAacType aacType) { Debug.Assert(handle != IntPtr.Zero, "The handle is invalid!"); int aacTypeValue = 0; int ret = Interop.MediaFormat.GetAudioAacType(handle, out aacTypeValue); MultimediaDebug.AssertNoError(ret); aacType = (MediaFormatAacType)aacTypeValue; Debug.Assert(Enum.IsDefined(typeof(MediaFormatAacType), aacType), "Invalid aac type!"); }
/// <summary> /// Initializes a new instance of the AudioMediaFormat class with the specified mime type, /// channel, sample rate, bit, bit rate, and AAC type. /// </summary> /// <param name="mimeType">The mime type of the format.</param> /// <param name="channel">The channel value of the format.</param> /// <param name="sampleRate">The sample rate value of the format.</param> /// <param name="bit">The bit value of the format.</param> /// <param name="bitRate">The bit rate value of the format.</param> /// <param name="aacType">The AAC bitstream format(ADIF or ADTS).</param> /// <exception cref="ArgumentException"> /// <paramref name="mimeType"/> or <paramref name="aacType"/> is invalid (i.e. undefined value).<br/> /// -or-<br/> /// <paramref name="aacType"/> is not <see cref="MediaFormatAacType.None"/>, but <paramref name="mimeType"/> is one of the AAC types. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="channel"/>, <paramref name="sampleRate"/>, <paramref name="bit"/>, or <paramref name="bitRate"/> is less than zero. /// </exception> /// <since_tizen> 3 </since_tizen> public AudioMediaFormat(MediaFormatAudioMimeType mimeType, int channel, int sampleRate, int bit, int bitRate, MediaFormatAacType aacType) : base(MediaFormatType.Audio) { ValidationUtil.ValidateEnum(typeof(MediaFormatAudioMimeType), mimeType, nameof(mimeType)); if (channel < 0) { throw new ArgumentOutOfRangeException(nameof(channel), channel, "Channel value can't be negative."); } if (sampleRate < 0) { throw new ArgumentOutOfRangeException(nameof(sampleRate), sampleRate, "Sample rate value can't be negative."); } if (bit < 0) { throw new ArgumentOutOfRangeException(nameof(bit), bit, "Bit value can't be negative."); } if (bitRate < 0) { throw new ArgumentOutOfRangeException(nameof(bitRate), bitRate, "Bit rate value can't be negative."); } ValidationUtil.ValidateEnum(typeof(MediaFormatAacType), aacType, nameof(aacType)); if (!IsAacSupportedMimeType(mimeType) && aacType != MediaFormatAacType.None) { throw new ArgumentException("Aac is supported only with aac mime types."); } MimeType = mimeType; Channel = channel; SampleRate = sampleRate; Bit = bit; BitRate = bitRate; AacType = aacType; }
/// <summary> /// Initializes a new instance of the AudioMediaFormat class with the specified mime type, /// channel, sample rate, bit, bit rate, and AAC type. /// </summary> /// <param name="mimeType">The mime type of the format.</param> /// <param name="channel">The channel value of the format.</param> /// <param name="sampleRate">The sample rate value of the format.</param> /// <param name="bit">The bit value of the format.</param> /// <param name="bitRate">The bit rate value of the format.</param> /// <param name="aacType">The AAC bitstream format(ADIF or ADTS).</param> /// <exception cref="ArgumentException"> /// <paramref name="mimeType"/> or <paramref name="aacType"/> is invalid (i.e. undefined value).<br/> /// -or-<br/> /// <paramref name="aacType"/> is not <see cref="MediaFormatAacType.None"/>, but <paramref name="mimeType"/> is one of the AAC types. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="channel"/>, <paramref name="sampleRate"/>, <paramref name="bit"/>, or <paramref name="bitRate"/> is less than zero. /// </exception> /// <since_tizen> 3 </since_tizen> public AudioMediaFormat(MediaFormatAudioMimeType mimeType, int channel, int sampleRate, int bit, int bitRate, MediaFormatAacType aacType) : base(MediaFormatType.Audio) { if (!Enum.IsDefined(typeof(MediaFormatAudioMimeType), mimeType)) { throw new ArgumentException($"Invalid mime type value : { (int)mimeType }"); } if (channel < 0) { throw new ArgumentOutOfRangeException("Channel value can't be negative."); } if (sampleRate < 0) { throw new ArgumentOutOfRangeException("Sample rate value can't be negative."); } if (bit < 0) { throw new ArgumentOutOfRangeException("Bit value can't be negative."); } if (bitRate < 0) { throw new ArgumentOutOfRangeException("Bit rate value can't be negative."); } if (!Enum.IsDefined(typeof(MediaFormatAacType), aacType)) { throw new ArgumentException($"Invalid aac type value : { (int)aacType }"); } if (!IsAacSupportedMimeType(mimeType) && aacType != MediaFormatAacType.None) { throw new ArgumentException("Aac is supported only with aac mime types."); } MimeType = mimeType; Channel = channel; SampleRate = sampleRate; Bit = bit; BitRate = bitRate; AacType = aacType; }
internal static extern int SetAudioAacType(IntPtr handle, MediaFormatAacType value);
internal static extern int GetAudioAacType(IntPtr handle, out MediaFormatAacType aacType);
/// <summary> /// Initializes a new instance of the AudioMediaFormat class with the specified mime type, /// channel, sample rate, bit, bit rate, and AAC type. /// </summary> /// <param name="mimeType">The mime type of the format.</param> /// <param name="channel">The channel value of the format.</param> /// <param name="sampleRate">The sample rate value of the format.</param> /// <param name="bit">The bit value of the format.</param> /// <param name="bitRate">The bit rate value of the format.</param> /// <param name="aacType">The AAC bitstream format(ADIF or ADTS).</param> /// <exception cref="ArgumentException"> /// <paramref name="mimeType"/> or <paramref name="aacType"/> is invalid (i.e. undefined value).<br/> /// -or-<br/> /// <paramref name="aacType"/> is not <see cref="MediaFormatAacType.None"/>, but <paramref name="mimeType"/> is one of the AAC types. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="channel"/>, <paramref name="sampleRate"/>, <paramref name="bit"/>, or <paramref name="bitRate"/> is less than zero. /// </exception> /// <since_tizen> 3 </since_tizen> public AudioMediaFormat(MediaFormatAudioMimeType mimeType, int channel, int sampleRate, int bit, int bitRate, MediaFormatAacType aacType) : this(mimeType, channel, sampleRate, bit, bitRate, aacType, 0, null) { }