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

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory.mm

Issue 2279293003: Update AecDump API to match RtcEventLog API signature. (Closed)
Patch Set: Fix rebase. Created 4 years, 3 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 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 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
11 #import "RTCPeerConnectionFactory+Private.h" 11 #import "RTCPeerConnectionFactory+Private.h"
12 12
13 #import "NSString+StdString.h" 13 #import "NSString+StdString.h"
14 #import "RTCAVFoundationVideoSource+Private.h" 14 #import "RTCAVFoundationVideoSource+Private.h"
15 #import "RTCAudioSource+Private.h" 15 #import "RTCAudioSource+Private.h"
16 #import "RTCAudioTrack+Private.h" 16 #import "RTCAudioTrack+Private.h"
17 #import "RTCMediaConstraints+Private.h" 17 #import "RTCMediaConstraints+Private.h"
18 #import "RTCMediaStream+Private.h" 18 #import "RTCMediaStream+Private.h"
19 #import "RTCPeerConnection+Private.h" 19 #import "RTCPeerConnection+Private.h"
20 #import "RTCVideoSource+Private.h" 20 #import "RTCVideoSource+Private.h"
21 #import "RTCVideoTrack+Private.h" 21 #import "RTCVideoTrack+Private.h"
22 #import "WebRTC/RTCLogging.h"
22 23
23 @implementation RTCPeerConnectionFactory { 24 @implementation RTCPeerConnectionFactory {
24 std::unique_ptr<rtc::Thread> _networkThread; 25 std::unique_ptr<rtc::Thread> _networkThread;
25 std::unique_ptr<rtc::Thread> _workerThread; 26 std::unique_ptr<rtc::Thread> _workerThread;
26 std::unique_ptr<rtc::Thread> _signalingThread; 27 std::unique_ptr<rtc::Thread> _signalingThread;
28 BOOL _hasStartedAecDump;
27 } 29 }
28 30
29 @synthesize nativeFactory = _nativeFactory; 31 @synthesize nativeFactory = _nativeFactory;
30 32
31 - (instancetype)init { 33 - (instancetype)init {
32 if ((self = [super init])) { 34 if ((self = [super init])) {
33 _networkThread = rtc::Thread::CreateWithSocketServer(); 35 _networkThread = rtc::Thread::CreateWithSocketServer();
34 BOOL result = _networkThread->Start(); 36 BOOL result = _networkThread->Start();
35 NSAssert(result, @"Failed to start network thread."); 37 NSAssert(result, @"Failed to start network thread.");
36 38
37 _workerThread = rtc::Thread::Create(); 39 _workerThread = rtc::Thread::Create();
38 result = _workerThread->Start(); 40 result = _workerThread->Start();
39 NSAssert(result, @"Failed to start worker thread."); 41 NSAssert(result, @"Failed to start worker thread.");
40 42
41 _signalingThread = rtc::Thread::Create(); 43 _signalingThread = rtc::Thread::Create();
42 result = _signalingThread->Start(); 44 result = _signalingThread->Start();
43 NSAssert(result, @"Failed to start signaling thread."); 45 NSAssert(result, @"Failed to start signaling thread.");
44 46
45 _nativeFactory = webrtc::CreatePeerConnectionFactory( 47 _nativeFactory = webrtc::CreatePeerConnectionFactory(
46 _networkThread.get(), _workerThread.get(), _signalingThread.get(), 48 _networkThread.get(), _workerThread.get(), _signalingThread.get(),
47 nullptr, nullptr, nullptr); 49 nullptr, nullptr, nullptr);
48 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); 50 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
49 } 51 }
50 return self; 52 return self;
51 } 53 }
52 54
53 - (BOOL)startAecDumpWithFileDescriptor:(int)fileDescriptor
54 maxFileSizeInBytes:(int)maxFileSizeInBytes {
55 // Pass the file to the recorder. The file ownership
56 // is passed to the recorder, and the recorder
57 // closes the file when needed.
58 return _nativeFactory->StartAecDump(fileDescriptor, maxFileSizeInBytes);
59 }
60
61 - (void)stopAecDump {
62 // The file is closed by the call below.
63 _nativeFactory->StopAecDump();
64 }
65
66 - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)c onstraints { 55 - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)c onstraints {
67 std::unique_ptr<webrtc::MediaConstraints> nativeConstraints; 56 std::unique_ptr<webrtc::MediaConstraints> nativeConstraints;
68 if (constraints) { 57 if (constraints) {
69 nativeConstraints = constraints.nativeConstraints; 58 nativeConstraints = constraints.nativeConstraints;
70 } 59 }
71 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = 60 rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
72 _nativeFactory->CreateAudioSource(nativeConstraints.get()); 61 _nativeFactory->CreateAudioSource(nativeConstraints.get());
73 return [[RTCAudioSource alloc] initWithNativeAudioSource:source]; 62 return [[RTCAudioSource alloc] initWithNativeAudioSource:source];
74 } 63 }
75 64
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 constraints: 97 constraints:
109 (RTCMediaConstraints *)constraints 98 (RTCMediaConstraints *)constraints
110 delegate: 99 delegate:
111 (nullable id<RTCPeerConnectionDelegate>)delegate { 100 (nullable id<RTCPeerConnectionDelegate>)delegate {
112 return [[RTCPeerConnection alloc] initWithFactory:self 101 return [[RTCPeerConnection alloc] initWithFactory:self
113 configuration:configuration 102 configuration:configuration
114 constraints:constraints 103 constraints:constraints
115 delegate:delegate]; 104 delegate:delegate];
116 } 105 }
117 106
107 - (BOOL)startAecDumpWithFilePath:(NSString *)filePath
108 maxSizeInBytes:(int64_t)maxSizeInBytes {
109 RTC_DCHECK(filePath.length);
110 RTC_DCHECK_GT(maxSizeInBytes, 0);
111
112 if (_hasStartedAecDump) {
113 RTCLogError(@"Aec dump already started.");
114 return NO;
115 }
116 int fd = open(filePath.UTF8String, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_I WUSR);
117 if (fd < 0) {
118 RTCLogError(@"Error opening file: %@. Error: %d", filePath, errno);
119 return NO;
120 }
121 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes);
122 return _hasStartedAecDump;
123 }
124
125 - (void)stopAecDump {
126 _nativeFactory->StopAecDump();
127 _hasStartedAecDump = NO;
128 }
129
118 @end 130 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698