130
135
qDebug() << "Number of clients: " << m_clients;
135
139
bool VideoDevicePool::isOpen()
137
return m_videodevice[currentDevice()].isOpen();
141
if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
142
return m_videodevices[m_current_device]->isOpen();
141
148
\fn VideoDevicePool::showDeviceCapabilities(int device)
143
int VideoDevicePool::showDeviceCapabilities(unsigned int device)
150
int VideoDevicePool::showDeviceCapabilities(int device)
145
return m_videodevice[device].showDeviceCapabilities();
153
device = m_current_device;
154
if ((device >= 0) && (device < m_videodevices.size()))
155
return m_videodevices[device]->showDeviceCapabilities();
148
160
int VideoDevicePool::width()
150
return m_videodevice[currentDevice()].width();
162
if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
163
return m_videodevices[m_current_device]->width();
153
168
int VideoDevicePool::minWidth()
155
return m_videodevice[currentDevice()].minWidth();
170
if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
171
return m_videodevices[m_current_device]->minWidth();
158
176
int VideoDevicePool::maxWidth()
160
return m_videodevice[currentDevice()].maxWidth();
178
if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
179
return m_videodevices[m_current_device]->maxWidth();
163
184
int VideoDevicePool::height()
165
return m_videodevice[currentDevice()].height();
186
if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
187
return m_videodevices[m_current_device]->height();
168
192
int VideoDevicePool::minHeight()
170
return m_videodevice[currentDevice()].minHeight();
194
if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
195
return m_videodevices[m_current_device]->minHeight();
173
200
int VideoDevicePool::maxHeight()
175
return m_videodevice[currentDevice()].maxHeight();
202
if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
203
return m_videodevices[m_current_device]->maxHeight();
178
208
int VideoDevicePool::setSize( int newwidth, int newheight)
180
if(m_videodevice.size())
181
return m_videodevice[currentDevice()].setSize(newwidth, newheight);
210
if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
211
return m_videodevices[m_current_device]->setSize(newwidth, newheight);
184
214
qDebug() << "VideoDevicePool::setSize() fallback for no device.";
364
385
int VideoDevicePool::getImage(QImage *qimage)
366
387
// qDebug() << "VideoDevicePool::getImage() called.";
367
if(m_videodevice.size())
368
return m_videodevice[currentDevice()].getImage(qimage);
388
if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
389
return m_videodevices[m_current_device]->getImage(qimage);
371
qDebug() << "VideoDevicePool::getImage() fallback for no device.";
373
// do NOT delete qimage here, as it is received as a parameter
374
if (qimage->width() != width() || qimage->height() != height())
375
*qimage = QImage(width(), height(), QImage::Format_RGB32);
377
uchar *bits=qimage->bits();
378
switch(m_buffer.pixelformat)
380
case PIXELFORMAT_NONE : break;
381
case PIXELFORMAT_GREY : break;
382
case PIXELFORMAT_RGB332 : break;
383
case PIXELFORMAT_RGB555 : break;
384
case PIXELFORMAT_RGB555X: break;
385
case PIXELFORMAT_RGB565 : break;
386
case PIXELFORMAT_RGB565X: break;
387
case PIXELFORMAT_RGB24 :
389
qDebug() << "VideoDevicePool::getImage() fallback for no device - RGB24.";
391
for(int loop=0;loop < qimage->numBytes();loop+=4)
393
bits[loop] = m_buffer.data[step];
394
bits[loop+1] = m_buffer.data[step+1];
395
bits[loop+2] = m_buffer.data[step+2];
401
case PIXELFORMAT_BGR24 : break;
404
for(int loop=0;loop < qimage->numBytes();loop+=4)
406
bits[loop] = m_buffer.data[step+2];
407
bits[loop+1] = m_buffer.data[step+1];
408
bits[loop+2] = m_buffer.data[step];
414
case PIXELFORMAT_RGB32 : memcpy(bits,&m_buffer.data[0], m_buffer.data.size());
416
case PIXELFORMAT_BGR32 : break;
417
case PIXELFORMAT_YUYV : break;
418
case PIXELFORMAT_UYVY : break;
419
case PIXELFORMAT_YUV420P: break;
420
case PIXELFORMAT_YUV422P: break;
424
qDebug() << "VideoDevicePool::getImage() exited successfuly.";
431
397
int VideoDevicePool::selectInput(int newinput)
433
399
qDebug() << "VideoDevicePool::selectInput(" << newinput << ") called.";
434
if(m_videodevice.size())
435
return m_videodevice[currentDevice()].selectInput(newinput);
400
if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
401
return m_videodevices[m_current_device]->selectInput(newinput);
441
407
\fn Kopete::AV::VideoDevicePool::fillDeviceQComboBox(QComboBox *combobox)
443
int VideoDevicePool::fillDeviceQComboBox(QComboBox *combobox)
409
void VideoDevicePool::fillDeviceQComboBox(QComboBox *combobox)
445
/// @todo implement me
446
411
qDebug() << "Called.";
447
// check if QComboBox is a valid pointer.
448
if (combobox != NULL)
412
if (combobox == NULL)
415
if (m_videodevices.size())
451
qDebug() << "Combobox cleaned.";
452
if(m_videodevice.size())
417
for (int loop = 0; loop < m_videodevices.size(); loop++)
454
for (int loop=0; loop < m_videodevice.size(); loop++)
456
combobox->addItem(m_videodevice[loop].m_name);
457
qDebug() << "Added device " << loop << ": " << m_videodevice[loop].m_name;
459
combobox->setCurrentIndex(currentDevice());
460
combobox->setEnabled(true);
419
combobox->addItem(m_videodevices[loop]->m_name);
420
qDebug() << "Added device" << loop << ": " << m_videodevices[loop]->m_name;
463
combobox->setEnabled(false);
422
combobox->setCurrentIndex(m_current_device);
424
combobox->setEnabled(m_videodevices.size());
469
428
\fn Kopete::AV::VideoDevicePool::fillInputQComboBox(QComboBox *combobox)
471
int VideoDevicePool::fillInputQComboBox(QComboBox *combobox)
430
void VideoDevicePool::fillInputQComboBox(QComboBox *combobox)
473
/// @todo implement me
474
432
qDebug() << "Called.";
475
if (combobox != NULL)
433
if (combobox == NULL)
436
if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
478
if ( !m_videodevice.isEmpty() && (currentDevice()>=0) && currentDevice() < m_videodevice.size() )
438
if (m_videodevices[m_current_device]->inputs() > 0)
480
if(m_videodevice[currentDevice()].inputs()>0)
440
for (int loop = 0; loop < m_videodevices[m_current_device]->inputs(); loop++)
482
for (int loop=0; loop < m_videodevice[currentDevice()].inputs(); loop++)
484
combobox->addItem(m_videodevice[currentDevice()].m_input[loop].name);
485
qDebug() << "Added input " << loop << ": " << m_videodevice[currentDevice()].m_input[loop].name << " (tuner: " << m_videodevice[currentDevice()].m_input[loop].hastuner << ")";
487
combobox->setCurrentIndex(currentInput());
488
combobox->setEnabled(true);
442
combobox->addItem(m_videodevices[m_current_device]->m_input[loop].name);
443
qDebug() << "Added input" << loop << ": " << m_videodevices[m_current_device]->m_input[loop].name
444
<< " (tuner: " << m_videodevices[m_current_device]->m_input[loop].hastuner << ")";
446
combobox->setCurrentIndex(m_videodevices[m_current_device]->currentInput());
492
combobox->setEnabled(false);
449
combobox->setEnabled(combobox->count());
498
453
\fn Kopete::AV::VideoDevicePool::fillStandardQComboBox(QComboBox *combobox)
500
int VideoDevicePool::fillStandardQComboBox(QComboBox *combobox)
455
void VideoDevicePool::fillStandardQComboBox(QComboBox *combobox)
502
/// @todo implement me
503
457
qDebug() << "Called.";
504
if (combobox != NULL)
458
if (combobox == NULL)
461
if ((m_current_device >= 0) && (m_current_device < m_videodevices.size()))
507
if ( !m_videodevice.isEmpty() && currentDevice() < m_videodevice.size() )
463
if (m_videodevices[m_current_device]->inputs() > 0)
509
if(m_videodevice[currentDevice()].inputs()>0)
465
for (unsigned int loop = 0; loop < 25; loop++)
511
for (unsigned int loop=0; loop < 25; loop++)
467
if (m_videodevices[m_current_device]->m_input[currentInput()].m_standards & (1 << loop))
513
if ( (m_videodevice[currentDevice()].m_input[currentInput()].m_standards) & (1 << loop) )
514
combobox->addItem(m_videodevice[currentDevice()].signalStandardName( 1 << loop));
516
case STANDARD_PAL_B1 : return V4L2_STD_PAL_B1; break;
517
case STANDARD_PAL_G : return V4L2_STD_PAL_G; break;
518
case STANDARD_PAL_H : return V4L2_STD_PAL_H; break;
519
case STANDARD_PAL_I : return V4L2_STD_PAL_I; break;
520
case STANDARD_PAL_D : return V4L2_STD_PAL_D; break;
521
case STANDARD_PAL_D1 : return V4L2_STD_PAL_D1; break;
522
case STANDARD_PAL_K : return V4L2_STD_PAL_K; break;
523
case STANDARD_PAL_M : return V4L2_STD_PAL_M; break;
524
case STANDARD_PAL_N : return V4L2_STD_PAL_N; break;
525
case STANDARD_PAL_Nc : return V4L2_STD_PAL_Nc; break;
526
case STANDARD_PAL_60 : return V4L2_STD_PAL_60; break;
527
case STANDARD_NTSC_M : return V4L2_STD_NTSC_M; break;
528
case STANDARD_NTSC_M_JP : return V4L2_STD_NTSC_M_JP; break;
529
case STANDARD_NTSC_443 : return V4L2_STD_NTSC; break; // Using workaround value because my videodev2.h header seems to not include this standard in struct __u64 v4l2_std_id
530
case STANDARD_SECAM_B : return V4L2_STD_SECAM_B; break;
531
case STANDARD_SECAM_D : return V4L2_STD_SECAM_D; break;
532
case STANDARD_SECAM_G : return V4L2_STD_SECAM_G; break;
533
case STANDARD_SECAM_H : return V4L2_STD_SECAM_H; break;
534
case STANDARD_SECAM_K : return V4L2_STD_SECAM_K; break;
535
case STANDARD_SECAM_K1 : return V4L2_STD_SECAM_K1; break;
536
case STANDARD_SECAM_L : return V4L2_STD_SECAM_L; break;
537
case STANDARD_SECAM_LC : return V4L2_STD_SECAM; break; // Using workaround value because my videodev2.h header seems to not include this standard in struct __u64 v4l2_std_id
538
case STANDARD_ATSC_8_VSB : return V4L2_STD_ATSC_8_VSB; break; // ATSC/HDTV Standard officially not supported by V4L2 but exists in videodev2.h
539
case STANDARD_ATSC_16_VSB : return V4L2_STD_ATSC_16_VSB; break; // ATSC/HDTV Standard officially not supported by V4L2 but exists in videodev2.h
540
case STANDARD_PAL_BG : return V4L2_STD_PAL_BG; break;
541
case STANDARD_PAL_DK : return V4L2_STD_PAL_DK; break;
542
case STANDARD_PAL : return V4L2_STD_PAL; break;
543
case STANDARD_NTSC : return V4L2_STD_NTSC; break;
544
case STANDARD_SECAM_DK : return V4L2_STD_SECAM_DK; break;
545
case STANDARD_SECAM : return V4L2_STD_SECAM; break;
546
case STANDARD_525_60 : return V4L2_STD_525_60; break;
547
case STANDARD_625_50 : return V4L2_STD_625_50; break;
548
case STANDARD_ALL : return V4L2_STD_ALL; break;
550
combobox->insertItem(m_videodevice[currentDevice()].m_input[loop].name);
551
qDebug() << "StandardQComboBox: Added input " << loop << ": " << m_videodevice[currentDevice()].m_input[loop].name << " (tuner: " << m_videodevice[currentDevice()].m_input[loop].hastuner << ")";*/
469
combobox->addItem(m_videodevices[m_current_device]->signalStandardName(1 << loop));
470
qDebug() << "Added signal standard" << loop << ": " << m_videodevices[m_current_device]->signalStandardName(1 << loop);
553
combobox->setCurrentIndex(0); // FIXME: set to actual signal standard
554
combobox->setEnabled(combobox->count());
558
combobox->setEnabled(false);
564
\fn Kopete::AV::VideoDevicePool::scanDevices()
566
int VideoDevicePool::scanDevices()
568
/// @todo implement me
570
if (m_videodevice.isEmpty()) {
571
qDebug() << "called";
572
#ifndef COMPILE_DISABLE_AVDEVICE
573
foreach (Solid::Device device,
574
Solid::Device::listFromType(Solid::DeviceInterface::Video, QString())) {
575
registerDevice( device );
579
qDebug() << "exited successfuly";
581
qDebug() << "Not scanning: initial device list already loaded";
586
void VideoDevicePool::registerDevice( Solid::Device & device )
588
qDebug() << "New video device at " << device.udi();
474
combobox->setCurrentIndex(0); // FIXME: set to actual signal standard
477
combobox->setEnabled(combobox->count());
479
#ifdef COMPILE_KDE_SUPPORT
480
bool VideoDevicePool::registerDevice( Solid::Device & device )
482
qDebug() << "called, UDI is:\n " << device.udi();
589
483
const Solid::Device * vendorDevice = &device;
590
while ( vendorDevice->isValid() && vendorDevice->vendor().isEmpty() )
592
vendorDevice = new Solid::Device( vendorDevice->parentUdi() );
594
if ( vendorDevice->isValid() )
596
qDebug() << "vendor: " << vendorDevice->vendor() << ", product: " << vendorDevice->product();
598
Solid::Video * solidVideoDevice = device.as<Solid::Video>();
599
if ( solidVideoDevice ) {
600
QStringList protocols = solidVideoDevice->supportedProtocols();
601
if ( protocols.contains( "video4linux" ) )
484
while (vendorDevice->isValid() && vendorDevice->vendor().isEmpty())
485
vendorDevice = new Solid::Device(vendorDevice->parentUdi());
486
/* NOTE: The device we register has usually an empty vendor string and a less meaningfull product string.
487
So we go up to the first parent device that has a non-empty vendor string,
488
because we find the expected strings describing the device there.
490
if (vendorDevice->isValid())
491
qDebug() << "vendor:" << vendorDevice->vendor() << ", product:" << vendorDevice->product();
493
qDebug() << "vendor:" << device.vendor() << ", product:" << device.product();
495
if (device.isValid())
497
Solid::Video * solidVideoDevice = device.as<Solid::Video>();
498
if (solidVideoDevice)
603
QStringList drivers = solidVideoDevice->supportedDrivers( "video4linux" );
604
if ( drivers.contains( "video4linux" ) )
500
QStringList protocols = solidVideoDevice->supportedProtocols();
501
if (protocols.contains("video4linux"))
606
qDebug() << "V4L device path is" << solidVideoDevice->driverHandle( "video4linux" ).toString();
607
VideoDevice videodevice;
608
videodevice.setUdi( device.udi() );
609
videodevice.setFileName(solidVideoDevice->driverHandle( "video4linux" ).toString());
610
qDebug() << "Found device " << videodevice.fileName();
612
if(videodevice.isOpen())
503
QStringList drivers = solidVideoDevice->supportedDrivers("video4linux");
504
if (drivers.contains("video4linux"))
614
qDebug() << "File " << videodevice.fileName() << " was opened successfuly";
616
m_videodevice.push_back(videodevice);
506
VideoDevice* videodevice = new VideoDevice;
507
videodevice->setUdi( device.udi() );
508
videodevice->setFileName(solidVideoDevice->driverHandle("video4linux").toString());
509
qDebug() << "V4L device path is" << solidVideoDevice->driverHandle("video4linux").toString();
510
if (EXIT_SUCCESS == videodevice->open())
512
bool cap = videodevice->canCapture();
513
videodevice->close();
516
if (m_videodevices.size() == 0)
517
m_current_device = 0;
518
m_videodevices.push_back(videodevice);
519
qDebug() << "Device is a valid video device, adding it to video device pool.";
523
qDebug() << "Device does not support capturing.";
526
qDebug() << "Device could not be opened.";
532
qDebug() << "Device is not a video device.";
624
\fn Kopete::AV::VideoDevicePool::hasDevices()
626
bool VideoDevicePool::hasDevices()
628
/// @todo implement me
629
if(m_videodevice.size())
535
qDebug() << "Not a valid Solid device: device is not available in the system.";
635
540
\fn Kopete::AV::VideoDevicePool::size()
637
542
int VideoDevicePool::size()
639
544
/// @todo implement me
640
return m_videodevice.size();
545
return m_videodevices.size();