iOS-为librtmp库添加向服务器发送录制命令方法
Posted 微笑永不打烊
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS-为librtmp库添加向服务器发送录制命令方法相关的知识,希望对你有一定的参考价值。
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);
}
以上是关于iOS-为librtmp库添加向服务器发送录制命令方法的主要内容,如果未能解决你的问题,请参考以下文章
ffmpeg添加库实战:移植srs-librtmp到ffmpeg
ffmpeg添加库实战:移植srs-librtmp到ffmpeg
vs2012 MinGW 编译ffmeg 引用外部库libx264,librtmp