mirror of https://bitbucket.org/ausocean/av.git
rtmp: dealt with unsupported cases in C_RTMP_ClientPacket
This commit is contained in:
parent
77393a1de7
commit
6c84506af2
176
rtmp/rtmp.go
176
rtmp/rtmp.go
|
@ -662,76 +662,80 @@ func C_RTMP_ClientPacket(r *C_RTMP, packet *C_RTMPPacket) int32 {
|
|||
switch packet.m_packetType {
|
||||
|
||||
case RTMP_PACKET_TYPE_CHUNK_SIZE:
|
||||
log.Println("RTMP_PACKET_TYPE_CHUNK_SIZE")
|
||||
// TODO: port this
|
||||
//C.HandleChangeChunkSize(r, packet)
|
||||
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_CONTROL:
|
||||
log.Println("RTMP_PACKET_TYPE_CONTROL")
|
||||
// TODO: port this
|
||||
C.HandleCtrl(r, packet)
|
||||
case 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_CONTROL:
|
||||
panic("Unsupported packet type RTMP_PACKET_TYPE_CONTROL")
|
||||
/*
|
||||
log.Println("RTMP_PACKET_TYPE_CONTROL")
|
||||
// TODO: port this
|
||||
C.HandleCtrl(r, packet)
|
||||
*/
|
||||
case RTMP_PACKET_TYPE_SERVER_BW:
|
||||
log.Println("RTMP_PACKET_TYPE_SERVER_BW")
|
||||
// TODO: port this
|
||||
//C.HandleServerBW(r, packet)
|
||||
C_HandlServerBW(r, packet)
|
||||
|
||||
case RTMP_PACKET_TYPE_CLIENT_BW:
|
||||
log.Println("RTMP_PACKET_TYPE_CLIENT_BW")
|
||||
// TODO: port this
|
||||
//C.HandleClientBW(r, packet)
|
||||
C_HandleClientBW(r, packet)
|
||||
|
||||
case RTMP_PACKET_TYPE_AUDIO:
|
||||
panic("Unsupported packet type RTMP_PACKET_TYPE_AUDIO")
|
||||
/*
|
||||
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
|
||||
}
|
||||
// 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_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);
|
||||
|
||||
if C.HandleInvoke(r, (*byte)(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:")
|
||||
case RTMP_PACKET_TYPE_VIDEO:
|
||||
panic("Unsupported packet type 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_FLEX_MESSAGE:
|
||||
panic("Unsupported packet type RTMP_PACKET_TYPE_FLEX_MESSAGE")
|
||||
/*
|
||||
{
|
||||
// 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
|
||||
// RTMP_Log(RTMP_LOGDEBUG,"%s, flex message, size %u bytes, not fully supported", __FUNCTION__, packet.m_nBodySize);
|
||||
|
||||
if C.HandleInvoke(r, (*byte)(incBytePtr(unsafe.Pointer(packet.m_body), 1)),
|
||||
C.uint(packet.m_nBodySize-1)) == 1 {
|
||||
bHasMediaPacket = 2
|
||||
}
|
||||
}
|
||||
*/
|
||||
case RTMP_PACKET_TYPE_INFO:
|
||||
panic("Unsupported packet type 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:
|
||||
|
@ -744,48 +748,48 @@ func C_RTMP_ClientPacket(r *C_RTMP, packet *C_RTMPPacket) int32 {
|
|||
log.Println("HasMediaPacket")
|
||||
bHasMediaPacket = 2
|
||||
}
|
||||
|
||||
case RTMP_PACKET_TYPE_FLASH_VIDEO:
|
||||
panic("Unsupported packet type RTMP_PACKET_TYPE_FLASH_VIDEO")
|
||||
/*
|
||||
case RTMP_PACKET_TYPE_FLASH_VIDEO:
|
||||
log.Println("RTMP_PACKET_TYPE_FLASH_VIDEO:")
|
||||
{
|
||||
var pos uint32 = 0
|
||||
var nTimeStamp uint32 = uint32(packet.m_nTimeStamp)
|
||||
{
|
||||
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))))
|
||||
|
||||
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, (*byte)(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 = uint32(nTimeStamp)
|
||||
if pos+11+dataSize+4 > uint32(packet.m_nBodySize) {
|
||||
// TODO use new logger here
|
||||
// RTMP_Log(RTMP_LOGWARNING, "Stream corrupt?!");
|
||||
break
|
||||
}
|
||||
|
||||
bHasMediaPacket = 1
|
||||
|
||||
switch {
|
||||
case *indxBytePtr(unsafe.Pointer(packet.m_body), int(pos)) == 0x12:
|
||||
C.HandleMetadata(r, (*byte)(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)
|
||||
}
|
||||
default:
|
||||
log.Println("DEFAULT")
|
||||
// TODO use new logger here
|
||||
// RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,packet.m_packetType);
|
||||
if r.m_pausing == 0 {
|
||||
r.m_mediaStamp = uint32(nTimeStamp)
|
||||
}
|
||||
|
||||
bHasMediaPacket = 1
|
||||
|
||||
}
|
||||
*/
|
||||
default:
|
||||
// TODO use new logger here
|
||||
// RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,packet.m_packetType);
|
||||
}
|
||||
return bHasMediaPacket
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue