formatting

SVN revision: 35008
This commit is contained in:
Sebastian Dransfeld 2008-07-06 09:31:29 +00:00
parent 0d3907acf3
commit ac83d5a90b
3 changed files with 390 additions and 360 deletions

View File

@ -1,3 +1,6 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
@ -9,11 +12,8 @@
/* Callbacks to get the eos */ /* Callbacks to get the eos */
static int _eos_timer_fct (void *data); static int _eos_timer_fct (void *data);
static int _em_fd_ev_active (void *data, Ecore_Fd_Handler *fdh); static int _em_fd_ev_active (void *data, Ecore_Fd_Handler *fdh);
static void _for_each_tag (GstTagList const* list, gchar const* tag, void *data); static void _for_each_tag (GstTagList const* list, gchar const* tag, void *data);
static void _free_metadata (Emotion_Gstreamer_Metadata *m); static void _free_metadata (Emotion_Gstreamer_Metadata *m);
/* Interface */ /* Interface */
@ -224,7 +224,6 @@ static Emotion_Video_Module em_module =
em_speed_get, /* speed_get */ em_speed_get, /* speed_get */
em_eject, /* eject */ em_eject, /* eject */
em_meta_get, /* meta_get */ em_meta_get, /* meta_get */
NULL /* handle */ NULL /* handle */
}; };
@ -269,15 +268,15 @@ em_init(Evas_Object *obj,
ev->vis = EMOTION_VIS_GOOM; ev->vis = EMOTION_VIS_GOOM;
/* Create the file descriptors */ /* Create the file descriptors */
if (pipe(fds) == 0) { if (pipe(fds) == 0)
{
ev->fd_ev_read = fds[0]; ev->fd_ev_read = fds[0];
ev->fd_ev_write = fds[1]; ev->fd_ev_write = fds[1];
fcntl(ev->fd_ev_read, F_SETFL, O_NONBLOCK); fcntl(ev->fd_ev_read, F_SETFL, O_NONBLOCK);
ev->fd_ev_handler = ecore_main_fd_handler_add(ev->fd_ev_read, ev->fd_ev_handler = ecore_main_fd_handler_add(ev->fd_ev_read,
ECORE_FD_READ, ECORE_FD_READ,
_em_fd_ev_active, _em_fd_ev_active,
ev, ev, NULL, NULL);
NULL, NULL);
ecore_main_fd_handler_active_set(ev->fd_ev_handler, ECORE_FD_READ); ecore_main_fd_handler_active_set(ev->fd_ev_handler, ECORE_FD_READ);
} }
else else
@ -346,51 +345,61 @@ em_file_open(const char *file,
ev->obj = obj; ev->obj = obj;
/* CD Audio */ /* CD Audio */
if (strstr (file,"cdda://")) { if (strstr(file, "cdda://"))
{
const char *device = NULL; const char *device = NULL;
unsigned int track = 1; unsigned int track = 1;
device = file + strlen("cdda://"); device = file + strlen("cdda://");
if (device[0] == '/') { if (device[0] == '/')
{
char *tmp; char *tmp;
if ((tmp = strchr (device, '?')) || (tmp = strchr (device, '#'))) { if ((tmp = strchr(device, '?')) || (tmp = strchr(device, '#')))
{
sscanf(tmp + 1, "%d", &track); sscanf(tmp + 1, "%d", &track);
tmp[0] = '\0'; tmp[0] = '\0';
} }
} }
else { else
{
device = NULL; device = NULL;
sscanf(file, "cdda://%d", &track); sscanf(file, "cdda://%d", &track);
} }
fprintf(stderr, "[Emotion] [gst] build CD Audio pipeline\n"); fprintf(stderr, "[Emotion] [gst] build CD Audio pipeline\n");
if (!(emotion_pipeline_cdda_build (ev, device, track))) { if (!(emotion_pipeline_cdda_build(ev, device, track)))
{
fprintf(stderr, "[Emotion] [gst] error while building CD Audio pipeline\n"); fprintf(stderr, "[Emotion] [gst] error while building CD Audio pipeline\n");
gst_object_unref(ev->pipeline); gst_object_unref(ev->pipeline);
return 0; return 0;
} }
} }
/* Dvd */ /* Dvd */
else if (strstr (file, "dvd://")) { else if (strstr(file, "dvd://"))
{
fprintf(stderr, "[Emotion] [gst] build DVD pipeline\n"); fprintf(stderr, "[Emotion] [gst] build DVD pipeline\n");
if (!(emotion_pipeline_dvd_build (ev, NULL))) { if (!(emotion_pipeline_dvd_build(ev, NULL)))
{
fprintf(stderr, "[Emotion] [gst] error while building DVD pipeline\n"); fprintf(stderr, "[Emotion] [gst] error while building DVD pipeline\n");
gst_object_unref(ev->pipeline); gst_object_unref(ev->pipeline);
return 0; return 0;
} }
} }
/* http */ /* http */
else if (strstr (file, "http://")) { else if (strstr(file, "http://"))
{
fprintf(stderr, "[Emotion] [gst] build URI pipeline\n"); fprintf(stderr, "[Emotion] [gst] build URI pipeline\n");
if (!(emotion_pipeline_uri_build (ev, file))) { if (!(emotion_pipeline_uri_build(ev, file)))
{
fprintf(stderr, "[Emotion] [gst] error while building URI pipeline\n"); fprintf(stderr, "[Emotion] [gst] error while building URI pipeline\n");
gst_object_unref(ev->pipeline); gst_object_unref(ev->pipeline);
return 0; return 0;
} }
} }
/* Normal media file */ /* Normal media file */
else { else
{
const char *filename; const char *filename;
filename = strstr(file, "file://") filename = strstr(file, "file://")
@ -398,7 +407,8 @@ em_file_open(const char *file,
: file; : file;
fprintf(stderr, "[Emotion] [gst] build file pipeline\n"); fprintf(stderr, "[Emotion] [gst] build file pipeline\n");
if (!(emotion_pipeline_file_build (ev, filename))) { if (!(emotion_pipeline_file_build(ev, filename)))
{
fprintf(stderr, "[Emotion] [gst] error while building File pipeline\n"); fprintf(stderr, "[Emotion] [gst] error while building File pipeline\n");
gst_object_unref(ev->pipeline); gst_object_unref(ev->pipeline);
return 0; return 0;
@ -413,7 +423,8 @@ em_file_open(const char *file,
Emotion_Audio_Sink *asink; Emotion_Audio_Sink *asink;
vsink = (Emotion_Video_Sink *)ecore_list_first_goto(ev->video_sinks); vsink = (Emotion_Video_Sink *)ecore_list_first_goto(ev->video_sinks);
if (vsink) { if (vsink)
{
fprintf(stderr, "video : \n"); fprintf(stderr, "video : \n");
fprintf(stderr, " size : %dx%d\n", vsink->width, vsink->height); fprintf(stderr, " size : %dx%d\n", vsink->width, vsink->height);
fprintf(stderr, " fps : %d/%d\n", vsink->fps_num, vsink->fps_den); fprintf(stderr, " fps : %d/%d\n", vsink->fps_num, vsink->fps_den);
@ -423,7 +434,8 @@ em_file_open(const char *file,
} }
asink = (Emotion_Audio_Sink *)ecore_list_first_goto(ev->audio_sinks); asink = (Emotion_Audio_Sink *)ecore_list_first_goto(ev->audio_sinks);
if (asink) { if (asink)
{
fprintf(stderr, "audio : \n"); fprintf(stderr, "audio : \n");
fprintf(stderr, " chan : %d\n", asink->channels); fprintf(stderr, " chan : %d\n", asink->channels);
fprintf(stderr, " rate : %d\n", asink->samplerate); fprintf(stderr, " rate : %d\n", asink->samplerate);
@ -455,7 +467,8 @@ em_file_close(void *video)
ecore_list_clear(ev->audio_sinks); ecore_list_clear(ev->audio_sinks);
/* shutdown eos */ /* shutdown eos */
if (ev->eos_timer) { if (ev->eos_timer)
{
ecore_timer_del(ev->eos_timer); ecore_timer_del(ev->eos_timer);
ev->eos_timer = NULL; ev->eos_timer = NULL;
} }
@ -502,7 +515,8 @@ em_stop(void *video)
ev = (Emotion_Gstreamer_Video *)video; ev = (Emotion_Gstreamer_Video *)video;
/* shutdown eos */ /* shutdown eos */
if (ev->eos_timer) { if (ev->eos_timer)
{
ecore_timer_del(ev->eos_timer); ecore_timer_del(ev->eos_timer);
ev->eos_timer = NULL; ev->eos_timer = NULL;
} }
@ -522,11 +536,13 @@ em_size_get(void *video,
ev = (Emotion_Gstreamer_Video *)video; ev = (Emotion_Gstreamer_Video *)video;
vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr);
if (vsink) { if (vsink)
{
if (width) *width = vsink->width; if (width) *width = vsink->width;
if (height) *height = vsink->height; if (height) *height = vsink->height;
} }
else { else
{
if (width) *width = 0; if (width) *width = 0;
if (height) *height = 0; if (height) *height = 0;
} }
@ -547,23 +563,23 @@ em_pos_set(void *video,
vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr);
asink = (Emotion_Audio_Sink *)ecore_list_index_goto(ev->video_sinks, ev->audio_sink_nbr); asink = (Emotion_Audio_Sink *)ecore_list_index_goto(ev->video_sinks, ev->audio_sink_nbr);
if (vsink) { if (vsink)
{
gst_element_seek(vsink->sink, 1.0, gst_element_seek(vsink->sink, 1.0,
GST_FORMAT_TIME, GST_FORMAT_TIME,
GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH, GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH,
GST_SEEK_TYPE_SET, GST_SEEK_TYPE_SET,
(gint64)(pos * (double)GST_SECOND), (gint64)(pos * (double)GST_SECOND),
GST_SEEK_TYPE_NONE, GST_SEEK_TYPE_NONE, -1);
-1);
} }
if (asink) { if (asink)
{
gst_element_seek(asink->sink, 1.0, gst_element_seek(asink->sink, 1.0,
GST_FORMAT_TIME, GST_FORMAT_TIME,
GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH, GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH,
GST_SEEK_TYPE_SET, GST_SEEK_TYPE_SET,
(gint64)(pos * (double)GST_SECOND), (gint64)(pos * (double)GST_SECOND),
GST_SEEK_TYPE_NONE, GST_SEEK_TYPE_NONE, -1);
-1);
} }
ev->seek_to_pos = pos; ev->seek_to_pos = pos;
} }
@ -723,8 +739,10 @@ em_format_get (void *video)
ev = (Emotion_Gstreamer_Video *)video; ev = (Emotion_Gstreamer_Video *)video;
vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr);
if (vsink) { if (vsink)
switch (vsink->fourcc) { {
switch (vsink->fourcc)
{
case GST_MAKE_FOURCC('I', '4', '2', '0'): case GST_MAKE_FOURCC('I', '4', '2', '0'):
return EMOTION_FORMAT_I420; return EMOTION_FORMAT_I420;
case GST_MAKE_FOURCC('Y', 'V', '1', '2'): case GST_MAKE_FOURCC('Y', 'V', '1', '2'):
@ -749,11 +767,13 @@ em_video_data_size_get(void *video, int *w, int *h)
ev = (Emotion_Gstreamer_Video *)video; ev = (Emotion_Gstreamer_Video *)video;
vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr);
if (vsink) { if (vsink)
{
*w = vsink->width; *w = vsink->width;
*h = vsink->height; *h = vsink->height;
} }
else { else
{
*w = 0; *w = 0;
*h = 0; *h = 0;
} }
@ -774,7 +794,8 @@ em_yuv_rows_get(void *video,
if (ev->obj_data) if (ev->obj_data)
{ {
if (em_format_get(video) == EMOTION_FORMAT_I420) { if (em_format_get(video) == EMOTION_FORMAT_I420)
{
for (i = 0; i < h; i++) for (i = 0; i < h; i++)
yrows[i] = &ev->obj_data[i * w]; yrows[i] = &ev->obj_data[i * w];
@ -784,7 +805,8 @@ em_yuv_rows_get(void *video,
for (i = 0; i < (h / 2); i++) for (i = 0; i < (h / 2); i++)
vrows[i] = &ev->obj_data[h * w + h * (w /4) + i * (w / 2)]; vrows[i] = &ev->obj_data[h * w + h * (w /4) + i * (w / 2)];
} }
else if (em_format_get(video) == EMOTION_FORMAT_YV12) { else if (em_format_get(video) == EMOTION_FORMAT_YV12)
{
for (i = 0; i < h; i++) for (i = 0; i < h; i++)
yrows[i] = &ev->obj_data[i * w]; yrows[i] = &ev->obj_data[i * w];
@ -810,7 +832,8 @@ em_bgra_data_get(void *video, unsigned char **bgra_data)
ev = (Emotion_Gstreamer_Video *)video; ev = (Emotion_Gstreamer_Video *)video;
if (ev->obj_data && em_format_get(video) == EMOTION_FORMAT_BGRA) { if (ev->obj_data && em_format_get(video) == EMOTION_FORMAT_BGRA)
{
*bgra_data = ev->obj_data; *bgra_data = ev->obj_data;
return 1; return 1;
} }
@ -1130,8 +1153,6 @@ em_speed_get(void *video)
static int static int
em_eject(void *video) em_eject(void *video)
{ {
Emotion_Gstreamer_Video *ev; Emotion_Gstreamer_Video *ev;
@ -1220,7 +1241,7 @@ _for_each_tag (GstTagList const* list,
count = gst_tag_list_get_tag_size(list, tag); count = gst_tag_list_get_tag_size(list, tag);
val = gst_tag_list_get_value_index(list, tag, 0); val = gst_tag_list_get_value_index(list, tag, 0);
for ( i = 0; i < count; ++i) for (i = 0; i < count; i++)
{ {
if (!strcmp(tag, GST_TAG_TITLE)) if (!strcmp(tag, GST_TAG_TITLE))
{ {
@ -1334,7 +1355,6 @@ _free_metadata (Emotion_Gstreamer_Metadata *m)
if (m->disc_id) g_free(m->disc_id); if (m->disc_id) g_free(m->disc_id);
free(m); free(m);
} }
static int static int
@ -1366,15 +1386,19 @@ _em_fd_ev_active(void *data, Ecore_Fd_Handler *fdh)
return 1; return 1;
} }
int _eos_timer_fct (void *data) static int
_eos_timer_fct(void *data)
{ {
Emotion_Gstreamer_Video *ev; Emotion_Gstreamer_Video *ev;
GstMessage *msg; GstMessage *msg;
ev = (Emotion_Gstreamer_Video *)data; ev = (Emotion_Gstreamer_Video *)data;
while ((msg = gst_bus_poll (ev->eos_bus, GST_MESSAGE_ERROR | GST_MESSAGE_EOS | GST_MESSAGE_TAG, 0))) { while ((msg = gst_bus_poll(ev->eos_bus, GST_MESSAGE_ERROR | GST_MESSAGE_EOS | GST_MESSAGE_TAG, 0)))
switch (GST_MESSAGE_TYPE(msg)) { {
case GST_MESSAGE_ERROR: { switch (GST_MESSAGE_TYPE(msg))
{
case GST_MESSAGE_ERROR:
{
gchar *debug; gchar *debug;
GError *err; GError *err;

View File

@ -1,3 +1,6 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifndef __EMOTION_GSTREAMER_H__ #ifndef __EMOTION_GSTREAMER_H__
#define __EMOTION_GSTREAMER_H__ #define __EMOTION_GSTREAMER_H__

View File

@ -1,3 +1,6 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifndef __EMOTION_GSTREAMER_PIPELINE_H__ #ifndef __EMOTION_GSTREAMER_PIPELINE_H__
#define __EMOTION_GSTREAMER_PIPELINE_H__ #define __EMOTION_GSTREAMER_PIPELINE_H__