GStreamer: correctly handle URLs from QMediaRecorder::setOutputLocation
Task-number: QTBUG-39949 Change-Id: Idf575b126bd3531655c8abda55c9e04149a4fb85 Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
This commit is contained in:
@@ -487,6 +487,11 @@ QUrl CameraBinSession::outputLocation() const
|
||||
|
||||
bool CameraBinSession::setOutputLocation(const QUrl& sink)
|
||||
{
|
||||
if (!sink.isRelative() && !sink.isLocalFile()) {
|
||||
qWarning("Output location must be a local file");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_sink = m_actualSink = sink;
|
||||
return true;
|
||||
}
|
||||
@@ -1007,8 +1012,9 @@ void CameraBinSession::recordVideo()
|
||||
if (m_actualSink.isEmpty()) {
|
||||
QString ext = m_mediaContainerControl->suggestedFileExtension(m_mediaContainerControl->actualContainerFormat());
|
||||
m_actualSink = QUrl::fromLocalFile(generateFileName("clip_", defaultDir(QCamera::CaptureVideo), ext));
|
||||
} else if (!m_actualSink.isLocalFile()) {
|
||||
m_actualSink = QUrl::fromLocalFile(m_actualSink.toEncoded());
|
||||
} else {
|
||||
// Output location was rejected in setOutputlocation() if not a local file
|
||||
m_actualSink = QUrl::fromLocalFile(QDir::currentPath()).resolved(m_actualSink);
|
||||
}
|
||||
|
||||
QString fileName = m_actualSink.toLocalFile();
|
||||
|
||||
@@ -134,8 +134,10 @@ GstElement *QGstreamerCaptureSession::buildEncodeBin()
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Output location was rejected in setOutputlocation() if not a local file
|
||||
QUrl actualSink = QUrl::fromLocalFile(QDir::currentPath()).resolved(m_sink);
|
||||
GstElement *fileSink = gst_element_factory_make("filesink", "filesink");
|
||||
g_object_set(G_OBJECT(fileSink), "location", m_sink.toString().toLocal8Bit().constData(), NULL);
|
||||
g_object_set(G_OBJECT(fileSink), "location", QFile::encodeName(actualSink.toLocalFile()).constData(), NULL);
|
||||
gst_bin_add_many(GST_BIN(encodeBin), muxer, fileSink, NULL);
|
||||
|
||||
if (!gst_element_link(muxer, fileSink)) {
|
||||
@@ -731,6 +733,11 @@ QUrl QGstreamerCaptureSession::outputLocation() const
|
||||
|
||||
bool QGstreamerCaptureSession::setOutputLocation(const QUrl& sink)
|
||||
{
|
||||
if (!sink.isRelative() && !sink.isLocalFile()) {
|
||||
qWarning("Output location must be a local file");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_sink = sink;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user