mirror of
https://github.com/lkmio/lkm.git
synced 2025-09-27 03:26:01 +08:00
41 lines
635 B
Go
41 lines
635 B
Go
package rtmp
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"github.com/lkmio/transport"
|
|
"net"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestName(t *testing.T) {
|
|
path := "../dump/rtmp-127.0.0.1.6850"
|
|
addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:1935")
|
|
|
|
file, err := os.ReadFile(path)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
client := transport.TCPClient{}
|
|
if _, err := client.Connect(nil, addr); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
length := len(file)
|
|
for i := 0; i < length; {
|
|
size := int(binary.BigEndian.Uint32(file[i:]))
|
|
if length-i < size {
|
|
return
|
|
}
|
|
|
|
i += 4
|
|
i += size
|
|
client.Write(file[i-size : i])
|
|
|
|
time.Sleep(10 * time.Millisecond)
|
|
}
|
|
|
|
}
|