protected MediaPacket GetMediaPacket(IntPtr handle) { MediaPacket mediaPacket = handle != IntPtr.Zero ? MediaPacket.From(handle) : throw new ArgumentException("MediaPacket handle is invalid.", nameof(handle)); return(mediaPacket); }
/// <summary> /// Enables to decode a video data for every frame. /// </summary> /// <remarks><para>The player must be in the <see cref="PlayerState.Idle"/> state, /// but <see cref="Multimedia.Display"/> must not be set.</para> /// <para>A <see cref="VideoFrameDecoded"/> event is called in a separate thread, not called in the main loop.</para> /// <para>The video frame can be retrieved using a <see cref="VideoFrameDecoded"/> event with a media packet parameter. /// If you change the media packet in the <see cref="VideoFrameDecoded"/> event, it will be displayed on the device. /// The callback function holds the same buffer that is drawn on the display device. /// and the <see cref="MediaPacket"/> is available until it is destroyed by <see cref="MediaPacket.Dispose()"/>. /// It is recommended to destroy the packet as quickly as possible after the decoded data is rendered on the display. /// All the packets have to be destroyed before <see cref="Unprepare"/> is called.</para></remarks> /// <feature>http://tizen.org/feature/multimedia.raw_video</feature> /// <exception cref="NotSupportedException">The required feature is not supported.</exception> /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception> /// <exception cref="InvalidOperationException"> /// Operation failed; internal error. /// -or-<br/> /// The player is not in the valid state. /// </exception> /// <seealso cref="DisableExportingVideoFrame"/> /// <since_tizen> 6 </since_tizen> public void EnableExportingVideoFrame() { ValidationUtil.ValidateFeatureSupported(PlayerFeatures.RawVideo); ValidatePlayerState(PlayerState.Idle); if (Display != null) { throw new InvalidOperationException("Display must be none."); } _videoFrameDecodedCallback = (packetHandle, _) => { var handler = VideoFrameDecoded; if (handler != null) { Log.Debug(PlayerLog.Tag, "packet : " + packetHandle); handler.Invoke(this, new VideoFrameDecodedEventArgs(MediaPacket.From(packetHandle))); } else { MediaPacket.From(packetHandle).Dispose(); } }; NativePlayer.SetVideoFrameDecodedCb(Handle, _videoFrameDecodedCallback). ThrowIfFailed(this, "Failed to register the VideoFrameDecoded"); }
private void RegisterMediaPacketPreviewCallback() { _mediaPacketPreviewCallback = (IntPtr mediaPacket, IntPtr userData) => { MediaPacket packet = MediaPacket.From(mediaPacket); var eventHandler = _mediaPacketPreview; if (eventHandler != null) { eventHandler.Invoke(this, new MediaPacketPreviewEventArgs(packet)); } else { packet.Dispose(); } }; CameraErrorFactory.ThrowIfError(Native.SetMediaPacketPreviewCallback(_handle, _mediaPacketPreviewCallback, IntPtr.Zero), "Setting media packet preview callback failed"); }
private void RegisterMediaPacketPreviewCallback() { _mediaPacketPreviewCallback = (mediaPacket, _) => { MediaPacket packet = MediaPacket.From(mediaPacket); var eventHandler = _mediaPacketPreview; if (eventHandler != null) { eventHandler.Invoke(this, new MediaPacketPreviewEventArgs(packet)); } packet.Dispose(); }; Native.SetMediaPacketPreviewCallback(_handle, _mediaPacketPreviewCallback). ThrowIfFailed("Failed to set media packet preview callback."); }
private void RegisterVideoFrameDecodedCallback() { _videoFrameDecodedCallback = (packetHandle, _) => { var handler = _videoFrameDecoded; if (handler != null) { Log.Debug(PlayerLog.Tag, "packet : " + packetHandle); handler.Invoke(this, new VideoFrameDecodedEventArgs(MediaPacket.From(packetHandle))); } else { MediaPacket.From(packetHandle).Dispose(); } }; NativePlayer.SetVideoFrameDecodedCb(Handle, _videoFrameDecodedCallback). ThrowIfFailed(this, "Failed to register the VideoFrameDecoded"); }
/// <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"); }