bool DeviceManager::getVideoCaptureDevice(Device& out, const std::string& name, int id)
{
    // If the name is empty, return the default device.
    if (name.empty() || name == kDefaultDeviceName) {
        return getDefaultVideoCaptureDevice(out);
    }

    std::vector<Device> devices;
    return getVideoCaptureDevices(devices) &&
        matchNameAndID(devices, out, name, id);

#if 0
    for (std::vector<Device>::const_iterator it = devices.begin(); it != devices.end(); ++it) {
        if (name == it->name) {
            InfoL << "Create VideoCapturer for " << name << endl;
            out = *it;
            return true;
        }
    }

    // If the name is a valid path to a file, then we'll create a simulated device
    // with the filename. The LmiMediaEngine will know to use a FileVideoCapturer
    // for these devices.
    if (talk_base::FileSystem::IsFile(name)) {
        InfoL << "Create FileVideoCapturer" << endl;
        *out = FileVideoCapturer::CreateFileVideoCapturerDevice(name);
        return true;
    }
#endif
}
bool DeviceManager::getDefaultVideoCaptureDevice(Device& device)
{
    bool ret = false;
    // We just return the first device.
    std::vector<Device> devices;
    ret = (getVideoCaptureDevices(devices) && !devices.empty());
    if (ret) {
        device = devices[0];
    }
    return ret;
}
int DeviceManager::getCapabilities()
{
    std::vector<Device> devices;
    int caps = VIDEO_RECV;
    if (getAudioInputDevices(devices) && !devices.empty()) {
        caps |= AUDIO_SEND;
    }
    if (getAudioOutputDevices(devices) && !devices.empty()) {
        caps |= AUDIO_RECV;
    }
    if (getVideoCaptureDevices(devices) && !devices.empty()) {
        caps |= VIDEO_SEND;
    }
    return caps;
}
Esempio n. 4
0
// cricket::VideoCapturer* openWebRtcVideoCaptureDevice(const std::string& deviceName)
std::unique_ptr<cricket::VideoCapturer> openWebRtcVideoCaptureDevice(const std::string& deviceName)
{
    cricket::WebRtcVideoDeviceCapturerFactory factory;
    // std::unique_ptr<cricket::VideoCapturer> capturer;
    cricket::VideoCapturer* capturer = nullptr;
    auto deviceNames = getVideoCaptureDevices();
    for (const auto& name : deviceNames) {
        if (name == deviceName) {
            return factory.Create(cricket::Device(name, 0));
        }
    }
    if (!capturer && !deviceNames.empty()) {
        return factory.Create(cricket::Device(deviceNames[0], 0));
    }

    assert(0 && "no video devices");
    return nullptr;
}
void DeviceManager::print(std::ostream& ost)
{
    std::vector<Device> devs;
    getAudioInputDevices(devs);
    ost << "Audio input devices: " << endl;
    for (std::size_t i = 0; i < devs.size(); ++i)
        devs[i].print(ost);

    getAudioOutputDevices(devs);
    ost << "Audio output devices: " << endl;
    for (std::size_t i = 0; i < devs.size(); ++i)
        devs[i].print(ost);

    getVideoCaptureDevices(devs);
    ost << "Video capture devices: " << endl;
    for (std::size_t i = 0; i < devs.size(); ++i)
        devs[i].print(ost);
}
bool DeviceManager::getVideoCaptureDevice(Device& out, int id)
{
    std::vector<Device> devices;
    return getVideoCaptureDevices(devices) &&
        matchID(devices, out, id);
}