android - android antmedia webrtc 将摄像头切换到屏幕共享,反之亦然
问题描述
我正在使用 Antmedia 官网提供的 webrtc-android-framework 模块。我能够建立连接,并且可以毫无问题地看到另一端发布的视频。但是我无法从相机切换到屏幕共享。我正在使用下面的代码从相机捕捉切换到屏幕共享。
public void MakeScreenCaptureReady() {
final EglBase.Context eglBaseContext = eglBase.getEglBaseContext();
PeerConnectionFactory peerConnectionFactory = peerConnectionClient.factory;
// create AudioSource
AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints());
this.audioTrack = peerConnectionFactory.createAudioTrack("101", audioSource);
surfaceTextureHelper = SurfaceTextureHelper.create("CaptureThread", eglBaseContext);
// create VideoCapturer
videoCapturer = createScreenCapturer();
VideoSource videoSource =
peerConnectionFactory.createVideoSource(videoCapturer.isScreencast());
localVideoTrack = peerConnectionFactory.createVideoTrack("118", videoSource);
videoCapturer.initialize(surfaceTextureHelper, context, videoSource.getCapturerObserver());
videoCapturer.startCapture(720, 1280, 30);
peerConnectionClient.setLocalVideoTrack(localVideoTrack);
peerConnectionClient.localVideoSender.setTrack(localVideoTrack, true); //true for taking ownership and replacing the existing track
}
它会将屏幕共享视频缓冲 2-3 秒,并source error
在订阅者端停止投掷。服务器上基本上没有可用的块来进一步缓冲。在点击上述代码之前,我已经获得了屏幕共享所需的权限。
startActivityForResult(
mMediaProjectionManager!!.createScreenCaptureIntent(),
SCREEN_RECORD_REQUEST_CODE
)
这是我用来在 onActivityResult 上调用上述方法的以下代码:
intent.putExtra(CallActivity.EXTRA_SCREENCAPTURE, true)
webRTCClient.setMediaProjectionParams(resultCode, data)
webRTCClient.MakeScreenCaptureReady()
如何实现相机和截屏的切换?任何帮助深表感谢。谢谢!
解决方案
推荐阅读
- r - R - 遍历目录会引发错误,但我不知道在哪里(尝试并捕获)
- scala - 如何根据变量中的另一列值检索列值
- python - 访问 PyTango 属性值
- java - 安卓 资源编译失败 v3.3
- java - 如何在@SuperBuilder 上使用 Lombok 的 toBuilder
- here-api - 检索流量计数
- c - 读入while循环
- c# - 是否可以防止数据库文件被外部删除/修改而无需在 c# 中打开它?
- listview - Focus timepicker by tapping on image in a list in xamarin.forms
- typescript - 类型'功能组件
' 不可分配给类型 '("input" & FunctionComponent