]> git.sesse.net Git - kdenlive/commitdiff
Display webcam pixel format in wizard
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 27 Oct 2010 20:21:45 +0000 (20:21 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 27 Oct 2010 20:21:45 +0000 (20:21 +0000)
svn path=/trunk/kdenlive/; revision=5054

src/blackmagic/capture.cpp
src/blackmagic/capture.h
src/kdenlivesettingsdialog.cpp
src/stopmotion/capturehandler.h
src/stopmotion/stopmotion.cpp
src/v4l/src.c
src/v4l/src.h
src/v4l/src_v4l2.c
src/v4l/v4lcapture.cpp
src/v4l/v4lcapture.h
src/wizard.cpp

index cb953b824c54ffe707d310d33121699cad9f1c97..505c0858e3a161e322fbf2b4332f70267c0b532e 100644 (file)
@@ -492,9 +492,9 @@ BmdCaptureHandler::BmdCaptureHandler(QVBoxLayout *lay, QWidget *parent):
 {
 }
 
-QString BmdCaptureHandler::getDeviceName(QString, int *, int *)
+QStringList BmdCaptureHandler::getDeviceName(QString)
 {
-    return QString();
+    return QStringList();
 }
 
 void BmdCaptureHandler::startPreview(int deviceId, int captureMode, bool audio)
index db716c80c505be26c088a7b148ee2a53e505d0fc..1a7942ec51ab28df2d72b8d6e3f4fe6c9abdebf7 100644 (file)
@@ -59,7 +59,7 @@ public:
     void showOverlay(QImage img, bool transparent = true);
     void hideOverlay();
     void hidePreview(bool hide);
-    QString getDeviceName(QString, int *, int *);
+    QStringList getDeviceName(QString);
 
 private:
     IDeckLinkIterator       *deckLinkIterator;
index f17c9f75d5f3ddd5cea4ede6a0077626efa67dcf..946a5bdfc5b794b2c83e41f35f8844d79f7e80e9 100644 (file)
@@ -83,15 +83,13 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent) :
     m_configCapture.setupUi(p4);
 
     V4lCaptureHandler v4l(NULL);
-    int width;
-    int height;
     // Video 4 Linux device detection
     for (int i = 0; i < 10; i++) {
         QString path = "/dev/video" + QString::number(i);
         if (QFile::exists(path)) {
-            QString deviceName = v4l.getDeviceName(path.toUtf8().constData(), &width, &height);
-            m_configCapture.kcfg_detectedv4ldevices->addItem(deviceName, path);
-            if (width > 0) m_configCapture.kcfg_detectedv4ldevices->setItemData(m_configCapture.kcfg_detectedv4ldevices->count() - 1, QString("%1x%2").arg(width).arg(height), Qt::UserRole + 1);
+            QStringList deviceInfo = v4l.getDeviceName(path);
+            m_configCapture.kcfg_detectedv4ldevices->addItem(deviceInfo.at(0), path);
+            m_configCapture.kcfg_detectedv4ldevices->setItemData(m_configCapture.kcfg_detectedv4ldevices->count() - 1, deviceInfo.at(1), Qt::UserRole + 1);
         }
     }
     connect(m_configCapture.kcfg_detectedv4ldevices, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdatev4lDevice()));
index f43fddae8b2d631e89d984d9f21ad9302f249db7..342a25105161ef3f4137bd45c7a82ee76dc43555 100644 (file)
@@ -38,7 +38,7 @@ public:
     virtual void showOverlay(QImage img, bool transparent = true) = 0;
     virtual void hideOverlay() = 0;
     virtual void hidePreview(bool hide) = 0;
-    virtual QString getDeviceName(QString input, int *width, int *height) = 0;
+    virtual QStringList getDeviceName(QString input) = 0;
     static void yuv2rgb(unsigned char *yuv_buffer, unsigned char *rgb_buffer, int width, int height);
 
 protected:
index e4e89f05470d37dbe1da8c86ccee7f92f2ab2449..a2485a9144eba48de80794e4a072cd35dd717cc8 100644 (file)
@@ -191,7 +191,7 @@ StopmotionWidget::StopmotionWidget(KUrl projectFolder, const QList< QAction * >
     }
     if (QFile::exists(KdenliveSettings::video4vdevice())) {
         if (m_bmCapture == NULL) m_bmCapture = new V4lCaptureHandler(m_layout);
-        capture_device->addItem(m_bmCapture->getDeviceName(KdenliveSettings::video4vdevice(), 0, 0), "v4l");
+        capture_device->addItem(m_bmCapture->getDeviceName(KdenliveSettings::video4vdevice()).at(0), "v4l");
     }
 
     connect(m_bmCapture, SIGNAL(frameSaved(const QString)), this, SLOT(slotNewThumb(const QString)));
index 96bb64cf5798cb5dd0dd8b54fe6b5c3084fc595f..391b121cfda1e5bbf6b3f5c9abcdc3833c100f79 100644 (file)
@@ -79,10 +79,10 @@ int src_open(src_t *src, char *source)
        return 0;
 }
 
-const char *src_query(src_t *src, char *source, int *width, int *height)
+const char *src_query(src_t *src, char *source, int *width, int *height, char **pixelformat)
 {
     src->source = source;
-    return src_v4l2.query(src, width, height);
+    return src_v4l2.query(src, width, height, pixelformat);
 }
 
 int src_close(src_t *src)
index 011a95191b861a0f2f20b9a46773632d05612b58..ae228a4b23798a84099c3bc9aed6854a9fbaeb18 100644 (file)
@@ -119,7 +119,7 @@ typedef struct {
        int (*open)(src_t *);
        int (*close)(src_t *);
        int (*grab)(src_t *);
-       const char *(*query)(src_t *, int*, int*);
+       const char *(*query)(src_t *, int*, int*, char **);
        
 } src_mod_t;
 
@@ -207,7 +207,7 @@ typedef struct {
 extern int src_open(src_t *src, char *source);
 extern int src_close(src_t *src);
 extern int src_grab(src_t *src);
-extern const char *src_query(src_t *src, char *source, int *width, int *height);
+extern const char *src_query(src_t *src, char *source, int *width, int *height, char **pixelformat);
 
 extern int src_set_option(src_option_t ***options, char *name, char *value);
 extern int src_get_option_by_number(src_option_t **opt, int number, char **name, char **value);
index 641913f6bf230a333eb26eb11ff864d9ef053e5a..6c37abdf51e5f0bf98e97ec374ba7cc9da42e0eb 100644 (file)
@@ -802,7 +802,7 @@ int src_v4l2_set_read(src_t *src)
        return(0);
 }
 
-static const char *src_v4l2_query(src_t *src, int *width, int *height)
+static const char *src_v4l2_query(src_t *src, int *width, int *height, char **pixelformat)
 {
        if(!src->source)
        {
@@ -836,10 +836,10 @@ static const char *src_v4l2_query(src_t *src, int *width, int *height)
            fprintf(stderr, "Cannot get capabilities.");
            return NULL;
        }
-       char * res = (char*) s->cap.card;
+       char *res = (char*) s->cap.card;
        if(!s->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) {
-           width = 0;
-           height = 0;
+           *width = 0;
+           *height = 0;
        }
        else {
            struct v4l2_format format;
@@ -851,8 +851,17 @@ static const char *src_v4l2_query(src_t *src, int *width, int *height)
             else {
                *width = format.fmt.pix.width;
                *height = format.fmt.pix.height;
-               fprintf(stderr, "Size: %d, %d.", width, height);
            }
+           struct v4l2_fmtdesc fmt;
+           memset(&fmt,0,sizeof(fmt));
+           fmt.index = 0;
+           fmt.type  = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+           if (ioctl(s->fd, VIDIOC_ENUM_FMT, &fmt) != -1)
+           {
+               *pixelformat = fmt.description;
+               fprintf(stderr, "format: %s", fmt.description);
+           }
+           else *pixelformat = "";
        }
        src_v4l2_close(src);
        return res;
index 013a7c80c79dacc4b9b908b103a541afb78413cf..c067a3a2bb766dd8fe95c0dc366157526c37a3fe 100644 (file)
@@ -96,7 +96,7 @@ V4lCaptureHandler::V4lCaptureHandler(QVBoxLayout *lay, QWidget *parent):
     lay->addWidget(m_display);
 }
 
-QString V4lCaptureHandler::getDeviceName(QString input, int *width, int *height)
+QStringList V4lCaptureHandler::getDeviceName(QString input)
 {
     fswebcam_config_t *config;
     /* Prepare the configuration structure. */
@@ -104,7 +104,7 @@ QString V4lCaptureHandler::getDeviceName(QString input, int *width, int *height)
     if (!config) {
         /*WARN("Out of memory.");*/
         fprintf(stderr, "Out of MEM....");
-        return input;
+        return QStringList() << input;
     }
 
     /* Set the defaults. */
@@ -154,9 +154,13 @@ QString V4lCaptureHandler::getDeviceName(QString input, int *width, int *height)
     v4lsrc.fps        = config->fps;
     v4lsrc.option     = config->option;
     char *source = config->device;
-    QString deviceName = src_query(&v4lsrc, source, width, height);
-    kDebug() << "DEVIE NAME: " << deviceName << ".";
-    return deviceName.isEmpty() ? input : deviceName;
+    int width = 0;
+    int height = 0;
+    char *pixelformat;
+    QString deviceName = src_query(&v4lsrc, source, &width, &height, &pixelformat);
+    QStringList result;
+    result << (deviceName.isEmpty() ? input : deviceName) << (width == 0 ? QString() : QString("%1x%2").arg(width).arg(height)) << QString(pixelformat);
+    return result;
 }
 
 void V4lCaptureHandler::startPreview(int /*deviceId*/, int /*captureMode*/, bool)
index ffa35b9358642135ad3c62b47a3811e88f8ec5d1..464bfa592d7c07c4ac6f65bb957b4ac3075b0668 100644 (file)
@@ -44,7 +44,7 @@ public:
     void showOverlay(QImage img, bool transparent = true);
     void hideOverlay();
     void hidePreview(bool hide);
-    QString getDeviceName(QString input, int *width, int *height);
+    QStringList getDeviceName(QString input);
 
 private:
     bool m_update;
index ad6a9e11061b81a77648189fe8a18cbab92dd23b..c88f9a01a143538e95035b75ed6b7e14ab073bb4 100644 (file)
@@ -150,18 +150,14 @@ void Wizard::slotDetectWebcam()
 
     // Video 4 Linux device detection
     V4lCaptureHandler v4l(NULL);
-    int width = 0;
-    int height = 0;
     for (int i = 0; i < 10; i++) {
         QString path = "/dev/video" + QString::number(i);
         if (QFile::exists(path)) {
-            QString deviceName = v4l.getDeviceName(path.toUtf8().constData(), &width, &height);
-            QString captureSize;
-            if (width > 0) captureSize = QString::number(width) + "x" + QString::number(height);
-            if (!deviceName.isEmpty()) {
-                QTreeWidgetItem *item = new QTreeWidgetItem(m_capture.device_list, QStringList() << deviceName << captureSize);
+            QStringList deviceInfo = v4l.getDeviceName(path.toUtf8().constData());
+            if (!deviceInfo.isEmpty()) {
+                QTreeWidgetItem *item = new QTreeWidgetItem(m_capture.device_list, QStringList() << deviceInfo.at(0) << "(" + deviceInfo.at(1) + ") " + deviceInfo.at(2));
                 item->setData(0, Qt::UserRole, path);
-                if (!captureSize.isEmpty()) item->setData(0, Qt::UserRole + 1, captureSize);
+                item->setData(0, Qt::UserRole + 1, deviceInfo.at(1));
             }
         }
     }