public virtual void StartRecording (Container container, VideoFormat videoFormat, AudioFormat audioFormat, RecordingCallback recordingCallback) { // Make sure that recording size is even videoFormat = new VideoFormat( videoFormat.width >> 1 << 1, videoFormat.height >> 1 << 1, videoFormat.framerate, videoFormat.bitrate, videoFormat.keyframeInterval ); // Save state this.dispatch = new MainDispatch(); this.videoFormat = videoFormat; this.recordingCallback = recordingCallback; this.framebuffer = new Texture2D(videoFormat.width, videoFormat.height, TextureFormat.ARGB32, false); // Start recording NatCorderBridge.StartRecording( container, videoFormat.width, videoFormat.height, videoFormat.framerate, videoFormat.bitrate, videoFormat.keyframeInterval, audioFormat.sampleRate, audioFormat.channelCount ); }
public void StartRecording(Container container, VideoFormat videoFormat, AudioFormat audioFormat, RecordingCallback videoCallback) { // Make sure that recording size is even videoFormat = new VideoFormat( videoFormat.width >> 1 << 1, videoFormat.height >> 1 << 1, videoFormat.framerate, videoFormat.bitrate, videoFormat.keyframeInterval ); // Save state this.dispatch = new MainDispatch(); this.videoFormat = videoFormat; this.recordingCallback = videoCallback; // Start recording natcorder.Call("startRecording", (int)container, videoFormat.width, videoFormat.height, videoFormat.framerate, videoFormat.bitrate, videoFormat.keyframeInterval, audioFormat.sampleRate, audioFormat.channelCount ); }
private void onVideo(string path) { dispatch.Dispatch(() => { videoCallback(path); dispatch.Release(); dispatch = null; }); }
private static void onPhoto(IntPtr imgPtr, int width, int height) { using (var dispatch = new MainDispatch()) { if (instance.photoCallback != null && imgPtr != IntPtr.Zero) { var photo = new Texture2D(width, height, TextureFormat.BGRA32, false); photo.LoadRawTextureData(unchecked ((IntPtr)(long)(ulong)imgPtr), width * height * 4); photo.Apply(); NatCamBridge.ReleasePhoto(imgPtr); instance.photoCallback(photo); } instance.photoCallback = null; } }
private static void onPhoto(IntPtr imgPtr, int width, int height, int size) { using (var dispatch = new MainDispatch()) { if (instance.photoCallback == null) { NatCamBridge.ReleasePhoto(); return; } if (imgPtr == IntPtr.Zero) { return; } var photo = new Texture2D(width, height, TextureFormat.BGRA32, false); photo.LoadRawTextureData(unchecked ((IntPtr)(long)(ulong)imgPtr), size); photo.Apply(); NatCamBridge.ReleasePhoto(); instance.photoCallback(photo, 0); instance.photoCallback = null; } }
public static void SavePhoto(Texture2D photo, SaveMode mode = SaveMode.SaveToAppDocuments, Orientation orientation = 0, SaveCallback callback = null) { if (photo == null) { return; } if (orientation != 0) { IDispatch main = new MainDispatch(), worker = new ConcurrentDispatch(); Util.RotateImage(Texture2D.Instantiate(photo), orientation, worker, main, (rotated, unused) => { Implementation.SavePhoto(rotated.EncodeToPNG(), mode, callback); Texture2D.Destroy(rotated); main.Release(); worker.Release(); }); } else { Implementation.SavePhoto(photo.EncodeToPNG(), mode, callback); } }
public void StartRecording(Configuration configuration, VideoCallback videoCallback, IAudioSource audioSource) { // Make sure that recording size is multiple of two configuration = new Configuration(2 * (configuration.width / 2), 2 * (configuration.height / 2), configuration.framerate, configuration.bitrate, configuration.keyframeInterval); // Save state this.dispatch = new MainDispatch(); this.configuration = configuration; this.videoCallback = videoCallback; this.audioSource = audioSource; // Start recording natcorder.Call("startRecording", configuration.width, configuration.height, configuration.framerate, configuration.bitrate, configuration.keyframeInterval, audioSource != null, audioSource != null ? audioSource.sampleRate : 0, audioSource != null ? audioSource.sampleCount : 0, audioSource != null ? audioSource.channelCount : 0 ); }
public void StartRecording (Configuration configuration, VideoCallback videoCallback, IAudioSource audioSource) { // Make sure that recording size is multiple of two configuration = new Configuration(2 * (configuration.width / 2), 2 * (configuration.height / 2), configuration.framerate, configuration.bitrate, configuration.keyframeInterval); // Save state this.dispatch = new MainDispatch(); this.configuration = configuration; this.videoCallback = videoCallback; this.audioSource = audioSource; this.framebuffer = new Texture2D(configuration.width, configuration.height, TextureFormat.ARGB32, false); // Start recording NatCorderBridge.StartRecording( configuration.width, configuration.height, configuration.framerate, configuration.bitrate, configuration.keyframeInterval, audioSource != null, audioSource != null ? audioSource.sampleRate : 0, audioSource != null ? audioSource.sampleCount : 0, audioSource != null ? audioSource.channelCount : 0 ); }
public void StartRecording(Configuration configuration, SaveCallback saveCallback, IAudioSource audioSource) { this.dispatch = new MainDispatch(); this.configuration = configuration; this.saveCallback = saveCallback; this.audioSource = audioSource; // Start recording natcorder.Call("startRecording", configuration.width, configuration.height, configuration.framerate, configuration.bitrate, configuration.keyframeInterval, audioSource != null, audioSource != null ? audioSource.sampleRate : 0, audioSource != null ? audioSource.channelCount : 0 ); // Start listening for audio if (audioSource != null) { audioSource.listener = this; } }
private void onVideo(string path) { dispatch.Dispatch(() => recordingCallback(path)); dispatch.Dispose(); dispatch = null; }
private static void OnVideo(string path) { using (var dispatch = new MainDispatch()) dispatch.Dispatch(() => instance.recordingCallback(path)); }