Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 2d76cc8

Browse files
Anton Grishindmitryermilov
Anton Grishin
authored andcommitted
Enable timestams for fix glsink
1 parent e8686de commit 2d76cc8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/common/src/mfx_gst_plugin_vdec.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@ gboolean mfx_gst_plugin_vdec_input_event(mfx_GstPad *mfxpad, mfx_GstPlugin *plug
197197
// forwarding EOS right away in case we failed to post a task
198198
return gst_pad_event_default(mfxpad->pad, (GstObject*)plugin, event);
199199
}
200+
else if (GST_EVENT_SEGMENT == event->type) {
201+
gint64 start = 0;
202+
GstSegment segment;
203+
gst_event_copy_segment (event, &segment);
204+
205+
if (segment.format != GST_FORMAT_TIME) {
206+
gst_pad_query_convert (mfxpad->pad, segment.format,
207+
segment.start, GST_FORMAT_TIME, &start);
208+
segment.format = GST_FORMAT_TIME;
209+
gst_event_unref (event);
210+
event = gst_event_new_segment (&segment);
211+
}
212+
}
200213
return gst_pad_event_default(mfxpad->pad, (GstObject*)plugin, event);
201214
}
202215

@@ -219,6 +232,23 @@ GstFlowReturn mfx_gst_vdec_chain(mfx_GstPad *mfxpad, mfx_GstPlugin *plugin, GstB
219232
return GST_FLOW_ERROR;
220233
}
221234

235+
if (GST_BUFFER_DTS (buffer) == GST_CLOCK_TIME_NONE &&
236+
GST_BUFFER_PTS (buffer) == GST_CLOCK_TIME_NONE) {
237+
GstClock *clock = gst_element_get_clock (&plugin->element);
238+
if (clock) {
239+
GstClockTime base_time =
240+
gst_element_get_base_time (&plugin->element);
241+
GstClockTime now = gst_clock_get_time (clock);
242+
if (now > base_time)
243+
now -= base_time;
244+
else
245+
now = 0;
246+
gst_object_unref (clock);
247+
248+
GST_BUFFER_PTS (buffer) = now;
249+
GST_BUFFER_DTS (buffer) = now;
250+
}
251+
}
222252
mfxGstPluginVdecData* vdec = (mfxGstPluginVdecData*)plugin->data;
223253

224254
std::shared_ptr<mfxGstPluginVdecData::InputData> input_data(new mfxGstPluginVdecData::InputData);

0 commit comments

Comments
 (0)