1

Based on the Linphone Windows 10 app implementation, I am able to view remote and local video by setting the properties Linphone.Core.NativeVideoWindowId and NativePreviewVideoWindowId to the respective Name:s of two Windows.UI.Xaml.Controls.SwapChainPanel controls.

When using Linphone in a corresponding Xamarin Android or iOS app, which UI control(s) should then be used, and which control property should be used to define the NativeVideoWindowId and NativePreviewVideoWindowId on those platforms?

Anders Gustafsson
  • 15,837
  • 8
  • 56
  • 114

2 Answers2

2

I have had the similar question.

Android:

videoView = new GL2JNIView(context);
surfaceView = new SurfaceView(context);

Assigning via the custom renderer, for example ViewRenderer<CameraPreview, Droid.Lib.CameraPreview>

iOS:

 var wrapper = (Xamarin.Forms.Platform.iOS.NativeViewWrapper)contentViewVideoParent.Content;
                var videoview = (UIView)wrapper.NativeView;

And assigning IntPtr videoview.Handle to the linphone view.

DigitApps
  • 81
  • 8
1

I have fixed same problem, with your answer, but I think in this example is some code missing (for next person, with the same problem), so I post the code which worked for me.

for iOS:


AppDelegate.cs (iOS project)

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
    global::Xamarin.Forms.Forms.Init();
    LoadApplication(new App(IntPtr.Zero));
    View view = null;
    UIView iView = new UIView(new RectangleF(0,0,640,480));
    view = iView.ToView();
    ((App)App.Current).ViedoFrame().Content = view;
    NativeViewWrapper wrapper = (NativeViewWrapper)((App)App.Current).ViedoFrame().Content;
    UIView uiView = (UIView)wrapper.NativeView;
    ((App)App.Current).Core.NativePreviewWindowId = uiView.Handle;
    ((App)App.Current).Core.VideoDisplayEnabled = true;
    ((App)App.Current).Core.VideoPreviewEnabled = true;
    
    return base.FinishedLaunching(app, options);
}

App.cs (shared project)

public partial class App : Application
{
    ...
    
    public Page MainPageContent;
    
    public App(IntPtr context)
    {
        InitializeComponent();
        MainPageContent = new MainPage();
        MainPage = new NavigationPage(MainPageContent);
    }
    
    public ContentView ViedoFrame()
    {
        return MainPageContent.FindByName<ContentView>("video_frame");
    }
    
    ...
}

MainPage.xaml (shared project)

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Kiwi"
             x:Class="Project.Linphone"
             Title="KiwiDoorUni">
             
    <ContentPage.ToolbarItems>
        ...
    </ContentPage.ToolbarItems>
    
    <StackLayout>
        ...
        <ContentView x:Name="video_frame">
        <!-- leave blank, UIView will be inserted here -->
        </ContentView>
    </StackLayout>
</ContentPage>

for android


i used the code from BelledonneCommunications in the Linphone Xamarin example project and it worked for me

example project can be found here:

https://github.com/BelledonneCommunications/linphone-xamarin

check the file: MainActivity.cs (android project)

KoiFresh
  • 11
  • 1
  • 1