GStreamer camerabin: return the proper camera source
- return m_cameraSrc for function cameraSource() instead of m_videoSrc.
m_videoSrc is not always assigned(default 0), it will crash on:
if (g_object_class_find_property(
G_OBJECT_GET_CLASS(m_session->cameraSource()), "exposure-mode")) {
And as the function name says, it would be better to return the
value m_cameraSrc.
- make sure pointers are not NULL before using them.
Change-Id: I8a56db34a805724b428409b87de7d072ee7bfa57
Reviewed-by: Yoann Lopes <yoann.lopes@qt.io>
This commit is contained in:
committed by
Yoann Lopes
parent
cf44daa754
commit
20528da413
@@ -65,9 +65,12 @@ QCamera::LockTypes CameraBinLocks::supportedLocks() const
|
|||||||
if (GstPhotography *photography = m_session->photography()) {
|
if (GstPhotography *photography = m_session->photography()) {
|
||||||
if (gst_photography_get_capabilities(photography) & GST_PHOTOGRAPHY_CAPS_WB_MODE)
|
if (gst_photography_get_capabilities(photography) & GST_PHOTOGRAPHY_CAPS_WB_MODE)
|
||||||
locks |= QCamera::LockWhiteBalance;
|
locks |= QCamera::LockWhiteBalance;
|
||||||
if (g_object_class_find_property(
|
|
||||||
G_OBJECT_GET_CLASS(m_session->cameraSource()), "exposure-mode")) {
|
if (GstElement *source = m_session->cameraSource()) {
|
||||||
locks |= QCamera::LockExposure;
|
if (g_object_class_find_property(
|
||||||
|
G_OBJECT_GET_CLASS(source), "exposure-mode")) {
|
||||||
|
locks |= QCamera::LockExposure;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -195,9 +198,13 @@ bool CameraBinLocks::isExposureLocked() const
|
|||||||
|
|
||||||
void CameraBinLocks::lockExposure(QCamera::LockChangeReason reason)
|
void CameraBinLocks::lockExposure(QCamera::LockChangeReason reason)
|
||||||
{
|
{
|
||||||
|
GstElement *source = m_session->cameraSource();
|
||||||
|
if (!source)
|
||||||
|
return;
|
||||||
|
|
||||||
m_pendingLocks &= ~QCamera::LockExposure;
|
m_pendingLocks &= ~QCamera::LockExposure;
|
||||||
g_object_set(
|
g_object_set(
|
||||||
G_OBJECT(m_session->cameraSource()),
|
G_OBJECT(source),
|
||||||
"exposure-mode",
|
"exposure-mode",
|
||||||
GST_PHOTOGRAPHY_EXPOSURE_MODE_MANUAL,
|
GST_PHOTOGRAPHY_EXPOSURE_MODE_MANUAL,
|
||||||
NULL);
|
NULL);
|
||||||
@@ -206,8 +213,12 @@ void CameraBinLocks::lockExposure(QCamera::LockChangeReason reason)
|
|||||||
|
|
||||||
void CameraBinLocks::unlockExposure(QCamera::LockStatus status, QCamera::LockChangeReason reason)
|
void CameraBinLocks::unlockExposure(QCamera::LockStatus status, QCamera::LockChangeReason reason)
|
||||||
{
|
{
|
||||||
|
GstElement *source = m_session->cameraSource();
|
||||||
|
if (!source)
|
||||||
|
return;
|
||||||
|
|
||||||
g_object_set(
|
g_object_set(
|
||||||
G_OBJECT(m_session->cameraSource()),
|
G_OBJECT(source),
|
||||||
"exposure-mode",
|
"exposure-mode",
|
||||||
GST_PHOTOGRAPHY_EXPOSURE_MODE_AUTO,
|
GST_PHOTOGRAPHY_EXPOSURE_MODE_AUTO,
|
||||||
NULL);
|
NULL);
|
||||||
|
|||||||
@@ -514,7 +514,8 @@ GstElement *CameraBinSession::buildCameraSource()
|
|||||||
if (!m_videoSrc)
|
if (!m_videoSrc)
|
||||||
m_videoSrc = gst_element_factory_make("v4l2src", "camera_source");
|
m_videoSrc = gst_element_factory_make("v4l2src", "camera_source");
|
||||||
|
|
||||||
g_object_set(G_OBJECT(m_cameraSrc), "video-source", m_videoSrc, NULL);
|
if (m_videoSrc)
|
||||||
|
g_object_set(G_OBJECT(m_cameraSrc), "video-source", m_videoSrc, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_videoSrc)
|
if (m_videoSrc)
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
GstPhotography *photography();
|
GstPhotography *photography();
|
||||||
#endif
|
#endif
|
||||||
GstElement *cameraBin() { return m_camerabin; }
|
GstElement *cameraBin() { return m_camerabin; }
|
||||||
GstElement *cameraSource() { return m_videoSrc; }
|
GstElement *cameraSource() { return m_cameraSrc; }
|
||||||
QGstreamerBusHelper *bus() { return m_busHelper; }
|
QGstreamerBusHelper *bus() { return m_busHelper; }
|
||||||
|
|
||||||
QList< QPair<int,int> > supportedFrameRates(const QSize &frameSize, bool *continuous) const;
|
QList< QPair<int,int> > supportedFrameRates(const QSize &frameSize, bool *continuous) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user