示例#1
0
        protected override void OnPing(RtmpConnection connection, RtmpChannel channel, RtmpHeader source, Ping ping)
        {
            switch (ping.PingType)
            {
            case Ping.ClientBuffer:
                IClientStream stream = null;
                // Get the stream id
                int streamId = ping.Value2;
                // Get requested buffer size in milliseconds
                int buffer = ping.Value3;
                if (streamId != 0)
                {
                    // The client wants to set the buffer time
                    stream = connection.GetStreamById(streamId);
                    if (stream != null)
                    {
                        stream.SetClientBufferDuration(buffer);
                        if (log.IsDebugEnabled)
                        {
                            log.Debug(string.Format("Client sent a buffer size: {0} ms for stream id: {1}", buffer, streamId));
                        }
                    }
                }
                // Catch-all to make sure buffer size is set
                if (stream == null)
                {
                    // Remember buffer time until stream is created
                    connection.RememberStreamBufferDuration(streamId, buffer);
                    if (log.IsDebugEnabled)
                    {
                        log.Debug(string.Format("Remembering client buffer size: {0} on stream id: {1} ", buffer, streamId));
                    }
                }
                break;

            case Ping.PongServer:
                // This is the response to an IConnection.Ping request
                connection.PingReceived(ping);
                break;

            default:
                log.Warn("Unhandled ping: " + ping);
                break;
            }
        }
示例#2
0
 protected override void OnPing(RtmpConnection connection, RtmpChannel channel, RtmpHeader source, Ping ping)
 {
     switch (ping.PingType)
     {
         case Ping.ClientBuffer:
             IClientStream stream = null;
             // Get the stream id
             int streamId = ping.Value2;
             // Get requested buffer size in milliseconds
             int buffer = ping.Value3;
             if (streamId != 0)
             {
                 // The client wants to set the buffer time
                 stream = connection.GetStreamById(streamId);
                 if (stream != null)
                 {
                     stream.SetClientBufferDuration(buffer);
                     if (log.IsDebugEnabled)
                         log.Debug(string.Format("Client sent a buffer size: {0} ms for stream id: {1}", buffer, streamId ));
                 }
             }
             // Catch-all to make sure buffer size is set
             if (stream == null)
             {
                 // Remember buffer time until stream is created
                 connection.RememberStreamBufferDuration(streamId, buffer);
                 if (log.IsDebugEnabled)
                     log.Debug(string.Format("Remembering client buffer size: {0} on stream id: {1} ", buffer, streamId));
             }
             break;
         case Ping.PongServer:
             // This is the response to an IConnection.Ping request
             connection.PingReceived(ping);
             break;
         default:
             log.Warn("Unhandled ping: " + ping);
             break;
     }
 }