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

Side by Side Diff: webrtc/examples/peerconnection/client/conductor.cc

Issue 2685093002: Switching some interfaces to use std::unique_ptr<>. (Closed)
Patch Set: Rebase onto master Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 } 359 }
360 360
361 if (InitializePeerConnection()) { 361 if (InitializePeerConnection()) {
362 peer_id_ = peer_id; 362 peer_id_ = peer_id;
363 peer_connection_->CreateOffer(this, NULL); 363 peer_connection_->CreateOffer(this, NULL);
364 } else { 364 } else {
365 main_wnd_->MessageBox("Error", "Failed to initialize PeerConnection", true); 365 main_wnd_->MessageBox("Error", "Failed to initialize PeerConnection", true);
366 } 366 }
367 } 367 }
368 368
369 cricket::VideoCapturer* Conductor::OpenVideoCaptureDevice() { 369 std::unique_ptr<cricket::VideoCapturer> Conductor::OpenVideoCaptureDevice() {
370 std::vector<std::string> device_names; 370 std::vector<std::string> device_names;
371 { 371 {
372 std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info( 372 std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info(
373 webrtc::VideoCaptureFactory::CreateDeviceInfo()); 373 webrtc::VideoCaptureFactory::CreateDeviceInfo());
374 if (!info) { 374 if (!info) {
375 return nullptr; 375 return nullptr;
376 } 376 }
377 int num_devices = info->NumberOfDevices(); 377 int num_devices = info->NumberOfDevices();
378 for (int i = 0; i < num_devices; ++i) { 378 for (int i = 0; i < num_devices; ++i) {
379 const uint32_t kSize = 256; 379 const uint32_t kSize = 256;
380 char name[kSize] = {0}; 380 char name[kSize] = {0};
381 char id[kSize] = {0}; 381 char id[kSize] = {0};
382 if (info->GetDeviceName(i, name, kSize, id, kSize) != -1) { 382 if (info->GetDeviceName(i, name, kSize, id, kSize) != -1) {
383 device_names.push_back(name); 383 device_names.push_back(name);
384 } 384 }
385 } 385 }
386 } 386 }
387 387
388 cricket::WebRtcVideoDeviceCapturerFactory factory; 388 cricket::WebRtcVideoDeviceCapturerFactory factory;
389 cricket::VideoCapturer* capturer = nullptr; 389 std::unique_ptr<cricket::VideoCapturer> capturer;
390 for (const auto& name : device_names) { 390 for (const auto& name : device_names) {
391 capturer = factory.Create(cricket::Device(name, 0)); 391 capturer = factory.Create(cricket::Device(name, 0));
392 if (capturer) { 392 if (capturer) {
393 break; 393 break;
394 } 394 }
395 } 395 }
396 return capturer; 396 return capturer;
397 } 397 }
398 398
399 void Conductor::AddStreams() { 399 void Conductor::AddStreams() {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 } 537 }
538 538
539 void Conductor::OnFailure(const std::string& error) { 539 void Conductor::OnFailure(const std::string& error) {
540 LOG(LERROR) << error; 540 LOG(LERROR) << error;
541 } 541 }
542 542
543 void Conductor::SendMessage(const std::string& json_object) { 543 void Conductor::SendMessage(const std::string& json_object) {
544 std::string* msg = new std::string(json_object); 544 std::string* msg = new std::string(json_object);
545 main_wnd_->QueueUIThreadCallback(SEND_MESSAGE_TO_PEER, msg); 545 main_wnd_->QueueUIThreadCallback(SEND_MESSAGE_TO_PEER, msg);
546 } 546 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698