首页 > 解决方案 > RTSP Socks 协议无效响应

问题描述

我在RTSP Describe使用 Socks 协议获得选项的响应时遇到问题。我得到了回应,选择但不是描述。例如,我关注了 wiki OPTIONS、DESCRIBE、SETUP、PLAY、TEARDOWN、GET_PARAMETER、SET_PARAMETER,我几乎在所有地方都得到了 200 响应,只是不在DESCRIBE

以下是实现:

StreamUtils.WriteLine(bufferedNetStream, stringBuilder.ToString());
RtspResponse rtspResponse = this.ReceiveResponse(bufferedNetStream);

这是缓冲流的读取实现:

public BufferedNetStream(TcpSocket sock, bool ownsSocket)
    {
        this.m_Socket = sock;
        this.m_ownsSocket = ownsSocket;
    }

    public override void Write(byte[] buffer, int offset, int count)
    {
        try
        {
            this.m_Socket.Send(buffer, offset, count);
        }
        catch (Exception exception)
        {
            this.lastExcept = exception;
        }
    }

    public static void WriteLine(Stream stream, string line)
    {
        byte[] bytes = Encoding.Default.GetBytes(string.Concat(line, "\r\n"));
        stream.Write(bytes, 0, (int)bytes.Length);
        stream.Flush();
        stream.Seek(0, SeekOrigin.Begin);
    }

    public override int Read(byte[] buffer, int offset, int size)
    {
        int num;
        this.lastExcept = null;
        if (this.dataBuffer != null)
        {
            int num1 = Math.Min(size, (int)this.dataBuffer.Length - this.dataOffset);
            Array.Copy(this.dataBuffer, this.dataOffset, buffer, offset, num1);
            offset += num1;
            this.dataOffset += num1;
            while (num1 < size)
            {
                this.dataBuffer = this.m_Socket.ReceivePacket();
                if (this.m_Socket.LastException != null)
                {
                    string stackTrace = this.m_Socket.LastException.StackTrace;
                    this.lastExcept = this.m_Socket.LastException;
                    num = num1;
                    return num;
                }
                else if (this.dataBuffer != null)
                {
                    this.dataOffset = 0;
                    if ((int)this.dataBuffer.Length != 0)
                    {
                        int num2 = Math.Min(size - num1, (int)this.dataBuffer.Length - this.dataOffset);
                        Array.Copy(this.dataBuffer, 0, buffer, offset, num2);
                        num1 += num2;
                        offset += num2;
                        this.dataOffset += num2;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    num = num1;
                    return num;
                }
            }
            num = num1;
        }
        else
        {
            num = 0;
        }
        return num;
    }

标签: c#rtsp

解决方案


推荐阅读