THink I've fixed some obvious syntax errors, but will need to debug tomorrow using cgo

This commit is contained in:
Saxon Milton 2018-02-13 19:53:25 +10:30
parent 8e6f6ba3e0
commit a9df7b7adc
3 changed files with 7 additions and 7 deletions

View File

@ -41,7 +41,7 @@ type RTMPSession interface {
} }
type rtmpSession struct { type rtmpSession struct {
rtmp *C.RTMP rtmp *C.struct_RTMP
url string url string
timeout uint timeout uint
} }
@ -54,21 +54,21 @@ func NewRTMPSession(url string, connectTimeout uint) (session *rtmpSession){
} }
func (s *rtmpSession) StartSession() error { func (s *rtmpSession) StartSession() error {
if !bool(C.RTMP_start_session(s.rtmp, C.(const char*)(s.url), C.uint(connect_timeout))) { if !bool(C.RTMP_start_session(s.rtmp, C.CString(s.url), C.uint(connect_timeout))) {
return errors.New("RTMP start error! Check rtmp log for details!") return errors.New("RTMP start error! Check rtmp log for details!")
} }
return nil return nil
} }
func (s *rtmpSession) WriteFrame(data []byte, dataLength uint) error { func (s *rtmpSession) WriteFrame(data []byte, dataLength uint) error {
if !bool(C.RTMP_write_frame(RTMP* rtmp, char* data, C.uint(data_length))) { if !bool(C.RTMP_write_frame(s.rtmp, (*C.char)(unsafe.Pointer(&data[0])), C.uint(data_length))) {
return errors.New("RTMP write error! Check rtmp log for details!") return errors.New("RTMP write error! Check rtmp log for details!")
} }
return nil return nil
} }
func (s *rtmpSession) EndSession() error { func (s *rtmpSession) EndSession() error {
if !bool(RTMP_end_session(RTMP* rtmp)) { if !bool(C.RTMP_end_session(s.rtmp)) {
return errors.New("RTMP end session error! Check rtmp log for details!") return errors.New("RTMP end session error! Check rtmp log for details!")
} }
return nil return nil

View File

@ -33,11 +33,11 @@ LICENSE
#include "rtmp_c/librtmp/log.h" #include "rtmp_c/librtmp/log.h"
#include "lwlog/lwlog.h" #include "lwlog/lwlog.h"
int RTMP_start_session(RTMP* rtmp, const char* url, uint connect_timeout){ int RTMP_start_session(RTMP* rtmp, char* url, uint connect_timeout){
rtmp = RTMP_Alloc(); rtmp = RTMP_Alloc();
RTMP_Init(rtmp); RTMP_Init(rtmp);
rtmp->Link.timeout = connect_timeout; rtmp->Link.timeout = connect_timeout;
if (!RTMP_SetupURL(rtmp, url)) { if (!RTMP_SetupURL(rtmp, (const char*)url)) {
RTMP_Log(RTMP_LOGERROR, "SetupURL Err\n"); RTMP_Log(RTMP_LOGERROR, "SetupURL Err\n");
RTMP_Free(rtmp); RTMP_Free(rtmp);
return 0; return 0;

View File

@ -33,6 +33,6 @@ LICENSE
#include "rtmp_c/librtmp/log.h" #include "rtmp_c/librtmp/log.h"
#include "lwlog/lwlog.h" #include "lwlog/lwlog.h"
int RTMP_start_session(RTMP* rtmp, const char* url, uint connect_timeout); int RTMP_start_session(RTMP* rtmp, char* url, uint connect_timeout);
int RTMP_write_frame(RTMP* rtmp, char* data, uint data_length); int RTMP_write_frame(RTMP* rtmp, char* data, uint data_length);
int RTMP_end_session(RTMP* rtmp); int RTMP_end_session(RTMP* rtmp);