pmp.h

Go to the documentation of this file.
00001 /*
00002  *      Digital Media Player library.
00003  *
00004  *      Copyright (c) 2005-2007 Naoaki Okazaki
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  * 
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00019  *
00020  */
00021 
00022 /* $Id: pmp.h 392 2007-02-23 09:37:33Z nyaochi $ */
00023 
00024 #ifndef __PMP_H__
00025 #define __PMP_H__
00026 
00027 #include <pmplib/os_types.h>
00028 
00029 #ifdef  PMP_EXPORTS
00030 #define PMPAPI  __declspec(dllexport)
00031 #else
00032 #define PMPAPI
00033 #endif/*PMP_EXPORTS*/
00034 
00035 #ifdef  __cplusplus
00036 extern "C" {
00037 #endif/*__cplusplus*/
00038 
00039 
00056 /*
00057  * Forward structure declarations.
00058  */
00059 struct tag_pmp_t;
00061 typedef struct tag_pmp_t pmp_t;
00062 
00063 struct tag_pmp_music_t;
00065 typedef struct tag_pmp_music_t pmp_music_t;
00066 
00070 enum {
00072         PMP_SUCCESS = 0,
00074         PMPERR_ERROR = 0x80000000,
00076         PMPERR_DEVICENOTFOUND,
00078         PMPERR_INSUFFICIENTMEMORY,
00080         PMPERR_NOTIMPLIMENTED,
00082         PMPERR_ENTRYNOTFOUND,
00084         PMPERR_INCONSISTENCY,
00086         PMPERR_OPENFORREAD,
00088         PMPERR_OPENFORWRITE,
00090         PMPERR_READ,
00092         PMPERR_WRITE,
00093 };
00094 
00099 enum {
00104         PMPOF_MUSIC_DB_READ             = 0x0001,
00109         PMPOF_MUSIC_DB_WRITE    = 0x0002,
00114         PMPOF_MUSIC_PL_READ             = 0x0004,
00119         PMPOF_MUSIC_PL_WRITE    = 0x0008,
00120 };
00121 
00125 #define PMPFOURCC(a, b, c, d)   \
00126         ((uint32_t)(a) << 24 | (uint32_t)(b) << 16 | (uint32_t)(c) << 8 | (uint32_t)(d))
00127 
00129 #define PMPCODEC_NONE                   PMPFOURCC(' ',' ',' ',' ')
00130 
00131 #define PMPCODEC_MPEGLAYER3             PMPFOURCC('M','P','A','3')
00132 
00133 #define PMPCODEC_WMA                    PMPFOURCC('W','M','A',' ')
00134 
00135 #define PMPCODEC_VORBIS                 PMPFOURCC('O','g','g','V')
00136 
00137 #define PMPCODEC_WAV                    PMPFOURCC('W','A','V','E')
00138 
00142 enum {
00144         PMPF_NONE =                     0x0000,
00146         PMPMF_SUPPORT =         0x0001,
00148         PMPMF_RECURSIVE =       0x0002, 
00150         PMPPF_SUPPORT =         0x0010,
00152         PMPPF_RECURSIVE =       0x0020,
00153 };
00154 
00155 
00164 #define PMP_DECLSIZE    (128)
00165 
00166 #define PMP_DECLUNAVAIL ("***")
00167 
00176 typedef struct {
00178         char    id[PMP_DECLSIZE];
00180         char    manufacturer[PMP_DECLSIZE];
00182         char    name[PMP_DECLSIZE];
00184         char    mode[PMP_DECLSIZE];
00186         char    language[PMP_DECLSIZE];
00188         char    version[PMP_DECLSIZE];
00190         char    min_version[PMP_DECLSIZE];
00192         char    max_version[PMP_DECLSIZE];
00193 } pmp_device_description_t;
00194 
00199 typedef struct {
00201         ucs2char_t              path_to_root[MAX_PATH];
00203         ucs2char_t              path_to_system[MAX_PATH];
00205         ucs2char_t              path_to_music[MAX_PATH];
00207         ucs2char_t              path_to_playlist[MAX_PATH];
00208 
00210         uint32_t                music_flag;
00212         uint32_t                playlist_flag;
00213 
00215         uint32_t                num_audio_codecs;
00217         uint32_t*               audio_codecs;
00218 
00220         uint32_t                num_audio_extensions;
00222         ucs2char_t**    audio_extensions;
00223 
00225         const pmp_device_description_t  decl;
00226 } pmp_device_information_t;
00227 
00239 struct tag_pmp_t {
00246         void* instance;
00247 
00256         uint32_t ref_count;
00257 
00264         uint32_t flag;
00265 
00269         pmp_device_information_t info;
00270 
00274         pmp_music_t* music;
00275 
00280         uint32_t (*add_ref)(pmp_t* pmp);
00281 
00288         uint32_t (*release)(pmp_t* pmp);
00289 
00295         result_t (*open)(pmp_t* pmp, uint32_t flag);
00296 
00301         result_t (*close)(pmp_t* pmp);
00302 };
00303 
00319 struct tag_pmp_music_record_t {
00326         ucs2char_t              *filename;
00327 
00333         ucs2char_t              *title;
00334 
00340         ucs2char_t              *artist;
00341 
00347         ucs2char_t              *composer;
00348 
00354         ucs2char_t              *album;
00355 
00361         ucs2char_t              *genre;
00362 
00368         ucs2char_t              *date;
00369 
00374         uint32_t                codec;
00375 
00380         uint32_t                codec_version;
00381 
00386         uint8_t                 is_vbr;
00387 
00392         uint32_t                track_number;
00393 
00398         uint32_t                total_tracks;
00399 
00404         uint32_t                disc_number;
00405 
00410         uint32_t                total_discs;
00411 
00416         uint32_t                sample_rate;
00417 
00422         uint32_t                bitrate;
00423 
00428         uint32_t                duration;
00429 
00434         uint64_t                num_samples;
00435 
00440         uint32_t                filesize;
00441 
00446         uint32_t                ts_update;
00447 
00452         uint32_t                rating;
00453 
00458         uint32_t                play_count;
00459 
00463         uint32_t                ts_playback;
00464 
00468         uint32_t                ts_import;
00469 };
00470 
00474 typedef struct tag_pmp_music_record_t pmp_music_record_t;
00475 
00479 typedef struct {
00483         ucs2char_t *name;
00484 
00488         int num_entries;
00489 
00493         ucs2char_t **entries;
00494 } pmp_playlist_t;
00495 
00510 struct tag_pmp_music_t {
00517         void* instance;
00518 
00525         pmp_t* pmp;
00526 
00552         result_t (*set_records)(pmp_music_t* music, const pmp_music_record_t* records, uint32_t num_records);
00553 
00580         result_t (*get_records)(pmp_music_t* music, pmp_music_record_t* records, uint32_t* num_records);
00581 
00601         result_t (*set_playlists)(pmp_music_t* music, const pmp_playlist_t* playlists, uint32_t num_playlists);
00602 
00629         result_t (*get_playlists)(pmp_music_t* music, pmp_playlist_t* playlists, uint32_t* num_playlists);
00630 
00642         result_t (*dump)(pmp_music_t* music, FILE *fp, int flag);
00643 };
00644 
00650 PMPAPI void pmplib_record_init(pmp_music_record_t* record);
00651 
00659 PMPAPI void pmplib_record_finish(pmp_music_record_t* record);
00660 
00670 PMPAPI result_t pmplib_record_clone(pmp_music_record_t* dst, const pmp_music_record_t* src);
00671 
00681 PMPAPI void pmplib_records_finish(pmp_music_record_t* records, int num_records);
00682 
00693 PMPAPI result_t pmplib_records_clone(pmp_music_record_t* dst, const pmp_music_record_t* src, int num_records);
00694 
00700 PMPAPI void pmplib_playlist_init(pmp_playlist_t* playlist);
00701 
00709 PMPAPI void pmplib_playlist_finish(pmp_playlist_t* playlist);
00710 
00719 PMPAPI void pmplib_playlist_clone(pmp_playlist_t* dst, const pmp_playlist_t* src);
00720 
00730 PMPAPI void pmplib_playlists_finish(pmp_playlist_t* playlists, int num_playlists);
00731 
00741 PMPAPI void pmplib_playlists_clone(pmp_playlist_t* dst, const pmp_playlist_t* src, int num_playlists);
00742 
00760 typedef void (*pmplib_enumerate_devid_callback_t)(void *instance, const char *devid);
00761 
00789 typedef result_t (*pmplib_create_t)(pmp_t** ptr_pmp, const ucs2char_t* path_to_device, const char *id);
00790 
00806 typedef result_t (*pmplib_enumerate_devid_t)(pmplib_enumerate_devid_callback_t callback, void *instance);
00807 
00830 PMPAPI uint32_t pmplib_interlocked_increment(uint32_t* count);
00831 
00843 PMPAPI uint32_t pmplib_interlocked_decrement(uint32_t* count);
00844 
00922 struct tag_pmplib_t;
00923 
00932 typedef struct tag_pmplib_t pmplib_t;
00933 
00950 PMPAPI result_t pmplib_init(pmplib_t** ptr_pmplib);
00951 
00966 PMPAPI result_t pmplib_finish(pmplib_t* pmplib);
00967 
00997 PMPAPI result_t pmplib_create(pmplib_t* pmplib, pmp_t** ptr_pmp, const ucs2char_t* path_to_device, const char *id);
00998 
01016 PMPAPI result_t pmplib_enumerate_devid(pmplib_t* pmplib, pmplib_enumerate_devid_callback_t callback, void *instance);
01017 
01027 #ifdef  __cplusplus
01028 }
01029 #endif/*__cplusplus*/
01030 
01031 #endif/*__PMP_H__*/
01032