From 63f4b54dde506d37db7a512145bb9d4ec164be16 Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Wed, 28 Aug 2024 09:03:36 +0900 Subject: [PATCH] [Multimedia] Add MediaPacket TBM surface APIs (#6278) * [Multimedia] Add MediaPacket TBM surface API --- .../Interop/Interop.MediaTool.cs | 7 ++++ src/Tizen.Multimedia/MediaTool/MediaPacket.cs | 41 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/Tizen.Multimedia/Interop/Interop.MediaTool.cs b/src/Tizen.Multimedia/Interop/Interop.MediaTool.cs index d088bbff8bc..029ed1cc254 100644 --- a/src/Tizen.Multimedia/Interop/Interop.MediaTool.cs +++ b/src/Tizen.Multimedia/Interop/Interop.MediaTool.cs @@ -115,6 +115,13 @@ internal static class MediaPacket [DllImport(Libraries.MediaTool, EntryPoint = "media_packet_get_duration")] internal static extern int GetDuration(IntPtr handle, out ulong value); + + [DllImport(Libraries.MediaTool, EntryPoint = "media_packet_get_tbm_surface")] + internal static extern int GetTbmSurface(IntPtr handle, out IntPtr surface); + + [DllImport(Libraries.MediaTool, EntryPoint = "media_packet_has_tbm_surface_buffer")] + internal static extern int HasTbmSurface(IntPtr handle, out bool hasTbmSurface); + } internal static class MediaFormat diff --git a/src/Tizen.Multimedia/MediaTool/MediaPacket.cs b/src/Tizen.Multimedia/MediaTool/MediaPacket.cs index affdc4d77f2..7d49b8ff7c4 100644 --- a/src/Tizen.Multimedia/MediaTool/MediaPacket.cs +++ b/src/Tizen.Multimedia/MediaTool/MediaPacket.cs @@ -502,6 +502,47 @@ public MediaPacketBufferFlags BufferFlags } } + /// + /// Gets the pointer to the TBM surface object associated with the packet. + /// + /// + /// The pointer to the TBM surface object.
+ /// If packet doesn't have TBM surface, this will return IntPtr.Zero. + ///
+ /// The MediaPacket has already been disposed. + /// 12 + public IntPtr TbmSurface + { + get + { + ValidateNotDisposed(); + + int ret = Native.GetTbmSurface(_handle, out var value); + MultimediaDebug.AssertNoError(ret); + + return value; + } + } + + /// + /// Gets a value indicating whether the packet has TBM surface or not. + /// + /// true if the packet has TBM surface; otherwise, false. + /// The MediaPacket has already been disposed. + /// 12 + public bool HasTbmSurface + { + get + { + ValidateNotDisposed(); + + int ret = Native.HasTbmSurface(_handle, out var value); + MultimediaDebug.AssertNoError(ret); + + return value; + } + } + #region Dispose support /// /// Gets a value indicating whether the packet has been disposed.