コード例 #1
0
ファイル: amf0.c プロジェクト: hslinxubin/libamf
/* load AMF data from stream */
amf0_data * amf0_data_read(read_proc_t read_proc, void * user_data) {
    uint8_t type;
    if (read_proc(&type, sizeof(uint8_t), user_data) == sizeof(uint8_t)) {
        switch (type) {
            case AMF0_TYPE_NUMBER:
                return amf0_number_read(read_proc, user_data);
            case AMF0_TYPE_BOOLEAN:
                return amf0_boolean_read(read_proc, user_data);
            case AMF0_TYPE_STRING:
                return amf0_string_read(read_proc, user_data);
            case AMF0_TYPE_OBJECT:
                return amf0_object_read(read_proc, user_data);
            case AMF0_TYPE_NULL:
                return amf0_null_new();
            case AMF0_TYPE_UNDEFINED:
                return amf0_undefined_new();
            /*case AMF0_TYPE_REFERENCE:*/
            case AMF0_TYPE_ECMA_ARRAY:
                return amf0_associative_array_read(read_proc, user_data);
            case AMF0_TYPE_STRICT_ARRAY:
                return amf0_array_read(read_proc, user_data);
            case AMF0_TYPE_DATE:
                return amf0_date_read(read_proc, user_data);
            /*case AMF0_TYPE_SIMPLEOBJECT:*/
            case AMF0_TYPE_XML_DOCUMENT:
            case AMF0_TYPE_TYPED_OBJECT:
            case AMF0_TYPE_OBJECT_END:
                return NULL; /* end of composite object */
            default:
                break;
        }
    }
    return NULL;
}
コード例 #2
0
ファイル: amf0.c プロジェクト: xuyetao1351552/libamf
/* load AMF data from stream */
amf0_data * amf0_data_read(read_proc_t read_proc, void * user_data) {
    uint8_t type;
    if (read_proc(&type, sizeof(uint8_t), user_data) == sizeof(uint8_t)) {
        switch (type) {
            case AMF0_TYPE_NUMBER:
                return amf0_number_read(read_proc, user_data);
            case AMF0_TYPE_BOOLEAN:
                return amf0_boolean_read(read_proc, user_data);
            case AMF0_TYPE_STRING:
                return amf0_string_read(read_proc, user_data);
            case AMF0_TYPE_OBJECT:
                return amf0_object_read(read_proc, user_data);
            case AMF0_TYPE_MOVIECLIP:
                return NULL; /* not supported */
            case AMF0_TYPE_NULL:
                return amf0_null_new();
            case AMF0_TYPE_UNDEFINED:
                return amf0_undefined_new();
            case AMF0_TYPE_REFERENCE: /* TODO */
                return NULL;
            case AMF0_TYPE_ECMA_ARRAY:
                return amf0_associative_array_read(read_proc, user_data);
            case AMF0_TYPE_OBJECT_END:
                return amf0_data_error(AMF0_ERROR_END_TAG); /* end of composite object */
            case AMF0_TYPE_STRICT_ARRAY:
                return amf0_array_read(read_proc, user_data);
            case AMF0_TYPE_DATE:
                return amf0_date_read(read_proc, user_data);
            case AMF0_TYPE_LONG_STRING: /* TODO */
            case AMF0_TYPE_UNSUPPORTED: /* TODO */
            case AMF0_TYPE_RECORDSET: /* not supported */
            case AMF0_TYPE_XML_DOCUMENT: /* TODO */
            case AMF0_TYPE_TYPED_OBJECT: /* TODO */
                return NULL;
            default:
                break;
        }
    }
    return NULL;
}