Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 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 #import "RTCAVFoundationVideoSource+Internal.h" | 28 #import "RTCAVFoundationVideoSource+Internal.h" |
| 29 | 29 |
| 30 #import "RTCMediaConstraints+Internal.h" | 30 #import "RTCMediaConstraints+Internal.h" |
| 31 #import "RTCMediaSource+Internal.h" | 31 #import "RTCMediaSource+Internal.h" |
| 32 #import "RTCPeerConnectionFactory+Internal.h" | 32 #import "RTCPeerConnectionFactory+Internal.h" |
| 33 #import "RTCVideoSource+Internal.h" | 33 #import "RTCVideoSource+Internal.h" |
| 34 | 34 |
| 35 #include <memory> | 35 #include <memory> |
| 36 | 36 |
| 37 @implementation RTCAVFoundationVideoSource | 37 @implementation RTCAVFoundationVideoSource { |
| 38 webrtc::AVFoundationVideoCapturer* _capturer; | |
|
tkchin_webrtc
2016/04/06 19:41:46
nit: Capturer *_capturer; (the style in the file i
| |
| 39 } | |
| 38 | 40 |
| 39 - (instancetype)initWithFactory:(RTCPeerConnectionFactory*)factory | 41 - (instancetype)initWithFactory:(RTCPeerConnectionFactory*)factory |
| 40 constraints:(RTCMediaConstraints*)constraints { | 42 constraints:(RTCMediaConstraints*)constraints { |
| 41 NSParameterAssert(factory); | 43 NSParameterAssert(factory); |
| 42 std::unique_ptr<webrtc::AVFoundationVideoCapturer> capturer; | 44 // We pass ownership of the capturer to the source, but since we own |
| 43 capturer.reset(new webrtc::AVFoundationVideoCapturer()); | 45 // the source, it should be ok to keep a raw pointer to the |
| 46 // capturer. | |
| 47 _capturer = new webrtc::AVFoundationVideoCapturer(); | |
| 44 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source = | 48 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source = |
| 45 factory.nativeFactory->CreateVideoSource(capturer.release(), constraints.c onstraints); | 49 factory.nativeFactory->CreateVideoSource(_capturer, |
| 50 constraints.constraints); | |
| 46 return [super initWithMediaSource:source]; | 51 return [super initWithMediaSource:source]; |
| 47 } | 52 } |
| 48 | 53 |
| 49 - (BOOL)canUseBackCamera { | 54 - (BOOL)canUseBackCamera { |
| 50 return self.capturer->CanUseBackCamera(); | 55 return self.capturer->CanUseBackCamera(); |
| 51 } | 56 } |
| 52 | 57 |
| 53 - (BOOL)useBackCamera { | 58 - (BOOL)useBackCamera { |
| 54 return self.capturer->GetUseBackCamera(); | 59 return self.capturer->GetUseBackCamera(); |
| 55 } | 60 } |
| 56 | 61 |
| 57 - (void)setUseBackCamera:(BOOL)useBackCamera { | 62 - (void)setUseBackCamera:(BOOL)useBackCamera { |
| 58 self.capturer->SetUseBackCamera(useBackCamera); | 63 self.capturer->SetUseBackCamera(useBackCamera); |
| 59 } | 64 } |
| 60 | 65 |
| 61 - (AVCaptureSession*)captureSession { | 66 - (AVCaptureSession*)captureSession { |
| 62 return self.capturer->GetCaptureSession(); | 67 return self.capturer->GetCaptureSession(); |
| 63 } | 68 } |
| 64 | 69 |
| 65 - (webrtc::AVFoundationVideoCapturer*)capturer { | 70 - (webrtc::AVFoundationVideoCapturer*)capturer { |
| 66 cricket::VideoCapturer* capturer = self.videoSource->GetVideoCapturer(); | 71 return _capturer; |
| 67 // This should be safe because no one should have changed the underlying video | |
| 68 // source. | |
| 69 webrtc::AVFoundationVideoCapturer* foundationCapturer = | |
| 70 static_cast<webrtc::AVFoundationVideoCapturer*>(capturer); | |
| 71 return foundationCapturer; | |
| 72 } | 72 } |
| 73 | 73 |
| 74 @end | 74 @end |
| OLD | NEW |