static gboolean garu_headerbar_sync_progress (GaruHeaderbar *self) { GaruApplication *app; GaruPlayer *player; GaruTagger *tagger; gint pos, len; gdouble fraction; app = GARU_APPLICATION (g_application_get_default ()); player = garu_application_get_player (app); if (garu_player_get_status (player) == GARU_PLAYER_STATUS_STOPPED) { garu_headerbar_sync_progress_stop (self); return FALSE; } tagger = garu_player_get_tagger (player); len = garu_tagger_get_length (tagger); pos = GST_TIME_AS_SECONDS (garu_player_get_position (player)); fraction = pos / (gdouble) len; garu_song_box_progress_bar_set_fraction (self->song_box, fraction); garu_song_box_set_position (self->song_box, pos); if (fraction >= 1) return FALSE; return TRUE; }
void pragha_toolbar_update_playback_progress(PraghaBackend *backend, gpointer user_data) { gint length = 0, newsec = 0; PraghaMusicobject *mobj = NULL; PraghaToolbar *toolbar = user_data; newsec = GST_TIME_AS_SECONDS(pragha_backend_get_current_position(backend)); if (newsec > 0) { mobj = pragha_backend_get_musicobject (backend); length = pragha_musicobject_get_length (mobj); if (length > 0) { pragha_toolbar_update_progress (toolbar, length, newsec); } else { gint nlength = GST_TIME_AS_SECONDS(pragha_backend_get_current_length(backend)); pragha_musicobject_set_length (mobj, nlength); } } }
gboolean print_position(GstElement *pipeline) { GstFormat fmt = GST_FORMAT_TIME; gint64 pos, len; if (gst_element_query_position (pipeline, &fmt, &pos) && gst_element_query_duration (pipeline, &fmt, &len)) { //g_print ("Time: %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT "\r", //GST_TIME_ARGS (pos), GST_TIME_ARGS (len)); g_print("%ld:%ld\r", GST_TIME_AS_SECONDS(pos),GST_TIME_AS_SECONDS(len)); QString time; if(GST_TIME_AS_SECONDS(pos)/60) { time.append(QString("%1").arg(GST_TIME_AS_SECONDS(pos)/60)); time.append(QString(":")); } time.append(QString("%1").arg(GST_TIME_AS_SECONDS(pos)%60)); time.append(QString(" / ")); if(GST_TIME_AS_SECONDS(len)/60) { time.append(QString("%1").arg(GST_TIME_AS_SECONDS(len)/60)); time.append(QString(":")); } time.append(QString("%1").arg(GST_TIME_AS_SECONDS(len)%60)); g_musicplay->m_timelabel->setText(time); //g_musicplay->m_timelabel->setText("<font color='red'>your</font>"); gint64 slidervalue=(pos<<6)/len; g_musicplay->m_time_slider->setValue(slidervalue); } /* call me again */ check_drop_frame(); return TRUE; }
static GstFlowReturn gst_h264_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) { GstH264Parse *h264parse; GstBuffer *buffer; h264parse = GST_H264_PARSE (parse); buffer = frame->buffer; /* periodic SPS/PPS sending */ if (h264parse->interval > 0 || h264parse->push_codec) { GstClockTime timestamp = GST_BUFFER_TIMESTAMP (buffer); guint64 diff; /* init */ if (!GST_CLOCK_TIME_IS_VALID (h264parse->last_report)) { h264parse->last_report = timestamp; } if (h264parse->idr_pos >= 0) { GST_LOG_OBJECT (h264parse, "IDR nal at offset %d", h264parse->idr_pos); if (timestamp > h264parse->last_report) diff = timestamp - h264parse->last_report; else diff = 0; GST_LOG_OBJECT (h264parse, "now %" GST_TIME_FORMAT ", last SPS/PPS %" GST_TIME_FORMAT, GST_TIME_ARGS (timestamp), GST_TIME_ARGS (h264parse->last_report)); GST_DEBUG_OBJECT (h264parse, "interval since last SPS/PPS %" GST_TIME_FORMAT, GST_TIME_ARGS (diff)); if (GST_TIME_AS_SECONDS (diff) >= h264parse->interval || h264parse->push_codec) { GstBuffer *codec_nal; gint i; GstClockTime new_ts; /* avoid overwriting a perfectly fine timestamp */ new_ts = GST_CLOCK_TIME_IS_VALID (timestamp) ? timestamp : h264parse->last_report; if (h264parse->align == GST_H264_PARSE_ALIGN_NAL) { /* send separate config NAL buffers */ GST_DEBUG_OBJECT (h264parse, "- sending SPS/PPS"); for (i = 0; i < MAX_SPS_COUNT; i++) { if ((codec_nal = h264parse->params->sps_nals[i])) { GST_DEBUG_OBJECT (h264parse, "sending SPS nal"); gst_h264_parse_push_codec_buffer (h264parse, codec_nal, timestamp); h264parse->last_report = new_ts; } } for (i = 0; i < MAX_PPS_COUNT; i++) { if ((codec_nal = h264parse->params->pps_nals[i])) { GST_DEBUG_OBJECT (h264parse, "sending PPS nal"); gst_h264_parse_push_codec_buffer (h264parse, codec_nal, timestamp); h264parse->last_report = new_ts; } } } else { /* insert config NALs into AU */ GstByteWriter bw; GstBuffer *new_buf; const gboolean bs = h264parse->format == GST_H264_PARSE_FORMAT_BYTE; gst_byte_writer_init_with_size (&bw, GST_BUFFER_SIZE (buffer), FALSE); gst_byte_writer_put_data (&bw, GST_BUFFER_DATA (buffer), h264parse->idr_pos); GST_DEBUG_OBJECT (h264parse, "- inserting SPS/PPS"); for (i = 0; i < MAX_SPS_COUNT; i++) { if ((codec_nal = h264parse->params->sps_nals[i])) { GST_DEBUG_OBJECT (h264parse, "inserting SPS nal"); gst_byte_writer_put_uint32_be (&bw, bs ? 1 : GST_BUFFER_SIZE (codec_nal)); gst_byte_writer_put_data (&bw, GST_BUFFER_DATA (codec_nal), GST_BUFFER_SIZE (codec_nal)); h264parse->last_report = new_ts; } } for (i = 0; i < MAX_PPS_COUNT; i++) { if ((codec_nal = h264parse->params->pps_nals[i])) { GST_DEBUG_OBJECT (h264parse, "inserting PPS nal"); gst_byte_writer_put_uint32_be (&bw, bs ? 1 : GST_BUFFER_SIZE (codec_nal)); gst_byte_writer_put_data (&bw, GST_BUFFER_DATA (codec_nal), GST_BUFFER_SIZE (codec_nal)); h264parse->last_report = new_ts; } } gst_byte_writer_put_data (&bw, GST_BUFFER_DATA (buffer) + h264parse->idr_pos, GST_BUFFER_SIZE (buffer) - h264parse->idr_pos); /* collect result and push */ new_buf = gst_byte_writer_reset_and_get_buffer (&bw); gst_buffer_copy_metadata (new_buf, buffer, GST_BUFFER_COPY_ALL); gst_buffer_replace (&frame->buffer, new_buf); } } /* we pushed whatever we had */ h264parse->push_codec = FALSE; } } gst_h264_parse_reset_frame (h264parse); return GST_FLOW_OK; }