GstDateTime * gst_date_time_new_now_utc (void) { GstDateTime *now, *utc; now = gst_date_time_new_now_local_time (); utc = gst_date_time_to_utc (now); gst_date_time_unref (now); return utc; }
/* * job_reset: * @job: job object * * reset job stat * */ void job_reset (Job *job) { gchar *stat, **stats, **cpustats; GstDateTime *start_time; gint i; EncoderOutput *encoder; guint version, window_size; *(job->output->state) = JOB_STATE_VOID_PENDING; g_file_get_contents ("/proc/stat", &stat, NULL, NULL); stats = g_strsplit (stat, "\n", 10); cpustats = g_strsplit (stats[0], " ", 10); job->start_ctime = 0; for (i = 1; i < 8; i++) { job->start_ctime += g_ascii_strtoull (cpustats[i], NULL, 10); } job->last_ctime = 0; job->last_utime = 0; job->last_stime = 0; g_free (stat); g_strfreev (stats); g_strfreev (cpustats); start_time = gst_date_time_new_now_local_time (); if (job->last_start_time != NULL) { g_free (job->last_start_time); } job->last_start_time = gst_date_time_to_iso8601_string (start_time); gst_date_time_unref (start_time); /* is live job with m3u8streaming? */ if (!(job->is_live) || !(jobdesc_m3u8streaming (job->description))) { return; } version = jobdesc_m3u8streaming_version (job->description); if (version == 0) { version = 3; } window_size = jobdesc_m3u8streaming_window_size (job->description); for (i = 0; i < job->output->encoder_count; i++) { encoder = &(job->output->encoders[i]); /* encoder dvr sequence */ encoder->sequence = job->output->sequence; /* reset m3u8 playlist */ if (encoder->m3u8_playlist != NULL) { m3u8playlist_free (encoder->m3u8_playlist); } encoder->m3u8_playlist = m3u8playlist_new (version, window_size, 0); } }
static void gstreamill_init (Gstreamill *gstreamill) { GstDateTime *start_time; gstreamill->stop = FALSE; gstreamill->system_clock = gst_system_clock_obtain (); g_object_set (gstreamill->system_clock, "clock-type", GST_CLOCK_TYPE_REALTIME, NULL); start_time = gst_date_time_new_now_local_time (); gstreamill->start_time = gst_date_time_to_iso8601_string (start_time); gst_date_time_unref (start_time); g_mutex_init (&(gstreamill->job_list_mutex)); gstreamill->job_list = NULL; }
/* * job_reset: * @job: job object * * reset job stat * */ void job_reset (Job *job) { gchar *stat, **stats, **cpustats; GstDateTime *start_time; gint i; EncoderOutput *encoder; guint version, window_size; struct sigevent sev; struct mq_attr attr; gchar *name; g_file_get_contents ("/proc/stat", &stat, NULL, NULL); stats = g_strsplit (stat, "\n", 10); cpustats = g_strsplit (stats[0], " ", 10); job->start_ctime = 0; for (i = 1; i < 8; i++) { job->start_ctime += g_ascii_strtoull (cpustats[i], NULL, 10); } job->last_ctime = 0; job->last_utime = 0; job->last_stime = 0; g_free (stat); g_strfreev (stats); g_strfreev (cpustats); start_time = gst_date_time_new_now_local_time (); if (job->last_start_time != NULL) { g_free (job->last_start_time); } job->last_start_time = gst_date_time_to_iso8601_string (start_time); gst_date_time_unref (start_time); /* is live job with m3u8streaming? */ if (!(job->is_live) || !(jobdesc_m3u8streaming (job->description))) { return; } version = jobdesc_m3u8streaming_version (job->description); if (version == 0) { version = 3; } window_size = jobdesc_m3u8streaming_window_size (job->description); for (i = 0; i < job->output->encoder_count; i++) { encoder = &(job->output->encoders[i]); name = g_strdup_printf ("/%s.%d", job->name, i); /* encoder dvr sequence */ encoder->sequence = job->output->sequence; /* reset m3u8 playlist */ if (encoder->m3u8_playlist != NULL) { m3u8playlist_free (encoder->m3u8_playlist); } encoder->m3u8_playlist = m3u8playlist_new (version, window_size, 0); /* reset message queue */ if (encoder->mqdes != -1) { if (mq_close (encoder->mqdes) == -1) { GST_ERROR ("mq_close %s error: %s", name, g_strerror (errno)); } if (mq_unlink (name) == -1) { GST_ERROR ("mq_unlink %s error: %s", name, g_strerror (errno)); } } attr.mq_flags = 0; attr.mq_maxmsg = 10; attr.mq_msgsize = 128; attr.mq_curmsgs = 0; encoder->mqdes = mq_open (name, O_RDONLY | O_CREAT | O_NONBLOCK, 0666, &attr); if (encoder->mqdes == -1) { GST_ERROR ("mq_open error : %s", g_strerror (errno)); } sev.sigev_notify = SIGEV_THREAD; sev.sigev_notify_function = notify_function; sev.sigev_notify_attributes = NULL; sev.sigev_value.sival_ptr = encoder; if (mq_notify (encoder->mqdes, &sev) == -1) { GST_ERROR ("mq_notify error : %s", g_strerror (errno)); } g_free (name); } }