码迷,mamicode.com
首页 > 移动开发 > 详细

iOS-为librtmp库添加向服务器发送录制命令方法

时间:2016-07-04 09:58:06      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:

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库添加向服务器发送录制命令方法

标签:

原文地址:http://www.cnblogs.com/liyanyan/p/5639429.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!