From 8a4642cad79b37f2ebb90dbed57bf7c731b79542 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Wed, 7 Jun 2023 20:36:36 +0900 Subject: [PATCH] win32ipc: Use gst_util_get_timestamp() Instead of duplicating the same code Part-of: --- .../gst-plugins-bad/sys/win32ipc/gstwin32ipcvideosink.cpp | 7 +------ .../gst-plugins-bad/sys/win32ipc/gstwin32ipcvideosrc.cpp | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/win32ipc/gstwin32ipcvideosink.cpp b/subprojects/gst-plugins-bad/sys/win32ipc/gstwin32ipcvideosink.cpp index 7b19bda90a..1d92c2dd3e 100644 --- a/subprojects/gst-plugins-bad/sys/win32ipc/gstwin32ipcvideosink.cpp +++ b/subprojects/gst-plugins-bad/sys/win32ipc/gstwin32ipcvideosink.cpp @@ -67,7 +67,6 @@ struct _GstWin32IpcVideoSink GstVideoInfo info; Win32IpcPipeServer *pipe; - LARGE_INTEGER frequency; Win32IpcVideoInfo minfo; @@ -150,7 +149,6 @@ static void gst_win32_ipc_video_sink_init (GstWin32IpcVideoSink * self) { self->pipe_name = g_strdup (DEFAULT_PIPE_NAME); - QueryPerformanceFrequency (&self->frequency); GST_OBJECT_FLAG_SET (self, GST_ELEMENT_FLAG_PROVIDE_CLOCK); GST_OBJECT_FLAG_SET (self, GST_ELEMENT_FLAG_REQUIRE_CLOCK); @@ -453,7 +451,6 @@ static GstFlowReturn gst_win32_ipc_video_sink_render (GstBaseSink * sink, GstBuffer * buf) { GstWin32IpcVideoSink *self = GST_WIN32_IPC_VIDEO_SINK (sink); - LARGE_INTEGER cur_time; GstClockTime pts; GstClockTime now_qpc; GstClockTime buf_pts; @@ -473,9 +470,7 @@ gst_win32_ipc_video_sink_render (GstBaseSink * sink, GstBuffer * buf) mmf = mem->mmf; - QueryPerformanceCounter (&cur_time); - pts = now_qpc = gst_util_uint64_scale (cur_time.QuadPart, GST_SECOND, - self->frequency.QuadPart); + pts = now_qpc = gst_util_get_timestamp (); buf_pts = GST_BUFFER_PTS (buf); if (!GST_CLOCK_TIME_IS_VALID (buf_pts)) diff --git a/subprojects/gst-plugins-bad/sys/win32ipc/gstwin32ipcvideosrc.cpp b/subprojects/gst-plugins-bad/sys/win32ipc/gstwin32ipcvideosrc.cpp index 8144a7dcba..4d3c903396 100644 --- a/subprojects/gst-plugins-bad/sys/win32ipc/gstwin32ipcvideosrc.cpp +++ b/subprojects/gst-plugins-bad/sys/win32ipc/gstwin32ipcvideosrc.cpp @@ -73,7 +73,6 @@ struct _GstWin32IpcVideoSrc gboolean have_video_meta; gsize offset[GST_VIDEO_MAX_PLANES]; gint stride[GST_VIDEO_MAX_PLANES]; - LARGE_INTEGER frequency; GstBufferPool *pool; /* properties */ @@ -156,7 +155,6 @@ gst_win32_ipc_video_src_init (GstWin32IpcVideoSrc * self) gst_base_src_set_live (GST_BASE_SRC (self), TRUE); self->pipe_name = g_strdup (DEFAULT_PIPE_NAME); self->processing_deadline = DEFAULT_PROCESSING_DEADLINE; - QueryPerformanceFrequency (&self->frequency); GST_OBJECT_FLAG_SET (self, GST_ELEMENT_FLAG_PROVIDE_CLOCK); GST_OBJECT_FLAG_SET (self, GST_ELEMENT_FLAG_REQUIRE_CLOCK); @@ -426,7 +424,6 @@ gst_win32_ipc_video_src_create (GstBaseSrc * src, guint64 offset, guint size, GstClockTime base_time; GstClockTime now_qpc; GstClockTime now_gst; - LARGE_INTEGER cur_time; gboolean is_qpc = TRUE; gboolean need_video_meta = FALSE; @@ -529,9 +526,7 @@ gst_win32_ipc_video_src_create (GstBaseSrc * src, guint64 offset, guint size, win32_ipc_mmf_unref (mmf); } - QueryPerformanceCounter (&cur_time); - now_qpc = gst_util_uint64_scale (cur_time.QuadPart, GST_SECOND, - self->frequency.QuadPart); + now_qpc = gst_util_get_timestamp (); clock = gst_element_get_clock (GST_ELEMENT_CAST (self)); now_gst = gst_clock_get_time (clock); base_time = GST_ELEMENT_CAST (self)->base_time;