Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Content.MediaContent / Interop / Interop.MediaInformation.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17
18 using System;
19 using System.Runtime.InteropServices;
20 using Tizen.Content.MediaContent;
21
22 internal static partial class Interop
23 {
24     internal static partial class MediaInformation
25     {
26         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
27         internal delegate void MediaThumbnailCompletedCallback(MediaContentError error, string filePath, IntPtr UserData);
28
29         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
30         internal delegate bool MediaTagCallback(IntPtr tagHandle, IntPtr UserData);
31
32         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
33         internal delegate bool MediaBookmarkCallback(IntPtr bookmarkHandle, IntPtr UserData);
34
35         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
36         internal delegate bool MediaFaceCallback(IntPtr bookmarkHandle, IntPtr UserData);
37
38         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
39         internal delegate void MediaInsertCompletedCallback(MediaContentError error, IntPtr UserData);
40
41         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
42         internal delegate void MediaInsertBurstShotCompletedCallback(MediaContentError error, IntPtr UserData);
43
44         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
45         internal delegate bool MediaInformationCallback(IntPtr mediaInformationHandle, IntPtr UserData);
46
47         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_insert_to_db", CallingConvention = CallingConvention.Cdecl)]
48         internal static extern MediaContentError Insert(string filePath, out SafeMediaInformationHandle info);
49
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);
52
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);
55
56         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_delete_from_db", CallingConvention = CallingConvention.Cdecl)]
57         internal static extern MediaContentError Delete(string mediaId);
58
59         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_delete_batch_from_db", CallingConvention = CallingConvention.Cdecl)]
60         internal static extern MediaContentError BatchDelete(IntPtr filter);
61
62         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_destroy", CallingConvention = CallingConvention.Cdecl)]
63         internal static extern MediaContentError Destroy(IntPtr mediaInformationHandle);
64
65         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_clone", CallingConvention = CallingConvention.Cdecl)]
66         internal static extern MediaContentError Clone(out SafeMediaInformationHandle dst, IntPtr src);
67
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);
70
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);
73
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);
76
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);
79
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);
82
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);
85
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);
88
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);
91
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);
94
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);
97
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);
100
101         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_id", CallingConvention = CallingConvention.Cdecl)]
102         internal static extern MediaContentError GetMediaId(SafeMediaInformationHandle mediaInformationHandle, out IntPtr mediaId);
103
104         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_file_path", CallingConvention = CallingConvention.Cdecl)]
105         internal static extern MediaContentError GetFilePath(SafeMediaInformationHandle mediaInformationHandle, out IntPtr filePath);
106
107         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_display_name", CallingConvention = CallingConvention.Cdecl)]
108         internal static extern MediaContentError GetDisplayName(SafeMediaInformationHandle mediaInformationHandle, out IntPtr name);
109
110         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_type", CallingConvention = CallingConvention.Cdecl)]
111         internal static extern MediaContentError GetMediaType(SafeMediaInformationHandle mediaInformationHandle, out MediaContentType type);
112
113         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_mime_type", CallingConvention = CallingConvention.Cdecl)]
114         internal static extern MediaContentError GetMimeType(SafeMediaInformationHandle mediaInformationHandle, out IntPtr mimeType);
115
116         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_size", CallingConvention = CallingConvention.Cdecl)]
117         internal static extern MediaContentError GetSize(SafeMediaInformationHandle mediaInformationHandle, out long size);
118
119         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_added_time", CallingConvention = CallingConvention.Cdecl)]
120         internal static extern MediaContentError GetAddedTime(SafeMediaInformationHandle mediaInformationHandle, out int addedTime);
121
122         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_modified_time", CallingConvention = CallingConvention.Cdecl)]
123         internal static extern MediaContentError GetModifiedTime(SafeMediaInformationHandle mediaInformationHandle, out int time);
124
125         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_timeline", CallingConvention = CallingConvention.Cdecl)]
126         internal static extern MediaContentError GetTimeline(SafeMediaInformationHandle mediaInformationHandle, out int time);
127
128         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_thumbnail_path", CallingConvention = CallingConvention.Cdecl)]
129         internal static extern MediaContentError GetThumbnailPath(SafeMediaInformationHandle mediaInformationHandle, out IntPtr filePath);
130
131         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_description", CallingConvention = CallingConvention.Cdecl)]
132         internal static extern MediaContentError GetDescription(SafeMediaInformationHandle mediaInformationHandle, out IntPtr description);
133
134         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_longitude", CallingConvention = CallingConvention.Cdecl)]
135         internal static extern MediaContentError GetLongitude(SafeMediaInformationHandle mediaInformationHandle, out double longitude);
136
137         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_latitude", CallingConvention = CallingConvention.Cdecl)]
138         internal static extern MediaContentError GetLatitude(SafeMediaInformationHandle mediaInformationHandle, out double latitude);
139
140         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_altitude", CallingConvention = CallingConvention.Cdecl)]
141         internal static extern MediaContentError GetAltitude(SafeMediaInformationHandle mediaInformationHandle, out double altitude);
142
143         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_weather", CallingConvention = CallingConvention.Cdecl)]
144         internal static extern MediaContentError GetWeather(SafeMediaInformationHandle mediaInformationHandle, out IntPtr weather);
145
146         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_rating", CallingConvention = CallingConvention.Cdecl)]
147         internal static extern MediaContentError GetRating(SafeMediaInformationHandle mediaInformationHandle, out int rating);
148
149         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_favorite", CallingConvention = CallingConvention.Cdecl)]
150         internal static extern MediaContentError GetFavorite(SafeMediaInformationHandle mediaInformationHandle, out bool favorite);
151
152         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_author", CallingConvention = CallingConvention.Cdecl)]
153         internal static extern MediaContentError GetAuthor(SafeMediaInformationHandle mediaInformationHandle, out IntPtr author);
154
155         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_provider", CallingConvention = CallingConvention.Cdecl)]
156         internal static extern MediaContentError GetProvider(SafeMediaInformationHandle mediaInformationHandle, out IntPtr provider);
157
158         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_content_name", CallingConvention = CallingConvention.Cdecl)]
159         internal static extern MediaContentError GetContentName(SafeMediaInformationHandle mediaInformationHandle, out IntPtr contentName);
160
161         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_title", CallingConvention = CallingConvention.Cdecl)]
162         internal static extern MediaContentError GetTitle(SafeMediaInformationHandle mediaInformationHandle, out IntPtr title);
163
164         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_category", CallingConvention = CallingConvention.Cdecl)]
165         internal static extern MediaContentError GetCategory(SafeMediaInformationHandle mediaInformationHandle, out IntPtr category);
166
167         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_location_tag", CallingConvention = CallingConvention.Cdecl)]
168         internal static extern MediaContentError GetLocationTag(SafeMediaInformationHandle mediaInformationHandle, out IntPtr locationTag);
169
170         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_age_rating", CallingConvention = CallingConvention.Cdecl)]
171         internal static extern MediaContentError GetAgeRating(SafeMediaInformationHandle mediaInformationHandle, out IntPtr ageRating);
172
173         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_keyword", CallingConvention = CallingConvention.Cdecl)]
174         internal static extern MediaContentError GetKeyword(SafeMediaInformationHandle mediaInformationHandle, out IntPtr keyword);
175
176         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_storage_id", CallingConvention = CallingConvention.Cdecl)]
177         internal static extern MediaContentError GetStorageId(SafeMediaInformationHandle mediaInformationHandle, out IntPtr storageId);
178
179         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_is_drm", CallingConvention = CallingConvention.Cdecl)]
180         internal static extern MediaContentError IsDrm(SafeMediaInformationHandle mediaInformationHandle, out bool isDrm);
181
182         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_storage_type", CallingConvention = CallingConvention.Cdecl)]
183         internal static extern MediaContentError GetStorageType(SafeMediaInformationHandle mediaInformationHandle, out ContentStorageType storageType);
184
185         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_played_count", CallingConvention = CallingConvention.Cdecl)]
186         internal static extern MediaContentError GetPlayedCount(SafeMediaInformationHandle mediaInformationHandle, out int playedCount);
187
188         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_played_time", CallingConvention = CallingConvention.Cdecl)]
189         internal static extern MediaContentError GetPlayedAt(SafeMediaInformationHandle mediaInformationHandle, out int playedTime);
190
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);
193
194         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_increase_played_count", CallingConvention = CallingConvention.Cdecl)]
195         internal static extern MediaContentError IncreasePlayedCount(SafeMediaInformationHandle mediaInformationHandle);
196
197         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_played_time", CallingConvention = CallingConvention.Cdecl)]
198         internal static extern MediaContentError SetPlayedAt(SafeMediaInformationHandle mediaInformationHandle);
199
200         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_display_name", CallingConvention = CallingConvention.Cdecl)]
201         internal static extern MediaContentError SetDisplayName(SafeMediaInformationHandle mediaInformationHandle, string displayName);
202
203         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_description", CallingConvention = CallingConvention.Cdecl)]
204         internal static extern MediaContentError SetDescription(SafeMediaInformationHandle mediaInformationHandle, string description);
205
206         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_longitude", CallingConvention = CallingConvention.Cdecl)]
207         internal static extern MediaContentError SetLongitude(SafeMediaInformationHandle mediaInformationHandle, double longitude);
208
209         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_latitude", CallingConvention = CallingConvention.Cdecl)]
210         internal static extern MediaContentError SetLatitude(SafeMediaInformationHandle mediaInformationHandle, double latitude);
211
212         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_altitude", CallingConvention = CallingConvention.Cdecl)]
213         internal static extern MediaContentError SetAltitude(SafeMediaInformationHandle mediaInformationHandle, double altitude);
214
215         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_weather", CallingConvention = CallingConvention.Cdecl)]
216         internal static extern MediaContentError SetWeather(SafeMediaInformationHandle mediaInformationHandle, string weather);
217
218         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_rating", CallingConvention = CallingConvention.Cdecl)]
219         internal static extern MediaContentError SetRating(SafeMediaInformationHandle mediaInformationHandle, int rating);
220
221         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_favorite", CallingConvention = CallingConvention.Cdecl)]
222         internal static extern MediaContentError SetFavorite(SafeMediaInformationHandle mediaInformationHandle, bool favorite);
223
224         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_author", CallingConvention = CallingConvention.Cdecl)]
225         internal static extern MediaContentError SetAuthor(SafeMediaInformationHandle mediaInformationHandle, string author);
226
227         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_provider", CallingConvention = CallingConvention.Cdecl)]
228         internal static extern MediaContentError SetProvider(SafeMediaInformationHandle mediaInformationHandle, string provider);
229
230         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_content_name", CallingConvention = CallingConvention.Cdecl)]
231         internal static extern MediaContentError SetContentName(SafeMediaInformationHandle mediaInformationHandle, string contentName);
232
233         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_category", CallingConvention = CallingConvention.Cdecl)]
234         internal static extern MediaContentError SetCategory(SafeMediaInformationHandle mediaInformationHandle, string category);
235
236         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_location_tag", CallingConvention = CallingConvention.Cdecl)]
237         internal static extern MediaContentError SetLocationTag(SafeMediaInformationHandle mediaInformationHandle, string locationTag);
238
239         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_age_rating", CallingConvention = CallingConvention.Cdecl)]
240         internal static extern MediaContentError SetAgeRating(SafeMediaInformationHandle mediaInformationHandle, string ageRating);
241
242         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_keyword", CallingConvention = CallingConvention.Cdecl)]
243         internal static extern MediaContentError SetKeyword(SafeMediaInformationHandle mediaInformationHandle, string keyword);
244
245         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_update_to_db", CallingConvention = CallingConvention.Cdecl)]
246         internal static extern MediaContentError UpdateToDB(IntPtr mediaInformationHandle);
247
248         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_refresh_metadata_to_db", CallingConvention = CallingConvention.Cdecl)]
249         internal static extern MediaContentError RefreshMetadataToDB(string mediaId);
250
251         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_set_added_time", CallingConvention = CallingConvention.Cdecl)]
252         internal static extern MediaContentError SetAddedTime(SafeMediaInformationHandle mediaInformationHandle, int addedTime);
253
254         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_move_to_db", CallingConvention = CallingConvention.Cdecl)]
255         internal static extern MediaContentError MoveToDB(SafeMediaInformationHandle mediaInformationHandle, string dstPath);
256
257         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_create_thumbnail", CallingConvention = CallingConvention.Cdecl)]
258         internal static extern MediaContentError CreateThumbnail(SafeMediaInformationHandle mediaInformationHandle, MediaThumbnailCompletedCallback callback, IntPtr userData);
259
260         [DllImport(Libraries.MediaContent, EntryPoint = "media_info_cancel_thumbnail", CallingConvention = CallingConvention.Cdecl)]
261         internal static extern MediaContentError CancelThumbnail(SafeMediaInformationHandle mediaInformationHandle);
262
263         internal sealed class SafeMediaInformationHandle : SafeHandle
264         {
265             public SafeMediaInformationHandle(IntPtr handle)
266                 : base(handle, true)
267             {
268             }
269             public SafeMediaInformationHandle()
270                 : base(IntPtr.Zero, true)
271             {
272             }
273
274             public override bool IsInvalid
275             {
276                 get { return this.handle == IntPtr.Zero; }
277             }
278
279             protected override bool ReleaseHandle()
280             {
281                 MediaInformation.Destroy(this.handle);
282                 this.SetHandle(IntPtr.Zero);
283                 return true;
284             }
285         }
286     }
287 }