如何修复 Android/Webrtc/PeerConnection/createOffer 中的 "m=video 9 UDP/TLS/RTP/SAVPF 0" 个问题
How to fix "m=video 9 UDP/TLS/RTP/SAVPF 0" issus in Android/Webrtc/PeerConnection/createOffer
如何get/enable webrtc/video-coding-format? (Android)
我正在尝试使用 media/vidio 创建 sdp-offer,但似乎没有返回支持 fmt:
m=video 9 UDP/TLS/RTP/SAVPF 0
它在一个应用程序(2 个对等连接)中使用数据通道和音频流。
部分代码:
// Media Constraint
MediaConstraints pcConstraints = new MediaConstraints();
pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("offerToReceiveAudio", "true"));
pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("offerToReceiveVideo", "true"));
MediaStream mediaStream = factory.createLocalMediaStream("MediaStream-"+name);
// Audio
AudioSource audioSource = factory.createAudioSource(new MediaConstraints());
mediaStream.addTrack(factory.createAudioTrack("Audio-"+name, audioSource));
// Video
videoTrackFromCamera = createVideoTrackFromCamera("Video-"+name);
if(videoTrackFromCamera!=null){
surfaceViewRenderer.init(rootEglBase.getEglBaseContext(), null);
surfaceViewRenderer.setMirror(true);
surfaceViewRenderer.setEnableHardwareScaler(true);
surfaceViewRenderer.setEnabled(true);
videoTrackFromCamera.addSink(surfaceViewRenderer);
mediaStream.addTrack(videoTrackFromCamera);
}
pc.addStream(mediaStream);
pc.createAnswer(sdpObserver, pcConstraints);
onCreateSuccess(SessionDescription),类型=要约,说明:
v=0
o=- 1829788378060179036 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE audio video data
a=msid-semantic: WMS MediaStream-First
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:Muza
a=ice-pwd:npxXusvEWRQtpS/hjmAoPGn+
a=ice-options:trickle renomination
a=fingerprint:sha-256 79:5F:F6:2A:42:53:41:38:C4:EC:15:0D:4E:D1:6C:3A:66:39:57:2B:78:BE:5B:2D:70:94:96:AA:98:86:D4:B1
a=setup:actpass
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
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:3451329273 cname:Jjbwj2+OSGEvw+Xc
a=ssrc:3451329273 msid:MediaStream-First Audio-First
a=ssrc:3451329273 mslabel:MediaStream-First
a=ssrc:3451329273 label:Audio-First
m=video 9 UDP/TLS/RTP/SAVPF 0
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:Muza
a=ice-pwd:npxXusvEWRQtpS/hjmAoPGn+
a=ice-options:trickle renomination
a=fingerprint:sha-256 79:5F:F6:2A:42:53:41:38:C4:EC:15:0D:4E:D1:6C:3A:66:39:57:2B:78:BE:5B:2D:70:94:96:AA:98:86:D4:B1
a=setup:actpass
a=mid:video
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=extmap:13 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 urn:3gpp:video-orientation
a=extmap:2 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
a=extmap:8 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07
a=extmap:9 http://www.webrtc.org/experiments/rtp-hdrext/color-space
a=sendrecv
a=rtcp-mux
a=rtcp-rsize
a=ssrc:2429683820 cname:Jjbwj2+OSGEvw+Xc
a=ssrc:2429683820 msid:MediaStream-First Video-First
a=ssrc:2429683820 mslabel:MediaStream-First
a=ssrc:2429683820 label:Video-First
m=application 9 DTLS/SCTP 5000
c=IN IP4 0.0.0.0
a=ice-ufrag:Muza
a=ice-pwd:npxXusvEWRQtpS/hjmAoPGn+
a=ice-options:trickle renomination
a=fingerprint:sha-256 79:5F:F6:2A:42:53:41:38:C4:EC:15:0D:4E:D1:6C:3A:66:39:57:2B:78:BE:5B:2D:70:94:96:AA:98:86:D4:B1
a=setup:actpass
a=mid:data
a=sctpmap:5000 webrtc-datachannel 1024
您似乎必须在创建 PeerConnectionFactory 时设置 VideoDecoderFactory
和 VideoEncoderFactory
:
WebRTCPeerConnectionDelegate(Context context) {
this.context = context;
PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions.builder(this.context)
.setEnableInternalTracer(false)
.createInitializationOptions());
EglBase.Context eglContext = EglBase.create().getEglBaseContext();
VideoDecoderFactory videoDecoderFactory = new DefaultVideoDecoderFactory(eglContext);
VideoEncoderFactory videoEncoderFactory = new DefaultVideoEncoderFactory(eglContext, true, true);
peerConnectionFactory = PeerConnectionFactory.builder()
.setVideoDecoderFactory(videoDecoderFactory)
.setVideoEncoderFactory(videoEncoderFactory)
.createPeerConnectionFactory();
}
如何get/enable webrtc/video-coding-format? (Android)
我正在尝试使用 media/vidio 创建 sdp-offer,但似乎没有返回支持 fmt:
m=video 9 UDP/TLS/RTP/SAVPF 0
它在一个应用程序(2 个对等连接)中使用数据通道和音频流。
部分代码:
// Media Constraint
MediaConstraints pcConstraints = new MediaConstraints();
pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("offerToReceiveAudio", "true"));
pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("offerToReceiveVideo", "true"));
MediaStream mediaStream = factory.createLocalMediaStream("MediaStream-"+name);
// Audio
AudioSource audioSource = factory.createAudioSource(new MediaConstraints());
mediaStream.addTrack(factory.createAudioTrack("Audio-"+name, audioSource));
// Video
videoTrackFromCamera = createVideoTrackFromCamera("Video-"+name);
if(videoTrackFromCamera!=null){
surfaceViewRenderer.init(rootEglBase.getEglBaseContext(), null);
surfaceViewRenderer.setMirror(true);
surfaceViewRenderer.setEnableHardwareScaler(true);
surfaceViewRenderer.setEnabled(true);
videoTrackFromCamera.addSink(surfaceViewRenderer);
mediaStream.addTrack(videoTrackFromCamera);
}
pc.addStream(mediaStream);
pc.createAnswer(sdpObserver, pcConstraints);
onCreateSuccess(SessionDescription),类型=要约,说明:
v=0
o=- 1829788378060179036 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE audio video data
a=msid-semantic: WMS MediaStream-First
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:Muza
a=ice-pwd:npxXusvEWRQtpS/hjmAoPGn+
a=ice-options:trickle renomination
a=fingerprint:sha-256 79:5F:F6:2A:42:53:41:38:C4:EC:15:0D:4E:D1:6C:3A:66:39:57:2B:78:BE:5B:2D:70:94:96:AA:98:86:D4:B1
a=setup:actpass
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
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:3451329273 cname:Jjbwj2+OSGEvw+Xc
a=ssrc:3451329273 msid:MediaStream-First Audio-First
a=ssrc:3451329273 mslabel:MediaStream-First
a=ssrc:3451329273 label:Audio-First
m=video 9 UDP/TLS/RTP/SAVPF 0
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:Muza
a=ice-pwd:npxXusvEWRQtpS/hjmAoPGn+
a=ice-options:trickle renomination
a=fingerprint:sha-256 79:5F:F6:2A:42:53:41:38:C4:EC:15:0D:4E:D1:6C:3A:66:39:57:2B:78:BE:5B:2D:70:94:96:AA:98:86:D4:B1
a=setup:actpass
a=mid:video
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=extmap:13 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 urn:3gpp:video-orientation
a=extmap:2 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
a=extmap:8 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07
a=extmap:9 http://www.webrtc.org/experiments/rtp-hdrext/color-space
a=sendrecv
a=rtcp-mux
a=rtcp-rsize
a=ssrc:2429683820 cname:Jjbwj2+OSGEvw+Xc
a=ssrc:2429683820 msid:MediaStream-First Video-First
a=ssrc:2429683820 mslabel:MediaStream-First
a=ssrc:2429683820 label:Video-First
m=application 9 DTLS/SCTP 5000
c=IN IP4 0.0.0.0
a=ice-ufrag:Muza
a=ice-pwd:npxXusvEWRQtpS/hjmAoPGn+
a=ice-options:trickle renomination
a=fingerprint:sha-256 79:5F:F6:2A:42:53:41:38:C4:EC:15:0D:4E:D1:6C:3A:66:39:57:2B:78:BE:5B:2D:70:94:96:AA:98:86:D4:B1
a=setup:actpass
a=mid:data
a=sctpmap:5000 webrtc-datachannel 1024
您似乎必须在创建 PeerConnectionFactory 时设置 VideoDecoderFactory
和 VideoEncoderFactory
:
WebRTCPeerConnectionDelegate(Context context) {
this.context = context;
PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions.builder(this.context)
.setEnableInternalTracer(false)
.createInitializationOptions());
EglBase.Context eglContext = EglBase.create().getEglBaseContext();
VideoDecoderFactory videoDecoderFactory = new DefaultVideoDecoderFactory(eglContext);
VideoEncoderFactory videoEncoderFactory = new DefaultVideoEncoderFactory(eglContext, true, true);
peerConnectionFactory = PeerConnectionFactory.builder()
.setVideoDecoderFactory(videoDecoderFactory)
.setVideoEncoderFactory(videoEncoderFactory)
.createPeerConnectionFactory();
}