Esempio n. 1
0
 protected virtual void TransmitVideo()
 {
     // Video frames will almost always be split up into multiple chunks, each of which will have multiple blocks.
     // The chunks that are ready for transmission are stored in the video codec's encodedChunks buffer.
     while (_videoEncodeResetEvent.WaitOne() && _isActive)
     {
         _videoEncodeResetEvent.Reset();
         if (_lastVideoFrame == null)
         {
             continue;
         }
         _videoEncoder.EncodeFrame(_lastVideoFrame, _lastStride);
         _lastVideoFrame = null;
         var buffer = _videoBufferPool.GetNext();
         try
         {
             bool moreChunks = true;
             while (moreChunks)
             {
                 buffer.Reset();
                 if (_videoEncoder.GetNextChunk(buffer, out moreChunks))
                 {
                     MediaConnection.SendVideoPacket(buffer);
                     Logger.LogVideoPacketSent(buffer);
                 }
             }
         }
         catch (Exception ex)
         {
             ClientLogger.Debug(ex.ToString);
         }
         finally
         {
             _videoBufferPool.Recycle(buffer);
         }
     }
 }