From: hsgwon Date: Tue, 9 Jul 2019 07:54:29 +0000 (+0900) Subject: [MediaContent] Add face Insert API (#922) X-Git-Tag: submit/tizen/20190710.005202~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2c4ae8c255da3f625d301101625086ea98cc494c;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [MediaContent] Add face Insert API (#922) * [MediaContent] Add face Insert API --- diff --git a/src/Tizen.Content.MediaContent/Interop/Interop.Face.cs b/src/Tizen.Content.MediaContent/Interop/Interop.Face.cs index ca3df6b6c..bebc695c5 100644 --- a/src/Tizen.Content.MediaContent/Interop/Interop.Face.cs +++ b/src/Tizen.Content.MediaContent/Interop/Interop.Face.cs @@ -22,12 +22,15 @@ internal static partial class Interop { internal static partial class Face { - [DllImport(Libraries.MediaContent, EntryPoint = "media_face_clone")] - internal static extern MediaContentError Clone(out IntPtr dst, IntPtr src); + [DllImport(Libraries.MediaContent, EntryPoint = "media_face_create")] + internal static extern MediaContentError Create(string mediaId, out IntPtr face); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_destroy")] internal static extern MediaContentError Destroy(IntPtr face); + [DllImport(Libraries.MediaContent, EntryPoint = "media_face_clone")] + internal static extern MediaContentError Clone(out IntPtr dst, IntPtr src); + [DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_face_id")] internal static extern MediaContentError GetId(IntPtr face, out IntPtr faceId); @@ -44,9 +47,6 @@ internal static partial class Interop [DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_tag")] internal static extern MediaContentError GetTag(IntPtr face, out IntPtr tag); - [DllImport(Libraries.MediaContent, EntryPoint = "media_face_create")] - internal static extern MediaContentError Create(string mediaId, out IntPtr face); - [DllImport(Libraries.MediaContent, EntryPoint = "media_face_set_face_rect")] internal static extern MediaContentError SetFaceRect(IntPtr face, int x, int y, int w, int h); @@ -57,7 +57,7 @@ internal static partial class Interop internal static extern MediaContentError SetTag(IntPtr face, string tag); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_insert_to_db")] - internal static extern MediaContentError InsertToDb(IntPtr handle); + internal static extern MediaContentError Insert(IntPtr handle); [DllImport(Libraries.MediaContent, EntryPoint = "media_face_update_to_db")] internal static extern MediaContentError Update(IntPtr face); diff --git a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/FaceInfoCommand.cs b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/FaceInfoCommand.cs index aee0da090..63c3b50fb 100644 --- a/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/FaceInfoCommand.cs +++ b/src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/FaceInfoCommand.cs @@ -140,5 +140,80 @@ namespace Tizen.Content.MediaContent Interop.Face.Destroy(handle); } } + + /// + /// Inserts a new face information to the database with the specified media ID, area, orientation. + /// + /// http://tizen.org/privilege/content.write + /// The media ID to be associated with. + /// The region of face in the media. + /// The orientation of specified media. + /// The containing the results. + /// The is disconnected. + /// The has already been disposed of. + /// An error occurred while executing the command. + /// is null. + /// + /// is a zero-length string, contains only white space.
+ /// -or-
+ /// is not valid enumeration. + ///
+ /// The caller has no required privilege. + /// 6 + public FaceInfo Insert(string mediaId, Rectangle area, Orientation orientation) + { + return Insert(mediaId, area, orientation, null); + } + + /// + /// Inserts a new face information to the database with the specified media ID, area, orientation, and tag. + /// + /// http://tizen.org/privilege/content.write + /// The media ID to be associated with. + /// The region of face in the media. + /// The orientation of specified media. + /// The tag value. + /// The containing the results. + /// The is disconnected. + /// The has already been disposed of. + /// An error occurred while executing the command. + /// is null. + /// + /// is a zero-length string, contains only white space.
+ /// -or-
+ /// is not valid enumeration. + ///
+ /// The caller has no required privilege. + /// 6 + public FaceInfo Insert(string mediaId, Rectangle area, Orientation orientation, string tag) + { + ValidateDatabase(); + + ValidationUtil.ValidateNotNullOrEmpty(mediaId, nameof(mediaId)); + ValidationUtil.ValidateEnum(typeof(Orientation), orientation, nameof(orientation)); + + Interop.Face.Create(mediaId, out IntPtr handle).ThrowIfError("Failed to create face handle"); + + try + { + Interop.Face.SetFaceRect(handle, area.X, area.Y, area.Width, area.Height). + ThrowIfError("Failed to set face area"); + + Interop.Face.SetOrientation(handle, orientation).ThrowIfError("Failed to set face orientation"); + + if (tag != null) + { + Interop.Face.SetTag(handle, tag).ThrowIfError("Failed to set face tag"); + } + + Interop.Face.Insert(handle).ThrowIfError("Failed to insert face information"); + + return new FaceInfo(handle); + } + finally + { + Interop.Face.Destroy(handle).ThrowIfError("Failed to destroy face handle"); + } + } } }