| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #if !defined(__has_feature) || !__has_feature(objc_arc) | 28 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 29 #error "This file requires ARC support." | 29 #error "This file requires ARC support." |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #import "RTCVideoCapturer+Internal.h" | 32 #import "RTCVideoCapturer+Internal.h" |
| 33 | 33 |
| 34 #include <memory> | 34 #include <memory> |
| 35 | 35 |
| 36 #include "webrtc/media/base/videocapturer.h" | 36 #include "webrtc/media/base/videocapturer.h" |
| 37 #include "webrtc/media/devices/devicemanager.h" | 37 #include "webrtc/media/engine/webrtcvideocapturerfactory.h" |
| 38 | 38 |
| 39 @implementation RTCVideoCapturer { | 39 @implementation RTCVideoCapturer { |
| 40 std::unique_ptr<cricket::VideoCapturer> _capturer; | 40 std::unique_ptr<cricket::VideoCapturer> _capturer; |
| 41 } | 41 } |
| 42 | 42 |
| 43 + (RTCVideoCapturer*)capturerWithDeviceName:(NSString*)deviceName { | 43 + (RTCVideoCapturer*)capturerWithDeviceName:(NSString*)deviceName { |
| 44 const std::string& device_name = std::string([deviceName UTF8String]); | 44 cricket::WebRtcVideoDeviceCapturerFactory factory; |
| 45 std::unique_ptr<cricket::DeviceManagerInterface> device_manager( | 45 cricket::Device device(std::string(deviceName.UTF8String), 0); |
| 46 cricket::DeviceManagerFactory::Create()); | 46 rtc::scoped_ptr<cricket::VideoCapturer> capturer(factory.Create(device)); |
| 47 bool initialized = device_manager->Init(); | |
| 48 NSAssert(initialized, @"DeviceManager::Init() failed"); | |
| 49 cricket::Device device; | |
| 50 if (!device_manager->GetVideoCaptureDevice(device_name, &device)) { | |
| 51 LOG(LS_ERROR) << "GetVideoCaptureDevice failed"; | |
| 52 return 0; | |
| 53 } | |
| 54 std::unique_ptr<cricket::VideoCapturer> capturer( | |
| 55 device_manager->CreateVideoCapturer(device)); | |
| 56 RTCVideoCapturer* rtcCapturer = | 47 RTCVideoCapturer* rtcCapturer = |
| 57 [[RTCVideoCapturer alloc] initWithCapturer:capturer.release()]; | 48 [[RTCVideoCapturer alloc] initWithCapturer:capturer.release()]; |
| 58 return rtcCapturer; | 49 return rtcCapturer; |
| 59 } | 50 } |
| 60 | 51 |
| 61 @end | 52 @end |
| 62 | 53 |
| 63 @implementation RTCVideoCapturer (Internal) | 54 @implementation RTCVideoCapturer (Internal) |
| 64 | 55 |
| 65 - (id)initWithCapturer:(cricket::VideoCapturer*)capturer { | 56 - (id)initWithCapturer:(cricket::VideoCapturer*)capturer { |
| 66 if ((self = [super init])) { | 57 if ((self = [super init])) { |
| 67 _capturer.reset(capturer); | 58 _capturer.reset(capturer); |
| 68 } | 59 } |
| 69 return self; | 60 return self; |
| 70 } | 61 } |
| 71 | 62 |
| 72 - (cricket::VideoCapturer*)takeNativeCapturer { | 63 - (cricket::VideoCapturer*)takeNativeCapturer { |
| 73 return _capturer.release(); | 64 return _capturer.release(); |
| 74 } | 65 } |
| 75 | 66 |
| 76 @end | 67 @end |
| OLD | NEW |