public override bool SignalInputData(int recAmount)
{
while (InputBuffer.AvaliableByteCounts > 0)
{
switch (_state)
{
case RtspState.InterleavedHeader:
//6. Do we have enough data?
if (InputBuffer.AvaliableByteCounts < _rtpDataLength)
{
return true;
}
_state = RtspState.Playload;
goto case RtspState.Playload;
case RtspState.NormalHeader:
ParseNormalHeaders();
if (_state != RtspState.Playload)
return true;
goto case RtspState.Playload;
case RtspState.Header:
if (InputBuffer.Reader.PeekChar() == '$')
{
//1. Marl this as a interleaved content
_rtpData = true;
//2. Do we have at least 4 bytes ($ sign, channel byte an 2-bytes length)?
var bufferLength = InputBuffer.AvaliableByteCounts;
if (bufferLength < 4) return true;
//3. Get the buffer
InputBuffer.Reader.ReadByte();
//4. Get the channel id
_rtpDataChanel = InputBuffer.Reader.ReadByte();
//5. Get the packet length
_rtpDataLength = InputBuffer.Reader.ReadUInt16();
if (_rtpDataLength > 8192)
{
FATAL("RTP data length too big");
return false;
}
//6. Do we have enough data?
if (_rtpDataLength + 4 > bufferLength)
{
_state = RtspState.InterleavedHeader;
return true;
}
_state = RtspState.Playload;
goto case RtspState.Playload;
}
_state = RtspState.NormalHeader;
goto case RtspState.NormalHeader;
case RtspState.Playload:
if (_rtpData)
{
if (InboundConnectivity != null)
{
if (!InboundConnectivity.FeedData(
_rtpDataChanel, InputBuffer, _rtpDataLength))
{
FATAL("Unable to handle raw RTP packet");
return false;
}
}
else
{
InputBuffer.Ignore(_rtpDataLength);
}
_state = RtspState.Header;
}
else
{
if (!HandleRTSPMessage())
{
FATAL("Unable to handle content");
return false;
}
}
break;
}
}
return false;
}