protected override bool PerformHandshake(InputStream buffer)
{
switch (_rtmpState)
{
case RTMPState.RTMP_STATE_NOT_INITIALIZED:
return PerformHandshakeStage1((string)CustomParameters[Defines.CONF_PROTOCOL] == Defines.CONF_PROTOCOL_OUTBOUND_RTMPE);
case RTMPState.RTMP_STATE_CLIENT_REQUEST_SENT:
if (buffer.AvaliableByteCounts < 3073) return true;
_usedScheme = (byte) ((string) CustomParameters[Defines.CONF_PROTOCOL] ==
Defines.CONF_PROTOCOL_OUTBOUND_RTMPE? 1: 0);
if (!PerformHandshakeStage2(buffer, _usedScheme==1))
{
Logger.FATAL("Unable to handshake");
return false;
}
if (!EnqueueForOutbound(OutputBuffer))
{
Logger.FATAL("Unable to signal output data");
return false;
}
if (_pKeyIn != null && _pKeyOut != null)
{
var pRTMPE = new RTMPEProtocol(_pKeyIn, _pKeyOut, (uint)OutputBuffer.Length);
ResetFarProtocol();
_farProtocol.NearProtocol = pRTMPE;
pRTMPE.NearProtocol = this;
this.Log().Info("New protocol chain:{0}",_farProtocol);
}
buffer.Ignore(3073);
_handshakeCompleted = true;
return true;
default:
Logger.FATAL("Invalid RTMP state:{0}",_rtmpState);
return false;
}
}