[rtmpdump] patch: gcc -Wextra
Peter Miller
pmiller at opensource.org.au
Fri Apr 8 17:38:54 CEST 2011
This patch adds the gcc -Wextra flag, and fixes all the warnings it
produces.
--
Regards
Peter Miller <pmiller at opensource.org.au>
/\/\* http://miller.emu.id.au/pmiller/
PGP public key ID: 1024D/D0EDB64D
fingerprint = AD0A C5DF C426 4F03 5D53 2BDB 18D8 A4E2 D0ED B64D
See http://www.keyserver.net or any PGP keyserver for public key.
"Copyright is a little coral reef of private right jutting up from the
ocean of the public domain." -- Paul Torremans
-------------- next part --------------
MIME-Version: 1.0
Content-Type: application/aegis-patch
Subject: rtmpdump.2.3 - rtmp_packet_type_name
Content-Name: rtmpdump.2.3.C021.patch
Content-Disposition: attachment; filename=rtmpdump.2.3.C021.patch
X-Aegis-Project-Name: rtmpdump.2.3
X-Aegis-Change-Number: 21
#
# This change set adds an rtmp_packet_type_name function, used to
# translate packet numbers into human readable strings, usually symbol
# names. All of the debug messages that print packet type information
# have been updated to use it.
#
# Aegis-Change-Set-Begin
# QlpoMzFBWSZTWasUnfoAANVfgAAQUAf/6iAABAq/79/qQAId2520xkNFNMmSbU8gmag9NQDQ
# GQNE0MmphJqbU0yNA0aAGg1Gp6jIBMjABDACaYJIpkyR6mTCamhtJo0aGgaYEN2IH8DCT1Jw
# sikacNEe1QzAwMHVUbrIySGdCMyvYAzUkyCgRgJ/qxdDjSFrYhDyBgK2/D9tZd1gvwFT6Kcc
# TjkmSDN6uWtl9nRt+fz2Zdg2haJsLX1V3keF5K0jjH0dtRO1NaPQ3uLS1mHPB2PmLLh8IyyZ
# kWuLthJh4DN8h15vM3Y7rB0MYmZnCVLIjIBb5cdnfPkEE7VB4pCfoEMeb1tzcXeaQMdsbd2W
# AlTAGgTrdhEhpr0MizVz0dNZa+hzVMtlOcz5ZqZE6dAp58y8eVZrwUDyrusBvBgdlyDjSuU0
# 7x1Vj3GtsbR7gQ3YAHZIDvvS1KlcErurlAogbVgVDjv7aqXOw4xWm4fistDF3IqBsSTMgEwK
# GzLE5bDdynREDdjeBwRAAzZNz2Yzbs/Ez1IbIMAyjXOsccDOo5QuojOdUvDAOhj2reV+xviI
# o+j2o2i1sRVqUR3LLxS1TUmZpDEJrQHugg2Y3hSQpFClythEWopZII7+MbWvyMtiH0ExTUmK
# u6+lLHgCcBAtXjwgBswpCCLGBlESWDoGJAayKLbToGoNAFOoAaZXygUzcIJlnUhvsznkFwa6
# lOpFkNtbuu6YUtUwP8XckU4UJCrFJ36A
# Aegis-Change-Set-End
#
Index: librtmp/rtmp.c
--- librtmp/rtmp.c
+++ librtmp/rtmp.c
@@ -184,10 +184,12 @@
RTMPPacket_Dump(RTMPPacket *p)
{
RTMP_Log(RTMP_LOGDEBUG,
- "RTMP PACKET: packet type: 0x%02x. channel: 0x%02x. info 1: %d info 2: %d. Body size: %lu. body: 0x%02x",
- p->m_packetType, p->m_nChannel, p->m_nTimeStamp, p->m_nInfoField2,
- (unsigned long)p->m_nBodySize,
- p->m_body ? (unsigned char)p->m_body[0] : 0);
+ "RTMP PACKET: packet type: %s (0x%02x), channel: 0x%02x, "
+ "info 1: %d, info 2: %d, Body size: %lu, body: 0x%02x",
+ rtmp_packet_type_name(p->m_packetType), p->m_packetType,
+ p->m_nChannel, p->m_nTimeStamp, p->m_nInfoField2,
+ (unsigned long)p->m_nBodySize,
+ p->m_body ? (unsigned char)p->m_body[0] : 0);
}
int
@@ -3814,9 +3816,10 @@
break;
}
#ifdef _DEBUG
- RTMP_Log(RTMP_LOGDEBUG, "type: %02X, size: %d, TS: %d ms, abs TS: %d",
- packet.m_packetType, nPacketLen, packet.m_nTimeStamp,
- packet.m_hasAbsTimestamp);
+ RTMP_Log(RTMP_LOGDEBUG,
+ "type: %s (0x%02X), size: %d, TS: %d ms, abs TS: %d",
+ rtmp_packet_type_name(packet.m_packetType), packet.m_packetType,
+ nPacketLen, packet.m_nTimeStamp, packet.m_hasAbsTimestamp);
if (packet.m_packetType == RTMP_PACKET_TYPE_VIDEO)
RTMP_Log(RTMP_LOGDEBUG, "frametype: %02X", (*packetBody & 0xf0));
#endif
@@ -3906,8 +3909,10 @@
#ifdef _DEBUG
RTMP_Log(RTMP_LOGDEBUG,
- "keyframe search: FLV Packet: type %02X, dataSize: %d, timeStamp: %d ms",
- packetBody[pos], dataSize, ts);
+ "keyframe search: FLV Packet: type %s "
+ "(0x%02X), dataSize: %d, timeStamp: %d ms",
+ rtmp_packet_type_name(packetBody[pos]),
+ packetBody[pos], dataSize, ts);
#endif
/* ok, is it a keyframe?:
* well doesn't work for audio!
@@ -4177,9 +4182,12 @@
#ifdef _DEBUG
RTMP_Log(RTMP_LOGDEBUG,
- "FLV Packet: type %02X, dataSize: %lu, tagSize: %lu, timeStamp: %lu ms",
- (unsigned char)packetBody[pos], dataSize, prevTagSize,
- nTimeStamp);
+ "FLV Packet: type %s (0x%02X), dataSize: %lu, "
+ "tagSize: %lu, timeStamp: %lu ms",
+ rtmp_packet_type_name((unsigned char)
+ packetBody[pos]),
+ (unsigned char)packetBody[pos], dataSize,
+ prevTagSize, nTimeStamp);
#endif
if (prevTagSize != (dataSize + 11))
@@ -4211,7 +4219,14 @@
* Update ext timestamp with this absolute offset in non-live mode
* otherwise report the relative one
*/
- /* RTMP_Log(RTMP_LOGDEBUG, "type: %02X, size: %d, pktTS: %dms, TS: %dms, bLiveStream: %d", packet.m_packetType, nPacketLen, packet.m_nTimeStamp, nTimeStamp, r->Link.lFlags & RTMP_LF_LIVE); */
+#if 0
+ RTMP_Log(RTMP_LOGDEBUG,
+ "type: %s (0x%02X), size: %d, pktTS: %dms, TS: %dms, "
+ "bLiveStream: %d",
+ rtmp_packet_type_name(packet.m_packetType), packet.m_packetType,
+ nPacketLen, packet.m_nTimeStamp, nTimeStamp,
+ r->Link.lFlags & RTMP_LF_LIVE);
+#endif
r->m_read.timestamp = (r->Link.lFlags & RTMP_LF_LIVE) ? packet.m_nTimeStamp : nTimeStamp;
ret = size;
@@ -4487,3 +4502,60 @@
}
#endif
+
+
+const char *
+rtmp_packet_type_name(int x)
+{
+ switch (x)
+ {
+ case RTMP_PACKET_TYPE_CHUNK_SIZE:
+ return "RTMP_PACKET_TYPE_CHUNK_SIZE";
+
+ case RTMP_PACKET_TYPE_BYTES_READ_REPORT:
+ return "RTMP_PACKET_TYPE_BYTES_READ_REPORT";
+
+ case RTMP_PACKET_TYPE_CONTROL:
+ return "RTMP_PACKET_TYPE_CONTROL";
+
+ case RTMP_PACKET_TYPE_SERVER_BW:
+ return "RTMP_PACKET_TYPE_SERVER_BW";
+
+ case RTMP_PACKET_TYPE_CLIENT_BW:
+ return "RTMP_PACKET_TYPE_CLIENT_BW";
+
+ case RTMP_PACKET_TYPE_AUDIO:
+ return "RTMP_PACKET_TYPE_AUDIO";
+
+ case RTMP_PACKET_TYPE_VIDEO:
+ return "RTMP_PACKET_TYPE_VIDEO";
+
+ case RTMP_PACKET_TYPE_FLEX_STREAM_SEND:
+ return "RTMP_PACKET_TYPE_FLEX_STREAM_SEND";
+
+ case RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT:
+ return "RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT";
+
+ case RTMP_PACKET_TYPE_FLEX_MESSAGE:
+ return "RTMP_PACKET_TYPE_FLEX_MESSAGE";
+
+ case RTMP_PACKET_TYPE_INFO:
+ return "RTMP_PACKET_TYPE_INFO";
+
+ case RTMP_PACKET_TYPE_SHARED_OBJECT:
+ return "RTMP_PACKET_TYPE_SHARED_OBJECT";
+
+ case RTMP_PACKET_TYPE_INVOKE:
+ return "RTMP_PACKET_TYPE_INVOKE";
+
+ case RTMP_PACKET_TYPE_FLASH_VIDEO:
+ return "RTMP_PACKET_TYPE_FLASH_VIDEO";
+
+ default:
+ {
+ static char buf[20];
+ snprintf(buf, sizeof(buf), "unknown type %d", x);
+ return buf;
+ }
+ }
+}
Index: librtmp/rtmp.h
--- librtmp/rtmp.h
+++ librtmp/rtmp.h
@@ -95,6 +95,18 @@
/* RTMP_PACKET_TYPE_... 0x15 */
#define RTMP_PACKET_TYPE_FLASH_VIDEO 0x16
+/**
+ * The rtmp_packet_type_name function may be used to obtain a human
+ * readable string corresponding to the packet type given.
+ *
+ * @param pt
+ * The packet type value to be translated.
+ * @returns
+ * pointer to a C string. only guaranteed valid until next call to
+ * this function.
+ */
+const char *rtmp_packet_type_name(int pt);
+
#define RTMP_MAX_HEADER_SIZE 18
#define RTMP_PACKET_SIZE_LARGE 0
Index: rtmpsrv.c
--- rtmpsrv.c
+++ rtmpsrv.c
@@ -743,9 +743,10 @@
{
int ret = 0;
- RTMP_Log(RTMP_LOGDEBUG, "%s, received packet type %02X, size %lu bytes",
- __FUNCTION__, packet->m_packetType,
- (unsigned long)packet->m_nBodySize);
+ RTMP_Log(RTMP_LOGDEBUG,
+ "%s, received packet type %s (0x%02X), size %lu bytes", __FUNCTION__,
+ rtmp_packet_type_name(packet->m_packetType), packet->m_packetType,
+ (unsigned long)packet->m_nBodySize);
switch (packet->m_packetType)
{
Index: rtmpsuck.c
--- rtmpsuck.c
+++ rtmpsuck.c
@@ -457,9 +457,10 @@
{
int ret = 0;
- RTMP_Log(RTMP_LOGDEBUG, "%s, %s sent packet type %02X, size %lu bytes",
- __FUNCTION__, cst[which], packet->m_packetType,
- (unsigned long)packet->m_nBodySize);
+ RTMP_Log(RTMP_LOGDEBUG, "%s, %s sent packet type %s (0x%02X), size %lu bytes",
+ __FUNCTION__, cst[which],
+ rtmp_packet_type_name(packet->m_packetType), packet->m_packetType,
+ (unsigned long)packet->m_nBodySize);
switch (packet->m_packetType)
{
@@ -592,8 +593,9 @@
break;
}
#ifdef _DEBUG
- RTMP_Log(RTMP_LOGDEBUG, "type: %02X, size: %d, TS: %d ms", packet->m_packetType,
- nPacketLen, packet->m_nTimeStamp);
+ RTMP_Log(RTMP_LOGDEBUG, "type: %s (0x%02X), size: %d, TS: %d ms",
+ rtmp_packet_type_name(packet->m_packetType),
+ packet->m_packetType, nPacketLen, packet->m_nTimeStamp);
if (packet->m_packetType == RTMP_PACKET_TYPE_VIDEO)
RTMP_Log(RTMP_LOGDEBUG, "frametype: %02X", (*packetBody & 0xf0));
#endif
@@ -692,9 +694,12 @@
#ifdef _DEBUG
RTMP_Log(RTMP_LOGDEBUG,
- "FLV Packet: type %02X, dataSize: %lu, tagSize: %lu, timeStamp: %lu ms",
- (unsigned char) packetBody[pos], dataSize, prevTagSize,
- *nTimeStamp);
+ "FLV Packet: type %s (0x%02X), dataSize: %lu, "
+ "tagSize: %lu, timeStamp: %lu ms",
+ rtmp_packet_type_name((unsigned char)
+ packetBody[pos]),
+ (unsigned char)packetBody[pos], dataSize,
+ prevTagSize, *nTimeStamp);
#endif
if (prevTagSize != (dataSize + 11))
@@ -1154,7 +1159,7 @@
{
RTMP_Log(RTMP_LOGERROR,
"%s: Failed to close listening socket, error %d",
- __FUNCTION__, GetSockError());
+ __FUNCTION__, GetSockError());
}
server->state = STREAMING_STOPPED;
More information about the rtmpdump
mailing list