Ejemplo n.º 1
0
 private void OnCapturedVideoFrame(object sender, VideoEventAgrs e)
 {
     //如果开启了美颜
     if (beauty_)
     {
         uint size = Convert.ToUInt32(e.Frame.Width * e.Frame.Height * 3 / 2);
         //处理数据
         byte[] i420 = NIMDemo.LivingStreamSDK.YUVHelper.ARGBToI420(e.Frame.Data, e.Frame.Width, e.Frame.Height);
         Beauty.Smooth.smooth_process(i420, e.Frame.Width, e.Frame.Height, 10, 0, 200);
         e.Frame.Data = NIMDemo.LivingStreamSDK.YUVHelper.I420ToARGB(i420, e.Frame.Width, e.Frame.Height);
         try
         {
             //发送自定义数据
             TimeSpan ts   = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
             ulong    time = Convert.ToUInt64(ts.TotalMilliseconds);
             NIMDemo.LivingStreamSDK.YUVHelper.i420Revert(ref i420, e.Frame.Width, e.Frame.Height);
             IntPtr unmanagedPointer = Marshal.AllocHGlobal(i420.Length);
             Marshal.Copy(i420, 0, unmanagedPointer, i420.Length);
             NIM.DeviceAPI.CustomVideoData(time, unmanagedPointer, size, (uint)e.Frame.Width, (uint)e.Frame.Height, null);
             Marshal.FreeHGlobal(unmanagedPointer);
         }
         catch (Exception ex)
         {
         }
         //本地显示数据
         ShowVideoFrame(_mineRegionGraphics, minePicBox.Width, minePicBox.Height, e.Frame);
     }
     else
     {
         ShowVideoFrame(_mineRegionGraphics, minePicBox.Width, minePicBox.Height, e.Frame);
     }
 }
Ejemplo n.º 2
0
 private void OnReceivedVideoFrame(object sender, VideoEventAgrs args)
 {
     ShowVideoFrame(_peerRegionGraphics, peerPicBox.Width, peerPicBox.Height, args.Frame);
 }