2008-05-23 03:33:04 +00:00
|
|
|
#include "ecdb.h"
|
|
|
|
|
2008-06-04 00:24:13 +00:00
|
|
|
int transcode_data_cb(void *data, int type, void *event);
|
|
|
|
int ecdb_audio_project_init(Ecdb_Audio_Project *proj);
|
|
|
|
|
|
|
|
Ecdb_Audio_Project *
|
|
|
|
ecdb_audio_project_new(void)
|
|
|
|
{
|
|
|
|
Ecdb_Audio_Project *proj;
|
|
|
|
|
|
|
|
proj = calloc(1, sizeof(Ecdb_Audio_Project));
|
|
|
|
if (!proj)
|
|
|
|
return NULL;
|
|
|
|
if (!ecdb_audio_project_init(proj))
|
|
|
|
{
|
|
|
|
FREE(proj);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return proj;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ecdb_audio_project_init(Ecdb_Audio_Project *proj)
|
|
|
|
{
|
|
|
|
if (!ecdb_project_init(ECDB_PROJECT(proj)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
proj->tracks = ecdb_source_new();
|
|
|
|
proj->num_tracks = 0;
|
|
|
|
proj->num_transcode_complete = 0;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-06-04 01:12:34 +00:00
|
|
|
void
|
|
|
|
ecdb_audio_project_destroy(Ecdb_Audio_Project *proj)
|
|
|
|
{
|
|
|
|
ecdb_source_destroy(proj->tracks);
|
|
|
|
ecdb_project_destroy(ECDB_PROJECT(proj));
|
|
|
|
free(proj);
|
|
|
|
}
|
|
|
|
|
2008-06-04 00:24:13 +00:00
|
|
|
void
|
|
|
|
ecdb_audio_project_start(Ecdb_Audio_Project *proj)
|
|
|
|
{
|
|
|
|
char cmd[PATH_MAX]; //<-- + 20ish?
|
|
|
|
int i;
|
|
|
|
|
2008-06-04 01:12:34 +00:00
|
|
|
/* Fork off the gstreamer program for every file to be added
|
|
|
|
* Depending on the number of files, this can be pretty system intensive, so
|
|
|
|
* is there a way to reduce/control this ?
|
|
|
|
*/
|
2008-06-04 00:24:13 +00:00
|
|
|
for (i = 0; proj->tracks->children[i]; i++)
|
|
|
|
{
|
|
|
|
snprintf(cmd, PATH_MAX, "ecdb_transcode_helper %s",
|
|
|
|
proj->tracks->children[i]->dst);
|
|
|
|
ecore_exe_pipe_run(cmd, ECORE_EXE_PIPE_READ |
|
2008-06-04 01:12:34 +00:00
|
|
|
ECORE_EXE_PIPE_READ_LINE_BUFFERED, NULL);
|
2008-06-04 00:24:13 +00:00
|
|
|
}
|
|
|
|
|
2008-06-04 01:12:34 +00:00
|
|
|
proj->num_tracks = i;
|
2008-06-04 00:24:13 +00:00
|
|
|
ecore_event_handler_add(ECORE_EXE_EVENT_DATA, transcode_data_cb, proj);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
transcode_data_cb(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
const char *rec;
|
|
|
|
Ecore_Exe_Event_Data *ev = event;
|
|
|
|
Ecdb_Audio_Project *proj = data;
|
|
|
|
|
|
|
|
rec = ev->data;
|
2008-06-04 01:12:34 +00:00
|
|
|
proj->num_transcode_complete++;
|
2008-06-04 00:24:13 +00:00
|
|
|
|
|
|
|
printf("Message: %s\n", rec);
|
|
|
|
|
|
|
|
if (!strcmp(rec, "EOS"))
|
|
|
|
{
|
|
|
|
printf("Transcode complete\n");
|
|
|
|
proj->num_transcode_complete++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* How to handle errors? */
|
|
|
|
else
|
|
|
|
printf("Error!\n");
|
|
|
|
|
|
|
|
if (proj->num_tracks == proj->num_transcode_complete)
|
2008-06-04 01:12:34 +00:00
|
|
|
{
|
2008-06-04 00:24:13 +00:00
|
|
|
printf("Hurrah, transcoding is done!\n");
|
2008-06-04 01:12:34 +00:00
|
|
|
|
|
|
|
/* Change to another event later */
|
|
|
|
ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, NULL, NULL, NULL);
|
|
|
|
}
|
2008-06-04 00:24:13 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|