Fix incorrect/missing application of recording settings in camerabin.
Don't set profiles if no settings are specified. Apply all settings before starting a pipeline as the mode can switch without being restarted and incompatible video recording settings can prevent the pipeline starting even in image capture mode. Set audio encoding settings and encoder profiles if they are supplied. Change-Id: I06febf977c2cae306383f9dbaae0f81f531b4757 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
committed by
The Qt Project
parent
4565cf26af
commit
dda1bb4716
@@ -106,16 +106,17 @@ void CameraBinAudioEncoder::resetActualSettings()
|
|||||||
GstEncodingProfile *CameraBinAudioEncoder::createProfile()
|
GstEncodingProfile *CameraBinAudioEncoder::createProfile()
|
||||||
{
|
{
|
||||||
QString codec = m_actualAudioSettings.codec();
|
QString codec = m_actualAudioSettings.codec();
|
||||||
|
QString preset = m_actualAudioSettings.encodingOption(QStringLiteral("preset")).toString();
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
if (codec.isEmpty())
|
if (codec.isEmpty())
|
||||||
caps = gst_caps_new_any();
|
return 0;
|
||||||
else
|
else
|
||||||
caps = gst_caps_from_string(codec.toLatin1());
|
caps = gst_caps_from_string(codec.toLatin1());
|
||||||
|
|
||||||
return (GstEncodingProfile *)gst_encoding_audio_profile_new(
|
return (GstEncodingProfile *)gst_encoding_audio_profile_new(
|
||||||
caps,
|
caps,
|
||||||
NULL, //preset
|
!preset.isEmpty() ? preset.toLatin1().constData() : NULL, //preset
|
||||||
NULL, //restriction
|
NULL, //restriction
|
||||||
0); //presence
|
0); //presence
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,7 +191,9 @@ GstEncodingContainerProfile *CameraBinRecorder::videoProfile()
|
|||||||
GstEncodingProfile *audioProfile = m_session->audioEncodeControl()->createProfile();
|
GstEncodingProfile *audioProfile = m_session->audioEncodeControl()->createProfile();
|
||||||
GstEncodingProfile *videoProfile = m_session->videoEncodeControl()->createProfile();
|
GstEncodingProfile *videoProfile = m_session->videoEncodeControl()->createProfile();
|
||||||
|
|
||||||
|
if (audioProfile)
|
||||||
gst_encoding_container_profile_add_profile(containerProfile, audioProfile);
|
gst_encoding_container_profile_add_profile(containerProfile, audioProfile);
|
||||||
|
if (videoProfile)
|
||||||
gst_encoding_container_profile_add_profile(containerProfile, videoProfile);
|
gst_encoding_container_profile_add_profile(containerProfile, videoProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
#define SUPPORTED_IMAGE_CAPTURE_CAPS_PROPERTY "image-capture-supported-caps"
|
#define SUPPORTED_IMAGE_CAPTURE_CAPS_PROPERTY "image-capture-supported-caps"
|
||||||
#define SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY "video-capture-supported-caps"
|
#define SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY "video-capture-supported-caps"
|
||||||
#define SUPPORTED_VIEWFINDER_CAPS_PROPERTY "viewfinder-supported-caps"
|
#define SUPPORTED_VIEWFINDER_CAPS_PROPERTY "viewfinder-supported-caps"
|
||||||
|
#define AUDIO_CAPTURE_CAPS_PROPERTY "audio-capture-caps"
|
||||||
#define IMAGE_CAPTURE_CAPS_PROPERTY "image-capture-caps"
|
#define IMAGE_CAPTURE_CAPS_PROPERTY "image-capture-caps"
|
||||||
#define VIDEO_CAPTURE_CAPS_PROPERTY "video-capture-caps"
|
#define VIDEO_CAPTURE_CAPS_PROPERTY "video-capture-caps"
|
||||||
#define VIEWFINDER_CAPS_PROPERTY "viewfinder-caps"
|
#define VIEWFINDER_CAPS_PROPERTY "viewfinder-caps"
|
||||||
@@ -346,6 +347,32 @@ void CameraBinSession::setupCaptureResolution()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CameraBinSession::setAudioCaptureCaps()
|
||||||
|
{
|
||||||
|
QAudioEncoderSettings settings = m_audioEncodeControl->audioSettings();
|
||||||
|
const int sampleRate = settings.sampleRate();
|
||||||
|
const int channelCount = settings.channelCount();
|
||||||
|
|
||||||
|
if (sampleRate == -1 && channelCount == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GstStructure *structure = gst_structure_new(
|
||||||
|
"audio/x-raw-int",
|
||||||
|
"endianness", G_TYPE_INT, 1234,
|
||||||
|
"signed", G_TYPE_BOOLEAN, TRUE,
|
||||||
|
"width", G_TYPE_INT, 16,
|
||||||
|
"depth", G_TYPE_INT, 16,
|
||||||
|
NULL);
|
||||||
|
if (sampleRate != -1)
|
||||||
|
gst_structure_set(structure, "rate", G_TYPE_INT, sampleRate, NULL);
|
||||||
|
if (channelCount != -1)
|
||||||
|
gst_structure_set(structure, "channels", G_TYPE_INT, channelCount, NULL);
|
||||||
|
|
||||||
|
GstCaps *caps = gst_caps_new_full(structure, NULL);
|
||||||
|
g_object_set(G_OBJECT(m_camerabin), AUDIO_CAPTURE_CAPS_PROPERTY, caps, NULL);
|
||||||
|
gst_caps_unref(caps);
|
||||||
|
}
|
||||||
|
|
||||||
GstElement *CameraBinSession::buildCameraSource()
|
GstElement *CameraBinSession::buildCameraSource()
|
||||||
{
|
{
|
||||||
#if CAMERABIN_DEBUG
|
#if CAMERABIN_DEBUG
|
||||||
@@ -651,14 +678,14 @@ void CameraBinSession::setState(QCamera::State newState)
|
|||||||
GstState pending = GST_STATE_NULL;
|
GstState pending = GST_STATE_NULL;
|
||||||
gst_element_get_state(m_camerabin, &binState, &pending, 0);
|
gst_element_get_state(m_camerabin, &binState, &pending, 0);
|
||||||
|
|
||||||
if (captureMode() == QCamera::CaptureVideo) {
|
|
||||||
m_recorderControl->applySettings();
|
m_recorderControl->applySettings();
|
||||||
|
|
||||||
g_object_set (G_OBJECT(m_camerabin),
|
g_object_set (G_OBJECT(m_camerabin),
|
||||||
"video-profile",
|
"video-profile",
|
||||||
m_recorderControl->videoProfile(),
|
m_recorderControl->videoProfile(),
|
||||||
NULL);
|
NULL);
|
||||||
}
|
|
||||||
|
setAudioCaptureCaps();
|
||||||
|
|
||||||
setupCaptureResolution();
|
setupCaptureResolution();
|
||||||
|
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
bool setupCameraBin();
|
bool setupCameraBin();
|
||||||
void setupCaptureResolution();
|
void setupCaptureResolution();
|
||||||
|
void setAudioCaptureCaps();
|
||||||
static void updateBusyStatus(GObject *o, GParamSpec *p, gpointer d);
|
static void updateBusyStatus(GObject *o, GParamSpec *p, gpointer d);
|
||||||
|
|
||||||
QUrl m_sink;
|
QUrl m_sink;
|
||||||
|
|||||||
@@ -160,18 +160,25 @@ QPair<int,int> CameraBinVideoEncoder::rateAsRational(qreal frameRate) const
|
|||||||
GstEncodingProfile *CameraBinVideoEncoder::createProfile()
|
GstEncodingProfile *CameraBinVideoEncoder::createProfile()
|
||||||
{
|
{
|
||||||
QString codec = m_actualVideoSettings.codec();
|
QString codec = m_actualVideoSettings.codec();
|
||||||
|
QString preset = m_actualVideoSettings.encodingOption(QStringLiteral("preset")).toString();
|
||||||
|
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
if (codec.isEmpty())
|
if (codec.isEmpty())
|
||||||
caps = gst_caps_new_any();
|
caps = 0;
|
||||||
else
|
else
|
||||||
caps = gst_caps_from_string(codec.toLatin1());
|
caps = gst_caps_from_string(codec.toLatin1());
|
||||||
|
|
||||||
return (GstEncodingProfile *)gst_encoding_video_profile_new(
|
GstEncodingVideoProfile *profile = gst_encoding_video_profile_new(
|
||||||
caps,
|
caps,
|
||||||
NULL, //preset
|
!preset.isEmpty() ? preset.toLatin1().constData() : NULL, //preset
|
||||||
NULL, //restriction
|
NULL, //restriction
|
||||||
0); //presence
|
1); //presence
|
||||||
|
|
||||||
|
gst_encoding_video_profile_set_pass(profile, 0);
|
||||||
|
gst_encoding_video_profile_set_variableframerate(profile, TRUE);
|
||||||
|
|
||||||
|
return (GstEncodingProfile *)profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
Reference in New Issue
Block a user