2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Runtime.InteropServices;
20 using Tizen.Content.MediaContent;
22 internal static partial class Interop
24 internal static partial class MediaInformation
26 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
27 internal delegate void MediaThumbnailCompletedCallback(MediaContentError error, string filePath, IntPtr UserData);
29 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
30 internal delegate bool MediaTagCallback(IntPtr tagHandle, IntPtr UserData);
32 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
33 internal delegate bool MediaBookmarkCallback(IntPtr bookmarkHandle, IntPtr UserData);
35 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
36 internal delegate bool MediaFaceCallback(IntPtr bookmarkHandle, IntPtr UserData);
38 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
39 internal delegate void MediaInsertCompletedCallback(MediaContentError error, IntPtr UserData);
41 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
42 internal delegate void MediaInsertBurstShotCompletedCallback(MediaContentError error, IntPtr UserData);
44 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
45 internal delegate bool MediaInformationCallback(IntPtr mediaInformationHandle, IntPtr UserData);
47 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_insert_to_db", CallingConvention = CallingConvention.Cdecl)]
48 internal static extern MediaContentError Insert(string filePath, out SafeMediaInformationHandle info);
50 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_insert_batch_to_db", CallingConvention = CallingConvention.Cdecl)]
51 internal static extern MediaContentError BatchInsert(string[] filePathArray, int arrayLength, MediaInsertCompletedCallback callback, IntPtr userData);
53 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_insert_burst_shot_to_db", CallingConvention = CallingConvention.Cdecl)]
54 internal static extern MediaContentError BurstShotInsert(string[] filePathArray, int arrayLength, MediaInsertBurstShotCompletedCallback callback, IntPtr userData);
56 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_delete_from_db", CallingConvention = CallingConvention.Cdecl)]
57 internal static extern MediaContentError Delete(string mediaId);
59 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_delete_batch_from_db", CallingConvention = CallingConvention.Cdecl)]
60 internal static extern MediaContentError BatchDelete(IntPtr filter);
62 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_destroy", CallingConvention = CallingConvention.Cdecl)]
63 internal static extern MediaContentError Destroy(IntPtr mediaInformationHandle);
65 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_clone", CallingConvention = CallingConvention.Cdecl)]
66 internal static extern MediaContentError Clone(out SafeMediaInformationHandle dst, IntPtr src);
68 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_count_from_db", CallingConvention = CallingConvention.Cdecl)]
69 internal static extern MediaContentError GetMediaCount(IntPtr filter, out int mediaCount);
71 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_foreach_media_from_db", CallingConvention = CallingConvention.Cdecl)]
72 internal static extern MediaContentError GetAllMedia(IntPtr filter, MediaInformationCallback callback, IntPtr userData);
74 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_tag_count_from_db", CallingConvention = CallingConvention.Cdecl)]
75 internal static extern MediaContentError GetTagCount(string mediaId, IntPtr filter, out int tagCount);
77 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_foreach_tag_from_db", CallingConvention = CallingConvention.Cdecl)]
78 internal static extern MediaContentError GetAllTags(string mediaId, IntPtr filter, MediaTagCallback callback, IntPtr userData);
80 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_bookmark_count_from_db", CallingConvention = CallingConvention.Cdecl)]
81 internal static extern MediaContentError GetBookmarkCount(string mediaId, IntPtr filter, out int bookmarkCount);
83 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_foreach_bookmark_from_db", CallingConvention = CallingConvention.Cdecl)]
84 internal static extern MediaContentError GetAllBookmarks(string mediaId, IntPtr filter, MediaBookmarkCallback callback, IntPtr userData);
86 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_face_count_from_db", CallingConvention = CallingConvention.Cdecl)]
87 internal static extern MediaContentError GetFaceCount(string mediaId, IntPtr filter, out int bookmarkCount);
89 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_foreach_face_from_db", CallingConvention = CallingConvention.Cdecl)]
90 internal static extern MediaContentError GetAllFaces(string mediaId, IntPtr filter, MediaFaceCallback callback, IntPtr userData);
92 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_image", CallingConvention = CallingConvention.Cdecl)]
93 internal static extern MediaContentError GetImage(IntPtr mediaInformationHandle, out Interop.ImageInformation.SafeImageInformationHandle image);
95 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_video", CallingConvention = CallingConvention.Cdecl)]
96 internal static extern MediaContentError GetVideo(IntPtr mediaInformationHandle, out Interop.VideoInformation.SafeVideoInformationHandle video);
98 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_audio", CallingConvention = CallingConvention.Cdecl)]
99 internal static extern MediaContentError GetAudio(IntPtr mediaInformationHandle, out Interop.AudioInformation.SafeAudioInformationHandle audio);
101 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_id", CallingConvention = CallingConvention.Cdecl)]
102 internal static extern MediaContentError GetMediaId(SafeMediaInformationHandle mediaInformationHandle, out IntPtr mediaId);
104 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_file_path", CallingConvention = CallingConvention.Cdecl)]
105 internal static extern MediaContentError GetFilePath(SafeMediaInformationHandle mediaInformationHandle, out IntPtr filePath);
107 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_display_name", CallingConvention = CallingConvention.Cdecl)]
108 internal static extern MediaContentError GetDisplayName(SafeMediaInformationHandle mediaInformationHandle, out IntPtr name);
110 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_type", CallingConvention = CallingConvention.Cdecl)]
111 internal static extern MediaContentError GetMediaType(SafeMediaInformationHandle mediaInformationHandle, out MediaContentType type);
113 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_mime_type", CallingConvention = CallingConvention.Cdecl)]
114 internal static extern MediaContentError GetMimeType(SafeMediaInformationHandle mediaInformationHandle, out IntPtr mimeType);
116 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_size", CallingConvention = CallingConvention.Cdecl)]
117 internal static extern MediaContentError GetSize(SafeMediaInformationHandle mediaInformationHandle, out long size);
119 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_added_time", CallingConvention = CallingConvention.Cdecl)]
120 internal static extern MediaContentError GetAddedTime(SafeMediaInformationHandle mediaInformationHandle, out int addedTime);
122 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_modified_time", CallingConvention = CallingConvention.Cdecl)]
123 internal static extern MediaContentError GetModifiedTime(SafeMediaInformationHandle mediaInformationHandle, out int time);
125 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_timeline", CallingConvention = CallingConvention.Cdecl)]
126 internal static extern MediaContentError GetTimeline(SafeMediaInformationHandle mediaInformationHandle, out int time);
128 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_thumbnail_path", CallingConvention = CallingConvention.Cdecl)]
129 internal static extern MediaContentError GetThumbnailPath(SafeMediaInformationHandle mediaInformationHandle, out IntPtr filePath);
131 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_description", CallingConvention = CallingConvention.Cdecl)]
132 internal static extern MediaContentError GetDescription(SafeMediaInformationHandle mediaInformationHandle, out IntPtr description);
134 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_longitude", CallingConvention = CallingConvention.Cdecl)]
135 internal static extern MediaContentError GetLongitude(SafeMediaInformationHandle mediaInformationHandle, out double longitude);
137 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_latitude", CallingConvention = CallingConvention.Cdecl)]
138 internal static extern MediaContentError GetLatitude(SafeMediaInformationHandle mediaInformationHandle, out double latitude);
140 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_altitude", CallingConvention = CallingConvention.Cdecl)]
141 internal static extern MediaContentError GetAltitude(SafeMediaInformationHandle mediaInformationHandle, out double altitude);
143 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_weather", CallingConvention = CallingConvention.Cdecl)]
144 internal static extern MediaContentError GetWeather(SafeMediaInformationHandle mediaInformationHandle, out IntPtr weather);
146 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_rating", CallingConvention = CallingConvention.Cdecl)]
147 internal static extern MediaContentError GetRating(SafeMediaInformationHandle mediaInformationHandle, out int rating);
149 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_favorite", CallingConvention = CallingConvention.Cdecl)]
150 internal static extern MediaContentError GetFavorite(SafeMediaInformationHandle mediaInformationHandle, out bool favorite);
152 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_author", CallingConvention = CallingConvention.Cdecl)]
153 internal static extern MediaContentError GetAuthor(SafeMediaInformationHandle mediaInformationHandle, out IntPtr author);
155 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_provider", CallingConvention = CallingConvention.Cdecl)]
156 internal static extern MediaContentError GetProvider(SafeMediaInformationHandle mediaInformationHandle, out IntPtr provider);
158 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_content_name", CallingConvention = CallingConvention.Cdecl)]
159 internal static extern MediaContentError GetContentName(SafeMediaInformationHandle mediaInformationHandle, out IntPtr contentName);
161 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_title", CallingConvention = CallingConvention.Cdecl)]
162 internal static extern MediaContentError GetTitle(SafeMediaInformationHandle mediaInformationHandle, out IntPtr title);
164 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_category", CallingConvention = CallingConvention.Cdecl)]
165 internal static extern MediaContentError GetCategory(SafeMediaInformationHandle mediaInformationHandle, out IntPtr category);
167 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_location_tag", CallingConvention = CallingConvention.Cdecl)]
168 internal static extern MediaContentError GetLocationTag(SafeMediaInformationHandle mediaInformationHandle, out IntPtr locationTag);
170 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_age_rating", CallingConvention = CallingConvention.Cdecl)]
171 internal static extern MediaContentError GetAgeRating(SafeMediaInformationHandle mediaInformationHandle, out IntPtr ageRating);
173 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_keyword", CallingConvention = CallingConvention.Cdecl)]
174 internal static extern MediaContentError GetKeyword(SafeMediaInformationHandle mediaInformationHandle, out IntPtr keyword);
176 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_storage_id", CallingConvention = CallingConvention.Cdecl)]
177 internal static extern MediaContentError GetStorageId(SafeMediaInformationHandle mediaInformationHandle, out IntPtr storageId);
179 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_is_drm", CallingConvention = CallingConvention.Cdecl)]
180 internal static extern MediaContentError IsDrm(SafeMediaInformationHandle mediaInformationHandle, out bool isDrm);
182 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_storage_type", CallingConvention = CallingConvention.Cdecl)]
183 internal static extern MediaContentError GetStorageType(SafeMediaInformationHandle mediaInformationHandle, out ContentStorageType storageType);
185 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_played_count", CallingConvention = CallingConvention.Cdecl)]
186 internal static extern MediaContentError GetPlayedCount(SafeMediaInformationHandle mediaInformationHandle, out int playedCount);
188 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_played_time", CallingConvention = CallingConvention.Cdecl)]
189 internal static extern MediaContentError GetPlayedAt(SafeMediaInformationHandle mediaInformationHandle, out int playedTime);
191 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_from_db", CallingConvention = CallingConvention.Cdecl)]
192 internal static extern MediaContentError GetMediaFromDB(string mediaId, out SafeMediaInformationHandle mediaInformationHandle);
194 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_increase_played_count", CallingConvention = CallingConvention.Cdecl)]
195 internal static extern MediaContentError IncreasePlayedCount(SafeMediaInformationHandle mediaInformationHandle);
197 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_played_time", CallingConvention = CallingConvention.Cdecl)]
198 internal static extern MediaContentError SetPlayedAt(SafeMediaInformationHandle mediaInformationHandle);
200 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_display_name", CallingConvention = CallingConvention.Cdecl)]
201 internal static extern MediaContentError SetDisplayName(SafeMediaInformationHandle mediaInformationHandle, string displayName);
203 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_description", CallingConvention = CallingConvention.Cdecl)]
204 internal static extern MediaContentError SetDescription(SafeMediaInformationHandle mediaInformationHandle, string description);
206 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_longitude", CallingConvention = CallingConvention.Cdecl)]
207 internal static extern MediaContentError SetLongitude(SafeMediaInformationHandle mediaInformationHandle, double longitude);
209 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_latitude", CallingConvention = CallingConvention.Cdecl)]
210 internal static extern MediaContentError SetLatitude(SafeMediaInformationHandle mediaInformationHandle, double latitude);
212 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_altitude", CallingConvention = CallingConvention.Cdecl)]
213 internal static extern MediaContentError SetAltitude(SafeMediaInformationHandle mediaInformationHandle, double altitude);
215 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_weather", CallingConvention = CallingConvention.Cdecl)]
216 internal static extern MediaContentError SetWeather(SafeMediaInformationHandle mediaInformationHandle, string weather);
218 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_rating", CallingConvention = CallingConvention.Cdecl)]
219 internal static extern MediaContentError SetRating(SafeMediaInformationHandle mediaInformationHandle, int rating);
221 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_favorite", CallingConvention = CallingConvention.Cdecl)]
222 internal static extern MediaContentError SetFavorite(SafeMediaInformationHandle mediaInformationHandle, bool favorite);
224 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_author", CallingConvention = CallingConvention.Cdecl)]
225 internal static extern MediaContentError SetAuthor(SafeMediaInformationHandle mediaInformationHandle, string author);
227 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_provider", CallingConvention = CallingConvention.Cdecl)]
228 internal static extern MediaContentError SetProvider(SafeMediaInformationHandle mediaInformationHandle, string provider);
230 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_content_name", CallingConvention = CallingConvention.Cdecl)]
231 internal static extern MediaContentError SetContentName(SafeMediaInformationHandle mediaInformationHandle, string contentName);
233 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_category", CallingConvention = CallingConvention.Cdecl)]
234 internal static extern MediaContentError SetCategory(SafeMediaInformationHandle mediaInformationHandle, string category);
236 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_location_tag", CallingConvention = CallingConvention.Cdecl)]
237 internal static extern MediaContentError SetLocationTag(SafeMediaInformationHandle mediaInformationHandle, string locationTag);
239 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_age_rating", CallingConvention = CallingConvention.Cdecl)]
240 internal static extern MediaContentError SetAgeRating(SafeMediaInformationHandle mediaInformationHandle, string ageRating);
242 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_keyword", CallingConvention = CallingConvention.Cdecl)]
243 internal static extern MediaContentError SetKeyword(SafeMediaInformationHandle mediaInformationHandle, string keyword);
245 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_update_to_db", CallingConvention = CallingConvention.Cdecl)]
246 internal static extern MediaContentError UpdateToDB(IntPtr mediaInformationHandle);
248 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_refresh_metadata_to_db", CallingConvention = CallingConvention.Cdecl)]
249 internal static extern MediaContentError RefreshMetadataToDB(string mediaId);
251 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_added_time", CallingConvention = CallingConvention.Cdecl)]
252 internal static extern MediaContentError SetAddedTime(SafeMediaInformationHandle mediaInformationHandle, int addedTime);
254 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_move_to_db", CallingConvention = CallingConvention.Cdecl)]
255 internal static extern MediaContentError MoveToDB(SafeMediaInformationHandle mediaInformationHandle, string dstPath);
257 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_create_thumbnail", CallingConvention = CallingConvention.Cdecl)]
258 internal static extern MediaContentError CreateThumbnail(SafeMediaInformationHandle mediaInformationHandle, MediaThumbnailCompletedCallback callback, IntPtr userData);
260 [DllImport(Libraries.MediaContent, EntryPoint = "media_info_cancel_thumbnail", CallingConvention = CallingConvention.Cdecl)]
261 internal static extern MediaContentError CancelThumbnail(SafeMediaInformationHandle mediaInformationHandle);
263 internal sealed class SafeMediaInformationHandle : SafeHandle
265 public SafeMediaInformationHandle(IntPtr handle)
269 public SafeMediaInformationHandle()
270 : base(IntPtr.Zero, true)
274 public override bool IsInvalid
276 get { return this.handle == IntPtr.Zero; }
279 protected override bool ReleaseHandle()
281 MediaInformation.Destroy(this.handle);
282 this.SetHandle(IntPtr.Zero);