[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ktp-call-ui] libktpcall/private: Respect phonon's settings for webcams
From:       Rohan Garg <rohangarg () kubuntu ! org>
Date:       2012-06-21 17:28:06
Message-ID: 20120621172806.AEC73A60A9 () git ! kde ! org
[Download RAW message or body]

Git commit af2c029c7a16af782072fe4bc44039ef15c171e7 by Rohan Garg.
Committed on 21/06/2012 at 19:24.
Pushed by garg into branch 'master'.

Respect phonon's settings for webcams

Now when a user prefers a webcam from the phonon KCM, the call ui
will respect this setting

REVIEWED BY: George Kiagiadakis

M  +18   -1    libktpcall/private/device-element-factory.cpp
M  +45   -4    libktpcall/private/phonon-integration.cpp
M  +2    -1    libktpcall/private/phonon-integration.h

http://commits.kde.org/telepathy-call-ui/af2c029c7a16af782072fe4bc44039ef15c171e7

diff --git a/libktpcall/private/device-element-factory.cpp \
b/libktpcall/private/device-element-factory.cpp index d879dca..d935313 100644
--- a/libktpcall/private/device-element-factory.cpp
+++ b/libktpcall/private/device-element-factory.cpp
@@ -146,7 +146,24 @@ QGst::ElementPtr DeviceElementFactory::makeVideoCaptureElement()
         return element;
     }
 
-    //TODO implement phonon settings
+
+    //Phonon integration
+    QList<Phonon::DeviceAccessList> phononDeviceLists
+        = PhononIntegration::readDevices(Phonon::VideoCaptureDeviceType, \
Phonon::CommunicationCaptureCategory); +
+    Q_FOREACH (const Phonon::DeviceAccessList & deviceList, phononDeviceLists) {
+        Q_FOREACH (const Phonon::DeviceAccess & device, deviceList) {
+            if(device.first == "v4l2") {
+                element = tryElement("v4l2src", device.second);
+            } else if (device.first == "v4l1") {
+                element = tryElement("v4lsrc", device.second);
+            }
+        }
+
+        if (element) {
+            return element;
+        }
+    }
 
     //as a last resort, try gstreamer's autodetection
     element = tryElement("autovideosrc");
diff --git a/libktpcall/private/phonon-integration.cpp \
b/libktpcall/private/phonon-integration.cpp index 95a0100..822017b 100644
--- a/libktpcall/private/phonon-integration.cpp
+++ b/libktpcall/private/phonon-integration.cpp
@@ -76,13 +76,24 @@ K_GLOBAL_STATIC(PhononIntegrationPrivate, s_priv);
 QList<Phonon::DeviceAccessList> \
                PhononIntegration::readDevices(Phonon::ObjectDescriptionType type,
                                                                Phonon::Category \
category)  {
+    QDBusInterface kded (QLatin1String("org.kde.kded"),
+                                     QLatin1String("/kded"),
+                                     QLatin1String("org.kde.kded"));
+
+    QDBusReply<bool> phononLoaded = kded.call(QLatin1String("loadModule"), \
QLatin1String("phononserver")); +
+    if(!phononLoaded) {
+        kDebug() << "Could not load phononserver!!";
+        return QList<Phonon::DeviceAccessList>();
+    }
+
     switch (type) {
     case Phonon::AudioOutputDeviceType:
     case Phonon::AudioCaptureDeviceType:
         return readAudioDevices(type, category);
         break;
     case Phonon::VideoCaptureDeviceType:
-        return readVideoDevices(category);
+        return readVideoDevices(type, category);
         break;
     default:
         return QList<Phonon::DeviceAccessList>();
@@ -140,10 +151,40 @@ QList<Phonon::DeviceAccessList> \
PhononIntegration::readAudioDevices(Phonon::Obje  return list;
 }
 
-QList<Phonon::DeviceAccessList> PhononIntegration::readVideoDevices(Phonon::Category \
category) +QList<Phonon::DeviceAccessList> \
PhononIntegration::readVideoDevices(Phonon::ObjectDescriptionType type, +             \
Phonon::Category category)  {
-    Q_UNUSED (category);
-    return QList<Phonon::DeviceAccessList>(); //TODO implement me
+    QList<Phonon::DeviceAccessList> list;
+
+    QList<int> indices = dbusCall< QList<int> >(s_priv->phononServer,
+                                                \
QLatin1String("videoDevicesIndexes"), type); +    kDebug() << "got video device \
indices" << indices << "for type" << type; +
+    indices = sortDevicesByCategoryPriority(type, category, indices);
+    kDebug() << "sorted video devices indices" << indices << "for category" << \
category; +
+    for (int i=0; i < indices.size(); ++i) {
+        QHash<QByteArray, QVariant> properties =
+            dbusCall< QHash<QByteArray, QVariant> >(s_priv->phononServer,
+                                                    \
QLatin1String("videoDevicesProperties"), +                                            \
indices.at(i)); +
+        if (hideAdvancedDevices()) {
+            const QVariant var = properties.value("isAdvanced");
+            if (var.isValid() && var.toBool()) {
+                kDebug() << "hiding device" << indices.at(i)
+                         << "because it is advanced and HideAdvancedDevices is \
specified"; +                continue;
+            }
+        }
+
+        QVariant accessList = properties.value("deviceAccessList");
+        if (accessList.isValid()) {
+            kDebug() << "appending device access list for device" << indices.at(i);
+            list.append(accessList.value<Phonon::DeviceAccessList>());
+        }
+    }
+    return list;
 }
 
 bool PhononIntegration::hideAdvancedDevices()
diff --git a/libktpcall/private/phonon-integration.h \
b/libktpcall/private/phonon-integration.h index 31eb98d..4474ef9 100644
--- a/libktpcall/private/phonon-integration.h
+++ b/libktpcall/private/phonon-integration.h
@@ -37,7 +37,8 @@ public:
 private:
     static QList<Phonon::DeviceAccessList> \
                readAudioDevices(Phonon::ObjectDescriptionType type,
                                                             Phonon::Category \
                category);
-    static QList<Phonon::DeviceAccessList> readVideoDevices(Phonon::Category \
category); +    static QList<Phonon::DeviceAccessList> \
readVideoDevices(Phonon::ObjectDescriptionType type, +                                \
Phonon::Category category);  static bool hideAdvancedDevices();
     static QList<int> sortDevicesByCategoryPriority(Phonon::ObjectDescriptionType \
                type,
                                                     Phonon::Category category,


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic