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;
84 struct lms_string_size container;
87 typedef struct lms_db_image lms_db_image_t;
89 API lms_db_image_t *lms_db_image_new(sqlite3 *db) GNUC_NON_NULL(1);
90 API int lms_db_image_start(lms_db_image_t *ldi) GNUC_NON_NULL(1);
91 API int lms_db_image_free(lms_db_image_t *ldi) GNUC_NON_NULL(1);
92 API int lms_db_image_add(lms_db_image_t *ldi, struct lms_image_info *info) GNUC_NON_NULL(1, 2);
95 struct lms_audio_info {
97 struct lms_string_size title;
98 struct lms_string_size artist;
99 struct lms_string_size album;
100 struct lms_string_size genre;
101 struct lms_string_size container;
102 struct lms_string_size codec;
103 struct lms_string_size dlna_profile;
104 struct lms_string_size dlna_mime;
105 unsigned int playcnt;
107 unsigned int sampling_rate;
108 unsigned int bitrate;
114 typedef struct lms_db_audio lms_db_audio_t;
116 API lms_db_audio_t *lms_db_audio_new(sqlite3 *db) GNUC_NON_NULL(1);
117 API int lms_db_audio_start(lms_db_audio_t *lda) GNUC_NON_NULL(1);
118 API int lms_db_audio_free(lms_db_audio_t *lda) GNUC_NON_NULL(1);
119 API int lms_db_audio_add(lms_db_audio_t *lda, struct lms_audio_info *info) GNUC_NON_NULL(1, 2);
123 enum lms_stream_type {
124 LMS_STREAM_TYPE_UNKNOWN,
125 LMS_STREAM_TYPE_AUDIO,
126 LMS_STREAM_TYPE_VIDEO,
127 LMS_STREAM_TYPE_SUBTITLE,
130 struct lms_stream_video_info {
131 struct lms_string_size aspect_ratio;
132 unsigned int bitrate;
139 struct lms_stream_audio_info {
140 unsigned int sampling_rate;
141 unsigned int bitrate;
146 struct lms_stream *next;
147 enum lms_stream_type type;
148 unsigned int stream_id;
149 struct lms_string_size codec;
150 struct lms_string_size lang;
152 struct lms_stream_audio_info audio;
153 struct lms_stream_video_info video;
157 struct lms_video_info {
159 struct lms_string_size title;
160 struct lms_string_size artist;
161 struct lms_string_size container;
162 struct lms_string_size dlna_profile;
163 struct lms_string_size dlna_mime;
166 struct lms_stream *streams;
169 typedef struct lms_db_video lms_db_video_t;
171 API lms_db_video_t *lms_db_video_new(sqlite3 *db) GNUC_NON_NULL(1);
172 API int lms_db_video_start(lms_db_video_t *ldv) GNUC_NON_NULL(1);
173 API int lms_db_video_free(lms_db_video_t *ldv) GNUC_NON_NULL(1);
174 API int lms_db_video_add(lms_db_video_t *ldv, struct lms_video_info *info) GNUC_NON_NULL(1, 2);
176 API int lms_stream_video_info_aspect_ratio_guess(struct lms_stream_video_info *info) GNUC_NON_NULL(1);
178 /* Playlist Records */
179 struct lms_playlist_info {
181 struct lms_string_size title;
182 unsigned int n_entries;
185 typedef struct lms_db_playlist lms_db_playlist_t;
187 API lms_db_playlist_t *lms_db_playlist_new(sqlite3 *db) GNUC_NON_NULL(1);
188 API int lms_db_playlist_start(lms_db_playlist_t *ldp) GNUC_NON_NULL(1);
189 API int lms_db_playlist_free(lms_db_playlist_t *ldp) GNUC_NON_NULL(1);
190 API int lms_db_playlist_add(lms_db_playlist_t *ldp, struct lms_playlist_info *info) GNUC_NON_NULL(1, 2);
199 #endif /* _LIGHTMEDIASCANNER_DB_H_ */