support events coming from xine a lot better...

still need to support title, artist etc. for mp3's and such...


SVN revision: 10579
This commit is contained in:
Carsten Haitzler 2004-06-24 10:55:43 +00:00
parent b97f661628
commit 2505c9ec3c
5 changed files with 323 additions and 81 deletions

View File

@ -474,6 +474,77 @@ video_obj_length_change_cb(void *data, Evas_Object *obj, void *event_info)
edje_object_part_text_set(oe, "video_progress_txt", buf);
}
static void
video_obj_stopped_cb(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *oe;
oe = data;
printf("video stopped!\n");
}
static void
video_obj_channels_cb(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *oe;
oe = data;
printf("channels changed: [AUD %i][VID %i][SPU %i]\n",
emotion_object_audio_channel_count(obj),
emotion_object_video_channel_count(obj),
emotion_object_spu_channel_count(obj));
}
static void
video_obj_title_cb(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *oe;
oe = data;
printf("video title to: \"%s\"\n", emotion_object_title_get(obj));
}
static void
video_obj_progress_cb(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *oe;
oe = data;
printf("progress: \"%s\" %3.3f\n",
emotion_object_progress_info_get(obj),
emotion_object_progress_status_get(obj));
}
static void
video_obj_ref_cb(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *oe;
oe = data;
printf("video ref to: \"%s\" %i\n",
emotion_object_ref_file_get(obj),
emotion_object_ref_num_get(obj));
}
static void
video_obj_button_num_cb(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *oe;
oe = data;
printf("video spu buttons to: %i\n",
emotion_object_spu_button_count_get(obj));
}
static void
video_obj_button_cb(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *oe;
oe = data;
printf("video selected spu button: %i\n",
emotion_object_spu_button_get(obj));
}
@ -621,18 +692,6 @@ init_video_object(char *file)
Frame_Data *fd;
/* basic video object setup */
o = emotion_object_add(evas);
emotion_object_file_set(o, file);
@ -642,18 +701,7 @@ init_video_object(char *file)
emotion_object_smooth_scale_set(o, 1);
evas_object_show(o);
/* end basic video setup. all the rest here is just to be fancy */
video_objs = evas_list_append(video_objs, o);
@ -677,7 +725,15 @@ init_video_object(char *file)
evas_object_smart_callback_add(o, "frame_decode", video_obj_frame_decode_cb, oe);
evas_object_smart_callback_add(o, "frame_resize", video_obj_frame_resize_cb, oe);
evas_object_smart_callback_add(o, "length_change", video_obj_length_change_cb, oe);
evas_object_smart_callback_add(o, "decode_stop", video_obj_stopped_cb, oe);
evas_object_smart_callback_add(o, "channels_change", video_obj_channels_cb, oe);
evas_object_smart_callback_add(o, "title_change", video_obj_title_cb, oe);
evas_object_smart_callback_add(o, "progress_change", video_obj_progress_cb, oe);
evas_object_smart_callback_add(o, "ref_change", video_obj_ref_cb, oe);
evas_object_smart_callback_add(o, "button_num_change", video_obj_button_num_cb, oe);
evas_object_smart_callback_add(o, "button_change", video_obj_button_cb, oe);
edje_object_signal_callback_add(oe, "video_control", "play", video_obj_signal_play_cb, o);
edje_object_signal_callback_add(oe, "video_control", "pause", video_obj_signal_pause_cb, o);
edje_object_signal_callback_add(oe, "video_control", "stop", video_obj_signal_stop_cb, o);

View File

@ -70,12 +70,12 @@ int emotion_object_video_channel_count (Evas_Object *obj);
const char *emotion_object_video_channel_name_get(Evas_Object *obj, int channel);
void emotion_object_video_channel_set (Evas_Object *obj, int channel);
int emotion_object_video_channel_get (Evas_Object *obj);
void emotion_object_spu_mute_set (Evas_Object *obj, Evas_Bool mute);
Evas_Bool emotion_object_spu_mute_get (Evas_Object *obj);
int emotion_object_spu_channel_count (Evas_Object *obj);
const char *emotion_object_spu_channel_name_get(Evas_Object *obj, int channel);
void emotion_object_spu_channel_set (Evas_Object *obj, int channel);
int emotion_object_spu_channel_get (Evas_Object *obj);
void emotion_object_spu_mute_set (Evas_Object *obj, Evas_Bool mute);
Evas_Bool emotion_object_spu_mute_get (Evas_Object *obj);
int emotion_object_spu_channel_count (Evas_Object *obj);
const char *emotion_object_spu_channel_name_get (Evas_Object *obj, int channel);
void emotion_object_spu_channel_set (Evas_Object *obj, int channel);
int emotion_object_spu_channel_get (Evas_Object *obj);
int emotion_object_chapter_count (Evas_Object *obj);
void emotion_object_chapter_set (Evas_Object *obj, int chapter);
int emotion_object_chapter_get (Evas_Object *obj);
@ -83,5 +83,12 @@ const char *emotion_object_chapter_name_get (Evas_Object *obj, int chapter
void emotion_object_play_speed_set (Evas_Object *obj, double speed);
double emotion_object_play_speed_get (Evas_Object *obj);
void emotion_object_eject (Evas_Object *obj);
const char *emotion_object_title_get (Evas_Object *obj);
const char *emotion_object_progress_info_get (Evas_Object *obj);
double emotion_object_progress_status_get (Evas_Object *obj);
const char *emotion_object_ref_file_get (Evas_Object *obj);
int emotion_object_ref_num_get (Evas_Object *obj);
int emotion_object_spu_button_count_get (Evas_Object *obj);
int emotion_object_spu_button_get (Evas_Object *obj);
#endif

View File

@ -65,5 +65,12 @@ void *_emotion_video_get(Evas_Object *obj);
void _emotion_frame_new(Evas_Object *obj);
void _emotion_video_pos_update(Evas_Object *obj, double pos, double len);
void _emotion_frame_resize(Evas_Object *obj, int w, int h, double ratio);
void _emotion_decode_stop(Evas_Object *obj);
void _emotion_channels_change(Evas_Object *obj);
void _emotion_title_set(Evas_Object *obj, char *title);
void _emotion_progress_set(Evas_Object *obj, char *info, double stat);
void _emotion_file_ref_set(Evas_Object *obj, char *file, int num);
void _emotion_spu_button_num_set(Evas_Object *obj, int num);
void _emotion_spu_button_set(Evas_Object *obj, int button);
#endif

View File

@ -46,6 +46,20 @@ struct _Smart_Data
unsigned char play : 1;
unsigned char seek : 1;
char *title;
struct {
char *info;
double stat;
} progress;
struct {
char *file;
int num;
} ref;
struct {
int button_num;
int button;
} spu;
};
static void _mouse_move(void *data, Evas *ev, Evas_Object *obj, void *event_info);
@ -135,7 +149,20 @@ emotion_object_file_set(Evas_Object *obj, const char *file)
if ((file) && (sd->file) && (!strcmp(file, sd->file))) return;
if (sd->file) free(sd->file);
sd->file = NULL;
if (sd->title) free(sd->title);
sd->title = NULL;
if (sd->progress.info) free(sd->progress.info);
sd->progress.info = NULL;
sd->progress.stat = 0.0;
if (sd->ref.file) free(sd->ref.file);
sd->ref.file = NULL;
sd->ref.num = 0;
sd->spu.button_num = 0;
sd->spu.button = -1;
sd->ratio = 1.0;
sd->pos = 0;
sd->seek_pos = 0;
sd->len = 0;
if (file)
{
int w, h;
@ -598,6 +625,70 @@ emotion_object_eject(Evas_Object *obj)
sd->module->eject(sd->video);
}
const char *
emotion_object_title_get(Evas_Object *obj)
{
Smart_Data *sd;
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
return sd->title;
}
const char *
emotion_object_progress_info_get(Evas_Object *obj)
{
Smart_Data *sd;
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
return sd->progress.info;
}
double
emotion_object_progress_status_get(Evas_Object *obj)
{
Smart_Data *sd;
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0);
return sd->progress.stat;
}
const char *
emotion_object_ref_file_get(Evas_Object *obj)
{
Smart_Data *sd;
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
return sd->ref.file;
}
int
emotion_object_ref_num_get(Evas_Object *obj)
{
Smart_Data *sd;
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
return sd->ref.num;
}
int
emotion_object_spu_button_count_get(Evas_Object *obj)
{
Smart_Data *sd;
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
return sd->spu.button_num;
}
int
emotion_object_spu_button_get(Evas_Object *obj)
{
Smart_Data *sd;
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
return sd->spu.button;
}
@ -650,6 +741,8 @@ _emotion_frame_resize(Evas_Object *obj, int w, int h, double ratio)
evas_object_image_size_get(sd->obj, &iw, &ih);
if ((w != iw) || (h != ih))
{
if (h > 0) sd->ratio = (double)w / (double)h;
else sd->ratio = 1.0;
evas_object_image_size_set(sd->obj, w, h);
changed = 1;
}
@ -661,6 +754,83 @@ _emotion_frame_resize(Evas_Object *obj, int w, int h, double ratio)
if (changed) evas_object_smart_callback_call(obj, "frame_resize", NULL);
}
void
_emotion_decode_stop(Evas_Object *obj)
{
Smart_Data *sd;
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
if (sd->play)
{
sd->play = 0;
evas_object_smart_callback_call(obj, "decode_stop", NULL);
}
}
void
_emotion_channels_change(Evas_Object *obj)
{
Smart_Data *sd;
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
evas_object_smart_callback_call(obj, "channels_change", NULL);
}
void
_emotion_title_set(Evas_Object *obj, char *title)
{
Smart_Data *sd;
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
if (sd->title) free(sd->title);
sd->title = strdup(title);
evas_object_smart_callback_call(obj, "title_change", NULL);
}
void
_emotion_progress_set(Evas_Object *obj, char *info, double stat)
{
Smart_Data *sd;
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
if (sd->progress.info) free(sd->progress.info);
sd->progress.info = strdup(info);
sd->progress.stat = stat;
evas_object_smart_callback_call(obj, "progress_change", NULL);
}
void
_emotion_file_ref_set(Evas_Object *obj, char *file, int num)
{
Smart_Data *sd;
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
if (sd->ref.file) free(sd->ref.file);
sd->ref.file = strdup(file);
sd->ref.num = num;
evas_object_smart_callback_call(obj, "ref_change", NULL);
}
void
_emotion_spu_button_num_set(Evas_Object *obj, int num)
{
Smart_Data *sd;
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
sd->spu.button_num = num;
evas_object_smart_callback_call(obj, "button_num_change", NULL);
}
void
_emotion_spu_button_set(Evas_Object *obj, int button)
{
Smart_Data *sd;
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
sd->spu.button = button;
evas_object_smart_callback_call(obj, "button_change", NULL);
}
/****************************/
/* Internal object routines */
@ -803,6 +973,7 @@ _smart_add(Evas_Object * obj)
evas_object_image_pixels_get_callback_set(sd->obj, _pixels_get, sd);
evas_object_smart_member_add(sd->obj, obj);
sd->ratio = 1.0;
sd->spu.button = -1;
evas_object_image_alpha_set(sd->obj, 0);
evas_object_smart_data_set(obj, sd);
}
@ -819,6 +990,8 @@ _smart_del(Evas_Object * obj)
evas_object_del(sd->obj);
if (sd->file) free(sd->file);
if (sd->job) ecore_job_del(sd->job);
if (sd->progress.info) free(sd->progress.info);
if (sd->ref.file) free(sd->ref.file);
free(sd);
}

View File

@ -244,7 +244,7 @@ em_file_open(const char *file, Evas_Object *obj)
xine_config_update_entry(decoder, &cf);
}
}
if (1)
if (0)
{
xine_mrl_t **mrls;
int mrls_num;
@ -263,7 +263,7 @@ em_file_open(const char *file, Evas_Object *obj)
}
}
}
if (1)
if (0)
{
char **auto_play_mrls;
int auto_play_num;
@ -1040,104 +1040,103 @@ _em_fd_ev_active(void *data, Ecore_Fd_Handler *fdh)
Emotion_Xine_Video *ev;
Emotion_Xine_Event *eev;
printf("event from xine...\n");
ev = buf[0];
eev = buf[1];
switch (eev->type)
{
case XINE_EVENT_UI_PLAYBACK_FINISHED:
{
printf("EV: Playback finished\n");
/* no data in this event */
if (ev->timer)
{
ecore_timer_del(ev->timer);
ev->timer = NULL;
}
ev->play = 0;
_emotion_decode_stop(ev->obj);
}
break;
case XINE_EVENT_UI_CHANNELS_CHANGED:
{
printf("EV: Channels changed\n");
/* no data in this event */
_emotion_channels_change(ev->obj);
}
break;
case XINE_EVENT_UI_SET_TITLE:
{
xine_ui_data_t *ev;
xine_ui_data_t *e;
ev = eev->xine_event;
printf("EV: New Title \"%s\"\n", ev->str);
// title is ev->str
e = eev->xine_event;
_emotion_title_set(ev->obj, e->str);
}
break;
case XINE_EVENT_UI_MESSAGE:
{
xine_ui_message_data_t *ev;
xine_ui_message_data_t *e;
ev = eev->xine_event;
printf("EV: UI Message\n");
// ev->type = error type(XINE_MSG_NO_ERROR, XINE_MSG_GENERAL_WARNING, XINE_MSG_UNKNOWN_HOST etc.)
// ev->messages is a list of messages DOUBLE null terminated
e = eev->xine_event;
printf("EV: UI Message [FIXME: break this out to emotion api]\n");
// e->type = error type(XINE_MSG_NO_ERROR, XINE_MSG_GENERAL_WARNING, XINE_MSG_UNKNOWN_HOST etc.)
// e->messages is a list of messages DOUBLE null terminated
}
break;
case XINE_EVENT_AUDIO_LEVEL:
{
xine_audio_level_data_t *ev;
xine_audio_level_data_t *e;
ev = eev->xine_event;
printf("EV: Audio Level\n");
// ev->left (0->100)
// ev->right
// ev->mute
e = eev->xine_event;
printf("EV: Audio Level [FIXME: break this out to emotion api]\n");
// e->left (0->100)
// e->right
// e->mute
}
break;
case XINE_EVENT_PROGRESS:
{
xine_progress_data_t *ev;
xine_progress_data_t *e;
ev = eev->xine_event;
printf("EV: Progress \"%s\" %i%%\n", ev->description, ev->percent);
// ev->description is text
// ev->percent is a percentage marker (0-100)
e = eev->xine_event;
_emotion_progress_set(ev->obj, e->description, (double)e->percent / 100.0);
}
break;
case XINE_EVENT_MRL_REFERENCE:
{
xine_mrl_reference_data_t *ev;
xine_mrl_reference_data_t *e;
ev = eev->xine_event;
printf("EV: MRL Ref to \"%s\"\n", ev->mrl);
// ev->alternative alternative playlist no
// ev->mrl is the mrl
e = eev->xine_event;
_emotion_file_ref_set(ev->obj, e->mrl, e->alternative);
}
break;
case XINE_EVENT_UI_NUM_BUTTONS:
{
xine_ui_data_t *ev;
xine_ui_data_t *e;
ev = eev->xine_event;
printf("EV: Num buttons %i\n", ev->num_buttons);
// ev->num_buttons indicates how many buttons in the spu
e = eev->xine_event;
_emotion_spu_button_num_set(ev->obj, e->num_buttons);
}
break;
case XINE_EVENT_SPU_BUTTON:
{
xine_spu_button_t *ev;
xine_spu_button_t *e;
ev = eev->xine_event;
printf("EV: Button enter? [%i] %i\n", ev->direction, ev->button);
// ev->direction 1 = enter, 0 = leave
// ev->button button number entered/left
e = eev->xine_event;
if (e->direction == 1)
_emotion_spu_button_set(ev->obj, e->button);
else
_emotion_spu_button_set(ev->obj, -1);
}
break;
case XINE_EVENT_DROPPED_FRAMES:
{
xine_dropped_frames_t *ev;
xine_dropped_frames_t *e;
ev = eev->xine_event;
printf("EV: Dropped Frames (skipped %i) (discarded %i)\n", ev->skipped_frames, ev->discarded_frames);
// ev->skipped_frames = % frames skipped * 10
// ev->discarded_frames = % frames skipped * 10
e = eev->xine_event;
printf("EV: Dropped Frames (skipped %i) (discarded %i) [FIXME: break this out to the emotion api]\n", e->skipped_frames, e->discarded_frames);
// e->skipped_frames = % frames skipped * 10
// e->discarded_frames = % frames skipped * 10
}
break;
default:
return;
// printf("EV: unknown event type %i\n", eev->type);
break;
}
if (eev->xine_event) free(eev->xine_event);
free(eev);