|
|
|
@ -484,6 +484,12 @@ amf0_bool srs_amf0_is_ecma_array(srs_amf0_t amf0)
|
|
|
|
|
return any->is_ecma_array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
amf0_bool srs_amf0_is_strict_array(srs_amf0_t amf0)
|
|
|
|
|
{
|
|
|
|
|
SrsAmf0Any* any = (SrsAmf0Any*)amf0;
|
|
|
|
|
return any->is_strict_array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* srs_amf0_to_string(srs_amf0_t amf0)
|
|
|
|
|
{
|
|
|
|
|
SrsAmf0Any* any = (SrsAmf0Any*)amf0;
|
|
|
|
@ -520,32 +526,44 @@ srs_amf0_t srs_amf0_object_property_value_at(srs_amf0_t amf0, int index)
|
|
|
|
|
return (srs_amf0_t)obj->value_at(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int srs_amf0_array_property_count(srs_amf0_t amf0)
|
|
|
|
|
int srs_amf0_ecma_array_property_count(srs_amf0_t amf0)
|
|
|
|
|
{
|
|
|
|
|
SrsAmf0EcmaArray * obj = (SrsAmf0EcmaArray*)amf0;
|
|
|
|
|
return obj->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* srs_amf0_array_property_name_at(srs_amf0_t amf0, int index)
|
|
|
|
|
const char* srs_amf0_ecma_array_property_name_at(srs_amf0_t amf0, int index)
|
|
|
|
|
{
|
|
|
|
|
SrsAmf0EcmaArray* obj = (SrsAmf0EcmaArray*)amf0;
|
|
|
|
|
return obj->key_raw_at(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srs_amf0_t srs_amf0_array_property_value_at(srs_amf0_t amf0, int index)
|
|
|
|
|
srs_amf0_t srs_amf0_ecma_array_property_value_at(srs_amf0_t amf0, int index)
|
|
|
|
|
{
|
|
|
|
|
SrsAmf0EcmaArray* obj = (SrsAmf0EcmaArray*)amf0;
|
|
|
|
|
return (srs_amf0_t)obj->value_at(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void __srs_amf0_do_print(SrsAmf0Any* any, stringstream& ss, int& level)
|
|
|
|
|
int srs_amf0_strict_array_property_count(srs_amf0_t amf0)
|
|
|
|
|
{
|
|
|
|
|
if (true) {
|
|
|
|
|
for (int i = 0; i < level; i++) {
|
|
|
|
|
ss << " ";
|
|
|
|
|
}
|
|
|
|
|
SrsAmf0EcmaArray * obj = (SrsAmf0EcmaArray*)amf0;
|
|
|
|
|
return obj->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srs_amf0_t srs_amf0_strict_array_property_at(srs_amf0_t amf0, int index)
|
|
|
|
|
{
|
|
|
|
|
SrsAmf0EcmaArray* obj = (SrsAmf0EcmaArray*)amf0;
|
|
|
|
|
return (srs_amf0_t)obj->value_at(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void __srs_fill_level_spaces(stringstream& ss, int level)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < level; i++) {
|
|
|
|
|
ss << " ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void __srs_amf0_do_print(SrsAmf0Any* any, stringstream& ss, int level)
|
|
|
|
|
{
|
|
|
|
|
if (any->is_boolean()) {
|
|
|
|
|
ss << "Boolean " << (any->to_boolean()? "true":"false") << endl;
|
|
|
|
|
} else if (any->is_number()) {
|
|
|
|
@ -558,26 +576,36 @@ void __srs_amf0_do_print(SrsAmf0Any* any, stringstream& ss, int& level)
|
|
|
|
|
SrsAmf0EcmaArray* obj = any->to_ecma_array();
|
|
|
|
|
ss << "EcmaArray " << "(" << obj->count() << " items)" << endl;
|
|
|
|
|
for (int i = 0; i < obj->count(); i++) {
|
|
|
|
|
ss << " Property '" << obj->key_at(i) << "' ";
|
|
|
|
|
if (obj->value_at(i)->is_object() || obj->value_at(i)->is_ecma_array()) {
|
|
|
|
|
int next_level = level + 1;
|
|
|
|
|
__srs_amf0_do_print(obj->value_at(i), ss, next_level);
|
|
|
|
|
__srs_fill_level_spaces(ss, level + 1);
|
|
|
|
|
ss << "Elem '" << obj->key_at(i) << "' ";
|
|
|
|
|
if (obj->value_at(i)->is_complex_object()) {
|
|
|
|
|
__srs_amf0_do_print(obj->value_at(i), ss, level + 1);
|
|
|
|
|
} else {
|
|
|
|
|
int next_level = 0;
|
|
|
|
|
__srs_amf0_do_print(obj->value_at(i), ss, next_level);
|
|
|
|
|
__srs_amf0_do_print(obj->value_at(i), ss, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (any->is_strict_array()) {
|
|
|
|
|
SrsAmf0StrictArray* obj = any->to_strict_array();
|
|
|
|
|
ss << "StrictArray " << "(" << obj->count() << " items)" << endl;
|
|
|
|
|
for (int i = 0; i < obj->count(); i++) {
|
|
|
|
|
__srs_fill_level_spaces(ss, level + 1);
|
|
|
|
|
ss << "Elem ";
|
|
|
|
|
if (obj->at(i)->is_complex_object()) {
|
|
|
|
|
__srs_amf0_do_print(obj->at(i), ss, level + 1);
|
|
|
|
|
} else {
|
|
|
|
|
__srs_amf0_do_print(obj->at(i), ss, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (any->is_object()) {
|
|
|
|
|
SrsAmf0Object* obj = any->to_object();
|
|
|
|
|
ss << "Object " << "(" << obj->count() << " items)" << endl;
|
|
|
|
|
for (int i = 0; i < obj->count(); i++) {
|
|
|
|
|
ss << " Property '" << obj->key_at(i) << "' ";
|
|
|
|
|
if (obj->value_at(i)->is_object() || obj->value_at(i)->is_ecma_array()) {
|
|
|
|
|
int next_level = level + 1;
|
|
|
|
|
__srs_amf0_do_print(obj->value_at(i), ss, next_level);
|
|
|
|
|
__srs_fill_level_spaces(ss, level + 1);
|
|
|
|
|
ss << "Property '" << obj->key_at(i) << "' ";
|
|
|
|
|
if (obj->value_at(i)->is_complex_object()) {
|
|
|
|
|
__srs_amf0_do_print(obj->value_at(i), ss, level + 1);
|
|
|
|
|
} else {
|
|
|
|
|
int next_level = 0;
|
|
|
|
|
__srs_amf0_do_print(obj->value_at(i), ss, next_level);
|
|
|
|
|
__srs_amf0_do_print(obj->value_at(i), ss, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@ -587,23 +615,29 @@ void __srs_amf0_do_print(SrsAmf0Any* any, stringstream& ss, int& level)
|
|
|
|
|
|
|
|
|
|
char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize)
|
|
|
|
|
{
|
|
|
|
|
if (!amf0) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stringstream ss;
|
|
|
|
|
|
|
|
|
|
ss.precision(1);
|
|
|
|
|
|
|
|
|
|
SrsAmf0Any* any = (SrsAmf0Any*)amf0;
|
|
|
|
|
|
|
|
|
|
int level = 0;
|
|
|
|
|
__srs_amf0_do_print(any, ss, level);
|
|
|
|
|
__srs_amf0_do_print(any, ss, 0);
|
|
|
|
|
|
|
|
|
|
string str = ss.str();
|
|
|
|
|
if (str.empty()) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*pdata = new char[str.length()];
|
|
|
|
|
char* data = new char[str.length() + 1];
|
|
|
|
|
memcpy(data, str.data(), str.length());
|
|
|
|
|
data[str.length()] = 0;
|
|
|
|
|
|
|
|
|
|
*pdata = data;
|
|
|
|
|
*psize = str.length();
|
|
|
|
|
memcpy(*pdata, str.data(), str.length());
|
|
|
|
|
|
|
|
|
|
return *pdata;
|
|
|
|
|
}
|
|
|
|
|