• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/libkopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • libkopete
  • avdevice
videodevicepool.cpp
Go to the documentation of this file.
1 /*
2  videodevicepool.cpp - Kopete Video Device Low-level Support
3 
4  Copyright (c) 2005-2006 by Cláudio da Silveira Pinheiro <taupter@gmail.com>
5  Copyright (c) 2010 by Frank Schaefer <fschaefer.oss@googlemail.com>
6 
7  Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
8 
9  *************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU Lesser General Public *
13  * License as published by the Free Software Foundation; either *
14  * version 2 of the License, or (at your option) any later version. *
15  * *
16  *************************************************************************
17 */
18 
19 #define ENABLE_AV
20 
21 #include "videodevicepool.h"
22 
23 #include <assert.h>
24 #include <cstdlib>
25 #include <cerrno>
26 #include <cstring>
27 
28 #include <kdebug.h>
29 #include <klocale.h>
30 #include <kglobal.h>
31 #include <kconfig.h>
32 #include <kconfiggroup.h>
33 #include <qapplication.h>
34 #include <qdir.h>
35 #include <solid/device.h>
36 #include <solid/devicenotifier.h>
37 #include <solid/deviceinterface.h>
38 #include <solid/video.h>
39 
40 
41 #include "videodevice.h"
42 
43 #define CLEAR(x) memset (&(x), 0, sizeof (x))
44 
45 namespace Kopete {
46 
47 namespace AV {
48 
49 VideoDevicePool *VideoDevicePool::s_self = NULL;
50 __u64 VideoDevicePool::m_clients = 0;
51 
57 VideoDevicePool* VideoDevicePool::self()
58 {
59  kDebug() << "called";
60  if (s_self == NULL)
61  {
62  kDebug() << "Generated new instance.";
63  s_self = new VideoDevicePool;
64  if (s_self)
65  m_clients = 0;
66  }
67  return s_self;
68 }
69 
74 VideoDevicePool::VideoDevicePool()
75 : QObject(qApp), m_current_device(-1)
76 {
77  connect( Solid::DeviceNotifier::instance(), SIGNAL(deviceAdded(QString)), SLOT(deviceAdded(QString)) );
78  connect( Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(QString)), SLOT(deviceRemoved(QString)) );
79  /* NOTE: No locking needed as long as we don't connect with Qt::ConnectionType = Qt::DirectConnection
80  while the signals are emitted by other threads
81  */
82  foreach( Solid::Device device, Solid::Device::listFromType(Solid::DeviceInterface::Video, QString()) )
83  registerDevice( device );
84 }
85 
90 VideoDevicePool::~VideoDevicePool()
91 {
92  s_self = 0L;
93  foreach ( VideoDevice* vd, m_videodevices )
94  delete vd;
95 }
96 
97 
98 
104 bool VideoDevicePool::isOpen()
105 {
106  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
107  return m_videodevices[m_current_device]->isOpen();
108  else
109  return false;
110 }
111 
120 int VideoDevicePool::open( int device )
121 {
122  kDebug() << "called with device" << device;
123  if (!m_videodevices.size() || (device >= m_videodevices.size()))
124  {
125  kDebug() << "Device not found.";
126  return EXIT_FAILURE;
127  }
128  if (device < 0)
129  {
130  kDebug() << "Trying to load saved device.";
131  device = getSavedDevice();
132  if (device < 0)
133  {
134  if (m_current_device < 0)
135  device = 0;
136  else
137  device = m_current_device;
138  kDebug() << "Saved device is not available, using default device:" << device;
139  }
140  }
141  int isopen = EXIT_FAILURE;
142  if ((device != m_current_device) || !isOpen())
143  {
144  if (isOpen())
145  {
146  if (EXIT_SUCCESS == m_videodevices[m_current_device]->close())
147  m_clients--;
148  else
149  return EXIT_FAILURE;
150  }
151  isopen = m_videodevices[device]->open();
152  if (isopen == EXIT_SUCCESS)
153  {
154  m_current_device = device;
155  loadDeviceConfig(); // Load and apply device parameters
156  m_clients++;
157  }
158  }
159  else
160  {
161  isopen = EXIT_SUCCESS;
162  m_clients++;
163  }
164  kDebug() << "Number of clients: " << m_clients;
165  return isopen;
166 }
167 
173 int VideoDevicePool::close()
174 {
175  int ret = EXIT_FAILURE;
176  if ((m_current_device < 0) || (m_current_device >= m_videodevices.size()))
177  {
178  kDebug() << "Current device out of range.";
179  }
180  else if (!m_clients)
181  {
182  ret = EXIT_SUCCESS;
183  }
184  else if (m_clients > 1)
185  {
186  m_clients--;
187  kDebug() << "The video device is still in use:" << m_clients << "clients";
188  ret = EXIT_SUCCESS;
189  }
190  else
191  {
192  ret = m_videodevices[m_current_device]->close();
193  if (EXIT_SUCCESS == ret)
194  m_clients--;
195  }
196  return ret;
197 }
198 
199 
200 
206 int VideoDevicePool::size()
207 {
208  return m_videodevices.size();
209 }
210 
216 int VideoDevicePool::currentDevice()
217 {
218  if (m_videodevices.size())
219  return m_current_device;
220  else // to be sure...
221  return -1;
222 }
223 
229 QString VideoDevicePool::currentDeviceUdi()
230 {
231  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
232  return m_videodevices[m_current_device]->udi();
233  else
234  return QString();
235 }
236 
242 int VideoDevicePool::inputs()
243 {
244  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
245  return m_videodevices[m_current_device]->inputs();
246  else
247  return 0;
248 }
249 
255 int VideoDevicePool::currentInput()
256 {
257  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
258  return m_videodevices[m_current_device]->currentInput();
259  else
260  return -1;
261 }
262 
269 int VideoDevicePool::selectInput( int input )
270 {
271  kDebug() << "called with input" << input;
272  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
273  return m_videodevices[m_current_device]->selectInput(input);
274  else
275  return EXIT_FAILURE;
276 }
277 
278 
279 
285 QList<NumericVideoControl> VideoDevicePool::getSupportedNumericControls()
286 {
287  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
288  return m_videodevices[m_current_device]->getSupportedNumericControls();
289  else
290  return QList<NumericVideoControl>();
291 }
292 
298 QList<BooleanVideoControl> VideoDevicePool::getSupportedBooleanControls()
299 {
300  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
301  return m_videodevices[m_current_device]->getSupportedBooleanControls();
302  else
303  return QList<BooleanVideoControl>();
304 }
305 
311 QList<MenuVideoControl> VideoDevicePool::getSupportedMenuControls()
312 {
313  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
314  return m_videodevices[m_current_device]->getSupportedMenuControls();
315  else
316  return QList<MenuVideoControl>();
317 }
318 
324 QList<ActionVideoControl> VideoDevicePool::getSupportedActionControls()
325 {
326  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
327  return m_videodevices[m_current_device]->getSupportedActionControls();
328  else
329  return QList<ActionVideoControl>();
330 }
331 
341 int VideoDevicePool::getControlValue( quint32 ctrl_id, qint32 * value )
342 {
343  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
344  return m_videodevices[m_current_device]->getControlValue(ctrl_id, value);
345  else
346  return EXIT_FAILURE;
347 }
348 
359 int VideoDevicePool::setControlValue( quint32 ctrl_id, qint32 value )
360 {
361  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
362  return m_videodevices[m_current_device]->setControlValue(ctrl_id, value);
363  else
364  return EXIT_FAILURE;
365 }
366 
367 
368 
374 int VideoDevicePool::startCapturing()
375 {
376  kDebug() << "startCapturing() called.";
377  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
378  return m_videodevices[m_current_device]->startCapturing();
379  else
380  return EXIT_FAILURE;
381 }
382 
383 
389 int VideoDevicePool::stopCapturing()
390 {
391  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
392  return m_videodevices[m_current_device]->stopCapturing();
393  else
394  return EXIT_FAILURE;
395 }
396 
400 int VideoDevicePool::getFrame()
401 {
402 // kDebug() << "VideoDevicePool::getFrame() called.";
403  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
404  return m_videodevices[m_current_device]->getFrame();
405  else
406  return EXIT_FAILURE;
407 }
408 
412 int VideoDevicePool::getImage( QImage *qimage )
413 {
414 // kDebug() << "VideoDevicePool::getImage() called.";
415  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
416  return m_videodevices[m_current_device]->getImage(qimage);
417  else
418  return EXIT_FAILURE;
419 }
420 
421 
422 
423 int VideoDevicePool::width()
424 {
425  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
426  return m_videodevices[m_current_device]->width();
427  else
428  return 0;
429 }
430 
431 int VideoDevicePool::minWidth()
432 {
433  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
434  return m_videodevices[m_current_device]->minWidth();
435  else
436  return 0;
437 }
438 
439 int VideoDevicePool::maxWidth()
440 {
441  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
442  return m_videodevices[m_current_device]->maxWidth();
443  else
444  return 0;
445 }
446 
447 int VideoDevicePool::height()
448 {
449  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
450  return m_videodevices[m_current_device]->height();
451  else
452  return 0;
453 }
454 
455 int VideoDevicePool::minHeight()
456 {
457  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
458  return m_videodevices[m_current_device]->minHeight();
459  else
460  return 0;
461 }
462 
463 int VideoDevicePool::maxHeight()
464 {
465  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
466  return m_videodevices[m_current_device]->maxHeight();
467  else
468  return 0;
469 }
470 
471 int VideoDevicePool::setImageSize( int newwidth, int newheight )
472 {
473  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
474  return m_videodevices[m_current_device]->setSize(newwidth, newheight);
475  else
476  return EXIT_FAILURE;
477 }
478 
479 
480 
486 void VideoDevicePool::fillDeviceKComboBox( KComboBox *combobox )
487 {
488  kDebug() << "Called.";
489  if (combobox == NULL)
490  return;
491  combobox->clear();
492  if (m_videodevices.size())
493  {
494  for (int loop = 0; loop < m_videodevices.size(); loop++)
495  {
496  combobox->addItem(m_videodevices[loop]->m_name);
497  kDebug() << "Added device" << loop << ": " << m_videodevices[loop]->m_name;
498  }
499  combobox->setCurrentIndex(m_current_device);
500  }
501  combobox->setEnabled(m_videodevices.size());
502 }
503 
509 void VideoDevicePool::fillInputKComboBox( KComboBox *combobox )
510 {
511  kDebug() << "Called.";
512  if (combobox == NULL)
513  return;
514  combobox->clear();
515  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
516  {
517  if (m_videodevices[m_current_device]->inputs() > 0)
518  {
519  for (int loop = 0; loop < m_videodevices[m_current_device]->inputs(); loop++)
520  {
521  combobox->addItem(m_videodevices[m_current_device]->m_input[loop].name);
522  kDebug() << "Added input" << loop << ": " << m_videodevices[m_current_device]->m_input[loop].name
523  << " (tuner: " << m_videodevices[m_current_device]->m_input[loop].hastuner << ")";
524  }
525  combobox->setCurrentIndex(m_videodevices[m_current_device]->currentInput());
526  }
527  }
528  combobox->setEnabled(combobox->count());
529 }
530 
536 void VideoDevicePool::fillStandardKComboBox( KComboBox *combobox )
537 {
538  kDebug() << "Called.";
539  if (combobox == NULL)
540  return;
541  combobox->clear();
542  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
543  {
544  if (m_videodevices[m_current_device]->inputs() > 0)
545  {
546  for (unsigned int loop = 0; loop < 25; loop++)
547  {
548  if (m_videodevices[m_current_device]->m_input[currentInput()].m_standards & (1 << loop))
549  {
550  combobox->addItem(m_videodevices[m_current_device]->signalStandardName(1 << loop));
551  kDebug() << "Added signal standard" << loop << ": " << m_videodevices[m_current_device]->signalStandardName(1 << loop);
552  }
553 
554  }
555  combobox->setCurrentIndex(0); // FIXME: set to actual signal standard
556  }
557  }
558  combobox->setEnabled(combobox->count());
559 }
560 
561 
562 
568 int VideoDevicePool::getSavedDevice()
569 {
570  kDebug() << "called";
571  if (m_videodevices.size())
572  {
573  KConfigGroup config(KGlobal::config(), "Video Device Settings");
574  QString currentdevice = config.readEntry("Current Device", QString());
575  kDebug() << "Device name:" << config.readEntry( QString::fromLocal8Bit( "Device %1 Name" ).arg( currentdevice ), QString("NOT SAVED") );
576  if (!currentdevice.isEmpty())
577  {
578  kDebug() << "Saved device:" << currentdevice;
579  QVector<VideoDevice*>::iterator vditerator;
580  for( vditerator = m_videodevices.begin(); vditerator != m_videodevices.end(); ++vditerator )
581  {
582  if ((*vditerator)->udi() == currentdevice)
583  {
584  int devIndex = std::distance (m_videodevices.begin(), vditerator);
585  kDebug() << "Saved device is available, device index is" << devIndex;
586  return devIndex;
587  }
588  }
589  kDebug() << "Saved device is not available.";
590  }
591  else
592  kDebug() << "No device saved.";
593  }
594  return -1;
595 }
596 
603 void VideoDevicePool::loadDeviceConfig()
604 {
605  kDebug() << "called";
606  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
607  {
608  KConfigGroup config(KGlobal::config(), "Video Device Settings");
609  // Load input and apply
610  const QString key_currentinput = QString::fromLocal8Bit( "Device %1 Current Input" ).arg( m_videodevices[m_current_device]->udi() );
611  const int currentinput = config.readEntry(key_currentinput, 0);
612  kDebug() << "Setting input to" << currentinput;
613  if (currentinput != m_videodevices[m_current_device]->currentInput())
614  m_videodevices[m_current_device]->selectInput(currentinput);
615  // Load video-controls and apply
616  quint32 ctrl_id;
617  qint32 ctrl_value;
618  QString ctrl_key;
619  bool ok = false;
620  const QString key_control_start = QString::fromLocal8Bit( "Device %1 Input %2 Control " ).arg( m_videodevices[m_current_device]->udi() ).arg( m_videodevices[m_current_device]->currentInput() );
621  QStringList ctrl_keys = config.keyList().filter(key_control_start);
622  kDebug() << "Found" << ctrl_keys.size() << "saved values for video-controls";
623  foreach (ctrl_key, ctrl_keys)
624  {
625  ctrl_id = QString(ctrl_key).remove(key_control_start).toUInt(&ok);
626  if (ok)
627  {
628  /* NOTE: we do not read the value as int with readEntry() directly
629  because it doesn't tell us if the saved value was valid.
630  If not, we do NOT apply a standard value.
631  */
632  QString tmpstr = config.readEntry(ctrl_key, QString());
633  ctrl_value = tmpstr.toInt(&ok);
634  if (ok && !tmpstr.isEmpty())
635  {
636  kDebug() << "Setting control" << ctrl_id << "to value" << ctrl_value;
637  m_videodevices[m_current_device]->setControlValue(ctrl_id, ctrl_value);
638  }
639  else
640  kDebug() << "Saved value for control" << ctrl_id << "is invalid:" << tmpstr;
641  }
642  else
643  kDebug() << "Invalid key:" << ctrl_key;
644  }
645  }
646  /* TODO: load and apply signal standard */
647 }
648 
655 void VideoDevicePool::saveCurrentDeviceConfig()
656 {
657  kDebug() << "called";
658  if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
659  {
660  KConfigGroup config(KGlobal::config(), "Video Device Settings");
661  // Save current device:
662  kDebug() << "Current device:" << m_videodevices[m_current_device]->udi();
663  config.writeEntry( "Current Device", m_videodevices[m_current_device]->udi() );
664  // Save current device name (for debugging only):
665  kDebug() << "Current device name:" << m_videodevices[m_current_device]->m_name;
666  const QString name = QString::fromLocal8Bit( "Device %1 Name" ).arg( m_videodevices[m_current_device]->udi() );
667  config.writeEntry( name, m_videodevices[m_current_device]->m_name );
668  // Open device if closed:
669  bool wasClosed = false;
670  if (!m_videodevices[m_current_device]->isOpen())
671  {
672  kDebug() << "Device is currently closed, will be opened.";
673  wasClosed = true;
674  if (EXIT_SUCCESS != m_videodevices[m_current_device]->open())
675  {
676  kDebug() << "Failed to open the device. Saving aborted.";
677  config.sync();
678  return;
679  }
680  }
681  // Save current input:
682  kDebug() << "Current input:" << m_videodevices[m_current_device]->currentInput();
683  const QString key_currentinput = QString::fromLocal8Bit( "Device %1 Current Input" ).arg( m_videodevices[m_current_device]->udi() );
684  config.writeEntry( key_currentinput, m_videodevices[m_current_device]->currentInput() );
685  // --- Save values of the controls ---:
686  qint32 ctrl_value;
687  const QString key_control_start = QString::fromLocal8Bit( "Device %1 Input %2 Control " ).arg( m_videodevices[m_current_device]->udi() ).arg( m_videodevices[m_current_device]->currentInput() );
688  // Save values of the numeric controls:
689  QList<NumericVideoControl> numCtrls = m_videodevices[m_current_device]->getSupportedNumericControls();
690  NumericVideoControl numCtrl;
691  foreach (numCtrl, numCtrls)
692  {
693  if (EXIT_SUCCESS == m_videodevices[m_current_device]->getControlValue(numCtrl.id, &ctrl_value))
694  {
695  kDebug() << "Numeric control:" << numCtrl.id << "value" << ctrl_value;
696  config.writeEntry( key_control_start + QString::number(numCtrl.id), ctrl_value );
697  }
698  else
699  kDebug() << "Error: couldn't get current value for numeric control" << numCtrl.id;
700  }
701  // Save values of the boolean controls:
702  QList<BooleanVideoControl> boolCtrls = m_videodevices[m_current_device]->getSupportedBooleanControls();
703  BooleanVideoControl boolCtrl;
704  foreach (boolCtrl, boolCtrls)
705  {
706  if (EXIT_SUCCESS == m_videodevices[m_current_device]->getControlValue(boolCtrl.id, &ctrl_value))
707  {
708  kDebug() << "Boolean control:" << boolCtrl.id << "value" << ctrl_value;
709  config.writeEntry( key_control_start + QString::number(boolCtrl.id), ctrl_value );
710  }
711  else
712  kDebug() << "Error: couldn't get current value for boolean control" << numCtrl.id;
713  }
714  // Save values of the menu controls:
715  QList<MenuVideoControl> menuCtrls = m_videodevices[m_current_device]->getSupportedMenuControls();
716  MenuVideoControl menuCtrl;
717  foreach (menuCtrl, menuCtrls)
718  {
719  if (EXIT_SUCCESS == m_videodevices[m_current_device]->getControlValue(menuCtrl.id, &ctrl_value))
720  {
721  kDebug() << "Menu-control:" << menuCtrl.id << "value" << ctrl_value;
722  config.writeEntry( key_control_start + QString::number(menuCtrl.id), ctrl_value );
723  }
724  else
725  kDebug() << "Error: couldn't get current value for menu-control" << numCtrl.id;
726  }
727  // NOTE: Action-video-controls don't have values, so there is nothing to save.
728  // Close device again (if it was closed before):
729  if (wasClosed)
730  {
731  if (EXIT_SUCCESS == m_videodevices[m_current_device]->close())
732  kDebug() << "Device successfully closed.";
733  else
734  kDebug() << "Error: failed to close the device.";
735  }
736  config.sync();
737  }
738  /* TODO: save signal standard */
739 }
740 
744 int VideoDevicePool::showDeviceCapabilities(int device)
745 {
746  if (device < 0)
747  device = m_current_device;
748  if ((device >= 0) && (device < m_videodevices.size()))
749  return m_videodevices[device]->showDeviceCapabilities();
750  else
751  return EXIT_FAILURE;
752 }
753 
754 
755 
761 void VideoDevicePool::deviceAdded( const QString & udi )
762 {
763  kDebug() << "called with UDI" << udi;
764  Solid::Device dev( udi );
765  if ( dev.is<Solid::Video>() )
766  {
767  kDebug() << "Device is a video device, trying to register it.";
768  if ( registerDevice( dev ) )
769  emit deviceRegistered( udi );
770  }
771  else
772  kDebug() << "Device is not a video device";
773 }
774 
780 void VideoDevicePool::deviceRemoved( const QString & udi )
781 {
782  kDebug() << "called with UDI" << udi;
783  int i = 0;
784  foreach ( VideoDevice* vd, m_videodevices )
785  {
786  if ( vd->udi() == udi )
787  {
788  kDebug() << "Video device with UDI" << udi << "has been removed!";
789  delete m_videodevices[i]; // NOTE: device is closed in destructor
790  m_videodevices.remove( i );
791  if (m_current_device == i)
792  {
793  if (m_videodevices.size())
794  m_current_device = 0;
795  else
796  m_current_device = -1;
797  m_clients = 0;
798  }
799  else if (m_current_device > i)
800  {
801  m_current_device--;
802  }
803  emit deviceUnregistered( udi );
804  return;
805  }
806  else
807  i++;
808  }
809 }
810 
817 bool VideoDevicePool::registerDevice( Solid::Device & device )
818 {
819  kDebug() << "called, UDI is:\n " << device.udi();
820  const Solid::Device * vendorDevice = &device;
821  while (vendorDevice->isValid() && vendorDevice->vendor().isEmpty())
822  vendorDevice = new Solid::Device(vendorDevice->parentUdi());
823  /* NOTE: The device we register has usually an empty vendor string and a less meaningfull product string.
824  So we go up to the first parent device that has a non-empty vendor string,
825  because we find the expected strings describing the device there.
826  */
827  if (vendorDevice->isValid())
828  kDebug() << "vendor:" << vendorDevice->vendor() << ", product:" << vendorDevice->product();
829  else
830  kDebug() << "vendor:" << device.vendor() << ", product:" << device.product();
831 
832  if (device.isValid())
833  {
834  Solid::Video * solidVideoDevice = device.as<Solid::Video>();
835  if (solidVideoDevice)
836  {
837  QStringList protocols = solidVideoDevice->supportedProtocols();
838  if (protocols.contains("video4linux"))
839  {
840  QStringList drivers = solidVideoDevice->supportedDrivers("video4linux");
841  if (drivers.contains("video4linux"))
842  {
843  VideoDevice* videodevice = new VideoDevice;
844  videodevice->setUdi( device.udi() );
845  videodevice->setFileName(solidVideoDevice->driverHandle("video4linux").toString());
846  kDebug() << "V4L device path is" << solidVideoDevice->driverHandle("video4linux").toString();
847  if (EXIT_SUCCESS == videodevice->open())
848  {
849  bool cap = videodevice->canCapture();
850  videodevice->close();
851  if (cap)
852  {
853  if (m_videodevices.size() == 0)
854  m_current_device = 0;
855  m_videodevices.push_back(videodevice);
856  kDebug() << "Device is a valid video device, adding it to video device pool.";
857  return true;
858  }
859  else
860  kDebug() << "Device does not support capturing.";
861  }
862  else
863  kDebug() << "Device could not be opened.";
864  delete videodevice;
865  }
866  }
867  }
868  else
869  kDebug() << "Device is not a video device.";
870  }
871  else
872  kDebug() << "Not a valid Solid device: device is not available in the system.";
873  return false;
874 }
875 
876 } // namespace AV
877 
878 } // namespace Kopete
Kopete::AV::VideoDevicePool::fillInputKComboBox
void fillInputKComboBox(KComboBox *combobox)
Fills a combobox with the names of all available inputs for the currently selected device...
Definition: videodevicepool.cpp:509
Kopete::AV::VideoDevicePool::startCapturing
int startCapturing()
Starts capturing from the currently selected video device.
Definition: videodevicepool.cpp:374
Kopete::AV::VideoDevicePool::getSavedDevice
int getSavedDevice()
Returns the index of the saved device.
Definition: videodevicepool.cpp:568
Kopete::AV::VideoDevicePool::setImageSize
int setImageSize(int newwidth, int newheight)
Definition: videodevicepool.cpp:471
Kopete::AV::VideoDevicePool::registerDevice
bool registerDevice(Solid::Device &dev)
Checks if the given device is a valid video device and adds it do the device list.
Definition: videodevicepool.cpp:817
Kopete::AV::VideoDevicePool::showDeviceCapabilities
int showDeviceCapabilities(int device=-1)
Definition: videodevicepool.cpp:744
Kopete::AV::VideoDevicePool::currentDeviceUdi
QString currentDeviceUdi()
Returns the unique device identifier (UDI) of the currently selected device.
Definition: videodevicepool.cpp:229
Kopete::AV::VideoDevicePool::getSupportedNumericControls
QList< NumericVideoControl > getSupportedNumericControls()
Returns the supported numeric controls for the current input.
Definition: videodevicepool.cpp:285
Kopete::AV::VideoDevicePool::maxHeight
int maxHeight()
Definition: videodevicepool.cpp:463
Kopete::AV::NumericVideoControl
Definition: videodevice.h:255
Kopete::AV::VideoDevicePool::~VideoDevicePool
~VideoDevicePool()
Destructor of class VideoDevicePool.
Definition: videodevicepool.cpp:90
Kopete::AV::VideoDevice::setFileName
int setFileName(QString filename)
Definition: videodevice.cpp:304
Kopete::AV::VideoDevicePool::getImage
int getImage(QImage *qimage)
Definition: videodevicepool.cpp:412
Kopete::AV::VideoDevicePool::deviceRegistered
void deviceRegistered(const QString &udi)
Provisional signatures, probably more useful to indicate which device was registered.
QStringList::contains
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QString::remove
QString & remove(int position, int n)
Kopete::AV::VideoDevicePool::getFrame
int getFrame()
Definition: videodevicepool.cpp:400
Kopete::AV::VideoDevicePool::minWidth
int minWidth()
Definition: videodevicepool.cpp:431
Kopete::AV::VideoDevicePool::getSupportedMenuControls
QList< MenuVideoControl > getSupportedMenuControls()
Returns the supported menu-controls for the current input.
Definition: videodevicepool.cpp:311
Kopete::AV::VideoDevice::setUdi
void setUdi(const QString &)
Definition: videodevice.cpp:3021
Kopete::AV::VideoDevicePool::loadDeviceConfig
void loadDeviceConfig()
Loads and applies the configuration for the currently selected device.
Definition: videodevicepool.cpp:603
QList::size
int size() const
Kopete::AV::VideoDevice
Definition: videodevice.h:276
Kopete::AV::VideoDevicePool::inputs
int inputs()
Returns the number of available inputs of the currently selected device.
Definition: videodevicepool.cpp:242
Kopete::AV::VideoDevicePool::height
int height()
Definition: videodevicepool.cpp:447
QObject::name
const char * name() const
QString::number
QString number(int n, int base)
QString::fromLocal8Bit
QString fromLocal8Bit(const char *str, int size)
Kopete::AV::VideoDevicePool::getSupportedBooleanControls
QList< BooleanVideoControl > getSupportedBooleanControls()
Returns the supported boolean controls for the current input.
Definition: videodevicepool.cpp:298
videodevice.h
QObject
QString::toInt
int toInt(bool *ok, int base) const
QString::isEmpty
bool isEmpty() const
Kopete::AV::VideoDevice::canCapture
bool canCapture()
Definition: videodevice.cpp:2986
Kopete::AV::VideoDevicePool::close
int close()
Closes the device.
Definition: videodevicepool.cpp:173
QString
QList
Kopete::AV::MenuVideoControl
Definition: videodevice.h:267
QStringList
Kopete::AV::VideoDevicePool::deviceAdded
void deviceAdded(const QString &udi)
Slot called when a new device is added to the system.
Definition: videodevicepool.cpp:761
Kopete::AV::VideoDevicePool::selectInput
int selectInput(int newinput)
Selects the input of the current video device.
Definition: videodevicepool.cpp:269
Kopete::AV::VideoDevicePool::saveCurrentDeviceConfig
void saveCurrentDeviceConfig()
Saves the current device configuration.
Definition: videodevicepool.cpp:655
Kopete::AV::VideoDevicePool::minHeight
int minHeight()
Definition: videodevicepool.cpp:455
Kopete::AV::VideoDevicePool::currentDevice
int currentDevice()
Returns the index of the current device.
Definition: videodevicepool.cpp:216
QImage
Kopete::AV::BooleanVideoControl
Definition: videodevice.h:245
Kopete::AV::VideoDevicePool::deviceRemoved
void deviceRemoved(const QString &udi)
Removes the device with the specified UDI from the device pool.
Definition: videodevicepool.cpp:780
Kopete::AV::VideoDevicePool::self
static VideoDevicePool * self()
Returns pointer to a common instance of the VideoDevicePool.
Definition: videodevicepool.cpp:57
Kopete::AV::VideoDevicePool::size
int size()
Returns the number of available video devices.
Definition: videodevicepool.cpp:206
Kopete::AV::VideoDevicePool::m_current_device
int m_current_device
Definition: videodevicepool.h:92
Kopete::AV::VideoDevicePool
This class allows kopete to check for the existence, open, configure, test, set parameters, grab frames from and close a given video capture card using the Video4Linux API.
Definition: videodevicepool.h:46
QVector
Kopete::AV::VideoDevicePool::stopCapturing
int stopCapturing()
Starts capturing from the currently selected video device.
Definition: videodevicepool.cpp:389
Kopete::AV::VideoDevicePool::open
int open(int device=-1)
Opens the video device with the specified index. The previously opened device is closed before...
Definition: videodevicepool.cpp:120
Kopete::AV::VideoDevicePool::width
int width()
Definition: videodevicepool.cpp:423
videodevicepool.h
Kopete::AV::VideoDevicePool::m_videodevices
QVector< VideoDevice * > m_videodevices
Definition: videodevicepool.h:93
Kopete::AV::VideoDevicePool::getControlValue
int getControlValue(quint32 ctrl_id, qint32 *value)
Reads the value of a video-control.
Definition: videodevicepool.cpp:341
__u64
#define __u64
Definition: videoinput.h:28
Kopete::AV::VideoDevicePool::fillStandardKComboBox
void fillStandardKComboBox(KComboBox *combobox)
Fills a combobox with the names of the available signal standards for the currently selected device...
Definition: videodevicepool.cpp:536
Kopete::AV::VideoDevicePool::isOpen
bool isOpen()
Returns true if the currently selected device is open and false othwerise.
Definition: videodevicepool.cpp:104
Kopete::AV::VideoDevice::open
virtual int open()
Definition: videodevice.cpp:322
Kopete::AV::VideoDevicePool::setControlValue
int setControlValue(quint32 ctrl_id, qint32 value)
Sets the value of a video-control.
Definition: videodevicepool.cpp:359
Kopete::AV::VideoDevicePool::deviceUnregistered
void deviceUnregistered(const QString &udi)
QStringList::filter
QStringList filter(const QString &str, Qt::CaseSensitivity cs) const
Kopete::AV::ActionVideoControl::id
quint32 id
Definition: videodevice.h:237
Kopete::AV::VideoDevicePool::fillDeviceKComboBox
void fillDeviceKComboBox(KComboBox *combobox)
Fills a combobox with the names of all available video devices.
Definition: videodevicepool.cpp:486
Kopete::AV::VideoDevice::close
virtual int close()
Closes the device.
Definition: videodevice.cpp:1658
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Kopete::AV::VideoDevicePool::maxWidth
int maxWidth()
Definition: videodevicepool.cpp:439
Kopete::AV::VideoDevicePool::getSupportedActionControls
QList< ActionVideoControl > getSupportedActionControls()
Returns the supported action-controls for the current input.
Definition: videodevicepool.cpp:324
QString::toUInt
uint toUInt(bool *ok, int base) const
Kopete::AV::VideoDevice::udi
QString udi() const
Definition: videodevice.cpp:3026
Kopete::AV::VideoDevicePool::currentInput
int currentInput()
Returns the index of the currently selected input.
Definition: videodevicepool.cpp:255
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal