Beispiel #1
0
 private NativeTransform.TransformCompletedCallback GetCallback(TaskCompletionSource <MediaPacket> tcs,
                                                                MediaPacket source)
 {
     return((nativehandle, errorCode, _) =>
     {
         if (errorCode == ImageUtilError.None)
         {
             try
             {
                 tcs.TrySetResult(MediaPacket.From(Marshal.PtrToStructure <IntPtr>(nativehandle)));
             }
             catch (Exception e)
             {
                 tcs.TrySetException(e);
             }
         }
         else if (errorCode == ImageUtilError.NotSupportedFormat)
         {
             tcs.TrySetException(new NotSupportedException(
                                     GenerateNotSupportedErrorMessage(source.Format as VideoMediaFormat)));
         }
         else
         {
             tcs.TrySetException(errorCode.ToException("Image transformation failed"));
         }
     });
 }
Beispiel #2
0
 internal OutputAvailableEventArgs(IntPtr packetHandle)
 {
     Packet = MediaPacket.From(packetHandle);
 }
Beispiel #3
0
        private void RegisterVideoFrameEncodedCallback()
        {
            _webRtcVideoFrameEncodedCallback = (handle, type, id, packet, _) =>
            {
                Log.Info(WebRTCLog.Tag, $"Track type[{type}], id[{id}]");

                _videoFrameEncoded?.Invoke(this,
                                           new WebRTCFrameEncodedEventArgs(new MediaStreamTrack(this, type, id), MediaPacket.From(packet)));
            };

            NativeWebRTC.SetVideoFrameEncodedCb(Handle, _webRtcVideoFrameEncodedCallback).
            ThrowIfFailed("Failed to set video frame encoded callback.");
        }