Permalink
Browse files

emotion: first try with xv.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk@63759 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
  • Loading branch information...
1 parent 2af2626 commit 0849f4694d7a1cfdd8cdb7b08792daa7c11cd071 cedric committed Oct 3, 2011
View
@@ -114,7 +114,7 @@ if test "x${have_emotion_test}" = "xyes" ; then
PKG_CHECK_MODULES(EMOTION_BIN, [eina >= 1.0.0 evas >= 1.0.0 ecore >= 1.0.0 ecore-evas >= 1.0.0 edje >= 1.0.0])
fi
-PKG_CHECK_MODULES(ECORE_X, [ecore-x >= 1.0.0], [have_ecore_x="yes"], [have_ecore_x="no"])
+PKG_CHECK_MODULES(ECORE_X, [ecore-x >= 1.0.0 ecore-evas >= 1.0.0], [have_ecore_x="yes"], [have_ecore_x="no"])
PKG_CHECK_MODULES(ECORE_FB, [ecore-fb >= 1.0.0], [have_ecore_fb="yes"], [have_ecore_fb="no"])
@@ -723,6 +723,8 @@ main(int argc, char **argv)
if (!ecore_evas)
goto shutdown_edje;
+ ecore_evas_alpha_set(ecore_evas, EINA_TRUE);
+
ecore_evas_callback_delete_request_set(ecore_evas, main_delete_request);
ecore_evas_callback_resize_set(ecore_evas, main_resize);
ecore_evas_title_set(ecore_evas, "Evas Media Test Program");
@@ -110,6 +110,8 @@ struct _Emotion_Video_Module
double (*speed_get) (void *ef);
int (*eject) (void *ef);
const char * (*meta_get) (void *ef, int meta);
+ void (*priority_set) (void *ef, Eina_Bool priority);
+ Eina_Bool (*priority_get) (void *ef);
Eina_Emotion_Plugins *plugin;
};
@@ -1269,6 +1269,32 @@ emotion_object_vis_supported(const Evas_Object *obj, Emotion_Vis visualization)
return sd->module->vis_supported(sd->video, visualization);
}
+EAPI void
+emotion_object_priority_set(Evas_Object *obj, Eina_Bool priority)
+{
+ Smart_Data *sd;
+
+ E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
+ fprintf(stderr, "priority set %p\n", sd->module);
+ if (!sd->module) return ;
+ if (!sd->video) return ;
+ if (!sd->module->priority_set) return ;
+ fprintf(stderr, "calling\n");
+ sd->module->priority_set(sd->video, priority);
+}
+
+EAPI Eina_Bool
+emotion_object_priority_get(const Evas_Object *obj)
+{
+ Smart_Data *sd;
+
+ E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
+ if (!sd->module) return EINA_FALSE;
+ if (!sd->video) return EINA_FALSE;
+ if (!sd->module->priority_get) return EINA_FALSE;
+ return sd->module->priority_get(sd->video);
+}
+
#ifdef HAVE_EIO
static void
_eio_load_xattr_cleanup(Smart_Data *sd, Eio_File *handler)
@@ -1714,6 +1714,8 @@ static Emotion_Video_Module em_module =
em_speed_get, /* speed_get */
em_eject, /* eject */
em_meta_get, /* meta_get */
+ NULL, /* priority_set */
+ NULL, /* priority_get */
NULL /* handle */
};
@@ -22,6 +22,7 @@ emotion_gstreamer_buffer_alloc(EvasVideoSinkPrivate *sink,
send->sink = sink;
send->frame = gst_buffer_ref(buffer);
send->preroll = preroll;
+ send->force = EINA_FALSE;
sink->ev->out++;
send->ev = sink->ev;
@@ -164,6 +164,10 @@ static int em_eject (void *video);
static const char *em_meta_get (void *video,
int meta);
+static void em_priority_set (void *video,
+ Eina_Bool pri);
+static Eina_Bool em_priority_get (void *video);
+
static GstBusSyncReply _eos_sync_fct(GstBus *bus,
GstMessage *message,
gpointer data);
@@ -228,6 +232,8 @@ static Emotion_Video_Module em_module =
em_speed_get, /* speed_get */
em_eject, /* eject */
em_meta_get, /* meta_get */
+ em_priority_set, /* priority_set */
+ em_priority_get, /* priority_get */
NULL /* handle */
};
@@ -345,32 +351,16 @@ em_init(Evas_Object *obj,
return 0;
}
-int
-em_shutdown(void *video)
+static void
+em_cleanup(Emotion_Gstreamer_Video *ev)
{
- Emotion_Gstreamer_Video *ev;
Emotion_Audio_Stream *astream;
Emotion_Video_Stream *vstream;
- ev = (Emotion_Gstreamer_Video *)video;
- if (!ev)
- return 0;
-
- if (ev->threads)
- {
- Ecore_Thread *t;
-
- EINA_LIST_FREE(ev->threads, t)
- ecore_thread_cancel(t);
-
- ev->delete_me = EINA_TRUE;
- return 1;
- }
-
- if (ev->in != ev->out)
+ if (ev->send)
{
- ev->delete_me = EINA_TRUE;
- return 1;
+ emotion_gstreamer_buffer_free(ev->send);
+ ev->send = NULL;
}
if (ev->eos_bus)
@@ -379,24 +369,41 @@ em_shutdown(void *video)
ev->eos_bus = NULL;
}
+ if (ev->metadata)
+ {
+ _free_metadata(ev->metadata);
+ ev->metadata = NULL;
+ }
+
if (ev->last_buffer)
{
gst_buffer_unref(ev->last_buffer);
ev->last_buffer = NULL;
}
+ if (!ev->stream)
+ {
+ evas_object_image_video_surface_set(emotion_object_image_get(ev->obj), NULL);
+ ev->stream = EINA_TRUE;
+ }
+
if (ev->pipeline)
{
gstreamer_video_sink_new(ev, ev->obj, NULL);
- g_object_set(G_OBJECT(ev->sink), "ev", NULL, NULL);
- g_object_set(G_OBJECT(ev->sink), "evas-object", NULL, NULL);
+ g_object_set(G_OBJECT(ev->esink), "ev", NULL, NULL);
+ g_object_set(G_OBJECT(ev->esink), "evas-object", NULL, NULL);
gst_element_set_state(ev->pipeline, GST_STATE_NULL);
gst_object_unref(ev->pipeline);
ev->pipeline = NULL;
ev->sink = NULL;
+ if (ev->teepad) gst_object_unref(ev->teepad);
+ ev->teepad = NULL;
+ if (ev->xvpad) gst_object_unref(ev->xvpad);
+ ev->xvpad = NULL;
+
if (ev->win) ecore_x_window_free(ev->win);
ev->win = 0;
}
@@ -405,6 +412,35 @@ em_shutdown(void *video)
free(astream);
EINA_LIST_FREE(ev->video_streams, vstream)
free(vstream);
+}
+
+int
+em_shutdown(void *video)
+{
+ Emotion_Gstreamer_Video *ev;
+
+ ev = (Emotion_Gstreamer_Video *)video;
+ if (!ev)
+ return 0;
+
+ if (ev->threads)
+ {
+ Ecore_Thread *t;
+
+ EINA_LIST_FREE(ev->threads, t)
+ ecore_thread_cancel(t);
+
+ ev->delete_me = EINA_TRUE;
+ return EINA_FALSE;
+ }
+
+ if (ev->in != ev->out)
+ {
+ ev->delete_me = EINA_TRUE;
+ return EINA_FALSE;
+ }
+
+ em_cleanup(ev);
free(ev);
@@ -479,19 +515,11 @@ static void
em_file_close(void *video)
{
Emotion_Gstreamer_Video *ev;
- Emotion_Audio_Stream *astream;
- Emotion_Video_Stream *vstream;
ev = (Emotion_Gstreamer_Video *)video;
if (!ev)
return;
- if (ev->eos_bus)
- {
- gst_object_unref(GST_OBJECT(ev->eos_bus));
- ev->eos_bus = NULL;
- }
-
if (ev->threads)
{
Ecore_Thread *t;
@@ -500,32 +528,10 @@ em_file_close(void *video)
ecore_thread_cancel(t);
}
- if (ev->pipeline)
- {
- gstreamer_video_sink_new(ev, ev->obj, NULL);
-
- g_object_set(G_OBJECT(ev->sink), "ev", NULL, NULL);
- g_object_set(G_OBJECT(ev->sink), "evas-object", NULL, NULL);
- gst_element_set_state(ev->pipeline, GST_STATE_NULL);
- gst_object_unref(ev->pipeline);
- ev->pipeline = NULL;
- ev->sink = NULL;
- }
+ em_cleanup(ev);
- /* we clear the stream lists */
- EINA_LIST_FREE(ev->audio_streams, astream)
- free(astream);
- EINA_LIST_FREE(ev->video_streams, vstream)
- free(vstream);
ev->pipeline_parsed = EINA_FALSE;
ev->play_started = 0;
-
- /* shutdown eos */
- if (ev->metadata)
- {
- _free_metadata(ev->metadata);
- ev->metadata = NULL;
- }
}
static void
@@ -1214,6 +1220,24 @@ em_meta_get(void *video, int meta)
return str;
}
+static void
+em_priority_set(void *video, Eina_Bool pri)
+{
+ Emotion_Gstreamer_Video *ev;
+
+ ev = video;
+ ev->priority = pri;
+}
+
+static Eina_Bool
+em_priority_get(void *video)
+{
+ Emotion_Gstreamer_Video *ev;
+
+ ev = video;
+ return ev->stream;
+}
+
static Eina_Bool
module_open(Evas_Object *obj,
const Emotion_Video_Module **module,
@@ -1429,6 +1453,30 @@ _free_metadata(Emotion_Gstreamer_Metadata *m)
free(m);
}
+static Eina_Bool
+_em_restart_stream(void *data)
+{
+ Emotion_Gstreamer_Video *ev;
+
+ ev = data;
+
+ ev->pipeline = gstreamer_video_sink_new(ev, ev->obj, ev->uri);
+
+ if (ev->pipeline)
+ {
+ ev->eos_bus = gst_pipeline_get_bus(GST_PIPELINE(ev->pipeline));
+ if (!ev->eos_bus)
+ {
+ ERR("could not get the bus");
+ return EINA_FALSE;
+ }
+
+ gst_bus_set_sync_handler(ev->eos_bus, _eos_sync_fct, ev);
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
static void
_eos_main_fct(void *data)
{
@@ -1475,6 +1523,14 @@ _eos_main_fct(void *data)
break;
case GST_MESSAGE_STREAM_STATUS:
break;
+ case GST_MESSAGE_ERROR:
+ ERR("Switching back to composited rendering.");
+ em_cleanup(ev);
+
+ ev->priority = EINA_FALSE;
+
+ ecore_idler_add(_em_restart_stream, ev);
+ break;
default:
ERR("bus say: %s [%i - %s]",
GST_MESSAGE_SRC_NAME(msg),
@@ -1498,6 +1554,10 @@ _eos_sync_fct(GstBus *bus __UNUSED__, GstMessage *msg, gpointer data)
case GST_MESSAGE_TAG:
case GST_MESSAGE_ASYNC_DONE:
case GST_MESSAGE_STREAM_STATUS:
+ INF("bus say: %s [%i - %s]",
+ GST_MESSAGE_SRC_NAME(msg),
+ GST_MESSAGE_TYPE(msg),
+ GST_MESSAGE_TYPE_NAME(msg));
send = emotion_gstreamer_message_alloc(ev, msg);
if (send) ecore_main_loop_thread_safe_call_async(_eos_main_fct, send);
@@ -1508,7 +1568,7 @@ _eos_sync_fct(GstBus *bus __UNUSED__, GstMessage *msg, gpointer data)
{
GstState old_state, new_state;
- gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
+ gst_message_parse_state_changed(msg, &old_state, &new_state, NULL);
INF("Element %s changed state from %s to %s.",
GST_OBJECT_NAME(msg->src),
gst_element_state_get_name(old_state),
@@ -1521,10 +1581,17 @@ _eos_sync_fct(GstBus *bus __UNUSED__, GstMessage *msg, gpointer data)
gchar *debug;
gst_message_parse_error(msg, &error, &debug);
- ERR("WARNING from element %s: %s", GST_OBJECT_NAME(msg->src), error->message);
+ ERR("ERROR from element %s: %s", GST_OBJECT_NAME(msg->src), error->message);
ERR("Debugging info: %s", (debug) ? debug : "none");
g_error_free(error);
g_free(debug);
+
+ if (strncmp(GST_OBJECT_NAME(msg->src), "xvimagesink", 11) == 0)
+ {
+ send = emotion_gstreamer_message_alloc(ev, msg);
+
+ if (send) ecore_main_loop_thread_safe_call_async(_eos_main_fct, send);
+ }
break;
}
case GST_MESSAGE_WARNING:
Oops, something went wrong.

0 comments on commit 0849f46

Please sign in to comment.