Exemplo n.º 1
0
int SendPlayStop(RTMP *r)
{
    RTMPPacket packet;
    char pbuf[512], *pend = pbuf+sizeof(pbuf);

    packet.m_nChannel = 0x03;     // control channel (invoke)
    packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
    packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
    packet.m_nTimeStamp = 0;
    packet.m_nInfoField2 = 0;
    packet.m_hasAbsTimestamp = 0;
    packet.m_body = pbuf + RTMP_MAX_HEADER_SIZE;

    char *enc = packet.m_body;
    enc = AMF_EncodeString(enc, pend, &av_onStatus);
    enc = AMF_EncodeNumber(enc, pend, 0);
    *enc++ = AMF_NULL;
    *enc++ = AMF_OBJECT;

    enc = AMF_EncodeNamedString(enc, pend, &av_level, &av_status);
    enc = AMF_EncodeNamedString(enc, pend, &av_code, &av_NetStream_Play_Stop);
    enc = AMF_EncodeNamedString(enc, pend, &av_description, &av_Stopped_playing);
    enc = AMF_EncodeNamedString(enc, pend, &av_details, &r->Link.playpath);
    enc = AMF_EncodeNamedString(enc, pend, &av_clientid, &av_clientid);
    *enc++ = 0;
    *enc++ = 0;
    *enc++ = AMF_OBJECT_END;

    packet.m_nBodySize = enc - packet.m_body;
    return RTMP_SendPacket(r, &packet, FALSE);
}
Exemplo n.º 2
0
static int
SendConnectResult(RTMP *r, double txn)
{
  RTMPPacket packet;
  char pbuf[384], *pend = pbuf+sizeof(pbuf);
  AMFObject obj;
  AMFObjectProperty p, op;
  AVal av;

  packet.m_nChannel = 0x03;     // control channel (invoke)
  packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
  packet.m_packetType = 0x14;   // INVOKE
  packet.m_nTimeStamp = 0;
  packet.m_nInfoField2 = 0;
  packet.m_hasAbsTimestamp = 0;
  packet.m_body = pbuf + RTMP_MAX_HEADER_SIZE;

  char *enc = packet.m_body;
  enc = AMF_EncodeString(enc, pend, &av__result);
  enc = AMF_EncodeNumber(enc, pend, txn);
  *enc++ = AMF_OBJECT;

  STR2AVAL(av, "FMS/3,5,1,525");
  enc = AMF_EncodeNamedString(enc, pend, &av_fmsVer, &av);
  enc = AMF_EncodeNamedNumber(enc, pend, &av_capabilities, 31.0);
  enc = AMF_EncodeNamedNumber(enc, pend, &av_mode, 1.0);
  *enc++ = 0;
  *enc++ = 0;
  *enc++ = AMF_OBJECT_END;

  *enc++ = AMF_OBJECT;

  STR2AVAL(av, "status");
  enc = AMF_EncodeNamedString(enc, pend, &av_level, &av);
  STR2AVAL(av, "NetConnection.Connect.Success");
  enc = AMF_EncodeNamedString(enc, pend, &av_code, &av);
  STR2AVAL(av, "Connection succeeded.");
  enc = AMF_EncodeNamedString(enc, pend, &av_description, &av);
  enc = AMF_EncodeNamedNumber(enc, pend, &av_objectEncoding, r->m_fEncoding);
#if 0
  STR2AVAL(av, "58656322c972d6cdf2d776167575045f8484ea888e31c086f7b5ffbd0baec55ce442c2fb");
  enc = AMF_EncodeNamedString(enc, pend, &av_secureToken, &av);
#endif
  STR2AVAL(p.p_name, "version");
  STR2AVAL(p.p_vu.p_aval, "3,5,1,525");
  p.p_type = AMF_STRING;
  obj.o_num = 1;
  obj.o_props = &p;
  op.p_type = AMF_OBJECT;
  STR2AVAL(op.p_name, "data");
  op.p_vu.p_object = obj;
  enc = AMFProp_Encode(&op, enc, pend);
  *enc++ = 0;
  *enc++ = 0;
  *enc++ = AMF_OBJECT_END;

  packet.m_nBodySize = enc - packet.m_body;

  return RTMP_SendPacket(r, &packet, FALSE);
}
Exemplo n.º 3
0
static char* amf_encode_name_value_string(char* out, char* outend, const char* name, const char* value)
{
	AVal n, v;
	n.av_len = strlen(name);
	n.av_val = (char*)name;
	v.av_len = strlen(value);
	v.av_val = (char*)value;

	return AMF_EncodeNamedString(out, outend, &n, &v);
}
Exemplo n.º 4
0
char* OBS::EncMetaData(char *enc, char *pend, bool bFLVFile)
{
    int    maxBitRate    = GetVideoEncoder()->GetBitRate();
    int    fps           = GetFPS();
    int    audioBitRate  = GetAudioEncoder()->GetBitRate();
    CTSTR  lpAudioCodec  = GetAudioEncoder()->GetCodec();

    double audioCodecID;
    const AVal *av_codecFourCC;

#ifdef USE_AAC
    if(scmpi(lpAudioCodec, TEXT("AAC")) == 0)
    {
        av_codecFourCC = &av_mp4a;
        audioCodecID = 10.0;
    }
    else
#endif
    {
        av_codecFourCC = &av_mp3;
        audioCodecID = 2.0;
    }

    if(bFLVFile)
    {
        *enc++ = AMF_ECMA_ARRAY;
        enc = AMF_EncodeInt32(enc, pend, 14);
    }
    else
        *enc++ = AMF_OBJECT;

    enc = AMF_EncodeNamedNumber(enc, pend, &av_duration,        0.0);
    enc = AMF_EncodeNamedNumber(enc, pend, &av_fileSize,        0.0);
    enc = AMF_EncodeNamedNumber(enc, pend, &av_width,           double(outputCX));
    enc = AMF_EncodeNamedNumber(enc, pend, &av_height,          double(outputCY));

    /*if(bFLVFile)
        enc = AMF_EncodeNamedNumber(enc, pend, &av_videocodecid,    7.0);//&av_avc1);//
    else*/
        enc = AMF_EncodeNamedString(enc, pend, &av_videocodecid,    &av_avc1);//7.0);//

    enc = AMF_EncodeNamedNumber(enc, pend, &av_videodatarate,   double(maxBitRate));
    enc = AMF_EncodeNamedNumber(enc, pend, &av_framerate,       double(fps));

    /*if(bFLVFile)
        enc = AMF_EncodeNamedNumber(enc, pend, &av_audiocodecid,    audioCodecID);//av_codecFourCC);//
    else*/
        enc = AMF_EncodeNamedString(enc, pend, &av_audiocodecid,    av_codecFourCC);//audioCodecID);//

    enc = AMF_EncodeNamedNumber(enc, pend, &av_audiodatarate,   double(audioBitRate)); //ex. 128kb\s
    enc = AMF_EncodeNamedNumber(enc, pend, &av_audiosamplerate, 44100.0);
    enc = AMF_EncodeNamedNumber(enc, pend, &av_audiosamplesize, 16.0);
    enc = AMF_EncodeNamedNumber(enc, pend, &av_audiochannels,   2.0);
    enc = AMF_EncodeNamedBoolean(enc, pend, &av_stereo,         true);
    enc = AMF_EncodeNamedString(enc, pend, &av_encoder,         &av_OBSVersion);
    *enc++ = 0;
    *enc++ = 0;
    *enc++ = AMF_OBJECT_END;

    return enc;
}
Exemplo n.º 5
0
uint8_t inline *amf_write_str_kv(uint8_t *s, uint8_t *e, const char *k, const char *v)
{
    AVal a = AVALSTR(k);
    AVal b = AVALSTR(v);
    return (uint8_t *)AMF_EncodeNamedString((char*)s, (char*)e, &a, &b);
}