android - 如何修复 Android/Webrtc/PeerConnection/createOffer 中的“m=video 9 UDP/TLS/RTP/SAVPF 0”问题
问题描述
如何获取/启用 webrtc/video-coding-format?(安卓)
我正在尝试使用媒体/视频创建 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),Type=Offer,描述:
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();
}
推荐阅读
- datepicker - 如何解决 No component factory found 的 NgxMaterialTimepickerContainerComponent 错误?
- c# - 为什么当值类型可以为空时,ApiController 返回空字典?
- ios - FirebaseInstanceID ARC 语义问题 Swift Xcode
- python - 如何修复 python 添加不精确的数字
- javascript - 带有引导程序的 JavaScript 表过滤器
- android - 如何每 x 次或每次触发更新我的位置(如果可能)
- c - 如何在 Xamarin Forms 平台上应用行为
- ios - 重命名 Cocoapods 依赖项
- git - 关于github中的版本控制
- json - 使用 swift 从 JSON 中删除不需要的数据