我在構建一個基於的voip
應用程序。我把下面的代碼之前每個調用我做:通話結束後我重置所有這些變量RTCVideoCapturer capturerWithDeviceName:(NSString *)在後續調用後變得非常緩慢
NSMutableArray *m = [[NSMutableArray alloc] init];
NSMutableArray *o = [[NSMutableArray alloc] init];
//[m addObject:[[RTCPair alloc] initWithKey:@"maxFrameRate" value:@"30"]];
//[m addObject:[[RTCPair alloc] initWithKey:@"maxFrameRate" value:@"24"]];
//[m addObject:[[RTCPair alloc] initWithKey:@"maxHeight" value:@"180"]];
NSString* cameraID = nil;
for (AVCaptureDevice *captureDevice in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) {
if (captureDevice.position == AVCaptureDevicePositionFront) {
cameraID = [captureDevice localizedName];
break;
}
}
capturer = [RTCVideoCapturer capturerWithDeviceName:cameraID]; //why so slow :(
RTCMediaConstraints *videoConstraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:m optionalConstraints:o];
videoSource = [peerConnectionFactory videoSourceWithCapturer:capturer constraints:videoConstraints];
localVideoTrack = [peerConnectionFactory videoTrackWithID:@"ARDAMSv0" source:videoSource];
lms = [peerConnectionFactory mediaStreamWithLabel:@"ARDAMS"];
if (localVideoTrack) [lms addVideoTrack:localVideoTrack];
[lms addAudioTrack:[peerConnectionFactory audioTrackWithID:@"ARDAMSa0"]];
[peerConnection addStream:lms constraints:[[RTCMediaConstraints alloc] init]];
dispatch_async(dispatch_get_main_queue(), ^{
[callViewController setLocalVideo];
});
後(大多隻是將它們設置爲無)。我已經看到這種方法工作得很好,但最近有一個bug潛入其中。每個後續的調用會增加該行
capturer = [RTCVideoCapturer capturerWithDeviceName:cameraID];
我試圖在應用的開始設置獲取部只有一次的執行時間,但隨後在
videoSource = [peerConnectionFactory videoSourceWithCapturer:capturer constraints:videoConstraints];
應用程序崩潰,即使所有參數進行初始化(我使用調試器進行檢查)。
有沒有人知道這可能是什麼?我敢肯定,這個相同的代碼之前工作完美。我沒有更新webrtc
庫,xcode
或iOS
。
謝謝你的提示,我現在休息了幾天,但是當我回去工作時我會仔細研究它。 – Kevin 2014-10-01 10:52:08
對不起,花了這麼長時間,我的代碼是一團糟,所以我決定重寫它的大部分。我現在正在重新使用除peerconnection之外的所有內容,但當我調用[peerConnection close]時,應用程序崩潰;你有什麼想法,爲什麼這可能是? – Kevin 2014-10-14 07:05:31
你得到的錯誤是什麼?對等連接是否爲零?同時檢查對等連接狀態,看它是否由於某種原因未被關閉(在這種情況下,將是peerConnection.signalingState)。 – Cam 2014-10-15 18:49:06