mirror of https://bitbucket.org/ausocean/av.git
Ported SendPublish - tested and working
This commit is contained in:
parent
a3654269e5
commit
6e7dbcda60
45
rtmp/rtmp.go
45
rtmp/rtmp.go
|
@ -238,6 +238,7 @@ var (
|
|||
av_playlist_ready = AVC("playlist_ready")
|
||||
av_set_playlist = AVC("set_playlist")
|
||||
av_FCPublish = AVC("FCPublish")
|
||||
av_live = AVC("live")
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -1944,7 +1945,6 @@ func C_HandleClientBW(r *C.RTMP, packet *C.RTMPPacket) {
|
|||
|
||||
// int HandleInvoke(RTMP* r, const char* body, unsigned int nBodySize);
|
||||
// rtmp.c +2912
|
||||
// TODO port RTMP_SendCreateStream (rtmp.c +1725)
|
||||
// TODO port SendPublish (rtmp.c +1908)
|
||||
// TODO port SendCheckBW (rtmp.c +2105)
|
||||
// TODO port AMF_Reset (amf.c +1282)
|
||||
|
@ -2065,7 +2065,7 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
|
|||
|
||||
if (r.Link.protocol & RTMP_FEATURE_WRITE) != 0 {
|
||||
log.Println("5.1")
|
||||
C.SendPublish(r)
|
||||
C_SendPublish(r)
|
||||
} /* NOTE This code doesn't run in our use case
|
||||
else {
|
||||
log.Println("5.2")
|
||||
|
@ -2337,6 +2337,47 @@ func C_RTMP_SendCreateStream(r *C.RTMP) int32 {
|
|||
return int32(C_RTMP_SendPacket(r, &packet, 1))
|
||||
}
|
||||
|
||||
// int SendPublish(RTMP* r);
|
||||
// rtmp.c +1908
|
||||
func C_SendPublish(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 = 0x04 /* source channel (invoke) */
|
||||
packet.m_headerType = RTMP_PACKET_SIZE_LARGE
|
||||
packet.m_packetType = RTMP_PACKET_TYPE_INVOKE
|
||||
packet.m_nTimeStamp = 0
|
||||
packet.m_nInfoField2 = C.int32_t(r.m_stream_id)
|
||||
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_publish)
|
||||
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
|
||||
}
|
||||
|
||||
enc = C_AMF_EncodeString(enc, pend, &av_live)
|
||||
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, 1))
|
||||
}
|
||||
|
||||
// #define AVMATCH(a1,a2)
|
||||
// amf.h +63
|
||||
func C_AVMATCH(a1, a2 *C.AVal) int32 {
|
||||
|
|
Loading…
Reference in New Issue