128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org/*
228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * libjingle
328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * Copyright 2013 Google Inc.
428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *
528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * Redistribution and use in source and binary forms, with or without
628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * modification, are permitted provided that the following conditions are met:
728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *
828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *  1. Redistributions of source code must retain the above copyright notice,
928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *     this list of conditions and the following disclaimer.
1028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *  2. Redistributions in binary form must reproduce the above copyright notice,
1128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *     this list of conditions and the following disclaimer in the documentation
1228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *     and/or other materials provided with the distribution.
1328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *  3. The name of the author may not be used to endorse or promote products
1428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *     derived from this software without specific prior written permission.
1528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *
1628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
1728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
1928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org */
2728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
2828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include "talk/media/devices/devicemanager.h"
2911426dc719f24ece3246fd8fb24ae073c49b42edkwiberg@webrtc.org#include "webrtc/base/arraysize.h"
305dda80abea311731144b1d544aff61c408412f12Henrik Kjellander#include "webrtc/modules/video_capture/video_capture_factory.h"
3128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
3228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgnamespace cricket {
3328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
3428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgclass MobileDeviceManager : public DeviceManager {
3528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org public:
3628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  MobileDeviceManager();
3728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual ~MobileDeviceManager();
3828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual bool GetVideoCaptureDevices(std::vector<Device>* devs);
3928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org};
4028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
4128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgMobileDeviceManager::MobileDeviceManager() {
4228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // We don't expect available devices to change on Android/iOS, so use a
4328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // do-nothing watcher.
4428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  set_watcher(new DeviceWatcher(this));
4528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org}
4628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
4728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgMobileDeviceManager::~MobileDeviceManager() {}
4828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
4928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgbool MobileDeviceManager::GetVideoCaptureDevices(std::vector<Device>* devs) {
5028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  devs->clear();
51d4e598d57aed714a599444a7eab5e8fdde52a950buildbot@webrtc.org  rtc::scoped_ptr<webrtc::VideoCaptureModule::DeviceInfo> info(
5228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      webrtc::VideoCaptureFactory::CreateDeviceInfo(0));
5328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  if (!info)
5428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return false;
5528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
560c4e06b4c6107a1b94f764e279e4fb4161e905b0Peter Boström  uint32_t num_cams = info->NumberOfDevices();
5728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  char id[256];
5828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  char name[256];
590c4e06b4c6107a1b94f764e279e4fb4161e905b0Peter Boström  for (uint32_t i = 0; i < num_cams; ++i) {
6011426dc719f24ece3246fd8fb24ae073c49b42edkwiberg@webrtc.org    if (info->GetDeviceName(i, name, arraysize(name), id, arraysize(id)))
6128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      continue;
6228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    devs->push_back(Device(name, id));
6328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
6428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  return true;
6528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org}
6628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
6728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgDeviceManagerInterface* DeviceManagerFactory::Create() {
6828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  return new MobileDeviceManager();
6928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org}
7028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
7128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgbool GetUsbId(const Device& device, std::string* usb_id) { return false; }
7228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
7328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgbool GetUsbVersion(const Device& device, std::string* usb_version) {
7428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  return false;
7528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org}
7628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
7728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org}  // namespace cricket
78