-2
我試圖構建一個WebRTC應用程序。設置AudioTrack時SessionDescription爲NULL
現在,我有這樣的:
PeerConnectionFactory.initializeAndroidGlobals(this, true);
final PeerConnectionFactory pcFactory = new PeerConnectionFactory(null);
final PeerConnection pc = pcFactory.createPeerConnection(ICE_SERVERS, MEDIA_CONSTRAINTS, new PeerConnection.Observer() {
private final String TAG = "WebRTC";
@Override
public void onSignalingChange(final PeerConnection.SignalingState signalingState) {
Log.d(TAG, "Signaling change\t" + signalingState);
}
@Override
public void onIceConnectionChange(final PeerConnection.IceConnectionState iceConnectionState) {
Log.d(TAG, "ICE connection change\t" + iceConnectionState);
}
@Override
public void onIceConnectionReceivingChange(final boolean b) {
Log.d(TAG, "ICE connection receiving change\t" + b);
}
@Override
public void onIceGatheringChange(final PeerConnection.IceGatheringState iceGatheringState) {
Log.d(TAG, "ICE gathering change\t" + iceGatheringState);
}
@Override
public void onIceCandidate(final IceCandidate iceCandidate) {
Log.d(TAG, "ICE candidate\t" + iceCandidate);
}
@Override
public void onIceCandidatesRemoved(final IceCandidate[] iceCandidates) {
for (final IceCandidate iceCandidate : iceCandidates){
Log.d(TAG, "ICE candidate removed\t" + iceCandidate);
}
}
@Override
public void onAddStream(final MediaStream mediaStream) {
Log.d(TAG, "Add stream\t" + mediaStream);
}
@Override
public void onRemoveStream(final MediaStream mediaStream) {
Log.d(TAG, "Remove stream\t" + mediaStream);
}
@Override
public void onDataChannel(final DataChannel dataChannel) {
Log.d(TAG, "Data channel\t" + dataChannel);
}
@Override
public void onRenegotiationNeeded() {
Log.d(TAG, "Renegotiation needed");
}
@Override
public void onAddTrack(final RtpReceiver rtpReceiver, final MediaStream[] mediaStreams) {
for (final MediaStream mediaStream : mediaStreams) {
Log.d(TAG, "Add track\t" + rtpReceiver + "\t" + mediaStream);
}
}
});
final AudioSource audioSource = pcFactory.createAudioSource(MEDIA_CONSTRAINTS);
Assert.assertNotNull(audioSource);
final AudioTrack audioTrack = pcFactory.createAudioTrack("Test Audio Track", audioSource);
Assert.assertNotNull(audioTrack);
final MediaStream localMS = pcFactory.createLocalMediaStream("Test Local Media Stream");
Assert.assertNotNull(localMS);
Assert.assertTrue(localMS.addTrack(audioTrack));
Assert.assertTrue(pc.addStream(localMS));
pc.createOffer(new SdpObserver() {
private final String TAG = "WebRTC";
@Override
public void onCreateSuccess(final SessionDescription sessionDescription) {
Log.d(TAG, "Create success\t" + sessionDescription.type + " " + sessionDescription.description);
pc.setLocalDescription(this, sessionDescription);
}
@Override
public void onSetSuccess() {
Log.d(TAG, "Set success");
}
@Override
public void onCreateFailure(final String s) {
Log.d(TAG, "Create failure\t" + s);
}
@Override
public void onSetFailure(final String s) {
Log.d(TAG, "Set failure\t" + s);
}
}, MEDIA_CONSTRAINTS);
而這種失敗與以下日誌:
Set failure SessionDescription is NULL.
然而,SessionDescription
絕對不是null
:
v=0
o=- 1671888432286839529 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE audio
a=msid-semantic: WMS Test Local Media Stream
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 102 0 8 106 105 13 110 112 113 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:wxDK
a=ice-pwd:VlshLQuefuFgJ244f8Oxn+00
a=ice-options:trickle renomination
a=fingerprint:sha-256 3E:A3:12:2D:2B:A4:A3:8E:F8:81:49:7D:1A:8B:30:32:EE:16:F4:C2:3E:60:53:28:70:F3:F9:5C:B6:1D:3F:FB
a=setup:actpass
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=sendrecv
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
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:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:112 telephone-event/32000
a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000
a=ssrc:509420374 cname:x453Wkh4ZHn5LRuV
a=ssrc:509420374 msid:Test Local Media Stream Test Audio Track
a=ssrc:509420374 mslabel:Test Local Media Stream
a=ssrc:509420374 label:Test Audio Track
但是當我刪除音頻的東西,或整個MediaStream,描述成爲這樣:
v=0
o=- 3918440358463799408 2 IN IP4 127.0.0.1
s=-
t=0 0
a=msid-semantic: WMS
它的工作原理。
任何想法可能是錯誤的?