protected override void OnPing(RtmpConnection connection, RtmpChannel channel, RtmpHeader source, Ping ping) { switch (ping.Value1) { case 3: { if (ping.Value2 == 0) { log.Warn("Unhandled ping: " + ping); break; } IClientStream streamById = null; if (connection is IStreamCapableConnection) { streamById = (connection as IStreamCapableConnection).GetStreamById(ping.Value2); } int bufferDuration = ping.Value3; if (streamById == null) { if (connection is RtmpServerConnection) { (connection as RtmpServerConnection).RememberStreamBufferDuration(ping.Value2, bufferDuration); } if (log.get_IsInfoEnabled()) { log.Info("Remembering client buffer on stream: " + bufferDuration); } break; } streamById.SetClientBufferDuration(bufferDuration); if (log.get_IsInfoEnabled()) { log.Info("Setting client buffer on stream: " + bufferDuration); } break; } case 7: connection.PingReceived(ping); break; default: log.Warn("Unhandled ping: " + ping); break; } }
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; } }
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; } }