summaryrefslogtreecommitdiff
path: root/src/include/common/media-svc-util.h
blob: 7129bbfec6fec0a3181002bc273154282aa292f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
 * libmedia-service
 *
 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */



#ifndef _MEDIA_SVC_UTIL_H_
#define _MEDIA_SVC_UTIL_H_

#include <string.h>
#include <stdbool.h>
#include <sqlite3.h>
#include <time.h>
#include "media-svc-env.h"

#ifdef __cplusplus
extern "C" {
#endif

#define STRING_VALID(str)	(str != NULL && strlen(str) > 0)

#define SAFE_FREE(src) do { \
				if (src) { \
					free(src); \
					src = NULL; \
				} \
			} while (0)


#define SAFE_STRLCAT(dst, src, n) do { \
				if (src) \
					g_strlcat(dst, src, n); \
			} while (0)

#define SAFE_STRLCPY(dst, src, n) do { \
				if (src) \
					g_strlcpy(dst, src, n); \
			} while (0)

/**
 * Media meta data information
 */
typedef struct {
	char		*title;				/**< track title*/
	char		*album;				/**< album name*/
	char		*artist;				/**< artist name*/
	char		*album_artist;		/**< artist name*/
	char		*genre;				/**< genre of track*/
	char		*composer;			/**< composer name*/
	char		*year;				/**< year*/
	char		*recorded_date;		/**< recorded date*/
	char		*copyright;			/**< copyright*/
	char		*track_num;			/**< track number*/
	char		*description;			/**< description*/
	int		bitrate;				/**< bitrate*/
	int		samplerate;			/**< samplerate*/
	int		channel;				/**< channel*/
	int		duration;			/**< duration*/
	float		longitude;			/**< longitude*/
	float		latitude;				/**< latitude*/
	float		altitude;				/**< altitude*/
	char		*exposure_time;		/**< exposure_time*/
	float		fnumber;			/**< fnumber*/
	int		iso;					/**< iso*/
	char		*model;				/**< model*/
	int		width;				/**< width*/
	int		height;				/**< height*/
	char		*datetaken;			/**< datetaken*/
	int		orientation;			/**< orientation*/
	int		rating;				/**< user defined rating */
	int		bitpersample;		/**< bitrate*/

	char		*title_pinyin;					/**< pinyin for title*/
	char		*album_pinyin;				/**< pinyin for album*/
	char		*artist_pinyin;					/**< pinyin for artist*/
	char		*album_artist_pinyin;			/**< pinyin for album_artist*/
	char		*genre_pinyin;					/**< pinyin for genre*/
	char		*composer_pinyin;				/**< pinyin for composer*/
	char		*copyright_pinyin;				/**< pinyin for copyright*/
	char		*description_pinyin;			/**< pinyin for description*/
	int		is_360;
} media_svc_content_meta_s;

/**
 * Media data information
 */
typedef struct {
	char		*media_uuid;					/**< Unique ID of item */
	char		*path;						/**< Full path of media file */
	char		*file_name;					/**< File name of media file. Display name */
	char		*file_name_pinyin;				/**< File name pinyin of media file. Display name */
	int		media_type;					/**< Type of media file : internal/external */
	char		*mime_type;					/**< Full path and file name of media file */
	unsigned long long	size;							/**< size */
	time_t	added_time;					/**< added time, time_t */
	time_t	modified_time;				/**< modified time, time_t */
	time_t	timeline;					/**< timeline of media, time_t */
	char		*folder_uuid;					/**< Unique ID of folder */
	int		album_id;					/**< Unique ID of album */
	char		*thumbnail_path;				/**< Thumbnail image file path */
	time_t	favourate;					/**< time favourate set */
	int		is_drm;						/**< is_drm. o or 1 */
	int		storage_type;					/**< Storage of media file : internal/external */
	char		*storage_uuid;					/**< Unique ID of storage */
	media_svc_content_meta_s	media_meta;	/**< meta data structure for audio files */
} media_svc_content_info_s;

/**
 * Type definition for content type
 */
typedef enum {
	MEDIA_SVC_MEDIA_TYPE_IMAGE	= 0,	/**< Image Content*/
	MEDIA_SVC_MEDIA_TYPE_VIDEO	= 1,	/**< Video Content*/
	MEDIA_SVC_MEDIA_TYPE_SOUND	= 2,	/**< Sound Content like Ringtone*/
	MEDIA_SVC_MEDIA_TYPE_MUSIC	= 3,	/**< Music Content like mp3*/
	MEDIA_SVC_MEDIA_TYPE_OTHER	= 4,	/**< Not media Content*/
} media_svc_media_type_e;

char * _media_info_generate_uuid(void);
void _media_svc_remove_file(const char *path);
int _media_svc_get_thumbnail_path(media_svc_media_type_e media_type, char *thumb_path, const char *pathname, const char *img_format, uid_t uid);
int _media_svc_get_file_time(const char *full_path);
char * _media_svc_get_title_by_path(const char *path);
int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, bool refresh);
int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info);
int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc_content_info_s *content_info, uid_t uid);
void _media_svc_destroy_content_info(media_svc_content_info_s *content_info);
int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_media_type_e media_type, uid_t uid);
int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str);
bool _media_svc_check_pinyin_support(void);
int _media_svc_extract_music_metadata_for_update(media_svc_content_info_s *content_info, const char *path);
int _media_svc_get_media_type(const char *path, int *mediatype);
bool _media_svc_is_valid_storage_type(ms_user_storage_type_e storage_type);

#ifdef __cplusplus
}
#endif

#endif /*_MEDIA_SVC_UTIL_H_*/