d79e0dde2342691ac0f312286be3fc611369be48
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Metadata / Interop / Interop.MetadataExtractor.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 using System;
18 using System.Runtime.InteropServices;
19 using Tizen.Multimedia;
20
21 internal static partial class Interop
22 {
23     internal static partial class MetadataExtractor
24     {
25         [DllImport(Libraries.MetadataExtractor, EntryPoint = "metadata_extractor_create")]
26         internal static extern MetadataExtractorError Create(out IntPtr handle);
27
28         [DllImport(Libraries.MetadataExtractor, EntryPoint = "metadata_extractor_set_path")]
29         internal static extern MetadataExtractorError SetPath(IntPtr handle, string path);
30
31         [DllImport(Libraries.MetadataExtractor, EntryPoint = "metadata_extractor_set_buffer")]
32         internal static extern MetadataExtractorError SetBuffer(IntPtr handle, IntPtr buffer, int size);
33
34         [DllImport(Libraries.MetadataExtractor, EntryPoint = "metadata_extractor_destroy")]
35         internal static extern MetadataExtractorError Destroy(IntPtr handle);
36
37         [DllImport(Libraries.MetadataExtractor, EntryPoint = "metadata_extractor_get_metadata")]
38         private static extern MetadataExtractorError GetMetadata(IntPtr handle, MetadataExtractorAttr attribute, out IntPtr value);
39
40         internal static string GetMetadata(IntPtr handle, MetadataExtractorAttr attr)
41         {
42             IntPtr valuePtr = IntPtr.Zero;
43
44             try
45             {
46                 var ret = GetMetadata(handle, attr, out valuePtr);
47                 MetadataExtractorRetValidator.ThrowIfError(ret, "Failed to get value for " + attr);
48                 return Marshal.PtrToStringAnsi(valuePtr);
49             }
50             finally
51             {
52                 Libc.Free(valuePtr);
53             }
54         }
55
56         [DllImport(Libraries.MetadataExtractor, EntryPoint = "metadata_extractor_get_artwork")]
57         internal static extern MetadataExtractorError GetArtwork(IntPtr handle, out IntPtr artwork,
58             out int size, out IntPtr mimeType);
59
60         [DllImport(Libraries.MetadataExtractor, EntryPoint = "metadata_extractor_get_frame")]
61         internal static extern MetadataExtractorError GetFrame(IntPtr handle, out IntPtr frame, out int size);
62
63         [DllImport(Libraries.MetadataExtractor, EntryPoint = "metadata_extractor_get_synclyrics")]
64         internal static extern MetadataExtractorError GetSynclyrics(IntPtr handle, int index,
65             out uint timeStamp, out IntPtr lyrics);
66
67         [DllImport(Libraries.MetadataExtractor, EntryPoint = "metadata_extractor_get_frame_at_time")]
68         internal static extern MetadataExtractorError GetFrameAtTime(IntPtr handle, uint timeStamp,
69             bool isAccurate, out IntPtr frame, out int size);
70     }
71 }