2017-03-27 4 views
0

Ich entwickle eine WebRTC iOS Anwendung, um Video/Audio von einer Webcam zu empfangen. Nur die Webcam sendet Video und Audio, das Mobilgerät sendet nichts.libjingle iOS: Fragen Sie nicht nach mic Erlaubnis

Ich verwende die libjingle_peerconnection Bibliothek von CocoaPods (v11177.2.0).

Alles funktioniert, ich empfange Video und Audio richtig, aber ich habe ein Problem mit Geräteberechtigungen. Wenn ich das Programm zum ersten Mal benutze, wenn ich ein Video von der Webcam empfangen möchte, frage die iOS-App nach der Erlaubnis des Mikrofons. Dies ist wichtig, weil das Gerät keinen Ton sendet und mein Client sagt: "Warum fragt die App nach dem Mikrofon?"

Es ist seltsam, weil für die Kamera die App keine Erlaubnis benötigt.

Ich habe die SDP überprüft und es scheint, dass beide (Angebot und Antwort) in Ordnung sind.

Dies ist die Art, wie ich die Peerconnection-Objekt erstellen ohne angebracht Ströme:

RTCICEServer *stunServer = [[RTCICEServer alloc]initWithURI:[NSURL URLWithString:@"stun:stun.l.google.com:19302"] username:@"" password:@""]; 
    NSMutableArray *iceServers = [NSMutableArray arrayWithObject:stunServer]; 

RTCPeerConnectionFactory *factory = [[RTCPeerConnectionFactory alloc]init]; 

NSArray *peerConnectionConstraints = @[[[RTCPair alloc] initWithKey:@"DtlsSrtpKeyAgreement" value:@"true"]]; 
RTCMediaConstraints *peerConnectionConstraints = [[RTCMediaConstraints alloc]initWithMandatoryConstraints:peerConnectionConstraints optionalConstraints:nil]; 

RTCPeerConnection *pConnection = [factory peerConnectionWithICEServers:iceServers constraints:peerConnectionConstraints delegate:self]; 

NSArray *sdpConstraints = @[[[RTCPair alloc] initWithKey:@"OfferToReceiveAudio" value:@"true"], 
          [[RTCPair alloc] initWithKey:@"OfferToReceiveVideo" value:@"true"]]; 

RTCMediaConstraints* sdpConstraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:sdpConstraints optionalConstraints:nil]; 
[pConnection createOfferWithDelegate:self constraints:sdpConstraints]; 

Hier wird das SDP-Angebot ist erstellt:

v=0 
o=- 6528383367639880158 2 IN IP4 127.0.0.1 
s=- 
t=0 0 
a=group:BUNDLE audio video 
a=msid-semantic: WMS 
m=audio 9 RTP/SAVPF 111 103 104 9 102 0 8 127 126 
c=IN IP4 0.0.0.0 
a=rtcp:9 IN IP4 0.0.0.0 
a=ice-ufrag:0QOsaBCKhCBBcHz5 
a=ice-pwd:/y5snrrO3Qmq37m2aejRbK1E 
a=mid:audio 
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level 
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time 
a=recvonly 
a=rtcp-mux 
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:x1lfnVdo9lCRa9ykH6759WhY1SnI+dbLjKNbkTl+ 
a=rtpmap:111 opus/48000/2 
a=fmtp:111 minptime=10; useinbandfec=1 
a=rtpmap:103 ISAC/16000 
a=rtpmap:104 ISAC/32000 
a=rtpmap:9 G722/8000 
a=rtpmap:102 ILBC/8000 
a=rtpmap:0 PCMU/8000 
a=rtpmap:8 PCMA/8000 
a=rtpmap:127 red/8000 
a=rtpmap:126 telephone-event/8000 
a=maxptime:60 
m=video 9 RTP/SAVPF 100 101 116 117 96 
c=IN IP4 0.0.0.0 
a=rtcp:9 IN IP4 0.0.0.0 
a=ice-ufrag:0QOsaBCKhCBBcHz5 
a=ice-pwd:/y5snrrO3Qmq37m2aejRbK1E 
a=mid:video 
a=extmap:2 urn:ietf:params:rtp-hdrext:toffset 
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time 
a=extmap:4 urn:3gpp:video-orientation 
a=recvonly 
a=rtcp-mux 
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:x1lfnVdo9lCRa9ykH6759WhY1SnI+dbLjKNbkTl+ 
a=rtpmap:100 VP8/90000 
a=rtcp-fb:100 ccm fir 
a=rtcp-fb:100 nack 
a=rtcp-fb:100 nack pli 
a=rtcp-fb:100 goog-remb 
a=rtcp-fb:100 transport-cc 
a=rtpmap:101 VP9/90000 
a=rtcp-fb:101 ccm fir 
a=rtcp-fb:101 nack 
a=rtcp-fb:101 nack pli 
a=rtcp-fb:101 goog-remb 
a=rtcp-fb:101 transport-cc 
a=rtpmap:116 red/90000 
a=rtpmap:117 ulpfec/90000 
a=rtpmap:96 rtx/90000 
a=fmtp:96 apt=100 

Und hier ist die SDP Antwort von der Webcam :

v=0 
o=- 3699612909 3699612909 IN IP4 0.0.0.0 
s=- 
c=IN IP4 0.0.0.0 
t=0 0 
a=msid-semantic: WMS 
a=group:BUNDLE audio video 
m=audio 1 RTP/SAVPF 111 0 
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time 
a=mid:audio 
a=rtcp:9 IN IP4 0.0.0.0 
a=rtpmap:111 opus/48000/2 
a=rtpmap:0 PCMU/8000 
a=sendonly 
a=rtcp-mux 
a=fmtp:111 minptime=10; useinbandfec=1 
a=maxptime:60 
a=ssrc:3192391506 cname:[email protected] 
a=ice-ufrag:r2kq 
a=ice-pwd:6VJu/y0Kbc4iUDQB/1ZrnE 
a=fingerprint:sha-256 57:26:29:A5:DD:CD:42:74:C9:A3:BB:C4:67:D1:1C:24:E9:4B:4C:86:6F:93:32:03:52:6B:2B:77:B3:C4:E8:88 
m=video 1 RTP/SAVPF 100 
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time 
a=mid:video 
a=rtcp:9 IN IP4 0.0.0.0 
a=rtpmap:100 VP8/90000 
a=rtcp-fb:100 ccm fir 
a=rtcp-fb:100 nack 
a=rtcp-fb:100 nack pli 
a=rtcp-fb:100 goog-remb 
a=sendonly 
a=rtcp-mux 
a=ssrc:455461391 cname:[email protected] 
a=ice-ufrag:r2kq 
a=ice-pwd:6VJu/y0Kbc4iUDQB/1ZrnE 
a=fingerprint:sha-256 57:26:29:A5:DD:CD:42:74:C9:A3:BB:C4:67:D1:1C:24:E9:4B:4C:86:6F:93:32:03:52:6B:2B:77:B3:C4:E8:88 

Wie Sie sehen können, in der SDP Angebot, beide Medien (Audio und Video) sind "receiveOnly" und in der SDP Antwort "sendOnly", also nehme ich an, dass es kein Problem mit dem SDP gibt.

Wer weiß warum fragt nach Mikrofon Erlaubnis? Wenn Sie weitere Informationen benötigen, lassen Sie es mich wissen.

Danke!

Antwort

1

ich mit Ihrem Code/Bibliotheken nicht gearbeitet habe, für diesen Teil kann ich nicht helfen, aber von den Apple documentation können wir lesen:

Das erste Mal, App-Audio-Sitzung versucht ein Audio zu verwenden, Eingabe Route während der Verwendung einer Kategorie, die Aufzeichnung ermöglicht, fordert das System automatisch den Benutzer zur Genehmigung. Sie können zuvor explizit fragen, indem Sie die Methode Record Permission (_:) aufrufen. Bis der Benutzer gewährt Ihrer App die Berechtigung zum Aufzeichnen, Ihre App kann nur Stille aufzeichnen.

, dass Sie einen Hinweis auf, dass etwas geben könnte, irgendwo (wahrscheinlich in der libjingle) zugreift, die iOS Audio Session und wahrscheinlich das, was das Mikrofon Erlaubnis abzufeuern.

0

Hier gehen Sie.Sie müssen den lokalen Strom wie

-(RTCMediaStream*)createLocalMediaStream 
{ 
RTCMediaStream* localStream = [_factory mediaStreamWithLabel:@"ARDAMS"]; 

if(![[ReveSingleton sharedManager].localCallControl isEqualToNumber:@251]) 
{ 
    RTCVideoTrack* localVideoTrack; 
    localVideoTrack = [self createLocalVideoTrack]; 

    if (localVideoTrack) { 
     [localStream addVideoTrack:localVideoTrack]; 
     [_delegate appClient:self didReceiveLocalVideoTrack:localVideoTrack]; 
    } 
} 

[localStream addAudioTrack:[_factory audioTrackWithID:@"ARDAMSa0"]]; 
if (_isSpeakerEnabled) 
    [self enableSpeaker]; 
return localStream; 
} 

Die createLocalVideoTrack Methode wie

- (RTCVideoTrack*)createLocalVideoTrack 
{ 

RTCVideoTrack* localVideoTrack = nil; 
#if !TARGET_IPHONE_SIMULATOR && TARGET_OS_IPHONE 

NSString* cameraID = nil; 
for (AVCaptureDevice* captureDevice in 
    [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) { 
    if (captureDevice.position == AVCaptureDevicePositionFront) { 
     cameraID = [captureDevice localizedName]; 
     [captureDevice lockForConfiguration:nil]; 
     //configure frame rate 

     [captureDevice unlockForConfiguration]; 
     // [AVCaptureDevice release]; 
     break; 
    } 
} 
NSAssert(cameraID, @"Unable to get the front camera id"); 

RTCVideoCapturer* capturer = [RTCVideoCapturer capturerWithDeviceName:cameraID]; 
RTCMediaConstraints* mediaConstraints = [self defaultMediaStreamConstraints]; 
RTCVideoSource* videoSource = [_factory videoSourceWithCapturer:capturer constraints:mediaConstraints]; 
localVideoTrack = [_factory videoTrackWithID:@"ARDAMSv0" source:videoSource]; 
#endif 
return localVideoTrack; 


} 

Kamera und Mikrofon Erlaubnis auf dem Bildschirm aufgefordert werden, sein wird, erstellen, wenn der Code verarbeitet werden.

+0

Sein Problem war, dass die Mikrofon-Erlaubnis gefragt wird, auch wenn die Aufnahme nicht verwendet wird. Laut dir fragt dies immer noch nach Mikrofon Erlaubnis (?) Und löst das Problem nicht. –

Verwandte Themen