Begin adding audio project stuff

This commit is contained in:
Jaime Thomas 2008-06-04 00:24:13 +00:00
parent 664299910d
commit 8e69faf23e
4 changed files with 98 additions and 5 deletions

View File

@ -1,2 +1,81 @@
#include "ecdb.h"
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;
}
void
ecdb_audio_project_start(Ecdb_Audio_Project *proj)
{
char cmd[PATH_MAX]; //<-- + 20ish?
int i;
/* Fork off the gstreamer program for every file to be added */
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 |
ECORE_EXE_PIPE_AUTO, NULL);
}
proj->num_tracks = i - 1;
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;
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)
printf("Hurrah, transcoding is done!\n");
return 1;
}

View File

@ -1,6 +1,7 @@
#ifndef ECDB_AUDIO_H
#define ECDB_AUDIO_H
int ecdb_audio_project_setup(Ecdb_Burn_Project *proj);
Ecdb_Audio_Project *ecdb_audio_project_new(void);
void ecdb_audio_project_start(Ecdb_Audio_Project *proj);
#endif

View File

@ -111,6 +111,21 @@ struct _Ecdb_Burn_Project
/* Typecast a pointer to an Ecdb_Burn_Project */
#define ECDB_BURN(proj) ((Ecdb_Burn_Project *) proj)
typedef struct _Ecdb_Audio_Project Ecdb_Audio_Project;
struct _Ecdb_Audio_Project
{
/* Inherit from normal project */
Ecdb_Project proj;
/* Audio tracks */
Ecdb_Source *tracks;
int num_tracks;
int num_transcode_complete;
};
/* Typecast a pointer to an Ecdb_Audio_Project */
#define ECDB_AUDIO(proj) ((Ecdb_Audio_Project *) proj)
typedef struct _Ecdb_Erase_Project Ecdb_Erase_Project;
struct _Ecdb_Erase_Project
{

View File

@ -11,8 +11,7 @@ bus_call(GstBus *bus, GstMessage *msg, gpointer data)
{
case GST_MESSAGE_EOS:
{
g_print("End of stream\n");
g_print("Send data back to main program\n");
g_print("EOS\n");
g_main_loop_quit(loop);
break;
}
@ -24,8 +23,7 @@ bus_call(GstBus *bus, GstMessage *msg, gpointer data)
gst_message_parse_error(msg, &err, &debug);
g_free(debug);
g_print("Error: %s\n", err->message);
g_print("Send error back to main program\n");
g_print("%s\n", err->message);
g_error_free(err);
g_main_loop_quit(loop);