b7c611bc887f3d0d1133bf60ed07a538cbd30fff
[platform/core/connectivity/mtp-responder.git] / include / util / mtp_media_info.h
1 /*
2  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
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 #ifndef _MTP_MEDIA_INFO_H_
18 #define _MTP_MEDIA_INFO_H_
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #include <glib.h>
25 #include <media_content.h>
26 #include "mtp_config.h"
27 #include "mtp_datatype.h"
28
29 #define MEDIA_PATH_COND                 "MEDIA_PATH="
30 #define MEDIA_PATH_COND_LEN             13      /* MEDIA_PATH="" */
31 #define MEDIA_PATH_COND_OR              " OR "
32 #define MEDIA_PATH_COND_OR_LEN          4
33 #define MEDIA_PATH_COND_MAX_LEN         MEDIA_PATH_COND_LEN + MTP_MAX_PATHNAME_SIZE
34
35 #define MTP_PAL_SAFE_FREE(src)  { g_free(src); src = NULL; }
36
37 /*
38  * struct MtpCommonMetadata
39  * This structure contains common metadata fields between
40  * video and audio files.
41  */
42 typedef struct {
43         mtp_char *artist;               /* A pointer to Artist */
44         mtp_char *album;                /* A pointer to Album name. */
45         mtp_char *genre;                /* A pointer to Genre */
46         mtp_char *author;               /* A pointer to Author name */
47         mtp_char *copyright;            /* A pointer to Copyright info */
48         mtp_char *year;                 /* A pointer to release year */
49         mtp_char *description;          /* A pointer to description */
50         mtp_int32 duration;             /* Duration of the track */
51         mtp_int32 audio_bitrate;        /* Audio bitrate */
52         mtp_int32 sample_rate;
53         mtp_int32 num_channel;
54         mtp_int32 audio_codec;
55         mtp_int32 rating;
56 } common_meta_t;
57
58 typedef struct {
59         mtp_int32 video_fps;
60         mtp_int32 video_br;
61         mtp_int32 video_h;
62         mtp_int32 video_w;
63         mtp_char *track;
64 } video_meta_t;
65
66 typedef struct {
67         mtp_int32 track;
68 } audio_meta_t;
69
70 typedef struct {
71         mtp_int32 ht;
72         mtp_int32 wt;
73 } image_meta_t;
74
75 typedef struct {
76         common_meta_t commonmeta;
77         audio_meta_t audiometa;
78 } comp_audio_meta_t;
79
80 typedef struct {
81         common_meta_t commonmeta;
82         video_meta_t videometa;
83 } comp_video_meta_t;
84
85 typedef struct {
86         void *data;
87         mtp_int32 count;
88         guint tid;
89         pthread_mutex_t *lock;
90 } timeout_data_t;
91
92 mtp_bool _util_get_audio_metadata(const mtp_char *filepath,
93                 comp_audio_meta_t *audio_data);
94 mtp_bool _util_get_video_metadata(mtp_char *filepath,
95                 comp_video_meta_t *video_data);
96 mtp_bool _util_get_image_ht_wt(const mtp_char *filepath, image_meta_t *image_data);
97 mtp_bool _util_get_audio_meta_from_extractor(const mtp_char *filepath,
98                 comp_audio_meta_t *audio_data);
99 mtp_bool _util_get_video_meta_from_extractor(const mtp_char *filepath,
100                 comp_video_meta_t *video_data);
101 void _util_flush_db(void);
102 void _util_delete_file_from_db(const mtp_char *filepath);
103 void _util_add_file_to_db(const mtp_char *filepath);
104 void _util_scan_folder_contents_in_db(const mtp_char *filepath);
105 void _util_free_common_meta(common_meta_t *metadata);
106 void _util_free_video_meta(video_meta_t *video);
107 void _util_free_image_meta(image_meta_t *image);
108
109 #ifdef __cplusplus
110 }
111 #endif
112
113 #endif /* _MTP_MEDIA_INFO_H_ */