mirror of https://bitbucket.org/ausocean/av.git
Ported RTMP_SendCreateStream - tested and working
This commit is contained in:
parent
a61d4a3a60
commit
a3654269e5
34
rtmp/rtmp.go
34
rtmp/rtmp.go
|
@ -1944,7 +1944,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 SendFCPublish (rtmp.c +1846)
|
||||
// TODO port RTMP_SendCreateStream (rtmp.c +1725)
|
||||
// TODO port SendPublish (rtmp.c +1908)
|
||||
// TODO port SendCheckBW (rtmp.c +2105)
|
||||
|
@ -2034,7 +2033,7 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
|
|||
C.RTMP_SendCtrl(r, 3, 0, 300)
|
||||
}
|
||||
*/
|
||||
C.RTMP_SendCreateStream(r)
|
||||
C_RTMP_SendCreateStream(r)
|
||||
/* NOTE This code doesn't run in our use case
|
||||
if (r.Link.protocol & RTMP_FEATURE_WRITE) == 0 {
|
||||
log.Println("2.5")
|
||||
|
@ -2307,6 +2306,37 @@ func C_SendFCPublish(r *C.RTMP) int32 {
|
|||
return int32(C_RTMP_SendPacket(r, &packet, 0))
|
||||
}
|
||||
|
||||
// int RTMP_SendCreateStream(RTMP* r);
|
||||
// rtmp.c +1725
|
||||
func C_RTMP_SendCreateStream(r *C.RTMP) int32 {
|
||||
var packet C.RTMPPacket
|
||||
var pbuf [256]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_createStream)
|
||||
r.m_numInvokes++
|
||||
enc = C_AMF_EncodeNumber(enc, pend, float64(r.m_numInvokes))
|
||||
*enc = AMF_NULL
|
||||
enc = (*byte)(incBytePtr(unsafe.Pointer(enc), 1))
|
||||
|
||||
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