summaryrefslogtreecommitdiff
path: root/legacy/emotion
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2012-03-05 09:33:05 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-03-05 09:33:05 +0000
commitcd00891529cab4ef46287696aa881336d58a24b4 (patch)
treeb127f0b4493141f47527a20fe7176ce727e2c9cc /legacy/emotion
parentf5bfcc675be99363247a524e2a8236c810ddd02d (diff)
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
Diffstat (limited to 'legacy/emotion')
-rw-r--r--legacy/emotion/src/bin/emotion_test_main.c5
-rw-r--r--legacy/emotion/src/lib/Emotion.h17
-rw-r--r--legacy/emotion/src/lib/emotion_private.h1
-rw-r--r--legacy/emotion/src/lib/emotion_smart.c12
-rw-r--r--legacy/emotion/src/modules/generic/emotion_generic.c12
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c26
-rw-r--r--legacy/emotion/src/modules/xine/emotion_xine.c16
-rw-r--r--legacy/emotion/src/modules/xine/emotion_xine.h1
8 files changed, 86 insertions, 4 deletions
diff --git a/legacy/emotion/src/bin/emotion_test_main.c b/legacy/emotion/src/bin/emotion_test_main.c
index 1ea3865a3c..6f9b3034e4 100644
--- a/legacy/emotion/src/bin/emotion_test_main.c
+++ b/legacy/emotion/src/bin/emotion_test_main.c
@@ -300,13 +300,14 @@ bg_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED
300static void 300static void
301video_obj_time_changed(Evas_Object *obj, Evas_Object *edje) 301video_obj_time_changed(Evas_Object *obj, Evas_Object *edje)
302{ 302{
303 double pos, len, scale; 303 double pos, len, scale, bsize;
304 char buf[256]; 304 char buf[256];
305 int ph, pm, ps, pf, lh, lm, ls; 305 int ph, pm, ps, pf, lh, lm, ls;
306 306
307 pos = emotion_object_position_get(obj); 307 pos = emotion_object_position_get(obj);
308 len = emotion_object_play_length_get(obj); 308 len = emotion_object_play_length_get(obj);
309// printf("%3.3f, %3.3f\n", pos, len); 309 bsize = emotion_object_buffer_size_get(obj);
310 // printf("%3.3f, %3.3f [%.2f]\n", pos, len, bsize);
310 scale = (len > 0.0) ? pos / len : 0.0; 311 scale = (len > 0.0) ? pos / len : 0.0;
311 edje_object_part_drag_value_set(edje, "video_progress", scale, 0.0); 312 edje_object_part_drag_value_set(edje, "video_progress", scale, 0.0);
312 lh = len / 3600; 313 lh = len / 3600;
diff --git a/legacy/emotion/src/lib/Emotion.h b/legacy/emotion/src/lib/Emotion.h
index bfd448b066..3e70b242e7 100644
--- a/legacy/emotion/src/lib/Emotion.h
+++ b/legacy/emotion/src/lib/Emotion.h
@@ -632,6 +632,23 @@ EAPI void emotion_object_position_set (Evas_Object *obj, double
632 * media file. 632 * media file.
633 */ 633 */
634EAPI double emotion_object_position_get (const Evas_Object *obj); 634EAPI double emotion_object_position_get (const Evas_Object *obj);
635
636/**
637 * @brief Get the percentual size of the buffering cache.
638 *
639 * @param obj The emotion object from which the buffer size will be retrieved.
640 * @return The buffer percent size, ranging from 0.0 to 1.0
641 *
642 * The buffer size is returned as a number between 0.0 and 1.0, 0.0 means
643 * the buffer if empty, 1.0 means full.
644 * If no buffering is in progress 1.0 is returned. In all other cases (maybe
645 * the backend don't support buffering) 1.0 is returned, thus you can always
646 * check for buffer_size < 1.0 to know if buffering is in progress.
647 *
648 * @warning xine backends don't implement this (will return 1.0).
649 */
650EAPI double emotion_object_buffer_size_get (const Evas_Object *obj);
651
635/** 652/**
636 * @brief Get whether the media file is seekable. 653 * @brief Get whether the media file is seekable.
637 * 654 *
diff --git a/legacy/emotion/src/lib/emotion_private.h b/legacy/emotion/src/lib/emotion_private.h
index 65954364a1..4f9458fb34 100644
--- a/legacy/emotion/src/lib/emotion_private.h
+++ b/legacy/emotion/src/lib/emotion_private.h
@@ -51,6 +51,7 @@ struct _Emotion_Video_Module
51 void (*size_get) (void *ef, int *w, int *h); 51 void (*size_get) (void *ef, int *w, int *h);
52 void (*pos_set) (void *ef, double pos); 52 void (*pos_set) (void *ef, double pos);
53 double (*len_get) (void *ef); 53 double (*len_get) (void *ef);
54 double (*buffer_size_get) (void *ef);
54 int (*fps_num_get) (void *ef); 55 int (*fps_num_get) (void *ef);
55 int (*fps_den_get) (void *ef); 56 int (*fps_den_get) (void *ef);
56 double (*fps_get) (void *ef); 57 double (*fps_get) (void *ef);
diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c
index 4b37879b58..141137442f 100644
--- a/legacy/emotion/src/lib/emotion_smart.c
+++ b/legacy/emotion/src/lib/emotion_smart.c
@@ -761,6 +761,18 @@ emotion_object_position_get(const Evas_Object *obj)
761 return sd->pos; 761 return sd->pos;
762} 762}
763 763
764EAPI double
765emotion_object_buffer_size_get(const Evas_Object *obj)
766{
767 Smart_Data *sd;
768
769 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 1.0);
770 if (!sd->module) return 1.0;
771 if (!sd->video_data) return 1.0;
772 if (!sd->module->buffer_size_get) return 1.0;
773 return sd->module->buffer_size_get(sd->video_data);
774}
775
764EAPI Eina_Bool 776EAPI Eina_Bool
765emotion_object_seekable_get(const Evas_Object *obj) 777emotion_object_seekable_get(const Evas_Object *obj)
766{ 778{
diff --git a/legacy/emotion/src/modules/generic/emotion_generic.c b/legacy/emotion/src/modules/generic/emotion_generic.c
index bf440f4650..1e2d139535 100644
--- a/legacy/emotion/src/modules/generic/emotion_generic.c
+++ b/legacy/emotion/src/modules/generic/emotion_generic.c
@@ -332,7 +332,7 @@ _player_position_changed(Emotion_Generic_Video *ev)
332 332
333 ev->pos = position; 333 ev->pos = position;
334 _emotion_video_pos_update(ev->obj, ev->pos, ev->len); 334 _emotion_video_pos_update(ev->obj, ev->pos, ev->len);
335 335/* hmmm. no _emotion_progress_set() is for "buffering" progress.
336 if (ev->len == 0) 336 if (ev->len == 0)
337 return; 337 return;
338 338
@@ -341,6 +341,7 @@ _player_position_changed(Emotion_Generic_Video *ev)
341 snprintf(buf, sizeof(buf), "%0.1f%%", progress * 100); 341 snprintf(buf, sizeof(buf), "%0.1f%%", progress * 100);
342 342
343 _emotion_progress_set(ev->obj, buf, progress); 343 _emotion_progress_set(ev->obj, buf, progress);
344 */
344} 345}
345 346
346static void 347static void
@@ -1162,6 +1163,14 @@ em_len_get(void *data)
1162 return ev->len; 1163 return ev->len;
1163} 1164}
1164 1165
1166static double
1167em_buffer_size_get(void *data)
1168{
1169 Emotion_Generic_Video *ev = data;
1170 return 1.0;
1171 ev = NULL;
1172}
1173
1165static int 1174static int
1166em_fps_num_get(void *data) 1175em_fps_num_get(void *data)
1167{ 1176{
@@ -1597,6 +1606,7 @@ static Emotion_Video_Module em_module =
1597 em_size_get, /* size_get */ 1606 em_size_get, /* size_get */
1598 em_pos_set, /* pos_set */ 1607 em_pos_set, /* pos_set */
1599 em_len_get, /* len_get */ 1608 em_len_get, /* len_get */
1609 em_buffer_size_get, /* buffer_size_get */
1600 em_fps_num_get, /* fps_num_get */ 1610 em_fps_num_get, /* fps_num_get */
1601 em_fps_den_get, /* fps_den_get */ 1611 em_fps_den_get, /* fps_den_get */
1602 em_fps_get, /* fps_get */ 1612 em_fps_get, /* fps_get */
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
index 9f0051b7c0..9d6b213563 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
@@ -67,6 +67,8 @@ static void em_pos_set (void *video,
67 67
68static double em_len_get (void *video); 68static double em_len_get (void *video);
69 69
70static double em_buffer_size_get (void *video);
71
70static int em_fps_num_get (void *video); 72static int em_fps_num_get (void *video);
71 73
72static int em_fps_den_get (void *video); 74static int em_fps_den_get (void *video);
@@ -212,6 +214,7 @@ static Emotion_Video_Module em_module =
212 em_size_get, /* size_get */ 214 em_size_get, /* size_get */
213 em_pos_set, /* pos_set */ 215 em_pos_set, /* pos_set */
214 em_len_get, /* len_get */ 216 em_len_get, /* len_get */
217 em_buffer_size_get, /* buffer_size_get */
215 em_fps_num_get, /* fps_num_get */ 218 em_fps_num_get, /* fps_num_get */
216 em_fps_den_get, /* fps_den_get */ 219 em_fps_den_get, /* fps_den_get */
217 em_fps_get, /* fps_get */ 220 em_fps_get, /* fps_get */
@@ -685,6 +688,29 @@ em_len_get(void *video)
685 return 0.0; 688 return 0.0;
686} 689}
687 690
691static double
692em_buffer_size_get(void *video)
693{
694 Emotion_Gstreamer_Video *ev;
695
696 GstQuery *query;
697 gboolean busy;
698 gint percent;
699
700 ev = video;
701
702 if (!ev->pipeline) return 0.0;
703
704 query = gst_query_new_buffering(GST_FORMAT_DEFAULT);
705 if (gst_element_query(ev->pipeline, query))
706 gst_query_parse_buffering_percent(query, &busy, &percent);
707 else
708 percent = 100;
709
710 gst_query_unref(query);
711 return ((float)(percent)) / 100.0;
712}
713
688static int 714static int
689em_fps_num_get(void *video) 715em_fps_num_get(void *video)
690{ 716{
diff --git a/legacy/emotion/src/modules/xine/emotion_xine.c b/legacy/emotion/src/modules/xine/emotion_xine.c
index 4108e73064..dd4a3a50cd 100644
--- a/legacy/emotion/src/modules/xine/emotion_xine.c
+++ b/legacy/emotion/src/modules/xine/emotion_xine.c
@@ -21,6 +21,7 @@ static void em_play (void *ef, double pos);
21static void em_stop (void *ef); 21static void em_stop (void *ef);
22static void em_size_get (void *ef, int *w, int *h); 22static void em_size_get (void *ef, int *w, int *h);
23static void em_pos_set (void *ef, double pos); 23static void em_pos_set (void *ef, double pos);
24static double em_buffer_size_get (void *ef);
24static double em_len_get (void *ef); 25static double em_len_get (void *ef);
25static int em_fps_num_get (void *ef); 26static int em_fps_num_get (void *ef);
26static int em_fps_den_get (void *ef); 27static int em_fps_den_get (void *ef);
@@ -425,6 +426,8 @@ em_init(Evas_Object *obj, void **emotion_video, Emotion_Module_Options *opt)
425 pthread_create(&ev->slave_th, NULL, _em_slave, ev); 426 pthread_create(&ev->slave_th, NULL, _em_slave, ev);
426 pthread_detach(ev->slave_th); 427 pthread_detach(ev->slave_th);
427 _em_slave_event(ev, 1, NULL); 428 _em_slave_event(ev, 1, NULL);
429
430 ev->buffer = 1.0;
428 431
429 *emotion_video = ev; 432 *emotion_video = ev;
430 return 1; 433 return 1;
@@ -532,6 +535,15 @@ em_len_get(void *ef)
532 return ev->len; 535 return ev->len;
533} 536}
534 537
538static double
539em_buffer_size_get(void *ef)
540{
541 Emotion_Xine_Video *ev;
542
543 ev = (Emotion_Xine_Video *)ef;
544 return ev->buffer;
545}
546
535static int 547static int
536em_fps_num_get(void *ef) 548em_fps_num_get(void *ef)
537{ 549{
@@ -1251,7 +1263,7 @@ _em_fd_ev_active(void *data __UNUSED__, Ecore_Fd_Handler *fdh)
1251{ 1263{
1252 int fd, len; 1264 int fd, len;
1253 void *buf[2]; 1265 void *buf[2];
1254 1266
1255 fd = ecore_main_fd_handler_fd_get(fdh); 1267 fd = ecore_main_fd_handler_fd_get(fdh);
1256 while ((len = read(fd, buf, sizeof(buf))) > 0) 1268 while ((len = read(fd, buf, sizeof(buf))) > 0)
1257 { 1269 {
@@ -1399,6 +1411,7 @@ _em_fd_ev_active(void *data __UNUSED__, Ecore_Fd_Handler *fdh)
1399 1411
1400 e = (xine_progress_data_t *)eev->xine_event; 1412 e = (xine_progress_data_t *)eev->xine_event;
1401 DBG("PROGRESS: %i", e->percent); 1413 DBG("PROGRESS: %i", e->percent);
1414 ev->buffer = e->percent;
1402 _emotion_progress_set(ev->obj, (char *)e->description, (double)e->percent / 100.0); 1415 _emotion_progress_set(ev->obj, (char *)e->description, (double)e->percent / 100.0);
1403 } 1416 }
1404 break; 1417 break;
@@ -1518,6 +1531,7 @@ static Emotion_Video_Module em_module =
1518 em_size_get, /* size_get */ 1531 em_size_get, /* size_get */
1519 em_pos_set, /* pos_set */ 1532 em_pos_set, /* pos_set */
1520 em_len_get, /* len_get */ 1533 em_len_get, /* len_get */
1534 em_buffer_size_get, /* buffer_size_get */
1521 em_fps_num_get, /* fps_num_get */ 1535 em_fps_num_get, /* fps_num_get */
1522 em_fps_den_get, /* fps_den_get */ 1536 em_fps_den_get, /* fps_den_get */
1523 em_fps_get, /* fps_get */ 1537 em_fps_get, /* fps_get */
diff --git a/legacy/emotion/src/modules/xine/emotion_xine.h b/legacy/emotion/src/modules/xine/emotion_xine.h
index 97aed72e80..c1cae2e5a0 100644
--- a/legacy/emotion/src/modules/xine/emotion_xine.h
+++ b/legacy/emotion/src/modules/xine/emotion_xine.h
@@ -22,6 +22,7 @@ struct _Emotion_Xine_Video
22 volatile double pos; 22 volatile double pos;
23 volatile double last_pos; 23 volatile double last_pos;
24 volatile double volume; 24 volatile double volume;
25 volatile double buffer;
25 double fps; 26 double fps;
26 double ratio; 27 double ratio;
27 int w, h; 28 int w, h;