标签:
SAVC(recordName);
SAVC(confID);
SAVC(timestamp);
#define AVS(str) {str,strlen(str)}
int
startRecord(RTMP *r, RTMPPacket *cp, char *recordData, char *recordName, char *confID, char *timestamp)
{
RTMPPacket packet;
char pbuf[1024], *pend = pbuf + sizeof(pbuf);
char *enc;
if (cp)
return RTMP_SendPacket(r, cp, TRUE);
const AVal avaldata = AVS(recordData);
const AVal avalName = AVS(recordName);
const AVal avalConfID = AVS(confID);
const AVal avalTimeStamp = AVS(timestamp);
packet.m_nChannel = 0x04; /* source channel (invoke) */
packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
packet.m_packetType = RTMP_PACKET_TYPE_INFO; /* DATA */
packet.m_nTimeStamp = 0;
packet.m_nInfoField2 = r->m_stream_id;
packet.m_hasAbsTimestamp = 0;
packet.m_body = pbuf + RTMP_MAX_HEADER_SIZE;
enc = packet.m_body;
enc = AMF_EncodeString(enc, pend, &avaldata);
if (!enc)
return FALSE;
*enc++ = AMF_OBJECT;
enc = AMF_EncodeNamedString(enc, pend, &av_recordName, &avalName);
if (!enc)
return FALSE;
enc = AMF_EncodeNamedString(enc, pend, &av_confID, &avalConfID);
if (!enc)
return FALSE;
enc = AMF_EncodeNamedString(enc, pend, &av_timestamp, &avalTimeStamp);
if (!enc)
return FALSE;
if (enc + 3 >= pend)
return FALSE;
*enc++ = 0;
*enc++ = 0; /* end of object - 0x00 0x00 0x09 */
*enc++ = AMF_OBJECT_END;
packet.m_nBodySize = enc - packet.m_body;
return RTMP_SendPacket(r, &packet, TRUE);
}
标签:
原文地址:http://www.cnblogs.com/liyanyan/p/5639429.html