Ported SendFCPublish - tested and working

This commit is contained in:
saxon 2018-08-15 04:05:15 +09:30
parent e02c785881
commit a61d4a3a60
1 changed files with 36 additions and 2 deletions

View File

@ -237,6 +237,7 @@ var (
av_NetStream_Pause_Notify = AVC("NetStream.Pause.Notify") av_NetStream_Pause_Notify = AVC("NetStream.Pause.Notify")
av_playlist_ready = AVC("playlist_ready") av_playlist_ready = AVC("playlist_ready")
av_set_playlist = AVC("set_playlist") av_set_playlist = AVC("set_playlist")
av_FCPublish = AVC("FCPublish")
) )
var ( var (
@ -1943,7 +1944,6 @@ func C_HandleClientBW(r *C.RTMP, packet *C.RTMPPacket) {
// int HandleInvoke(RTMP* r, const char* body, unsigned int nBodySize); // int HandleInvoke(RTMP* r, const char* body, unsigned int nBodySize);
// rtmp.c +2912 // rtmp.c +2912
// TODO port SendReleaseStream (rtmp.c +1816)
// TODO port SendFCPublish (rtmp.c +1846) // TODO port SendFCPublish (rtmp.c +1846)
// TODO port RTMP_SendCreateStream (rtmp.c +1725) // TODO port RTMP_SendCreateStream (rtmp.c +1725)
// TODO port SendPublish (rtmp.c +1908) // TODO port SendPublish (rtmp.c +1908)
@ -2026,7 +2026,7 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
if (r.Link.protocol & RTMP_FEATURE_WRITE) != 0 { if (r.Link.protocol & RTMP_FEATURE_WRITE) != 0 {
log.Println("2.3") log.Println("2.3")
C_SendReleaseStream(r) C_SendReleaseStream(r)
C.SendFCPublish(r) C_SendFCPublish(r)
} /* NOTE This code doesn't run in our use case } /* NOTE This code doesn't run in our use case
else { else {
log.Println("2.4") log.Println("2.4")
@ -2273,6 +2273,40 @@ func C_SendReleaseStream(r *C.RTMP) int32 {
return int32(C_RTMP_SendPacket(r, &packet, 0)) return int32(C_RTMP_SendPacket(r, &packet, 0))
} }
// int SendFCPublish(RTMP* r);
// rtmp.c +1846
func C_SendFCPublish(r *C.RTMP) int32 {
var packet C.RTMPPacket
var pbuf [1024]byte
var pend *byte = (*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&pbuf[0])) +
unsafe.Sizeof(pbuf)))
var enc *byte
packet.m_nChannel = 0x03 /* control channel (invoke) */
packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM
packet.m_packetType = RTMP_PACKET_TYPE_INVOKE
packet.m_nTimeStamp = 0
packet.m_nInfoField2 = 0
packet.m_hasAbsTimestamp = 0
packet.m_body = (*C.char)(incBytePtr(unsafe.Pointer(&pbuf[0]),
int(RTMP_MAX_HEADER_SIZE)))
enc = (*byte)(unsafe.Pointer(packet.m_body))
enc = C_AMF_EncodeString(enc, pend, &av_FCPublish)
r.m_numInvokes++
enc = C_AMF_EncodeNumber(enc, pend, float64(r.m_numInvokes))
*enc = AMF_NULL
enc = (*byte)(incBytePtr(unsafe.Pointer(enc), 1))
enc = C_AMF_EncodeString(enc, pend, &r.Link.playpath)
if enc == nil {
return 0
}
packet.m_nBodySize = C.uint32_t(uintptr(unsafe.Pointer(enc)) - uintptr(
unsafe.Pointer(packet.m_body)))
return int32(C_RTMP_SendPacket(r, &packet, 0))
}
// #define AVMATCH(a1,a2) // #define AVMATCH(a1,a2)
// amf.h +63 // amf.h +63
func C_AVMATCH(a1, a2 *C.AVal) int32 { func C_AVMATCH(a1, a2 *C.AVal) int32 {