golanggohlsrtmpwebrtcmedia-serverobs-studiortcprtmp-proxyrtmp-serverrtprtsprtsp-proxyrtsp-relayrtsp-serversrtstreamingwebrtc-proxy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.3 KiB
80 lines
2.3 KiB
package handshake |
|
|
|
import ( |
|
"bytes" |
|
"testing" |
|
|
|
"github.com/stretchr/testify/require" |
|
) |
|
|
|
func TestC1S1Read(t *testing.T) { |
|
c1s1dec := C1S1{ |
|
Time: 435234723, |
|
Random: append( |
|
[]byte{ |
|
0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, |
|
0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x2d, 0x0a, |
|
0x37, 0x6f, 0x63, 0x2e, 0xa0, 0x21, 0xa0, 0xa4, |
|
0x81, 0xb1, 0x50, 0x21, 0x5a, 0x6d, 0x81, 0xad, |
|
0xf8, 0x44, 0x69, 0x13, 0xcc, 0x02, 0x8c, 0xd4, |
|
0x64, 0x43, 0xc9, 0x9f, 0xcf, 0xc6, 0x03, 0x04, |
|
}, |
|
bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04}, 370)..., |
|
), |
|
Digest: []byte{ |
|
0x3f, 0xd0, 0xb1, 0xdf, 0xed, 0x6c, 0x9b, 0xc3, |
|
0x73, 0x68, 0xe2, 0x47, 0x92, 0x59, 0x32, 0x9a, |
|
0x3a, 0xc9, 0x1e, 0xeb, 0xfc, 0xad, 0x8e, 0x9d, |
|
0x4e, 0xf4, 0x30, 0xb1, 0x9a, 0xc9, 0x15, 0x99, |
|
}, |
|
} |
|
|
|
c1s1enc := append( |
|
[]byte{ |
|
0x19, 0xf1, 0x27, 0xa3, 0x00, 0x00, 0x00, 0x00, |
|
0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, |
|
0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x2d, 0x0a, |
|
0x37, 0x6f, 0x63, 0x2e, 0xa0, 0x21, 0xa0, 0xa4, |
|
0x81, 0xb1, 0x50, 0x21, 0x5a, 0x6d, 0x81, 0xad, |
|
0xf8, 0x44, 0x69, 0x13, 0xcc, 0x02, 0x8c, 0xd4, |
|
0x64, 0x43, 0xc9, 0x9f, 0xcf, 0xc6, 0x03, 0x04, |
|
}, |
|
bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04}, 370)..., |
|
) |
|
|
|
var c1s1 C1S1 |
|
err := c1s1.Read(bytes.NewReader(c1s1enc), true) |
|
require.NoError(t, err) |
|
require.Equal(t, c1s1dec, c1s1) |
|
} |
|
|
|
func TestC1S1Write(t *testing.T) { |
|
c1s1dec := C1S1{ |
|
Time: 435234723, |
|
Random: bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04}, 382), |
|
Digest: []byte{ |
|
0x3f, 0xd0, 0xb1, 0xdf, 0xed, 0x6c, 0x9b, 0xc3, |
|
0x73, 0x68, 0xe2, 0x47, 0x92, 0x59, 0x32, 0x9a, |
|
0x3a, 0xc9, 0x1e, 0xeb, 0xfc, 0xad, 0x8e, 0x9d, |
|
0x4e, 0xf4, 0x30, 0xb1, 0x9a, 0xc9, 0x15, 0x99, |
|
}, |
|
} |
|
|
|
c1s1enc := append( |
|
[]byte{ |
|
0x19, 0xf1, 0x27, 0xa3, 0x00, 0x00, 0x00, 0x00, |
|
0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, |
|
0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x2d, 0x0a, |
|
0x37, 0x6f, 0x63, 0x2e, 0xa0, 0x21, 0xa0, 0xa4, |
|
0x81, 0xb1, 0x50, 0x21, 0x5a, 0x6d, 0x81, 0xad, |
|
0xf8, 0x44, 0x69, 0x13, 0xcc, 0x02, 0x8c, 0xd4, |
|
0x64, 0x43, 0xc9, 0x9f, 0xcf, 0xc6, 0x03, 0x04, |
|
}, |
|
bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04}, 370)..., |
|
) |
|
|
|
var buf bytes.Buffer |
|
err := c1s1dec.Write(&buf, true) |
|
require.NoError(t, err) |
|
require.Equal(t, c1s1enc, buf.Bytes()) |
|
}
|
|
|