Tanoda
Bridge.cs
Go to the documentation of this file.
1/*
2* NatCorder
3* Copyright (c) 2020 Yusuf Olokoba.
4*/
5
6using System;
7using System.Runtime.InteropServices;
8
10{
11 public static class Bridge
12 {
13 private const string Assembly =
14#if UNITY_IOS && !UNITY_EDITOR
15 @"__Internal";
16 #else
17 @"NatCorder";
18#endif
19
20 public delegate void RecordingHandler(IntPtr context, IntPtr path); // CHECK // Marshal string directly?
21
22 [DllImport(Assembly, EntryPoint = @"NCCreateMP4Recorder")]
23 public static extern IntPtr CreateMP4Recorder(int width, int height, float framerate, int bitrate,
24 int keyframeInterval, int sampleRate, int channelCount,
25 [MarshalAs(UnmanagedType.LPStr)] string recordingPath, RecordingHandler callback, IntPtr context);
26
27 [DllImport(Assembly, EntryPoint = @"NCCreateHEVCRecorder")]
28 public static extern IntPtr CreateHEVCRecorder(int width, int height, float framerate, int bitrate,
29 int keyframeInterval, int sampleRate, int channelCount,
30 [MarshalAs(UnmanagedType.LPStr)] string recordingPath, RecordingHandler callback, IntPtr context);
31
32 [DllImport(Assembly, EntryPoint = @"NCCreateGIFRecorder")]
33 public static extern IntPtr CreateGIFRecorder(int width, int height, float frameDuration,
34 [MarshalAs(UnmanagedType.LPStr)] string recordingPath, RecordingHandler callback, IntPtr context);
35
36 [DllImport(Assembly, EntryPoint = @"NCFrameSize")]
37 public static extern void FrameSize(this IntPtr recorder, out int width, out int height);
38
39 [DllImport(Assembly, EntryPoint = @"NCCommitFrame")]
40 public static extern void CommitFrame(this IntPtr recorder, IntPtr pixelBuffer, long timestamp);
41
42 [DllImport(Assembly, EntryPoint = @"NCCommitSamples")]
43 public static extern void CommitSamples(this IntPtr recorder, float[] sampleBuffer, int sampleCount,
44 long timestamp);
45
46 [DllImport(Assembly, EntryPoint = @"NCFinishWriting")]
47 public static extern void FinishWriting(this IntPtr recorder);
48 }
49}