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