void StreamingControlWidget::StartCameraStreaming() { VideoDevices tList = mVideoWorker->GetPossibleDevices(); VideoDevices::iterator tIt; QString tSelectedDevice = ""; for (tIt = tList.begin(); tIt != tList.end(); tIt++) { if (tIt->Type == Camera) { tSelectedDevice = QString(tIt->Name.c_str()); break; } } // found something? if (tSelectedDevice == "") { ShowWarning("Missing camera", "No camera available. Please, select another source!"); return; } LOG(LOG_VERBOSE, "Selecting %s", tSelectedDevice.toStdString().c_str()); mVideoWorker->SetCurrentDevice(tSelectedDevice); if (mVideoWorker->SupportsMultipleInputStreams()) SetVideoInputSelectionVisible(); else SetVideoInputSelectionVisible(false); }
void MediaSourceDesktop::getVideoDevices(VideoDevices &pVList) { static bool tFirstCall = true; VideoDeviceDescriptor tDevice; #ifdef MSD_DEBUG_PACKETS tFirstCall = true; #endif if (tFirstCall) LOG(LOG_VERBOSE, "Enumerating hardware.."); //############################# //### screen segment //############################# tDevice.Name = MSD_DESKTOP_SEGMENT; tDevice.Card = "segment"; #ifdef APPLE tDevice.Desc = "OSX Cocoa based screen segment capturing"; #else tDevice.Desc = "Qt based screen segment capturing"; #endif if (tFirstCall) LOG(LOG_VERBOSE, "Found video device: %s (card: %s)", tDevice.Name.c_str(), tDevice.Card.c_str()); pVList.push_back(tDevice); tFirstCall = false; }
void MediaSourceFile::getVideoDevices(VideoDevices &pVList) { VideoDeviceDescriptor tDevice; tDevice.Name = mDesiredDevice; tDevice.Card = mDesiredDevice; tDevice.Desc = "file source: \"" + mDesiredDevice + "\""; pVList.push_back(tDevice); }
void MediaSourceDesktop::getVideoDevices(VideoDevices &pVList) { static bool tFirstCall = true; VideoDeviceDescriptor tDevice; #ifdef MSD_DEBUG_PACKETS tFirstCall = true; #endif if (tFirstCall) LOG(LOG_VERBOSE, "Enumerating hardware.."); //############################# //### screen segment //############################# tDevice.Name = MEDIA_SOURCE_DESKTOP; tDevice.Card = "segment"; #ifdef APPLE tDevice.Desc = "OSX Cocoa based screen segment capturing"; #else tDevice.Desc = "Qt based screen segment capturing"; #endif if (tFirstCall) LOG(LOG_VERBOSE, "Found video device: %s (card: %s)", tDevice.Name.c_str(), tDevice.Card.c_str()); pVList.push_back(tDevice); QDesktopWidget *tDesktop = QApplication::desktop(); if (tDesktop != NULL) { if (tFirstCall) { LOG(LOG_VERBOSE, "Desktop found.."); LOG(LOG_VERBOSE, " ..resolution: %d * %d", tDesktop->width(), tDesktop->height()); LOG(LOG_VERBOSE, " ..screens: %d", tDesktop->numScreens()); LOG(LOG_VERBOSE, " ..virtualized: %d", tDesktop->isVirtualDesktop()); } for (int i = 0; i < tDesktop->numScreens(); i++) { QWidget *tScreen = tDesktop->screen(i); if (tFirstCall) { LOG(LOG_VERBOSE, " ..screen %d: resolution=%d*%d, available resolution=%d*%d, position=(%d, %d)", i, tDesktop->screenGeometry(i).width(), tDesktop->screenGeometry(i).height(), tDesktop->availableGeometry(i).width(), tDesktop->availableGeometry(i).height(), tDesktop->screenGeometry(i).x(), tDesktop->screenGeometry(i).y()); } } } tFirstCall = false; }
QString MediaSourceGrabberThread::GetDeviceDescription(QString pName) { if (mMediaSource->GetMediaType() == MEDIA_VIDEO) { VideoDevices::iterator tIt; VideoDevices tVList; mMediaSource->getVideoDevices(tVList); for (tIt = tVList.begin(); tIt != tVList.end(); tIt++) if (pName.toStdString() == tIt->Name) return QString(tIt->Desc.c_str()); }else if (mMediaSource->GetMediaType() == MEDIA_AUDIO) { AudioDevices::iterator tIt; AudioDevices tVList; mMediaSource->getAudioDevices(tVList); for (tIt = tVList.begin(); tIt != tVList.end(); tIt++) if (pName.toStdString() == tIt->Name) return QString(tIt->Desc.c_str()); } return ""; }
void MediaSourceVFW::getVideoDevices(VideoDevices &pVList) { static bool tFirstCall = true; HWND tWinHandle = NULL; int tRes; VideoDeviceDescriptor tDevice; #ifdef MSVFW_DEBUG_PACKETS tFirstCall = true; #endif if (tFirstCall) { mFoundVFWDevices.clear(); LOG(LOG_VERBOSE, "Enumerating hardware.."); // windows supports up to 10 drivers which are indexed from 0 to 9 //HINT: http://msdn.microsoft.com/en-us/library/dd756909%28VS.85%29.aspx char tDriverName[256]; char tDriverVersion[32]; for (int i = 0; i < 10; i++) { //#################################### //### verbose output and store device description //#################################### if (capGetDriverDescription(i, tDriverName, 256, tDriverVersion, 32)) { LOG(LOG_INFO, "Found active VFW device %d", i); LOG(LOG_INFO, " ..name: %s", tDriverName); LOG(LOG_INFO, " ..version: %s", tDriverVersion); tDevice.Name = string(tDriverName); tDevice.Card = (char)i + 48; tDevice.Desc = "VFW based video device " + tDevice.Card + " \"" + string(tDriverName) + "\""; tDevice.Type = Camera; // assume all as camera devices LOG(LOG_VERBOSE, "Found video device: %s (card: %s)", tDevice.Name.c_str(), tDevice.Card.c_str()); } //############################################## //### probe device by creating a capture window //############################################## tWinHandle = capCreateCaptureWindow(NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0); if(!tWinHandle) { LOG(LOG_INFO, "Could not create capture window"); continue; } tRes = SendMessage(tWinHandle, WM_CAP_DRIVER_CONNECT, i, 0); if(!tRes) { LOG(LOG_INFO, "Could not connect to device"); mDeviceAvailable[i] = false; DestroyWindow(tWinHandle); continue; }else mDeviceAvailable[i] = true; //HINT: maybe our capture frames are upside down, see http://www.microsoft.com/whdc/archive/biheight.mspx -> detect this BITMAPINFO tInfo; tRes = capGetVideoFormat(tWinHandle, &tInfo, sizeof(tInfo)); if (!tRes) { LOG(LOG_ERROR, "Not connected to the capture window"); DestroyWindow(tWinHandle); continue; } DestroyWindow(tWinHandle); //############################################### //### finally add this device to the result list //############################################### mFoundVFWDevices.push_back(tDevice); } }else { LOG(LOG_VERBOSE, "Using internal device cache with %d entries", (int)mFoundVFWDevices.size()); } tFirstCall = false; VideoDevices::iterator tIt; for (tIt = mFoundVFWDevices.begin(); tIt != mFoundVFWDevices.end(); tIt++) { pVList.push_back(*tIt); } }