forked from enlightenment/efl
emotion/generic: Add support for fetching meta info.
SVN revision: 63219
This commit is contained in:
parent
bed7fa1c6a
commit
0d7da38f05
|
@ -186,7 +186,10 @@ static void
|
|||
_send_cmd_str(struct _App *app, const char *str)
|
||||
{
|
||||
int len;
|
||||
len = strlen(str) + 1;
|
||||
if (str)
|
||||
len = strlen(str) + 1;
|
||||
else
|
||||
len = 0;
|
||||
_em_write_safe(app->em_write, &len, sizeof(len));
|
||||
_em_write_safe(app->em_write, str, len);
|
||||
}
|
||||
|
@ -649,6 +652,36 @@ _send_all_track_info(struct _App *app)
|
|||
current, track_count, desc);
|
||||
}
|
||||
|
||||
static void
|
||||
_send_all_meta_info(struct _App *app)
|
||||
{
|
||||
const char *meta;
|
||||
|
||||
_send_cmd_start(app, EM_RESULT_META_INFO);
|
||||
|
||||
/*
|
||||
* Will send in this order: title, artist, album, year,
|
||||
* genre, comments, disc id and track count.
|
||||
*/
|
||||
meta = libvlc_media_get_meta(app->m, libvlc_meta_Title);
|
||||
_send_cmd_str(app, meta);
|
||||
meta = libvlc_media_get_meta(app->m, libvlc_meta_Artist);
|
||||
_send_cmd_str(app, meta);
|
||||
meta = libvlc_media_get_meta(app->m, libvlc_meta_Album);
|
||||
_send_cmd_str(app, meta);
|
||||
meta = libvlc_media_get_meta(app->m, libvlc_meta_Date);
|
||||
_send_cmd_str(app, meta);
|
||||
meta = libvlc_media_get_meta(app->m, libvlc_meta_Genre);
|
||||
_send_cmd_str(app, meta);
|
||||
meta = NULL; // sending empty comments
|
||||
_send_cmd_str(app, meta);
|
||||
meta = NULL; // sending empty disc id
|
||||
_send_cmd_str(app, meta);
|
||||
meta = libvlc_media_get_meta(app->m, libvlc_meta_TrackNumber);
|
||||
_send_cmd_str(app, meta);
|
||||
_send_cmd_finish(app);
|
||||
}
|
||||
|
||||
static void
|
||||
_position_changed(struct _App *app)
|
||||
{
|
||||
|
@ -665,6 +698,9 @@ _position_changed(struct _App *app)
|
|||
/* sending audio track info */
|
||||
_send_all_track_info(app);
|
||||
|
||||
/* sending meta info */
|
||||
_send_all_meta_info(app);
|
||||
|
||||
libvlc_media_player_stop(app->mp);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ enum _Emotion_Generic_Result
|
|||
EM_RESULT_VIDEO_TRACK_INFO, // param: current track, track count, track_id, track_name, track_id2, track_name2, ...
|
||||
EM_RESULT_SPU_TRACK_INFO, // param: current spu, spu count, spu_id, spu_name, spu_id2, spu_name2, ...
|
||||
// (int, int, int, string, int, string, ...)
|
||||
EM_RESULT_META_INFO, // param: title, artist, album, year, genre, comments, disc id, count (all int)
|
||||
EM_RESULT_LAST
|
||||
};
|
||||
|
||||
|
|
|
@ -497,6 +497,51 @@ _player_spu_tracks_info(Emotion_Generic_Video *ev)
|
|||
&ev->spu_channel_current);
|
||||
}
|
||||
|
||||
static void
|
||||
_player_helper_str_read(Emotion_Generic_Video *ev, const char **pstr)
|
||||
{
|
||||
int len;
|
||||
char buf[PATH_MAX];
|
||||
if (_player_str_read(ev, buf, &len))
|
||||
*pstr = eina_stringshare_add_length(buf, len);
|
||||
}
|
||||
|
||||
static void
|
||||
_player_meta_info_free(Emotion_Generic_Video *ev)
|
||||
{
|
||||
eina_stringshare_replace(&ev->meta.title, NULL);
|
||||
eina_stringshare_replace(&ev->meta.artist, NULL);
|
||||
eina_stringshare_replace(&ev->meta.album, NULL);
|
||||
eina_stringshare_replace(&ev->meta.year, NULL);
|
||||
eina_stringshare_replace(&ev->meta.genre, NULL);
|
||||
eina_stringshare_replace(&ev->meta.comment, NULL);
|
||||
eina_stringshare_replace(&ev->meta.disc_id, NULL);
|
||||
eina_stringshare_replace(&ev->meta.count, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_player_meta_info_read(Emotion_Generic_Video *ev)
|
||||
{
|
||||
INF("Receiving meta info:");
|
||||
_player_meta_info_free(ev);
|
||||
_player_helper_str_read(ev, &ev->meta.title);
|
||||
_player_helper_str_read(ev, &ev->meta.artist);
|
||||
_player_helper_str_read(ev, &ev->meta.album);
|
||||
_player_helper_str_read(ev, &ev->meta.year);
|
||||
_player_helper_str_read(ev, &ev->meta.genre);
|
||||
_player_helper_str_read(ev, &ev->meta.comment);
|
||||
_player_helper_str_read(ev, &ev->meta.disc_id);
|
||||
_player_helper_str_read(ev, &ev->meta.count);
|
||||
INF("title: '%s'", ev->meta.title);
|
||||
INF("artist: '%s'", ev->meta.artist);
|
||||
INF("album: '%s'", ev->meta.album);
|
||||
INF("year: '%s'", ev->meta.year);
|
||||
INF("genre: '%s'", ev->meta.genre);
|
||||
INF("comment: '%s'", ev->meta.comment);
|
||||
INF("disc_id: '%s'", ev->meta.disc_id);
|
||||
INF("count: '%s'", ev->meta.count);
|
||||
}
|
||||
|
||||
static void
|
||||
_player_file_closed(Emotion_Generic_Video *ev)
|
||||
{
|
||||
|
@ -593,6 +638,9 @@ _player_read_cmd(Emotion_Generic_Video *ev)
|
|||
case EM_RESULT_SPU_TRACK_INFO:
|
||||
_player_spu_tracks_info(ev);
|
||||
break;
|
||||
case EM_RESULT_META_INFO:
|
||||
_player_meta_info_read(ev);
|
||||
break;
|
||||
default:
|
||||
WRN("received wrong command: %d", type);
|
||||
};
|
||||
|
@ -812,6 +860,7 @@ em_shutdown(void *data)
|
|||
_audio_channels_free(ev);
|
||||
_video_channels_free(ev);
|
||||
_spu_channels_free(ev);
|
||||
_player_meta_info_free(ev);
|
||||
|
||||
eina_stringshare_del(ev->cmdline);
|
||||
eina_stringshare_del(ev->shmname);
|
||||
|
@ -1330,10 +1379,30 @@ em_eject(void *ef __UNUSED__)
|
|||
}
|
||||
|
||||
static const char *
|
||||
em_meta_get(void *ef __UNUSED__, int meta __UNUSED__)
|
||||
em_meta_get(void *data, int meta)
|
||||
{
|
||||
char * meta_data = NULL;
|
||||
return meta_data;
|
||||
Emotion_Generic_Video *ev = data;
|
||||
|
||||
switch (meta) {
|
||||
case EMOTION_META_INFO_TRACK_TITLE:
|
||||
return ev->meta.title;
|
||||
case EMOTION_META_INFO_TRACK_ARTIST:
|
||||
return ev->meta.artist;
|
||||
case EMOTION_META_INFO_TRACK_ALBUM:
|
||||
return ev->meta.album;
|
||||
case EMOTION_META_INFO_TRACK_YEAR:
|
||||
return ev->meta.year;
|
||||
case EMOTION_META_INFO_TRACK_GENRE:
|
||||
return ev->meta.genre;
|
||||
case EMOTION_META_INFO_TRACK_COMMENT:
|
||||
return ev->meta.comment;
|
||||
case EMOTION_META_INFO_TRACK_DISC_ID:
|
||||
return ev->meta.disc_id;
|
||||
case EMOTION_META_INFO_TRACK_COUNT:
|
||||
return ev->meta.count;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Emotion_Video_Module em_module =
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
typedef struct _Emotion_Generic_Video Emotion_Generic_Video;
|
||||
typedef struct _Emotion_Generic_Player Emotion_Generic_Player;
|
||||
typedef struct _Emotion_Generic_Channel Emotion_Generic_Channel;
|
||||
typedef struct _Emotion_Generic_Meta Emotion_Generic_Meta;
|
||||
|
||||
struct _Emotion_Generic_Player
|
||||
{
|
||||
|
@ -20,6 +21,18 @@ struct _Emotion_Generic_Channel
|
|||
const char *name;
|
||||
};
|
||||
|
||||
struct _Emotion_Generic_Meta
|
||||
{
|
||||
const char *title;
|
||||
const char *artist;
|
||||
const char *album;
|
||||
const char *year;
|
||||
const char *genre;
|
||||
const char *comment;
|
||||
const char *disc_id;
|
||||
const char *count;
|
||||
};
|
||||
|
||||
/* emotion/generic main structure */
|
||||
struct _Emotion_Generic_Video
|
||||
{
|
||||
|
@ -64,6 +77,7 @@ struct _Emotion_Generic_Video
|
|||
int spu_channels_count;
|
||||
int spu_channel_current;
|
||||
struct _Emotion_Generic_Channel *spu_channels;
|
||||
Emotion_Generic_Meta meta;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue