diff options
author | Yoann Lopes <yoann.lopes@theqtcompany.com> | 2015-11-13 18:48:19 +0100 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@theqtcompany.com> | 2015-11-19 11:59:20 +0000 |
commit | 7c4574a6985671f14148ad8ee591aee4487f5d4d (patch) | |
tree | 5c1a748ba06c94d6866ecac4bd75409c5ed5f85d /src/plugins/gstreamer/camerabin/camerabinsession.cpp | |
parent | 4a2c597a0666452a39939339ebd6f87040952cd3 (diff) | |
download | qtmultimedia-7c4574a6985671f14148ad8ee591aee4487f5d4d.tar.gz |
Support compiling with GStreamer < 0.10.32 in the camerabin plugin.
The documented minimum GStreamer version for Qt Multimedia is 0.10.24,
however, the camerabin plugin actually required 0.10.32 to compile
successfully. The reason is mainly due to the GstEncodingProfiles
API, which is used to implement the audio and video encoding settings
controls. There's no hard requirement for that API anymore and the
aforementioned controls simply don't do anything when the GStreamer
version used to compile is older than 0.10.32.
A few other GStreamer calls had to be ifdef'd or replaced in order
to compile with 0.10.24.
Note that this patch only makes sure it compiles with older versions,
running the camerabin plugin with GStreamer < 0.10.32 is currently
untested and it might not work as expected.
Task-number: QTBUG-48914
Change-Id: I4ce8e932f24a33e919e29326729e12bbae561faf
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
Diffstat (limited to 'src/plugins/gstreamer/camerabin/camerabinsession.cpp')
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinsession.cpp | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp index a0e9f753b..3dd200c54 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp @@ -308,7 +308,7 @@ static GstCaps *resolutionToCaps(const QSize &resolution, if (frameRate > 0.0) { gint numerator; gint denominator; - gst_util_double_to_fraction(frameRate, &numerator, &denominator); + qt_gst_util_double_to_fraction(frameRate, &numerator, &denominator); gst_caps_set_simple( caps, @@ -404,7 +404,7 @@ void CameraBinSession::setupCaptureResolution() if (!qFuzzyIsNull(viewfinderFrameRate)) { int n, d; - gst_util_double_to_fraction(viewfinderFrameRate, &n, &d); + qt_gst_util_double_to_fraction(viewfinderFrameRate, &n, &d); g_object_set(G_OBJECT(m_videoSrc), "fps-n", n, NULL); g_object_set(G_OBJECT(m_videoSrc), "fps-d", d, NULL); } @@ -798,12 +798,14 @@ void CameraBinSession::start() m_recorderControl->applySettings(); +#ifdef HAVE_GST_ENCODING_PROFILES GstEncodingContainerProfile *profile = m_recorderControl->videoProfile(); g_object_set (G_OBJECT(m_camerabin), "video-profile", profile, NULL); gst_encoding_profile_unref(profile); +#endif setAudioCaptureCaps(); @@ -1065,13 +1067,38 @@ bool CameraBinSession::processBusMessage(const QGstreamerMessage &message) return false; } +QString CameraBinSession::currentContainerFormat() const +{ + if (!m_muxer) + return QString(); + + QString format; + + if (GstPad *srcPad = gst_element_get_static_pad(m_muxer, "src")) { + if (GstCaps *caps = qt_gst_pad_get_caps(srcPad)) { + gchar *capsString = gst_caps_to_string(caps); + format = QString::fromLatin1(capsString); + if (capsString) + g_free(capsString); + gst_caps_unref(caps); + } + gst_object_unref(GST_OBJECT(srcPad)); + } + + return format; +} + void CameraBinSession::recordVideo() { + QString format = currentContainerFormat(); + if (format.isEmpty()) + format = m_mediaContainerControl->actualContainerFormat(); + const QString actualFileName = m_mediaStorageLocation.generateFileName(m_sink.isLocalFile() ? m_sink.toLocalFile() : m_sink.toString(), QMediaStorageLocation::Movies, QLatin1String("clip_"), - m_mediaContainerControl->suggestedFileExtension(m_mediaContainerControl->actualContainerFormat())); + m_mediaContainerControl->suggestedFileExtension(format)); m_recordingActive = true; m_actualSink = QUrl::fromLocalFile(actualFileName); @@ -1433,14 +1460,28 @@ void CameraBinSession::elementAdded(GstBin *, GstElement *element, CameraBinSess g_signal_connect(G_OBJECT(element), "element-removed", G_CALLBACK(elementRemoved), session); } else if (!factory) { // no-op +#if GST_CHECK_VERSION(0,10,31) } else if (gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_AUDIO_ENCODER)) { +#else + } else if (strstr(gst_element_factory_get_klass(factory), "Encoder/Audio") != NULL) { +#endif session->m_audioEncoder = element; session->m_audioEncodeControl->applySettings(element); +#if GST_CHECK_VERSION(0,10,31) } else if (gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_VIDEO_ENCODER)) { +#else + } else if (strstr(gst_element_factory_get_klass(factory), "Encoder/Video") != NULL) { +#endif session->m_videoEncoder = element; session->m_videoEncodeControl->applySettings(element); +#if GST_CHECK_VERSION(0,10,31) + } else if (gst_element_factory_list_is_type(factory, GST_ELEMENT_FACTORY_TYPE_MUXER)) { +#else + } else if (strstr(gst_element_factory_get_klass(factory), "Muxer") != NULL) { +#endif + session->m_muxer = element; } } @@ -1450,6 +1491,8 @@ void CameraBinSession::elementRemoved(GstBin *, GstElement *element, CameraBinSe session->m_audioEncoder = 0; else if (element == session->m_videoEncoder) session->m_videoEncoder = 0; + else if (element == session->m_muxer) + session->m_muxer = 0; } QT_END_NAMESPACE |