for bug https://github.com/winlinvip/st-load/pull/3, add ecma array to object.
正在显示
2 个修改的文件
包含
18 行增加
和
0 行删除
@@ -1740,6 +1740,22 @@ srs_amf0_t srs_amf0_create_object() | @@ -1740,6 +1740,22 @@ srs_amf0_t srs_amf0_create_object() | ||
1740 | return SrsAmf0Any::object(); | 1740 | return SrsAmf0Any::object(); |
1741 | } | 1741 | } |
1742 | 1742 | ||
1743 | +srs_amf0_t srs_amf0_ecma_array_to_object(srs_amf0_t ecma_arr) | ||
1744 | +{ | ||
1745 | + srs_assert(srs_amf0_is_ecma_array(ecma_arr)); | ||
1746 | + | ||
1747 | + SrsAmf0EcmaArray* arr = (SrsAmf0EcmaArray*)ecma_arr; | ||
1748 | + SrsAmf0Object* obj = SrsAmf0Any::object(); | ||
1749 | + | ||
1750 | + for (int i = 0; i < arr->count(); i++) { | ||
1751 | + std::string key = arr->key_at(i); | ||
1752 | + SrsAmf0Any* value = arr->value_at(i); | ||
1753 | + obj->set(key, value->copy()); | ||
1754 | + } | ||
1755 | + | ||
1756 | + return obj; | ||
1757 | +} | ||
1758 | + | ||
1743 | void srs_amf0_free(srs_amf0_t amf0) | 1759 | void srs_amf0_free(srs_amf0_t amf0) |
1744 | { | 1760 | { |
1745 | SrsAmf0Any* any = (SrsAmf0Any*)amf0; | 1761 | SrsAmf0Any* any = (SrsAmf0Any*)amf0; |
@@ -552,12 +552,14 @@ typedef double srs_amf0_number; | @@ -552,12 +552,14 @@ typedef double srs_amf0_number; | ||
552 | * parse amf0 from data. | 552 | * parse amf0 from data. |
553 | * @param nparsed, the parsed size, NULL to ignore. | 553 | * @param nparsed, the parsed size, NULL to ignore. |
554 | * @return the parsed amf0 object. NULL for error. | 554 | * @return the parsed amf0 object. NULL for error. |
555 | +* @remark user must free the parsed or created object by srs_amf0_free. | ||
555 | */ | 556 | */ |
556 | extern srs_amf0_t srs_amf0_parse(char* data, int size, int* nparsed); | 557 | extern srs_amf0_t srs_amf0_parse(char* data, int size, int* nparsed); |
557 | extern srs_amf0_t srs_amf0_create_number(srs_amf0_number value); | 558 | extern srs_amf0_t srs_amf0_create_number(srs_amf0_number value); |
558 | extern srs_amf0_t srs_amf0_create_ecma_array(); | 559 | extern srs_amf0_t srs_amf0_create_ecma_array(); |
559 | extern srs_amf0_t srs_amf0_create_strict_array(); | 560 | extern srs_amf0_t srs_amf0_create_strict_array(); |
560 | extern srs_amf0_t srs_amf0_create_object(); | 561 | extern srs_amf0_t srs_amf0_create_object(); |
562 | +extern srs_amf0_t srs_amf0_ecma_array_to_object(srs_amf0_t ecma_arr); | ||
561 | extern void srs_amf0_free(srs_amf0_t amf0); | 563 | extern void srs_amf0_free(srs_amf0_t amf0); |
562 | /* size and to bytes */ | 564 | /* size and to bytes */ |
563 | extern int srs_amf0_size(srs_amf0_t amf0); | 565 | extern int srs_amf0_size(srs_amf0_t amf0); |
-
请 注册 或 登录 后发表评论