コード例 #1
0
ファイル: gstreamill.c プロジェクト: bbshocking/gstreamill
static guint64 create_job_process (Job *job)
{
        GError *error = NULL;
        gchar *argv[16], *p;
        GPid pid;
        gint i, j;

        i = 0;
        argv[i++] = g_strdup (job->exe_path);
        argv[i++] = g_strdup ("-l");
        argv[i++] = g_strdup (job->log_dir);
        argv[i++] = g_strdup ("-n");
        argv[i++] = unicode_file_name_2_shm_name (job->name);
        argv[i++] = g_strdup ("-q");
        argv[i++] = g_strdup_printf ("%ld", strlen (job->description));
        p = jobdesc_get_debug (job->description);
        if (p != NULL) {
                argv[i++] = g_strdup_printf ("--gst-debug=%s", p);
                g_free (p);
        }
        argv[i++] = NULL;
        if (!g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, &error)) {
                GST_ERROR ("Start job %s error, reason: %s.", job->name, error->message);
                for (j = 0; j < i; j++) {
                        if (argv[j] != NULL) {
                                g_free (argv[j]);
                        }
                }
                g_error_free (error);
                return JOB_STATE_START_FAILURE;
        }

        for (j = 0; j < i; j++) {
                if (argv[j] != NULL) {
                        g_free (argv[j]);
                }
        }
        job->worker_pid = pid;
        g_child_watch_add (pid, (GChildWatchFunc)child_watch_cb, job);

        while ((*(job->output->state) == JOB_STATE_READY) || (*(job->output->state) == JOB_STATE_VOID_PENDING)) {
                GST_WARNING ("waiting job process creating ... state: %s", job_state_get_name (*(job->output->state)));
                g_usleep (50000);
        }

        return *(job->output->state);
}
コード例 #2
0
ファイル: gstreamill.c プロジェクト: g522342435/gstreamill
static gchar * create_job_process (Job *job)
{
        GError *error = NULL;
        gchar *argv[16], path[512], *p;
        GPid pid;
        gint i, j;

        memset (path, '\0', sizeof (path));
        if (readlink ("/proc/self/exe", path, sizeof (path)) == -1) {
                GST_ERROR ("Read /proc/self/exe error.");
                return g_strdup ("create live job failure");
        }
        i = 0;
        argv[i++] = g_strdup (path);
        argv[i++] = g_strdup ("-l");
        argv[i++] = g_strdup (job->log_dir);
        argv[i++] = g_strdup ("-n");
        argv[i++] = g_strdup_printf ("%s", job->name);
        argv[i++] = g_strdup ("-q");
        argv[i++] = g_strdup_printf ("%ld", strlen (job->description));
        p = jobdesc_get_debug (job->description);
        if (p != NULL) {
                argv[i++] = g_strdup_printf ("--gst-debug=%s", p);
                g_free (p);
        }
        argv[i++] = NULL;
        if (!g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, &error)) {
                GST_ERROR ("Start job %s error, reason: %s.", job->name, error->message);
                for (j = 0; j < i; j++) {
                        if (argv[j] != NULL) {
                                g_free (argv[j]);
                        }
                }
                g_error_free (error);
                return g_strdup ("create live job process failure");
        }

        for (j = 0; j < i; j++) {
                if (argv[j] != NULL) {
                        g_free (argv[j]);
                }
        }
        job->worker_pid = pid;
        g_child_watch_add (pid, (GChildWatchFunc)child_watch_cb, job);

        return g_strdup ("create live job process success");
}