2009-07-31, 09:57
In section 6.1.1 of the spec, the Chunk Stream ID can be 1 to 3 bytes long. The current code only handles a 1 byte ID (values 0-63).
Probably easier for me to just give you the patch...
I should point out, it's possible I have the 3 byte decode wrong; the text says the 3rd byte is most significant, but the Figure implies that it's the 2nd byte. So maybe it should be t[0] + t[1] << 8 instead. I suspect though that the actual value doesn't matter to us...
Probably easier for me to just give you the patch...
Code:
diff -wur old/rtmp.cpp new/rtmp.cpp
--- old/rtmp.cpp 2009-05-14 10:13:54.000000000 -0700
+++ new/rtmp.cpp 2009-07-26 19:14:03.000000000 -0700
@@ -1026,6 +1129,28 @@
packet.m_headerType = (type & 0xc0) >> 6;
packet.m_nChannel = (type & 0x3f);
+ if ( packet.m_nChannel == 0 )
+ {
+ if (ReadN(&type,1) != 1)
+ {
+ Log(LOGERROR, "%s, failed to read RTMP packet header 2nd byte", __FUNCTION__);
+ return false;
+ }
+ packet.m_nChannel = (unsigned)type;
+ packet.m_nChannel += 64;
+ } else if ( packet.m_nChannel == 1 )
+ {
+ char t[2];
+ int tmp;
+ if (ReadN(t,2) != 2)
+ {
+ Log(LOGERROR, "%s, failed to read RTMP packet header 3rd byte", __FUNCTION__);
+ return false;
+ }
+ tmp = (((unsigned)t[0])<<8) + (unsigned)t[1];
+ packet.m_nChannel = tmp + 64;
+ Log(LOGDEBUG, "%s, m_nChannel: %0x", __FUNCTION__, packet.m_nChannel);
+ }
int nSize = packetSize[packet.m_headerType];
diff -wur old/rtmp.h new/rtmp.h
--- old/rtmp.h 2009-05-12 17:15:20.000000000 -0700
+++ new/rtmp.h 2009-07-26 19:56:43.000000000 -0700
@@ -205,14 +211,12 @@
char *m_pBuffer; // data read from socket
char *m_pBufferStart; // pointer into m_pBuffer of next byte to process
int m_nBufferSize; // number of unprocessed bytes in buffer
- RTMPPacket m_vecChannelsIn[64];
- RTMPPacket m_vecChannelsOut[64];
- int m_channelTimestamp[64]; // abs timestamp of last packet
+ RTMPPacket m_vecChannelsIn[65600];
+ RTMPPacket m_vecChannelsOut[65600];
+ int m_channelTimestamp[65600]; // abs timestamp of last packet
double m_fDuration; // duration of stream in seconds
};
};
#endif
-
-
diff -wur old/rtmppacket.h new/rtmppacket.h
--- old/rtmppacket.h 2009-05-14 09:45:32.000000000 -0700
+++ new/rtmppacket.h 2009-07-13 22:33:23.000000000 -0700
@@ -56,7 +56,7 @@
BYTE m_headerType;
BYTE m_packetType;
- BYTE m_nChannel;
+ int m_nChannel;
int32_t m_nInfoField1; // 3 first bytes
int32_t m_nInfoField2; // last 4 bytes in a long header, absolute timestamp for long headers, relative timestamp for short headers
bool m_hasAbsTimestamp; // timestamp absolute or relative?
I should point out, it's possible I have the 3 byte decode wrong; the text says the 3rd byte is most significant, but the Figure implies that it's the 2nd byte. So maybe it should be t[0] + t[1] << 8 instead. I suspect though that the actual value doesn't matter to us...