gpt4 book ai didi

android - WebRTC - 创建 PeerConnectionFactory 对象

转载 作者:行者123 更新时间:2023-12-02 16:53:35 24 4
gpt4 key购买 nike

我之前使用过 WebRTC 1.0.22672,现在我切换到最新版本 1.0.26885。之前我使用此代码创建 PeerConnectionFactory 和 VideoSource 对象,并且工作正常:

PeerConnectionFactory.InitializationOptions initializationOptions =
PeerConnectionFactory.InitializationOptions.builder(this)
.createInitializationOptions();
PeerConnectionFactory.initialize(initializationOptions);

//Create a new PeerConnectionFactory instance - using Hardware encoder and decoder.
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
DefaultVideoEncoderFactory defaultVideoEncoderFactory = new DefaultVideoEncoderFactory(
rootEglBase.getEglBaseContext(), /* enableIntelVp8Encoder */true, /* enableH264HighProfile */true);
DefaultVideoDecoderFactory defaultVideoDecoderFactory = new DefaultVideoDecoderFactory(rootEglBase.getEglBaseContext());
peerConnectionFactory = new PeerConnectionFactory(options, defaultVideoEncoderFactory, defaultVideoDecoderFactory);


//Now create a VideoCapturer instance.
VideoCapturer videoCapturerAndroid;
videoCapturerAndroid = createCameraCapturer(new Camera1Enumerator(false));


//Create MediaConstraints - Will be useful for specifying video and audio constraints.
audioConstraints = new MediaConstraints();
videoConstraints = new MediaConstraints();

//Create a VideoSource instance
if (videoCapturerAndroid != null) {
videoSource = peerConnectionFactory.createVideoSource(videoCapturerAndroid);
}

但在最新版本中,我在 new PeerConnectionFactory... 上有两个错误上面写着:

'PeerConnectionFactory(long)' is not public in 'org.webrtc.PeerConnectionFactory'. Cannot be accessed from outside package

以及peerConnectionFactory.createVideoSource...

那个syas:

createVideoSource (boolean) in PeerConnectionFactory cannot be applied to (org.webrtc.VideoCapturer)  

如何解决这些错误?

有人可以告诉我为什么没有 Android 原生 WebRTC 的文档或更改日志吗?!

最佳答案

How can i solve these errors?

WebRTC 最新版本中已弃用或删除了许多 API。请执行以下步骤来解决这些错误。

第 1 步:更改代码

peerConnectionFactory = new PeerConnectionFactory(options, defaultVideoEncoderFactory, defaultVideoDecoderFactory);

peerConnectionFactory = PeerConnectionFactory.builder()
.setOptions(options)
.setVideoEncoderFactory(defaultVideoEncoderFactory)
.setVideoDecoderFactory(defaultVideoDecoderFactory)
.createPeerConnectionFactory();

第 2 步:更改代码

//Create a VideoSource instance
if (videoCapturerAndroid != null) {
videoSource = peerConnectionFactory.createVideoSource(videoCapturerAndroid);
}

//Create a VideoSource instance
if (videoCapturerAndroid != null) {
SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("CaptureThread", rootEglBase.getEglBaseContext());
videoSource = peerConnectionFactory.createVideoSource(videoCapturerAndroid.isScreencast());
videoCapturerAndroid.initialize(surfaceTextureHelper, getApplicationContext(), videoSource.getCapturerObserver());
}

Can someone tell my WHY there is no documentation or change-log for android native WebRTC?

更改日志位于

https://webrtc.googlesource.com/src/+log

注意:关于您的问题,您可以点击以下链接了解更多详情。

https://groups.google.com/forum/#!topic/discuss-webrtc/gwJP5Sf0cdE

关于android - WebRTC - 创建 PeerConnectionFactory 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55085726/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com