我正在使用Linphone实现视频通话。我可以在手机中捕捉摄像头,并在应用程序中显示视频预览。但我需要在客户端摄像头中捕捉视频的预览。我通过纹理视图捕捉视频。这是我的纹理视图代码,我在其中显示我的摄像头
async Task PrepareSession()
{
IsBusy = true;
try
{
CloseSession();
sessionBuilder = device.CreateCaptureRequest(cameraTemplate);
List<Surface> surfaces = new List<Surface>();
if (texture.IsAvailable && previewSize != null)
{
LinearLayout fl = new LinearLayout(this.Context);
ViewGroup.LayoutParams lparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
fl.LayoutParameters = lparams;
displayCamera = new TextureView(this.Context);
ViewGroup.LayoutParams dparams = new ViewGroup.LayoutParams(100, 100);
displayCamera.LayoutParameters = dparams;
captureCamera = new TextureView(this.Context);
ViewGroup.LayoutParams cparams = new ViewGroup.LayoutParams(100, 100);
captureCamera.LayoutParameters = cparams;
fl.AddView(displayCamera);
fl.AddView(captureCamera);
var texture = this.texture.SurfaceTexture;
texture.SetDefaultBufferSize(previewSize.Width, previewSize.Height);
Core.VideoDisplayEnabled = true;
Core.VideoCaptureEnabled = true;
Core.NativeVideoWindowId = displayCamera.Handle;
Core.NativePreviewWindowId = captureCamera.Handle;
Surface previewSurface = new Surface(texture);
surfaces.Add(previewSurface);
sessionBuilder.AddTarget(previewSurface);
}
这是Linphone代码,通过它他们显示客户端摄像头的视频预览。
TextureView captureCamera;
LinearLayout fl = new LinearLayout(this);
ViewGroup.LayoutParams lparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
fl.LayoutParameters = lparams;
captureCamera = new TextureView(this);
ViewGroup.LayoutParams cparams = new ViewGroup.LayoutParams(320, 240);
captureCamera.LayoutParameters = cparams;
fl.AddView(captureCamera);
app.getLayoutView().Children.Add(fl);
app.Core.NativePreviewWindowId = captureCamera.Handle;
app.Core.VideoCaptureEnabled = true;
我已经尝试了以下代码组合
Core.NativeVideoWindowId = texture.Handle;
我得到的对象找不到异常的Core.NativeVideoWindowId。我如何可以添加视频预览直接在布局中,并简单地得到它的ID。我已经通过了以下链接。
https://github.com/BelledonneCommunications/linphone-xamarin
How to show a textureview through stacklayout in xamarin forms?
https://gitlab.linphone.org/BC/public/tutorials
我不知道怎么解决这个问题。有什么建议吗?
1条答案
按热度按时间eulz3vhy1#
如果要显示远程视频视图,必须使用Core.NativeVideoWindowId,而不是Core. NativePreviewWindowId。您真的应该看看我们的教程,这将帮助您更好地了解我们的API是如何工作的:https://gitlab.linphone.org/BC/public/tutorials
顺祝商祺!