[Camera] Add new preview data format and type (#379)
authorhsgwon <haesu.gwon@samsung.com>
Thu, 23 Aug 2018 05:38:45 +0000 (14:38 +0900)
committerGitHub <noreply@github.com>
Thu, 23 Aug 2018 05:38:45 +0000 (14:38 +0900)
* [Camera] Add new preview data format and type

src/Tizen.Multimedia.Camera/Camera/CameraEnums.cs
src/Tizen.Multimedia.Camera/Camera/CameraException.cs
src/Tizen.Multimedia.Camera/Camera/DepthPlane.cs [new file with mode: 0644]
src/Tizen.Multimedia.Camera/Camera/PreviewFrame.cs [changed mode: 0755->0644]
src/Tizen.Multimedia.Camera/Interop/Interop.Camera.cs [changed mode: 0755->0644]

index dd7f557..9aadb2d 100644 (file)
@@ -229,7 +229,12 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Encoded pixel format : H264.
         /// </summary>
-        H264 = 15
+        H264 = 15,
+        /// <summary>
+        /// Depth pixel format
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        Invz
     }
 
     /// <summary>
@@ -905,6 +910,11 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Encoded plane data.
         /// </summary>
-        EncodedPlane
+        EncodedPlane,
+        /// <summary>
+        /// Depth plane data.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        DepthPlane
     }
 }
index 345e5f4..7fe3aea 100644 (file)
@@ -35,6 +35,7 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Initializes a new instance of the <see cref="CameraException"/> class with a specified error message.
         /// </summary>
+        /// <param name="message">A specified error message.</param>
         /// <since_tizen> 3 </since_tizen>
         public CameraException(string message) : base(message)
         {
@@ -58,6 +59,7 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Initializes a new instance of the <see cref="CameraDeviceException"/> class with a specified error message.
         /// </summary>
+        /// <param name="message">A specified error message.</param>
         /// <since_tizen> 3 </since_tizen>
         public CameraDeviceException(string message) : base(message)
         {
@@ -81,6 +83,7 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Initializes a new instance of the <see cref="CameraDeviceNotFoundException"/> class with a specified error message.
         /// </summary>
+        /// <param name="message">A specified error message.</param>
         /// <since_tizen> 3 </since_tizen>
         public CameraDeviceNotFoundException(string message) : base(message)
         {
diff --git a/src/Tizen.Multimedia.Camera/Camera/DepthPlane.cs b/src/Tizen.Multimedia.Camera/Camera/DepthPlane.cs
new file mode 100644 (file)
index 0000000..fe169ba
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2018 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.Runtime.InteropServices;
+using static Interop.Camera;
+
+namespace Tizen.Multimedia
+{
+    /// <summary>
+    /// The class containing the depth data for subject distance.
+    /// </summary>
+    /// <since_tizen> 5 </since_tizen>
+    public class DepthPlane : IPreviewPlane
+    {
+        internal DepthPlane(DepthPlaneStruct unmanagedData)
+        {
+            Data = new byte[unmanagedData.DataLength];
+            Marshal.Copy(unmanagedData.Data, Data, 0, (int)unmanagedData.DataLength);
+        }
+
+        /// <summary>
+        /// The buffer containing the depth data.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        public byte[] Data { get; }
+    }
+}
old mode 100755 (executable)
new mode 100644 (file)
index edb233b..88369a8
@@ -46,6 +46,10 @@ namespace Tizen.Multimedia
                 {
                     return new EncodedPlane(unmanagedStruct.Plane.EncodedPlane);
                 }
+                else if (unmanagedStruct.Format == CameraPixelFormat.Invz)
+                {
+                    return new DepthPlane(unmanagedStruct.Plane.DepthPlane);
+                }
                 else
                 {
                     return new SinglePlane(unmanagedStruct.Plane.SinglePlane);
@@ -72,6 +76,10 @@ namespace Tizen.Multimedia
                 {
                     return PlaneType.EncodedPlane;
                 }
+                else if (unmanagedStruct.Format == CameraPixelFormat.Invz)
+                {
+                    return PlaneType.DepthPlane;
+                }
                 else
                 {
                     return PlaneType.SinglePlane;
old mode 100755 (executable)
new mode 100644 (file)
index affcce6..d1b58dc
@@ -255,6 +255,13 @@ internal static partial class Interop
             internal uint DataLength;
         }
 
+        [StructLayout(LayoutKind.Sequential)]
+        internal struct DepthPlaneStruct
+        {
+            internal IntPtr Data;
+            internal uint DataLength;
+        }
+
         [StructLayout(LayoutKind.Explicit)]
         internal struct PreviewPlaneStruct
         {
@@ -266,6 +273,8 @@ internal static partial class Interop
             internal TriplePlaneStruct TriplePlane;
             [FieldOffsetAttribute(0)]
             internal EncodedPlaneStruct EncodedPlane;
+            [FieldOffsetAttribute(0)]
+            internal DepthPlaneStruct DepthPlane;
         }
 
         [StructLayout(LayoutKind.Sequential)]