Hello all,
I've an application that uses WebRTC stack directly from native side (C++) in Android, integrated with Qt Framework ( just in case it's interesting to know this ). Please, anyone can direct me on how to get the Android camera working without using java?
For other platforms I'm using to get the devices this helper I've created; based on how I've seen WebRTC working:
powah::DeviceManager::VideoDevices powah::DeviceManager::_getDevices()
{
powah::DeviceManager::VideoDevices devices;
std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info(
webrtc::VideoCaptureFactory::CreateDeviceInfo(0));
if (!info) return devices;
int num_devices = info->NumberOfDevices();
for (int i = 0; i < num_devices; ++i) {
const uint32_t kSize = 256;
char name[kSize] = {0};
char id[kSize] = {0};
if (info->GetDeviceName(i, name, kSize, id, kSize) != -1)
{
powah::VideoDevice * device = new powah::VideoDevice();
device->setName(name);
device->setId(id);
int32_t numberCapabilities = info->NumberOfCapabilities(id);
for (int j = 0; j < numberCapabilities; j++)
{
webrtc::VideoCaptureCapability capability;
if (info->GetCapability(id, j, capability) < 0) continue;
// Check FPS
if ((capability.maxFPS > powah::MAX_FPS)
|| (capability.maxFPS < powah::MIN_FPS)) continue;
// Check Resolution
if ((capability.width > powah::MAX_WIDTH)
|| (capability.height > powah::MAX_HEIGHT)) continue;
std::stringstream nameSt;
nameSt << capability.width << "x" << capability.height;
std::string name = nameSt.str();
for (const powah::Capability & cap : m_predefinedCapabilities)
{
if ((cap.width() == capability.width) &&
(cap.height() == capability.height))
{
name = cap.name();
break;
}
}
device->addCapability(capability, name);
}
powah::VideoDevice::Capabilities capabilities = device->capabilities();
powah::VideoDevice::Capabilities::iterator it = capabilities.end();
device->setCurrentCapability((*--it));
devices.push_back(device);
}
}
return devices;
}
But for Android list no devices as the method CreateDeviceInfo (webrtc\modules\video_capture\video_capture_factory.cc) returns nullptr while Android:
VideoCaptureModule::DeviceInfo* VideoCaptureFactory::CreateDeviceInfo(
const int32_t id) {
#if defined(ANDROID)
return nullptr;
#else
return videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(id);
#endif
}
Thanks in advance, regards.