winlin

for bug https://github.com/winlinvip/st-load/pull/3, add ecma array to object.

... ... @@ -1740,6 +1740,22 @@ srs_amf0_t srs_amf0_create_object()
return SrsAmf0Any::object();
}
srs_amf0_t srs_amf0_ecma_array_to_object(srs_amf0_t ecma_arr)
{
srs_assert(srs_amf0_is_ecma_array(ecma_arr));
SrsAmf0EcmaArray* arr = (SrsAmf0EcmaArray*)ecma_arr;
SrsAmf0Object* obj = SrsAmf0Any::object();
for (int i = 0; i < arr->count(); i++) {
std::string key = arr->key_at(i);
SrsAmf0Any* value = arr->value_at(i);
obj->set(key, value->copy());
}
return obj;
}
void srs_amf0_free(srs_amf0_t amf0)
{
SrsAmf0Any* any = (SrsAmf0Any*)amf0;
... ...
... ... @@ -552,12 +552,14 @@ typedef double srs_amf0_number;
* parse amf0 from data.
* @param nparsed, the parsed size, NULL to ignore.
* @return the parsed amf0 object. NULL for error.
* @remark user must free the parsed or created object by srs_amf0_free.
*/
extern srs_amf0_t srs_amf0_parse(char* data, int size, int* nparsed);
extern srs_amf0_t srs_amf0_create_number(srs_amf0_number value);
extern srs_amf0_t srs_amf0_create_ecma_array();
extern srs_amf0_t srs_amf0_create_strict_array();
extern srs_amf0_t srs_amf0_create_object();
extern srs_amf0_t srs_amf0_ecma_array_to_object(srs_amf0_t ecma_arr);
extern void srs_amf0_free(srs_amf0_t amf0);
/* size and to bytes */
extern int srs_amf0_size(srs_amf0_t amf0);
... ...