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:
Zhang Xingtao
2016-04-12 23:48:35 +08:00
committed by Yoann Lopes
parent cf44daa754
commit 20528da413
3 changed files with 19 additions and 7 deletions

View File

@@ -65,9 +65,12 @@ QCamera::LockTypes CameraBinLocks::supportedLocks() const
if (GstPhotography *photography = m_session->photography()) {
if (gst_photography_get_capabilities(photography) & GST_PHOTOGRAPHY_CAPS_WB_MODE)
locks |= QCamera::LockWhiteBalance;
if (g_object_class_find_property(
G_OBJECT_GET_CLASS(m_session->cameraSource()), "exposure-mode")) {
locks |= QCamera::LockExposure;
if (GstElement *source = m_session->cameraSource()) {
if (g_object_class_find_property(
G_OBJECT_GET_CLASS(source), "exposure-mode")) {
locks |= QCamera::LockExposure;
}
}
}
#endif
@@ -195,9 +198,13 @@ bool CameraBinLocks::isExposureLocked() const
void CameraBinLocks::lockExposure(QCamera::LockChangeReason reason)
{
GstElement *source = m_session->cameraSource();
if (!source)
return;
m_pendingLocks &= ~QCamera::LockExposure;
g_object_set(
G_OBJECT(m_session->cameraSource()),
G_OBJECT(source),
"exposure-mode",
GST_PHOTOGRAPHY_EXPOSURE_MODE_MANUAL,
NULL);
@@ -206,8 +213,12 @@ void CameraBinLocks::lockExposure(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(m_session->cameraSource()),
G_OBJECT(source),
"exposure-mode",
GST_PHOTOGRAPHY_EXPOSURE_MODE_AUTO,
NULL);

View File

@@ -514,7 +514,8 @@ GstElement *CameraBinSession::buildCameraSource()
if (!m_videoSrc)
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)

View File

@@ -91,7 +91,7 @@ public:
GstPhotography *photography();
#endif
GstElement *cameraBin() { return m_camerabin; }
GstElement *cameraSource() { return m_videoSrc; }
GstElement *cameraSource() { return m_cameraSrc; }
QGstreamerBusHelper *bus() { return m_busHelper; }
QList< QPair<int,int> > supportedFrameRates(const QSize &frameSize, bool *continuous) const;