将本地媒体添加到对等连接时,我遇到了问题。当我将本地媒体添加到对等连接时,我在logcat中看到以下错误。
7-29 14:37:17.054:E / rtc(5482):#。/../ webrtc / modules / video_coding / main / source / video_sender.cc,第81行,
中的致命错误我打开video_sender.cc文件并完成了它。该行有评论 "注册要使用的发送编解码器。" 然后我理解了编解码器的一些问题。
如何在android中注册带有本地流的编解码器?
try (<obtain resource here>)
答案 0 :(得分:0)
试试这个..这对我来说非常合适......
private MediaStream localMS;
private PeerConnectionFactory factory;
public void setCamera() {
PeerConnectionFactory.initializeAndroidGlobals(listener, true, true,
params.videoCodecHwAcceleration, mEGLcontext);
factory = new PeerConnectionFactory();
localMS = factory.createLocalMediaStream("ARDAMS");
if (pcParams.videoCallEnabled) {
MediaConstraints videoConstraints = new MediaConstraints();
videoConstraints.mandatory.add(new MediaConstraints.KeyValuePair("maxHeight", Integer.toString(pcParams.videoHeight)));
videoConstraints.mandatory.add(new MediaConstraints.KeyValuePair("maxWidth", Integer.toString(pcParams.videoWidth)));
videoConstraints.mandatory.add(new MediaConstraints.KeyValuePair("maxFrameRate", Integer.toString(pcParams.videoFps)));
videoConstraints.mandatory.add(new MediaConstraints.KeyValuePair("minFrameRate", Integer.toString(pcParams.videoFps)));
videoSource = factory.createVideoSource(getVideoCapturer(), videoConstraints);
localMS.addTrack(factory.createVideoTrack("ARDAMSv0", videoSource));
}
AudioSource audioSource = factory.createAudioSource(new MediaConstraints());
localMS.addTrack(factory.createAudioTrack("ARDAMSa0", audioSource));
mListener.onLocalStream(localMS);
}
private VideoCapturer getVideoCapturer() {
String frontCameraDeviceName = VideoCapturerAndroid.getNameOfFrontFacingDevice();
return VideoCapturerAndroid.create(frontCameraDeviceName);
}