Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Unified Diff: webrtc/examples/peerconnection/client/conductor.cc

Issue 1715883002: Remove DeviceManager and DeviceInfo. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/api.gyp ('k') | webrtc/media/base/fakemediaengine.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/examples/peerconnection/client/conductor.cc
diff --git a/webrtc/examples/peerconnection/client/conductor.cc b/webrtc/examples/peerconnection/client/conductor.cc
index 2facf94585740bc9f84034f738798584fe3b8e64..ca07ef319cb43aa66c5500523ca81167fcc1cd0a 100644
--- a/webrtc/examples/peerconnection/client/conductor.cc
+++ b/webrtc/examples/peerconnection/client/conductor.cc
@@ -19,7 +19,8 @@
#include "webrtc/base/json.h"
#include "webrtc/base/logging.h"
#include "webrtc/examples/peerconnection/client/defaults.h"
-#include "webrtc/media/devices/devicemanager.h"
+#include "webrtc/media/engine/webrtcvideocapturerfactory.h"
+#include "webrtc/modules/video_capture/video_capture_factory.h"
// Names used for a IceCandidate JSON object.
const char kCandidateSdpMidName[] = "sdpMid";
@@ -369,23 +370,31 @@ void Conductor::ConnectToPeer(int peer_id) {
}
cricket::VideoCapturer* Conductor::OpenVideoCaptureDevice() {
- rtc::scoped_ptr<cricket::DeviceManagerInterface> dev_manager(
- cricket::DeviceManagerFactory::Create());
- if (!dev_manager->Init()) {
- LOG(LS_ERROR) << "Can't create device manager";
- return NULL;
- }
- std::vector<cricket::Device> devs;
- if (!dev_manager->GetVideoCaptureDevices(&devs)) {
- LOG(LS_ERROR) << "Can't enumerate video devices";
- return NULL;
+ std::vector<std::string> device_names;
+ {
+ std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info(
+ webrtc::VideoCaptureFactory::CreateDeviceInfo(0));
+ if (!info) {
+ return nullptr;
+ }
+ 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) {
+ device_names.push_back(name);
+ }
+ }
}
- std::vector<cricket::Device>::iterator dev_it = devs.begin();
- cricket::VideoCapturer* capturer = NULL;
- for (; dev_it != devs.end(); ++dev_it) {
- capturer = dev_manager->CreateVideoCapturer(*dev_it);
- if (capturer != NULL)
+
+ cricket::WebRtcVideoDeviceCapturerFactory factory;
+ cricket::VideoCapturer* capturer = nullptr;
+ for (const auto& name : device_names) {
+ capturer = factory.Create(cricket::Device(name, 0));
+ if (capturer) {
break;
+ }
}
return capturer;
}
« no previous file with comments | « webrtc/api/api.gyp ('k') | webrtc/media/base/fakemediaengine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698