diff options
author | Andrew den Exter <andrew.den.exter@jollamobile.com> | 2014-07-17 06:34:30 +0000 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@digia.com> | 2014-09-11 11:41:06 +0200 |
commit | 55ce8ed07233efbfc224a0bfd6d45ad81b24ac99 (patch) | |
tree | 4f937f5d66194430ad5b83aa92fcbdac184b13b4 /src/plugins/gstreamer/camerabin/camerabinaudioencoder.cpp | |
parent | 9c020cd39ad9e81239a0953fb3039b79cbee0433 (diff) |
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>
Diffstat (limited to 'src/plugins/gstreamer/camerabin/camerabinaudioencoder.cpp')
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinaudioencoder.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/plugins/gstreamer/camerabin/camerabinaudioencoder.cpp b/src/plugins/gstreamer/camerabin/camerabinaudioencoder.cpp index fe8098a02..865a764a8 100644 --- a/src/plugins/gstreamer/camerabin/camerabinaudioencoder.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinaudioencoder.cpp @@ -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 |