📄 box_code_meta.c
字号:
if (e) return e; ptr->item_ID = gf_bs_read_u16(bs); return GF_OK;}#ifndef GPAC_READ_ONLYGF_Err pitm_Write(GF_Box *s, GF_BitStream *bs){ GF_Err e; GF_PrimaryItemBox *ptr = (GF_PrimaryItemBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u16(bs, ptr->item_ID); return GF_OK;}GF_Err pitm_Size(GF_Box *s){ GF_Err e; GF_ItemLocationBox *ptr = (GF_ItemLocationBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_get_size(s); if (e) return e; ptr->size += 16; return GF_OK;}#endifGF_Box *ipro_New(){ GF_ItemProtectionBox *tmp = (GF_ItemProtectionBox *) malloc(sizeof(GF_ItemProtectionBox)); if (tmp == NULL) return NULL; memset(tmp, 0, sizeof(GF_ItemProtectionBox)); gf_isom_full_box_init((GF_Box *)tmp); tmp->type = GF_ISOM_BOX_TYPE_IPRO; tmp->protection_information = gf_list_new(); return (GF_Box *)tmp;}void ipro_del(GF_Box *s){ u32 count, i; GF_ItemProtectionBox *ptr = (GF_ItemProtectionBox *)s; if (ptr == NULL) return; count = gf_list_count(ptr->protection_information); for (i = 0; i < count; i++) { GF_Box *a = (GF_Box *)gf_list_get(ptr->protection_information, i); gf_isom_box_del(a); } gf_list_del(ptr->protection_information); free(ptr);}GF_Err ipro_AddBox(GF_Box *s, GF_Box *a){ GF_ItemProtectionBox *ptr = (GF_ItemProtectionBox *)s; if (a->type == GF_ISOM_BOX_TYPE_SINF) gf_list_add(ptr->protection_information, a); else gf_isom_box_del(a); return GF_OK;}GF_Err ipro_Read(GF_Box *s, GF_BitStream *bs){ GF_Err e; e = gf_isom_full_box_read(s, bs); if (e) return e; return gf_isom_read_box_list(s, bs, ipro_AddBox);}#ifndef GPAC_READ_ONLYGF_Err ipro_Write(GF_Box *s, GF_BitStream *bs){ u32 count, i; GF_Err e; GF_ItemProtectionBox *ptr = (GF_ItemProtectionBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_write(s, bs); if (e) return e; count = gf_list_count(ptr->protection_information); gf_bs_write_u16(bs, count); if (count) { for (i = 0; i < count; i++) { GF_Box *a = (GF_Box *)gf_list_get(ptr->protection_information, i); e = gf_isom_box_write(a, bs); if (e) return e; } } return GF_OK;}GF_Err ipro_Size(GF_Box *s){ u32 i, count; GF_Err e; GF_ItemProtectionBox *ptr = (GF_ItemProtectionBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_get_size(s); if (e) return e; ptr->size += 2; if ((count = gf_list_count(ptr->protection_information))) { for (i = 0; i < count; i++) { GF_Box *a = (GF_Box *)gf_list_get(ptr->protection_information, i); e = gf_isom_box_size(a); if (e) return e; ptr->size += a->size; } } return GF_OK;}#endifGF_Box *infe_New(){ GF_ItemInfoEntryBox *tmp = (GF_ItemInfoEntryBox *) malloc(sizeof(GF_ItemInfoEntryBox)); if (tmp == NULL) return NULL; memset(tmp, 0, sizeof(GF_ItemInfoEntryBox)); gf_isom_full_box_init((GF_Box *)tmp); tmp->type = GF_ISOM_BOX_TYPE_INFE; return (GF_Box *)tmp;}void infe_del(GF_Box *s){ GF_ItemInfoEntryBox *ptr = (GF_ItemInfoEntryBox *)s; if (ptr == NULL) return; if (ptr->item_name) free(ptr->item_name); if (ptr->full_path) free(ptr->full_path); if (ptr->content_type) free(ptr->content_type); if (ptr->content_encoding) free(ptr->content_encoding); free(ptr);}GF_Err infe_Read(GF_Box *s, GF_BitStream *bs){ GF_Err e; char *buf; u32 buf_len, i, string_len, string_start; GF_ItemInfoEntryBox *ptr = (GF_ItemInfoEntryBox *)s; if (ptr == NULL) return GF_BAD_PARAM; e = gf_isom_full_box_read(s, bs); if (e) return e; ptr->item_ID = gf_bs_read_u16(bs); ptr->item_protection_index = gf_bs_read_u16(bs); ptr->size -= 4; buf_len = (u32) (ptr->size); buf = (char*)malloc(buf_len); if (buf_len != gf_bs_read_data(bs, buf, buf_len)) { free(buf); return GF_ISOM_INVALID_FILE; } string_len = 1; string_start = 0; for (i = 0; i < buf_len; i++) { if (buf[i] == 0) { if (!ptr->item_name) { ptr->item_name = (char*)malloc(sizeof(char)*string_len); memcpy(ptr->item_name, buf+string_start, string_len); } else if (!ptr->content_type) { ptr->content_type = (char*)malloc(sizeof(char)*string_len); memcpy(ptr->content_type, buf+string_start, string_len); } else { ptr->content_encoding = (char*)malloc(sizeof(char)*string_len); memcpy(ptr->content_encoding, buf+string_start, string_len); } string_start += string_len; string_len = 0; } string_len++; } free(buf); if (!ptr->item_name || !ptr->content_type) return GF_ISOM_INVALID_FILE; return GF_OK;}#ifndef GPAC_READ_ONLYGF_Err infe_Write(GF_Box *s, GF_BitStream *bs){ GF_Err e; u32 len; GF_ItemInfoEntryBox *ptr = (GF_ItemInfoEntryBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u16(bs, ptr->item_ID); gf_bs_write_u16(bs, ptr->item_protection_index); if (ptr->item_name) { len = strlen(ptr->item_name)+1; gf_bs_write_data(bs, ptr->item_name, len); } if (ptr->content_type) { len = strlen(ptr->content_type)+1; gf_bs_write_data(bs, ptr->content_type, len); } if (ptr->content_encoding) { len = strlen(ptr->content_encoding)+1; gf_bs_write_data(bs, ptr->content_encoding, len); } return GF_OK;}GF_Err infe_Size(GF_Box *s){ GF_Err e; GF_ItemInfoEntryBox *ptr = (GF_ItemInfoEntryBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_get_size(s); if (e) return e; ptr->size += 4; if (ptr->item_name) ptr->size += strlen(ptr->item_name)+1; if (ptr->content_type) ptr->size += strlen(ptr->content_type)+1; if (ptr->content_encoding) ptr->size += strlen(ptr->content_encoding)+1; return GF_OK;}#endifGF_Box *iinf_New(){ GF_ItemInfoBox *tmp = (GF_ItemInfoBox *) malloc(sizeof(GF_ItemInfoBox)); if (tmp == NULL) return NULL; memset(tmp, 0, sizeof(GF_ItemInfoBox)); gf_isom_full_box_init((GF_Box *)tmp); tmp->type = GF_ISOM_BOX_TYPE_IINF; tmp->item_infos = gf_list_new(); return (GF_Box *)tmp;}void iinf_del(GF_Box *s){ u32 count, i; GF_ItemInfoBox *ptr = (GF_ItemInfoBox *)s; if (ptr == NULL) return; count = gf_list_count(ptr->item_infos); for (i = 0; i < count; i++) { GF_Box *a = (GF_Box *)gf_list_get(ptr->item_infos, i); gf_isom_box_del(a); } gf_list_del(ptr->item_infos); free(ptr);}GF_Err iinf_Read(GF_Box *s, GF_BitStream *bs){ GF_Err e; GF_Box *a; u32 count; GF_ItemInfoBox *ptr = (GF_ItemInfoBox *)s; e = gf_isom_full_box_read(s, bs); if (e) return e; count = gf_bs_read_u16(bs); while (count) { e = gf_isom_parse_box(&a, bs); if (e) return e; if (ptr->size<a->size) return GF_ISOM_INVALID_FILE; if (a->type == GF_ISOM_BOX_TYPE_INFE) gf_list_add(ptr->item_infos, a); else gf_isom_box_del(a); count --; } return GF_OK;}#ifndef GPAC_READ_ONLYGF_Err iinf_Write(GF_Box *s, GF_BitStream *bs){ u32 count, i; GF_Err e; GF_ItemInfoBox *ptr = (GF_ItemInfoBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_write(s, bs); if (e) return e; count = gf_list_count(ptr->item_infos); gf_bs_write_u16(bs, count); if (count) { for (i = 0; i < count; i++) { GF_Box *a = (GF_Box *)gf_list_get(ptr->item_infos, i); e = gf_isom_box_write(a, bs); if (e) return e; } } return GF_OK;}GF_Err iinf_Size(GF_Box *s){ u32 i, count; GF_Err e; GF_ItemInfoBox *ptr = (GF_ItemInfoBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_get_size(s); if (e) return e; ptr->size += 2; if ((count = gf_list_count(ptr->item_infos))) { for (i = 0; i < count; i++) { GF_Box *a = (GF_Box *)gf_list_get(ptr->item_infos, i); e = gf_isom_box_size(a); if (e) return e; ptr->size += a->size; } } return GF_OK;}#endifGF_Box *imif_New(){ GF_IPMPInfoBox *tmp = (GF_IPMPInfoBox*) malloc(sizeof(GF_IPMPInfoBox)); if (tmp == NULL) return NULL; memset(tmp, 0, sizeof(GF_IPMPInfoBox)); gf_isom_full_box_init((GF_Box *)tmp); tmp->type = GF_ISOM_BOX_TYPE_IMIF; tmp->descriptors = gf_list_new(); return (GF_Box *)tmp;}void imif_del(GF_Box *s){ GF_IPMPInfoBox *ptr = (GF_IPMPInfoBox*)s; if (ptr == NULL) return; gf_odf_desc_list_del(ptr->descriptors); gf_list_del(ptr->descriptors); free(ptr);}GF_Err imif_Read(GF_Box *s, GF_BitStream *bs){ GF_Err e; u32 size; char *data; GF_IPMPInfoBox *ptr = (GF_IPMPInfoBox *)s; e = gf_isom_full_box_read(s, bs); if (e) return e; size = (u32) (s->size); data = (char*)malloc(sizeof(char)*size); gf_bs_read_data(bs, data, size); e = gf_odf_desc_list_read(data, size, ptr->descriptors); free(data); return e;}#ifndef GPAC_READ_ONLYGF_Err imif_Write(GF_Box *s, GF_BitStream *bs){ u32 dlen; char *data; GF_Err e; GF_IPMPInfoBox *ptr = (GF_IPMPInfoBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_write(s, bs); if (e) return e; e = gf_odf_desc_list_write(ptr->descriptors, &data, &dlen); if (e) return e; gf_bs_write_data(bs, data, dlen); free(data); return GF_OK;}GF_Err imif_Size(GF_Box *s){ u32 size; GF_Err e; GF_IPMPInfoBox *ptr = (GF_IPMPInfoBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_get_size(s); if (e) return e; e = gf_odf_desc_list_size(ptr->descriptors, &size); if (e) return e; ptr->size += size; return GF_OK;}#endifGF_Box *ipmc_New(){ GF_IPMPControlBox *tmp = (GF_IPMPControlBox*) malloc(sizeof(GF_IPMPControlBox)); if (tmp == NULL) return NULL; memset(tmp, 0, sizeof(GF_IPMPControlBox)); gf_isom_full_box_init((GF_Box *)tmp); tmp->type = GF_ISOM_BOX_TYPE_IPMC; tmp->descriptors = gf_list_new(); return (GF_Box *)tmp;}void ipmc_del(GF_Box *s){ GF_IPMPControlBox *ptr = (GF_IPMPControlBox*)s; if (ptr == NULL) return; gf_odf_desc_del((GF_Descriptor *)ptr->ipmp_tools); gf_odf_desc_list_del(ptr->descriptors); gf_list_del(ptr->descriptors); free(ptr);}GF_Err ipmc_Read(GF_Box *s, GF_BitStream *bs){ GF_Err e; u32 size, i, count; GF_Descriptor *desc; GF_Err gf_odf_parse_descriptor(GF_BitStream *bs, GF_Descriptor **desc, u32 *desc_size); s32 gf_odf_size_field_size(u32 size_desc); GF_IPMPControlBox *ptr = (GF_IPMPControlBox *)s; e = gf_isom_full_box_read(s, bs); if (e) return e; e = gf_odf_parse_descriptor(bs, (GF_Descriptor **)&ptr->ipmp_tools, &size); if (e) return e; count = gf_bs_read_u8(bs); for (i=0; i<count; i++) { e = gf_odf_parse_descriptor(bs, &desc, &size); if (e) break; gf_list_add(ptr->descriptors, desc); } return e;}#ifndef GPAC_READ_ONLYGF_Err ipmc_Write(GF_Box *s, GF_BitStream *bs){ GF_Err e; GF_Err gf_odf_write_descriptor_list(GF_BitStream *bs, GF_List *descList); GF_Err gf_odf_write_descriptor(GF_BitStream *bs, GF_Descriptor *desc); GF_IPMPControlBox *ptr = (GF_IPMPControlBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_write(s, bs); if (e) return e; e = gf_odf_write_descriptor(bs, (GF_Descriptor *)ptr->ipmp_tools); if (e) return e; gf_bs_write_u8(bs, gf_list_count(ptr->descriptors)); return gf_odf_write_descriptor_list(bs, ptr->descriptors);}GF_Err ipmc_Size(GF_Box *s){ u32 size; GF_Err e; GF_IPMPControlBox *ptr = (GF_IPMPControlBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_get_size(s); if (e) return e; ptr->size += gf_odf_desc_size((GF_Descriptor *)ptr->ipmp_tools) + 1; e = gf_odf_desc_list_size(ptr->descriptors, &size); if (e) return e; ptr->size += size; return GF_OK;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -