Xamarin固有の問題かネイティブな問題か分かりません。ios h264ビデオレンダリングがうまくいき、15回再開しました。ビデオが見えなくなりました。
私は自分のViewRendererを作成しており、OnElementChangedは私のUIImageViewです。
base.OnElementChanged(e);
Foundation.NSError error;
var session = AVFoundation.AVAudioSession.SharedInstance();
session.SetCategory(AVFoundation.AVAudioSession.CategoryPlayAndRecord, out error);
if (error != null)
{
ClientLogger.Instance.Log("Error im MediaViewRenderer creating AV session, error code: " + error.Code, ClientLogger.LogLevel.Error);
}
//_control = e.NewElement as CustomMediaView;
UIKit.UIImageView surface = new UIKit.UIImageView();
if (surface != null)
{
this.SetNativeControl(surface);
それは私がレンダリングするたびにnullをセットバインドされ、フレームの場合、私は私のvideolayerを作成します。
if (_surface != null)
{
if (_videoLayer == null && IsRunning)
{
_videoLayer = new AVSampleBufferDisplayLayer();
_videoLayer.VideoGravity = AVLayerVideoGravity.ResizeAspect.ToString();
_timeBase = new CMTimebase(CMClock.HostTimeClock);
_videoLayer.ControlTimebase = _timeBase;
_videoLayer.ControlTimebase.Time = CMTime.Zero;
_videoLayer.ControlTimebase.Rate = 1.0;
_surface.Layer.AddSublayer(_videoLayer);
}
if (_videoLayer != null)
{
//if (_videoLayer.VisibleRect == null || _videoLayer.VisibleRect.Height == 0 || _videoLayer.VisibleRect.Width == 0)
// ClientLogger.Instance.Log("Error iOS H264Decoder rect", ClientLogger.LogLevel.Error);
_videoLayer.Frame = _surface.Frame;
_videoLayer.Bounds = _surface.Bounds;
}
私は私のRTPストリームとデコードを受け、それがここdescripedされるように私のビデオを表示します。
How to use VideoToolbox to decompress H.264 video stream
私はビデオを停止したい場合は、私はあまりにも、nullに後でsurafceをvideolayerを設定します。
_videoLayer.Flush();
_videoLayer.Dispose();
_videoLayer = null;
_surface.Dispose();
_surface = null;
これはうまく動作し、私に約15回の素晴らしいH264ビデオを提供します。
その後、空白の背景のみが表示されます。ビデオは表示されません。デコーダーが正常に動作し、レンダリングされているように見えます。サーフェスとビデオレイヤーはnullではありません。
メモリホールがないか、少なくともサイズ問題ではないようです。
iOS 9と10の両方で発生します。 ビデオレイヤーに問題があると思いますか?
なぜ15回程度しか動作しないのでしょうか?
ありがとうございました!
これは本当に面白いです。再生しているビデオについてもっと教えていただけますか? – Feign