Removed code we currently don't need in, C_RTMP_ClientPacket - tested and working

This commit is contained in:
saxon 2018-08-12 19:37:56 +09:30
parent 1c8e7b01fc
commit dc6e9a9a4b
1 changed files with 97 additions and 97 deletions

View File

@ -1724,8 +1724,8 @@ func C_RTMP_ConnectStream(r *C.RTMP, seekTime int32) int {
continue
}
// TODO: port this
C.RTMP_ClientPacket(r, &packet)
//C.RTMP_ClientPacket(r, &packet)
C_RTMP_ClientPacket(r, &packet)
C_RTMPPacket_Free(&packet)
}
}
@ -1734,131 +1734,131 @@ func C_RTMP_ConnectStream(r *C.RTMP, seekTime int32) int {
// int RTMP_ClientPacket()
// rtmp.c +1226
// NOTE cases have been commented out that are not currently used by AusOcean
func C_RTMP_ClientPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
var bHasMediaPacket int32 = 0
switch packet.m_packetType {
case RTMP_PACKET_TYPE_CHUNK_SIZE:
/* chunk size */
log.Println("RTMP_PACKET_TYPE_CHUNK_SIZE")
// TODO: port this
C.HandleChangeChunkSize(r, packet)
/*
case RTMP_PACKET_TYPE_BYTES_READ_REPORT:
log.Println("RTMP_PACKET_TYPE_BYTES_READ_REPORT")
// TODO: usue new logger here
//RTMP_Log(RTMP_LOGDEBUG, "%s, received: bytes read report", __FUNCTION__);
case RTMP_PACKET_TYPE_BYTES_READ_REPORT:
/* bytes read report */
// TODO: usue new logger here
//RTMP_Log(RTMP_LOGDEBUG, "%s, received: bytes read report", __FUNCTION__);
case RTMP_PACKET_TYPE_CONTROL:
/* ctrl */
// TODO: port this
C.HandleCtrl(r, packet)
case RTMP_PACKET_TYPE_CONTROL:
log.Println("RTMP_PACKET_TYPE_CONTROL")
// TODO: port this
C.HandleCtrl(r, packet)
*/
case RTMP_PACKET_TYPE_SERVER_BW:
/* server bw */
log.Println("RTMP_PACKET_TYPE_SERVER_BW")
// TODO: port this
C.HandleServerBW(r, packet)
case RTMP_PACKET_TYPE_CLIENT_BW:
/* client bw */
log.Println("RTMP_PACKET_TYPE_CLIENT_BW")
// TODO: port this
C.HandleClientBW(r, packet)
/*
case RTMP_PACKET_TYPE_AUDIO:
log.Println("RTMP_PACKET_TYPE_AUDIO")
// TODO port this
//C.HandleAudio(r, packet) NOTE this does nothing
bHasMediaPacket = 1
if r.m_mediaChannel == 0 {
r.m_mediaChannel = packet.m_nChannel
}
case RTMP_PACKET_TYPE_AUDIO:
/* audio data */
/*RTMP_Log(RTMP_LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize); */
// TODO port this
//C.HandleAudio(r, packet) NOTE this does nothing
bHasMediaPacket = 1
if r.m_mediaChannel == 0 {
r.m_mediaChannel = packet.m_nChannel
}
if r.m_pausing == 0 {
r.m_mediaStamp = packet.m_nTimeStamp
}
if r.m_pausing == 0 {
r.m_mediaStamp = packet.m_nTimeStamp
}
case RTMP_PACKET_TYPE_VIDEO:
log.Println("RTMP_PACKET_TYPE_VIDEO:")
// TODO port this
// C.HandleVideo(r, packet) NOTE this does nothing
bHasMediaPacket = 1
if r.m_mediaChannel == 0 {
r.m_mediaChannel = packet.m_nChannel
}
if r.m_pausing == 0 {
r.m_mediaStamp = packet.m_nTimeStamp
}
case RTMP_PACKET_TYPE_VIDEO:
/* video data */
/*RTMP_Log(RTMP_LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize); */
// TODO port this
// C.HandleVideo(r, packet) NOTE this does nothing
bHasMediaPacket = 1
if r.m_mediaChannel == 0 {
r.m_mediaChannel = packet.m_nChannel
}
if r.m_pausing == 0 {
r.m_mediaStamp = packet.m_nTimeStamp
}
case RTMP_PACKET_TYPE_FLEX_MESSAGE:
log.Println("RTMP_PACKET_TYPE_FLEX_MESSAGE:")
{
// TODO use new logger here
// RTMP_Log(RTMP_LOGDEBUG,"%s, flex message, size %u bytes, not fully supported", __FUNCTION__, packet.m_nBodySize);
case RTMP_PACKET_TYPE_FLEX_MESSAGE:
/* flex message */
{
// TODO use new logger here
// RTMP_Log(RTMP_LOGDEBUG,"%s, flex message, size %u bytes, not fully supported", __FUNCTION__, packet.m_nBodySize);
if C.HandleInvoke(r, (*C.char)(incBytePtr(unsafe.Pointer(packet.m_body), 1)),
C.uint(packet.m_nBodySize-1)) == 1 {
bHasMediaPacket = 2
}
}
case RTMP_PACKET_TYPE_INFO:
/* metadata (notify) */
// TODO use new logger here
//RTMP_Log(RTMP_LOGDEBUG, "%s, received: notify %u bytes", __FUNCTION__,packet.m_nBodySize);
if C.HandleMetadata(r, packet.m_body, C.uint(packet.m_nBodySize)) != 0 {
bHasMediaPacket = 1
}
if C.HandleInvoke(r, (*C.char)(incBytePtr(unsafe.Pointer(packet.m_body), 1)),
C.uint(packet.m_nBodySize-1)) == 1 {
bHasMediaPacket = 2
}
}
case RTMP_PACKET_TYPE_INFO:
log.Println(" RTMP_PACKET_TYPE_INFO:")
// TODO use new logger here
//RTMP_Log(RTMP_LOGDEBUG, "%s, received: notify %u bytes", __FUNCTION__,packet.m_nBodySize);
if C.HandleMetadata(r, packet.m_body, C.uint(packet.m_nBodySize)) != 0 {
bHasMediaPacket = 1
}
*/
case RTMP_PACKET_TYPE_INVOKE:
/* invoke */
log.Println("RTMP_PACKET_TYPE_INVOKE:")
// TODO use new logger here
//RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %u bytes", __FUNCTION__,packet.m_nBodySize);
/*RTMP_LogHex(packet.m_body, packet.m_nBodySize); */
if C.HandleInvoke(r, packet.m_body, C.uint(packet.m_nBodySize)) == 1 {
bHasMediaPacket = 2
}
/*
case RTMP_PACKET_TYPE_FLASH_VIDEO:
log.Println("RTMP_PACKET_TYPE_FLASH_VIDEO:")
{
var pos uint32 = 0
var nTimeStamp uint32 = uint32(packet.m_nTimeStamp)
case RTMP_PACKET_TYPE_FLASH_VIDEO:
{
/* go through FLV packets and handle metadata packets */
var pos uint32 = 0
var nTimeStamp uint32 = uint32(packet.m_nTimeStamp)
for pos+11 < uint32(packet.m_nBodySize) {
var dataSize uint32 = C_AMF_DecodeInt24((*byte)(incBytePtr(unsafe.Pointer(
packet.m_body), int(pos+1))))
for pos+11 < uint32(packet.m_nBodySize) {
var dataSize uint32 = C_AMF_DecodeInt24((*byte)(incBytePtr(unsafe.Pointer(
packet.m_body), int(pos+1)))) /* size without header (11) and prevTagSize (4) */
if pos+11+dataSize+4 > uint32(packet.m_nBodySize) {
// TODO use new logger here
// RTMP_Log(RTMP_LOGWARNING, "Stream corrupt?!");
break
}
switch {
case *indxBytePtr(unsafe.Pointer(packet.m_body), int(pos)) == 0x12:
C.HandleMetadata(r, (*C.char)(incBytePtr(unsafe.Pointer(packet.m_body),
int(pos+11))), C.uint(dataSize))
case *indxBytePtr(unsafe.Pointer(packet.m_body), int(pos)) == 8 ||
*indxBytePtr(unsafe.Pointer(packet.m_body), int(pos)) == 9:
nTimeStamp = C_AMF_DecodeInt24((*byte)(incBytePtr(unsafe.Pointer(
packet.m_body), int(pos+4))))
nTimeStamp |= uint32(*indxBytePtr(unsafe.Pointer(packet.m_body),
int(pos+7)) << 24)
}
pos += (11 + dataSize + 4)
}
if r.m_pausing == 0 {
r.m_mediaStamp = C.uint32_t(nTimeStamp)
}
bHasMediaPacket = 1
if pos+11+dataSize+4 > uint32(packet.m_nBodySize) {
// TODO use new logger here
// RTMP_Log(RTMP_LOGWARNING, "Stream corrupt?!");
break
}
switch {
case *indxBytePtr(unsafe.Pointer(packet.m_body), int(pos)) == 0x12:
C.HandleMetadata(r, (*C.char)(incBytePtr(unsafe.Pointer(packet.m_body),
int(pos+11))), C.uint(dataSize))
case *indxBytePtr(unsafe.Pointer(packet.m_body), int(pos)) == 8 ||
*indxBytePtr(unsafe.Pointer(packet.m_body), int(pos)) == 9:
nTimeStamp = C_AMF_DecodeInt24((*byte)(incBytePtr(unsafe.Pointer(
packet.m_body), int(pos+4))))
nTimeStamp |= uint32(*indxBytePtr(unsafe.Pointer(packet.m_body),
int(pos+7)) << 24)
}
pos += (11 + dataSize + 4)
}
if r.m_pausing == 0 {
r.m_mediaStamp = C.uint32_t(nTimeStamp)
}
/* FLV tag(s) */
/*RTMP_Log(RTMP_LOGDEBUG, "%s, received: FLV tag(s) %lu bytes", __FUNCTION__, packet.m_nBodySize); */
bHasMediaPacket = 1
}
default:
// TODO use new logger here
// RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,packet.m_packetType);
default:
log.Println("DEFAULT")
// TODO use new logger here
// RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,packet.m_packetType);
*/
}
return bHasMediaPacket
}