本文整理汇总了C++中SrsAmf0EcmaArray::set方法的典型用法代码示例。如果您正苦于以下问题:C++ SrsAmf0EcmaArray::set方法的具体用法?C++ SrsAmf0EcmaArray::set怎么用?C++ SrsAmf0EcmaArray::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SrsAmf0EcmaArray
的用法示例。
在下文中一共展示了SrsAmf0EcmaArray::set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: srs_amf0_ecma_array_property_set
void srs_amf0_ecma_array_property_set(srs_amf0_t amf0, const char* name, srs_amf0_t value)
{
SrsAmf0Any* any = (SrsAmf0Any*)amf0;
srs_assert(any->is_ecma_array());
SrsAmf0EcmaArray* obj = (SrsAmf0EcmaArray*)amf0;
any = (SrsAmf0Any*)value;
obj->set(name, any);
}
示例2: response_connect_app
int SrsRtmpServer::response_connect_app(SrsRequest *req, const char* server_ip)
{
int ret = ERROR_SUCCESS;
SrsConnectAppResPacket* pkt = new SrsConnectAppResPacket();
pkt->props->set("fmsVer", SrsAmf0Any::str("FMS/"RTMP_SIG_FMS_VER));
pkt->props->set("capabilities", SrsAmf0Any::number(127));
pkt->props->set("mode", SrsAmf0Any::number(1));
pkt->info->set(StatusLevel, SrsAmf0Any::str(StatusLevelStatus));
pkt->info->set(StatusCode, SrsAmf0Any::str(StatusCodeConnectSuccess));
pkt->info->set(StatusDescription, SrsAmf0Any::str("Connection succeeded"));
pkt->info->set("objectEncoding", SrsAmf0Any::number(req->objectEncoding));
SrsAmf0EcmaArray* data = SrsAmf0Any::ecma_array();
pkt->info->set("data", data);
data->set("version", SrsAmf0Any::str(RTMP_SIG_FMS_VER));
data->set("srs_sig", SrsAmf0Any::str(RTMP_SIG_SRS_KEY));
data->set("srs_server", SrsAmf0Any::str(RTMP_SIG_SRS_KEY" "RTMP_SIG_SRS_VERSION" ("RTMP_SIG_SRS_URL_SHORT")"));
data->set("srs_license", SrsAmf0Any::str(RTMP_SIG_SRS_LICENSE));
data->set("srs_role", SrsAmf0Any::str(RTMP_SIG_SRS_ROLE));
data->set("srs_url", SrsAmf0Any::str(RTMP_SIG_SRS_URL));
data->set("srs_version", SrsAmf0Any::str(RTMP_SIG_SRS_VERSION));
data->set("srs_site", SrsAmf0Any::str(RTMP_SIG_SRS_WEB));
data->set("srs_email", SrsAmf0Any::str(RTMP_SIG_SRS_EMAIL));
data->set("srs_copyright", SrsAmf0Any::str(RTMP_SIG_SRS_COPYRIGHT));
data->set("srs_primary_authors", SrsAmf0Any::str(RTMP_SIG_SRS_PRIMARY_AUTHROS));
if (server_ip) {
data->set("srs_server_ip", SrsAmf0Any::str(server_ip));
}
// for edge to directly get the id of client.
data->set("srs_pid", SrsAmf0Any::number(getpid()));
data->set("srs_id", SrsAmf0Any::number(_srs_context->get_id()));
if ((ret = protocol->send_and_free_packet(pkt, 0)) != ERROR_SUCCESS) {
srs_error("send connect app response message failed. ret=%d", ret);
return ret;
}
srs_info("send connect app response message success.");
return ret;
}
示例3: TEST
// user scenario: coding and decoding with amf0
VOID TEST(AMF0Test, ScenarioMain)
{
// coded amf0 object
int nb_bytes = 0;
char* bytes = NULL;
// coding data to binaries by amf0
// for example, send connect app response to client.
if (true) {
// props: object
// fmsVer: string
// capabilities: number
// mode: number
// info: object
// level: string
// code: string
// descrption: string
// objectEncoding: number
// data: array
// version: string
// srs_sig: string
SrsAmf0Object* props = SrsAmf0Any::object();
SrsAutoFree(SrsAmf0Object, props);
props->set("fmsVer", SrsAmf0Any::str("FMS/3,5,3,888"));
props->set("capabilities", SrsAmf0Any::number(253));
props->set("mode", SrsAmf0Any::number(123));
SrsAmf0Object* info = SrsAmf0Any::object();
SrsAutoFree(SrsAmf0Object, info);
info->set("level", SrsAmf0Any::str("info"));
info->set("code", SrsAmf0Any::str("NetStream.Connnect.Success"));
info->set("descrption", SrsAmf0Any::str("connected"));
info->set("objectEncoding", SrsAmf0Any::number(3));
SrsAmf0EcmaArray* data = SrsAmf0Any::ecma_array();
info->set("data", data);
data->set("version", SrsAmf0Any::str("FMS/3,5,3,888"));
data->set("srs_sig", SrsAmf0Any::str("srs"));
// buf store the serialized props/info
nb_bytes = props->total_size() + info->total_size();
ASSERT_GT(nb_bytes, 0);
bytes = new char[nb_bytes];
// use SrsStream to write props/info to binary buf.
SrsStream s;
EXPECT_EQ(ERROR_SUCCESS, s.initialize(bytes, nb_bytes));
EXPECT_EQ(ERROR_SUCCESS, props->write(&s));
EXPECT_EQ(ERROR_SUCCESS, info->write(&s));
EXPECT_TRUE(s.empty());
// now, user can use the buf
EXPECT_EQ(0x03, bytes[0]);
EXPECT_EQ(0x09, bytes[nb_bytes - 1]);
}
SrsAutoFree(char, bytes);
// decoding amf0 object from bytes
// when user know the schema
if (true) {
ASSERT_TRUE(NULL != bytes);
// use SrsStream to assist amf0 object to read from bytes.
SrsStream s;
EXPECT_EQ(ERROR_SUCCESS, s.initialize(bytes, nb_bytes));
// decoding
// if user know the schema, for instance, it's an amf0 object,
// user can use specified object to decoding.
SrsAmf0Object* props = SrsAmf0Any::object();
SrsAutoFree(SrsAmf0Object, props);
EXPECT_EQ(ERROR_SUCCESS, props->read(&s));
// user can use specified object to decoding.
SrsAmf0Object* info = SrsAmf0Any::object();
SrsAutoFree(SrsAmf0Object, info);
EXPECT_EQ(ERROR_SUCCESS, info->read(&s));
// use the decoded data.
SrsAmf0Any* prop = NULL;
// if user requires specified property, use ensure of amf0 object
EXPECT_TRUE(NULL != (prop = props->ensure_property_string("fmsVer")));
// the property can assert to string.
ASSERT_TRUE(prop->is_string());
// get the prop string value.
EXPECT_STREQ("FMS/3,5,3,888", prop->to_str().c_str());
// get other type property value
EXPECT_TRUE(NULL != (prop = info->get_property("data")));
// we cannot assert the property is ecma array
if (prop->is_ecma_array()) {
SrsAmf0EcmaArray* data = prop->to_ecma_array();
// it must be a ecma array.
ASSERT_TRUE(NULL != data);
// get property of array
EXPECT_TRUE(NULL != (prop = data->ensure_property_string("srs_sig")));
ASSERT_TRUE(prop->is_string());
//.........这里部分代码省略.........