timecodestamper: Add running-time source mode

Add a new source mode "running-time". This mode will convert buffer
running time into timecode

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7322>
This commit is contained in:
Seungha Yang 2024-08-08 06:23:47 +09:00 committed by GStreamer Marge Bot
parent ea59c921d6
commit 8f9a53fa85
3 changed files with 32 additions and 0 deletions

View file

@ -240879,6 +240879,11 @@
"desc": "Timecode from real time clock",
"name": "rtc",
"value": "5"
},
{
"desc": "Buffer running time as timecode",
"name": "running-time",
"value": "6"
}
]
}

View file

@ -189,6 +189,15 @@ gst_timecodestamper_source_get_type (void)
"Linear timecode from an audio device", "ltc"},
{GST_TIME_CODE_STAMPER_SOURCE_RTC,
"Timecode from real time clock", "rtc"},
/**
* GstTimeCodeStamperSource::running-time:
*
* Buffer running time as timecode
*
* Since: 1.26
*/
{GST_TIME_CODE_STAMPER_SOURCE_RUNNING_TIME,
"Buffer running time as timecode", "running-time"},
{0, NULL, NULL},
};
@ -1581,6 +1590,23 @@ gst_timecodestamper_transform_ip (GstBaseTransform * vfilter,
case GST_TIME_CODE_STAMPER_SOURCE_RTC:
tc = timecodestamper->rtc_tc;
break;
case GST_TIME_CODE_STAMPER_SOURCE_RUNNING_TIME:
if (GST_CLOCK_TIME_IS_VALID (running_time)) {
guint64 num_frames = gst_util_uint64_scale (running_time,
timecodestamper->fps_n, timecodestamper->fps_d * GST_SECOND);
guint field_count = 0;
if (timecodestamper->interlace_mode !=
GST_VIDEO_INTERLACE_MODE_PROGRESSIVE) {
field_count = 1;
}
tc = gst_video_time_code_new (timecodestamper->fps_n,
timecodestamper->fps_d, NULL, tc_flags, 0, 0, 0, 0, field_count);
gst_video_time_code_add_frames (tc, num_frames);
free_tc = TRUE;
}
break;
}
switch (timecodestamper->tc_set) {

View file

@ -52,6 +52,7 @@ typedef enum GstTimeCodeStamperSource
GST_TIME_CODE_STAMPER_SOURCE_LAST_KNOWN_OR_ZERO,
GST_TIME_CODE_STAMPER_SOURCE_LTC,
GST_TIME_CODE_STAMPER_SOURCE_RTC,
GST_TIME_CODE_STAMPER_SOURCE_RUNNING_TIME,
} GstTimeCodeStamperSource;
typedef enum GstTimeCodeStamperSet {