⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 odf_code.c

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 C
📖 第 1 页 / 共 5 页
字号:
	e = gf_odf_delete_descriptor_list(od->OCIDescriptors);	if (e) return e;	e = gf_odf_delete_descriptor_list(od->IPMP_Descriptors);	if (e) return e;	e = gf_odf_delete_descriptor_list(od->extensionDescriptors);	if (e) return e;	free(od);	return GF_OK;}GF_Err AddDescriptorToIsomOD(GF_IsomObjectDescriptor *od, GF_Descriptor *desc){	if (!od || !desc) return GF_BAD_PARAM;	//check if we can handle ContentClassif tags	if ( (desc->tag >= GF_ODF_OCI_BEGIN_TAG) &&		(desc->tag <= GF_ODF_OCI_END_TAG) ) {		return gf_list_add(od->OCIDescriptors, desc);	}	//or extension ...	if ( (desc->tag >= GF_ODF_EXT_BEGIN_TAG) &&		(desc->tag <= GF_ODF_EXT_END_TAG) ) {		return gf_list_add(od->extensionDescriptors, desc);	}	switch (desc->tag) {	case GF_ODF_ESD_TAG:		return GF_ODF_FORBIDDEN_DESCRIPTOR;	case GF_ODF_ESD_INC_TAG:		//there shouldn't be ref if inc		if (gf_list_count(od->ES_ID_RefDescriptors)) return GF_ODF_FORBIDDEN_DESCRIPTOR;		return gf_list_add(od->ES_ID_IncDescriptors, desc);	case GF_ODF_ESD_REF_TAG:		//there shouldn't be inc if ref		if (gf_list_count(od->ES_ID_IncDescriptors)) return GF_ODF_FORBIDDEN_DESCRIPTOR;		return gf_list_add(od->ES_ID_RefDescriptors, desc);	//we use the same struct for v1 and v2 IPMP DPs	case GF_ODF_IPMP_PTR_TAG:	case GF_ODF_IPMP_TAG:		return gf_list_add(od->IPMP_Descriptors, desc);	default:		return GF_BAD_PARAM;	}}GF_Err gf_odf_read_isom_od(GF_BitStream *bs, GF_IsomObjectDescriptor *od, u32 DescSize){	GF_Err e;	u32 reserved, urlflag;	u32 tmpSize, nbBytes = 0;	if (! od) return GF_BAD_PARAM;	od->objectDescriptorID = gf_bs_read_int(bs, 10);	urlflag = gf_bs_read_int(bs, 1);	reserved = gf_bs_read_int(bs, 5);	nbBytes += 2;		if (urlflag) {		u32 read;		e = gf_odf_read_url_string(bs, & od->URLString, &read);		if (e) return e;		nbBytes += read;	}	while (nbBytes < DescSize) {		GF_Descriptor *tmp = NULL;		e = gf_odf_parse_descriptor(bs, &tmp, &tmpSize);		if (e) return e;		if (!tmp) return GF_ODF_INVALID_DESCRIPTOR;		e = AddDescriptorToIsomOD(od, tmp);		if (e) return e;		nbBytes += tmpSize + gf_odf_size_field_size(tmpSize);	}	if (nbBytes != DescSize) return GF_ODF_INVALID_DESCRIPTOR;	return GF_OK;}GF_Err gf_odf_size_isom_od(GF_IsomObjectDescriptor *od, u32 *outSize){	GF_Err e;	if (! od) return GF_BAD_PARAM;	*outSize = 2;	if (od->URLString) {		*outSize += gf_odf_size_url_string(od->URLString);	} else {		e = gf_odf_size_descriptor_list(od->ES_ID_IncDescriptors, outSize);		if (e) return e;		e = gf_odf_size_descriptor_list(od->ES_ID_RefDescriptors, outSize);		if (e) return e;		e = gf_odf_size_descriptor_list(od->OCIDescriptors, outSize);		if (e) return e;		e = gf_odf_size_descriptor_list(od->IPMP_Descriptors, outSize);		if (e) return e;	}	return gf_odf_size_descriptor_list(od->extensionDescriptors, outSize);}GF_Err gf_odf_write_isom_od(GF_BitStream *bs, GF_IsomObjectDescriptor *od){	GF_Err e;	u32 size;	if (! od) return GF_BAD_PARAM;	e = gf_odf_size_descriptor((GF_Descriptor *)od, &size);	if (e) return e;	e = gf_odf_write_base_descriptor(bs, od->tag, size);	if (e) return e;		gf_bs_write_int(bs, od->objectDescriptorID, 10);	gf_bs_write_int(bs, od->URLString != NULL ? 1 : 0, 1);	gf_bs_write_int(bs, 31, 5);		//reserved: 0b1111.1 == 31	if (od->URLString) {		gf_odf_write_url_string(bs, od->URLString);	} else {		e = gf_odf_write_descriptor_list(bs, od->ES_ID_IncDescriptors);		if (e) return e;		e = gf_odf_write_descriptor_list(bs, od->ES_ID_RefDescriptors);		if (e) return e;		e = gf_odf_write_descriptor_list(bs, od->OCIDescriptors);		if (e) return e;		e = gf_odf_write_descriptor_list_filter(bs, od->IPMP_Descriptors, GF_ODF_IPMP_PTR_TAG);		if (e) return e;		e = gf_odf_write_descriptor_list_filter(bs, od->IPMP_Descriptors, GF_ODF_IPMP_TAG);		if (e) return e;	}	e = gf_odf_write_descriptor_list(bs, od->extensionDescriptors);	if (e) return e;	return GF_OK;}GF_Descriptor *gf_odf_new_cc(){	GF_CCDescriptor *newDesc = (GF_CCDescriptor *) malloc(sizeof(GF_CCDescriptor));	if (!newDesc) return NULL;	newDesc->contentClassificationData = NULL;	newDesc->dataLength = 0;	newDesc->classificationEntity = 0;	newDesc->classificationTable = 0;	newDesc->tag = GF_ODF_CC_TAG;	return (GF_Descriptor *) newDesc;}GF_Err gf_odf_del_cc(GF_CCDescriptor *ccd){	if (!ccd) return GF_BAD_PARAM;	if (ccd->contentClassificationData) free(ccd->contentClassificationData);	free(ccd);	return GF_OK;}GF_Err gf_odf_read_cc(GF_BitStream *bs, GF_CCDescriptor *ccd, u32 DescSize){	u32 nbBytes = 0;	if (!ccd) return GF_BAD_PARAM;	ccd->classificationEntity = gf_bs_read_int(bs, 32);	ccd->classificationTable = gf_bs_read_int(bs, 16);	nbBytes += 6;	ccd->dataLength = DescSize - 6;	ccd->contentClassificationData = (char*)malloc(sizeof(char) * ccd->dataLength);	if (!ccd->contentClassificationData) return GF_OUT_OF_MEM;	gf_bs_read_data(bs, ccd->contentClassificationData, ccd->dataLength);	nbBytes += ccd->dataLength;	if (DescSize != nbBytes) return GF_ODF_INVALID_DESCRIPTOR;	return GF_OK;}GF_Err gf_odf_size_cc(GF_CCDescriptor *ccd, u32 *outSize){	if (!ccd) return GF_BAD_PARAM;	*outSize = 6 + ccd->dataLength;	return GF_OK;}GF_Err gf_odf_write_cc(GF_BitStream *bs, GF_CCDescriptor *ccd){	u32 size;	GF_Err e;	if (!ccd) return GF_BAD_PARAM;	e = gf_odf_size_descriptor((GF_Descriptor *)ccd, &size);	if (e) return e;	e = gf_odf_write_base_descriptor(bs, ccd->tag, size);	if (e) return e;	gf_bs_write_int(bs, ccd->classificationEntity, 32);	gf_bs_write_int(bs, ccd->classificationTable, 16);	gf_bs_write_data(bs, ccd->contentClassificationData, ccd->dataLength);	return GF_OK;}GF_Descriptor *gf_odf_new_cc_date(){	GF_CC_Date *newDesc = (GF_CC_Date *) malloc(sizeof(GF_CC_Date));	if (!newDesc) return NULL;	memset(newDesc->contentCreationDate, 0, 5);	newDesc->tag = GF_ODF_CC_DATE_TAG;	return (GF_Descriptor *) newDesc;}GF_Err gf_odf_del_cc_date(GF_CC_Date *cdd){	if (!cdd) return GF_BAD_PARAM;	free(cdd);	return GF_OK;}GF_Err gf_odf_read_cc_date(GF_BitStream *bs, GF_CC_Date *cdd, u32 DescSize){	u32 nbBytes = 0;	if (!cdd) return GF_BAD_PARAM;	gf_bs_read_data(bs, cdd->contentCreationDate, DATE_CODING_BIT_LEN);	nbBytes += DATE_CODING_BIT_LEN / 8;	if (DescSize != nbBytes) return GF_ODF_INVALID_DESCRIPTOR;	return GF_OK;}GF_Err gf_odf_size_cc_date(GF_CC_Date *cdd, u32 *outSize){	if (!cdd) return GF_BAD_PARAM;	*outSize = (DATE_CODING_BIT_LEN / 8);	return GF_OK;}GF_Err gf_odf_write_cc_date(GF_BitStream *bs, GF_CC_Date *cdd){	u32 size;	GF_Err e;	if (!cdd) return GF_BAD_PARAM;	e = gf_odf_size_descriptor((GF_Descriptor *)cdd, &size);	if (e) return e;	e = gf_odf_write_base_descriptor(bs, cdd->tag, size);	if (e) return e;	gf_bs_write_data(bs, cdd->contentCreationDate , DATE_CODING_BIT_LEN);	return GF_OK;}GF_Descriptor *gf_odf_new_cc_name(){	GF_CC_Name *newDesc = (GF_CC_Name *) malloc(sizeof(GF_CC_Name));	if (!newDesc) return NULL;	newDesc->ContentCreators = gf_list_new();	if (! newDesc->ContentCreators) {		free(newDesc);		return NULL;	}	newDesc->tag = GF_ODF_CC_NAME_TAG;	return (GF_Descriptor *) newDesc;}GF_Err gf_odf_del_cc_name(GF_CC_Name *cnd){	u32 i;	GF_ContentCreatorInfo *tmp;	if (!cnd) return GF_BAD_PARAM;	i=0;	while ((tmp = (GF_ContentCreatorInfo *)gf_list_enum(cnd->ContentCreators, &i))) {		if (tmp->contentCreatorName) free(tmp->contentCreatorName);		free(tmp);	}	gf_list_del(cnd->ContentCreators);	free(cnd);	return GF_OK;}GF_Err gf_odf_read_cc_name(GF_BitStream *bs, GF_CC_Name *cnd, u32 DescSize){	GF_Err e;	u32 i, aligned, count, len, nbBytes = 0;	if (!cnd) return GF_BAD_PARAM;	count = gf_bs_read_int(bs, 8);	nbBytes += 1;	for (i = 0; i< count; i++) {		GF_ContentCreatorInfo *tmp = (GF_ContentCreatorInfo*)malloc(sizeof(GF_ContentCreatorInfo));		if (! tmp) return GF_OUT_OF_MEM;		memset(tmp , 0, sizeof(GF_ContentCreatorInfo));		tmp->langCode = gf_bs_read_int(bs, 24);		tmp->isUTF8 = gf_bs_read_int(bs, 1);		aligned = gf_bs_read_int(bs, 7);		nbBytes += 4;		e = OD_ReadUTF8String(bs, & tmp->contentCreatorName, tmp->isUTF8, &len);		if (e) return e;		nbBytes += len;		e = gf_list_add(cnd->ContentCreators, tmp);	}	if (DescSize != nbBytes) return GF_ODF_INVALID_DESCRIPTOR;	return GF_OK;}GF_Err gf_odf_size_cc_name(GF_CC_Name *cnd, u32 *outSize){	u32 i;	GF_ContentCreatorInfo *tmp;	if (!cnd) return GF_BAD_PARAM;	*outSize = 1;	i=0;	while ((tmp = (GF_ContentCreatorInfo *)gf_list_enum(cnd->ContentCreators, &i))) {		*outSize += 4 + OD_SizeUTF8String(tmp->contentCreatorName, tmp->isUTF8);	}	return GF_OK;}GF_Err gf_odf_write_cc_name(GF_BitStream *bs, GF_CC_Name *cnd){	GF_Err e;	GF_ContentCreatorInfo *tmp;	u32 i, size;	if (!cnd) return GF_BAD_PARAM;	e = gf_odf_size_descriptor((GF_Descriptor *)cnd, &size);	if (e) return e;	e = gf_odf_write_base_descriptor(bs, cnd->tag, size);	if (e) return e;	gf_bs_write_int(bs, gf_list_count(cnd->ContentCreators), 8);	i=0;	while ((tmp = (GF_ContentCreatorInfo *)gf_list_enum(cnd->ContentCreators, &i))) {		gf_bs_write_int(bs, tmp->langCode, 24);		gf_bs_write_int(bs, tmp->isUTF8, 1);		gf_bs_write_int(bs, 0, 7);		//aligned		OD_WriteUTF8String(bs, tmp->contentCreatorName, tmp->isUTF8);	}	return GF_OK;}	GF_Descriptor *gf_odf_new_ci(){	GF_CIDesc *newDesc = (GF_CIDesc *) malloc(sizeof(GF_CIDesc));	if (!newDesc) return NULL;	newDesc->compatibility = 0;	newDesc->contentIdentifier = NULL;	newDesc->tag = GF_ODF_CI_TAG;	newDesc->contentIdentifierFlag = 0;	newDesc->contentIdentifierType = 0;	newDesc->contentType = 0;	newDesc->contentTypeFlag = 0;	newDesc->protectedContent = 0;	return (GF_Descriptor *) newDesc;}GF_Err gf_odf_del_ci(GF_CIDesc *cid){	if (!cid) return GF_BAD_PARAM;	if (cid->contentIdentifier) free(cid->contentIdentifier);	free(cid);	return GF_OK;}GF_Err gf_odf_read_ci(GF_BitStream *bs, GF_CIDesc *cid, u32 DescSize){	u32 reserved, nbBytes = 0;	if (! cid) return GF_BAD_PARAM;	cid->compatibility = gf_bs_read_int(bs, 2);	//MUST BE NULL	if (cid->compatibility) return GF_ODF_INVALID_DESCRIPTOR;	cid->contentTypeFlag = gf_bs_read_int(bs, 1);	cid->contentIdentifierFlag = gf_bs_read_int(bs, 1);	cid->protectedContent = gf_bs_read_int(bs, 1);	reserved = gf_bs_read_int(bs, 3);	nbBytes += 1;	if (cid->contentTypeFlag) {		cid->contentType = gf_bs_read_int(bs, 8);		nbBytes += 1;	}	if (cid->contentIdentifierFlag) {		cid->contentIdentifierType = gf_bs_read_int(bs, 8);		cid->contentIdentifier = (char*)malloc(DescSize - 2 - cid->contentTypeFlag);		if (! cid->contentIdentifier) return GF_OUT_OF_MEM;		gf_bs_read_data(bs, cid->contentIdentifier, DescSize - 2 - cid->contentTypeFlag);		nbBytes += DescSize - 1 - cid->contentTypeFlag;	}	if (nbBytes != DescSize) return GF_ODF_INVALID_DESCRIPTOR;	return GF_OK;}GF_Err gf_odf_size_ci(GF_CIDesc *cid, u32 *outSize){	if (! cid) return GF_BAD_PARAM;	*outSize = 1;	if (cid->contentTypeFlag) *outSize += 1;	if (cid->contentIdentifierFlag) 		*outSize += strlen((const char*)cid->contentIdentifier) - 1 - cid->contentTypeFlag;	return GF_OK;}GF_Err gf_odf_write_ci(GF_BitStream *bs, GF_CIDesc *cid){	GF_Err e;	u32 size;	if (! cid) return GF_BAD_PARAM;	e = gf_odf_size_descriptor((GF_Descriptor *)cid, &size);	if (e) return e;	e = gf_odf_write_base_descriptor(bs, cid->tag, size);	if (e) return e;	gf_bs_write_int(bs, cid->compatibility, 2);	gf_bs_write_int(bs, cid->contentTypeFlag, 1);	gf_bs_write_int(bs, cid->contentIdentifierFlag, 1);	gf_bs_write_int(bs, cid->protectedContent, 1);	gf_bs_write_int(bs, 7, 3);		//reserved 0b111 = 7	if (cid->contentTypeFlag) {		gf_bs_write_int(bs, cid->contentType, 8);	}	if (cid->contentIdentifierFlag) {		gf_bs_write_int(bs, cid->contentIdentifierType, 8);		gf_bs_write_data(bs, cid->contentIdentifier, size - 2 - cid->contentTypeFlag);	}	return GF_OK;}GF_Descriptor *gf_odf_new_dcd(){	GF_DecoderConfig *newDesc = (GF_DecoderConfig *) malloc(sizeof(GF_DecoderConfig));	if (!newDesc) return NULL;	newDesc->avgBitrate = 0;	newDesc->bufferSizeDB = 0;	newDesc->maxBitrate = 0;	newDesc->objectTypeIndication = 0;	newDesc->streamType = 0;	newDesc->upstream = 0;	newDesc->decoderSpecificInfo = NULL;	newDesc->profileLevelIndicationIndexDescriptor = gf_list_new();	newDesc->tag = GF_ODF_DCD_TAG;	return (GF_Descriptor *) newDesc;}GF_Err gf_odf_del_dcd(GF_DecoderConfig *dcd){	GF_Err e;	if (!dcd) return GF_BAD_PARAM;	if (dcd->decoderSpecificInfo) {		e = gf_odf_delete_descriptor((GF_Descriptor *) dcd->decoderSpecificInfo);		if (e) return e;	}	e = gf_odf_delete_descriptor_list(dcd->profileLevelIndicationIndexDescriptor);	if (e) return e;	free(dcd);	return GF_OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -