Commit 54650f35 authored by Thomas Guillem's avatar Thomas Guillem

playback_service: merge with media_list

media_list will be removed from api if it's finally only used by playback_service
parent 23567626
......@@ -28,6 +28,8 @@
#include <Emotion.h>
#include "playback_service.h"
#include "media/media_list.h"
#include "ui/interface.h"
#define PLAYLIST_CONTEXT_COUNT (PLAYLIST_CONTEXT_OTHERS + 1)
......@@ -115,6 +117,24 @@ ps_emotion_play_finished_cb(void *data, Evas_Object *obj, void *event)
media_list_set_next(p_ps->p_ml);
}
static void
ml_on_media_added_cb(media_list *p_ml, void *p_user_data, unsigned int i_pos,
media_item *p_mi)
{
playback_service *p_ps = p_user_data;
PS_SEND_CALLBACK(pf_on_media_added, i_pos, p_mi);
}
static void
ml_on_media_removed_cb(media_list *p_ml, void *p_user_data, unsigned int i_pos,
media_item *p_mi)
{
playback_service *p_ps = p_user_data;
PS_SEND_CALLBACK(pf_on_media_removed, i_pos, p_mi);
}
static void
ml_on_media_selected_cb(media_list *p_ml, void *p_user_data, unsigned int i_pos,
media_item *p_mi)
......@@ -130,6 +150,7 @@ ml_on_media_selected_cb(media_list *p_ml, void *p_user_data, unsigned int i_pos,
if (i_pos >= 0)
playback_service_start(p_ps);
}
PS_SEND_CALLBACK(pf_on_media_selected, i_pos, p_mi);
}
static Evas_Object *
......@@ -179,8 +200,8 @@ playback_service_create(application *p_app, interface *p_intf)
for (unsigned int i = 0; i < PLAYLIST_CONTEXT_COUNT; ++i)
{
media_list_callbacks cbs = {
.pf_on_media_added = NULL,
.pf_on_media_removed = NULL,
.pf_on_media_added = ml_on_media_added_cb,
.pf_on_media_removed = ml_on_media_removed_cb,
.pf_on_media_selected = ml_on_media_selected_cb,
.p_user_data = p_ps,
};
......@@ -246,12 +267,6 @@ playback_service_set_context(playback_service *p_ps, enum PLAYLIST_CONTEXT i_ctx
return 0;
}
media_list *
playback_service_get_ml(playback_service *p_ps)
{
return p_ps->p_ml;
}
void *
playback_service_register_callbacks(playback_service *p_ps, playback_service_callbacks *p_cbs)
{
......@@ -454,3 +469,69 @@ playback_service_seek_backward(playback_service *p_ps)
p_ps->b_seeking = true;
return 0;
}
int
playback_service_list_insert(playback_service *p_ps, int i_index, media_item *p_mi)
{
return media_list_insert(p_ps->p_ml, i_index, p_mi);
}
int
playback_service_list_remove(playback_service *p_ps, media_item *p_mi)
{
return media_list_remove(p_ps->p_ml, p_mi);
}
int
playback_service_list_remove_index(playback_service *p_ps, unsigned int i_index)
{
return media_list_remove_index(p_ps->p_ml, i_index);
}
void
playback_service_list_clear(playback_service *p_ps)
{
return media_list_clear(p_ps->p_ml);
}
unsigned int
playback_service_list_get_count(playback_service *p_ps)
{
return media_list_get_count(p_ps->p_ml);
}
unsigned int
playback_service_list_get_pos(playback_service *p_ps)
{
return media_list_get_pos(p_ps->p_ml);
}
void
playback_service_list_set_pos(playback_service *p_ps, unsigned int i_index)
{
media_list_set_pos(p_ps->p_ml, i_index);
}
void
playback_service_list_set_next(playback_service *p_ps)
{
media_list_set_next(p_ps->p_ml);
}
void
playback_service_list_set_prev(playback_service *p_ps)
{
media_list_set_prev(p_ps->p_ml);
}
media_item *
playback_service_list_get_item(playback_service *p_ps)
{
return media_list_get_item(p_ps->p_ml);
}
media_item *
playback_service_list_get_item_at(playback_service *p_ps, unsigned int i_index)
{
return media_list_get_item_at(p_ps->p_ml, i_index);
}
......@@ -26,7 +26,7 @@
#define PLAYBACK_SERVICE_H
#include "application.h"
#include "media/media_list.h"
#include "media/media_item.h"
enum PLAYLIST_CONTEXT {
PLAYLIST_CONTEXT_AUDIO,
......@@ -37,6 +37,9 @@ enum PLAYLIST_CONTEXT {
typedef struct playback_service_callbacks playback_service_callbacks;
struct playback_service_callbacks
{
void (*pf_on_media_added)(playback_service *p_ps, void *p_user_data, unsigned int i_pos, media_item *p_mi);
void (*pf_on_media_removed)(playback_service *p_ps, void *p_user_data, unsigned int i_pos, media_item *p_mi);
void (*pf_on_media_selected)(playback_service *p_ps, void *p_user_data, unsigned int i_pos, media_item *p_mi);
void (*pf_on_started)(playback_service *p_ps, void *p_user_data, media_item *p_mi);
void (*pf_on_stopped)(playback_service *p_ps, void *p_user_data, media_item *p_mi);
void (*pf_on_new_len)(playback_service *p_ps, void *p_user_data, double i_len);
......@@ -55,9 +58,6 @@ playback_service_destroy(playback_service *p_ps);
int
playback_service_set_context(playback_service *p_ps, enum PLAYLIST_CONTEXT i_ctx);
media_list *
playback_service_get_ml(playback_service *p_ps);
void *
playback_service_register_callbacks(playback_service *p_ps, playback_service_callbacks *p_cbs);
......@@ -109,5 +109,43 @@ playback_service_seek_forward(playback_service *p_ps);
int
playback_service_seek_backward(playback_service *p_ps);
int
playback_service_list_insert(playback_service *p_ps, int i_index, media_item *p_mi);
static inline int
playback_service_list_append(playback_service *p_ps, media_item *p_mi)
{
return playback_service_list_insert(p_ps, -1, p_mi);
}
int
playback_service_list_remove(playback_service *p_ps, media_item *p_mi);
int
playback_service_list_remove_index(playback_service *p_ps, unsigned int i_index);
void
playback_service_list_clear(playback_service *p_ps);
unsigned int
playback_service_list_get_count(playback_service *p_ps);
unsigned int
playback_service_list_get_pos(playback_service *p_ps);
void
playback_service_list_set_pos(playback_service *p_ps, unsigned int i_index);
void
playback_service_list_set_next(playback_service *p_ps);
void
playback_service_list_set_prev(playback_service *p_ps);
media_item *
playback_service_list_get_item(playback_service *p_ps);
media_item *
playback_service_list_get_item_at(playback_service *p_ps, unsigned int i_index);
#endif /* PLAYBACK_SERVICE_H */
......@@ -35,7 +35,6 @@
typedef struct video_player
{
playback_service *p_ps;
media_list *p_ml;
/* Widgets */
Evas_Object *play_pause_button, *progress_slider;
......@@ -163,10 +162,9 @@ create_video_gui(playback_service *p_ps, Evas_Object *parent, const char* file_p
LOGE("playback_service_start: %s", p_mi->psz_path);
playback_service_set_context(vd->p_ps, PLAYLIST_CONTEXT_VIDEO);
vd->p_ml = playback_service_get_ml(vd->p_ps);
media_list_clear(vd->p_ml);
media_list_append(vd->p_ml, p_mi);
playback_service_list_clear(vd->p_ps);
playback_service_list_append(vd->p_ps, p_mi);
playback_service_start(vd->p_ps);
return layout;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment