mirror of https://bitbucket.org/ausocean/av.git
Removed code we currently don't need in, C_RTMP_ClientPacket - tested and working
This commit is contained in:
parent
1c8e7b01fc
commit
dc6e9a9a4b
194
rtmp/rtmp.go
194
rtmp/rtmp.go
|
@ -1724,8 +1724,8 @@ func C_RTMP_ConnectStream(r *C.RTMP, seekTime int32) int {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: port this
|
//C.RTMP_ClientPacket(r, &packet)
|
||||||
C.RTMP_ClientPacket(r, &packet)
|
C_RTMP_ClientPacket(r, &packet)
|
||||||
C_RTMPPacket_Free(&packet)
|
C_RTMPPacket_Free(&packet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1734,131 +1734,131 @@ func C_RTMP_ConnectStream(r *C.RTMP, seekTime int32) int {
|
||||||
|
|
||||||
// int RTMP_ClientPacket()
|
// int RTMP_ClientPacket()
|
||||||
// rtmp.c +1226
|
// 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 {
|
func C_RTMP_ClientPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
|
||||||
var bHasMediaPacket int32 = 0
|
var bHasMediaPacket int32 = 0
|
||||||
switch packet.m_packetType {
|
switch packet.m_packetType {
|
||||||
|
|
||||||
case RTMP_PACKET_TYPE_CHUNK_SIZE:
|
case RTMP_PACKET_TYPE_CHUNK_SIZE:
|
||||||
/* chunk size */
|
log.Println("RTMP_PACKET_TYPE_CHUNK_SIZE")
|
||||||
// TODO: port this
|
// 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_BYTES_READ_REPORT:
|
case RTMP_PACKET_TYPE_CONTROL:
|
||||||
/* bytes read report */
|
log.Println("RTMP_PACKET_TYPE_CONTROL")
|
||||||
// TODO: usue new logger here
|
// TODO: port this
|
||||||
//RTMP_Log(RTMP_LOGDEBUG, "%s, received: bytes read report", __FUNCTION__);
|
C.HandleCtrl(r, packet)
|
||||||
|
*/
|
||||||
case RTMP_PACKET_TYPE_CONTROL:
|
|
||||||
/* ctrl */
|
|
||||||
// TODO: port this
|
|
||||||
C.HandleCtrl(r, packet)
|
|
||||||
|
|
||||||
case RTMP_PACKET_TYPE_SERVER_BW:
|
case RTMP_PACKET_TYPE_SERVER_BW:
|
||||||
/* server bw */
|
log.Println("RTMP_PACKET_TYPE_SERVER_BW")
|
||||||
// TODO: port this
|
// TODO: port this
|
||||||
C.HandleServerBW(r, packet)
|
C.HandleServerBW(r, packet)
|
||||||
|
|
||||||
case RTMP_PACKET_TYPE_CLIENT_BW:
|
case RTMP_PACKET_TYPE_CLIENT_BW:
|
||||||
/* client bw */
|
log.Println("RTMP_PACKET_TYPE_CLIENT_BW")
|
||||||
// TODO: port this
|
// TODO: port this
|
||||||
C.HandleClientBW(r, packet)
|
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:
|
if r.m_pausing == 0 {
|
||||||
/* audio data */
|
r.m_mediaStamp = packet.m_nTimeStamp
|
||||||
/*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 {
|
case RTMP_PACKET_TYPE_VIDEO:
|
||||||
r.m_mediaStamp = packet.m_nTimeStamp
|
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:
|
case RTMP_PACKET_TYPE_FLEX_MESSAGE:
|
||||||
/* video data */
|
log.Println("RTMP_PACKET_TYPE_FLEX_MESSAGE:")
|
||||||
/*RTMP_Log(RTMP_LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize); */
|
{
|
||||||
// TODO port this
|
// TODO use new logger here
|
||||||
// C.HandleVideo(r, packet) NOTE this does nothing
|
// RTMP_Log(RTMP_LOGDEBUG,"%s, flex message, size %u bytes, not fully supported", __FUNCTION__, packet.m_nBodySize);
|
||||||
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:
|
if C.HandleInvoke(r, (*C.char)(incBytePtr(unsafe.Pointer(packet.m_body), 1)),
|
||||||
/* flex message */
|
C.uint(packet.m_nBodySize-1)) == 1 {
|
||||||
{
|
bHasMediaPacket = 2
|
||||||
// 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_INFO:
|
||||||
if C.HandleInvoke(r, (*C.char)(incBytePtr(unsafe.Pointer(packet.m_body), 1)),
|
log.Println(" RTMP_PACKET_TYPE_INFO:")
|
||||||
C.uint(packet.m_nBodySize-1)) == 1 {
|
// TODO use new logger here
|
||||||
bHasMediaPacket = 2
|
//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_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
|
|
||||||
}
|
|
||||||
|
|
||||||
case RTMP_PACKET_TYPE_INVOKE:
|
case RTMP_PACKET_TYPE_INVOKE:
|
||||||
/* invoke */
|
log.Println("RTMP_PACKET_TYPE_INVOKE:")
|
||||||
// TODO use new logger here
|
// TODO use new logger here
|
||||||
//RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %u bytes", __FUNCTION__,packet.m_nBodySize);
|
//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 {
|
if C.HandleInvoke(r, packet.m_body, C.uint(packet.m_nBodySize)) == 1 {
|
||||||
bHasMediaPacket = 2
|
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:
|
for pos+11 < uint32(packet.m_nBodySize) {
|
||||||
{
|
var dataSize uint32 = C_AMF_DecodeInt24((*byte)(incBytePtr(unsafe.Pointer(
|
||||||
/* go through FLV packets and handle metadata packets */
|
packet.m_body), int(pos+1))))
|
||||||
var pos uint32 = 0
|
|
||||||
var nTimeStamp uint32 = uint32(packet.m_nTimeStamp)
|
|
||||||
|
|
||||||
for pos+11 < uint32(packet.m_nBodySize) {
|
if pos+11+dataSize+4 > uint32(packet.m_nBodySize) {
|
||||||
var dataSize uint32 = C_AMF_DecodeInt24((*byte)(incBytePtr(unsafe.Pointer(
|
// TODO use new logger here
|
||||||
packet.m_body), int(pos+1)))) /* size without header (11) and prevTagSize (4) */
|
// 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
|
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
switch {
|
log.Println("DEFAULT")
|
||||||
case *indxBytePtr(unsafe.Pointer(packet.m_body), int(pos)) == 0x12:
|
// TODO use new logger here
|
||||||
C.HandleMetadata(r, (*C.char)(incBytePtr(unsafe.Pointer(packet.m_body),
|
// RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,packet.m_packetType);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
return bHasMediaPacket
|
return bHasMediaPacket
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue