/// <summary> /// Initializes a new instance of the MediaStreamSource class with the specified <see cref="AudioMediaFormat"/>. /// </summary> /// <param name="audioMediaFormat">The <see cref="AudioMediaFormat"/> for this source.</param> /// <remarks>AAC is supported.</remarks> /// <exception cref="ArgumentNullException"><paramref name="audioMediaFormat"/> is null.</exception> /// <exception cref="ArgumentException"><paramref name="audioMediaFormat"/> is not supported.</exception> /// <seealso cref="SupportedAudioTypes"/> /// <since_tizen> 3 </since_tizen> public MediaStreamSource(AudioMediaFormat audioMediaFormat) { if (audioMediaFormat == null) { throw new ArgumentNullException(nameof(audioMediaFormat)); } _audioMediaFormat = audioMediaFormat; AudioConfiguration = CreateAudioConfiguration(audioMediaFormat); }
/// <summary> /// Initializes a new instance of the MediaStreamSource class /// with the specified <see cref="AudioMediaFormat"/> and <see cref="VideoMediaFormat"/>. /// </summary> /// <param name="audioMediaFormat">The <see cref="AudioMediaFormat"/> for this source.</param> /// <param name="videoMediaFormat">The <see cref="VideoMediaFormat"/> for this source.</param> /// <remarks>AAC and H.264 are supported.</remarks> /// <exception cref="ArgumentNullException">Both <paramref name="audioMediaFormat"/> and <paramref name="videoMediaFormat"/> are null.</exception> /// <exception cref="ArgumentException"> /// <paramref name="audioMediaFormat"/> is not supported.<br/> /// -or-<br/> /// <paramref name="videoMediaFormat"/> is not supported. /// </exception> /// <seealso cref="SupportedAudioTypes"/> /// <seealso cref="SupportedVideoTypes"/> /// <since_tizen> 3 </since_tizen> public MediaStreamSource(AudioMediaFormat audioMediaFormat, VideoMediaFormat videoMediaFormat) { if (audioMediaFormat == null && videoMediaFormat == null) { throw new ArgumentNullException(nameof(audioMediaFormat) + " and " + nameof(videoMediaFormat)); } _audioMediaFormat = audioMediaFormat; _videoMediaFormat = videoMediaFormat; AudioConfiguration = CreateAudioConfiguration(audioMediaFormat); VideoConfiguration = CreateVideoConfiguration(videoMediaFormat); }
private MediaStreamConfiguration CreateAudioConfiguration(AudioMediaFormat format) { if (format == null) { return(null); } if (!SupportedAudioTypes.Contains(format.MimeType)) { Log.Error(PlayerLog.Tag, "The audio format is not supported : " + format.MimeType); throw new ArgumentException($"The audio format is not supported, Type : {format.MimeType}."); } return(new MediaStreamConfiguration(this, StreamType.Audio)); }
/// <summary> /// Enable to decode an audio data for exporting PCM from a data. /// </summary> /// <param name="format">The media format handle required to audio PCM specification. /// The format has to include <see cref="AudioMediaFormat.MimeType"/>, /// <see cref="AudioMediaFormat.Channel"/> and <see cref="AudioMediaFormat.SampleRate"/>. /// If the format is NULL, the original PCM format or platform default PCM format will be applied.</param> /// <param name="option">The audio extract option.</param> /// <remarks><para>The player must be in the <see cref="PlayerState.Idle"/> state.</para> /// <para>A <see cref="AudioDataDecoded"/> event is called in a separate thread(not in the main loop).</para> /// <para>The audio PCM data can be retrieved using a <see cref="AudioDataDecoded"/> event as a media packet /// and it is available until it's destroyed by <see cref="MediaPacket.Dispose()"/>. /// The packet has to be destroyed as quickly as possible after rendering the data /// and all the packets have to be destroyed before <see cref="Unprepare"/> is called.</para></remarks> /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception> /// <exception cref="ArgumentException">The value is not valid.</exception> /// <exception cref="InvalidOperationException"> /// Operation failed; internal error. /// -or-<br/> /// The player is not in the valid state. /// </exception> /// <seealso cref="PlayerAudioExtractOption"/> /// <seealso cref="DisableExportingAudioData"/> /// <since_tizen> 6 </since_tizen> public void EnableExportingAudioData(AudioMediaFormat format, PlayerAudioExtractOption option) { ValidatePlayerState(PlayerState.Idle); ValidationUtil.ValidateEnum(typeof(PlayerAudioExtractOption), option, nameof(option)); _audioFrameDecodedCallback = (IntPtr packetHandle, IntPtr userData) => { var handler = AudioDataDecoded; if (handler != null) { Log.Debug(PlayerLog.Tag, "packet : " + packetHandle.ToString()); handler.Invoke(this, new AudioDataDecodedEventArgs(MediaPacket.From(packetHandle))); } else { MediaPacket.From(packetHandle).Dispose(); } }; NativePlayer.SetAudioFrameDecodedCb(Handle, format == null ? IntPtr.Zero : format.AsNativeHandle(), option, _audioFrameDecodedCallback, IntPtr.Zero).ThrowIfFailed(this, "Failed to register the _audioFrameDecoded"); }