zoukankan      html  css  js  c++  java
  • iOS-为librtmp库添加向服务器发送录制命令方法

    为librtmp库添加向服务器发送录制命令方法是基于librtmp库而写,recordData为录制命令,recordName、confID、timestamp为录制命令参数。

    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;  //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);

    }

     

  • 相关阅读:
    《那些年,我们拿下FPGA》做笔记
    三种初始化
    hdu4417 Super Mario 树阵离线/划分树
    【设计模式】文章摘要 查找联系人控件
    STL set
    阐述 QUEST CENTRAL FOR DB2 八罪
    使用线程执行堆栈StackTraceElement设计Android日志模块
    苹果iOS苹果公司的手机用户都有权索赔
    Android 4.4 沉浸式透明状态栏与导航栏
    常见的几种RuntimeException
  • 原文地址:https://www.cnblogs.com/liyanyan/p/5639429.html
Copyright © 2011-2022 走看看