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

📄 isma_sample.c

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 C
📖 第 1 页 / 共 2 页
字号:
		if (outKMS_URI) *outKMS_URI = NULL;	}	if (sea->protection_info->info && sea->protection_info->info->isfm) {		if (outSelectiveEncryption) *outSelectiveEncryption = sea->protection_info->info->isfm->selective_encryption;		if (outIVLength) *outIVLength = sea->protection_info->info->isfm->IV_length;		if (outKeyIndicationLength) *outKeyIndicationLength = sea->protection_info->info->isfm->key_indicator_length;	} else {		if (outSelectiveEncryption) *outSelectiveEncryption = 0;		if (outIVLength) *outIVLength = 0;		if (outKeyIndicationLength) *outKeyIndicationLength = 0;	}	return GF_OK;}/*retrieves ISMACryp info for the given track & SDI*/GF_EXPORTGF_Err gf_isom_get_omadrm_info(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex, u32 *outOriginalFormat,							   u32 *outSchemeType, u32 *outSchemeVersion,							   const char **outContentID, const char **outRightsIssuerURL, const char **outTextualHeaders, u32 *outTextualHeadersLen, u64 *outPlaintextLength, u32 *outEncryptionType, Bool *outSelectiveEncryption, u32 *outIVLength, u32 *outKeyIndicationLength){	GF_TrackBox *trak;	GF_SampleEntryBox *sea;		trak = gf_isom_get_track_from_file(the_file, trackNumber);	if (!trak) return GF_BAD_PARAM;	Media_GetSampleDesc(trak->Media, sampleDescriptionIndex, &sea, NULL);	/*non-encrypted or non-ISMA*/	if (!sea || !sea->protection_info) return GF_BAD_PARAM;	if (!sea->protection_info->scheme_type || !sea->protection_info->original_format) return GF_NON_COMPLIANT_BITSTREAM;	if (!sea->protection_info->info || !sea->protection_info->info->okms || !sea->protection_info->info->okms->hdr) return GF_NON_COMPLIANT_BITSTREAM;	if (outOriginalFormat) {		*outOriginalFormat = sea->protection_info->original_format->data_format;		if (IsMP4Description(sea->protection_info->original_format->data_format)) *outOriginalFormat = GF_ISOM_SUBTYPE_MPEG4;	}	if (outSchemeType) *outSchemeType = sea->protection_info->scheme_type->scheme_type;	if (outSchemeVersion) *outSchemeVersion = sea->protection_info->scheme_type->scheme_version;	if (outContentID) *outContentID = sea->protection_info->info->okms->hdr->ContentID;	if (outRightsIssuerURL) *outRightsIssuerURL = sea->protection_info->info->okms->hdr->RightsIssuerURL;	if (outTextualHeaders) {		*outTextualHeaders = sea->protection_info->info->okms->hdr->TextualHeaders;		if (outTextualHeadersLen) *outTextualHeadersLen = sea->protection_info->info->okms->hdr->TextualHeadersLen;	}	if (outPlaintextLength) *outPlaintextLength = sea->protection_info->info->okms->hdr->PlaintextLength;	if (outEncryptionType) *outEncryptionType = sea->protection_info->info->okms->hdr->EncryptionMethod;	if (sea->protection_info->info && sea->protection_info->info->okms  && sea->protection_info->info->okms->fmt) {		if (outSelectiveEncryption) *outSelectiveEncryption = sea->protection_info->info->okms->fmt->selective_encryption;		if (outIVLength) *outIVLength = sea->protection_info->info->okms->fmt->IV_length;		if (outKeyIndicationLength) *outKeyIndicationLength = sea->protection_info->info->okms->fmt->key_indicator_length;	} else {		if (outSelectiveEncryption) *outSelectiveEncryption = 0;		if (outIVLength) *outIVLength = 0;		if (outKeyIndicationLength) *outKeyIndicationLength = 0;	}	return GF_OK;}#ifndef GPAC_READ_ONLYGF_Err gf_isom_remove_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex){	GF_TrackBox *trak;	GF_Err e;	GF_SampleEntryBox *sea;	e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE);	if (e) return e;		trak = gf_isom_get_track_from_file(the_file, trackNumber);	if (!trak || !trak->Media || !StreamDescriptionIndex) return GF_BAD_PARAM;	Media_GetSampleDesc(trak->Media, StreamDescriptionIndex, &sea, NULL);	/*non-encrypted or non-ISMA*/	if (!sea || !sea->protection_info) return GF_BAD_PARAM;	if (!sea->protection_info->scheme_type || !sea->protection_info->original_format) return GF_NON_COMPLIANT_BITSTREAM;	sea->type = sea->protection_info->original_format->data_format;	gf_isom_box_del((GF_Box *)sea->protection_info);	sea->protection_info = NULL;	if (sea->type == GF_4CC('2','6','4','b')) sea->type = GF_ISOM_BOX_TYPE_AVC1;	return GF_OK;}GF_Err gf_isom_change_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, char *scheme_uri, char *kms_uri){	GF_TrackBox *trak;	GF_Err e;	GF_SampleEntryBox *sea;	e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE);	if (e) return e;		trak = gf_isom_get_track_from_file(the_file, trackNumber);	if (!trak || !trak->Media || !StreamDescriptionIndex) return GF_BAD_PARAM;	Media_GetSampleDesc(trak->Media, StreamDescriptionIndex, &sea, NULL);	/*non-encrypted or non-ISMA*/	if (!sea || !sea->protection_info) return GF_BAD_PARAM;	if (!sea->protection_info->scheme_type || !sea->protection_info->original_format) return GF_NON_COMPLIANT_BITSTREAM;	if (scheme_uri) {		free(sea->protection_info->scheme_type->URI);		sea->protection_info->scheme_type->URI = strdup(scheme_uri);	}	if (kms_uri) {		free(sea->protection_info->info->ikms->URI);		sea->protection_info->info->ikms->URI = strdup(kms_uri);	}	return GF_OK;}GF_Err gf_isom_set_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index, u32 scheme_type, 						   u32 scheme_version, char *scheme_uri, char *kms_URI,						   Bool selective_encryption, u32 KI_length, u32 IV_length){	u32 original_format;	GF_Err e;	GF_SampleEntryBox *sea;	GF_TrackBox *trak = gf_isom_get_track_from_file(the_file, trackNumber);	if (!trak) return GF_BAD_PARAM;	e = Media_GetSampleDesc(trak->Media, desc_index, &sea, NULL);	if (e) return e;	/* Replacing the Media Type */	switch (sea->type) {	case GF_ISOM_BOX_TYPE_MP4A:	case GF_ISOM_BOX_TYPE_DAMR:	case GF_ISOM_BOX_TYPE_DEVC:	case GF_ISOM_BOX_TYPE_DQCP:	case GF_ISOM_BOX_TYPE_DSMV:		original_format = sea->type;		sea->type = GF_ISOM_BOX_TYPE_ENCA;		break;	case GF_ISOM_BOX_TYPE_MP4V:	case GF_ISOM_BOX_TYPE_D263:		original_format = sea->type;		sea->type = GF_ISOM_BOX_TYPE_ENCV;		break;	/*special case for AVC1*/	case GF_ISOM_BOX_TYPE_AVC1:		original_format = GF_4CC('2','6','4','b');		sea->type = GF_ISOM_BOX_TYPE_ENCV;		break;	case GF_ISOM_BOX_TYPE_MP4S:		original_format = sea->type;		sea->type = GF_ISOM_BOX_TYPE_ENCS;		break;	default:		return GF_BAD_PARAM;	}		sea->protection_info = (GF_ProtectionInfoBox *)sinf_New();	sea->protection_info->scheme_type = (GF_SchemeTypeBox *)schm_New();	sea->protection_info->scheme_type->scheme_type = scheme_type;	sea->protection_info->scheme_type->scheme_version = scheme_version;	if (scheme_uri) {		sea->protection_info->scheme_type->flags |= 0x000001;		sea->protection_info->scheme_type->URI = strdup(scheme_uri);	}	sea->protection_info->original_format = (GF_OriginalFormatBox *)frma_New();	sea->protection_info->original_format->data_format = original_format;	sea->protection_info->info = (GF_SchemeInformationBox *)schi_New();	sea->protection_info->info->ikms = (GF_ISMAKMSBox *)iKMS_New();	sea->protection_info->info->ikms->URI = strdup(kms_URI);	sea->protection_info->info->isfm = (GF_ISMASampleFormatBox *)iSFM_New();	sea->protection_info->info->isfm->selective_encryption = selective_encryption;	sea->protection_info->info->isfm->key_indicator_length = KI_length;	sea->protection_info->info->isfm->IV_length = IV_length;	return GF_OK;}GF_Err gf_isom_set_oma_protection(GF_ISOFile *the_file, u32 trackNumber, u32 desc_index,						   char *contentID, char *kms_URI, u32 encryption_type, u64 plainTextLength, char *textual_headers, u32 textual_headers_len,						   Bool selective_encryption, u32 KI_length, u32 IV_length){	u32 original_format;	GF_Err e;	GF_SampleEntryBox *sea;	GF_TrackBox *trak = gf_isom_get_track_from_file(the_file, trackNumber);	if (!trak) return GF_BAD_PARAM;	e = Media_GetSampleDesc(trak->Media, desc_index, &sea, NULL);	if (e) return e;	/* Replacing the Media Type */	switch (sea->type) {	case GF_ISOM_BOX_TYPE_MP4A:	case GF_ISOM_BOX_TYPE_DAMR:	case GF_ISOM_BOX_TYPE_DEVC:	case GF_ISOM_BOX_TYPE_DQCP:	case GF_ISOM_BOX_TYPE_DSMV:		original_format = sea->type;		sea->type = GF_ISOM_BOX_TYPE_ENCA;		break;	case GF_ISOM_BOX_TYPE_MP4V:	case GF_ISOM_BOX_TYPE_AVC1:	case GF_ISOM_BOX_TYPE_D263:		original_format = sea->type;		sea->type = GF_ISOM_BOX_TYPE_ENCV;		break;	case GF_ISOM_BOX_TYPE_MP4S:		original_format = sea->type;		sea->type = GF_ISOM_BOX_TYPE_ENCS;		break;	default:		return GF_BAD_PARAM;	}		sea->protection_info = (GF_ProtectionInfoBox *)sinf_New();	sea->protection_info->scheme_type = (GF_SchemeTypeBox *)schm_New();	sea->protection_info->scheme_type->scheme_type = GF_4CC('o','d','k','m');	sea->protection_info->scheme_type->scheme_version = 0x00000200;	sea->protection_info->original_format = (GF_OriginalFormatBox *)frma_New();	sea->protection_info->original_format->data_format = original_format;	sea->protection_info->info = (GF_SchemeInformationBox *)schi_New();	sea->protection_info->info->okms = (GF_OMADRMKMSBox *)odkm_New();	sea->protection_info->info->okms->fmt = (GF_OMADRMAUFormatBox*)gf_isom_box_new(GF_ISOM_BOX_TYPE_ODAF);	sea->protection_info->info->okms->fmt->selective_encryption = selective_encryption;	sea->protection_info->info->okms->fmt->key_indicator_length = KI_length;	sea->protection_info->info->okms->fmt->IV_length = IV_length;	sea->protection_info->info->okms->hdr = (GF_OMADRMCommonHeaderBox*)ohdr_New();	sea->protection_info->info->okms->hdr->EncryptionMethod = encryption_type;	sea->protection_info->info->okms->hdr->PaddingScheme = (encryption_type==0x01) ? 1 : 0;	sea->protection_info->info->okms->hdr->PlaintextLength = plainTextLength;	if (contentID) sea->protection_info->info->okms->hdr->ContentID = strdup(contentID);	if (kms_URI) sea->protection_info->info->okms->hdr->RightsIssuerURL = strdup(kms_URI);	if (textual_headers) {		sea->protection_info->info->okms->hdr->TextualHeaders = malloc(sizeof(char)*textual_headers_len);		memcpy(sea->protection_info->info->okms->hdr->TextualHeaders, textual_headers, sizeof(char)*textual_headers_len);		sea->protection_info->info->okms->hdr->TextualHeadersLen = textual_headers_len;	}	return GF_OK;}#endif

⌨️ 快捷键说明

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