Name: csapi-multimedia
Summary: Tizen Multimedia API for C#
-Version: 1.0.41
-Release: 1
+Version: 1.0.42
+Release: 0
Group: Development/Libraries
License: Apache-2.0
URL: https://www.tizen.org
+++ /dev/null
-/*
- * 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.
- */
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// The class containing area of the display.
- /// </summary>
- public class Area
- {
- /// <summary>
- /// Constructor for area class.
- /// </summary>
- /// <param name="x">X coordinate</param>
- /// <param name="y">Y coordinate</param>
- /// <param name="width">Width of area</param>
- /// <param name="height">Height of area</param>
- public Area(int x, int y, int width, int height)
- {
- X = x;
- Y = y;
- Width = width;
- Height = height;
- }
-
- /// <summary>
- /// X coordinate of the area.
- /// </summary>
- public int X
- {
- get;
- }
-
- /// <summary>
- /// Y coordinate of the area.
- /// </summary>
- public int Y
- {
- get;
- }
-
- /// <summary>
- /// Width of area.
- /// </summary>
- public int Width
- {
- get;
- }
-
- /// <summary>
- /// Height of area.
- /// </summary>
- public int Height
- {
- get;
- }
- }
-}
-
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
using System;
using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
using System.Runtime.InteropServices;
-using Tizen.Internals.Errors;
-using Tizen.Multimedia;
-using System.IO;
-
+using System.Threading;
+using System.Collections;
namespace Tizen.Multimedia
{
static internal class CameraLog
{
private IntPtr _handle = IntPtr.Zero;
private bool _disposed = false;
- private Interop.Camera.CapturingCallback _capturingCallback;
- private Interop.Camera.CaptureCompletedCallback _captureCompletedCallback;
- private Interop.Camera.FaceDetectedCallback _faceDetectedCallback;
- private EventHandler<CameraErrorOccurredEventArgs> _cameraErrorOccurred;
- private EventHandler<CameraStateChangedEventArgs> _cameraStateChanged;
- private EventHandler<PreviewEventArgs> _preview;
- private EventHandler<CameraFocusChangedEventArgs> _cameraFocusChanged;
- private EventHandler<CameraInterruptedEventArgs> _cameraInterrupted;
- private EventHandler<HdrCaptureProgressEventArgs> _hdrProgress;
- private EventHandler<MediaPacketPreviewEventArgs> _mediaPacketPreview;
- private readonly CameraFeature _cameraFeature;
- private readonly CameraSetting _cameraSetting;
- private readonly CameraDisplay _cameraDisplay;
- private readonly List<FaceDetectedData> _faces = new List<FaceDetectedData>();
- private Interop.Camera.PreviewCallback _previewCallback;
- Interop.Camera.MediaPacketPreviewCallback _mediaPacketCallback;
- private Interop.Camera.FocusChangedCallback _focusCallback;
- private Interop.Camera.HdrCaptureProgressCallback _hdrProgressCallback;
- private Interop.Camera.StateChangedCallback _stateChangedCallback;
- private Interop.Camera.InterruptedCallback _interruptedCallback;
- private Interop.Camera.ErrorCallback _errorCallback;
+ private CameraState _state = CameraState.None;
+ private static Dictionary<object, int> _callbackIdInfo = new Dictionary<object, int>();
/// <summary>
- /// Initializes a new instance of the <see cref="Tizen.Multimedia.Camera"/> Class.
+ /// Initializes a new instance of the <see cref="Camera"/> Class.
/// </summary>
- /// <param name="device">Device.</param>
+ /// <param name="device">The camera device to access</param>
public Camera(CameraDevice device)
{
- int ret = Interop.Camera.Create((int)device, out _handle);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to create camera instance");
- }
+ CameraErrorFactory.ThrowIfError(Interop.Camera.Create((int)device, out _handle),
+ "Failed to create camera instance");
+
+ Feature = new CameraFeatures(this);
+ Setting = new CameraSettings(this);
+ Display = new CameraDisplay(this);
- _cameraFeature = new CameraFeature(_handle);
- _cameraSetting = new CameraSetting(_handle);
- _cameraDisplay = new CameraDisplay(_handle);
+ RegisterCallbacks();
+
+ _state = CameraState.Created;
}
/// <summary>
return _handle;
}
+#region Dispose support
/// <summary>
- /// Event that occurs when there is change in HDR capture progress.
+ /// Release any unmanaged resources used by this object.
/// </summary>
- public event EventHandler<HdrCaptureProgressEventArgs> HdrCaptureProgress
+ public void Dispose()
{
- add
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
{
- if (_hdrProgress == null)
+ if (disposing)
{
- _hdrProgressCallback = (int percent, IntPtr userData) =>
- {
- HdrCaptureProgressEventArgs eventArgs = new HdrCaptureProgressEventArgs(percent);
- _hdrProgress?.Invoke(this, eventArgs);
- };
- int ret = Interop.Camera.SetHdrCaptureProgressCallback(_handle, _hdrProgressCallback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Setting hdr progress callback failed");
- }
+ // to be used if there are any other disposable objects
}
- _hdrProgress += value;
+ if (_handle != IntPtr.Zero)
+ {
+ Interop.Camera.Destroy(_handle);
+ _handle = IntPtr.Zero;
+ }
+
+ _disposed = true;
}
+ }
- remove
+ internal void ValidateNotDisposed()
+ {
+ if (_disposed)
{
- _hdrProgress -= value;
- if (_hdrProgress == null)
- {
- int ret = Interop.Camera.UnsetHdrCaptureProgressCallback(_handle);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Unsetting hdr progress callback failed");
- }
- }
+ throw new ObjectDisposedException(nameof(Camera));
}
}
+#endregion Dispose support
+
+#region Check camera state
+ internal void ValidateState(params CameraState[] required)
+ {
+ ValidateNotDisposed();
+
+ Debug.Assert(required.Length > 0);
+
+ var curState = _state;
+ if (!required.Contains(curState))
+ {
+ throw new InvalidOperationException($"The camera is not in a valid state. " +
+ $"Current State : { curState }, Valid State : { string.Join(", ", required) }.");
+ }
+ }
+
+ internal void SetState(CameraState state)
+ {
+ _state = state;
+ }
+#endregion Check camera state
+
+#region EventHandlers
+ /// <summary>
+ /// Event that occurs when an camera is interrupted by policy.
+ /// </summary>
+ public event EventHandler<CameraInterruptedEventArgs> Interrupted;
+ private Interop.Camera.InterruptedCallback _interruptedCallback;
+
+ /// <summary>
+ /// Event that occurs when there is an asynchronous error.
+ /// </summary>
+ public event EventHandler<CameraErrorOccurredEventArgs> ErrorOccurred;
+ private Interop.Camera.ErrorCallback _errorCallback;
+
+ /// <summary>
+ /// Event that occurs when the auto focus state is changed.
+ /// </summary>
+ public event EventHandler<CameraFocusStateChangedEventArgs> FocusStateChanged;
+ private Interop.Camera.FocusStateChangedCallback _focusStateChangedCallback;
+
+ /// <summary>
+ /// Event that occurs when a face is detected in preview frame.
+ /// </summary>
+ public event EventHandler<FaceDetectedEventArgs> FaceDetected;
+ private Interop.Camera.FaceDetectedCallback _faceDetectedCallback;
/// <summary>
/// Event that occurs during capture of image.
/// </summary>
- public event EventHandler<CapturingEventArgs> Capturing;
+ public event EventHandler<CameraCapturingEventArgs> Capturing;
+ private Interop.Camera.CapturingCallback _capturingCallback;
/// <summary>
/// Event that occurs after the capture of the image.
/// </summary>
public event EventHandler<EventArgs> CaptureCompleted;
+ private Interop.Camera.CaptureCompletedCallback _captureCompletedCallback;
/// <summary>
- /// Event that occurs when camera state is changed.
+ /// Event that occurs when there is change in HDR capture progress.
+ /// Check whether HdrCapture feature is supported or not before add this EventHandler.
/// </summary>
- public event EventHandler<CameraStateChangedEventArgs> CameraStateChanged
- {
- add
- {
- if (_cameraStateChanged == null)
- {
- _stateChangedCallback = (CameraState previous, CameraState current, bool byPolicy, IntPtr userData) =>
- {
- CameraStateChangedEventArgs eventArgs = new CameraStateChangedEventArgs(previous, current, byPolicy);
- _cameraStateChanged?.Invoke(this, eventArgs);
- };
- int ret = Interop.Camera.SetStateChangedCallback(_handle, _stateChangedCallback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Setting state changed callback failed");
- }
- }
+ public event EventHandler<HdrCaptureProgressEventArgs> HdrCaptureProgress;
+ private Interop.Camera.HdrCaptureProgressCallback _hdrCaptureProgressCallback;
- _cameraStateChanged += value;
- }
+ /// <summary>
+ /// Event that occurs when camera state is changed.
+ /// </summary>
+ public event EventHandler<CameraStateChangedEventArgs> StateChanged;
+ private Interop.Camera.StateChangedCallback _stateChangedCallback;
- remove
- {
- _cameraStateChanged -= value;
- if (_cameraStateChanged == null)
- {
- int ret = Interop.Camera.UnsetStateChangedCallback(_handle);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Unsetting state changed callback failed");
- }
- }
- }
- }
+ #region DeviceStateChanged callback
+ internal static Interop.Camera.DeviceStateChangedCallback _deviceStateChangedCallback;
+ public static event EventHandler<CameraDeviceStateChangedEventArgs> _deviceStateChanged;
+ public static object _deviceStateChangedEventLock = new object();
/// <summary>
- /// Event that occurs when the auto-focus state of camera changes.
+ /// Set the DeviceStateChanged Callback.
+ /// User doesn't need to create camera instance.
+ /// This static EventHandler calls platform function every time because each callback function have to remain its own callbackId.
/// </summary>
- public event EventHandler<CameraFocusChangedEventArgs> CameraFocusChanged
+ /// <param name="callback">Callback of type <see cref="Interop.Camera.DeviceStateChangedCallback"/>.</param>
+ /// <param name="callbackId">The Id of registered callback.</param>
+ /// <exception cref="InvalidOperationException">In case of any invalid operations</exception>
+ /// <exception cref="NotSupportedException">In case of this feature is not supported</exception>
+ /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ public static event EventHandler<CameraDeviceStateChangedEventArgs> DeviceStateChanged
{
add
{
- if (_cameraFocusChanged == null)
+ lock (_deviceStateChangedEventLock)
{
- _focusCallback = (CameraFocusState state, IntPtr userData) =>
+ int callbackId = 0;
+
+ _deviceStateChangedCallback = (CameraDevice device, CameraDeviceState state, IntPtr userData) =>
{
- CameraFocusChangedEventArgs eventArgs = new CameraFocusChangedEventArgs(state);
- _cameraFocusChanged?.Invoke(this, eventArgs);
+ _deviceStateChanged?.Invoke(null, new CameraDeviceStateChangedEventArgs(device, state));
};
- int ret = Interop.Camera.SetFocusChangedCallback(_handle, _focusCallback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Setting focus changed callback failed");
- }
- }
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetDeviceStateChangedCallback(_deviceStateChangedCallback, IntPtr.Zero, out callbackId),
+ "Failed to set interrupt callback");
- _cameraFocusChanged += value;
- }
+ // Keep current callbackId and EventHandler pair to remove EventHandler later.
+ _callbackIdInfo.Add(value, callbackId);
+ Log.Info(CameraLog.Tag, "add callbackId " + callbackId.ToString());
- remove
- {
- _cameraFocusChanged -= value;
- if (_cameraFocusChanged == null)
- {
- int ret = Interop.Camera.UnsetFocusChangedCallback(_handle);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Unsetting focus changed callback failed");
- }
+ _deviceStateChanged += value;
}
}
- }
- /// <summary>
- /// Event that occurs when an camera is interrupted by policy.
- /// </summary>
- public event EventHandler<CameraInterruptedEventArgs> CameraInterrupted
- {
- add
+ remove
{
- if (_cameraInterrupted == null)
+ lock (_deviceStateChangedEventLock)
{
- _interruptedCallback = (CameraPolicy policy, CameraState previous, CameraState current, IntPtr userData) =>
- {
- CameraInterruptedEventArgs eventArgs = new CameraInterruptedEventArgs(policy, previous, current);
- _cameraInterrupted?.Invoke(this, eventArgs);
- };
- int ret = Interop.Camera.SetInterruptedCallback(_handle, _interruptedCallback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Setting interrupt callback failed");
- }
- }
+ _deviceStateChanged -= value;
- _cameraInterrupted += value;
- }
+ int callbackId = 0;
+ _callbackIdInfo.TryGetValue(value, out callbackId);
+ Log.Info(CameraLog.Tag, "remove callbackId " + callbackId.ToString());
- remove
- {
- _cameraInterrupted -= value;
- if (_cameraInterrupted == null)
- {
- int ret = Interop.Camera.UnsetInterruptedCallback(_handle);
- if (ret != (int)CameraError.None)
+ CameraErrorFactory.ThrowIfError(Interop.Camera.UnsetDeviceStateChangedCallback(callbackId),
+ "Unsetting media packet preview callback failed");
+
+ _callbackIdInfo.Remove(value);
+
+ if (_deviceStateChanged == null)
{
- CameraErrorFactory.ThrowException(ret, "Unsetting interrupt callback failed");
+ _deviceStateChangedCallback = null;
}
}
}
}
+ #endregion DeviceStateChanged callback
+ #region Preview EventHandler
+ private Interop.Camera.PreviewCallback _previewCallback;
+ private event EventHandler<PreviewEventArgs> _preview;
+ private object _previewEventLock = new object();
/// <summary>
- /// Event that occurs when there is an asynchronous error.
+ /// Event that occurs once per frame when previewing.
+ /// Preview callback is registered when user add callback explicitly to avoid useless P/Invoke.
/// </summary>
- public event EventHandler<CameraErrorOccurredEventArgs> CameraErrorOccurred
+ public event EventHandler<PreviewEventArgs> Preview
{
add
{
- if (_cameraErrorOccurred == null)
+ lock (_previewEventLock)
{
- _errorCallback = (CameraErrorCode error, CameraState current, IntPtr userData) =>
+ if (_preview == null)
{
- CameraErrorOccurredEventArgs eventArgs = new CameraErrorOccurredEventArgs(error, current);
- _cameraErrorOccurred?.Invoke(this, eventArgs);
- };
- int ret = Interop.Camera.SetErrorCallback(_handle, _errorCallback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Setting error callback failed");
+ RegisterPreviewCallback();
}
- }
- _cameraErrorOccurred += value;
+ _preview += value;
+ }
}
remove
{
- _cameraErrorOccurred -= value;
- if (_cameraErrorOccurred == null)
+ lock (_previewEventLock)
{
- int ret = Interop.Camera.UnsetErrorCallback(_handle);
- if (ret != (int)CameraError.None)
+ _preview -= value;
+
+ if (_preview == null)
{
- CameraErrorFactory.ThrowException(ret, "Unsetting error callback failed");
+ CameraErrorFactory.ThrowIfError(Interop.Camera.UnsetPreviewCallback(_handle),
+ "Unsetting preview callback failed");
+ _previewCallback = null;
}
}
}
}
+ #endregion Preview EventHandler
- /// <summary>
- /// Event that occurs when a face is detected in preview frame.
- /// </summary>
- public event EventHandler<FaceDetectedEventArgs> FaceDetected;
+ #region MediaPacketPreview EventHandler
+ private Interop.Camera.MediaPacketPreviewCallback _mediaPacketPreviewCallback;
+ private EventHandler<MediaPacketPreviewEventArgs> _mediaPacketPreview;
+ private object _mediaPacketPreviewEventLock = new object();
/// <summary>
/// Event that occurs once per frame when previewing.
+ /// Preview callback is registered when user add callback explicitly to avoid useless P/Invoke.
/// </summary>
- public event EventHandler<PreviewEventArgs> Preview
+ public event EventHandler<MediaPacketPreviewEventArgs> MediaPacketPreview
{
add
{
- if (_preview == null)
- {
- CreatePreviewCallback();
- }
-
- _preview += value;
- }
-
- remove
- {
- _preview -= value;
- if (_preview == null)
+ lock (_mediaPacketPreviewEventLock)
{
- int ret = Interop.Camera.UnsetPreviewCallback(_handle);
- if (ret != (int)CameraError.None)
+ if (_mediaPacketPreview == null)
{
- CameraErrorFactory.ThrowException(ret, "Unsetting preview callback failed");
+ RegisterMediaPacketPreviewCallback();
}
- }
- }
- }
- /// <summary>
- /// Event that occurs once per frame when previewing.
- /// </summary>
- public event EventHandler<MediaPacketPreviewEventArgs> MediaPacketPreview
- {
- add
- {
- if (_mediaPacketPreview == null)
- {
- CreateMediaPacketPreviewCallback();
+ _mediaPacketPreview += value;
}
-
- _mediaPacketPreview += value;
}
remove
{
- _mediaPacketPreview -= value;
- if (_mediaPacketPreview == null)
+ lock (_mediaPacketPreviewEventLock)
{
- int ret = Interop.Camera.UnsetMediaPacketPreviewCallback(_handle);
- if (ret != (int)CameraError.None)
+ _mediaPacketPreview -= value;
+
+ if (_mediaPacketPreview == null)
{
- CameraErrorFactory.ThrowException(ret, "Unsetting media packet preview callback failed");
+ CameraErrorFactory.ThrowIfError(Interop.Camera.UnsetMediaPacketPreviewCallback(_handle),
+ "Unsetting media packet preview callback failed");
+ _mediaPacketPreviewCallback = null;
}
}
}
}
+ #endregion MediaPacketPreview EventHandler
+#endregion EventHandlers
+
+#region Properties
/// <summary>
/// Get/Set the various camera settings.
/// </summary>
- public CameraSetting Setting
- {
- get
- {
- return _cameraSetting;
- }
- }
+ public CameraSettings Setting { get; }
/// <summary>
/// Gets the various camera features.
/// </summary>
- public CameraFeature Feature
- {
- get
- {
- return _cameraFeature;
- }
- }
+ public CameraFeatures Feature { get; }
/// <summary>
/// Get/set various camera display properties.
/// </summary>
- public CameraDisplay Display
- {
- get
- {
- return _cameraDisplay;
- }
- }
+ public CameraDisplay Display { get; }
/// <summary>
/// Gets the state of the camera.
{
get
{
- int val = 0;
+ CameraState val = CameraState.None;
+ CameraErrorFactory.ThrowIfError(Interop.Camera.GetState(_handle, out val),
+ "Failed to get camera state");
- int ret = Interop.Camera.GetState(_handle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera state, " + (CameraError)ret);
- }
-
- return (CameraState)val;
+ return val;
}
}
{
bool val = false;
- int ret = Interop.Camera.GetDisplayReuseHint(_handle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera display reuse hint, " + (CameraError)ret);
- }
+ CameraErrorFactory.ThrowIfError(Interop.Camera.GetDisplayReuseHint(_handle, out val),
+ "Failed to get camera display reuse hint");
return val;
}
set
{
- int ret = Interop.Camera.SetDisplayReuseHint(_handle, value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set display reuse hint, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set display reuse hint.");
- }
- }
- }
-
- /// <summary>
- /// Resolution of the preview.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
- public CameraResolution PreviewResolution
- {
- get
- {
- int width = 0;
- int height = 0;
- int ret = Interop.Camera.GetPreviewResolution(_handle, out width, out height);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera preview resolution, " + (CameraError)ret);
- }
-
- CameraResolution res = new CameraResolution(width, height);
- return res;
- }
-
- set
- {
- CameraResolution res = value;
- int ret = Interop.Camera.SetPreviewResolution(_handle, res.Width, res.Height);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set preview resolution, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set preview resolution.");
- }
- }
- }
-
- /// <summary>
- /// Gets the recommended preview resolution.
- /// </summary>
- /// <remarks>
- /// Depending on the capture resolution aspect ratio and display resolution,
- /// the recommended preview resolution is determined.
- /// </remarks>
- public CameraResolution RecommendedPreviewResolution
- {
- get
- {
- int width = 0;
- int height = 0;
- int ret = Interop.Camera.GetRecommendedPreviewResolution(_handle, out width, out height);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get recommended preview resolution, " + (CameraError)ret);
- }
-
- CameraResolution res = new CameraResolution(width, height);
- return res;
- }
- }
-
- /// <summary>
- /// Resolution of the captured image.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
- public CameraResolution CaptureResolution
- {
- get
- {
- int width = 0;
- int height = 0;
- int ret = Interop.Camera.GetCaptureResolution(_handle, out width, out height);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera capture resolution, " + (CameraError)ret);
- }
-
- CameraResolution res = new CameraResolution(width, height);
- return res;
- }
-
- set
- {
- CameraResolution res = value;
- int ret = Interop.Camera.SetCaptureResolution(_handle, res.Width, res.Height);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set capture resolution, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set capture resolution.");
- }
- }
- }
-
- /// <summary>
- /// Format of an image to be captured.
- /// </summary>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
- public CameraPixelFormat CaptureFormat
- {
- get
- {
- int val = 0;
- int ret = Interop.Camera.GetCaptureFormat(_handle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera capture format, " + (CameraError)ret);
- }
-
- return (CameraPixelFormat)val;
- }
-
- set
- {
- int ret = Interop.Camera.SetCaptureFormat(_handle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set capture format, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set capture format.");
- }
- }
- }
-
- /// <summary>
- /// The preview data format.
- /// </summary>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
- public CameraPixelFormat PreviewFormat
- {
- get
- {
- int val = 0;
- int ret = Interop.Camera.GetPreviewFormat(_handle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get preview format, " + (CameraError)ret);
- }
-
- return (CameraPixelFormat)val;
- }
-
- set
- {
- int ret = Interop.Camera.SetPreviewFormat(_handle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set preview format, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set preview format.");
- }
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetDisplayReuseHint(_handle, value),
+ "Failed to set display reuse hint.");
}
}
{
get
{
- int val = 0;
- int ret = Interop.Camera.GetFacingDirection(_handle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera direction, " + (CameraError)ret);
- }
+ CameraFacingDirection val = 0;
- return (CameraFacingDirection)val;
- }
- }
-
- /// <summary>
- /// Gets the camera's flash state.
- /// </summary>
- public CameraFlashState FlashState
- {
- get
- {
- int val = 0;
- int ret = Interop.Camera.GetFlashState(_handle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera flash state, " + (CameraError)ret);
- }
+ CameraErrorFactory.ThrowIfError(Interop.Camera.GetFacingDirection(_handle, out val),
+ "Failed to get camera direction");
- return (CameraFlashState)val;
+ return val;
}
}
/// Gets the camera device count.
/// </summary>
/// <remarks>
- /// If the device supports primary and secondary camera, this returns 2.
- /// If 1 is returned, the device only supports primary camera.
+ /// This returns 2, if the device supports primary and secondary cameras.
+ /// Otherwise 1, if the device only supports primary camera.
/// </remarks>
public int CameraCount
{
get
{
int val = 0;
- int ret = Interop.Camera.GetDeviceCount(_handle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera device count, " + (CameraError)ret);
- }
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.GetDeviceCount(_handle, out val),
+ "Failed to get camera device count");
return val;
}
}
+#endregion Properties
+#region Methods
/// <summary>
/// Changes the camera device.
/// </summary>
/// http://tizen.org/privilege/camera
/// </privilege>
/// <remarks>
- /// This method can be used to change camera device without using destory and create method.
- /// If display reuse is set using <see cref="Tizen.Multimedia.Camera.DisplayReuseHint"/>
- /// before stopping the preview, display handle will be reused and last frame on display
- /// can be kept even though cameradevice is changed.
+ /// If display reuse is set using <see cref="DisplayReuseHint"/>
+ /// before stopping the preview, the display will be reused and last frame on the display
+ /// can be kept even though camera device is changed.
+ /// The camera must be in the <see cref="CameraState.Created"/> or <see cref="CameraState.Preview"/> state.
/// </remarks>
/// <exception cref="ArgumentException">In case of invalid parameters</exception>
/// <exception cref="InvalidOperationException">In case of any invalid operations</exception>
/// <exception cref="NotSupportedException">In case of ChangeDevice feature is not supported</exception>
public void ChangeDevice(CameraDevice device)
{
- int ret = Interop.Camera.ChangeDevice(_handle, (int)device);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to change the camera device");
- }
+ ValidateState(CameraState.Created, CameraState.Preview);
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.ChangeDevice(_handle, (int)device),
+ "Failed to change the camera device");
}
/// <summary>
public CameraDeviceState GetDeviceState(CameraDevice device)
{
int val = 0;
- int ret = Interop.Camera.GetDeviceState(device, out val);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the camera device state.");
- }
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.GetDeviceState(device, out val),
+ "Failed to get the camera device state.");
return (CameraDeviceState)val;
}
+ public static CameraFlashState GetFlashState(CameraDevice device)
+ {
+ CameraFlashState val = CameraFlashState.NotUsed;
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.GetFlashState(device, out val),
+ "Failed to get camera flash state");
+
+ return val;
+ }
+
/// <summary>
/// Starts capturing and drawing preview frames on the screen.
/// The display handle must be set using <see cref="Tizen.Multimedia.Camera.SetDisplay"/>
/// <exception cref="UnauthorizedAccessException">In case of access to the resources cannot be granted</exception>
public void StartPreview()
{
- int ret = Interop.Camera.StartPreview(_handle);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to start the camera preview.");
- }
+ ValidateState(CameraState.Created, CameraState.Captured);
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.StartPreview(_handle),
+ "Failed to start the camera preview.");
+
+ // Update by StateChangedCallback can be delayed for dozens of milliseconds.
+ SetState(CameraState.Preview);
}
/// <summary>
/// <exception cref="UnauthorizedAccessException">In case of access to the resources cannot be granted</exception>
public void StopPreview()
{
- int ret = Interop.Camera.StopPreview(_handle);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to stop the camera preview.");
- }
+ CameraErrorFactory.ThrowIfError(Interop.Camera.StopPreview(_handle),
+ "Failed to stop the camera preview.");
+
+ SetState(CameraState.Created);
}
/// <summary>
/// <exception cref="UnauthorizedAccessException">In case of access to the resources cannot be granted</exception>
public void StartCapture()
{
- Log.Info(CameraLog.Tag, "StartCapture API starting");
-
- _capturingCallback = (IntPtr image, IntPtr postview, IntPtr thumbnail, IntPtr userData) =>
- {
- Interop.Camera.ImageDataStruct _img = new Interop.Camera.ImageDataStruct();
- Interop.Camera.ImageDataStruct _post = new Interop.Camera.ImageDataStruct();
- Interop.Camera.ImageDataStruct _thumb = new Interop.Camera.ImageDataStruct();
- ImageData img = new ImageData();
- ImageData post = new ImageData();
- ImageData thumb = new ImageData();
-
- if (image != IntPtr.Zero)
- {
- _img = Interop.Camera.IntPtrToImageDataStruct(image);
- CopyImageData(img, _img);
- }
- if (postview != IntPtr.Zero)
- {
- _post = Interop.Camera.IntPtrToImageDataStruct(postview);
- CopyImageData(post, _post);
- }
- if (thumbnail != IntPtr.Zero)
- {
- _thumb = Interop.Camera.IntPtrToImageDataStruct(thumbnail);
- CopyImageData(thumb, _thumb);
- }
+ ValidateState(CameraState.Preview);
- CapturingEventArgs eventArgs = new CapturingEventArgs(img, post, thumb);
- Capturing?.Invoke(this, eventArgs);
- };
+ CameraErrorFactory.ThrowIfError(Interop.Camera.StartCapture(_handle, _capturingCallback, _captureCompletedCallback, IntPtr.Zero),
+ "Failed to start the camera capture.");
- _captureCompletedCallback = (IntPtr userData) =>
- {
- EventArgs eventArgs = new EventArgs();
- CaptureCompleted?.Invoke(this, eventArgs);
- };
-
- int ret = Interop.Camera.StartCapture(_handle, _capturingCallback, _captureCompletedCallback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to start the camera capture.");
- }
- Log.Info(CameraLog.Tag, "StartCapture API finished");
- }
-
- /// <summary>
- /// Aborts continuous capturing.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- /// <exception cref="InvalidOperationException">In case of any invalid operations</exception>
- /// <exception cref="NotSupportedException">In case of this feature is not supported</exception>
- /// <exception cref="UnauthorizedAccessException">In case of access to the resources cannot be granted</exception>
- public void StopContinuousCapture()
- {
- int ret = Interop.Camera.StopContinuousCapture(_handle);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to stop the continuous capture.");
- }
+ SetState(CameraState.Capturing);
}
/// <summary>
/// <exception cref="InvalidOperationException">In case of any invalid operations</exception>
/// <exception cref="NotSupportedException">In case of this feature is not supported</exception>
/// <exception cref="UnauthorizedAccessException">In case of access to the resources cannot be granted</exception>
- public void StartContinuousCapture(int count, int interval)
+ public void StartCapture(int count, int interval, CancellationToken cancellationToken)
{
- _capturingCallback = (IntPtr image, IntPtr postview, IntPtr thumbnail, IntPtr userData) =>
- {
- Interop.Camera.ImageDataStruct _img = new Interop.Camera.ImageDataStruct();
- Interop.Camera.ImageDataStruct _post = new Interop.Camera.ImageDataStruct();
- Interop.Camera.ImageDataStruct _thumb = new Interop.Camera.ImageDataStruct();
- ImageData img = new ImageData();
- ImageData post = new ImageData();
- ImageData thumb = new ImageData();
-
- if (image != IntPtr.Zero)
- {
- _img = Interop.Camera.IntPtrToImageDataStruct(image);
- CopyImageData(img, _img);
- }
- if (postview != IntPtr.Zero)
- {
- _post = Interop.Camera.IntPtrToImageDataStruct(postview);
- CopyImageData(post, _post);
- }
- if (thumbnail != IntPtr.Zero)
- {
- _thumb = Interop.Camera.IntPtrToImageDataStruct(thumbnail);
- CopyImageData(thumb, _thumb);
- }
+ ValidateState(CameraState.Preview);
- CapturingEventArgs eventArgs = new CapturingEventArgs(img, post, thumb);
- Capturing?.Invoke(this, eventArgs);
- };
+ if (count < 2)
+ {
+ throw new ArgumentOutOfRangeException(nameof(count), count, $"{nameof(count)} should be greater than one.");
+ }
- _captureCompletedCallback = (IntPtr userData) =>
+ if (interval < 0)
{
- EventArgs eventArgs = new EventArgs();
- CaptureCompleted?.Invoke(this, eventArgs);
- };
+ throw new ArgumentOutOfRangeException(nameof(interval), interval, $"{nameof(interval)} should be greater than or equal to zero.");
+ }
- int ret = Interop.Camera.StartContinuousCapture(_handle, count, interval, _capturingCallback, _captureCompletedCallback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
+ //Handle CancellationToken
+ if (cancellationToken != CancellationToken.None)
{
- CameraErrorFactory.ThrowException(ret, "Failed to start the continuous capture.");
+ cancellationToken.Register(() =>
+ {
+ CameraErrorFactory.ThrowIfError(Interop.Camera.StopContinuousCapture(_handle),
+ "Failed to cancel the continuous capture");
+ SetState(CameraState.Captured);
+ });
}
- }
- /// <summary>
- /// Sets the display handle to show preview images.
- /// </summary>
- /// <param name="displayType">Display type.</param>
- /// <param name="preview">MediaView object to display preview.</param>
- /// <remarks>
- /// This method must be called before StartPreview() method.
- /// In Custom ROI display mode, DisplayRoiArea property must be set before calling this method.
- /// </remarks>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
- /// <exception cref="InvalidOperationException">In case of any invalid operations</exception>
- /// <exception cref="NotSupportedException">In case of this feature is not supported</exception>
- /// <exception cref="UnauthorizedAccessException">In case of access to the resources cannot be granted</exception>
- public void SetDisplay(CameraDisplayType displayType, MediaView preview)
- {
- int ret = Interop.Camera.SetDisplay(_handle, (int)displayType, preview);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to set the camera display.");
- }
+ CameraErrorFactory.ThrowIfError(Interop.Camera.StartContinuousCapture(_handle, count, interval,
+ _capturingCallback, _captureCompletedCallback, IntPtr.Zero), "Failed to start the continuous capture.");
+
+ SetState(CameraState.Capturing);
}
/// <summary>
/// <exception cref="UnauthorizedAccessException">In case of access to the resources cannot be granted</exception>
public void StartFocusing(bool continuous)
{
- int ret = Interop.Camera.StartFocusing(_handle, continuous);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to cancel the camera focus.");
- }
+ ValidateState(CameraState.Preview, CameraState.Captured);
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.StartFocusing(_handle, continuous),
+ "Failed to cancel the camera focus.");
}
/// <summary>
/// <exception cref="InvalidOperationException">In case of any invalid operations</exception>
/// <exception cref="NotSupportedException">In case of this feature is not supported</exception>
/// <exception cref="UnauthorizedAccessException">In case of access to the resources cannot be granted</exception>
- public void CancelFocusing()
+ public void StopFocusing()
{
- int ret = Interop.Camera.CancelFocusing(_handle);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to cancel the camera focus.");
- }
+ ValidateState(CameraState.Preview, CameraState.Captured);
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.CancelFocusing(_handle),
+ "Failed to cancel the camera focus.");
}
/// <summary>
/// <exception cref="UnauthorizedAccessException">In case of access to the resources cannot be granted</exception>
public void StartFaceDetection()
{
+ ValidateState(CameraState.Preview);
+
_faceDetectedCallback = (IntPtr faces, int count, IntPtr userData) =>
{
- Interop.Camera.DetectedFaceStruct[] faceStruct = new Interop.Camera.DetectedFaceStruct[count];
+ var result = new List<FaceDetectionData>();
IntPtr current = faces;
+
for (int i = 0; i < count; i++)
{
- faceStruct[i] = Marshal.PtrToStructure<Interop.Camera.DetectedFaceStruct>(current);
- FaceDetectedData face = new FaceDetectedData(faceStruct[i].id, faceStruct[i].score, faceStruct[i].x, faceStruct[i].y, faceStruct[i].width, faceStruct[i].height);
- _faces.Add(face);
- current = (IntPtr)((long)current + Marshal.SizeOf(faceStruct[i]));
+ result.Add(new FaceDetectionData(current));
+ current = IntPtr.Add(current, Marshal.SizeOf<Interop.Camera.DetectedFaceStruct>());
}
- FaceDetectedEventArgs eventArgs = new FaceDetectedEventArgs(_faces);
- FaceDetected?.Invoke(this, eventArgs);
+ FaceDetected?.Invoke(this, new FaceDetectedEventArgs(result));
};
-
- int ret = Interop.Camera.StartFaceDetection(_handle, _faceDetectedCallback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to start the face detection.");
- }
+ CameraErrorFactory.ThrowIfError(Interop.Camera.StartFaceDetection(_handle, _faceDetectedCallback, IntPtr.Zero),
+ "Failed to start face detection");
}
/// <summary>
/// <exception cref="UnauthorizedAccessException">In case of access to the resources cannot be granted</exception>
public void StopFaceDetection()
{
- int ret = Interop.Camera.StopFaceDetection(_handle);
- if (ret != (int)CameraError.None)
+ if (_faceDetectedCallback == null)
{
- CameraErrorFactory.ThrowException(ret, "Failed to stop the face detection.");
+ throw new InvalidOperationException("The face detection is not started.");
}
- }
- /// <summary>
- /// DeviceChangedCallback delegate.
- /// </summary>
- public delegate void DeviceChangedCallback(CameraDevice device, CameraDeviceState state, IntPtr userData);
+ CameraErrorFactory.ThrowIfError(Interop.Camera.StopFaceDetection(_handle),
+ "Failed to stop the face detection.");
- /// <summary>
- /// set the DeviceStateChanged Callback.
- /// </summary>
- /// <param name="callback">Callback of type <see cref="Tizen.Multimedia.Camera.DeviceChangedCallback"/>.</param>
- /// <param name="callbackId">The Id of registered callback.</param>
- /// <exception cref="InvalidOperationException">In case of any invalid operations</exception>
- /// <exception cref="NotSupportedException">In case of this feature is not supported</exception>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
- public static void SetDeviceStateChangedCallback(DeviceChangedCallback callback, out int callbackId)
- {
- int ret = Camera.AddDeviceChangedCallback(callback, IntPtr.Zero, out callbackId);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Setting device state changed callback failed");
- }
+ _faceDetectedCallback = null;
}
+#endregion Methods
- /// <summary>
- /// Unset the DeviceStateChanged Callback.
- /// </summary>
- /// <param name="callbackId">Registered callbackId to be deleted.</param>
- /// <exception cref="InvalidOperationException">In case of any invalid operations</exception>
- /// <exception cref="NotSupportedException">In case of this feature is not supported</exception>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
- public static void UnsetDeviceStateChangedCallback(int callbackId)
+#region Callback registrations
+ public void RegisterCallbacks()
{
- int ret = Interop.Camera.UnsetDeviceStateChangedCallback(callbackId);
- if (ret != (int)CameraError.None)
+ RegisterErrorCallback();
+ RegisterFocusStateChanged();
+ RegisterHdrCaptureProgress();
+ RegisterInterruptedCallback();
+ RegisterStateChangedCallback();
+
+ //Define capturing callback
+ _capturingCallback = (IntPtr image, IntPtr postview, IntPtr thumbnail, IntPtr userData) =>
{
- CameraErrorFactory.ThrowException(ret, "Unsetting device state changed callback failed");
- }
+ Capturing?.Invoke(this, new CameraCapturingEventArgs(new ImageData(image),
+ postview == IntPtr.Zero ? null : new ImageData(postview),
+ thumbnail == IntPtr.Zero ? null : new ImageData(thumbnail)));
+ };
+
+ //Define captureCompleted callback
+ _captureCompletedCallback = _ =>
+ {
+ SetState(CameraState.Captured);
+ CaptureCompleted?.Invoke(this, EventArgs.Empty);
+ };
}
- /// <summary>
- /// Release any unmanaged resources used by this object.
- /// </summary>
- public void Dispose()
+ private void RegisterInterruptedCallback()
{
- Dispose(true);
- GC.SuppressFinalize(this);
+ _interruptedCallback = (CameraPolicy policy, CameraState previous, CameraState current, IntPtr userData) =>
+ {
+ Interrupted?.Invoke(this, new CameraInterruptedEventArgs(policy, previous, current));
+ };
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetInterruptedCallback(_handle, _interruptedCallback, IntPtr.Zero),
+ "Failed to set interrupt callback");
}
- protected virtual void Dispose(bool disposing)
+ private void RegisterErrorCallback()
{
- if (!_disposed)
+ _errorCallback = (CameraErrorCode error, CameraState current, IntPtr userData) =>
{
- if (disposing)
- {
- // to be used if there are any other disposable objects
- }
-
- if (_handle != IntPtr.Zero)
- {
- Interop.Camera.Destroy(_handle);
- _handle = IntPtr.Zero;
- }
-
- _disposed = true;
- }
+ ErrorOccurred?.Invoke(this, new CameraErrorOccurredEventArgs(error, current));
+ };
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetErrorCallback(_handle, _errorCallback, IntPtr.Zero),
+ "Setting error callback failed");
}
- internal void ValidateNotDisposed()
+ private void RegisterStateChangedCallback()
{
- if (_disposed)
+ _stateChangedCallback = (CameraState previous, CameraState current, bool byPolicy, IntPtr _) =>
{
- throw new ObjectDisposedException(nameof(Camera));
- }
+ _state = current;
+ Log.Info(CameraLog.Tag, "Camera state changed " + previous.ToString() + " -> " + current.ToString());
+ StateChanged?.Invoke(this, new CameraStateChangedEventArgs(previous, current, byPolicy));
+ };
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetStateChangedCallback(_handle, _stateChangedCallback, IntPtr.Zero),
+ "Setting state changed callback failed");
}
- [DllImport(Interop.Libraries.Camera, EntryPoint = "camera_add_device_state_changed_cb")]
- internal static extern int AddDeviceChangedCallback(DeviceChangedCallback callback, IntPtr userData, out int callbackId);
-
- internal static void CopyImageData(ImageData image, Interop.Camera.ImageDataStruct img)
+ private void RegisterFocusStateChanged()
{
- image._data = new byte[img.size];
- if(img.data != IntPtr.Zero)
- Marshal.Copy(img.data, image._data, 0, (int)img.size);
- image._width = img.width;
- image._height = img.height;
- image._format = img.format;
- image._exif = new byte[img.exifSize];
- if (img.exif != IntPtr.Zero)
- Marshal.Copy(img.exif, image._exif, 0, (int)img.exifSize);
+ _focusStateChangedCallback = (CameraFocusState state, IntPtr userData) =>
+ {
+ FocusStateChanged?.Invoke(this, new CameraFocusStateChangedEventArgs(state));
+ };
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetFocusStateChangedCallback(_handle, _focusStateChangedCallback, IntPtr.Zero),
+ "Setting focus changed callback failed");
}
- internal static PreviewData CopyPreviewData(Interop.Camera.CameraPreviewDataStruct previewStruct, PlaneType type)
+ private void RegisterHdrCaptureProgress()
{
- Log.Info(CameraLog.Tag, "plane type " + type.ToString());
- if (type == PlaneType.SinglePlane)
- {
- SinglePlaneData singleData = new SinglePlaneData();
- singleData.Format = previewStruct.format;
- singleData.Height = previewStruct.height;
- singleData.TimeStamp = previewStruct.timestamp;
- singleData.Width = previewStruct.width;
- Interop.Camera.SinglePlane singlePlane = previewStruct.frameData.singlePlane;
- singleData.YUVData = new byte[singlePlane.yuvsize];
-
- if (singlePlane.yuvsize > 0)
- Marshal.Copy(singlePlane.yuv, singleData.YUVData, 0, (int)singlePlane.yuvsize);
-
- return singleData;
- }
- else if (type == PlaneType.DoublePlane)
- {
- DoublePlaneData doubleData = new DoublePlaneData();
- doubleData.Format = previewStruct.format;
- doubleData.Height = previewStruct.height;
- doubleData.TimeStamp = previewStruct.timestamp;
- doubleData.Width = previewStruct.width;
- Interop.Camera.DoublePlane doublePlane = previewStruct.frameData.doublePlane;
- doubleData.YData = new byte[doublePlane.ysize];
- doubleData.UVData = new byte[doublePlane.uvsize];
- Log.Info(CameraLog.Tag, "ysize " + doublePlane.ysize);
- Log.Info(CameraLog.Tag, "uv size " + doublePlane.uvsize);
-
- if (doublePlane.ysize > 0)
- Marshal.Copy(doublePlane.y, doubleData.YData, 0, (int)doublePlane.ysize);
-
- if (doublePlane.uvsize > 0)
- Marshal.Copy(doublePlane.uv, doubleData.UVData, 0, (int)doublePlane.uvsize);
-
- return doubleData;
- }
- else if (type == PlaneType.TriplePlane)
+ //Hdr Capture can not be supported.
+ if (Feature.IsHdrCaptureSupported)
{
- TriplePlaneData tripleData = new TriplePlaneData();
- tripleData.Format = previewStruct.format;
- tripleData.Height = previewStruct.height;
- tripleData.TimeStamp = previewStruct.timestamp;
- tripleData.Width = previewStruct.width;
- Interop.Camera.TriplePlane triplePlane = previewStruct.frameData.triplePlane;
- tripleData.YData = new byte[triplePlane.ysize];
- tripleData.UData = new byte[triplePlane.usize];
- tripleData.VData = new byte[triplePlane.vsize];
-
- if (triplePlane.ysize > 0)
- Marshal.Copy(triplePlane.y, tripleData.YData, 0, (int)triplePlane.ysize);
-
- if (triplePlane.usize > 0)
- Marshal.Copy(triplePlane.u, tripleData.UData, 0, (int)triplePlane.usize);
-
- if (triplePlane.vsize > 0)
- Marshal.Copy(triplePlane.v, tripleData.VData, 0, (int)triplePlane.vsize);
-
- return tripleData;
- }
- else
- {
- EncodedPlaneData encodedData = new EncodedPlaneData();
- encodedData.Format = previewStruct.format;
- encodedData.Height = previewStruct.height;
- encodedData.TimeStamp = previewStruct.timestamp;
- encodedData.Width = previewStruct.width;
- Interop.Camera.EncodedPlane encodedPlane = previewStruct.frameData.encodedPlane;
- encodedData.Data = new byte[encodedPlane.size];
-
- if (encodedPlane.size > 0)
- Marshal.Copy(encodedPlane.data, encodedData.Data, 0, (int)encodedPlane.size);
-
- return encodedData;
+ _hdrCaptureProgressCallback = (int percent, IntPtr userData) =>
+ {
+ HdrCaptureProgress?.Invoke(this, new HdrCaptureProgressEventArgs(percent));
+ };
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetHdrCaptureProgressCallback(_handle, _hdrCaptureProgressCallback, IntPtr.Zero),
+ "Setting Hdr capture progress callback failed");
}
}
- private void CreatePreviewCallback()
+ private void RegisterPreviewCallback()
{
- Log.Info(CameraLog.Tag, "Create preview callback.");
-
_previewCallback = (IntPtr frame, IntPtr userData) =>
{
- Interop.Camera.CameraPreviewDataStruct _previewStruct = Interop.Camera.IntPtrToCameraPreviewDataStruct(frame);
- PlaneType _type = PlaneType.SinglePlane;
- PreviewData _previewData = new PreviewData();
-
- if (_previewStruct.format == CameraPixelFormat.H264 || _previewStruct.format == CameraPixelFormat.Jpeg)
- {
- _type = PlaneType.EncodedPlane;
- _previewData = CopyPreviewData(_previewStruct, _type);
- }
- else
- {
- Log.Info(CameraLog.Tag, "Number of plane " + _previewStruct.numOfPlanes);
- if (_previewStruct.numOfPlanes == 1)
- {
- _type = PlaneType.SinglePlane;
- _previewData = CopyPreviewData(_previewStruct, _type);
- }
- else if (_previewStruct.numOfPlanes == 2)
- {
- _type = PlaneType.DoublePlane;
- _previewData = CopyPreviewData(_previewStruct, _type);
- }
- else if (_previewStruct.numOfPlanes == 3)
- {
- _type = PlaneType.TriplePlane;
- _previewData = CopyPreviewData(_previewStruct, _type);
- }
- }
-
- PreviewEventArgs eventArgs = new PreviewEventArgs(_previewData, _type);
-
- _preview?.Invoke(this, eventArgs);
+ _preview?.Invoke(this, new PreviewEventArgs(new PreviewData(frame)));
};
-
- int ret = Interop.Camera.SetPreviewCallback(_handle, _previewCallback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Setting preview callback failed");
- }
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetPreviewCallback(_handle, _previewCallback, IntPtr.Zero),
+ "Setting preview callback failed");
}
- private void CreateMediaPacketPreviewCallback()
+ private void RegisterMediaPacketPreviewCallback()
{
- _mediaPacketCallback = (IntPtr mediaPacket, IntPtr userData) =>
+ _mediaPacketPreviewCallback = (IntPtr mediaPacket, IntPtr userData) =>
{
MediaPacket packet = MediaPacket.From(mediaPacket);
+ var eventHandler = _mediaPacketPreview;
- MediaPacketPreviewEventArgs eventArgs = new MediaPacketPreviewEventArgs(packet);
- _mediaPacketPreview?.Invoke(this, eventArgs);
+ if (eventHandler != null)
+ {
+ eventHandler.Invoke(this, new MediaPacketPreviewEventArgs(packet));
+ }
+ else
+ {
+ packet.Dispose();
+ }
};
-
- int ret = Interop.Camera.SetMediaPacketPreviewCallback(_handle, _mediaPacketCallback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Setting media packet preview callback failed");
- }
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetMediaPacketPreviewCallback(_handle, _mediaPacketPreviewCallback, IntPtr.Zero),
+ "Setting media packet preview callback failed");
}
+#endregion Callback registrations
}
}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
/// <summary>
/// An extended EventArgs class which contains details about the captured image.
/// </summary>
- public class CapturingEventArgs : EventArgs
+ public class CameraCapturingEventArgs : EventArgs
{
- internal CapturingEventArgs(ImageData img, ImageData post, ImageData thumbnail)
+ internal CameraCapturingEventArgs(ImageData img, ImageData post, ImageData thumbnail)
{
Image = img;
PostView = post;
--- /dev/null
+/*
+ * 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;
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// An extended EventArgs class which contains details about previous and current state
+ /// of the camera when its state is changed.
+ /// </summary>
+ public class CameraDeviceStateChangedEventArgs : EventArgs
+ {
+ internal CameraDeviceStateChangedEventArgs(CameraDevice device, CameraDeviceState state)
+ {
+ Device = device;
+ State = state;
+ }
+
+ /// <summary>
+ /// Camera device type.
+ /// </summary>
+ public CameraDevice Device { get; }
+
+ /// <summary>
+ /// Current state of the camera device.
+ /// </summary>
+ public CameraDeviceState State { get; }
+ }
+}
+
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
/// </summary>
public class CameraDisplay
{
- internal readonly IntPtr _displayHandle;
+ internal readonly Camera _camera;
- internal CameraDisplay(IntPtr handle)
+ internal CameraDisplay(Camera camera)
{
- _displayHandle = handle;
+ _camera = camera;
+ }
+
+ /// <summary>
+ /// The display mode.
+ /// </summary>
+ public CameraDisplayMode Mode
+ {
+ get
+ {
+ CameraDisplayMode val = CameraDisplayMode.LetterBox;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.GetMode(_camera.GetHandle(), out val),
+ "Failed to get camera display mode");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.SetMode(_camera.GetHandle(), value),
+ "Failed to set camera display mode.");
+ }
+ }
+
+ /// <summary>
+ /// The display visibility.
+ /// True if camera display visible, otherwise false.
+ /// </summary>
+ public bool Visible
+ {
+ get
+ {
+ bool val = false;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.GetVisible(_camera.GetHandle(), out val),
+ "Failed to get visible value");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.SetVisible(_camera.GetHandle(), value),
+ "Failed to set display visible.");
+ }
}
/// <summary>
{
get
{
- int val = 0;
- int ret = Interop.CameraDisplay.GetDisplayRotation(_displayHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get display rotation " + (CameraError)ret);
- }
-
- return (CameraRotation)val;
+ CameraRotation val = CameraRotation.None;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.GetRotation(_camera.GetHandle(), out val),
+ "Failed to get display rotation");
+
+ return val;
}
set
{
- int ret = Interop.CameraDisplay.SetDisplayRotation(_displayHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set display rotation, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set display rotation.");
- }
+ CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.SetRotation(_camera.GetHandle(), value),
+ "Failed to set display rotation.");
}
}
{
get
{
- int val = 0;
- int ret = Interop.CameraDisplay.GetDisplayFlip(_displayHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get display flip, " + (CameraError)ret);
- }
-
- return (CameraFlip)val;
+ CameraFlip val = CameraFlip.None;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.GetFlip(_camera.GetHandle(), out val),
+ "Failed to get display flip");
+
+ return val;
}
set
{
- int ret = Interop.CameraDisplay.SetDisplayFlip(_displayHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set display flip, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set display flip.");
- }
+ CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.SetFlip(_camera.GetHandle(), value),
+ "Failed to set display flip.");
}
}
/// <summary>
- /// The display mode.
+ /// the ROI(Region Of Interest) area of display.
/// </summary>
- public CameraDisplayMode Mode
+ public Rectangle RoiArea
{
get
{
- int val = 0;
- int ret = Interop.CameraDisplay.GetDisplayMode(_displayHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera display mode, " + (CameraError)ret);
- }
-
- return (CameraDisplayMode)val;
+ int x = 0;
+ int y = 0;
+ int width = 0;
+ int height = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.GetRoiArea(_camera.GetHandle(), out x, out y, out width, out height),
+ "Failed to get display roi area");
+
+ return new Rectangle(x, y, width, height);
}
set
{
- int ret = Interop.CameraDisplay.SetDisplayMode(_displayHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera display mode, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera display mode.");
- }
+ CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.SetRoiArea(_camera.GetHandle(),
+ value.X, value.Y, value.Width, value.Height), "Failed to set display roi area.");
}
}
/// <summary>
- /// The display visibility.
- /// True if camera display visible, otherwise false.
+ /// Sets the display type and handle to show preview images.
/// </summary>
- public bool Visible
+ /// <param name="displayType">Display type.</param>
+ /// <param name="preview">MediaView object to display preview.</param>
+ /// <remarks>
+ /// This method must be called before StartPreview() method.
+ /// In Custom ROI display mode, DisplayRoiArea property must be set before calling this method.
+ /// </remarks>
+ /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ /// <exception cref="InvalidOperationException">In case of any invalid operations</exception>
+ /// <exception cref="NotSupportedException">In case of this feature is not supported</exception>
+ /// <exception cref="UnauthorizedAccessException">In case of access to the resources cannot be granted</exception>
+ public void SetInfo(CameraDisplayType displayType, MediaView displayHandle)
{
- get
- {
- bool val = false;
- int ret = Interop.CameraDisplay.GetDisplayVisible(_displayHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get visible value, " + (CameraError)ret);
- }
+ _camera.ValidateState(CameraState.Created);
- return val;
- }
+ ValidationUtil.ValidateEnum(typeof(CameraDisplayType), displayType);
- set
- {
- int ret = Interop.CameraDisplay.SetDisplayVisible(_displayHandle, (bool)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set display visible, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set display visible.");
- }
- }
+ CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.SetInfo(_camera.GetHandle(), displayType, displayHandle),
+ "Failed to set the camera display.");
}
}
}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
/// <summary>
/// Not opened.
/// </summary>
- Null,
+ NotOpened,
/// <summary>
/// Opened.
/// </summary>
/// <summary>
/// Rear direction.
/// </summary>
- RearDirection,
+ Rear,
/// <summary>
/// Front direction
/// </summary>
- FrontDirection
+ Front
}
/// <summary>
/// <summary>
/// Security policy
/// </summary>
- Security,
+ Security = 4,
/// <summary>
/// Resource conflict
/// </summary>
/// </summary>
Disable,
/// <summary>
- /// Enable theater mode - Preview image is displayed on external display with full screen mode, but preview image is not shown on device display.
+ /// Clone mode - Preview image is displayed on external display with full screen mode. Also preview image is shown by the UI on device display.
/// </summary>
- Enable,
+ Clone,
/// <summary>
- /// Clone mode - Preview image is displayed on external display with full screen mode. Also preview image is shown by the UI on device display.
+ /// Enable theater mode - Preview image is displayed on external display with full screen mode, but preview image is not shown on device display.
/// </summary>
- Clone
+ Enable
}
/// <summary>
///Enumeration for the white balance levels of the camera.
/// </summary>
- public enum CameraWhitebalance
+ public enum CameraWhiteBalance
{
/// <summary>
/// None.
/// <summary>
/// Device Error.
/// </summary>
- DeviceError = CameraError.ErrorDevice,
+ DeviceError = CameraError.DeviceError,
/// <summary>
/// Internal error.
/// </summary>
/// <summary>
/// Out of memory.
/// </summary>
- OutOfMemory = CameraError.OutOfMemory
+ OutOfMemory = CameraError.OutOfMemory,
+ /// <summary>
+ /// Service is disconnected.
+ /// </summary>
+ ServiceDisconnected = CameraError.ServiceDisconnected
}
/// <summary>
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
{
internal enum CameraError
{
- None = ErrorCode.None,
- InvalidParameter = ErrorCode.InvalidParameter,
TizenErrorCamera = -0x01910000,
CameraErrorClass = TizenErrorCamera,
+ None = ErrorCode.None,
+ InvalidParameter = ErrorCode.InvalidParameter,
InvalidState = CameraErrorClass | 0x02,
OutOfMemory = ErrorCode.OutOfMemory,
- ErrorDevice = CameraErrorClass | 0x04,
+ DeviceError = CameraErrorClass | 0x04,
InvalidOperation = ErrorCode.InvalidOperation,
- SoundPolicy = CameraErrorClass | 0x06,
SecurityRestricted = CameraErrorClass | 0x07,
DeviceBusy = CameraErrorClass | 0x08,
DeviceNotFound = CameraErrorClass | 0x09,
- SoundPolicyByCall = CameraErrorClass | 0x0a,
- SoundPolicyByAlarm = CameraErrorClass | 0x0b,
Esd = CameraErrorClass | 0x0c,
PermissionDenied = ErrorCode.PermissionDenied,
NotSupported = ErrorCode.NotSupported,
internal static class CameraErrorFactory
{
- internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null)
+ internal static void ThrowIfError(int errorCode, string errorMessage = null)
{
CameraError err = (CameraError)errorCode;
- if (string.IsNullOrEmpty(errorMessage))
+ if (err == CameraError.None)
{
- errorMessage = err.ToString();
+ return;
}
- switch ((CameraError)errorCode)
+ Log.Info(CameraLog.Tag, "errorCode : " + err.ToString());
+
+ switch (err)
{
case CameraError.InvalidParameter:
- throw new ArgumentException(errorMessage, paramName);
+ throw new ArgumentException(errorMessage);
case CameraError.OutOfMemory:
throw new OutOfMemoryException(errorMessage);
- case CameraError.ErrorDevice:
+ case CameraError.DeviceError:
case CameraError.DeviceBusy:
+ case CameraError.Esd:
+ throw new CameraDeviceException(errorMessage);
+
case CameraError.DeviceNotFound:
- case CameraError.SoundPolicy:
+ throw new CameraDeviceNotFoundException(errorMessage);
+
case CameraError.SecurityRestricted:
- case CameraError.SoundPolicyByCall:
- case CameraError.SoundPolicyByAlarm:
- case CameraError.Esd:
case CameraError.PermissionDenied:
throw new UnauthorizedAccessException(errorMessage);
case CameraError.InvalidState:
case CameraError.InvalidOperation:
- case CameraError.ResourceConflict:
+ case CameraError.ResourceConflict:
case CameraError.ServiceDisconnected:
throw new InvalidOperationException(errorMessage);
+
+ default:
+ throw new Exception("Unknown error : " + errorCode);
}
}
}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
--- /dev/null
+/*
+ * 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;
+
+namespace Tizen.Multimedia
+{
+ public class CameraException : Exception
+ {
+ public CameraException() : base()
+ {
+ }
+
+ public CameraException(string message) : base(message)
+ {
+ }
+ }
+
+ public class CameraDeviceException : CameraException
+ {
+ public CameraDeviceException() : base()
+ {
+ }
+
+ public CameraDeviceException(string message) : base(message)
+ {
+ }
+ }
+
+ public class CameraDeviceNotFoundException : CameraException
+ {
+ public CameraDeviceNotFoundException() : base()
+ {
+ }
+
+ public CameraDeviceNotFoundException(string message) : base(message)
+ {
+ }
+ }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * 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.Collections.Generic;
-using Tizen.Internals.Errors;
-using System.Xml.Schema;
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// The CameraFeature class provides properties
- /// to get various capability information of the camera device.
- /// </summary>
- public class CameraFeature
- {
- internal readonly IntPtr _cameraHandle;
- private readonly List<CameraResolution> _previewResolution;
- private readonly List<CameraResolution> _cameraResolution;
- private readonly List<CameraPixelFormat> _captureFormat;
- private readonly List<CameraPixelFormat> _previewFormat;
- private readonly List<CameraFps> _fps;
- private readonly List<CameraFps> _fpsResolution;
- private readonly List<CameraAutoFocusMode> _afMode;
- private readonly List<CameraExposureMode> _exposureMode;
- private readonly List<CameraTheaterMode> _theater;
- private readonly List<CameraWhitebalance> _whitebalance;
- private readonly List<CameraIsoLevel> _iso;
- private readonly List<CameraEffectMode> _effect;
- private readonly List<CameraSceneMode> _sceneMode;
- private readonly List<CameraFlashMode> _flashMode;
- private readonly List<CameraRotation> _streamRotation;
- private readonly List<CameraFlip> _streamFlip;
- private readonly List<CameraPtzType> _ptzType;
-
- internal CameraFeature(IntPtr _handle)
- {
- _cameraHandle = _handle;
- _previewResolution = new List<CameraResolution>();
- _cameraResolution = new List<CameraResolution>();
- _captureFormat = new List<CameraPixelFormat>();
- _previewFormat = new List<CameraPixelFormat>();
- _fps = new List<CameraFps>();
- _fpsResolution = new List<CameraFps>();
- _afMode = new List<CameraAutoFocusMode>();
- _exposureMode = new List<CameraExposureMode>();
- _theater = new List<CameraTheaterMode>();
- _whitebalance = new List<CameraWhitebalance>();
- _iso = new List<CameraIsoLevel>();
- _effect = new List<CameraEffectMode>();
- _sceneMode = new List<CameraSceneMode>();
- _flashMode = new List<CameraFlashMode>();
- _streamRotation = new List<CameraRotation>();
- _streamFlip = new List<CameraFlip>();
- _ptzType = new List<CameraPtzType>();
- }
-
- /// <summary>
- /// Gets continuous capture feature's supported state.
- /// true if supported, otherwise false.
- /// </summary>
- public bool ContinuousCaptureSupport
- {
- get
- {
- bool val = false;
-
- val = Interop.CameraFeature.ContinuousCaptureSupport(_cameraHandle);
- int ret = ErrorFacts.GetLastResult();
- if ((CameraError)ret != CameraError.None)
- {
- CameraError err = (CameraError)ret;
- Log.Error(CameraLog.Tag, "Failed to get continuous feature support, " + err.ToString());
- }
-
- return val;
- }
- }
-
- /// <summary>
- /// Gets the face detection feature's supported state.
- /// true if supported, otherwise false.
- /// </summary>
- public bool FaceDetectionSupport
- {
- get
- {
- bool val = false;
-
- val = Interop.CameraFeature.FaceDetectionSupport(_cameraHandle);
- int ret = ErrorFacts.GetLastResult();
- if ((CameraError)ret != CameraError.None)
- {
- CameraError err = (CameraError)ret;
- Log.Error(CameraLog.Tag, "Failed to get face detection support, " + err.ToString());
- }
-
- return val;
- }
- }
-
- /// <summary>
- /// Gets the zero shutter lag feature's supported state.
- /// true if supported, otherwise false.
- /// </summary>
- public bool ZeroShutterLagSupport
- {
- get
- {
- bool val = false;
-
- val = Interop.CameraFeature.ZeroShutterLagSupport(_cameraHandle);
- int ret = ErrorFacts.GetLastResult();
- if ((CameraError)ret != CameraError.None)
- {
- CameraError err = (CameraError)ret;
- Log.Error(CameraLog.Tag, "Failed to get zero shutter lag support, " + err.ToString());
- }
-
- return val;
- }
- }
-
- /// <summary>
- /// Gets the media packet preview callback feature's supported state.
- /// true if supported, otherwise false.
- /// </summary>
- public bool MediaPacketPreviewCallbackSupport
- {
- get
- {
- bool val = false;
-
- val = Interop.CameraFeature.MediaPacketPreviewCallbackSupport(_cameraHandle);
- int ret = ErrorFacts.GetLastResult();
- if ((CameraError)ret != CameraError.None)
- {
- CameraError err = (CameraError)ret;
- Log.Error(CameraLog.Tag, "Failed to get media packet preview callback support, " + err.ToString());
- }
-
- return val;
- }
- }
-
- /// <summary>
- /// Gets the support state of HDR capture.
- /// true if supported, otherwise false.
- /// </summary>
- public bool HdrCaptureSupport
- {
- get
- {
- bool val = false;
-
- val = Interop.CameraFeature.HdrCaptureSupport(_cameraHandle);
- int ret = ErrorFacts.GetLastResult();
- if ((CameraError)ret != CameraError.None)
- {
- CameraError err = (CameraError)ret;
- Log.Error(CameraLog.Tag, "Failed to get hdr capture feature support, " + err.ToString());
- }
-
- return val;
- }
- }
-
- /// <summary>
- /// Gets the support state of the anti-shake feature.
- /// true if supported, otherwise false.
- /// </summary>
- public bool AntiShakeSupport
- {
- get
- {
- bool val = false;
-
- val = Interop.CameraFeature.AntiShakeSupport(_cameraHandle);
- int ret = ErrorFacts.GetLastResult();
- if ((CameraError)ret != CameraError.None)
- {
- CameraError err = (CameraError)ret;
- Log.Error(CameraLog.Tag, "Failed to get anti shake feature support, " + err.ToString());
- }
-
- return val;
- }
- }
-
- /// <summary>
- /// Gets the support state of the video stabilization feature.
- /// true if supported, otherwise false.
- /// </summary>
- public bool VideoStabilizationSupport
- {
- get
- {
- bool val = false;
-
- val = Interop.CameraFeature.VideoStabilizationSupport(_cameraHandle);
- int ret = ErrorFacts.GetLastResult();
- if ((CameraError)ret != CameraError.None)
- {
- CameraError err = (CameraError)ret;
- Log.Error(CameraLog.Tag, "Failed to get video stabilization feature support, " + err.ToString());
- }
-
- return val;
- }
- }
-
- /// <summary>
- /// Gets state of support of auto contrast feature.
- /// true if supported, otherwise false.
- /// </summary>
- public bool AutoContrastSupport
- {
- get
- {
- bool val = false;
-
- val = Interop.CameraFeature.AutoContrastSupport(_cameraHandle);
- int ret = ErrorFacts.GetLastResult();
- if ((CameraError)ret != CameraError.None)
- {
- CameraError err = (CameraError)ret;
- Log.Error(CameraLog.Tag, "Failed to get auto contrast feature support, " + err.ToString());
- }
-
- return val;
- }
- }
-
- /// <summary>
- /// Retrieves all the preview resolutions supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported preview resolutions.
- /// by recorder.
- /// </returns>
- public IEnumerable<CameraResolution> PreviewResolutions
- {
- get
- {
- if (_previewResolution.Count == 0)
- {
- Interop.CameraFeature.PreviewResolutionCallback callback = (int width, int height, IntPtr userData) =>
- {
- CameraResolution temp = new CameraResolution(width, height);
- _previewResolution.Add(temp);
- return true;
- };
-
- int ret = Interop.CameraFeature.SupportedPreviewResolutions(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported preview resolutions");
- }
- }
-
- return _previewResolution;
- }
- }
-
- /// <summary>
- /// Retrieves all the capture resolutions supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported capture resolutions.
- /// </returns>
- public IEnumerable<CameraResolution> CaptureResolutions
- {
- get
- {
- if (_cameraResolution.Count == 0)
- {
- Interop.CameraFeature.CaptureResolutionCallback callback = (int width, int height, IntPtr userData) =>
- {
- CameraResolution temp = new CameraResolution(width, height);
- _cameraResolution.Add(temp);
- return true;
- };
-
- int ret = Interop.CameraFeature.SupportedCaptureResolutions(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported capture resolutions");
- }
- }
-
- return _cameraResolution;
- }
- }
-
- /// <summary>
- /// Retrieves all the capture formats supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported capture formats.
- /// </returns>
- public IEnumerable<CameraPixelFormat> CaptureFormats
- {
- get
- {
- if (_captureFormat.Count == 0)
- {
- Interop.CameraFeature.CaptureFormatCallback callback = (CameraPixelFormat format, IntPtr userData) =>
- {
- _captureFormat.Add(format);
- return true;
- };
-
- int ret = Interop.CameraFeature.SupportedCaptureFormats(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported capture formats.");
- }
- }
-
- return _captureFormat;
- }
- }
-
- /// <summary>
- /// Retrieves all the preview formats supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported preview formats.
- /// </returns>
- public IEnumerable<CameraPixelFormat> PreviewFormats
- {
- get
- {
- if (_previewFormat.Count == 0)
- {
- Interop.CameraFeature.PreviewFormatCallback callback = (CameraPixelFormat format, IntPtr userData) =>
- {
- _previewFormat.Add(format);
- return true;
- };
-
- int ret = Interop.CameraFeature.SupportedPreviewFormats(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported preview formats.");
- }
- }
-
- return _previewFormat;
- }
- }
-
- /// <summary>
- /// Retrieves all the fps supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported fps.
- /// </returns>
- public IEnumerable<CameraFps> Fps
- {
- get
- {
- if (_fps.Count == 0)
- {
- Interop.CameraFeature.FpsCallback callback = (CameraFps fps, IntPtr userData) =>
- {
- _fps.Add(fps);
- return true;
- };
-
- int ret = Interop.CameraFeature.SupportedFps(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported camera fps");
- }
- }
-
- return _fps;
- }
- }
-
- private bool resolutionCallback(CameraFps fps, IntPtr userData)
- {
- _fpsResolution.Add(fps);
- return true;
- }
-
- /// <summary>
- /// Retrieves all the fps by resolution supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported fps by resolution.
- /// </returns>
- public IEnumerable<CameraFps> FpsByResolution(int width, int height)
- {
- if (_fpsResolution.Count == 0)
- {
- int ret = Interop.CameraFeature.SupportedFpsByResolution(_cameraHandle, width, height, resolutionCallback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported fps by resolutions.");
- }
- }
-
- return _fpsResolution;
- }
-
- /// <summary>
- /// Retrieves all the fps by resolution supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported fps by resolution.
- /// </returns>
- public IEnumerable<CameraAutoFocusMode> AfMode
- {
- get
- {
- if (_afMode.Count == 0)
- {
- Interop.CameraFeature.AfModeCallback callback = (CameraAutoFocusMode mode, IntPtr userData) =>
- {
- _afMode.Add(mode);
- return true;
- };
-
- int ret = Interop.CameraFeature.SupportedAfModes(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported Auto focus modes.");
- }
- }
-
- return _afMode;
- }
- }
-
- /// <summary>
- /// Retrieves all the exposure modes supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported camera exposure modes.
- /// </returns>
- public IEnumerable<CameraExposureMode> ExposureModes
- {
- get
- {
- if (_exposureMode.Count == 0)
- {
- Interop.CameraFeature.ExposureModeCallback callback = (CameraExposureMode mode, IntPtr userData) =>
- {
- _exposureMode.Add(mode);
- return true;
- };
-
- int ret = Interop.CameraFeature.SupportedExposureModes(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported Exposure modes.");
- }
- }
-
- return _exposureMode;
- }
- }
-
- /// <summary>
- /// Retrieves all the Iso level supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported camera Iso levels.
- /// </returns>
- public IEnumerable<CameraIsoLevel> IsoLevel
- {
- get
- {
- if (_iso.Count == 0)
- {
- Interop.CameraFeature.IsoCallback callback = (CameraIsoLevel iso, IntPtr userData) =>
- {
- _iso.Add(iso);
- return true;
- };
-
- int ret = Interop.CameraFeature.SupportedIso(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported Iso levels.");
- }
- }
-
- return _iso;
- }
- }
-
- /// <summary>
- /// Retrieves all the theater modes supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported camera theater modes.
- /// </returns>
- public IEnumerable<CameraTheaterMode> TheaterMode
- {
- get
- {
- if (_theater.Count == 0)
- {
- Interop.CameraFeature.TheaterModeCallback callback = (CameraTheaterMode theaterMode, IntPtr userData) =>
- {
- _theater.Add(theaterMode);
- return true;
- };
-
- int ret = Interop.CameraFeature.SupportedTheaterModes(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported theater modes.");
- }
- }
-
- return _theater;
- }
- }
-
- /// <summary>
- /// Retrieves all the whitebalance mode supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported camera white balance modes.
- /// </returns>
- public IEnumerable<CameraWhitebalance> Whitebalance
- {
- get
- {
- if (_whitebalance.Count == 0)
- {
- Interop.CameraFeature.WhitebalanceCallback callback = (CameraWhitebalance whitebalance, IntPtr userData) =>
- {
- _whitebalance.Add(whitebalance);
- return true;
- };
- int ret = Interop.CameraFeature.SupportedWhitebalance(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported white balance.");
- }
- }
-
- return _whitebalance;
- }
- }
-
- /// <summary>
- /// Retrieves all the flash modes supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported camera flash modes.
- /// </returns>
- public IEnumerable<CameraFlashMode> FlashMode
- {
- get
- {
- if (_flashMode.Count == 0)
- {
- Interop.CameraFeature.FlashModeCallback callback = (CameraFlashMode flashMode, IntPtr userData) =>
- {
- _flashMode.Add(flashMode);
- return true;
- };
- int ret = Interop.CameraFeature.SupportedFlashModes(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported flash modes.");
- }
- }
-
- return _flashMode;
- }
- }
-
- /// <summary>
- /// Retrieves all the scene modes supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported camera scene modes.
- /// </returns>
- public IEnumerable<CameraSceneMode> SceneMode
- {
- get
- {
- if (_sceneMode.Count == 0)
- {
- Interop.CameraFeature.SceneModeCallback callback = (CameraSceneMode sceneMode, IntPtr userData) =>
- {
- _sceneMode.Add(sceneMode);
- return true;
- };
- int ret = Interop.CameraFeature.SupportedSceneModes(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported scene modes.");
- }
- }
-
- return _sceneMode;
- }
- }
-
- /// <summary>
- /// Retrieves all the effects supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported camera effects.
- /// </returns>
- public IEnumerable<CameraEffectMode> Effect
- {
- get
- {
- if (_effect.Count == 0)
- {
- Interop.CameraFeature.EffectCallback callback = (CameraEffectMode effect, IntPtr userData) =>
- {
- _effect.Add(effect);
- return true;
- };
- int ret = Interop.CameraFeature.SupportedEffects(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported camera effects.");
- }
- }
-
- return _effect;
- }
- }
-
- /// <summary>
- /// Retrieves all the stream rotation supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported camera stream rotations.
- /// </returns>
- public IEnumerable<CameraRotation> StreamRotation
- {
- get
- {
- if (_streamRotation.Count == 0)
- {
- Interop.CameraFeature.StreamRotationCallback callback = (CameraRotation streamRotation, IntPtr userData) =>
- {
- _streamRotation.Add(streamRotation);
- return true;
- };
- int ret = Interop.CameraFeature.SupportedStreamRotations(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported camera rotations.");
- }
- }
-
- return _streamRotation;
- }
- }
-
- /// <summary>
- /// Retrieves all the flips supported by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported camera flip.
- /// </returns>
- public IEnumerable<CameraFlip> StreamFlip
- {
- get
- {
- if (_streamFlip.Count == 0)
- {
- Interop.CameraFeature.StreamFlipCallback callback = (CameraFlip streamFlip, IntPtr userData) =>
- {
- _streamFlip.Add(streamFlip);
- return true;
- };
- int ret = Interop.CameraFeature.SupportedStreamFlips(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported camera flips.");
- }
- }
-
- return _streamFlip;
- }
- }
-
- /// <summary>
- /// Retrieves all the ptz types by the camera.
- /// </summary>
- /// <returns>
- /// It returns a list containing all the supported ptz types.
- /// </returns>
- public IEnumerable<CameraPtzType> PtzType
- {
- get
- {
- if (_ptzType.Count == 0)
- {
- Interop.CameraFeature.PtzTypeCallback callback = (CameraPtzType ptzType, IntPtr userData) =>
- {
- _ptzType.Add(ptzType);
- return true;
- };
- int ret = Interop.CameraFeature.SupportedPtzTypes(_cameraHandle, callback, IntPtr.Zero);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the supported Ptz types.");
- }
- }
-
- return _ptzType;
- }
- }
- }
-}
--- /dev/null
+/*
+ * 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.Collections.Generic;
+using Tizen.Internals.Errors;
+
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// The CameraFeatures class provides properties
+ /// to get various capability information of the camera device.
+ /// </summary>
+ public class CameraFeatures
+ {
+ internal readonly Camera _camera;
+
+ private List<Size> _previewResolutions;
+ private List<Size> _cameraResolutions;
+ private List<CameraPixelFormat> _captureFormats;
+ private List<CameraPixelFormat> _previewFormats;
+ private List<CameraFps> _fps;
+ private List<CameraAutoFocusMode> _autoFocusModes;
+ private List<CameraExposureMode> _exposureModes;
+ private List<CameraIsoLevel> _isoLevels;
+ private List<CameraTheaterMode> _theaterModes;
+ private List<CameraWhiteBalance> _whitebalances;
+ private List<CameraFlashMode> _flashModes;
+ private List<CameraSceneMode> _sceneModes;
+ private List<CameraEffectMode> _effectModes;
+ private List<CameraRotation> _streamRotations;
+ private List<CameraFlip> _streamFlips;
+ private List<CameraPtzType> _ptzTypes;
+
+ private delegate int GetRangeDelegate(IntPtr handle, out int min, out int max);
+ private delegate bool IsSupportedDelegate(IntPtr handle);
+
+ internal CameraFeatures(Camera camera)
+ {
+ _camera = camera;
+
+ IsFaceDetectionSupported = IsFeatureSupported(Interop.CameraFeatures.IsFaceDetectionSupported);
+ IsMediaPacketPreviewCallbackSupported = IsFeatureSupported(Interop.CameraFeatures.IsMediaPacketPreviewCallbackSupported);
+ IsZeroShutterLagSupported = IsFeatureSupported(Interop.CameraFeatures.IsZeroShutterLagSupported);
+ IsContinuousCaptureSupported = IsFeatureSupported(Interop.CameraFeatures.IsContinuousCaptureSupported);
+ IsHdrCaptureSupported = IsFeatureSupported(Interop.CameraFeatures.IsHdrCaptureSupported);
+ IsAntiShakeSupported = IsFeatureSupported(Interop.CameraFeatures.IsAntiShakeSupported);
+ IsVideoStabilizationSupported = IsFeatureSupported(Interop.CameraFeatures.IsVideoStabilizationSupported);
+ IsAutoContrastSupported = IsFeatureSupported(Interop.CameraFeatures.IsAutoContrastSupported);
+ IsBrigtnessSupported = CheckRangeValid(Interop.CameraSettings.GetBrightnessRange);
+ IsExposureSupported = CheckRangeValid(Interop.CameraSettings.GetExposureRange);
+ IsZoomSupported = CheckRangeValid(Interop.CameraSettings.GetZoomRange);
+ IsPanSupported = CheckRangeValid(Interop.CameraSettings.GetPanRange);
+ IsTiltSupported = CheckRangeValid(Interop.CameraSettings.GetTiltRange);
+ }
+
+ private bool IsFeatureSupported(IsSupportedDelegate func)
+ {
+ bool ret = func(_camera.GetHandle());
+
+ CameraErrorFactory.ThrowIfError(ErrorFacts.GetLastResult(), "Failed to check feature is suported or not.");
+
+ return ret;
+ }
+
+ private bool CheckRangeValid(GetRangeDelegate func)
+ {
+ int min = 0;
+ int max = 0;
+
+ CameraErrorFactory.ThrowIfError(func(_camera.GetHandle(), out min, out max), "Failed to check feature is suported or not.");
+
+ return min < max;
+ }
+
+ /// <summary>
+ /// Gets the face detection feature's supported state.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsFaceDetectionSupported { get; }
+
+ /// <summary>
+ /// Gets the media packet preview callback feature's supported state.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsMediaPacketPreviewCallbackSupported { get; }
+
+ /// <summary>
+ /// Gets the zero shutter lag feature's supported state.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsZeroShutterLagSupported { get; }
+
+ /// <summary>
+ /// Gets continuous capture feature's supported state.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsContinuousCaptureSupported { get; }
+
+ /// <summary>
+ /// Gets the support state of HDR capture.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsHdrCaptureSupported { get; }
+
+ /// <summary>
+ /// Gets the support state of the anti-shake feature.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsAntiShakeSupported { get; }
+
+ /// <summary>
+ /// Gets the support state of the video stabilization feature.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsVideoStabilizationSupported { get; }
+
+ /// <summary>
+ /// Gets the support state of auto contrast feature.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsAutoContrastSupported { get; }
+
+ /// <summary>
+ /// Gets the support state of brightness feature.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsBrigtnessSupported { get; }
+
+ /// <summary>
+ /// Gets the support state of exposure feature.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsExposureSupported { get; }
+
+ /// <summary>
+ /// Gets the support state of zoom feature.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsZoomSupported { get; }
+
+ /// <summary>
+ /// Gets the support state of pan feature.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsPanSupported { get; }
+
+ /// <summary>
+ /// Gets the support state of tilt feature.
+ /// true if supported, otherwise false.
+ /// </summary>
+ public bool IsTiltSupported { get; }
+
+ /// <summary>
+ /// Retrieves all the preview resolutions supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported preview resolutions.
+ /// by recorder.
+ /// </returns>
+ public IEnumerable<Size> SupportedPreviewResolutions
+ {
+ get
+ {
+ if (_previewResolutions == null)
+ {
+ _previewResolutions = new List<Size>();
+
+ Interop.CameraFeatures.PreviewResolutionCallback callback = (int width, int height, IntPtr userData) =>
+ {
+ _previewResolutions.Add(new Size(width, height));
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedPreviewResolutions(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported preview resolutions");
+ }
+
+ return _previewResolutions;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the capture resolutions supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported capture resolutions.
+ /// </returns>
+ public IEnumerable<Size> SupportedCaptureResolutions
+ {
+ get
+ {
+ if (_cameraResolutions == null)
+ {
+ _cameraResolutions = new List<Size>();
+
+ Interop.CameraFeatures.CaptureResolutionCallback callback = (int width, int height, IntPtr userData) =>
+ {
+ _cameraResolutions.Add(new Size(width, height));
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedCaptureResolutions(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported capture resolutions");
+ }
+
+ return _cameraResolutions;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the capture formats supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported capture formats.
+ /// </returns>
+ public IEnumerable<CameraPixelFormat> SupportedCapturePixelFormats
+ {
+ get
+ {
+ if (_captureFormats == null)
+ {
+ _captureFormats = new List<CameraPixelFormat>();
+
+ Interop.CameraFeatures.CaptureFormatCallback callback = (CameraPixelFormat format, IntPtr userData) =>
+ {
+ _captureFormats.Add(format);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedCapturePixelFormats(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported capture formats.");
+ }
+
+ return _captureFormats;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the preview formats supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported preview formats.
+ /// </returns>
+ public IEnumerable<CameraPixelFormat> SupportedPreviewPixelFormats
+ {
+ get
+ {
+ if (_previewFormats == null)
+ {
+ _previewFormats = new List<CameraPixelFormat>();
+
+ Interop.CameraFeatures.PreviewFormatCallback callback = (CameraPixelFormat format, IntPtr userData) =>
+ {
+ _previewFormats.Add(format);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedPreviewPixelFormats(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported preview formats.");
+ }
+
+ return _previewFormats;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the fps supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported fps.
+ /// </returns>
+ public IEnumerable<CameraFps> SupportedPreviewFps
+ {
+ get
+ {
+ if (_fps == null)
+ {
+ _fps = new List<CameraFps>();
+
+ Interop.CameraFeatures.FpsCallback callback = (CameraFps fps, IntPtr userData) =>
+ {
+ _fps.Add(fps);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedPreviewFps(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported camera fps");
+ }
+
+ return _fps;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the fps by resolution supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported fps by resolution.
+ /// </returns>
+ public IEnumerable<CameraFps> GetSupportedPreviewFpsByResolution(int width, int height)
+ {
+ var result = new List<CameraFps>();
+
+ Interop.CameraFeatures.FpsByResolutionCallback callback = (CameraFps fps, IntPtr userData) =>
+ {
+ result.Add(fps);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedPreviewFpsByResolution(_camera.GetHandle(),
+ width, height, callback, IntPtr.Zero), "Failed to get the supported fps by resolutions.");
+
+ return result;
+ }
+
+ /// <summary>
+ /// Retrieves all the fps by resolution supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported fps by resolution.
+ /// </returns>
+ public IEnumerable<CameraFps> GetSupportedPreviewFpsByResolution(Size size)
+ {
+ return GetSupportedPreviewFpsByResolution(size.Width, size.Height);
+ }
+
+ /// <summary>
+ /// Retrieves all the fps by resolution supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported fps by resolution.
+ /// </returns>
+ public IEnumerable<CameraAutoFocusMode> SupportedAutoFocusModes
+ {
+ get
+ {
+ if (_autoFocusModes == null)
+ {
+ _autoFocusModes = new List<CameraAutoFocusMode>();
+
+ Interop.CameraFeatures.AfModeCallback callback = (CameraAutoFocusMode mode, IntPtr userData) =>
+ {
+ _autoFocusModes.Add(mode);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedAfModes(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported Auto focus modes.");
+ }
+
+ return _autoFocusModes;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the exposure modes supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported camera exposure modes.
+ /// </returns>
+ public IEnumerable<CameraExposureMode> SupportedExposureModes
+ {
+ get
+ {
+ if (_exposureModes == null)
+ {
+ _exposureModes = new List<CameraExposureMode>();
+
+ Interop.CameraFeatures.ExposureModeCallback callback = (CameraExposureMode mode, IntPtr userData) =>
+ {
+ _exposureModes.Add(mode);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedExposureModes(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported Exposure modes.");
+ }
+
+ return _exposureModes;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the Iso level supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported camera Iso levels.
+ /// </returns>
+ public IEnumerable<CameraIsoLevel> SupportedIsoLevels
+ {
+ get
+ {
+ if (_isoLevels == null)
+ {
+ _isoLevels = new List<CameraIsoLevel>();
+
+ Interop.CameraFeatures.IsoCallback callback = (CameraIsoLevel iso, IntPtr userData) =>
+ {
+ _isoLevels.Add(iso);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedIso(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported Iso levels.");
+ }
+
+ return _isoLevels;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the theater modes supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported camera theater modes.
+ /// </returns>
+ public IEnumerable<CameraTheaterMode> SupportedTheaterModes
+ {
+ get
+ {
+ if (_theaterModes == null)
+ {
+ _theaterModes = new List<CameraTheaterMode>();
+
+ Interop.CameraFeatures.TheaterModeCallback callback = (CameraTheaterMode theaterMode, IntPtr userData) =>
+ {
+ _theaterModes.Add(theaterMode);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedTheaterModes(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported theater modes.");
+ }
+
+ return _theaterModes;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the whitebalance mode supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported camera white balance modes.
+ /// </returns>
+ public IEnumerable<CameraWhiteBalance> SupportedWhiteBalances
+ {
+ get
+ {
+ if (_whitebalances == null)
+ {
+ _whitebalances = new List<CameraWhiteBalance>();
+
+ Interop.CameraFeatures.WhitebalanceCallback callback = (CameraWhiteBalance whiteBalance, IntPtr userData) =>
+ {
+ _whitebalances.Add(whiteBalance);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedWhitebalance(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported white balance.");
+ }
+
+ return _whitebalances;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the flash modes supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported camera flash modes.
+ /// </returns>
+ public IEnumerable<CameraFlashMode> SupportedFlashModes
+ {
+ get
+ {
+ if (_flashModes == null)
+ {
+ _flashModes = new List<CameraFlashMode>();
+
+ Interop.CameraFeatures.FlashModeCallback callback = (CameraFlashMode flashMode, IntPtr userData) =>
+ {
+ _flashModes.Add(flashMode);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedFlashModes(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported flash modes.");
+ }
+
+ return _flashModes;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the scene modes supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported camera scene modes.
+ /// </returns>
+ public IEnumerable<CameraSceneMode> SupportedSceneModes
+ {
+ get
+ {
+ if (_sceneModes == null)
+ {
+ _sceneModes = new List<CameraSceneMode>();
+
+ Interop.CameraFeatures.SceneModeCallback callback = (CameraSceneMode sceneMode, IntPtr userData) =>
+ {
+ _sceneModes.Add(sceneMode);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedSceneModes(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported scene modes.");
+ }
+
+ return _sceneModes;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the effects supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported camera effects.
+ /// </returns>
+ public IEnumerable<CameraEffectMode> SupportedEffects
+ {
+ get
+ {
+ if (_effectModes == null)
+ {
+ _effectModes = new List<CameraEffectMode>();
+
+ Interop.CameraFeatures.EffectCallback callback = (CameraEffectMode effect, IntPtr userData) =>
+ {
+ _effectModes.Add(effect);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedEffects(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported camera effects.");
+ }
+
+ return _effectModes;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the stream rotation supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported camera stream rotations.
+ /// </returns>
+ public IEnumerable<CameraRotation> SupportedStreamRotations
+ {
+ get
+ {
+ if (_streamRotations == null)
+ {
+ _streamRotations = new List<CameraRotation>();
+
+ Interop.CameraFeatures.StreamRotationCallback callback = (CameraRotation streamRotation, IntPtr userData) =>
+ {
+ _streamRotations.Add(streamRotation);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedStreamRotations(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported camera rotations.");
+ }
+
+ return _streamRotations;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the flips supported by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported camera flip.
+ /// </returns>
+ public IEnumerable<CameraFlip> SupportedStreamFlips
+ {
+ get
+ {
+ if (_streamFlips == null)
+ {
+ _streamFlips = new List<CameraFlip>();
+
+ Interop.CameraFeatures.StreamFlipCallback callback = (CameraFlip streamFlip, IntPtr userData) =>
+ {
+ _streamFlips.Add(streamFlip);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedStreamFlips(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported camera flips.");
+ }
+
+ return _streamFlips;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all the ptz types by the camera.
+ /// </summary>
+ /// <returns>
+ /// It returns a list containing all the supported ptz types.
+ /// </returns>
+ public IEnumerable<CameraPtzType> SupportedPtzTypes
+ {
+ get
+ {
+ if (_ptzTypes.Count == 0)
+ {
+ _ptzTypes = new List<CameraPtzType>();
+
+ Interop.CameraFeatures.PtzTypeCallback callback = (CameraPtzType ptzType, IntPtr userData) =>
+ {
+ _ptzTypes.Add(ptzType);
+ return true;
+ };
+ CameraErrorFactory.ThrowIfError(Interop.CameraFeatures.SupportedPtzTypes(_camera.GetHandle(), callback, IntPtr.Zero),
+ "Failed to get the supported Ptz types.");
+ }
+
+ return _ptzTypes;
+ }
+ }
+ }
+}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
/// An extended EventArgs class which contains details about focus state of the
/// camera.
/// </summary>
- public class CameraFocusChangedEventArgs : EventArgs
+ public class CameraFocusStateChangedEventArgs : EventArgs
{
- internal CameraFocusChangedEventArgs(CameraFocusState state)
+ internal CameraFocusStateChangedEventArgs(CameraFocusState state)
{
State = state;
}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
+++ /dev/null
-/*
- * 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;
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// Camera resolution class.
- /// </summary>
- public class CameraResolution
- {
- /// <summary>
- /// public constructor.
- /// </summary>
- /// <param name="width">Resolution width</param>
- /// <param name="height">Resolution height</param>
- public CameraResolution(int width, int height)
- {
- Width = width;
- Height = height;
- }
-
- /// <summary>
- /// The resolution width.
- /// </summary>
- public int Width
- {
- get;
- private set;
- }
-
- /// <summary>
- /// The resolution height.
- /// </summary>
- public int Height
- {
- get;
- private set;
- }
- }
-}
-
+++ /dev/null
-/*
- * 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.Collections.Generic;
-using System.Runtime.InteropServices;
-using Tizen.Internals.Errors;
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// The camera setting class provides methods/properties to get and
- /// set basic camera attributes.
- /// </summary>
- public class CameraSetting
- {
- internal readonly IntPtr _settingHandle;
-
- internal CameraSetting(IntPtr _handle)
- {
- _settingHandle = _handle;
- }
-
- /// <summary>
- /// Sets auto focus area.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- /// <param name="x">X position</param>
- /// <param name="y">Y position</param>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
- public void SetFocusArea(int x, int y)
- {
- int ret = Interop.CameraSetting.SetAfArea(_settingHandle, x, y);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to set the autofocus area.");
- }
- }
-
- /// <summary>
- /// Clears the auto focus area.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public void ClearFocusArea()
- {
- int ret = Interop.CameraSetting.ClearAfArea(_settingHandle);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to clear the autofocus area.");
- }
- }
-
- /// <summary>
- /// Sets the position to move horizontally.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- /// <param name="type">ptz move type.</param>
- /// <param name="panStep">pan step</param>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
- public void SetPan(CameraPtzMoveType type, int panStep)
- {
- int ret = Interop.CameraSetting.SetPan(_settingHandle, (int)type, panStep);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to set the camera pan type.");
- }
- }
-
- /// <summary>
- /// Gets the current position of the camera.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- /// <returns>Returns the camera's horizontal position</returns>
- public int GetPan()
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetPan(_settingHandle, out val);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to get the camera pan step.");
- }
-
- return val;
- }
-
- /// <summary>
- /// Sets the position to move vertically.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- /// <param name="type">ptz move type</param>
- /// <param name="tiltStep">tilt step</param>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
- public void SetTilt(CameraPtzMoveType type, int tiltStep)
- {
- int ret = Interop.CameraSetting.SetTilt(_settingHandle, (int)type, tiltStep);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to set the camera tilt type\t.");
- }
- }
-
- /// <summary>
- /// Gets the current position of the camera.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- /// <returns>Returns the current vertical position</returns>
- public int GetTilt()
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetTilt(_settingHandle, out val);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to set the camera current position.");
- }
-
- return val;
- }
-
- /// <summary>
- /// Removes the geotag(GPS data) in the EXIF(Exchangeable image file format) tag.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public void RemoveGeoTag()
- {
- int ret = Interop.CameraSetting.RemoveGeotag(_settingHandle);
- if (ret != (int)CameraError.None)
- {
- CameraErrorFactory.ThrowException(ret, "Failed to remove the geotag\t.");
- }
- }
-
- /// <summary>
- /// The preview frame rate.
- /// </summary>
- public CameraFps PreviewFps
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetPreviewFps(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera preview fps, " + (CameraError)ret);
- }
-
- return (CameraFps)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetPreviewFps(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set preview fps, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set preview fps.");
- }
- }
- }
-
- /// <summary>
- /// The quality of the image.
- /// The range for image quality is 1 to 100.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera.
- /// </privilege>
- public int ImageQuality
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetImageQuality(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get image quality, " + (CameraError)ret);
- }
-
- return val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetImageQuality(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set image quality, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set image quality.");
- }
- }
- }
-
- /// <summary>
- /// The bit rate of encoded preview.
- /// </summary>
- public int EncodedPreviewBitrate
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetBitrate(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get preview bitrate, " + (CameraError)ret);
- }
-
- return val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetBitrate(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set encoded preview bitrate, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set encoded preview bitrate.");
- }
- }
- }
-
- /// <summary>
- /// GOP(Group Of Pictures) interval of encoded preview.
- /// </summary>
- public int EncodedPreviewGopInterval
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetGopInterval(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get preview gop interval, " + (CameraError)ret);
- }
-
- return val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetGopInterval(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set encoded preview gop interval, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set encoded preview gop intervals.");
- }
- }
- }
-
- /// <summary>
- /// The zoom level.
- /// The range for zoom level is received from ZoomRange property.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera.
- /// </privilege>
- public int ZoomLevel
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetZoom(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get zoom level, " + (CameraError)ret);
- }
-
- return val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetZoom(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set zoom level, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set zoom level.");
- }
- }
- }
-
- /// <summary>
- /// Gets the available zoom level.
- /// </summary>
- /// <remarks>
- /// If min value is greater than the max value, it means this feature is not supported.
- /// </remarks>
- public Range ZoomRange
- {
- get
- {
- int min = 0;
- int max = 0;
-
- int ret = Interop.CameraSetting.GetZoomRange(_settingHandle, out min, out max);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get zoom range, " + (CameraError)ret);
- }
-
- Range res = new Range(min, max);
- return res;
- }
- }
-
- /// <summary>
- /// Gets the available exposure value.
- /// </summary>
- /// <remarks>
- /// If min value is greater than the max value, it means this feature is not supported.
- /// </remarks>
- public Range ExposureRange
- {
- get
- {
- int min = 0;
- int max = 0;
-
- int ret = Interop.CameraSetting.GetExposureRange(_settingHandle, out min, out max);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get exposure range, " + (CameraError)ret);
- }
-
- Range res = new Range(min, max);
- return res;
- }
- }
-
- /// <summary>
- /// Gets the available brightness level.
- /// </summary>
- /// <remarks>
- /// If min value is greater than the max value, it means this feature is not supported.
- /// </remarks>
- public Range BrightnessRange
- {
- get
- {
- int min = 0;
- int max = 0;
-
- int ret = Interop.CameraSetting.GetBrightnessRange(_settingHandle, out min, out max);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get brightness range, " + (CameraError)ret);
- }
-
- Range res = new Range(min, max);
- return res;
- }
- }
-
- /// <summary>
- /// Gets the available contrast level.
- /// </summary>
- /// <remarks>
- /// If min value is greater than the max value, it means this feature is not supported.
- /// </remarks>
- public Range ContrastRange
- {
- get
- {
- int min = 0;
- int max = 0;
-
- int ret = Interop.CameraSetting.GetContrastRange(_settingHandle, out min, out max);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get contrast range, " + (CameraError)ret);
- }
-
- Range res = new Range(min, max);
- return res;
- }
- }
-
- /// <summary>
- /// Gets lower limit and upper limit for pan position.
- /// </summary>
- /// <remarks>
- /// If min value is greater than the max value, it means this feature is not supported.
- /// </remarks>
- public Range PanRange
- {
- get
- {
- int min = 0;
- int max = 0;
-
- int ret = Interop.CameraSetting.GetPanRange(_settingHandle, out min, out max);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get pan range, " + (CameraError)ret);
- }
-
- Range res = new Range(min, max);
- return res;
- }
- }
-
- /// <summary>
- /// Gets lower limit and upper limit for tilt position.
- /// </summary>
- /// <remarks>
- /// If min value is greater than the max value, it means this feature is not supported.
- /// </remarks>
- public Range TiltRange
- {
- get
- {
- int min = 0;
- int max = 0;
-
- int ret = Interop.CameraSetting.GetTiltRange(_settingHandle, out min, out max);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get tilt range, " + (CameraError)ret);
- }
-
- Range res = new Range(min, max);
- return res;
- }
- }
-
- /// <summary>
- /// The auto focus mode.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public CameraAutoFocusMode AfMode
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetAfMode(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera autofocus mode, " + (CameraError)ret);
- }
-
- return (CameraAutoFocusMode)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetAfMode(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera autofocus mode, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera autofocus mode.");
- }
- }
- }
-
- /// <summary>
- /// The exposure mode.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public CameraExposureMode ExposureMode
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetExposureMode(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera exposure mode, " + (CameraError)ret);
- }
-
- return (CameraExposureMode)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetExposureMode(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera exposure mode, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera exposure mode.");
- }
- }
- }
-
- /// <summary>
- /// The exposure value.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public int Exposure
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetExposure(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera exposure value, " + (CameraError)ret);
- }
-
- return val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetExposure(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera exposure value, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera exposure value.");
- }
- }
- }
-
- /// <summary>
- /// The ISO level.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public CameraIsoLevel IsoLevel
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetIso(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera Iso level, " + (CameraError)ret);
- }
-
- return (CameraIsoLevel)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetIso(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera Iso level, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera Iso level.");
- }
- }
- }
-
- /// <summary>
- /// The theater mode.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- /// <remarks>
- /// If you want to display the preview image on the external display with the full screen mode,
- /// use this property.
- /// </remarks>
- public CameraTheaterMode TheaterMode
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetTheaterMode(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera theater mode, " + (CameraError)ret);
- }
-
- return (CameraTheaterMode)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetTheaterMode(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera theater mode, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera theater mode.");
- }
- }
- }
-
- /// <summary>
- /// The brightness level of the camera.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public int Brightness
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetBrightness(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera brightness value, " + (CameraError)ret);
- }
-
- return val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetBrightness(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera brightness value, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera brightness value.");
- }
- }
- }
-
- /// <summary>
- /// The contrast level of the camera.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public int Contrast
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetContrast(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera contrast value, " + (CameraError)ret);
- }
-
- return val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetContrast(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera contrast value, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera contrast value.");
- }
- }
- }
-
- /// <summary>
- /// The whitebalance mode.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public CameraWhitebalance Whitebalance
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetWhitebalance(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera whitebalance, " + (CameraError)ret);
- }
-
- return (CameraWhitebalance)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetWhitebalance(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera whitebalance, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera whitebalance.");
- }
- }
- }
-
- /// <summary>
- /// The camera effect mode.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public CameraEffectMode Effect
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetEffect(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera effect, " + (CameraError)ret);
- }
-
- return (CameraEffectMode)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetEffect(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera effect, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera effect.");
- }
- }
- }
-
- /// <summary>
- /// The scene mode.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public CameraSceneMode SceneMode
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetSceneMode(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera scene mode, " + (CameraError)ret);
- }
-
- return (CameraSceneMode)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetSceneMode(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera scene mode, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera scene mode.");
- }
- }
- }
-
- /// <summary>
- /// The scene mode.
- /// true if EXIF tags are enabled in JPEG file, otherwise false.
- /// </summary>
- public bool EnableTag
- {
- get
- {
- bool val = false;
- int ret = Interop.CameraSetting.IsEnabledTag(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera enable tag, " + (CameraError)ret);
- }
-
- return val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.EnableTag(_settingHandle, (bool)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera enable tag, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera enable tag.");
- }
- }
- }
-
- /// <summary>
- /// The camera image description in the EXIF tag.
- /// </summary>
- public string ImageDescription
- {
- get
- {
- IntPtr val;
- int ret = Interop.CameraSetting.GetImageDescription(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get image description, " + (CameraError)ret);
- }
-
- string result = Marshal.PtrToStringAnsi(val);
- Interop.Libc.Free(val);
- return result;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetImageDescription(_settingHandle, value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set image description, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set image description.");
- }
- }
- }
-
- /// <summary>
- /// The software information in the EXIF tag.
- /// </summary>
- public string TagSoftware
- {
- get
- {
- IntPtr val;
- int ret = Interop.CameraSetting.GetTagSoftware(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get tag software, " + (CameraError)ret);
- }
-
- string result = Marshal.PtrToStringAnsi(val);
- Interop.Libc.Free(val);
- return result;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetTagSoftware(_settingHandle, value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set tag software, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set tag software.");
- }
- }
- }
-
- /// <summary>
- /// The geotag(GPS data) in the EXIF tag.
- /// </summary>
- public Location GeoTag
- {
- get
- {
- double latitude = 0.0;
- double longitude = 0.0;
- double altitude = 0.0;
-
- int ret = Interop.CameraSetting.GetGeotag(_settingHandle, out latitude, out longitude, out altitude);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get tag, " + (CameraError)ret);
- }
-
- Location loc = new Location(latitude, longitude, altitude);
- return loc;
- }
-
- set
- {
- Location loc = value;
- int ret = Interop.CameraSetting.SetGeotag(_settingHandle, loc.Latitude, loc.Longitude, loc.Altitude);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get contrast range, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set geo tag.");
- }
- }
- }
-
- /// <summary>
- /// The camera orientation in the tag.
- /// </summary>
- public CameraTagOrientation TagOrientation
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetTagOrientation(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera tag orientation, " + (CameraError)ret);
- }
-
- return (CameraTagOrientation)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetTagOrientation(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera tag orientation, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera tag orientation.");
- }
- }
- }
-
- /// <summary>
- /// The camera's flash mode.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public CameraFlashMode FlashMode
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetFlashMode(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera flash mode, " + (CameraError)ret);
- }
-
- return (CameraFlashMode)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetFlashMode(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera flash mode, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera flash mode.");
- }
- }
- }
-
- /// <summary>
- /// Gets the camera lens orientation angle.
- /// </summary>
- public int LensOrientation
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetLensOrientation(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera lens orientation, " + (CameraError)ret);
- }
-
- return val;
- }
- }
-
- /// <summary>
- /// The stream rotation.
- /// </summary>
- public CameraRotation StreamRotation
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetStreamRotation(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera stream rotation, " + (CameraError)ret);
- }
-
- return (CameraRotation)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetStreamRotation(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera stream rotation, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera stream rotation.");
- }
- }
- }
-
- /// <summary>
- /// The stream flip.
- /// </summary>
- public CameraFlip StreamFlip
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetFlip(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera stream flip, " + (CameraError)ret);
- }
-
- return (CameraFlip)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetFlip(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera stream flip, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera flip.");
- }
- }
- }
-
- /// <summary>
- /// The mode of HDR(High dynamic range) capture.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- /// <remarks>
- /// Taking multiple pictures at different exposure levels and intelligently stitching them together
- /// so that we eventually arrive at a picture that is representative in both dark and bright areas.
- /// If this attribute is set, then eventhandler set for HdrCaptureProgress event is invoked.
- /// </remarks>
- public CameraHdrMode HdrMode
- {
- get
- {
- int val = 0;
- int ret = Interop.CameraSetting.GetHdrMode(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera hdr mode, " + (CameraError)ret);
- }
-
- return (CameraHdrMode)val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.SetHdrMode(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera hdr mode, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera hdr mode.");
- }
- }
- }
-
- /// <summary>
- /// The anti shake feature.
- /// If true the antishake feature is enabled, otherwise false.
- /// </summary>
- public bool AntiShake
- {
- get
- {
- bool val = false;
- int ret = Interop.CameraSetting.IsEnabledAntiShake(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera anti shake value, " + (CameraError)ret);
- }
-
- return val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.EnableAntiShake(_settingHandle, (bool)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera anti shake value, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera anti shake value.");
- }
- }
- }
-
- /// <summary>
- /// Enables/Disables the video stabilization feature.
- /// If true video stabilization is enabled, otherwise false.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- /// <remarks>
- /// If video stabilization is enabled, zero shutter lag is disabled.
- /// This feature is used to record a video.
- /// </remarks>
- public bool VideoStabilization
- {
- get
- {
- bool val = false;
- int ret = Interop.CameraSetting.IsEnabledVideoStabilization(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera video stabilization, " + (CameraError)ret);
- }
-
- return val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.EnableVideoStabilization(_settingHandle, (bool)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera video stabilization, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera video stabilization.");
- }
- }
- }
-
- /// <summary>
- /// The auto contrast.
- /// If true auto contrast is enabled, otherwise false.
- /// </summary>
- /// <privilege>
- /// http://tizen.org/privilege/camera
- /// </privilege>
- public bool AutoContrast
- {
- get
- {
- bool val = false;
- int ret = Interop.CameraSetting.IsEnabledAutoContrast(_settingHandle, out val);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get camera auto contrast, " + (CameraError)ret);
- }
-
- return val;
- }
-
- set
- {
- int ret = Interop.CameraSetting.EnableAutoContrast(_settingHandle, (bool)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera enable auto contrast, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera enable auto contrast.");
- }
- }
- }
-
- /// <summary>
- /// Disables shutter sound.
- /// If true shutter sound is disabled, otherwise false.
- /// </summary>
- /// <remarks>
- /// In some countries, this operation is not permitted.
- /// </remarks>
- public bool DisableShutterSound
- {
- set
- {
- int ret = Interop.CameraSetting.DisableShutterSound(_settingHandle, (bool)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to disable shutter sound, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set disable shutter sound.");
- }
- }
- }
-
- /// <summary>
- /// Sets the type of PTZ(Pan Tilt Zoom).
- /// </summary>
- public CameraPtzType PtzType
- {
- set
- {
- int ret = Interop.CameraSetting.SetPtzType(_settingHandle, (int)value);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set camera ptz type, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set camera ptz type.");
- }
- }
- }
-
- /// <summary>
- /// the ROI(Region Of Interest) area of display.
- /// </summary>
- public Area DisplayRoiArea
- {
- get
- {
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
-
- int ret = Interop.CameraSetting.GetDisplayRoiArea(_settingHandle, out x, out y, out width, out height);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to get display roi area, " + (CameraError)ret);
- }
-
- Area ar = new Area(x, y, width, height);
- return ar;
- }
-
- set
- {
- Area ar = (Area)value;
- int ret = Interop.CameraSetting.SetDisplayRoiArea(_settingHandle, ar.X, ar.Y, ar.Width, ar.Height);
- if ((CameraError)ret != CameraError.None)
- {
- Log.Error(CameraLog.Tag, "Failed to set display roi area, " + (CameraError)ret);
- CameraErrorFactory.ThrowException(ret, "Failed to set display roi area.");
- }
- }
- }
- }
-}
-
--- /dev/null
+/*
+ * 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.Linq;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// The camera setting class provides methods/properties to get and
+ /// set basic camera attributes.
+ /// </summary>
+ public class CameraSettings
+ {
+ internal readonly Camera _camera;
+
+ private readonly Range? _brightnessRange;
+ private readonly Range? _contrastRange;
+ private readonly Range? _panRange;
+ private readonly Range? _tiltRange;
+ private readonly Range? _exposureRange;
+ private readonly Range? _zoomRange;
+
+ internal CameraSettings(Camera camera)
+ {
+ _camera = camera;
+
+ _contrastRange = GetRange(Interop.CameraSettings.GetContrastRange);
+ _brightnessRange = GetRange(Interop.CameraSettings.GetBrightnessRange);
+ _exposureRange = GetRange(Interop.CameraSettings.GetExposureRange);
+ _zoomRange = GetRange(Interop.CameraSettings.GetZoomRange);
+ _panRange = GetRange(Interop.CameraSettings.GetPanRange);
+ _tiltRange = GetRange(Interop.CameraSettings.GetTiltRange);
+ }
+
+ private delegate int GetRangeDelegate(IntPtr handle, out int min, out int max);
+ private Range? GetRange(GetRangeDelegate func)
+ {
+ int min = 0;
+ int max = 0;
+
+ CameraErrorFactory.ThrowIfError(func(_camera.GetHandle(), out min, out max),
+ "Failed to initialize the camera settings");
+
+ if (min > max)
+ {
+ return null;
+ }
+
+ return new Range(min, max);
+ }
+
+#region Auto Focus
+ /// <summary>
+ /// Sets auto focus area.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ /// <param name="x">X position</param>
+ /// <param name="y">Y position</param>
+ /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ public void SetAutoFocusArea(int x, int y)
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetAutoFocusArea(_camera.GetHandle(), x, y),
+ "Failed to set the autofocus area.");
+ }
+
+ public void SetAutoFocusArea(Point pos)
+ {
+ SetAutoFocusArea(pos.X, pos.Y);
+ }
+
+ /// <summary>
+ /// Clears the auto focus area.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public void ClearFocusArea()
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.ClearAutoFocusArea(_camera.GetHandle()),
+ "Failed to clear the autofocus area.");
+ }
+
+ /// <summary>
+ /// The auto focus mode.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public CameraAutoFocusMode AutoFocusMode
+ {
+ get
+ {
+ CameraAutoFocusMode val = CameraAutoFocusMode.None;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetAutoFocusMode(_camera.GetHandle(), out val),
+ "Failed to get camera autofocus mode");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetAutoFocusMode(_camera.GetHandle(), value),
+ "Failed to set camera autofocus mode.");
+ }
+ }
+ #endregion Auto Focus
+
+#region Contrast
+ /// <summary>
+ /// The contrast level of the camera.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public int Contrast
+ {
+ get
+ {
+ int val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetContrast(_camera.GetHandle(), out val),
+ "Failed to get camera contrast value");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetContrast(_camera.GetHandle(), value),
+ "Failed to set camera contrast value.");
+ }
+ }
+
+ /// <summary>
+ /// The auto contrast.
+ /// If true auto contrast is enabled, otherwise false.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public bool AutoContrast
+ {
+ get
+ {
+ bool val = false;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.IsEnabledAutoContrast(_camera.GetHandle(), out val),
+ "Failed to get camera auto contrast");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.EnableAutoContrast(_camera.GetHandle(), value),
+ "Failed to set camera enable auto contrast.");
+ }
+ }
+ /// <summary>
+ /// Gets the available contrast level.
+ /// </summary>
+ /// <remarks>
+ /// If min value is greater than the max value, it means this feature is not supported.
+ /// </remarks>
+ public Range ContrastRange
+ {
+ get
+ {
+ if (_contrastRange.HasValue == false)
+ {
+ throw new NotSupportedException("Contrast is not supported.");
+ }
+
+ return _contrastRange.Value;
+ }
+ }
+#endregion Contrast
+
+#region Brightness
+ /// <summary>
+ /// The brightness level of the camera.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public int Brightness
+ {
+ get
+ {
+ int val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetBrightness(_camera.GetHandle(), out val),
+ "Failed to get camera brightness value");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetBrightness(_camera.GetHandle(), value),
+ "Failed to set camera brightness value.");
+ }
+ }
+
+ /// <summary>
+ /// Gets the available brightness level.
+ /// </summary>
+ /// <remarks>
+ /// If min value is greater than the max value, it means this feature is not supported.
+ /// </remarks>
+ public Range BrightnessRange
+ {
+ get
+ {
+ if (_brightnessRange.HasValue == false)
+ {
+ throw new NotSupportedException("Brightness is not supported.");
+ }
+
+ return _brightnessRange.Value;
+ }
+ }
+#endregion Brightness
+
+#region Exposure
+ /// <summary>
+ /// The exposure value.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public int Exposure
+ {
+ get
+ {
+ int val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetExposure(_camera.GetHandle(), out val),
+ "Failed to get camera exposure value");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetExposure(_camera.GetHandle(), value),
+ "Failed to set camera exposure value.");
+ }
+ }
+
+ /// <summary>
+ /// The exposure mode.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public CameraExposureMode ExposureMode
+ {
+ get
+ {
+ CameraExposureMode val = CameraExposureMode.Off;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetExposureMode(_camera.GetHandle(), out val),
+ "Failed to get camera exposure mode");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetExposureMode(_camera.GetHandle(), value),
+ "Failed to set camera exposure mode.");
+ }
+ }
+
+ /// <summary>
+ /// Gets the available exposure value.
+ /// </summary>
+ /// <remarks>
+ /// If min value is greater than the max value, it means this feature is not supported.
+ /// </remarks>
+ public Range ExposureRange
+ {
+ get
+ {
+ if (_exposureRange.HasValue == false)
+ {
+ throw new NotSupportedException("Exposure is not supported.");
+ }
+
+ return _exposureRange.Value;
+ }
+ }
+ #endregion Exposure
+
+#region Zoom
+ /// <summary>
+ /// The zoom level.
+ /// The range for zoom level is received from ZoomRange property.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera.
+ /// </privilege>
+ public int ZoomLevel
+ {
+ get
+ {
+ int val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetZoom(_camera.GetHandle(), out val),
+ "Failed to get zoom level");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetZoom(_camera.GetHandle(), (int)value),
+ "Failed to set zoom level.");
+ }
+ }
+
+ /// <summary>
+ /// Gets the available zoom level.
+ /// </summary>
+ /// <remarks>
+ /// If min value is greater than the max value, it means this feature is not supported.
+ /// </remarks>
+ public Range ZoomRange
+ {
+ get
+ {
+ if (_zoomRange.HasValue == false)
+ {
+ throw new NotSupportedException("Zoom is not supported.");
+ }
+
+ return _zoomRange.Value;
+ }
+ }
+#endregion Zoom
+
+ /// <summary>
+ /// The whitebalance mode.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public CameraWhiteBalance WhiteBalance
+ {
+ get
+ {
+ CameraWhiteBalance val = CameraWhiteBalance.None;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetWhiteBalance(_camera.GetHandle(), out val),
+ "Failed to get camera whitebalance");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetWhitebalance(_camera.GetHandle(), value),
+ "Failed to set camera whitebalance.");
+ }
+ }
+
+ /// <summary>
+ /// The ISO level.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public CameraIsoLevel IsoLevel
+ {
+ get
+ {
+ CameraIsoLevel val = CameraIsoLevel.Auto;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetIso(_camera.GetHandle(), out val),
+ "Failed to get camera Iso level");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetIso(_camera.GetHandle(), value),
+ "Failed to set camera Iso level.");
+ }
+ }
+
+ /// <summary>
+ /// The quality of the image.
+ /// The range for image quality is 1 to 100.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera.
+ /// </privilege>
+ public int ImageQuality
+ {
+ get
+ {
+ int val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetImageQuality(_camera.GetHandle(), out val),
+ "Failed to get image quality");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetImageQuality(_camera.GetHandle(), value),
+ "Failed to set image quality.");
+ }
+ }
+
+#region Resolution, Format, Fps of preview, capture
+ /// <summary>
+ /// The preview frame rate.
+ /// </summary>
+ public CameraFps PreviewFps
+ {
+ get
+ {
+ CameraFps val = CameraFps.Auto;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetPreviewFps(_camera.GetHandle(), out val),
+ "Failed to get camera preview fps");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetPreviewFps(_camera.GetHandle(), value),
+ "Failed to set preview fps.");
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the resolution of preview
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ public Size PreviewResolution
+ {
+ get
+ {
+ int width = 0;
+ int height = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.GetPreviewResolution(_camera.GetHandle(), out width, out height),
+ "Failed to get camera preview resolution");
+
+ return new Size(width, height);
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetPreviewResolution(_camera.GetHandle(), value.Width, value.Height),
+ "Failed to set preview resolution.");
+ }
+ }
+
+ /// <summary>
+ /// Gets the recommended preview resolution.
+ /// </summary>
+ /// <remarks>
+ /// Depending on the capture resolution aspect ratio and display resolution,
+ /// the recommended preview resolution is determined.
+ /// </remarks>
+ public Size RecommendedPreviewResolution
+ {
+ get
+ {
+ int width = 0;
+ int height = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.GetRecommendedPreviewResolution(_camera.GetHandle(), out width, out height),
+ "Failed to get recommended preview resolution");
+
+ return new Size(width, height);
+ }
+ }
+
+ /// <summary>
+ /// The preview data format.
+ /// </summary>
+ /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ public CameraPixelFormat PreviewPixelFormat
+ {
+ get
+ {
+ CameraPixelFormat val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.GetPreviewPixelFormat(_camera.GetHandle(), out val),
+ "Failed to get preview format");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetPreviewPixelFormat(_camera.GetHandle(), value),
+ "Failed to set preview format.");
+ }
+ }
+
+ /// <summary>
+ /// Resolution of the captured image.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ public Size CaptureResolution
+ {
+ get
+ {
+ int width = 0;
+ int height = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.GetCaptureResolution(_camera.GetHandle(), out width, out height),
+ "Failed to get camera capture resolution");
+
+ return new Size(width, height);
+ }
+
+ set
+ {
+ Size res = value;
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetCaptureResolution(_camera.GetHandle(), res.Width, res.Height),
+ "Failed to set capture resolution.");
+ }
+ }
+
+ /// <summary>
+ /// Format of an image to be captured.
+ /// </summary>
+ /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ public CameraPixelFormat CapturePixelFormat
+ {
+ get
+ {
+ CameraPixelFormat val = CameraPixelFormat.Invalid;
+
+ CameraErrorFactory.ThrowIfError(Interop.Camera.GetCaptureFormat(_camera.GetHandle(), out val),
+ "Failed to get camera capture formats");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.Camera.SetCaptureFormat(_camera.GetHandle(), value),
+ "Failed to set capture format.");
+ }
+ }
+#endregion Resolution, Format, Fps of preview, capture
+
+#region Encoded preview
+ /// <summary>
+ /// The bit rate of encoded preview.
+ /// </summary>
+ public int EncodedPreviewBitrate
+ {
+ get
+ {
+ int val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetBitrate(_camera.GetHandle(), out val),
+ "Failed to get preview bitrate");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetBitrate(_camera.GetHandle(), (int)value),
+ "Failed to set encoded preview bitrate.");
+ }
+ }
+
+ /// <summary>
+ /// GOP(Group Of Pictures) interval of encoded preview.
+ /// </summary>
+ public int EncodedPreviewGopInterval
+ {
+ get
+ {
+ int val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetGopInterval(_camera.GetHandle(), out val),
+ "Failed to get preview gop interval");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetGopInterval(_camera.GetHandle(), (int)value),
+ "Failed to set encoded preview gop intervals.");
+ }
+ }
+#endregion Encoded preview
+
+ /// <summary>
+ /// The theater mode.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ /// <remarks>
+ /// If you want to display the preview image on the external display with the full screen mode,
+ /// use this property.
+ /// </remarks>
+ public CameraTheaterMode TheaterMode
+ {
+ get
+ {
+ CameraTheaterMode val = CameraTheaterMode.Disable;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetTheaterMode(_camera.GetHandle(), out val),
+ "Failed to get camera theater mode");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetTheaterMode(_camera.GetHandle(), value),
+ "Failed to set camera theater mode.");
+ }
+ }
+
+ /// <summary>
+ /// The camera effect mode.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public CameraEffectMode Effect
+ {
+ get
+ {
+ CameraEffectMode val = CameraEffectMode.None;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetEffect(_camera.GetHandle(), out val),
+ "Failed to get camera effect");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetEffect(_camera.GetHandle(), value),
+ "Failed to set camera effect.");
+ }
+ }
+
+ /// <summary>
+ /// The scene mode.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public CameraSceneMode SceneMode
+ {
+ get
+ {
+ CameraSceneMode val = CameraSceneMode.Normal;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetSceneMode(_camera.GetHandle(), out val),
+ "Failed to get camera scene mode");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetSceneMode(_camera.GetHandle(), value),
+ "Failed to set camera scene mode.");
+ }
+ }
+
+ /// <summary>
+ /// The camera's flash mode.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public CameraFlashMode FlashMode
+ {
+ get
+ {
+ CameraFlashMode val = CameraFlashMode.Off;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetFlashMode(_camera.GetHandle(), out val),
+ "Failed to get camera flash mode");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetFlashMode(_camera.GetHandle(), value),
+ "Failed to set camera flash mode.");
+ }
+ }
+
+ /// <summary>
+ /// Gets the camera lens orientation angle.
+ /// </summary>
+ public int LensOrientation
+ {
+ get
+ {
+ int val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetLensOrientation(_camera.GetHandle(), out val),
+ "Failed to get camera lens orientation");
+
+ return val;
+ }
+ }
+
+ /// <summary>
+ /// The stream rotation.
+ /// </summary>
+ public CameraRotation StreamRotation
+ {
+ get
+ {
+ CameraRotation val = CameraRotation.None;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetStreamRotation(_camera.GetHandle(), out val),
+ "Failed to get camera stream rotation");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetStreamRotation(_camera.GetHandle(), value),
+ "Failed to set camera stream rotation.");
+ }
+ }
+
+ /// <summary>
+ /// The stream flip.
+ /// </summary>
+ public CameraFlip StreamFlip
+ {
+ get
+ {
+ CameraFlip val = CameraFlip.None;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetFlip(_camera.GetHandle(), out val),
+ "Failed to get camera stream flip");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetFlip(_camera.GetHandle(), value),
+ "Failed to set camera flip.");
+ }
+ }
+
+ /// <summary>
+ /// The mode of HDR(High dynamic range) capture.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ /// <remarks>
+ /// Taking multiple pictures at different exposure levels and intelligently stitching them together
+ /// so that we eventually arrive at a picture that is representative in both dark and bright areas.
+ /// If this attribute is set, then eventhandler set for HdrCaptureProgress event is invoked.
+ /// </remarks>
+ public CameraHdrMode HdrMode
+ {
+ get
+ {
+ CameraHdrMode val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetHdrMode(_camera.GetHandle(), out val),
+ "Failed to get camera hdr mode");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetHdrMode(_camera.GetHandle(), value),
+ "Failed to set camera hdr mode.");
+ }
+ }
+
+ /// <summary>
+ /// The anti shake feature.
+ /// If true the antishake feature is enabled, otherwise false.
+ /// </summary>
+ public bool AntiShake
+ {
+ get
+ {
+ bool val = false;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.IsEnabledAntiShake(_camera.GetHandle(), out val),
+ "Failed to get camera anti shake value");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.EnableAntiShake(_camera.GetHandle(), value),
+ "Failed to set camera anti shake value.");
+ }
+ }
+
+ /// <summary>
+ /// Enables/Disables the video stabilization feature.
+ /// If true video stabilization is enabled, otherwise false.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ /// <remarks>
+ /// If video stabilization is enabled, zero shutter lag is disabled.
+ /// This feature is used to record a video.
+ /// </remarks>
+ public bool VideoStabilization
+ {
+ get
+ {
+ bool val = false;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.IsEnabledVideoStabilization(_camera.GetHandle(), out val),
+ "Failed to get camera video stabilization");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.EnableVideoStabilization(_camera.GetHandle(), value),
+ "Failed to set camera video stabilization.");
+ }
+ }
+
+ /// <summary>
+ /// Disables shutter sound.
+ /// If true shutter sound is disabled, otherwise false.
+ /// </summary>
+ /// <remarks>
+ /// In some countries, this operation is not permitted.
+ /// </remarks>
+ public bool DisableShutterSound
+ {
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.DisableShutterSound(_camera.GetHandle(), value),
+ "Failed to set disable shutter sound.");
+ }
+ }
+
+#region PTZ(Pan Tilt Zoom), Pan, Tilt
+ /// <summary>
+ /// Sets the type of PTZ(Pan Tilt Zoom). Mechanical or Electronic.
+ /// </summary>
+ public CameraPtzType PtzType
+ {
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetPtzType(_camera.GetHandle(), (int)value),
+ "Failed to set camera ptz type.");
+ }
+ }
+
+ /// <summary>
+ /// Sets the position to move horizontally.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ /// <param name="type">ptz move type.</param>
+ /// <param name="panStep">pan step</param>
+ /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ public void SetPan(CameraPtzMoveType type, int panStep)
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetPan(_camera.GetHandle(), type, panStep),
+ "Failed to set the camera pan type.");
+ }
+
+ /// <summary>
+ /// Gets the current position of the camera.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ /// <returns>Returns the camera's horizontal position</returns>
+ public int GetPan()
+ {
+ int val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetPan(_camera.GetHandle(), out val),
+ "Failed to get the camera pan step.");
+
+ return val;
+ }
+
+ /// <summary>
+ /// Sets the position to move vertically.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ /// <param name="type">ptz move type</param>
+ /// <param name="tiltStep">tilt step</param>
+ /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ public void SetTilt(CameraPtzMoveType type, int tiltStep)
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetTilt(_camera.GetHandle(), type, tiltStep),
+ "Failed to set the camera tilt type\t.");
+ }
+
+ /// <summary>
+ /// Gets the current position of the camera.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ /// <returns>Returns the current vertical position</returns>
+ public int GetTilt()
+ {
+ int val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetTilt(_camera.GetHandle(), out val),
+ "Failed to set the camera current position.");
+
+ return val;
+ }
+
+ /// <summary>
+ /// Gets lower limit and upper limit for pan position.
+ /// </summary>
+ /// <remarks>
+ /// If min value is greater than the max value, it means this feature is not supported.
+ /// </remarks>
+ public Range PanRange
+ {
+ get
+ {
+ if (_panRange.HasValue == false)
+ {
+ throw new NotSupportedException("Pan is not supported.");
+ }
+ return _panRange.Value;
+ }
+ }
+
+ /// <summary>
+ /// Gets lower limit and upper limit for tilt position.
+ /// </summary>
+ /// <remarks>
+ /// If min value is greater than the max value, it means this feature is not supported.
+ /// </remarks>
+ public Range TiltRange
+ {
+ get
+ {
+ if (_tiltRange.HasValue == false)
+ {
+ throw new NotSupportedException("Tilt is not supported.");
+ }
+ return _tiltRange.Value;
+ }
+ }
+#endregion PTZ(Pan Tilt Zoom), Pan, Tilt
+
+#region EXIF tag
+ /// <summary>
+ /// The scene mode.
+ /// true if EXIF tags are enabled in JPEG file, otherwise false.
+ /// </summary>
+ public bool EnableTag
+ {
+ get
+ {
+ bool val = false;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.IsEnabledTag(_camera.GetHandle(), out val),
+ "Failed to get camera enable tag");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.EnableTag(_camera.GetHandle(), value),
+ "Failed to set camera enable tag.");
+ }
+ }
+
+ /// <summary>
+ /// The camera image description in the EXIF tag.
+ /// </summary>
+ public string ImageDescriptionTag
+ {
+ get
+ {
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetImageDescription(_camera.GetHandle(), out val),
+ "Failed to get image description");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetImageDescription(_camera.GetHandle(), value),
+ "Failed to set image description.");
+ }
+ }
+
+ /// <summary>
+ /// The software information in the EXIF tag.
+ /// </summary>
+ public string SoftwareTag
+ {
+ get
+ {
+ IntPtr val = IntPtr.Zero;
+
+ try
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetTagSoftware(_camera.GetHandle(), out val),
+ "Failed to get tag software");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetTagSoftware(_camera.GetHandle(), value),
+ "Failed to set tag software.");
+ }
+ }
+
+ /// <summary>
+ /// The geotag(GPS data) in the EXIF tag.
+ /// </summary>
+ public Location GeoTag
+ {
+ get
+ {
+ double latitude = 0.0;
+ double longitude = 0.0;
+ double altitude = 0.0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetGeotag(_camera.GetHandle(), out latitude, out longitude, out altitude),
+ "Failed to get tag");
+
+ return new Location(latitude, longitude, altitude);
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetGeotag(_camera.GetHandle(),
+ value.Latitude, value.Longitude, value.Altitude), "Failed to set geo tag.");
+ }
+ }
+
+ /// <summary>
+ /// Removes the geotag(GPS data) in the EXIF(Exchangeable image file format) tag.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/camera
+ /// </privilege>
+ public void RemoveGeoTag()
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.RemoveGeotag(_camera.GetHandle()),
+ "Failed to remove the geotag\t.");
+ }
+
+ /// <summary>
+ /// The camera orientation in the tag.
+ /// </summary>
+ public CameraTagOrientation OrientationTag
+ {
+ get
+ {
+ CameraTagOrientation val = 0;
+
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.GetTagOrientation(_camera.GetHandle(), out val),
+ "Failed to get camera tag orientation");
+
+ return val;
+ }
+
+ set
+ {
+ CameraErrorFactory.ThrowIfError(Interop.CameraSettings.SetTagOrientation(_camera.GetHandle(), value),
+ "Failed to set camera tag orientation.");
+ }
+ }
+#endregion EXIF tag
+ }
+}
+
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* limitations under the License.
*/
-using System;
+using System.Runtime.InteropServices;
namespace Tizen.Multimedia
{
/// <summary>
/// The class containing image data which has two planes.
/// </summary>
- public class DoublePlaneData : PreviewData
+ public class DoublePlane : IPreviewPlane
{
- internal DoublePlaneData()
+ internal DoublePlane(Interop.Camera.DoublePlaneStruct unmanaged)
{
+ Y = new byte[unmanaged.YLength];
+ UV = new byte[unmanaged.UVLength];
+ Marshal.Copy(unmanaged.Y, Y, 0, (int)unmanaged.YLength);
+ Marshal.Copy(unmanaged.UV, UV, 0, (int)unmanaged.UVLength);
}
/// <summary>
/// The Y plane data.
/// </summary>
- public byte[] YData
- {
- get;
- internal set;
- }
+ public byte[] Y { get; }
/// <summary>
/// The UV plane data.
/// </summary>
- public byte[] UVData
- {
- get;
- internal set;
- }
+ public byte[] UV { get; }
}
}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* limitations under the License.
*/
-using System;
+using System.Runtime.InteropServices;
namespace Tizen.Multimedia
{
/// <summary>
/// The class containing Encoded image data.
/// </summary>
- public class EncodedPlaneData : PreviewData
+ public class EncodedPlane : IPreviewPlane
{
- internal EncodedPlaneData()
+ internal EncodedPlane(Interop.Camera.EncodedPlaneStruct unmanagedData)
{
+ Data = new byte[unmanagedData.DataLength];
+ Marshal.Copy(unmanagedData.Data, Data, 0, (int)unmanagedData.DataLength);
}
/// <summary>
/// The buffer containing encoded image data.
/// </summary>
- public byte[] Data
- {
- get;
- internal set;
- }
+ public byte[] Data { get; }
}
}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
*/
using System;
+using System.Runtime.InteropServices;
namespace Tizen.Multimedia
{
/// <summary>
/// The class contains the details of the detected face.
/// </summary>
- public class FaceDetectedData
+ public class FaceDetectionData
{
- private int _id;
- private int _score;
- private int _x;
- private int _y;
- private int _width;
- private int _height;
-
- internal FaceDetectedData(int id, int score, int x, int y, int width, int height)
+ internal FaceDetectionData(IntPtr ptr)
{
- _id = id;
- _score = score;
- _x = x;
- _y = y;
- _width = width;
- _height = height;
+ var unmanagedStruct = Marshal.PtrToStructure<Interop.Camera.DetectedFaceStruct>(ptr);
+
+ Id = unmanagedStruct.Id;
+ Score = unmanagedStruct.Score;
+ X = unmanagedStruct.X;
+ Y = unmanagedStruct.Y;
+ Width = unmanagedStruct.Width;
+ Height = unmanagedStruct.Height;
}
/// <summary>
/// The Id of each face.
/// </summary>
- public int Id
- {
- get
- {
- return _id;
- }
- }
+ public int Id { get; }
/// <summary>
/// The confidence level for the detection of the face.
/// </summary>
- public int Score
- {
- get
- {
- return _score;
- }
- }
+ public int Score { get; }
/// <summary>
/// The X co-ordinate of the face.
/// </summary>
- public int X
- {
- get
- {
- return _x;
- }
- }
+ public int X { get; }
/// <summary>
/// The Y co-ordinate of the face.
/// </summary>
- public int Y
- {
- get
- {
- return _y;
- }
- }
+ public int Y { get; }
/// <summary>
/// The width of the face.
/// </summary>
- public int Width
- {
- get
- {
- return _width;
- }
- }
+ public int Width { get; }
/// <summary>
/// The height of the face.
/// </summary>
- public int Height
- {
- get
- {
- return _height;
- }
- }
+ public int Height { get; }
}
}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
{
/// <summary>
/// An extended EventArgs class which contains details about all the faces detected.
+ /// If user need to remain faces data, user have to copy the data.
/// </summary>
public class FaceDetectedEventArgs : EventArgs
{
- private readonly List<FaceDetectedData> _faces;
- internal FaceDetectedEventArgs(List<FaceDetectedData> faces)
+ internal FaceDetectedEventArgs(List<FaceDetectionData> faces)
{
- _faces = new List<FaceDetectedData>(faces);
+ Faces = faces;
}
/// <summary>
- /// List containing faces of type <see cref="Tizen.Multimedia.FaceDetectedData"/>.
+ /// List containing faces of type <see cref="Tizen.Multimedia.FaceDetectionData"/>.
/// </summary>
- public IEnumerable<FaceDetectedData> Faces
- {
- get
- {
- return _faces;
- }
- }
+ public IEnumerable<FaceDetectionData> Faces { get; }
}
}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Multimedia
+{
+ public interface IPreviewPlane
+ {
+ }
+}
\ No newline at end of file
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
*/
using System;
+using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Tizen.Multimedia
/// </summary>
public class ImageData
{
- internal byte[] _data;
- internal int _width;
- internal int _height;
- internal CameraPixelFormat _format;
- internal byte[] _exif;
-
- internal ImageData()
+ internal ImageData(IntPtr ptr)
{
- }
+ var unmanagedStruct = Marshal.PtrToStructure<Interop.Camera.ImageDataStruct>(ptr);
- /// <summary>
- /// The buffer containing image data.
- /// </summary>
- public byte[] Data
- {
- get
+ Format = unmanagedStruct.Format;
+ Width = unmanagedStruct.Width;
+ Height = unmanagedStruct.Height;
+
+ if (unmanagedStruct.Data != IntPtr.Zero && unmanagedStruct.DataLength > 0)
+ {
+ Data = new byte[unmanagedStruct.DataLength];
+ Marshal.Copy(unmanagedStruct.Data, Data, 0, (int)unmanagedStruct.DataLength);
+ }
+ else
{
- return _data;
+ Debug.Fail("ImageData is null!");
+ }
+
+ //Exif can be null
+ if (unmanagedStruct.ExifLength > 0)
+ {
+ Exif = new byte[unmanagedStruct.ExifLength];
+ Marshal.Copy(unmanagedStruct.Exif, Exif, 0, (int)unmanagedStruct.ExifLength);
}
}
/// <summary>
+ /// The pixel format of the captured image.
+ /// </summary>
+ public CameraPixelFormat Format { get; }
+
+ /// <summary>
/// The width of the image.
/// </summary>
- public int Width
- {
- get
- {
- return _width;
- }
- }
+ public int Width { get; }
/// <summary>
/// The height of the image.
/// </summary>
- public int Height
- {
- get
- {
- return _height;
- }
- }
+ public int Height { get; }
/// <summary>
- /// The pixel format of the captured image.
+ /// The buffer containing image data.
/// </summary>
- public CameraPixelFormat Format
- {
- get
- {
- return _format;
- }
- }
+ public byte[] Data { get; }
/// <summary>
/// String containing Exif data.
/// </summary>
- public byte[] Exif
- {
- get
- {
- return _exif;
- }
- }
+ public byte[] Exif { get; }
}
}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* limitations under the License.
*/
+using System;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+using static Interop.Camera;
+
namespace Tizen.Multimedia
{
/// <summary>
/// </summary>
public class PreviewData
{
- internal PreviewData()
+ internal PreviewData(IntPtr ptr)
+ {
+ var unmanagedStruct = Marshal.PtrToStructure<CameraPreviewDataStruct>(ptr);
+
+ Format = unmanagedStruct.Format;
+ Width = unmanagedStruct.Width;
+ Height = unmanagedStruct.Height;
+ TimeStamp = unmanagedStruct.TimeStamp;
+ PlaneType = GetPlaneType(unmanagedStruct);
+ Plane = ConvertPlane(unmanagedStruct);
+ }
+
+ private static IPreviewPlane ConvertPlane(CameraPreviewDataStruct unmanagedStruct)
{
+ if (unmanagedStruct.NumOfPlanes == 1)
+ {
+ if (unmanagedStruct.Format == CameraPixelFormat.H264 || unmanagedStruct.Format == CameraPixelFormat.Jpeg)
+ {
+ return new EncodedPlane(unmanagedStruct.Plane.EncodedPlane);
+ }
+ else
+ {
+ return new SinglePlane(unmanagedStruct.Plane.SinglePlane);
+ }
+ }
+ else if (unmanagedStruct.NumOfPlanes == 2)
+ {
+ return new DoublePlane(unmanagedStruct.Plane.DoublePlane);
+ }
+ else if (unmanagedStruct.NumOfPlanes == 3)
+ {
+ return new TriplePlane(unmanagedStruct.Plane.TriplePlane);
+ }
+
+ Debug.Fail("Unknown preview data!");
+ return null;
+ }
+
+ private static PlaneType GetPlaneType(CameraPreviewDataStruct unmanagedStruct)
+ {
+ if (unmanagedStruct.NumOfPlanes == 1)
+ {
+ if (unmanagedStruct.Format == CameraPixelFormat.H264 || unmanagedStruct.Format == CameraPixelFormat.Jpeg)
+ {
+ return PlaneType.EncodedPlane;
+ }
+ else
+ {
+ return PlaneType.SinglePlane;
+ }
+ }
+ else if (unmanagedStruct.NumOfPlanes == 2)
+ {
+ return PlaneType.DoublePlane;
+ }
+
+ return PlaneType.TriplePlane;
}
/// <summary>
/// The pixel format of the image.
/// </summary>
- public CameraPixelFormat Format
- {
- get;
- internal set;
- }
+ public CameraPixelFormat Format { get; }
/// <summary>
/// The width of the image.
/// </summary>
- public int Width
- {
- get;
- internal set;
- }
+ public int Width { get; }
/// <summary>
/// The height of the image.
/// </summary>
- public int Height
- {
- get;
- internal set;
- }
+ public int Height { get; }
/// <summary>
/// The time of capture of the image.
/// </summary>
- public uint TimeStamp
- {
- get;
- internal set;
- }
+ public uint TimeStamp { get; }
+
+ public IPreviewPlane Plane { get; }
+
+ public PlaneType PlaneType { get; }
}
}
-
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
/// </summary>
public class PreviewEventArgs : EventArgs
{
- internal PreviewEventArgs(PreviewData frame, PlaneType type)
+ internal PreviewEventArgs(PreviewData preview)
{
- Frame = frame;
- Type = type;
+ Preview = preview;
}
/// <summary>
/// PreviewData frame.
/// </summary>
- public PreviewData Frame { get; }
-
- /// <summary>
- /// Number of planes in image data.
- /// </summary>
- public PlaneType Type { get; }
+ public PreviewData Preview { get; }
}
}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* limitations under the License.
*/
-using System;
+using System.Runtime.InteropServices;
namespace Tizen.Multimedia
{
/// <summary>
/// The class containing image data which has single plane.
/// </summary>
- public class SinglePlaneData : PreviewData
+ public class SinglePlane : IPreviewPlane
{
- internal SinglePlaneData()
+ internal SinglePlane(Interop.Camera.SinglePlaneStruct unmanaged)
{
+ Data = new byte[unmanaged.DataLength];
+ Marshal.Copy(unmanaged.Data, Data, 0, (int)unmanaged.DataLength);
}
/// <summary>
/// The YUV plane data.
/// </summary>
- public byte[] YUVData
- {
- get;
- internal set;
- }
+ public byte[] Data { get; }
}
}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* limitations under the License.
*/
-using System;
+using System.Runtime.InteropServices;
namespace Tizen.Multimedia
{
/// <summary>
/// The class containing image data which has three planes.
/// </summary>
- public class TriplePlaneData : PreviewData
+ public class TriplePlane : IPreviewPlane
{
- internal TriplePlaneData()
+ internal TriplePlane(Interop.Camera.TriplePlaneStruct unmanaged)
{
+ Y = new byte[unmanaged.YLength];
+ U = new byte[unmanaged.ULength];
+ V = new byte[unmanaged.VLength];
+ Marshal.Copy(unmanaged.Y, Y, 0, (int)unmanaged.YLength);
+ Marshal.Copy(unmanaged.U, U, 0, (int)unmanaged.ULength);
+ Marshal.Copy(unmanaged.V, V, 0, (int)unmanaged.VLength);
}
/// <summary>
/// The Y plane data.
/// </summary>
- public byte[] YData
- {
- get;
- internal set;
- }
+ public byte[] Y { get; }
/// <summary>
/// The U plane data.
/// </summary>
- public byte[] UData
- {
- get;
- internal set;
- }
+ public byte[] U { get; }
/// <summary>
/// The V plane data.
/// </summary>
- public byte[] VData
- {
- get;
- internal set;
- }
+ public byte[] V { get; }
}
}
-using System;
+using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Tizen.Multimedia;
internal delegate void InterruptedCallback(CameraPolicy policy, CameraState previous, CameraState current, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void FocusChangedCallback(CameraFocusState state, IntPtr userData);
+ internal delegate void FocusStateChangedCallback(CameraFocusState state, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void ErrorCallback(CameraErrorCode error, CameraState current, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void HdrCaptureProgressCallback(int percent, IntPtr userData);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void DeviceStateChangedCallback(CameraDevice device, CameraDeviceState state, IntPtr userData);
[DllImport(Libraries.Camera, EntryPoint = "camera_create")]
internal static extern int Create(int device, out IntPtr handle);
internal static extern int StopContinuousCapture(IntPtr handle);
[DllImport(Libraries.Camera, EntryPoint = "camera_get_state")]
- internal static extern int GetState(IntPtr handle, out int state);
+ internal static extern int GetState(IntPtr handle, out CameraState state);
[DllImport(Libraries.Camera, EntryPoint = "camera_start_focusing")]
internal static extern int StartFocusing(IntPtr handle, bool continuous);
[DllImport(Libraries.Camera, EntryPoint = "camera_cancel_focusing")]
internal static extern int CancelFocusing(IntPtr handle);
- [DllImport(Libraries.Camera, EntryPoint = "camera_set_display")]
- internal static extern int SetDisplay(IntPtr handle, int displayType, IntPtr displayHandle);
-
[DllImport(Libraries.Camera, EntryPoint = "camera_set_preview_resolution")]
internal static extern int SetPreviewResolution(IntPtr handle, int width, int height);
internal static extern int GetCaptureResolution(IntPtr handle, out int width, out int height);
[DllImport(Libraries.Camera, EntryPoint = "camera_set_capture_format")]
- internal static extern int SetCaptureFormat(IntPtr handle, int format);
+ internal static extern int SetCaptureFormat(IntPtr handle, CameraPixelFormat format);
[DllImport(Libraries.Camera, EntryPoint = "camera_get_capture_format")]
- internal static extern int GetCaptureFormat(IntPtr handle, out int format);
+ internal static extern int GetCaptureFormat(IntPtr handle, out CameraPixelFormat format);
[DllImport(Libraries.Camera, EntryPoint = "camera_set_preview_format")]
- internal static extern int SetPreviewFormat(IntPtr handle, int format);
+ internal static extern int SetPreviewPixelFormat(IntPtr handle, CameraPixelFormat format);
[DllImport(Libraries.Camera, EntryPoint = "camera_get_preview_format")]
- internal static extern int GetPreviewFormat(IntPtr handle, out int format);
+ internal static extern int GetPreviewPixelFormat(IntPtr handle, out CameraPixelFormat format);
[DllImport(Libraries.Camera, EntryPoint = "camera_get_facing_direction")]
- internal static extern int GetFacingDirection(IntPtr handle, out int direction);
+ internal static extern int GetFacingDirection(IntPtr handle, out CameraFacingDirection direction);
[DllImport(Libraries.Camera, EntryPoint = "camera_get_flash_state")]
- internal static extern int GetFlashState(IntPtr handle, out int state);
+ internal static extern int GetFlashState(CameraDevice device, out CameraFlashState state);
[DllImport(Libraries.Camera, EntryPoint = "camera_set_preview_cb")]
internal static extern int SetPreviewCallback(IntPtr handle, PreviewCallback callback, IntPtr userData);
[DllImport(Libraries.Camera, EntryPoint = "camera_set_state_changed_cb")]
internal static extern int SetStateChangedCallback(IntPtr handle, StateChangedCallback callback, IntPtr userData);
+ [DllImport(Libraries.Camera, EntryPoint = "camera_add_device_state_changed_cb")]
+ internal static extern int SetDeviceStateChangedCallback(DeviceStateChangedCallback callback, IntPtr userData, out int callbackId);
+
[DllImport(Libraries.Camera, EntryPoint = "camera_unset_state_changed_cb")]
internal static extern int UnsetStateChangedCallback(IntPtr handle);
internal static extern int UnsetInterruptedCallback(IntPtr handle);
[DllImport(Libraries.Camera, EntryPoint = "camera_set_focus_changed_cb")]
- internal static extern int SetFocusChangedCallback(IntPtr handle, FocusChangedCallback callback, IntPtr userData);
+ internal static extern int SetFocusStateChangedCallback(IntPtr handle, FocusStateChangedCallback callback, IntPtr userData);
[DllImport(Libraries.Camera, EntryPoint = "camera_unset_focus_changed_cb")]
internal static extern int UnsetFocusChangedCallback(IntPtr handle);
[StructLayout(LayoutKind.Sequential)]
internal struct ImageDataStruct
{
- internal IntPtr data;
- internal uint size;
- internal int width;
- internal int height;
- internal CameraPixelFormat format;
- internal IntPtr exif;
- internal uint exifSize;
- }
-
- internal static ImageDataStruct IntPtrToImageDataStruct(IntPtr unmanagedVariable)
- {
- ImageDataStruct ImageStruct = Marshal.PtrToStructure<ImageDataStruct>(unmanagedVariable);
- return ImageStruct;
+ internal IntPtr Data;
+ internal uint DataLength;
+ internal int Width;
+ internal int Height;
+ internal CameraPixelFormat Format;
+ internal IntPtr Exif;
+ internal uint ExifLength;
}
[StructLayout(LayoutKind.Sequential)]
internal struct DetectedFaceStruct
{
- internal int id;
- internal int score;
- internal int x;
- internal int y;
- internal int width;
- internal int height;
+ internal int Id;
+ internal int Score;
+ internal int X;
+ internal int Y;
+ internal int Width;
+ internal int Height;
}
[StructLayout(LayoutKind.Sequential)]
- internal struct SinglePlane
+ internal struct SinglePlaneStruct
{
- internal IntPtr yuv;
- internal uint yuvsize;
+ internal IntPtr Data;
+ internal uint DataLength;
}
[StructLayout(LayoutKind.Sequential)]
- internal struct DoublePlane
+ internal struct DoublePlaneStruct
{
- internal IntPtr y;
- internal IntPtr uv;
- internal uint ysize;
- internal uint uvsize;
+ internal IntPtr Y;
+ internal IntPtr UV;
+ internal uint YLength;
+ internal uint UVLength;
}
[StructLayout(LayoutKind.Sequential)]
- internal struct TriplePlane
+ internal struct TriplePlaneStruct
{
- internal IntPtr y;
- internal IntPtr u;
- internal IntPtr v;
- internal uint ysize;
- internal uint usize;
- internal uint vsize;
+ internal IntPtr Y;
+ internal IntPtr U;
+ internal IntPtr V;
+ internal uint YLength;
+ internal uint ULength;
+ internal uint VLength;
}
[StructLayout(LayoutKind.Sequential)]
- internal struct EncodedPlane
+ internal struct EncodedPlaneStruct
{
- internal IntPtr data;
- internal uint size;
+ internal IntPtr Data;
+ internal uint DataLength;
}
[StructLayout(LayoutKind.Explicit)]
- internal struct PlaneData
+ internal struct PreviewPlaneStruct
{
[FieldOffsetAttribute(0)]
- internal SinglePlane singlePlane;
+ internal SinglePlaneStruct SinglePlane;
[FieldOffsetAttribute(0)]
- internal DoublePlane doublePlane;
+ internal DoublePlaneStruct DoublePlane;
[FieldOffsetAttribute(0)]
- internal TriplePlane triplePlane;
+ internal TriplePlaneStruct TriplePlane;
[FieldOffsetAttribute(0)]
- internal EncodedPlane encodedPlane;
+ internal EncodedPlaneStruct EncodedPlane;
}
[StructLayout(LayoutKind.Sequential)]
internal struct CameraPreviewDataStruct
{
- internal CameraPixelFormat format;
- internal int width;
- internal int height;
- internal int numOfPlanes;
- internal uint timestamp;
- internal PlaneData frameData;
- }
-
- internal static CameraPreviewDataStruct IntPtrToCameraPreviewDataStruct(IntPtr unmanagedVariable)
- {
- CameraPreviewDataStruct PreviewDataStruct = Marshal.PtrToStructure<CameraPreviewDataStruct>(unmanagedVariable);
- return PreviewDataStruct;
+ internal CameraPixelFormat Format;
+ internal int Width;
+ internal int Height;
+ internal int NumOfPlanes;
+ internal uint TimeStamp;
+ internal PreviewPlaneStruct Plane;
}
}
}
-using System;
+using System;
using System.Runtime.InteropServices;
using Tizen.Multimedia;
{
internal static partial class CameraDisplay
{
- [DllImport(Libraries.Camera, EntryPoint = "camera_set_display_rotation")]
- internal static extern int SetDisplayRotation(IntPtr handle, int rotation);
+ [DllImport(Libraries.Camera, EntryPoint = "camera_get_display_mode")]
+ internal static extern int GetMode(IntPtr handle, out CameraDisplayMode mode);
+
+ [DllImport(Libraries.Camera, EntryPoint = "camera_set_display_mode")]
+ internal static extern int SetMode(IntPtr handle, CameraDisplayMode mode);
+
+ [DllImport(Libraries.Camera, EntryPoint = "camera_is_display_visible")]
+ internal static extern int GetVisible(IntPtr handle, out bool visible);
+
+ [DllImport(Libraries.Camera, EntryPoint = "camera_set_display_visible")]
+ internal static extern int SetVisible(IntPtr handle, bool visible);
[DllImport(Libraries.Camera, EntryPoint = "camera_get_display_rotation")]
- internal static extern int GetDisplayRotation(IntPtr handle, out int rotation);
+ internal static extern int GetRotation(IntPtr handle, out CameraRotation rotation);
- [DllImport(Libraries.Camera, EntryPoint = "camera_set_display_flip")]
- internal static extern int SetDisplayFlip(IntPtr handle, int flip);
+ [DllImport(Libraries.Camera, EntryPoint = "camera_set_display_rotation")]
+ internal static extern int SetRotation(IntPtr handle, CameraRotation rotation);
[DllImport(Libraries.Camera, EntryPoint = "camera_get_display_flip")]
- internal static extern int GetDisplayFlip(IntPtr handle, out int flip);
+ internal static extern int GetFlip(IntPtr handle, out CameraFlip flip);
- [DllImport(Libraries.Camera, EntryPoint = "camera_set_display_visible")]
- internal static extern int SetDisplayVisible(IntPtr handle, bool visible);
+ [DllImport(Libraries.Camera, EntryPoint = "camera_set_display_flip")]
+ internal static extern int SetFlip(IntPtr handle, CameraFlip flip);
- [DllImport(Libraries.Camera, EntryPoint = "camera_is_display_visible")]
- internal static extern int GetDisplayVisible(IntPtr handle, out bool visible);
+ [DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_display_roi_area")]
+ internal static extern int GetRoiArea(IntPtr handle, out int x, out int y, out int width, out int height);
- [DllImport(Libraries.Camera, EntryPoint = "camera_set_display_mode")]
- internal static extern int SetDisplayMode(IntPtr handle, int mode);
+ [DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_display_roi_area")]
+ internal static extern int SetRoiArea(IntPtr handle, int x, int y, int width, int height);
- [DllImport(Libraries.Camera, EntryPoint = "camera_get_display_mode")]
- internal static extern int GetDisplayMode(IntPtr handle, out int mode);
+ [DllImport(Libraries.Camera, EntryPoint = "camera_set_display")]
+ internal static extern int SetInfo(IntPtr handle, CameraDisplayType displayType, IntPtr displayHandle);
}
}
internal static partial class Interop
{
- internal static partial class CameraFeature
+ internal static partial class CameraFeatures
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate bool PreviewResolutionCallback(int Width, int Height, IntPtr userData);
internal delegate bool TheaterModeCallback(CameraTheaterMode mode, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate bool WhitebalanceCallback(CameraWhitebalance whitebalance, IntPtr userData);
+ internal delegate bool WhitebalanceCallback(CameraWhiteBalance whitebalance, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate bool EffectCallback(CameraEffectMode effect, IntPtr userData);
[DllImport(Libraries.Camera, EntryPoint = "camera_is_supported_continuous_capture")]
[return: MarshalAs(UnmanagedType.I1)]
- internal static extern bool ContinuousCaptureSupport(IntPtr handle);
+ internal static extern bool IsContinuousCaptureSupported(IntPtr handle);
[DllImport(Libraries.Camera, EntryPoint = "camera_is_supported_face_detection")]
[return: MarshalAs(UnmanagedType.I1)]
- internal static extern bool FaceDetectionSupport(IntPtr handle);
+ internal static extern bool IsFaceDetectionSupported(IntPtr handle);
[DllImport(Libraries.Camera, EntryPoint = "camera_is_supported_zero_shutter_lag")]
[return: MarshalAs(UnmanagedType.I1)]
- internal static extern bool ZeroShutterLagSupport(IntPtr handle);
+ internal static extern bool IsZeroShutterLagSupported(IntPtr handle);
[DllImport(Libraries.Camera, EntryPoint = "camera_is_supported_media_packet_preview_cb")]
[return: MarshalAs(UnmanagedType.I1)]
- internal static extern bool MediaPacketPreviewCallbackSupport(IntPtr handle);
+ internal static extern bool IsMediaPacketPreviewCallbackSupported(IntPtr handle);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_is_supported_hdr_capture")]
[return: MarshalAs(UnmanagedType.I1)]
- internal static extern bool HdrCaptureSupport(IntPtr handle);
+ internal static extern bool IsHdrCaptureSupported(IntPtr handle);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_is_supported_anti_shake")]
[return: MarshalAs(UnmanagedType.I1)]
- internal static extern bool AntiShakeSupport(IntPtr handle);
+ internal static extern bool IsAntiShakeSupported(IntPtr handle);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_is_supported_video_stabilization")]
[return: MarshalAs(UnmanagedType.I1)]
- internal static extern bool VideoStabilizationSupport(IntPtr handle);
+ internal static extern bool IsVideoStabilizationSupported(IntPtr handle);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_is_supported_auto_contrast")]
[return: MarshalAs(UnmanagedType.I1)]
- internal static extern bool AutoContrastSupport(IntPtr handle);
+ internal static extern bool IsAutoContrastSupported(IntPtr handle);
[DllImport(Libraries.Camera, EntryPoint = "camera_foreach_supported_preview_resolution")]
internal static extern int SupportedPreviewResolutions(IntPtr handle, PreviewResolutionCallback callback, IntPtr userData);
internal static extern int SupportedCaptureResolutions(IntPtr handle, CaptureResolutionCallback callback, IntPtr userData);
[DllImport(Libraries.Camera, EntryPoint = "camera_foreach_supported_capture_format")]
- internal static extern int SupportedCaptureFormats(IntPtr handle, CaptureFormatCallback callback, IntPtr userData);
+ internal static extern int SupportedCapturePixelFormats(IntPtr handle, CaptureFormatCallback callback, IntPtr userData);
[DllImport(Libraries.Camera, EntryPoint = "camera_foreach_supported_preview_format")]
- internal static extern int SupportedPreviewFormats(IntPtr handle, PreviewFormatCallback callback, IntPtr userData);
+ internal static extern int SupportedPreviewPixelFormats(IntPtr handle, PreviewFormatCallback callback, IntPtr userData);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_fps")]
- internal static extern int SupportedFps(IntPtr handle, FpsCallback callback, IntPtr userData);
+ internal static extern int SupportedPreviewFps(IntPtr handle, FpsCallback callback, IntPtr userData);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_fps_by_resolution")]
- internal static extern int SupportedFpsByResolution(IntPtr handle, int width, int height, FpsByResolutionCallback callback, IntPtr userData);
+ internal static extern int SupportedPreviewFpsByResolution(IntPtr handle, int width, int height, FpsByResolutionCallback callback, IntPtr userData);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_foreach_supported_af_mode")]
internal static extern int SupportedAfModes(IntPtr handle, AfModeCallback callback, IntPtr userData);
-using System;
+using System;
using System.Runtime.InteropServices;
using Tizen.Multimedia;
internal static partial class Interop
{
- internal static partial class CameraSetting
+ internal static partial class CameraSettings
{
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_preview_fps")]
- internal static extern int SetPreviewFps(IntPtr handle, int fps);
+ internal static extern int SetPreviewFps(IntPtr handle, CameraFps fps);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_preview_fps")]
- internal static extern int GetPreviewFps(IntPtr handle, out int fps);
+ internal static extern int GetPreviewFps(IntPtr handle, out CameraFps fps);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_image_quality")]
internal static extern int SetImageQuality(IntPtr handle, int quality);
internal static extern int GetZoomRange(IntPtr handle, out int min, out int max);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_af_mode")]
- internal static extern int SetAfMode(IntPtr handle, int mode);
+ internal static extern int SetAutoFocusMode(IntPtr handle, CameraAutoFocusMode mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_af_mode")]
- internal static extern int GetAfMode(IntPtr handle, out int mode);
+ internal static extern int GetAutoFocusMode(IntPtr handle, out CameraAutoFocusMode mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_af_area")]
- internal static extern int SetAfArea(IntPtr handle, int x, int y);
+ internal static extern int SetAutoFocusArea(IntPtr handle, int x, int y);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_clear_af_area")]
- internal static extern int ClearAfArea(IntPtr handle);
+ internal static extern int ClearAutoFocusArea(IntPtr handle);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_exposure_mode")]
- internal static extern int SetExposureMode(IntPtr handle, int mode);
+ internal static extern int SetExposureMode(IntPtr handle, CameraExposureMode mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_exposure_mode")]
- internal static extern int GetExposureMode(IntPtr handle, out int mode);
+ internal static extern int GetExposureMode(IntPtr handle, out CameraExposureMode mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_exposure")]
internal static extern int SetExposure(IntPtr handle, int value);
internal static extern int GetExposureRange(IntPtr handle, out int min, out int max);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_iso")]
- internal static extern int SetIso(IntPtr handle, int iso);
+ internal static extern int SetIso(IntPtr handle, CameraIsoLevel iso);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_iso")]
- internal static extern int GetIso(IntPtr handle, out int iso);
+ internal static extern int GetIso(IntPtr handle, out CameraIsoLevel iso);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_theater_mode")]
- internal static extern int SetTheaterMode(IntPtr handle, int mode);
+ internal static extern int SetTheaterMode(IntPtr handle, CameraTheaterMode mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_theater_mode")]
- internal static extern int GetTheaterMode(IntPtr handle, out int mode);
+ internal static extern int GetTheaterMode(IntPtr handle, out CameraTheaterMode mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_brightness")]
internal static extern int SetBrightness(IntPtr handle, int level);
internal static extern int GetContrastRange(IntPtr handle, out int min, out int max);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_whitebalance")]
- internal static extern int SetWhitebalance(IntPtr handle, int level);
+ internal static extern int SetWhitebalance(IntPtr handle, CameraWhiteBalance level);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_whitebalance")]
- internal static extern int GetWhitebalance(IntPtr handle, out int level);
+ internal static extern int GetWhiteBalance(IntPtr handle, out CameraWhiteBalance level);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_effect")]
- internal static extern int SetEffect(IntPtr handle, int level);
+ internal static extern int SetEffect(IntPtr handle, CameraEffectMode mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_effect")]
- internal static extern int GetEffect(IntPtr handle, out int level);
+ internal static extern int GetEffect(IntPtr handle, out CameraEffectMode mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_scene_mode")]
- internal static extern int SetSceneMode(IntPtr handle, int level);
+ internal static extern int SetSceneMode(IntPtr handle, CameraSceneMode mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_scene_mode")]
- internal static extern int GetSceneMode(IntPtr handle, out int level);
+ internal static extern int GetSceneMode(IntPtr handle, out CameraSceneMode mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_enable_tag")]
internal static extern int EnableTag(IntPtr handle, bool enable);
internal static extern int GetTagSoftware(IntPtr handle, out IntPtr software);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_tag_orientation")]
- internal static extern int SetTagOrientation(IntPtr handle, int orientation);
+ internal static extern int SetTagOrientation(IntPtr handle, CameraTagOrientation orientation);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_tag_orientation")]
- internal static extern int GetTagOrientation(IntPtr handle, out int orientation);
+ internal static extern int GetTagOrientation(IntPtr handle, out CameraTagOrientation orientation);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_geotag")]
internal static extern int SetGeotag(IntPtr handle, double latitude, double longtitude, double altitude);
internal static extern int RemoveGeotag(IntPtr handle);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_flash_mode")]
- internal static extern int SetFlashMode(IntPtr handle, int mode);
+ internal static extern int SetFlashMode(IntPtr handle, CameraFlashMode mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_flash_mode")]
- internal static extern int GetFlashMode(IntPtr handle, out int mode);
+ internal static extern int GetFlashMode(IntPtr handle, out CameraFlashMode mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_lens_orientation")]
internal static extern int GetLensOrientation(IntPtr handle, out int angle);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_stream_rotation")]
- internal static extern int SetStreamRotation(IntPtr handle, int mode);
+ internal static extern int SetStreamRotation(IntPtr handle, CameraRotation mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_stream_rotation")]
- internal static extern int GetStreamRotation(IntPtr handle, out int mode);
+ internal static extern int GetStreamRotation(IntPtr handle, out CameraRotation mode);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_stream_flip")]
- internal static extern int SetFlip(IntPtr handle, int flip);
+ internal static extern int SetFlip(IntPtr handle, CameraFlip flip);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_stream_flip")]
- internal static extern int GetFlip(IntPtr handle, out int flip);
+ internal static extern int GetFlip(IntPtr handle, out CameraFlip flip);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_hdr_mode")]
- internal static extern int SetHdrMode(IntPtr handle, int hdr);
+ internal static extern int SetHdrMode(IntPtr handle, CameraHdrMode hdr);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_hdr_mode")]
- internal static extern int GetHdrMode(IntPtr handle, out int hdr);
+ internal static extern int GetHdrMode(IntPtr handle, out CameraHdrMode hdr);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_enable_anti_shake")]
internal static extern int EnableAntiShake(IntPtr handle, bool enable);
internal static extern int DisableShutterSound(IntPtr handle, bool disable);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_pan")]
- internal static extern int SetPan(IntPtr handle, int type, int step);
+ internal static extern int SetPan(IntPtr handle, CameraPtzMoveType type, int step);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_pan")]
internal static extern int GetPan(IntPtr handle, out int step);
internal static extern int GetPanRange(IntPtr handle, out int min, out int max);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_tilt")]
- internal static extern int SetTilt(IntPtr handle, int type, int step);
+ internal static extern int SetTilt(IntPtr handle, CameraPtzMoveType type, int step);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_tilt")]
internal static extern int GetTilt(IntPtr handle, out int step);
[DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_ptz_type")]
internal static extern int SetPtzType(IntPtr handle, int type);
-
- [DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_display_roi_area")]
- internal static extern int SetDisplayRoiArea(IntPtr handle, int x, int y, int width, int height);
-
- [DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_display_roi_area")]
- internal static extern int GetDisplayRoiArea(IntPtr handle, out int x, out int y, out int width, out int height);
}
}
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
- <PropertyGroup>\r
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
- <ProjectGuid>{0CE698B0-4849-4096-9D7F-30E611F50DAD}</ProjectGuid>\r
- <OutputType>Library</OutputType>\r
- <AppDesignerFolder>Properties</AppDesignerFolder>\r
- <RootNamespace>Tizen.Multimedia</RootNamespace>\r
- <AssemblyName>Tizen.Multimedia</AssemblyName>\r
- <FileAlignment>512</FileAlignment>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>\r
- <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>\r
- <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>\r
- <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>\r
- <NoStdLib>true</NoStdLib>\r
- <NoWarn>$(NoWarn);1701;1702</NoWarn>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
- <DebugSymbols>true</DebugSymbols>\r
- <DebugType>full</DebugType>\r
- <Optimize>false</Optimize>\r
- <OutputPath>bin\Debug\</OutputPath>\r
- <DefineConstants>DEBUG;TRACE</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
- <DebugType>pdbonly</DebugType>\r
- <Optimize>true</Optimize>\r
- <OutputPath>bin\Release\</OutputPath>\r
- <DefineConstants>TRACE</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <SignAssembly>true</SignAssembly>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <AssemblyOriginatorKeyFile>Tizen.Multimedia.snk</AssemblyOriginatorKeyFile>\r
- </PropertyGroup>\r
- <ItemGroup>\r
- <Compile Include="*\*.cs" />\r
- </ItemGroup>\r
- <ItemGroup>\r
- <None Include="Tizen.Multimedia.nuspec" />\r
- <None Include="Tizen.Multimedia.project.json" />\r
- <None Include="Tizen.Multimedia.snk" />\r
- </ItemGroup>\r
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.\r
- Other similar extension points exist, see Microsoft.Common.targets.\r
- <Target Name="BeforeBuild">\r
- </Target>\r
- <Target Name="AfterBuild">\r
- </Target>\r
- -->\r
- <PropertyGroup>\r
- <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and\r
- https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild\r
- -->\r
- <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two\r
- properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and\r
- to prevent it from outputting a warning (MSB3644).\r
- -->\r
- <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>\r
- <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>\r
- <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>\r
- </PropertyGroup>\r
-</Project>\r
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{0CE698B0-4849-4096-9D7F-30E611F50DAD}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.Multimedia</RootNamespace>
+ <AssemblyName>Tizen.Multimedia</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup>
+ <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>
+ <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
+ <NoStdLib>true</NoStdLib>
+ <NoWarn>$(NoWarn);1701;1702</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Tizen.Multimedia.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="*\*.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Tizen.Multimedia.nuspec" />
+ <None Include="Tizen.Multimedia.project.json" />
+ <None Include="Tizen.Multimedia.snk" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+ <PropertyGroup>
+ <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and
+ https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild
+ -->
+ <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two
+ properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and
+ to prevent it from outputting a warning (MSB3644).
+ -->
+ <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>
+ <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
+ <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
-{\r
- "dependencies": {\r
- "ElmSharp": "1.1.0-*",\r
- "NETStandard.Library": "1.6.0",\r
- "Tizen": "1.0.2",\r
- "Tizen.Applications": "1.2.0"\r
- },\r
- "frameworks": {\r
- "netstandard1.3": {}\r
- }\r
-}\r
+{
+ "dependencies": {
+ "ElmSharp": "1.1.0-*",
+ "NETStandard.Library": "1.6.0",
+ "Tizen": "1.0.2",
+ "Tizen.Applications": "1.2.4"
+ },
+ "frameworks": {
+ "netstandard1.3": {}
+ }
+}
\ No newline at end of file