public override void ViewDidLoad() { base.ViewDidLoad(); // Initialize the class responsible for managing AV capture session and asset writer videoProcessor = new RosyWriterVideoProcessor(); // Keep track of changes to the device orientation so we can update the video processor var notificationCenter = NSNotificationCenter.DefaultCenter; notificationCenter.AddObserver(UIApplication.DidChangeStatusBarOrientationNotification, DeviceOrientationDidChange); UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications(); // Setup and start the capture session videoProcessor.SetupAndStartCaptureSession(); Console.WriteLine("Finished Setting up AV"); notificationCenter.AddObserver(UIApplication.DidBecomeActiveNotification, On_ApplicationDidBecomeActive); oglView = new RosyWriterPreviewWindow(RectangleF.Empty); // Our interface is always in portrait oglView.Transform = videoProcessor.TransformFromCurrentVideoOrientationToOrientation(AVCaptureVideoOrientation.Portrait); RectangleF bounds = viewPreview.ConvertRectToView(viewPreview.Bounds, oglView); oglView.Bounds = bounds; oglView.Center = new PointF(viewPreview.Bounds.Size.Width / 2.0F, viewPreview.Bounds.Size.Height / 2.0F); viewPreview.AddSubview(oglView); Console.WriteLine("Added OGL View"); // Set up labels shouldShowStats = true; frameRateLabel = LabelWithText(string.Empty, 10.0F); viewPreview.AddSubview(frameRateLabel); dimensionsLabel = LabelWithText(string.Empty, 54.0F); viewPreview.AddSubview(dimensionsLabel); typeLabel = LabelWithText(string.Empty, 90F); viewPreview.Add(typeLabel); // btnRecord Event Handler btnRecord.Clicked += On_ToggleRecording; // Video Processor Event Handlers videoProcessor.RecordingDidStart += On_RecordingDidStart; videoProcessor.RecordingDidStop += On_RecordingDidStop; videoProcessor.RecordingWillStart += On_RecordingWillStart; videoProcessor.RecordingWillStop += On_RecordingWillStop; videoProcessor.PixelBufferReadyForDisplay += On_PixelBufferReadyForDisplay; Console.WriteLine("Finished OnDidLoad"); }
public override void ViewDidLoad() { base.ViewDidLoad (); // Initialize the class responsible for managing AV capture session and asset writer videoProcessor = new RosyWriterVideoProcessor (); // Keep track of changes to the device orientation so we can update the video processor var notificationCenter = NSNotificationCenter.DefaultCenter; notificationCenter.AddObserver(UIApplication.DidChangeStatusBarOrientationNotification, DeviceOrientationDidChange); UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications (); // Setup and start the capture session videoProcessor.SetupAndStartCaptureSession (); notificationCenter.AddObserver (UIApplication.DidBecomeActiveNotification, OnApplicationDidBecomeActive); oglView = new RosyWriterPreviewWindow(CGRect.Empty); // Our interface is always in portrait oglView.Transform = videoProcessor.TransformFromCurrentVideoOrientationToOrientation(AVCaptureVideoOrientation.Portrait); CGRect bounds = previewView.ConvertRectToView(previewView.Bounds, oglView); oglView.Bounds = bounds; oglView.Center = new CGPoint(previewView.Bounds.Size.Width / 2.0F, previewView.Bounds.Size.Height / 2.0F); previewView.AddSubview(oglView); // Set up labels shouldShowStats = true; frameRateLabel = LabelWithText (string.Empty, 10.0F); previewView.AddSubview (frameRateLabel); dimensionsLabel = LabelWithText (string.Empty, 54.0F); previewView.AddSubview (dimensionsLabel); typeLabel = LabelWithText (string.Empty, 90F); previewView.Add (typeLabel); // btnRecord Event Handler btnRecord.Clicked += OnToggleRecording; // Video Processor Event Handlers videoProcessor.RecordingDidStart += OnRecordingDidStart; videoProcessor.RecordingDidStop += OnRecordingDidStop; videoProcessor.RecordingWillStart += OnRecordingWillStart; videoProcessor.RecordingWillStop += OnRecordingWillStop; videoProcessor.PixelBufferReadyForDisplay += OnPixelBufferReadyForDisplay; }