Back to working order - now we will slowly go through changing to my funcs making sure it works

This commit is contained in:
saxon 2018-07-28 15:08:09 +09:30
parent 80cc24f665
commit 69ff0bbad5
3 changed files with 29 additions and 17 deletions

View File

@ -372,10 +372,13 @@ func (s *session) Write(data []byte) (int, error) {
return 0, Err(3)
}
if rtmpIsConnected(s.rtmp) == 0 {
// if rtmpIsConnected(s.rtmp) == 0 {
if C.RTMP_IsConnected(s.rtmp) == 0 {
return 0, Err(1)
}
if rtmpWrite(s.rtmp, data) == 0 {
// if rtmpWrite(s.rtmp, data) == 0 {
if C.RTMP_Write(s.rtmp, (*C.char)(unsafe.Pointer(&data[0])), C.int(len(data))) == 0 {
return 0, Err(2)
}
return len(data), nil
@ -390,27 +393,34 @@ func rtmpIsConnected(r *C.RTMP) int {
func startSession(rtmp *C.RTMP, u string, timeout uint32) (*C.RTMP, error) {
connect_timeout := C.int(timeout)
rtmp = rtmpAlloc()
rtmpInit(rtmp)
// rtmp = rtmpAlloc()
rtmp = C.RTMP_Alloc()
// rtmpInit(rtmp)
C.RTMP_Init(rtmp)
rtmp.Link.timeout = connect_timeout
if rtmpSetupUrl(rtmp, u) == 0 {
//C.RTMP_Clos(rtmp)
//C.RTMP_Free(rtmp)
// if rtmpSetupUrl(rtmp, u) == 0 {
if C.RTMP_SetupURL(rtmp, C.CString(u)) == 0 {
C.RTMP_Close(rtmp)
C.RTMP_Free(rtmp)
return nil, errors.New("rtmp startSession: Failed to setup URL!")
}
rtmpEnableWrite(rtmp)
rtmpSetBufferMS(rtmp, 3600*1000)
if rtmpConnect(rtmp, nil) == 0 {
//C.RTMP_Close(rtmp)
//C.RTMP_Free(rtmp)
// rtmpEnableWrite(rtmp)
C.RTMP_EnableWrite(rtmp)
// rtmpSetBufferMS(rtmp, 3600*1000)
C.RTMP_SetBufferMS(rtmp, 3600*1000)
// if rtmpConnect(rtmp, nil) == 0 {
if C.RTMP_Connect(rtmp, nil) == 0 {
C.RTMP_Close(rtmp)
C.RTMP_Free(rtmp)
return nil, errors.New("rtmp startSession: Failed to connect!")
}
// TODO: port this
if rtmpConnectStream(rtmp, 0) == 0 {
//C.RTMP_Close(rtmp)
//C.RTMP_Free(rtmp)
// if rtmpConnectStream(rtmp, 0) == 0 {
if C.RTMP_ConnectStream(rtmp, 0) == 0 {
C.RTMP_Close(rtmp)
C.RTMP_Free(rtmp)
return nil, errors.New("rtmp startSession: Failed to connect stream!")
}

View File

@ -118,7 +118,7 @@ static int SendCheckBWResult(RTMP *r, double txn);
int SendDeleteStream(RTMP *r, double dStreamId);
static int SendFCSubscribe(RTMP *r, AVal *subscribepath);
static int SendPlay(RTMP *r);
static int SendBytesReceived(RTMP *r);
int SendBytesReceived(RTMP *r);
static int SendUsherToken(RTMP *r, AVal *usherToken);
#if 0 /* unused */
@ -2076,7 +2076,7 @@ RTMP_SendClientBW(RTMP *r)
return RTMP_SendPacket(r, &packet, FALSE);
}
static int
int
SendBytesReceived(RTMP *r)
{
RTMPPacket packet;

View File

@ -299,6 +299,8 @@ extern "C"
int HandShake(RTMP *r, int FP9HandShake);
int SendBytesReceived(RTMP *r);
int SendConnectPacket(RTMP *r, RTMPPacket *cp);
int SendDeleteStream(RTMP *r, double dStreamId);