Implement encoder settings in camerabin backend.
This is not comprehensive since different encoders have different names and representations for many settings, but it should cover bit rate for most encoders, and quality and encodingMode for a number of common encoders. Change-Id: I0ba4e70c2f234e0deaaa02bdecc0f5198122c1e9 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
committed by
Yoann Lopes
parent
9c020cd39a
commit
55ce8ed072
@@ -117,4 +117,28 @@ GstEncodingProfile *CameraBinAudioEncoder::createProfile()
|
||||
return profile;
|
||||
}
|
||||
|
||||
void CameraBinAudioEncoder::applySettings(GstElement *encoder)
|
||||
{
|
||||
GObjectClass * const objectClass = G_OBJECT_GET_CLASS(encoder);
|
||||
const char * const name = gst_plugin_feature_get_name(
|
||||
GST_PLUGIN_FEATURE(gst_element_get_factory(encoder)));
|
||||
|
||||
const bool isVorbis = qstrcmp(name, "vorbisenc") == 0;
|
||||
|
||||
const int bitRate = m_actualAudioSettings.bitRate();
|
||||
if (!isVorbis && bitRate == -1) {
|
||||
// Bit rate is invalid, don't evaluate the remaining conditions unless the encoder is
|
||||
// vorbisenc which is known to accept -1 as an unspecified bitrate.
|
||||
} else if (g_object_class_find_property(objectClass, "bitrate")) {
|
||||
g_object_set(G_OBJECT(encoder), "bitrate", bitRate, NULL);
|
||||
} else if (g_object_class_find_property(objectClass, "target-bitrate")) {
|
||||
g_object_set(G_OBJECT(encoder), "target-bitrate", bitRate, NULL);
|
||||
}
|
||||
|
||||
if (isVorbis) {
|
||||
static const double qualities[] = { 0.1, 0.3, 0.5, 0.7, 1.0 };
|
||||
g_object_set(G_OBJECT(encoder), "quality", qualities[m_actualAudioSettings.quality()], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Reference in New Issue
Block a user