From: Davide Andreoli <dave@gurumeditation.it>

Subject: [E-devel] Emotion buffer size patch

Hi, here is a patch for emotion, it add a new function to retrive the
status of the buffer while playing online stream.
It is implemented only for the gstreamer backend, the xine one
do not play at all here. What about the generic one?

(xine does play - i implameneted this with the xine module, and
generic is given a func that always returns 1.0 for now).



SVN revision: 68684
This commit is contained in:
Davide Andreoli 2012-03-05 09:33:05 +00:00 committed by Carsten Haitzler
parent f5bfcc675b
commit cd00891529
8 changed files with 86 additions and 4 deletions

View File

@ -300,13 +300,14 @@ bg_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED
static void
video_obj_time_changed(Evas_Object *obj, Evas_Object *edje)
{
double pos, len, scale;
double pos, len, scale, bsize;
char buf[256];
int ph, pm, ps, pf, lh, lm, ls;
pos = emotion_object_position_get(obj);
len = emotion_object_play_length_get(obj);
// printf("%3.3f, %3.3f\n", pos, len);
bsize = emotion_object_buffer_size_get(obj);
// printf("%3.3f, %3.3f [%.2f]\n", pos, len, bsize);
scale = (len > 0.0) ? pos / len : 0.0;
edje_object_part_drag_value_set(edje, "video_progress", scale, 0.0);
lh = len / 3600;

View File

@ -632,6 +632,23 @@ EAPI void emotion_object_position_set (Evas_Object *obj, double
* media file.
*/
EAPI double emotion_object_position_get (const Evas_Object *obj);
/**
* @brief Get the percentual size of the buffering cache.
*
* @param obj The emotion object from which the buffer size will be retrieved.
* @return The buffer percent size, ranging from 0.0 to 1.0
*
* The buffer size is returned as a number between 0.0 and 1.0, 0.0 means
* the buffer if empty, 1.0 means full.
* If no buffering is in progress 1.0 is returned. In all other cases (maybe
* the backend don't support buffering) 1.0 is returned, thus you can always
* check for buffer_size < 1.0 to know if buffering is in progress.
*
* @warning xine backends don't implement this (will return 1.0).
*/
EAPI double emotion_object_buffer_size_get (const Evas_Object *obj);
/**
* @brief Get whether the media file is seekable.
*

View File

@ -51,6 +51,7 @@ struct _Emotion_Video_Module
void (*size_get) (void *ef, int *w, int *h);
void (*pos_set) (void *ef, double pos);
double (*len_get) (void *ef);
double (*buffer_size_get) (void *ef);
int (*fps_num_get) (void *ef);
int (*fps_den_get) (void *ef);
double (*fps_get) (void *ef);

View File

@ -761,6 +761,18 @@ emotion_object_position_get(const Evas_Object *obj)
return sd->pos;
}
EAPI double
emotion_object_buffer_size_get(const Evas_Object *obj)
{
Smart_Data *sd;
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 1.0);
if (!sd->module) return 1.0;
if (!sd->video_data) return 1.0;
if (!sd->module->buffer_size_get) return 1.0;
return sd->module->buffer_size_get(sd->video_data);
}
EAPI Eina_Bool
emotion_object_seekable_get(const Evas_Object *obj)
{

View File

@ -332,7 +332,7 @@ _player_position_changed(Emotion_Generic_Video *ev)
ev->pos = position;
_emotion_video_pos_update(ev->obj, ev->pos, ev->len);
/* hmmm. no _emotion_progress_set() is for "buffering" progress.
if (ev->len == 0)
return;
@ -341,6 +341,7 @@ _player_position_changed(Emotion_Generic_Video *ev)
snprintf(buf, sizeof(buf), "%0.1f%%", progress * 100);
_emotion_progress_set(ev->obj, buf, progress);
*/
}
static void
@ -1162,6 +1163,14 @@ em_len_get(void *data)
return ev->len;
}
static double
em_buffer_size_get(void *data)
{
Emotion_Generic_Video *ev = data;
return 1.0;
ev = NULL;
}
static int
em_fps_num_get(void *data)
{
@ -1597,6 +1606,7 @@ static Emotion_Video_Module em_module =
em_size_get, /* size_get */
em_pos_set, /* pos_set */
em_len_get, /* len_get */
em_buffer_size_get, /* buffer_size_get */
em_fps_num_get, /* fps_num_get */
em_fps_den_get, /* fps_den_get */
em_fps_get, /* fps_get */

View File

@ -67,6 +67,8 @@ static void em_pos_set (void *video,
static double em_len_get (void *video);
static double em_buffer_size_get (void *video);
static int em_fps_num_get (void *video);
static int em_fps_den_get (void *video);
@ -212,6 +214,7 @@ static Emotion_Video_Module em_module =
em_size_get, /* size_get */
em_pos_set, /* pos_set */
em_len_get, /* len_get */
em_buffer_size_get, /* buffer_size_get */
em_fps_num_get, /* fps_num_get */
em_fps_den_get, /* fps_den_get */
em_fps_get, /* fps_get */
@ -685,6 +688,29 @@ em_len_get(void *video)
return 0.0;
}
static double
em_buffer_size_get(void *video)
{
Emotion_Gstreamer_Video *ev;
GstQuery *query;
gboolean busy;
gint percent;
ev = video;
if (!ev->pipeline) return 0.0;
query = gst_query_new_buffering(GST_FORMAT_DEFAULT);
if (gst_element_query(ev->pipeline, query))
gst_query_parse_buffering_percent(query, &busy, &percent);
else
percent = 100;
gst_query_unref(query);
return ((float)(percent)) / 100.0;
}
static int
em_fps_num_get(void *video)
{

View File

@ -21,6 +21,7 @@ static void em_play (void *ef, double pos);
static void em_stop (void *ef);
static void em_size_get (void *ef, int *w, int *h);
static void em_pos_set (void *ef, double pos);
static double em_buffer_size_get (void *ef);
static double em_len_get (void *ef);
static int em_fps_num_get (void *ef);
static int em_fps_den_get (void *ef);
@ -425,6 +426,8 @@ em_init(Evas_Object *obj, void **emotion_video, Emotion_Module_Options *opt)
pthread_create(&ev->slave_th, NULL, _em_slave, ev);
pthread_detach(ev->slave_th);
_em_slave_event(ev, 1, NULL);
ev->buffer = 1.0;
*emotion_video = ev;
return 1;
@ -532,6 +535,15 @@ em_len_get(void *ef)
return ev->len;
}
static double
em_buffer_size_get(void *ef)
{
Emotion_Xine_Video *ev;
ev = (Emotion_Xine_Video *)ef;
return ev->buffer;
}
static int
em_fps_num_get(void *ef)
{
@ -1251,7 +1263,7 @@ _em_fd_ev_active(void *data __UNUSED__, Ecore_Fd_Handler *fdh)
{
int fd, len;
void *buf[2];
fd = ecore_main_fd_handler_fd_get(fdh);
while ((len = read(fd, buf, sizeof(buf))) > 0)
{
@ -1399,6 +1411,7 @@ _em_fd_ev_active(void *data __UNUSED__, Ecore_Fd_Handler *fdh)
e = (xine_progress_data_t *)eev->xine_event;
DBG("PROGRESS: %i", e->percent);
ev->buffer = e->percent;
_emotion_progress_set(ev->obj, (char *)e->description, (double)e->percent / 100.0);
}
break;
@ -1518,6 +1531,7 @@ static Emotion_Video_Module em_module =
em_size_get, /* size_get */
em_pos_set, /* pos_set */
em_len_get, /* len_get */
em_buffer_size_get, /* buffer_size_get */
em_fps_num_get, /* fps_num_get */
em_fps_den_get, /* fps_den_get */
em_fps_get, /* fps_get */

View File

@ -22,6 +22,7 @@ struct _Emotion_Xine_Video
volatile double pos;
volatile double last_pos;
volatile double volume;
volatile double buffer;
double fps;
double ratio;
int w, h;