/* * encoder_output_gop_seek: * @encoder_output: (in): the encoder output. * @timestamp: (in): time stamp of the top to seek * * return the address of the gop with time stamp of timestamp. * * Returns: gop addr if found, otherwise G_MAXUINT64 or 18446744073709551615(0xffffffffffffffff). * */ guint64 encoder_output_gop_seek (EncoderOutput *encoder_output, GstClockTime timestamp) { guint64 rap_addr; GstClockTime t; rap_addr = *(encoder_output->head_addr); if (rap_addr > encoder_output->cache_size) { GST_ERROR ("FATAL: %s rap_addr value is %lu", encoder_output->name, rap_addr); return G_MAXUINT64; } while (rap_addr != *(encoder_output->last_rap_addr)) { t = encoder_output_rap_timestamp (encoder_output, rap_addr); if (timestamp == t) { break; } rap_addr = encoder_output_rap_next (encoder_output, rap_addr); if (rap_addr > encoder_output->cache_size) { GST_ERROR ("FATAL: %s rap_addr value is %lu", encoder_output->name, rap_addr); return G_MAXUINT64; } } if (rap_addr != *(encoder_output->last_rap_addr)) { return rap_addr; } else { return G_MAXUINT64; } }
static void notify_function (union sigval sv) { EncoderOutput *encoder_output; struct sigevent sev; GstClockTime last_timestamp; GstClockTime segment_duration; gsize size; gchar *url, buf[128]; encoder_output = (EncoderOutput *)sv.sival_ptr; /* mq_notify first */ sev.sigev_notify = SIGEV_THREAD; sev.sigev_notify_function = notify_function; sev.sigev_notify_attributes = NULL; sev.sigev_value.sival_ptr = sv.sival_ptr; if (mq_notify (encoder_output->mqdes, &sev) == -1) { GST_ERROR ("mq_notify error : %s", g_strerror (errno)); } size = mq_receive (encoder_output->mqdes, buf, 128, NULL); if (size == -1) { GST_ERROR ("mq_receive error : %s", g_strerror (errno)); return; } buf[size] = '\0'; sscanf (buf, "%lu", &segment_duration); last_timestamp = encoder_output_rap_timestamp (encoder_output, *(encoder_output->last_rap_addr)); url = g_strdup_printf ("%lu.ts", encoder_output->last_timestamp); m3u8playlist_add_entry (encoder_output->m3u8_playlist, url, segment_duration); if (encoder_output->dvr_duration != 0) { dvr_record_segment (encoder_output, segment_duration); } encoder_output->last_timestamp = last_timestamp; g_free (url); }