[Merge] lp:~phablet-team/ubuntu/utopic/qtmultimedia-opensource-src/use-camerabin1 into lp:ubuntu/qtmultimedia-opensource-src

Jim Hodapp jim.hodapp at canonical.com
Thu May 29 07:52:29 UTC 2014


A few comments inline. Once these get resolved, it should be ready.

Diff comments:

> === modified file 'debian/changelog'
> --- debian/changelog	2014-05-09 13:19:04 +0000
> +++ debian/changelog	2014-05-28 13:01:34 +0000
> @@ -1,3 +1,9 @@
> +qtmultimedia-opensource-src (5.2.1-3ubuntu3) UNRELEASED; urgency=medium
> +
> +  * Use camerabin1 instead of camerabin2 to improve success in querying and setting resolution and framerate
> +
> + -- Ugo Riboni <ugo.riboni at canonical.com>  Wed, 28 May 2014 14:39:36 +0200
> +
>  qtmultimedia-opensource-src (5.2.1-3ubuntu2) utopic; urgency=medium
>  
>    * Package qtmultimedia5-examples should depend on qml-module-qtmultimedia
> 
> === modified file 'debian/patches/series'
> --- debian/patches/series	2014-05-07 08:03:29 +0000
> +++ debian/patches/series	2014-05-28 13:01:34 +0000
> @@ -1,3 +1,4 @@
>  skip_failing_tests.patch
>  fix_failing_test.diff
>  bigendian_support.diff
> +use-camerabin1.diff
> 
> === added file 'debian/patches/use-camerabin1.diff'
> --- debian/patches/use-camerabin1.diff	1970-01-01 00:00:00 +0000
> +++ debian/patches/use-camerabin1.diff	2014-05-28 13:01:34 +0000
> @@ -0,0 +1,366 @@
> +Description: Use camerabin1 instead of camerabin2 to improve success in querying and setting resolution and framerate
> +Author: Ugo Riboni <ugo.riboni at canonical.com>
> +Last-Update: 2014-05-28
> +
> +=== modified file 'src/plugins/gstreamer/camerabin/camerabinsession.cpp'
> +--- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp	2014-05-20 12:02:34 +0000
> ++++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp	2014-05-21 15:32:57 +0000
> +@@ -82,31 +82,25 @@
> + //#define CAMERABIN_DEBUG_DUMP_BIN 1
> + #define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v)))
> + 
> +-#define FILENAME_PROPERTY "location"
> ++#define FILENAME_PROPERTY "filename"
> + #define MODE_PROPERTY "mode"
> + #define MUTE_PROPERTY "mute"
> + #define IMAGE_PP_PROPERTY "image-post-processing"
> + #define IMAGE_ENCODER_PROPERTY "image-encoder"
> + #define VIDEO_PP_PROPERTY "video-post-processing"
> + #define VIEWFINDER_SINK_PROPERTY "viewfinder-sink"
> +-#define CAMERA_SOURCE_PROPERTY "camera-source"
> + #define AUDIO_SOURCE_PROPERTY "audio-source"
> + #define SUPPORTED_IMAGE_CAPTURE_CAPS_PROPERTY "image-capture-supported-caps"
> +-#define SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY "video-capture-supported-caps"
> +-#define SUPPORTED_VIEWFINDER_CAPS_PROPERTY "viewfinder-supported-caps"
> ++#define SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY "video-source-caps"
> + #define AUDIO_CAPTURE_CAPS_PROPERTY "audio-capture-caps"
> +-#define IMAGE_CAPTURE_CAPS_PROPERTY "image-capture-caps"
> +-#define VIDEO_CAPTURE_CAPS_PROPERTY "video-capture-caps"
> +-#define VIEWFINDER_CAPS_PROPERTY "viewfinder-caps"
> + #define PREVIEW_CAPS_PROPERTY "preview-caps"
> + #define POST_PREVIEWS_PROPERTY "post-previews"
> + 
> +-
> +-#define CAPTURE_START "start-capture"
> +-#define CAPTURE_STOP "stop-capture"
> +-
> +-#define CAMERABIN_IMAGE_MODE 1
> +-#define CAMERABIN_VIDEO_MODE 2
> ++#define CAPTURE_START "capture-start"
> ++#define CAPTURE_STOP "capture-stop"
> ++
> ++#define CAMERABIN_IMAGE_MODE 0
> ++#define CAMERABIN_VIDEO_MODE 1
> + 
> + #define gstRef(element) { gst_object_ref(GST_OBJECT(element)); gst_object_sink(GST_OBJECT(element)); }
> + #define gstUnref(element) { if (element) { gst_object_unref(GST_OBJECT(element)); element = 0; } }
> +@@ -144,7 +138,7 @@
> +      m_audioEncoder(0),
> +      m_muxer(0)
> + {
> +-    m_camerabin = gst_element_factory_make("camerabin2", "camerabin2");
> ++    m_camerabin = gst_element_factory_make("camerabin", "camerabin");
> +     g_signal_connect(G_OBJECT(m_camerabin), "notify::idle", G_CALLBACK(updateBusyStatus), this);
> +     gstRef(m_camerabin);
> + 
> +@@ -247,103 +241,25 @@
> +     return true;
> + }
> + 
> +-static GstCaps *resolutionToCaps(const QSize &resolution, const QPair<int, int> &rate = qMakePair<int,int>(0,0))
> +-{
> +-    if (resolution.isEmpty())
> +-        return gst_caps_new_any();
> +-
> +-    GstCaps *caps = 0;
> +-    if (rate.second > 0) {
> +-        caps = gst_caps_new_full(gst_structure_new("video/x-raw-yuv",
> +-                                                   "width", G_TYPE_INT, resolution.width(),
> +-                                                   "height", G_TYPE_INT, resolution.height(),
> +-                                                   "framerate", GST_TYPE_FRACTION, rate.first, rate.second,
> +-                                                   NULL),
> +-                                 gst_structure_new("video/x-raw-rgb",
> +-                                                   "width", G_TYPE_INT, resolution.width(),
> +-                                                   "height", G_TYPE_INT, resolution.height(),
> +-                                                   "framerate", GST_TYPE_FRACTION, rate.first, rate.second,
> +-                                                   NULL),
> +-                                 gst_structure_new("video/x-raw-data",
> +-                                                   "width", G_TYPE_INT, resolution.width(),
> +-                                                   "height", G_TYPE_INT, resolution.height(),
> +-                                                   "framerate", GST_TYPE_FRACTION, rate.first, rate.second,
> +-                                                   NULL),
> +-                                gst_structure_new("video/x-android-buffer",
> +-                                                   "width", G_TYPE_INT, resolution.width(),
> +-                                                                                    "height", G_TYPE_INT, resolution.height(),
> +-                                                                                    "framerate", GST_TYPE_FRACTION, rate.first, rate.second,
> +-                                                                                    NULL),
> +-                                 gst_structure_new("image/jpeg",
> +-                                                   "width", G_TYPE_INT, resolution.width(),
> +-                                                   "height", G_TYPE_INT, resolution.height(),
> +-                                                   "framerate", GST_TYPE_FRACTION, rate.first, rate.second,
> +-                                                   NULL),
> +-                                 NULL);
> +-    } else {
> +-        caps = gst_caps_new_full (gst_structure_new ("video/x-raw-yuv",
> +-                                                     "width", G_TYPE_INT, resolution.width(),
> +-                                                     "height", G_TYPE_INT, resolution.height(),
> +-                                                     NULL),
> +-                                  gst_structure_new ("video/x-raw-rgb",
> +-                                                     "width", G_TYPE_INT, resolution.width(),
> +-                                                     "height", G_TYPE_INT, resolution.height(),
> +-                                                     NULL),
> +-                                  gst_structure_new("video/x-raw-data",
> +-                                                    "width", G_TYPE_INT, resolution.width(),
> +-                                                    "height", G_TYPE_INT, resolution.height(),
> +-                                                    NULL),
> +-                                  gst_structure_new ("video/x-android-buffer",
> +-                                                     "width", G_TYPE_INT, resolution.width(),
> +-                                                     "height", G_TYPE_INT, resolution.height(),
> +-                                                     NULL),
> +-                                  gst_structure_new ("image/jpeg",
> +-                                                     "width", G_TYPE_INT, resolution.width(),
> +-                                                     "height", G_TYPE_INT, resolution.height(),
> +-                                                     NULL),
> +-                                  NULL);
> +-    }
> +-
> +-    return caps;
> +-}
> +-
> + void CameraBinSession::setupCaptureResolution()
> + {
> +     QSize resolution = m_imageEncodeControl->imageSettings().resolution();
> +     if (!resolution.isEmpty()) {
> +-        GstCaps *caps = resolutionToCaps(resolution);
> +-#if CAMERABIN_DEBUG
> +-        qDebug() << Q_FUNC_INFO << "set image resolution" << resolution << gst_caps_to_string(caps);
> +-#endif
> +-        g_object_set(m_camerabin, IMAGE_CAPTURE_CAPS_PROPERTY, caps, NULL);
> +-        gst_caps_unref(caps);
> +-    } else {
> +-        g_object_set(m_camerabin, IMAGE_CAPTURE_CAPS_PROPERTY, NULL, NULL);
> ++        g_signal_emit_by_name (m_camerabin, "set-image-resolution",
> ++            resolution.width(),resolution.height(), 0);
> +     }
> + 
> +     resolution = m_videoEncodeControl->actualVideoSettings().resolution();
> +-    //qreal framerate = m_videoEncodeControl->videoSettings().frameRate();
> +-    if (!resolution.isEmpty()) {
> +-        GstCaps *caps = resolutionToCaps(resolution /*, framerate*/); //convert to rational
> +-#if CAMERABIN_DEBUG
> +-        qDebug() << Q_FUNC_INFO << "set video resolution" << resolution << gst_caps_to_string(caps);
> +-#endif
> +-        g_object_set(m_camerabin, VIDEO_CAPTURE_CAPS_PROPERTY, caps, NULL);
> +-        gst_caps_unref(caps);
> +-    } else {
> +-        g_object_set(m_camerabin, VIDEO_CAPTURE_CAPS_PROPERTY, NULL, NULL);
> +-    }
> +-
> +-    resolution = m_viewfinderSettingsControl->resolution();
> +-    if (!resolution.isEmpty()) {
> +-        GstCaps *caps = resolutionToCaps(resolution);
> +-#if CAMERABIN_DEBUG
> +-        qDebug() << Q_FUNC_INFO << "set viewfinder resolution" << resolution << gst_caps_to_string(caps);
> +-#endif
> +-        g_object_set(m_camerabin, VIEWFINDER_CAPS_PROPERTY, caps, NULL);
> +-        gst_caps_unref(caps);
> +-    } else {
> +-        g_object_set(m_camerabin, VIEWFINDER_CAPS_PROPERTY, NULL, NULL);
> ++    qreal framerate = m_videoEncodeControl->actualVideoSettings().frameRate();
> ++
> ++    if (!resolution.isEmpty()) {
> ++#if CAMERABIN_DEBUG
> ++        qDebug() << Q_FUNC_INFO << "set video resolution" << resolution << framerate;
> ++#endif
> ++
> ++        QPair<int, int> rate = m_videoEncodeControl->rateAsRational(framerate);
> ++        g_signal_emit_by_name (m_camerabin, "set-video-resolution-fps", resolution.width(),
> ++            resolution.height(), rate.first, rate.second, NULL);
> +     }
> + }
> + 
> +@@ -383,7 +299,7 @@
> +     m_videoInputHasChanged = false;
> + 
> +     GstElement *videoSrc = 0;
> +-    g_object_get(G_OBJECT(m_camerabin), CAMERA_SOURCE_PROPERTY, &videoSrc, NULL);
> ++    g_object_get(G_OBJECT(m_camerabin), "video-source", &videoSrc, NULL);
> + 
> +     // If the QT_GSTREAMER_CAMERABIN_SRC environment variable has been set use the source
> +     // it recommends.
> +@@ -435,9 +351,6 @@
> +         }
> +     }
> + 
> +-    if (m_videoSrc != videoSrc)
> +-        g_object_set(G_OBJECT(m_camerabin), CAMERA_SOURCE_PROPERTY, m_videoSrc, NULL);
> +-
> +     return m_videoSrc;
> + }
> + 
> +@@ -624,6 +537,83 @@
> +     return m_pendingState;
> + }
> + 
> ++static gint compare_ranks (GstPluginFeature * f1, GstPluginFeature * f2)
> ++{
> ++  gint diff;
> ++  const gchar *rname1, *rname2;
> ++
> ++  diff =  gst_plugin_feature_get_rank (f2) - gst_plugin_feature_get_rank (f1);
> ++  if (diff != 0)
> ++    return diff;
> ++
> ++  rname1 = gst_plugin_feature_get_name (f1);
> ++  rname2 = gst_plugin_feature_get_name (f2);
> ++
> ++  diff = g_strcmp0 (rname1, rname2);
> ++
> ++  return diff;
> ++}
> ++
> ++QString CameraBinSession::findPlugin(const QString &category, const QString &MIMEType) const
> ++{
> ++#ifdef CAMERABIN_DEBUG_FIND_CODECS
> ++    qDebug() << "Trying to find codec for category" << category << "and type" << MIMEType;
> ++#endif
> ++
> ++    GstCaps* wanted = gst_caps_from_string(MIMEType.toLatin1());

Style consistency: GstCaps *wanted instead of GstCaps* wanted

> ++    GList *feature_list;
> ++    GList *walk;
> ++
> ++    feature_list = gst_registry_get_feature_list(gst_registry_get_default(), GST_TYPE_ELEMENT_FACTORY);
> ++    feature_list = g_list_sort(feature_list, (GCompareFunc) compare_ranks);
> ++
> ++    for (walk = feature_list; walk != NULL; walk = walk->next) {
> ++        GstElementFactory *factory;
> ++        const gchar *klass;
> ++
> ++        factory = GST_ELEMENT_FACTORY(walk->data);
> ++        klass = gst_element_factory_get_klass(factory);
> ++
> ++        if (category == klass) {
> ++#ifdef CAMERABIN_DEBUG_FIND_CODECS
> ++            qDebug() << "  element" << GST_PLUGIN_FEATURE_NAME(factory) << ":" << gst_plugin_feature_get_rank((GstPluginFeature*)walk->data);
> ++#endif
> ++
> ++            const GList *list;
> ++            const GList *walkpads;
> ++            list = gst_element_factory_get_static_pad_templates(factory);
> ++            for (walkpads = list; walkpads != NULL; walkpads = walkpads->next) {
> ++                GstStaticPadTemplate *pad = (GstStaticPadTemplate*) walkpads->data;
> ++                if (pad->direction == GST_PAD_SRC) {
> ++                    GstCaps *padcaps = gst_static_pad_template_get_caps(pad);
> ++
> ++#ifdef CAMERABIN_DEBUG_FIND_CODECS
> ++                    unsigned int padcapslen = gst_caps_get_size(padcaps);
> ++                    for (unsigned int i = 0; i < padcapslen; i++) {
> ++                        GstStructure *structure = gst_caps_get_structure(padcaps, i);
> ++                        qDebug() << "     " << gst_structure_get_name(structure);
> ++                    }
> ++#endif
> ++                    if (gst_caps_can_intersect(padcaps, wanted)) {
> ++#ifdef CAMERABIN_DEBUG_FIND_CODECS
> ++                        qDebug() << "     ^^^^ MATCH";
> ++#endif
> ++                        gst_caps_unref(wanted);
> ++                        gst_caps_unref(padcaps);
> ++                        gst_plugin_feature_list_free(feature_list);
> ++                        return GST_PLUGIN_FEATURE_NAME(factory);
> ++                    }
> ++                    gst_caps_unref(padcaps);
> ++                }
> ++            }
> ++        }
> ++    }
> ++    gst_plugin_feature_list_free(feature_list);
> ++    gst_caps_unref(wanted);
> ++
> ++    return QString();
> ++}
> ++
> + void CameraBinSession::setState(QCamera::State newState)
> + {
> +     if (newState == m_pendingState)
> +@@ -680,10 +670,35 @@
> + 
> +             m_recorderControl->applySettings();
> + 
> +-            g_object_set (G_OBJECT(m_camerabin),
> +-                          "video-profile",
> +-                          m_recorderControl->videoProfile(),
> +-                          NULL);
> ++            QString videoCodec = findPlugin("Codec/Encoder/Video", m_videoEncodeControl->actualVideoSettings().codec());
> ++            if (videoCodec.isEmpty()) {
> ++                qWarning() << "No video encoder found for MIME type" << m_videoEncodeControl->actualVideoSettings().codec();

What happens if the videoCodec or audioCodec or containerFormat QStrings are empty? Does recording still work at all? Does the user get an error indicating recording won't work?

> ++            } else {
> ++                g_object_set (G_OBJECT(m_camerabin),
> ++                              "video-encoder",
> ++                              gst_element_factory_make(videoCodec.toLatin1(), NULL),
> ++                              NULL);
> ++            }
> ++
> ++            QString audioCodec = findPlugin("Codec/Encoder/Audio", m_audioEncodeControl->actualAudioSettings().codec());
> ++            if (audioCodec.isEmpty()) {
> ++                qWarning() << "No audio encoder found for MIME type" << m_audioEncodeControl->actualAudioSettings().codec();
> ++            } else {
> ++                g_object_set (G_OBJECT(m_camerabin),
> ++                              "audio-encoder",
> ++                              gst_element_factory_make(audioCodec.toLatin1(), NULL),
> ++                              NULL);
> ++            }
> ++
> ++            QString containerFormat = findPlugin("Codec/Muxer", m_mediaContainerControl->actualContainerFormat());
> ++            if (containerFormat.isEmpty()) {
> ++                qWarning() << "No muxer found for MIME type" << m_mediaContainerControl->actualContainerFormat();
> ++            } else {
> ++                g_object_set (G_OBJECT(m_camerabin),
> ++                              "video-muxer",
> ++                              gst_element_factory_make(containerFormat.toLatin1(), NULL),
> ++                              NULL);
> ++            }
> + 
> +             setAudioCaptureCaps();
> + 
> +@@ -1049,11 +1064,8 @@
> + {
> +     QList< QPair<int,int> > res;
> + 
> +-    GstCaps *supportedCaps = 0;
> +-    g_object_get(G_OBJECT(m_camerabin),
> +-                 SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY,
> +-                 &supportedCaps, NULL);
> +-
> ++    GstCaps *supportedCaps;
> ++    g_object_get(G_OBJECT(m_camerabin), SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY, &supportedCaps, NULL);
> +     if (!supportedCaps)
> +         return res;
> + 
> +@@ -1161,10 +1173,12 @@
> +         *continuous = false;
> + 
> +     GstCaps *supportedCaps = 0;

Is there a g_object_unref for supportedCaps?

> +-    g_object_get(G_OBJECT(m_camerabin),
> +-                 (mode == QCamera::CaptureStillImage) ?
> +-                     SUPPORTED_IMAGE_CAPTURE_CAPS_PROPERTY : SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY,
> +-                 &supportedCaps, NULL);
> ++
> ++    if (mode == QCamera::CaptureStillImage) {
> ++        g_object_get(G_OBJECT(m_camerabin), SUPPORTED_IMAGE_CAPTURE_CAPS_PROPERTY, &supportedCaps, NULL);
> ++    } else {
> ++        g_object_get(G_OBJECT(m_camerabin), SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY, &supportedCaps, NULL);
> ++    }
> + 
> +     if (!supportedCaps)
> +         return res;
> +@@ -1235,7 +1249,6 @@
> +             res << maxSize;
> +     }
> + 
> +-
> +     qSort(res.begin(), res.end(), resolutionLessThan);
> + 
> +     //if the range is continuos, populate is with the common rates

Spelling mistake: should be "continuous"

> +
> +=== modified file 'src/plugins/gstreamer/camerabin/camerabinsession.h'
> +--- a/src/plugins/gstreamer/camerabin/camerabinsession.h	2014-05-20 12:02:34 +0000
> ++++ b/src/plugins/gstreamer/camerabin/camerabinsession.h	2014-05-20 12:53:53 +0000
> +@@ -195,6 +195,7 @@
> +     void setupCaptureResolution();
> +     void setAudioCaptureCaps();
> +     static void updateBusyStatus(GObject *o, GParamSpec *p, gpointer d);
> ++    QString findPlugin(const QString &category, const QString &MIMEType) const;
> + 
> +     QUrl m_sink;
> +     QUrl m_actualSink;
> +
> 


-- 
https://code.launchpad.net/~phablet-team/ubuntu/utopic/qtmultimedia-opensource-src/use-camerabin1/+merge/221223
Your team Ubuntu Phablet Team is subscribed to branch lp:~phablet-team/ubuntu/utopic/qtmultimedia-opensource-src/use-camerabin1.



More information about the Ubuntu-reviews mailing list