/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2020, Collabora Ltd.
 *     Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
 *
 * gstlibcamera-utils.h - GStreamer libcamera Utility Functions
 */

#ifndef __GST_LIBCAMERA_UTILS_H__
#define __GST_LIBCAMERA_UTILS_H__

#include <gst/gst.h>
#include <gst/video/video.h>

#include <libcamera/stream.h>

GstCaps *gst_libcamera_stream_formats_to_caps(const libcamera::StreamFormats &formats);
GstCaps *gst_libcamera_stream_configuration_to_caps(const libcamera::StreamConfiguration &stream_cfg);
void gst_libcamera_configure_stream_from_caps(libcamera::StreamConfiguration &stream_cfg,
					      GstCaps *caps);
void gst_libcamera_resume_task(GstTask *task);

/**
 * \class GLibLocker
 * \brief A simple scoped mutex locker for GMutex
 */
class GLibLocker
{
public:
	GLibLocker(GMutex *mutex)
		: mutex_(mutex)
	{
		g_mutex_lock(mutex_);
	}

	GLibLocker(GstObject *object)
		: mutex_(GST_OBJECT_GET_LOCK(object))
	{
		g_mutex_lock(mutex_);
	}

	~GLibLocker()
	{
		g_mutex_unlock(mutex_);
	}

private:
	GMutex *mutex_;
};

/**
 * \class GLibRecLocker
 * \brief A simple scoped mutex locker for GRecMutex
 */
class GLibRecLocker
{
public:
	GLibRecLocker(GRecMutex *mutex)
		: mutex_(mutex)
	{
		g_rec_mutex_lock(mutex_);
	}

	~GLibRecLocker()
	{
		g_rec_mutex_unlock(mutex_);
	}

private:
	GRecMutex *mutex_;
};

#endif /* __GST_LIBCAMERA_UTILS_H__ */
feathericons/percent.svg?h=v0.4.0'>log</a><a class='active' href='/libcamera/libcamera.git/tree/src/apps/qcam/assets/feathericons/percent.svg?h=v0.4.0&amp;id=fe989ee51498c5ce610bfabeb13f791032794194'>tree</a><a href='/libcamera/libcamera.git/commit/src/apps/qcam/assets/feathericons/percent.svg?h=v0.4.0&amp;id=fe989ee51498c5ce610bfabeb13f791032794194'>commit</a><a href='/libcamera/libcamera.git/diff/src/apps/qcam/assets/feathericons/percent.svg?h=v0.4.0&amp;id=fe989ee51498c5ce610bfabeb13f791032794194'>diff</a></td><td class='form'><form class='right' method='get' action='/libcamera/libcamera.git/log/src/apps/qcam/assets/feathericons/percent.svg'>
<input type='hidden' name='h' value='v0.4.0'/><input type='hidden' name='id' value='fe989ee51498c5ce610bfabeb13f791032794194'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/libcamera/libcamera.git/tree/?h=v0.4.0&amp;id=fe989ee51498c5ce610bfabeb13f791032794194'>root</a>/<a href='/libcamera/libcamera.git/tree/src?h=v0.4.0&amp;id=fe989ee51498c5ce610bfabeb13f791032794194'>src</a>/<a href='/libcamera/libcamera.git/tree/src/apps?h=v0.4.0&amp;id=fe989ee51498c5ce610bfabeb13f791032794194'>apps</a>/<a href='/libcamera/libcamera.git/tree/src/apps/qcam?h=v0.4.0&amp;id=fe989ee51498c5ce610bfabeb13f791032794194'>qcam</a>/<a href='/libcamera/libcamera.git/tree/src/apps/qcam/assets?h=v0.4.0&amp;id=fe989ee51498c5ce610bfabeb13f791032794194'>assets</a>/<a href='/libcamera/libcamera.git/tree/src/apps/qcam/assets/feathericons?h=v0.4.0&amp;id=fe989ee51498c5ce610bfabeb13f791032794194'>feathericons</a>/<a href='/libcamera/libcamera.git/tree/src/apps/qcam/assets/feathericons/percent.svg?h=v0.4.0&amp;id=fe989ee51498c5ce610bfabeb13f791032794194'>percent.svg</a></div><div class='content'>blob: 2cb9719daa36ef5c6cd8e2c47a2c1728cfd03974 (<a href='/libcamera/libcamera.git/plain/src/apps/qcam/assets/feathericons/percent.svg?h=v0.4.0&amp;id=fe989ee51498c5ce610bfabeb13f791032794194'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
</pre></td>
<td class='lines'><pre><code><span class="hl kwa">&lt;svg</span> <span class="hl kwb">xmlns</span>=<span class="hl str">&quot;http://www.w3.org/2000/svg&quot;</span> <span class="hl kwb">width</span>=<span class="hl str">&quot;24&quot;</span> <span class="hl kwb">height</span>=<span class="hl str">&quot;24&quot;</span> <span class="hl kwb">viewBox</span>=<span class="hl str">&quot;0 0 24 24&quot;</span> <span class="hl kwb">fill</span>=<span class="hl str">&quot;none&quot;</span> <span class="hl kwb">stroke</span>=<span class="hl str">&quot;currentColor&quot;</span> <span class="hl kwb">stroke-width</span>=<span class="hl str">&quot;2&quot;</span> <span class="hl kwb">stroke-linecap</span>=<span class="hl str">&quot;round&quot;</span> <span class="hl kwb">stroke-linejoin</span>=<span class="hl str">&quot;round&quot;</span> <span class="hl kwb">class</span>=<span class="hl str">&quot;feather feather-percent&quot;</span><span class="hl kwa">&gt;&lt;line</span> <span class="hl kwb">x1</span>=<span class="hl str">&quot;19&quot;</span> <span class="hl kwb">y1</span>=<span class="hl str">&quot;5&quot;</span> <span class="hl kwb">x2</span>=<span class="hl str">&quot;5&quot;</span> <span class="hl kwb">y2</span>=<span class="hl str">&quot;19&quot;</span><span class="hl kwa">&gt;&lt;/line&gt;&lt;circle</span> <span class="hl kwb">cx</span>=<span class="hl str">&quot;6.5&quot;</span> <span class="hl kwb">cy</span>=<span class="hl str">&quot;6.5&quot;</span> <span class="hl kwb">r</span>=<span class="hl str">&quot;2.5&quot;</span><span class="hl kwa">&gt;&lt;/circle&gt;&lt;circle</span> <span class="hl kwb">cx</span>=<span class="hl str">&quot;17.5&quot;</span> <span class="hl kwb">cy</span>=<span class="hl str">&quot;17.5&quot;</span> <span class="hl kwb">r</span>=<span class="hl str">&quot;2.5&quot;</span><span class="hl kwa">&gt;&lt;/circle&gt;&lt;/svg&gt;</span>
</code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.1</a> (<a href='https://git-scm.com/'>git 2.18.0</a>) at 2025-02-18 23:28:07 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>