2 using System.Runtime.InteropServices;
3 using Tizen.Multimedia;
5 internal static partial class Interop
7 internal static partial class StreamRecorder
9 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_create")]
10 internal static extern StreamRecorderErrorCode Create(out StreamRecorderHandle handle);
12 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_prepare")]
13 internal static extern StreamRecorderErrorCode Prepare(StreamRecorderHandle handle);
15 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_unprepare")]
16 internal static extern StreamRecorderErrorCode Unprepare(StreamRecorderHandle handle);
18 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_start")]
19 internal static extern StreamRecorderErrorCode Start(StreamRecorderHandle handle);
21 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_pause")]
22 internal static extern StreamRecorderErrorCode Pause(StreamRecorderHandle handle);
24 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_commit")]
25 internal static extern StreamRecorderErrorCode Commit(StreamRecorderHandle handle);
27 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_cancel")]
28 internal static extern StreamRecorderErrorCode Cancel(StreamRecorderHandle handle);
30 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_push_stream_buffer")]
31 internal static extern StreamRecorderErrorCode PushStreamBuffer(StreamRecorderHandle handle,
32 IntPtr mediaPacketHandle);
34 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_enable_source_buffer")]
35 internal static extern StreamRecorderErrorCode EnableSourceBuffer(StreamRecorderHandle handle,
36 StreamRecorderSourceType type);
38 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_get_state")]
39 internal static extern StreamRecorderErrorCode GetState(StreamRecorderHandle handle, out RecorderState state);
42 internal class StreamRecorderHandle : SafeHandle
44 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_destroy")]
45 private static extern StreamRecorderErrorCode Destroy(IntPtr handle);
47 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_cancel")]
48 private static extern StreamRecorderErrorCode Cancel(IntPtr handle);
50 [DllImport(Libraries.StreamRecorder, EntryPoint = "streamrecorder_unprepare")]
51 private static extern StreamRecorderErrorCode Unprepare(IntPtr handle);
53 protected StreamRecorderHandle() : base(IntPtr.Zero, true)
57 public override bool IsInvalid => handle == IntPtr.Zero;
59 protected override bool ReleaseHandle()
63 Cancel(handle).Ignore(StreamRecorderErrorCode.InvalidState).ThrowIfError("Failed to cancel.");
64 Unprepare(handle).Ignore(StreamRecorderErrorCode.InvalidState).ThrowIfError("Failed to unprepare.");
65 Destroy(handle).ThrowIfError("Failed to destory.");
71 Tizen.Log.Debug(GetType().FullName, $"Failed to release native RecorderHandle; {e.Message}");