From: Haesu Gwon Date: Mon, 31 May 2021 08:25:23 +0000 (+0900) Subject: [Camera] Add new internal API - extra preview event (#3011) X-Git-Tag: accepted/tizen/unified/20231205.024657~1830 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6405fb6c273725b83ad82ad5e237bd109b314f6b;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Camera] Add new internal API - extra preview event (#3011) * [Camera] Add new internal API - extra preview event --- diff --git a/src/Tizen.Multimedia.Camera/Camera/Camera.Events.cs b/src/Tizen.Multimedia.Camera/Camera/Camera.Events.cs new file mode 100644 index 0000000..99824fe --- /dev/null +++ b/src/Tizen.Multimedia.Camera/Camera/Camera.Events.cs @@ -0,0 +1,463 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.ComponentModel; +using Native = Interop.Camera; + +namespace Tizen.Multimedia +{ + /// + /// This camera class provides methods to capture photos and supports setting up notifications + /// for state changes of capturing, previewing, focusing, and informing about the resolution and the binary format, + /// and functions for picture manipulations like sepia, negative, and many more. + /// It also notifies you when a significant picture parameter changes, (For example, focus). + /// + /// 3 + /// http://tizen.org/feature/camera + public partial class Camera : IDisposable, IDisplayable + { + /// + /// An event that occurs when the camera interrupt is started by the policy. + /// + /// 4 + public event EventHandler InterruptStarted; + private Native.InterruptStartedCallback _interruptStartedCallback; + + /// + /// An event that occurs when an camera is interrupted by the policy. + /// + /// 3 + public event EventHandler Interrupted; + private Native.InterruptedCallback _interruptedCallback; + + /// + /// An event that occurs when there is an asynchronous error. + /// + /// 3 + public event EventHandler ErrorOccurred; + private Native.ErrorCallback _errorCallback; + + /// + /// An event that occurs when the auto focus state is changed. + /// + /// 3 + public event EventHandler FocusStateChanged; + private Native.FocusStateChangedCallback _focusStateChangedCallback; + + /// + /// An event that occurs when a face is detected in the preview frame. + /// + /// 3 + public event EventHandler FaceDetected; + private Native.FaceDetectedCallback _faceDetectedCallback; + + /// + /// An event that occurs during capture of an image. + /// + /// 3 + public event EventHandler Capturing; + private Native.CapturingCallback _capturingCallback; + + /// + /// An event that occurs after the capture of the image. + /// + /// 3 + public event EventHandler CaptureCompleted; + private Native.CaptureCompletedCallback _captureCompletedCallback; + + private Native.HdrCaptureProgressCallback _hdrCaptureProgressCallback; + private event EventHandler _hdrCaptureProgress; + private object _hdrCaptureProgressEventLock = new object(); + + /// + /// An event that occurs when there is a change in the HDR capture progress. + /// Checks whether the is supported or not before adding this EventHandler. + /// + /// 3 + /// In case of HDR feature is not supported. + public event EventHandler HdrCaptureProgress + { + add + { + lock (_hdrCaptureProgressEventLock) + { + if (_hdrCaptureProgress == null) + { + RegisterHdrCaptureProgress(); + } + + _hdrCaptureProgress += value; + } + } + + remove + { + lock (_hdrCaptureProgressEventLock) + { + _hdrCaptureProgress -= value; + + if (_hdrCaptureProgress == null) + { + UnregisterHdrCaptureProgress(); + } + } + } + } + + /// + /// An event that occurs when the camera state is changed. + /// + /// 3 + public event EventHandler StateChanged; + private Native.StateChangedCallback _stateChangedCallback; + + private static Native.DeviceStateChangedCallback _deviceStateChangedCallback; + private static event EventHandler _deviceStateChanged; + private static object _deviceStateChangedEventLock = new object(); + private static int _deviceStateCallbackId; + + /// + /// An event that occurs after the is changed. + /// + /// 3 + /// In case of any invalid operations. + /// In case of this feature is not supported. + /// In case of invalid parameters. + public static event EventHandler DeviceStateChanged + { + add + { + lock (_deviceStateChangedEventLock) + { + if (_deviceStateChanged == null) + { + RegisterDeviceStateChangedCallback(); + } + + _deviceStateChanged += value; + } + } + + remove + { + lock (_deviceStateChangedEventLock) + { + _deviceStateChanged -= value; + + if (_deviceStateChanged == null) + { + UnregisterDeviceStateChangedCallback(); + } + } + } + } + + private Native.PreviewCallback _previewCallback; + private event EventHandler _preview; + private object _previewEventLock = new object(); + /// + /// An event that occurs once per frame when previewing. + /// Preview callback is registered when an user adds a callback explicitly to avoid useless P/Invoke. + /// + /// 3 + public event EventHandler Preview + { + add + { + lock (_previewEventLock) + { + if (_preview == null) + { + RegisterPreviewCallback(); + } + + _preview += value; + } + } + + remove + { + lock (_previewEventLock) + { + _preview -= value; + + if (_preview == null) + { + UnregisterPreviewCallback(); + } + } + } + } + + private Native.MediaPacketPreviewCallback _mediaPacketPreviewCallback; + private EventHandler _mediaPacketPreview; + private object _mediaPacketPreviewEventLock = new object(); + + /// + /// An event that occurs once per frame when previewing. + /// Preview callback is registered when an user adds a callback explicitly to avoid useless P/Invoke. + /// + /// 3 + public event EventHandler MediaPacketPreview + { + add + { + lock (_mediaPacketPreviewEventLock) + { + if (_mediaPacketPreview == null) + { + RegisterMediaPacketPreviewCallback(); + } + + _mediaPacketPreview += value; + } + } + + remove + { + lock (_mediaPacketPreviewEventLock) + { + _mediaPacketPreview -= value; + + if (_mediaPacketPreview == null) + { + UnregisterMediaPacketPreviewCallback(); + } + } + } + } + + private Native.ExtraPreviewCallback _extraPreviewCallback; + private event EventHandler _extraPreview; + /// + /// An event that occurs once per frame when previewing. + /// Preview callback is registered when an user adds a callback explicitly to avoid useless P/Invoke. + /// + /// 9 + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler ExtraPreview + { + add + { + if (_extraPreview == null) + { + RegisterExtraPreviewCallback(); + } + + _extraPreview += value; + } + + remove + { + _extraPreview -= value; + + if (_extraPreview == null) + { + UnregisterExtraPreviewCallback(); + } + } + } + + private void RegisterCallbacks() + { + RegisterErrorCallback(); + RegisterFocusStateChanged(); + RegisterInterruptStartedCallback(); + RegisterInterruptedCallback(); + RegisterStateChangedCallback(); + + //Define capturing callback + _capturingCallback = (main, postview, thumbnail, userData) => + { + Capturing?.Invoke(this, new CameraCapturingEventArgs(new StillImage(main), + postview == IntPtr.Zero ? null : new StillImage(postview), + thumbnail == IntPtr.Zero ? null : new StillImage(thumbnail))); + }; + + //Define captureCompleted callback + _captureCompletedCallback = _ => + { + SetState(CameraState.Captured); + CaptureCompleted?.Invoke(this, EventArgs.Empty); + }; + } + + private void RegisterInterruptStartedCallback() + { + _interruptStartedCallback = (policy, state, _) => + { + InterruptStarted?.Invoke(this, new CameraInterruptStartedEventArgs(policy, state)); + }; + + Native.SetInterruptStartedCallback(_handle, _interruptStartedCallback). + ThrowIfFailed("Failed to set interrupt callback."); + } + + private void RegisterInterruptedCallback() + { + _interruptedCallback = (policy, previous, current, _) => + { + Interrupted?.Invoke(this, new CameraInterruptedEventArgs(policy, previous, current)); + }; + + Native.SetInterruptedCallback(_handle, _interruptedCallback). + ThrowIfFailed("Failed to set interrupt callback."); + } + + private void RegisterErrorCallback() + { + _errorCallback = (error, current, _) => + { + ErrorOccurred?.Invoke(this, new CameraErrorOccurredEventArgs(error, current)); + }; + + Native.SetErrorCallback(_handle, _errorCallback). + ThrowIfFailed("Setting error callback failed"); + } + + private void RegisterStateChangedCallback() + { + _stateChangedCallback = (previous, current, byPolicy, _) => + { + SetState(current); + Log.Info(CameraLog.Tag, "Camera state changed " + previous.ToString() + " -> " + current.ToString()); + StateChanged?.Invoke(this, new CameraStateChangedEventArgs(previous, current, byPolicy)); + }; + + Native.SetStateChangedCallback(_handle, _stateChangedCallback). + ThrowIfFailed("Failed to set state changed callback."); + } + + private static void RegisterDeviceStateChangedCallback() + { + _deviceStateChangedCallback = (device, state, _) => + { + _deviceStateChanged?.Invoke(null, new CameraDeviceStateChangedEventArgs(device, state)); + }; + + Native.SetDeviceStateChangedCallback(_deviceStateChangedCallback, IntPtr.Zero, out _deviceStateCallbackId). + ThrowIfFailed("Failed to set device state changed callback."); + + Log.Info(CameraLog.Tag, "add callbackId " + _deviceStateCallbackId.ToString()); + } + + private static void UnregisterDeviceStateChangedCallback() + { + Native.UnsetDeviceStateChangedCallback(_deviceStateCallbackId). + ThrowIfFailed("Failed to unset device state changed callback."); + + _deviceStateChangedCallback = null; + _deviceStateCallbackId = 0; + } + + private void RegisterFocusStateChanged() + { + _focusStateChangedCallback = (state, _) => + { + FocusStateChanged?.Invoke(this, new CameraFocusStateChangedEventArgs(state)); + }; + + Native.SetFocusStateChangedCallback(_handle, _focusStateChangedCallback). + ThrowIfFailed("Failed to set focus changed callback."); + } + + private void RegisterHdrCaptureProgress() + { + _hdrCaptureProgressCallback = (percent, _) => + { + _hdrCaptureProgress?.Invoke(this, new HdrCaptureProgressEventArgs(percent)); + }; + + Native.SetHdrCaptureProgressCallback(_handle, _hdrCaptureProgressCallback). + ThrowIfFailed("Failed to set Hdr capture progress callback."); + } + + private void UnregisterHdrCaptureProgress() + { + Native.UnsetHdrCaptureProgressCallback(_handle). + ThrowIfFailed("Failed to unset hdr capture progres callback."); + + _hdrCaptureProgressCallback = null; + } + + private void RegisterPreviewCallback() + { + _previewCallback = (frame, _) => + { + _preview?.Invoke(this, new PreviewEventArgs(new PreviewFrame(frame))); + }; + + Native.SetPreviewCallback(_handle, _previewCallback). + ThrowIfFailed("Failed to set preview callback."); + } + + private void UnregisterPreviewCallback() + { + Native.UnsetPreviewCallback(_handle). + ThrowIfFailed("Failed to unset preview callback."); + + _previewCallback = null; + } + + private void RegisterMediaPacketPreviewCallback() + { + _mediaPacketPreviewCallback = (mediaPacket, _) => + { + MediaPacket packet = MediaPacket.From(mediaPacket); + + var eventHandler = _mediaPacketPreview; + + if (eventHandler != null) + { + eventHandler.Invoke(this, new MediaPacketPreviewEventArgs(packet)); + } + + packet.Dispose(); + }; + + Native.SetMediaPacketPreviewCallback(_handle, _mediaPacketPreviewCallback). + ThrowIfFailed("Failed to set media packet preview callback."); + } + + private void UnregisterMediaPacketPreviewCallback() + { + Native.UnsetMediaPacketPreviewCallback(_handle). + ThrowIfFailed("Failed to unset media packet preview callback."); + + _mediaPacketPreviewCallback = null; + } + + private void RegisterExtraPreviewCallback() + { + _extraPreviewCallback = (frame, streamId, _) => + { + _extraPreview?.Invoke(this, new ExtraPreviewEventArgs(new PreviewFrame(frame), streamId)); + }; + + Native.SetExtraPreviewCallback(_handle, _extraPreviewCallback). + ThrowIfFailed("Failed to set extra preview callback."); + } + + private void UnregisterExtraPreviewCallback() + { + Native.UnsetPreviewCallback(_handle). + ThrowIfFailed("Failed to unset preview callback."); + + _extraPreviewCallback = null; + } + } +} \ No newline at end of file diff --git a/src/Tizen.Multimedia.Camera/Camera/Camera.Properties.cs b/src/Tizen.Multimedia.Camera/Camera/Camera.Properties.cs new file mode 100644 index 0000000..1943a48 --- /dev/null +++ b/src/Tizen.Multimedia.Camera/Camera/Camera.Properties.cs @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Diagnostics; +using static Interop; +using Native = Interop.Camera; + +namespace Tizen.Multimedia +{ + /// + /// This camera class provides methods to capture photos and supports setting up notifications + /// for state changes of capturing, previewing, focusing, and informing about the resolution and the binary format, + /// and functions for picture manipulations like sepia, negative, and many more. + /// It also notifies you when a significant picture parameter changes, (For example, focus). + /// + /// 3 + /// http://tizen.org/feature/camera + public partial class Camera : IDisposable, IDisplayable + { + /// + /// Gets or sets the various camera settings. + /// + /// 4 + public CameraSettings Settings { get; } + + /// + /// Gets the various camera capabilities. + /// + /// 4 + public CameraCapabilities Capabilities { get; } + + /// + /// Get/set various camera display properties. + /// + /// 3 + public CameraDisplaySettings DisplaySettings { get; } + + private Display _display; + + private CameraError SetDisplay(Display display) + { + if (display == null) + { + return CameraDisplay.SetDisplay(GetHandle(), DisplayType.None, IntPtr.Zero); + } + + return display.ApplyTo(this); + } + + private void ReplaceDisplay(Display newDisplay) + { + _display?.SetOwner(null); + _display = newDisplay; + _display?.SetOwner(this); + } + + /// + /// Sets or gets the display type and handle to show preview images. + /// The camera must be in the state. + /// + /// 3 + /// + /// This must be set before the StartPreview() method. + /// In custom ROI display mode, DisplayRoiArea property must be set before calling this method. + /// + /// In case of any invalid operations. + /// In case of this feature is not supported. + /// The camera already has been disposed of. + /// In case of access to the resources cannot be granted. + public Display Display + { + get + { + return _display; + } + + set + { + ValidateState(CameraState.Created); + + if (value?.Owner != null) + { + if (ReferenceEquals(this, value.Owner)) + { + return; + } + + throw new ArgumentException("The display has already been assigned to another."); + } + + SetDisplay(value).ThrowIfFailed("Failed to set the camera display"); + + ReplaceDisplay(value); + } + } + + CameraError IDisplayable.ApplyEvasDisplay(DisplayType type, ElmSharp.EvasObject evasObject) + { + Debug.Assert(_disposed == false); + ValidationUtil.ValidateEnum(typeof(DisplayType), type, nameof(type)); + + return CameraDisplay.SetDisplay(GetHandle(), type, evasObject); + } + + CameraError IDisplayable.ApplyEcoreWindow(IntPtr windowHandle) + { + Debug.Assert(_disposed == false); + + return CameraDisplay.SetEcoreDisplay(GetHandle(), windowHandle); + } + + /// + /// Gets the state of the camera. + /// + /// 3 + /// None, Created, Preview, Capturing, Captured. + /// The camera already has been disposed of. + public CameraState State + { + get + { + ValidateNotDisposed(); + + Native.GetState(_handle, out CameraState val).ThrowIfFailed("Failed to get camera state"); + + return val; + } + } + + /// + /// The hint for the display reuse. + /// If the hint is set to true, the display will be reused when the camera device is changed with + /// the ChangeDevice method. + /// + /// 3 + /// In case of invalid parameters. + /// An invalid state. + /// The camera already has been disposed of. + public bool DisplayReuseHint + { + get + { + ValidateNotDisposed(); + + Native.GetDisplayReuseHint(_handle, out bool val).ThrowIfFailed("Failed to get camera display reuse hint"); + + return val; + } + + set + { + ValidateState(CameraState.Preview); + + Native.SetDisplayReuseHint(_handle, value).ThrowIfFailed("Failed to set display reuse hint."); + } + } + + /// + /// Gets the facing direction of the camera module. + /// + /// 3 + /// A that specifies the facing direction of the camera device. + /// The camera already has been disposed of. + public CameraFacingDirection Direction + { + get + { + ValidateNotDisposed(); + + Native.GetFacingDirection(_handle, out var val).ThrowIfFailed("Failed to get camera direction"); + + return val; + } + } + + /// + /// Gets the camera device count. + /// + /// 3 + /// This returns 2, if the device supports primary and secondary cameras. + /// Otherwise 1, if the device only supports primary camera. + /// The camera already has been disposed of. + public int CameraCount + { + get + { + ValidateNotDisposed(); + + Native.GetDeviceCount(_handle, out int val).ThrowIfFailed("Failed to get camera device count"); + + return val; + } + } + } +} diff --git a/src/Tizen.Multimedia.Camera/Camera/Camera.cs b/src/Tizen.Multimedia.Camera/Camera/Camera.cs index bfb39a5..2ce5e82 100644 --- a/src/Tizen.Multimedia.Camera/Camera/Camera.cs +++ b/src/Tizen.Multimedia.Camera/Camera/Camera.cs @@ -20,7 +20,6 @@ using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; using System.Threading; -using static Interop; using Native = Interop.Camera; namespace Tizen.Multimedia @@ -40,7 +39,7 @@ namespace Tizen.Multimedia /// /// 3 /// http://tizen.org/feature/camera - public class Camera : IDisposable, IDisplayable + public partial class Camera : IDisposable, IDisplayable { private IntPtr _handle = IntPtr.Zero; private bool _disposed = false; @@ -156,397 +155,7 @@ namespace Tizen.Multimedia } #endregion Check camera state - #region EventHandlers - /// - /// An event that occurs when the camera interrupt is started by the policy. - /// - /// 4 - public event EventHandler InterruptStarted; - private Native.InterruptStartedCallback _interruptStartedCallback; - - /// - /// An event that occurs when an camera is interrupted by the policy. - /// - /// 3 - public event EventHandler Interrupted; - private Native.InterruptedCallback _interruptedCallback; - - /// - /// An event that occurs when there is an asynchronous error. - /// - /// 3 - public event EventHandler ErrorOccurred; - private Native.ErrorCallback _errorCallback; - - /// - /// An event that occurs when the auto focus state is changed. - /// - /// 3 - public event EventHandler FocusStateChanged; - private Native.FocusStateChangedCallback _focusStateChangedCallback; - - /// - /// An event that occurs when a face is detected in the preview frame. - /// - /// 3 - public event EventHandler FaceDetected; - private Native.FaceDetectedCallback _faceDetectedCallback; - - /// - /// An event that occurs during capture of an image. - /// - /// 3 - public event EventHandler Capturing; - private Native.CapturingCallback _capturingCallback; - - /// - /// An event that occurs after the capture of the image. - /// - /// 3 - public event EventHandler CaptureCompleted; - private Native.CaptureCompletedCallback _captureCompletedCallback; - - private Native.HdrCaptureProgressCallback _hdrCaptureProgressCallback; - private event EventHandler _hdrCaptureProgress; - private object _hdrCaptureProgressEventLock = new object(); - - /// - /// An event that occurs when there is a change in the HDR capture progress. - /// Checks whether the is supported or not before adding this EventHandler. - /// - /// 3 - /// In case of HDR feature is not supported. - public event EventHandler HdrCaptureProgress - { - add - { - lock (_hdrCaptureProgressEventLock) - { - if (_hdrCaptureProgress == null) - { - RegisterHdrCaptureProgress(); - } - - _hdrCaptureProgress += value; - } - } - - remove - { - lock (_hdrCaptureProgressEventLock) - { - _hdrCaptureProgress -= value; - - if (_hdrCaptureProgress == null) - { - UnregisterHdrCaptureProgress(); - } - } - } - } - - /// - /// An event that occurs when the camera state is changed. - /// - /// 3 - public event EventHandler StateChanged; - private Native.StateChangedCallback _stateChangedCallback; - - private static Native.DeviceStateChangedCallback _deviceStateChangedCallback; - private static event EventHandler _deviceStateChanged; - private static object _deviceStateChangedEventLock = new object(); - private static int _deviceStateCallbackId; - - /// - /// An event that occurs after the is changed. - /// - /// 3 - /// In case of any invalid operations. - /// In case of this feature is not supported. - /// In case of invalid parameters. - public static event EventHandler DeviceStateChanged - { - add - { - lock (_deviceStateChangedEventLock) - { - if (_deviceStateChanged == null) - { - RegisterDeviceStateChangedCallback(); - } - - _deviceStateChanged += value; - } - } - - remove - { - lock (_deviceStateChangedEventLock) - { - _deviceStateChanged -= value; - - if (_deviceStateChanged == null) - { - UnregisterDeviceStateChangedCallback(); - } - } - } - } - - private Native.PreviewCallback _previewCallback; - private event EventHandler _preview; - private object _previewEventLock = new object(); - /// - /// An event that occurs once per frame when previewing. - /// Preview callback is registered when an user adds a callback explicitly to avoid useless P/Invoke. - /// - /// 3 - public event EventHandler Preview - { - add - { - lock (_previewEventLock) - { - if (_preview == null) - { - RegisterPreviewCallback(); - } - - _preview += value; - } - } - - remove - { - lock (_previewEventLock) - { - _preview -= value; - - if (_preview == null) - { - UnregisterPreviewCallback(); - } - } - } - } - - private Native.MediaPacketPreviewCallback _mediaPacketPreviewCallback; - private EventHandler _mediaPacketPreview; - private object _mediaPacketPreviewEventLock = new object(); - - /// - /// An event that occurs once per frame when previewing. - /// Preview callback is registered when an user adds a callback explicitly to avoid useless P/Invoke. - /// - /// 3 - public event EventHandler MediaPacketPreview - { - add - { - lock (_mediaPacketPreviewEventLock) - { - if (_mediaPacketPreview == null) - { - RegisterMediaPacketPreviewCallback(); - } - - _mediaPacketPreview += value; - } - } - - remove - { - lock (_mediaPacketPreviewEventLock) - { - _mediaPacketPreview -= value; - - if (_mediaPacketPreview == null) - { - UnregisterMediaPacketPreviewCallback(); - } - } - } - } - #endregion EventHandlers - - #region Properties - /// - /// Gets or sets the various camera settings. - /// - /// 4 - public CameraSettings Settings { get; } - - /// - /// Gets the various camera capabilities. - /// - /// 4 - public CameraCapabilities Capabilities { get; } - - /// - /// Get/set various camera display properties. - /// - /// 3 - public CameraDisplaySettings DisplaySettings { get; } - - private Display _display; - - private CameraError SetDisplay(Display display) - { - if (display == null) - { - return CameraDisplay.SetDisplay(GetHandle(), DisplayType.None, IntPtr.Zero); - } - - return display.ApplyTo(this); - } - - private void ReplaceDisplay(Display newDisplay) - { - _display?.SetOwner(null); - _display = newDisplay; - _display?.SetOwner(this); - } - - /// - /// Sets or gets the display type and handle to show preview images. - /// The camera must be in the state. - /// - /// 3 - /// - /// This must be set before the StartPreview() method. - /// In custom ROI display mode, DisplayRoiArea property must be set before calling this method. - /// - /// In case of any invalid operations. - /// In case of this feature is not supported. - /// The camera already has been disposed of. - /// In case of access to the resources cannot be granted. - public Display Display - { - get - { - return _display; - } - - set - { - ValidateState(CameraState.Created); - - if (value?.Owner != null) - { - if (ReferenceEquals(this, value.Owner)) - { - return; - } - - throw new ArgumentException("The display has already been assigned to another."); - } - SetDisplay(value).ThrowIfFailed("Failed to set the camera display"); - - ReplaceDisplay(value); - } - } - - CameraError IDisplayable.ApplyEvasDisplay(DisplayType type, ElmSharp.EvasObject evasObject) - { - Debug.Assert(_disposed == false); - ValidationUtil.ValidateEnum(typeof(DisplayType), type, nameof(type)); - - return CameraDisplay.SetDisplay(GetHandle(), type, evasObject); - } - - CameraError IDisplayable.ApplyEcoreWindow(IntPtr windowHandle) - { - Debug.Assert(_disposed == false); - - return CameraDisplay.SetEcoreDisplay(GetHandle(), windowHandle); - } - - /// - /// Gets the state of the camera. - /// - /// 3 - /// None, Created, Preview, Capturing, Captured. - /// The camera already has been disposed of. - public CameraState State - { - get - { - ValidateNotDisposed(); - - CameraState val = CameraState.None; - - Native.GetState(_handle, out val).ThrowIfFailed("Failed to get camera state"); - - return val; - } - } - - /// - /// The hint for the display reuse. - /// If the hint is set to true, the display will be reused when the camera device is changed with - /// the ChangeDevice method. - /// - /// 3 - /// In case of invalid parameters. - /// An invalid state. - /// The camera already has been disposed of. - public bool DisplayReuseHint - { - get - { - ValidateNotDisposed(); - - Native.GetDisplayReuseHint(_handle, out bool val).ThrowIfFailed("Failed to get camera display reuse hint"); - - return val; - } - - set - { - ValidateState(CameraState.Preview); - - Native.SetDisplayReuseHint(_handle, value).ThrowIfFailed("Failed to set display reuse hint."); - } - } - - /// - /// Gets the facing direction of the camera module. - /// - /// 3 - /// A that specifies the facing direction of the camera device. - /// The camera already has been disposed of. - public CameraFacingDirection Direction - { - get - { - ValidateNotDisposed(); - - Native.GetFacingDirection(_handle, out var val).ThrowIfFailed("Failed to get camera direction"); - - return val; - } - } - - /// - /// Gets the camera device count. - /// - /// 3 - /// This returns 2, if the device supports primary and secondary cameras. - /// Otherwise 1, if the device only supports primary camera. - /// The camera already has been disposed of. - public int CameraCount - { - get - { - ValidateNotDisposed(); - - Native.GetDeviceCount(_handle, out int val).ThrowIfFailed("Failed to get camera device count"); - - return val; - } - } - #endregion Properties #region Methods /// @@ -678,7 +287,7 @@ namespace Tizen.Multimedia { ValidateState(CameraState.Preview); - Native.StartCapture(_handle, _capturingCallback, _captureCompletedCallback, IntPtr.Zero). + Native.StartCapture(_handle, _capturingCallback, _captureCompletedCallback). ThrowIfFailed("Failed to start the camera capture."); SetState(CameraState.Capturing); @@ -733,7 +342,7 @@ namespace Tizen.Multimedia }); } - Native.StartContinuousCapture(_handle, count, interval, _capturingCallback, _captureCompletedCallback, IntPtr.Zero). + Native.StartContinuousCapture(_handle, count, interval, _capturingCallback, _captureCompletedCallback). ThrowIfFailed("Failed to start the continuous capture."); SetState(CameraState.Capturing); @@ -814,7 +423,7 @@ namespace Tizen.Multimedia FaceDetected?.Invoke(this, new FaceDetectedEventArgs(result)); }; - Native.StartFaceDetection(_handle, _faceDetectedCallback, IntPtr.Zero). + Native.StartFaceDetection(_handle, _faceDetectedCallback). ThrowIfFailed("Failed to start face detection"); } @@ -842,174 +451,5 @@ namespace Tizen.Multimedia _faceDetectedCallback = null; } #endregion Methods - - #region Callback registrations - private void RegisterCallbacks() - { - RegisterErrorCallback(); - RegisterFocusStateChanged(); - RegisterInterruptStartedCallback(); - RegisterInterruptedCallback(); - RegisterStateChangedCallback(); - - //Define capturing callback - _capturingCallback = (IntPtr main, IntPtr postview, IntPtr thumbnail, IntPtr userData) => - { - Capturing?.Invoke(this, new CameraCapturingEventArgs(new StillImage(main), - postview == IntPtr.Zero ? null : new StillImage(postview), - thumbnail == IntPtr.Zero ? null : new StillImage(thumbnail))); - }; - - //Define captureCompleted callback - _captureCompletedCallback = _ => - { - SetState(CameraState.Captured); - CaptureCompleted?.Invoke(this, EventArgs.Empty); - }; - } - - private void RegisterInterruptStartedCallback() - { - _interruptStartedCallback = (CameraPolicy policy, CameraState state, IntPtr userData) => - { - InterruptStarted?.Invoke(this, new CameraInterruptStartedEventArgs(policy, state)); - }; - - Native.SetInterruptStartedCallback(_handle, _interruptStartedCallback, IntPtr.Zero). - ThrowIfFailed("Failed to set interrupt callback"); - } - - private void RegisterInterruptedCallback() - { - _interruptedCallback = (CameraPolicy policy, CameraState previous, CameraState current, IntPtr userData) => - { - Interrupted?.Invoke(this, new CameraInterruptedEventArgs(policy, previous, current)); - }; - - Native.SetInterruptedCallback(_handle, _interruptedCallback, IntPtr.Zero). - ThrowIfFailed("Failed to set interrupt callback"); - } - - private void RegisterErrorCallback() - { - _errorCallback = (CameraErrorCode error, CameraState current, IntPtr userData) => - { - ErrorOccurred?.Invoke(this, new CameraErrorOccurredEventArgs(error, current)); - }; - - Native.SetErrorCallback(_handle, _errorCallback, IntPtr.Zero).ThrowIfFailed("Setting error callback failed"); - } - - private void RegisterStateChangedCallback() - { - _stateChangedCallback = (CameraState previous, CameraState current, bool byPolicy, IntPtr _) => - { - SetState(current); - Log.Info(CameraLog.Tag, "Camera state changed " + previous.ToString() + " -> " + current.ToString()); - StateChanged?.Invoke(this, new CameraStateChangedEventArgs(previous, current, byPolicy)); - }; - - Native.SetStateChangedCallback(_handle, _stateChangedCallback, IntPtr.Zero). - ThrowIfFailed("Setting state changed callback failed"); - } - - private static void RegisterDeviceStateChangedCallback() - { - _deviceStateChangedCallback = (CameraDevice device, CameraDeviceState state, IntPtr userData) => - { - _deviceStateChanged?.Invoke(null, new CameraDeviceStateChangedEventArgs(device, state)); - }; - - Native.SetDeviceStateChangedCallback(_deviceStateChangedCallback, IntPtr.Zero, out _deviceStateCallbackId). - ThrowIfFailed("Failed to set device state changed callback"); - - Log.Info(CameraLog.Tag, "add callbackId " + _deviceStateCallbackId.ToString()); - } - - private static void UnregisterDeviceStateChangedCallback() - { - Native.UnsetDeviceStateChangedCallback(_deviceStateCallbackId). - ThrowIfFailed("Unsetting device state changed callback failed"); - - _deviceStateChangedCallback = null; - _deviceStateCallbackId = 0; - } - - private void RegisterFocusStateChanged() - { - _focusStateChangedCallback = (CameraFocusState state, IntPtr userData) => - { - FocusStateChanged?.Invoke(this, new CameraFocusStateChangedEventArgs(state)); - }; - - Native.SetFocusStateChangedCallback(_handle, _focusStateChangedCallback, IntPtr.Zero). - ThrowIfFailed("Setting focus changed callback failed"); - } - - private void RegisterHdrCaptureProgress() - { - _hdrCaptureProgressCallback = (int percent, IntPtr userData) => - { - _hdrCaptureProgress?.Invoke(this, new HdrCaptureProgressEventArgs(percent)); - }; - - Native.SetHdrCaptureProgressCallback(_handle, _hdrCaptureProgressCallback, IntPtr.Zero). - ThrowIfFailed("Setting Hdr capture progress callback failed"); - } - - private void UnregisterHdrCaptureProgress() - { - Native.UnsetHdrCaptureProgressCallback(_handle). - ThrowIfFailed("Unsetting hdr capture progress is failed"); - - _hdrCaptureProgressCallback = null; - } - - private void RegisterPreviewCallback() - { - _previewCallback = (IntPtr frame, IntPtr userData) => - { - _preview?.Invoke(this, new PreviewEventArgs(new PreviewFrame(frame))); - }; - - Native.SetPreviewCallback(_handle, _previewCallback, IntPtr.Zero). - ThrowIfFailed("Setting preview callback failed"); - } - - private void UnregisterPreviewCallback() - { - Native.UnsetPreviewCallback(_handle).ThrowIfFailed("Unsetting preview callback failed"); - - _previewCallback = null; - } - - private void RegisterMediaPacketPreviewCallback() - { - _mediaPacketPreviewCallback = (IntPtr mediaPacket, IntPtr userData) => - { - MediaPacket packet = MediaPacket.From(mediaPacket); - - var eventHandler = _mediaPacketPreview; - - if (eventHandler != null) - { - eventHandler.Invoke(this, new MediaPacketPreviewEventArgs(packet)); - } - - packet.Dispose(); - }; - - Native.SetMediaPacketPreviewCallback(_handle, _mediaPacketPreviewCallback, IntPtr.Zero). - ThrowIfFailed("Setting media packet preview callback failed"); - } - - private void UnregisterMediaPacketPreviewCallback() - { - Native.UnsetMediaPacketPreviewCallback(_handle). - ThrowIfFailed("Unsetting media packet preview callback failed"); - - _mediaPacketPreviewCallback = null; - } - #endregion Callback registrations } } diff --git a/src/Tizen.Multimedia.Camera/Camera/CameraCapabilities.cs b/src/Tizen.Multimedia.Camera/Camera/CameraCapabilities.cs index 23ec438..7056ed4 100644 --- a/src/Tizen.Multimedia.Camera/Camera/CameraCapabilities.cs +++ b/src/Tizen.Multimedia.Camera/Camera/CameraCapabilities.cs @@ -582,15 +582,15 @@ namespace Tizen.Multimedia #region Methods for getting supported values private IList GetSupportedPreviewResolutions() { - List previewResolutions = new List(); + var previewResolutions = new List(); - NativeCapabilities.PreviewResolutionCallback callback = (int width, int height, IntPtr userData) => + NativeCapabilities.PreviewResolutionCallback callback = (width, height, _) => { previewResolutions.Add(new Size(width, height)); return true; }; - NativeCapabilities.SupportedPreviewResolutions(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedPreviewResolutions(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported preview resolutions"); return previewResolutions.AsReadOnly(); @@ -598,15 +598,15 @@ namespace Tizen.Multimedia private IList GetSupportedCaptureResolutions() { - List cameraResolutions = new List(); + var cameraResolutions = new List(); - NativeCapabilities.CaptureResolutionCallback callback = (int width, int height, IntPtr userData) => + NativeCapabilities.CaptureResolutionCallback callback = (width, height, _) => { cameraResolutions.Add(new Size(width, height)); return true; }; - NativeCapabilities.SupportedCaptureResolutions(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedCaptureResolutions(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported capture resolutions"); return cameraResolutions.AsReadOnly(); @@ -614,15 +614,15 @@ namespace Tizen.Multimedia private IList GetSupportedCapturePixelFormats() { - List captureFormats = new List(); + var captureFormats = new List(); - NativeCapabilities.CaptureFormatCallback callback = (CameraPixelFormat format, IntPtr userData) => + NativeCapabilities.CaptureFormatCallback callback = (format, _) => { captureFormats.Add(format); return true; }; - NativeCapabilities.SupportedCapturePixelFormats(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedCapturePixelFormats(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported capture formats."); return captureFormats.AsReadOnly(); @@ -630,15 +630,15 @@ namespace Tizen.Multimedia private IList GetSupportedPreviewPixelFormats() { - List previewFormats = new List(); + var previewFormats = new List(); - NativeCapabilities.PreviewFormatCallback callback = (CameraPixelFormat format, IntPtr userData) => + NativeCapabilities.PreviewFormatCallback callback = (format, _) => { previewFormats.Add(format); return true; }; - NativeCapabilities.SupportedPreviewPixelFormats(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedPreviewPixelFormats(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported preview formats."); return previewFormats.AsReadOnly(); @@ -646,15 +646,15 @@ namespace Tizen.Multimedia private IList GetSupportedPreviewFps() { - List previewFps = new List(); + var previewFps = new List(); - NativeCapabilities.FpsCallback callback = (CameraFps fps, IntPtr userData) => + NativeCapabilities.FpsCallback callback = (fps, _) => { previewFps.Add(fps); return true; }; - NativeCapabilities.SupportedPreviewFps(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedPreviewFps(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported camera fps"); return previewFps.AsReadOnly(); @@ -662,15 +662,15 @@ namespace Tizen.Multimedia private IList GetSupportedPreviewFpsByResolutions(int width, int height) { - List fpsByResolution = new List(); + var fpsByResolution = new List(); - NativeCapabilities.FpsByResolutionCallback callback = (CameraFps fps, IntPtr userData) => + NativeCapabilities.FpsByResolutionCallback callback = (fps, _) => { fpsByResolution.Add(fps); return true; }; - NativeCapabilities.SupportedPreviewFpsByResolution(_camera.GetHandle(), width, height, callback, IntPtr.Zero). + NativeCapabilities.SupportedPreviewFpsByResolution(_camera.GetHandle(), width, height, callback). ThrowIfFailed("Failed to get the supported fps by resolutions."); return fpsByResolution.AsReadOnly(); @@ -678,15 +678,15 @@ namespace Tizen.Multimedia private IList GetSupportedAutoFocusModes() { - List autoFocusModes = new List(); + var autoFocusModes = new List(); - NativeCapabilities.AfModeCallback callback = (CameraAutoFocusMode mode, IntPtr userData) => + NativeCapabilities.AfModeCallback callback = (mode, _) => { autoFocusModes.Add(mode); return true; }; - NativeCapabilities.SupportedAutoFocusModes(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedAutoFocusModes(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported Auto focus modes."); return autoFocusModes.AsReadOnly(); @@ -694,15 +694,15 @@ namespace Tizen.Multimedia private IList GetSupportedExposureModes() { - List exposureModes = new List(); + var exposureModes = new List(); - NativeCapabilities.ExposureModeCallback callback = (CameraExposureMode mode, IntPtr userData) => + NativeCapabilities.ExposureModeCallback callback = (mode, _) => { exposureModes.Add(mode); return true; }; - NativeCapabilities.SupportedExposureModes(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedExposureModes(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported Exposure modes."); return exposureModes.AsReadOnly(); @@ -710,15 +710,15 @@ namespace Tizen.Multimedia private IList GetSupportedIsoLevels() { - List isoLevels = new List(); + var isoLevels = new List(); - NativeCapabilities.IsoCallback callback = (CameraIsoLevel iso, IntPtr userData) => + NativeCapabilities.IsoCallback callback = (iso, _) => { isoLevels.Add(iso); return true; }; - NativeCapabilities.SupportedIso(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedIso(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported Iso levels."); return isoLevels.AsReadOnly(); @@ -726,15 +726,15 @@ namespace Tizen.Multimedia private IList GetSupportedTheaterModes() { - List theaterModes = new List(); + var theaterModes = new List(); - NativeCapabilities.TheaterModeCallback callback = (CameraTheaterMode theaterMode, IntPtr userData) => + NativeCapabilities.TheaterModeCallback callback = (theaterMode, _) => { theaterModes.Add(theaterMode); return true; }; - NativeCapabilities.SupportedTheaterModes(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedTheaterModes(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported theater modes."); return theaterModes.AsReadOnly(); @@ -742,15 +742,15 @@ namespace Tizen.Multimedia private IList GetSupportedWhitebalances() { - List whitebalances = new List(); + var whitebalances = new List(); - NativeCapabilities.WhitebalanceCallback callback = (CameraWhiteBalance whiteBalance, IntPtr userData) => + NativeCapabilities.WhitebalanceCallback callback = (whiteBalance, _) => { whitebalances.Add(whiteBalance); return true; }; - NativeCapabilities.SupportedWhitebalance(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedWhitebalance(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported white balance."); return whitebalances.AsReadOnly(); @@ -758,15 +758,15 @@ namespace Tizen.Multimedia private IList GetSupportedFlashModes() { - List flashModes = new List(); + var flashModes = new List(); - NativeCapabilities.FlashModeCallback callback = (CameraFlashMode flashMode, IntPtr userData) => + NativeCapabilities.FlashModeCallback callback = (flashMode, _) => { flashModes.Add(flashMode); return true; }; - NativeCapabilities.SupportedFlashModes(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedFlashModes(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported flash modes."); return flashModes.AsReadOnly(); @@ -774,15 +774,15 @@ namespace Tizen.Multimedia private IList GetSupportedSceneModes() { - List sceneModes = new List(); + var sceneModes = new List(); - NativeCapabilities.SceneModeCallback callback = (CameraSceneMode sceneMode, IntPtr userData) => + NativeCapabilities.SceneModeCallback callback = (sceneMode, _) => { sceneModes.Add(sceneMode); return true; }; - NativeCapabilities.SupportedSceneModes(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedSceneModes(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported scene modes."); return sceneModes.AsReadOnly(); @@ -790,15 +790,15 @@ namespace Tizen.Multimedia private IList GetSupportedEffects() { - List effectModes = new List(); + var effectModes = new List(); - NativeCapabilities.EffectCallback callback = (CameraEffectMode effect, IntPtr userData) => + NativeCapabilities.EffectCallback callback = (effect, _) => { effectModes.Add(effect); return true; }; - NativeCapabilities.SupportedEffects(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedEffects(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported camera effects."); return effectModes.AsReadOnly(); @@ -806,15 +806,15 @@ namespace Tizen.Multimedia private IList GetSupportedStreamRotations() { - List streamRotations = new List(); + var streamRotations = new List(); - NativeCapabilities.StreamRotationCallback callback = (Rotation streamRotation, IntPtr userData) => + NativeCapabilities.StreamRotationCallback callback = (streamRotation, _) => { streamRotations.Add(streamRotation); return true; }; - NativeCapabilities.SupportedStreamRotations(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedStreamRotations(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported camera rotations."); return streamRotations.AsReadOnly(); @@ -822,15 +822,15 @@ namespace Tizen.Multimedia private IList GetSupportedStreamFlips() { - List streamFlips = new List(); + var streamFlips = new List(); - NativeCapabilities.StreamFlipCallback callback = (Flips streamFlip, IntPtr userData) => + NativeCapabilities.StreamFlipCallback callback = (streamFlip, _) => { streamFlips.Add(streamFlip); return true; }; - NativeCapabilities.SupportedStreamFlips(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedStreamFlips(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported camera flips."); return streamFlips.AsReadOnly(); @@ -838,15 +838,15 @@ namespace Tizen.Multimedia private IList GetSupportedPtzTypes() { - List ptzTypes = new List(); + var ptzTypes = new List(); - NativeCapabilities.PtzTypeCallback callback = (CameraPtzType ptzType, IntPtr userData) => + NativeCapabilities.PtzTypeCallback callback = (ptzType, _) => { ptzTypes.Add(ptzType); return true; }; - NativeCapabilities.SupportedPtzTypes(_camera.GetHandle(), callback, IntPtr.Zero). + NativeCapabilities.SupportedPtzTypes(_camera.GetHandle(), callback). ThrowIfFailed("Failed to get the supported Ptz types."); return ptzTypes.AsReadOnly(); diff --git a/src/Tizen.Multimedia.Camera/Camera/CameraCapturingEventArgs.cs b/src/Tizen.Multimedia.Camera/Camera/CameraCapturingEventArgs.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/CameraDeviceStateChangedEventArgs.cs b/src/Tizen.Multimedia.Camera/Camera/CameraDeviceStateChangedEventArgs.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/CameraErrorOccurredEventArgs.cs b/src/Tizen.Multimedia.Camera/Camera/CameraErrorOccurredEventArgs.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/CameraFocusStateChangedEventArgs.cs b/src/Tizen.Multimedia.Camera/Camera/CameraFocusStateChangedEventArgs.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/CameraInterruptStartedEventArgs.cs b/src/Tizen.Multimedia.Camera/Camera/CameraInterruptStartedEventArgs.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/CameraInterruptedEventArgs.cs b/src/Tizen.Multimedia.Camera/Camera/CameraInterruptedEventArgs.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/CameraStateChangedEventArgs.cs b/src/Tizen.Multimedia.Camera/Camera/CameraStateChangedEventArgs.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/DoublePlane.cs b/src/Tizen.Multimedia.Camera/Camera/DoublePlane.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/ExtraPreviewEventArgs.cs b/src/Tizen.Multimedia.Camera/Camera/ExtraPreviewEventArgs.cs new file mode 100644 index 0000000..40734e5 --- /dev/null +++ b/src/Tizen.Multimedia.Camera/Camera/ExtraPreviewEventArgs.cs @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.ComponentModel; + +namespace Tizen.Multimedia +{ + /// + /// Provides data for the event. + /// + /// 9 + [EditorBrowsable(EditorBrowsableState.Never)] + public class ExtraPreviewEventArgs : EventArgs + { + internal ExtraPreviewEventArgs(PreviewFrame preview, int streadId) + { + Preview = preview; + StreamId = streadId; + } + + /// + /// Gets the preview frame data. + /// + /// 9 + [EditorBrowsable(EditorBrowsableState.Never)] + public PreviewFrame Preview { get; } + + /// + /// Gets the stream ID. + /// + /// 9 + [EditorBrowsable(EditorBrowsableState.Never)] + public int StreamId { get; } + } +} diff --git a/src/Tizen.Multimedia.Camera/Camera/FaceDetectedEventArgs.cs b/src/Tizen.Multimedia.Camera/Camera/FaceDetectedEventArgs.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/FaceDetectionData.cs b/src/Tizen.Multimedia.Camera/Camera/FaceDetectionData.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/HdrCaptureProgressEventArgs.cs b/src/Tizen.Multimedia.Camera/Camera/HdrCaptureProgressEventArgs.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/MediaPacketPreviewEventArgs.cs b/src/Tizen.Multimedia.Camera/Camera/MediaPacketPreviewEventArgs.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/PreviewEventArgs.cs b/src/Tizen.Multimedia.Camera/Camera/PreviewEventArgs.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/SinglePlane.cs b/src/Tizen.Multimedia.Camera/Camera/SinglePlane.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/StillImage.cs b/src/Tizen.Multimedia.Camera/Camera/StillImage.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Camera/TriplePlane.cs b/src/Tizen.Multimedia.Camera/Camera/TriplePlane.cs old mode 100755 new mode 100644 diff --git a/src/Tizen.Multimedia.Camera/Interop/Interop.Camera.cs b/src/Tizen.Multimedia.Camera/Interop/Interop.Camera.cs index 26b87fd..759269c 100644 --- a/src/Tizen.Multimedia.Camera/Interop/Interop.Camera.cs +++ b/src/Tizen.Multimedia.Camera/Interop/Interop.Camera.cs @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + using System; using System.Runtime.InteropServices; using Tizen.Internals; @@ -51,6 +51,9 @@ internal static partial class Interop internal delegate void PreviewCallback(IntPtr frame, IntPtr userData); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void ExtraPreviewCallback(IntPtr frame, int streamId, IntPtr userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void MediaPacketPreviewCallback(IntPtr mediaPacketHandle, IntPtr userData); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -82,11 +85,11 @@ internal static partial class Interop [DllImport(Libraries.Camera, EntryPoint = "camera_start_capture")] internal static extern CameraError StartCapture(IntPtr handle, CapturingCallback captureCallback, - CaptureCompletedCallback completedCallback, IntPtr userData); + CaptureCompletedCallback completedCallback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_start_continuous_capture")] internal static extern CameraError StartContinuousCapture(IntPtr handle, int count, int interval, - CapturingCallback captureCallback, CaptureCompletedCallback completedCallback, IntPtr userData); + CapturingCallback captureCallback, CaptureCompletedCallback completedCallback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_stop_continuous_capture")] internal static extern CameraError StopContinuousCapture(IntPtr handle); @@ -110,7 +113,7 @@ internal static partial class Interop internal static extern CameraError GetRecommendedPreviewResolution(IntPtr handle, out int width, out int height); [DllImport(Libraries.Camera, EntryPoint = "camera_start_face_detection")] - internal static extern CameraError StartFaceDetection(IntPtr handle, FaceDetectedCallback callback, IntPtr userData); + internal static extern CameraError StartFaceDetection(IntPtr handle, FaceDetectedCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_stop_face_detection")] internal static extern CameraError StopFaceDetection(IntPtr handle); @@ -146,19 +149,25 @@ internal static partial class Interop internal static extern CameraError GetFlashState(CameraDevice device, out CameraFlashState state); [DllImport(Libraries.Camera, EntryPoint = "camera_set_preview_cb")] - internal static extern CameraError SetPreviewCallback(IntPtr handle, PreviewCallback callback, IntPtr userData); + internal static extern CameraError SetPreviewCallback(IntPtr handle, PreviewCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_unset_preview_cb")] internal static extern CameraError UnsetPreviewCallback(IntPtr handle); [DllImport(Libraries.Camera, EntryPoint = "camera_set_media_packet_preview_cb")] - internal static extern CameraError SetMediaPacketPreviewCallback(IntPtr handle, MediaPacketPreviewCallback callback, IntPtr userData); + internal static extern CameraError SetMediaPacketPreviewCallback(IntPtr handle, MediaPacketPreviewCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_unset_media_packet_preview_cb")] internal static extern CameraError UnsetMediaPacketPreviewCallback(IntPtr handle); + [DllImport(Libraries.Camera, EntryPoint = "camera_set_extra_preview_cb")] + internal static extern CameraError SetExtraPreviewCallback(IntPtr handle, ExtraPreviewCallback callback, IntPtr userData = default); + + [DllImport(Libraries.Camera, EntryPoint = "camera_unset_extra_preview_cb")] + internal static extern CameraError UnsetExtraPreviewCallback(IntPtr handle); + [DllImport(Libraries.Camera, EntryPoint = "camera_set_state_changed_cb")] - internal static extern CameraError SetStateChangedCallback(IntPtr handle, StateChangedCallback callback, IntPtr userData); + internal static extern CameraError SetStateChangedCallback(IntPtr handle, StateChangedCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_add_device_state_changed_cb")] internal static extern CameraError SetDeviceStateChangedCallback(DeviceStateChangedCallback callback, IntPtr userData, out int callbackId); @@ -170,31 +179,31 @@ internal static partial class Interop internal static extern CameraError UnsetDeviceStateChangedCallback(int cbId); [DllImport(Libraries.Camera, EntryPoint = "camera_set_interrupt_started_cb")] - internal static extern CameraError SetInterruptStartedCallback(IntPtr handle, InterruptStartedCallback callback, IntPtr userData); + internal static extern CameraError SetInterruptStartedCallback(IntPtr handle, InterruptStartedCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_unset_interrupt_started_cb")] internal static extern CameraError UnsetInterruptStartedCallback(IntPtr handle); [DllImport(Libraries.Camera, EntryPoint = "camera_set_interrupted_cb")] - internal static extern CameraError SetInterruptedCallback(IntPtr handle, InterruptedCallback callback, IntPtr userData); + internal static extern CameraError SetInterruptedCallback(IntPtr handle, InterruptedCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_unset_interrupted_cb")] internal static extern CameraError UnsetInterruptedCallback(IntPtr handle); [DllImport(Libraries.Camera, EntryPoint = "camera_set_focus_changed_cb")] - internal static extern CameraError SetFocusStateChangedCallback(IntPtr handle, FocusStateChangedCallback callback, IntPtr userData); + internal static extern CameraError SetFocusStateChangedCallback(IntPtr handle, FocusStateChangedCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_unset_focus_changed_cb")] internal static extern CameraError UnsetFocusChangedCallback(IntPtr handle); [DllImport(Libraries.Camera, EntryPoint = "camera_set_error_cb")] - internal static extern CameraError SetErrorCallback(IntPtr handle, ErrorCallback callback, IntPtr userData); + internal static extern CameraError SetErrorCallback(IntPtr handle, ErrorCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_unset_error_cb")] internal static extern CameraError UnsetErrorCallback(IntPtr handle); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_hdr_capture_progress_cb")] - internal static extern CameraError SetHdrCaptureProgressCallback(IntPtr handle, HdrCaptureProgressCallback callback, IntPtr userData); + internal static extern CameraError SetHdrCaptureProgressCallback(IntPtr handle, HdrCaptureProgressCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_unset_hdr_capture_progress_cb")] internal static extern CameraError UnsetHdrCaptureProgressCallback(IntPtr handle); diff --git a/src/Tizen.Multimedia.Camera/Interop/Interop.CameraCapabilities.cs b/src/Tizen.Multimedia.Camera/Interop/Interop.CameraCapabilities.cs index f4306e1..4743c96 100755 --- a/src/Tizen.Multimedia.Camera/Interop/Interop.CameraCapabilities.cs +++ b/src/Tizen.Multimedia.Camera/Interop/Interop.CameraCapabilities.cs @@ -107,54 +107,54 @@ internal static partial class Interop internal static extern bool IsAutoContrastSupported(IntPtr handle); [DllImport(Libraries.Camera, EntryPoint = "camera_foreach_supported_preview_resolution")] - internal static extern CameraError SupportedPreviewResolutions(IntPtr handle, PreviewResolutionCallback callback, IntPtr userData); + internal static extern CameraError SupportedPreviewResolutions(IntPtr handle, PreviewResolutionCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_foreach_supported_capture_resolution")] - internal static extern CameraError SupportedCaptureResolutions(IntPtr handle, CaptureResolutionCallback callback, IntPtr userData); + internal static extern CameraError SupportedCaptureResolutions(IntPtr handle, CaptureResolutionCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_foreach_supported_capture_format")] - internal static extern CameraError SupportedCapturePixelFormats(IntPtr handle, CaptureFormatCallback callback, IntPtr userData); + internal static extern CameraError SupportedCapturePixelFormats(IntPtr handle, CaptureFormatCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_foreach_supported_preview_format")] - internal static extern CameraError SupportedPreviewPixelFormats(IntPtr handle, PreviewFormatCallback callback, IntPtr userData); + internal static extern CameraError SupportedPreviewPixelFormats(IntPtr handle, PreviewFormatCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_fps")] - internal static extern CameraError SupportedPreviewFps(IntPtr handle, FpsCallback callback, IntPtr userData); + internal static extern CameraError SupportedPreviewFps(IntPtr handle, FpsCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_fps_by_resolution")] - internal static extern CameraError SupportedPreviewFpsByResolution(IntPtr handle, int width, int height, FpsByResolutionCallback callback, IntPtr userData); + internal static extern CameraError SupportedPreviewFpsByResolution(IntPtr handle, int width, int height, FpsByResolutionCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_af_mode")] - internal static extern CameraError SupportedAutoFocusModes(IntPtr handle, AfModeCallback callback, IntPtr userData); + internal static extern CameraError SupportedAutoFocusModes(IntPtr handle, AfModeCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_exposure_mode")] - internal static extern CameraError SupportedExposureModes(IntPtr handle, ExposureModeCallback callback, IntPtr userData); + internal static extern CameraError SupportedExposureModes(IntPtr handle, ExposureModeCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_iso")] - internal static extern CameraError SupportedIso(IntPtr handle, IsoCallback callback, IntPtr userData); + internal static extern CameraError SupportedIso(IntPtr handle, IsoCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_theater_mode")] - internal static extern CameraError SupportedTheaterModes(IntPtr handle, TheaterModeCallback callback, IntPtr userData); + internal static extern CameraError SupportedTheaterModes(IntPtr handle, TheaterModeCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_whitebalance")] - internal static extern CameraError SupportedWhitebalance(IntPtr handle, WhitebalanceCallback callback, IntPtr userData); + internal static extern CameraError SupportedWhitebalance(IntPtr handle, WhitebalanceCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_effect")] - internal static extern CameraError SupportedEffects(IntPtr handle, EffectCallback callback, IntPtr userData); + internal static extern CameraError SupportedEffects(IntPtr handle, EffectCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_scene_mode")] - internal static extern CameraError SupportedSceneModes(IntPtr handle, SceneModeCallback callback, IntPtr userData); + internal static extern CameraError SupportedSceneModes(IntPtr handle, SceneModeCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_flash_mode")] - internal static extern CameraError SupportedFlashModes(IntPtr handle, FlashModeCallback callback, IntPtr userData); + internal static extern CameraError SupportedFlashModes(IntPtr handle, FlashModeCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_stream_rotation")] - internal static extern CameraError SupportedStreamRotations(IntPtr handle, StreamRotationCallback callback, IntPtr userData); + internal static extern CameraError SupportedStreamRotations(IntPtr handle, StreamRotationCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_stream_flip")] - internal static extern CameraError SupportedStreamFlips(IntPtr handle, StreamFlipCallback callback, IntPtr userData); + internal static extern CameraError SupportedStreamFlips(IntPtr handle, StreamFlipCallback callback, IntPtr userData = default); [DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_ptz_type")] - internal static extern CameraError SupportedPtzTypes(IntPtr handle, PtzTypeCallback callback, IntPtr userData); + internal static extern CameraError SupportedPtzTypes(IntPtr handle, PtzTypeCallback callback, IntPtr userData = default); } }