mirror of https://bitbucket.org/ausocean/av.git
Moved conn from C_RTMPSockBuf to C_RTMP_LNK and deleted the former.
This commit is contained in:
parent
474642f53b
commit
6133032a05
21
rtmp/rtmp.go
21
rtmp/rtmp.go
|
@ -236,7 +236,7 @@ func C_RTMP_EnableWrite(r *C_RTMP) {
|
|||
// int RTMP_IsConnected(RTMP *r);
|
||||
// rtmp.c +363
|
||||
func C_RTMP_IsConnected(r *C_RTMP) bool {
|
||||
return r.m_sb.conn != nil
|
||||
return r.Link.conn != nil
|
||||
}
|
||||
|
||||
// void RTMP_SetBufferMS(RTMP *r, int size);
|
||||
|
@ -289,11 +289,10 @@ func C_RTMP_Connect(r *C_RTMP, cp *C_RTMPPacket) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.m_sb.conn, err = net.DialTCP("tcp4", nil, addr)
|
||||
r.Link.conn, err = net.DialTCP("tcp4", nil, addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.m_sb.timeout = r.Link.timeout
|
||||
if debugMode {
|
||||
log.Println("... connected, handshaking...")
|
||||
}
|
||||
|
@ -426,11 +425,11 @@ func C_RTMP_ClientPacket(r *C_RTMP, packet *C_RTMPPacket) int32 {
|
|||
// int ReadN(RTMP* r, char* buffer, int n);
|
||||
// rtmp.c +1390
|
||||
func C_ReadN(r *C_RTMP, buf []byte) error {
|
||||
err := r.m_sb.conn.SetReadDeadline(time.Now().Add(time.Second * time.Duration(r.m_sb.timeout)))
|
||||
err := r.Link.conn.SetReadDeadline(time.Now().Add(time.Second * time.Duration(r.Link.timeout)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n, err := io.ReadFull(r.m_sb.conn, buf)
|
||||
n, err := io.ReadFull(r.Link.conn, buf)
|
||||
if err != nil {
|
||||
if debugMode {
|
||||
log.Printf("C_ReadN error: %v\n", err)
|
||||
|
@ -451,11 +450,11 @@ func C_ReadN(r *C_RTMP, buf []byte) error {
|
|||
// int WriteN(RTMP* r, const char* buffer, int n);
|
||||
// rtmp.c +1502
|
||||
func C_WriteN(r *C_RTMP, buf []byte) error {
|
||||
err := r.m_sb.conn.SetWriteDeadline(time.Now().Add(time.Second * time.Duration(r.m_sb.timeout)))
|
||||
err := r.Link.conn.SetWriteDeadline(time.Now().Add(time.Second * time.Duration(r.Link.timeout)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = r.m_sb.conn.Write(buf)
|
||||
_, err = r.Link.conn.Write(buf)
|
||||
if err != nil {
|
||||
if debugMode {
|
||||
log.Printf("C_WriteN, RTMP send error: %v\n", err)
|
||||
|
@ -1435,8 +1434,8 @@ func C_RTMP_SendPacket(r *C_RTMP, packet *C_RTMPPacket, queue int) error {
|
|||
nChunkSize := int(r.m_outChunkSize)
|
||||
|
||||
if debugMode {
|
||||
if r.m_sb.conn != nil {
|
||||
f, err := r.m_sb.conn.File()
|
||||
if r.Link.conn != nil {
|
||||
f, err := r.Link.conn.File()
|
||||
if err != nil {
|
||||
log.Printf("could not get file: %v", err)
|
||||
} else {
|
||||
|
@ -1531,14 +1530,14 @@ func C_CloseInternal(r *C_RTMP, reconnect bool) {
|
|||
}
|
||||
C_SendDeleteStream(r, float64(i))
|
||||
}
|
||||
err := r.m_sb.conn.Close()
|
||||
err := r.Link.conn.Close()
|
||||
if err != nil && debugMode {
|
||||
log.Printf("C_RTMPSockBuf_Close error: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
r.m_stream_id = -1
|
||||
r.m_sb.conn = nil
|
||||
r.Link.conn = nil
|
||||
r.m_nBWCheckCounter = 0
|
||||
r.m_nBytesIn = 0
|
||||
r.m_nBytesInSent = 0
|
||||
|
|
|
@ -138,11 +138,7 @@ type C_RTMPPacket struct {
|
|||
|
||||
// typedef struct RTMPSockBuf
|
||||
// rtmp.h +127
|
||||
// TODO: Incorporate what is left of C_RTMPSockBuf into C_RTMP_LNK
|
||||
type C_RTMPSockBuf struct {
|
||||
conn *net.TCPConn
|
||||
timeout uint
|
||||
}
|
||||
// DELETED: subsumed by C_RTMP_LNK
|
||||
|
||||
// RTMPPacket_IsReady(a)
|
||||
// rtmp.h +142
|
||||
|
@ -170,6 +166,7 @@ type C_RTMP_LNK struct {
|
|||
protocol int32
|
||||
timeout uint
|
||||
port uint16
|
||||
conn *net.TCPConn
|
||||
}
|
||||
|
||||
// typedef struct RTMPMethod
|
||||
|
@ -211,6 +208,5 @@ type C_RTMP struct {
|
|||
m_resplen int32
|
||||
m_unackd int32
|
||||
m_write C_RTMPPacket
|
||||
m_sb C_RTMPSockBuf
|
||||
Link C_RTMP_LNK
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue