mirror of https://bitbucket.org/ausocean/av.git
Merge Session.write() into Session.Write().
This commit is contained in:
parent
56a3bf8b26
commit
26e8133a6e
22
rtmp/rtmp.go
22
rtmp/rtmp.go
|
@ -858,25 +858,3 @@ func handshake(s *Session) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// write prepares data to write then sends it.
|
|
||||||
func (s *Session) write(buf []byte) error {
|
|
||||||
if buf[0] == RTMP_PACKET_TYPE_INFO || (buf[0] == 'F' && buf[1] == 'L' && buf[2] == 'V') {
|
|
||||||
return errUnimplemented
|
|
||||||
}
|
|
||||||
if len(buf) < minDataSize {
|
|
||||||
return errTinyPacket
|
|
||||||
}
|
|
||||||
|
|
||||||
pkt := packet{
|
|
||||||
packetType: buf[0],
|
|
||||||
bodySize: C_AMF_DecodeInt24(buf[1:4]),
|
|
||||||
timestamp: C_AMF_DecodeInt24(buf[4:7]) | uint32(buf[7])<<24,
|
|
||||||
channel: RTMP_CHANNEL_SOURCE,
|
|
||||||
info: s.streamID,
|
|
||||||
}
|
|
||||||
|
|
||||||
resizePacket(&pkt, pkt.bodySize, RTMP_PACKET_SIZE_AUTO)
|
|
||||||
copy(pkt.body, buf[minDataSize:minDataSize+pkt.bodySize])
|
|
||||||
return sendPacket(s, &pkt, false)
|
|
||||||
}
|
|
||||||
|
|
|
@ -159,7 +159,24 @@ func (s *Session) Write(data []byte) (int, error) {
|
||||||
if !s.isConnected() {
|
if !s.isConnected() {
|
||||||
return 0, errNotConnected
|
return 0, errNotConnected
|
||||||
}
|
}
|
||||||
err := s.write(data)
|
if data[0] == RTMP_PACKET_TYPE_INFO || (data[0] == 'F' && data[1] == 'L' && data[2] == 'V') {
|
||||||
|
return 0, errUnimplemented
|
||||||
|
}
|
||||||
|
if len(data) < minDataSize {
|
||||||
|
return 0, errTinyPacket
|
||||||
|
}
|
||||||
|
|
||||||
|
pkt := packet{
|
||||||
|
packetType: data[0],
|
||||||
|
bodySize: C_AMF_DecodeInt24(data[1:4]),
|
||||||
|
timestamp: C_AMF_DecodeInt24(data[4:7]) | uint32(data[7])<<24,
|
||||||
|
channel: RTMP_CHANNEL_SOURCE,
|
||||||
|
info: s.streamID,
|
||||||
|
}
|
||||||
|
|
||||||
|
resizePacket(&pkt, pkt.bodySize, RTMP_PACKET_SIZE_AUTO)
|
||||||
|
copy(pkt.body, data[minDataSize:minDataSize+pkt.bodySize])
|
||||||
|
err := sendPacket(s, &pkt, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue