The issue I am having is that my Xamarin Forms custom renderer for the Android SurfaceViewRenderer does not have the same aspect ratio as the remote video it displays. This causes the video to have an equal portion of both sides cut off. I have tried looking at the SurfaceChanged event of the SurfaceViewRenderer but the width and height are related to the SurfaceView itself and not the video track that it is the sink to.
In my OnAddStream function of my peer connection observer I can see the MediaStream object and the related remote VideoTrack. Here is the area of code I believe will be most relevant:
public void OnAddStream(MediaStream p0)
{
System.Diagnostics.Debug.WriteLine($"{nameof(OnAddStream)}");
try
{
var videoTracks = p0.VideoTracks.OfType<VideoTrack>();
videoTracks.FirstOrDefault().AddSink(_remoteView);
var theRemoteSurface = _remoteView.Holder.SurfaceFrame;
var metrics = Resources.System.DisplayMetrics;
// this is wrong and should be the remote video aspect ratio
decimal remoteRatio = decimal.Divide((theRemoteSurface.Right - theRemoteSurface.Left), (theRemoteSurface.Bottom - theRemoteSurface.Top));
decimal myRatio = decimal.Divide(metrics.WidthPixels, metrics.HeightPixels);
var audioTracks = p0.AudioTracks.OfType<AudioTrack>();
audioTracks.FirstOrDefault().SetEnabled(true);
audioTracks.FirstOrDefault().SetVolume(10);
}
catch (Exception ex)
{
}
}