GF_Err ienc_box_dump(GF_Box *a, FILE * trace)
{
	u32 i, nb_keys, kpos;
	GF_ItemEncryptionPropertyBox *ptr = (GF_ItemEncryptionPropertyBox *)a;
	if (!a) return GF_BAD_PARAM;
	gf_isom_box_dump_start(a, "ItemEncryptionPropertyBox", trace);
	if (ptr->version)
		gf_fprintf(trace, " skip_byte_block=\"%d\" crypt_byte_block=\"%d\"", ptr->skip_byte_block, ptr->crypt_byte_block);
	gf_fprintf(trace, ">\n");
	nb_keys = ptr->key_info ? ptr->key_info[2] : 0;
	kpos = 3;
	for (i = 0; i < nb_keys; i++) {
		u8 iv_size = ptr->key_info[kpos];
		gf_fprintf(trace, "<KeyInfo KID=\"");
		dump_data_hex(trace, ptr->key_info + kpos + 1, 16);
		gf_fprintf(trace, "\"");
		kpos+=17;
		if (iv_size) {
			gf_fprintf(trace, " IV_size=\"%d\"/>\n", iv_size);
		} else {
			iv_size = ptr->key_info[kpos];
			gf_fprintf(trace, " constant_IV_size=\"%d\" constant_IV=\"", iv_size);
			dump_data_hex(trace, ptr->key_info + kpos + 1, iv_size);
			gf_fprintf(trace, "\"/>\n");
			kpos += 1 + iv_size;
		}
	}
	if (!ptr->size)
		gf_fprintf(trace, "<KeyInfo KID=\"\" IV_size=\"\" constant_IV_size=\"\" constant_IV=\"\" />\n");

	gf_isom_box_dump_done("ItemEncryptionPropertyBox", a, trace);
	return GF_OK;
}
GF_Err ienc_box_dump(GF_Box *a, FILE * trace)
{
	u32 i, nb_keys, kpos;
	GF_ItemEncryptionPropertyBox *ptr = (GF_ItemEncryptionPropertyBox *)a;
	if (!a) return GF_BAD_PARAM;
	gf_isom_box_dump_start(a, "ItemEncryptionPropertyBox", trace);
	if (ptr->version)
		gf_fprintf(trace, " skip_byte_block=\"%d\" crypt_byte_block=\"%d\"", ptr->skip_byte_block, ptr->crypt_byte_block);
	gf_fprintf(trace, ">\n");
	nb_keys = ptr->key_info ? ptr->key_info[2] : 0;
	kpos = 3;
	for (i = 0; i < nb_keys; i++) {
		u8 iv_size = ptr->key_info[kpos];
		gf_fprintf(trace, "<KeyInfo KID=\"");
		dump_data_hex(trace, ptr->key_info + kpos + 1, 16);
		gf_fprintf(trace, "\"");
		kpos+=17;
		if (iv_size) {
			gf_fprintf(trace, " IV_size=\"%d\"/>\n", iv_size);
		} else {
			iv_size = ptr->key_info[kpos];
			gf_fprintf(trace, " constant_IV_size=\"%d\" constant_IV=\"", iv_size);
			dump_data_hex(trace, ptr->key_info + kpos + 1, iv_size);
			gf_fprintf(trace, "\"/>\n");
			kpos += 1 + iv_size;
		}
	}
	if (!ptr->size)
		gf_fprintf(trace, "<KeyInfo KID=\"\" IV_size=\"\" constant_IV_size=\"\" constant_IV=\"\" />\n");

	gf_isom_box_dump_done("ItemEncryptionPropertyBox", a, trace);
	return GF_OK;
}