2 * Copyright (C) 2007 by INdT
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * @author Gustavo Sverzut Barbieri <gustavo.barbieri@openbossa.org>
21 #ifndef _LIGHTMEDIASCANNER_DB_H_
22 #define _LIGHTMEDIASCANNER_DB_H_ 1
30 # define API __attribute__ ((visibility("default")))
34 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
35 # define GNUC_NON_NULL(...) __attribute__((nonnull(__VA_ARGS__)))
37 # define GNUC_NON_NULL(...)
41 # define GNUC_NON_NULL(...)
44 #include <lightmediascanner_plugin.h>
45 #include <lightmediascanner_utils.h>
53 * @defgroup LMS_DB DataBase-API
55 * Although Light Media Scanner uses SQLite3 and doesn't try to hide it from
56 * plugins/parsers, it does provide some utilities to make development easier
57 * and less error prone.
59 * @warning This is to be considered an *internal* API for plugins/parsers and
60 * there's no versioning or backward compatibility whatsoever. It's much
61 * better to keep plugins inside LMS tree than keeping them separate.
73 struct lms_image_info {
75 struct lms_string_size title;
76 struct lms_string_size artist;
77 struct lms_string_size dlna_profile;
78 struct lms_string_size dlna_mime;
81 unsigned short height;
82 unsigned short orientation;
83 struct lms_gps_info gps;
86 typedef struct lms_db_image lms_db_image_t;
88 API lms_db_image_t *lms_db_image_new(sqlite3 *db) GNUC_NON_NULL(1);
89 API int lms_db_image_start(lms_db_image_t *ldi) GNUC_NON_NULL(1);
90 API int lms_db_image_free(lms_db_image_t *ldi) GNUC_NON_NULL(1);
91 API int lms_db_image_add(lms_db_image_t *ldi, struct lms_image_info *info) GNUC_NON_NULL(1, 2);
94 struct lms_audio_info {
96 struct lms_string_size title;
97 struct lms_string_size artist;
98 struct lms_string_size album;
99 struct lms_string_size genre;
100 struct lms_string_size container;
101 struct lms_string_size codec;
102 struct lms_string_size dlna_profile;
103 struct lms_string_size dlna_mime;
104 unsigned int playcnt;
106 unsigned int sampling_rate;
107 unsigned int bitrate;
113 typedef struct lms_db_audio lms_db_audio_t;
115 API lms_db_audio_t *lms_db_audio_new(sqlite3 *db) GNUC_NON_NULL(1);
116 API int lms_db_audio_start(lms_db_audio_t *lda) GNUC_NON_NULL(1);
117 API int lms_db_audio_free(lms_db_audio_t *lda) GNUC_NON_NULL(1);
118 API int lms_db_audio_add(lms_db_audio_t *lda, struct lms_audio_info *info) GNUC_NON_NULL(1, 2);
122 enum lms_stream_type {
123 LMS_STREAM_TYPE_UNKNOWN,
124 LMS_STREAM_TYPE_AUDIO,
125 LMS_STREAM_TYPE_VIDEO,
126 LMS_STREAM_TYPE_SUBTITLE,
129 struct lms_stream_video_info {
130 struct lms_string_size aspect_ratio;
131 unsigned int bitrate;
138 struct lms_stream_audio_info {
139 unsigned int sampling_rate;
140 unsigned int bitrate;
145 struct lms_stream *next;
146 enum lms_stream_type type;
147 unsigned int stream_id;
148 struct lms_string_size codec;
149 struct lms_string_size lang;
151 struct lms_stream_audio_info audio;
152 struct lms_stream_video_info video;
156 struct lms_video_info {
158 struct lms_string_size title;
159 struct lms_string_size artist;
160 struct lms_string_size container;
161 struct lms_string_size dlna_profile;
162 struct lms_string_size dlna_mime;
164 struct lms_stream *streams;
167 typedef struct lms_db_video lms_db_video_t;
169 API lms_db_video_t *lms_db_video_new(sqlite3 *db) GNUC_NON_NULL(1);
170 API int lms_db_video_start(lms_db_video_t *ldv) GNUC_NON_NULL(1);
171 API int lms_db_video_free(lms_db_video_t *ldv) GNUC_NON_NULL(1);
172 API int lms_db_video_add(lms_db_video_t *ldv, struct lms_video_info *info) GNUC_NON_NULL(1, 2);
174 API int lms_stream_video_info_aspect_ratio_guess(struct lms_stream_video_info *info) GNUC_NON_NULL(1);
176 /* Playlist Records */
177 struct lms_playlist_info {
179 struct lms_string_size title;
180 unsigned int n_entries;
183 typedef struct lms_db_playlist lms_db_playlist_t;
185 API lms_db_playlist_t *lms_db_playlist_new(sqlite3 *db) GNUC_NON_NULL(1);
186 API int lms_db_playlist_start(lms_db_playlist_t *ldp) GNUC_NON_NULL(1);
187 API int lms_db_playlist_free(lms_db_playlist_t *ldp) GNUC_NON_NULL(1);
188 API int lms_db_playlist_add(lms_db_playlist_t *ldp, struct lms_playlist_info *info) GNUC_NON_NULL(1, 2);
197 #endif /* _LIGHTMEDIASCANNER_DB_H_ */