static u_char* edash_packager_write_content_protection(void* ctx, u_char* p, media_track_t* track) { write_content_protection_context_t* context = ctx; drm_info_t* drm_info = (drm_info_t*)track->file_info.drm_info; drm_system_info_t* cur_info; vod_str_t base64; vod_str_t pssh; p = vod_copy(p, VOD_EDASH_MANIFEST_CONTENT_PROTECTION_CENC, sizeof(VOD_EDASH_MANIFEST_CONTENT_PROTECTION_CENC) - 1); for (cur_info = drm_info->pssh_array.first; cur_info < drm_info->pssh_array.last; cur_info++) { if (vod_memcmp(cur_info->system_id, edash_playready_system_id, sizeof(edash_playready_system_id)) == 0) { if (context->write_playready_kid) { p = vod_copy(p, VOD_EDASH_MANIFEST_CONTENT_PROTECTION_PLAYREADY_V2_PART1, sizeof(VOD_EDASH_MANIFEST_CONTENT_PROTECTION_PLAYREADY_V2_PART1) - 1); p = mp4_encrypt_write_guid(p, cur_info->system_id); p = vod_copy(p, VOD_EDASH_MANIFEST_CONTENT_PROTECTION_PLAYREADY_V2_PART2, sizeof(VOD_EDASH_MANIFEST_CONTENT_PROTECTION_PLAYREADY_V2_PART2) - 1); p = mp4_encrypt_write_guid(p, drm_info->key_id); } else { p = vod_copy(p, VOD_EDASH_MANIFEST_CONTENT_PROTECTION_PLAYREADY_PART1, sizeof(VOD_EDASH_MANIFEST_CONTENT_PROTECTION_PLAYREADY_PART1) - 1); p = mp4_encrypt_write_guid(p, cur_info->system_id); } p = vod_copy(p, VOD_EDASH_MANIFEST_CONTENT_PROTECTION_PLAYREADY_PART3, sizeof(VOD_EDASH_MANIFEST_CONTENT_PROTECTION_PLAYREADY_PART3) - 1); base64.data = p; vod_encode_base64(&base64, &cur_info->data); p += base64.len; p = vod_copy(p, VOD_EDASH_MANIFEST_CONTENT_PROTECTION_PLAYREADY_PART4, sizeof(VOD_EDASH_MANIFEST_CONTENT_PROTECTION_PLAYREADY_PART4) - 1); } else { p = vod_copy(p, VOD_EDASH_MANIFEST_CONTENT_PROTECTION_CENC_PART1, sizeof(VOD_EDASH_MANIFEST_CONTENT_PROTECTION_CENC_PART1) - 1); p = mp4_encrypt_write_guid(p, cur_info->system_id); p = vod_copy(p, VOD_EDASH_MANIFEST_CONTENT_PROTECTION_CENC_PART2, sizeof(VOD_EDASH_MANIFEST_CONTENT_PROTECTION_CENC_PART2) - 1); p = mp4_encrypt_write_guid(p, drm_info->key_id); p = vod_copy(p, VOD_EDASH_MANIFEST_CONTENT_PROTECTION_CENC_PART3, sizeof(VOD_EDASH_MANIFEST_CONTENT_PROTECTION_CENC_PART3) - 1); pssh.data = context->temp_buffer; pssh.len = edash_packager_write_pssh(pssh.data, cur_info) - pssh.data; base64.data = p; vod_encode_base64(&base64, &pssh); p += base64.len; p = vod_copy(p, VOD_EDASH_MANIFEST_CONTENT_PROTECTION_CENC_PART4, sizeof(VOD_EDASH_MANIFEST_CONTENT_PROTECTION_CENC_PART4) - 1); } } return p; }
static u_char* edash_packager_write_psshs(void* context, u_char* p) { drm_system_info_array_t* pssh_array = (drm_system_info_array_t*)context; drm_system_info_t* cur_info; for (cur_info = pssh_array->first; cur_info < pssh_array->last; cur_info++) { p = edash_packager_write_pssh(p, cur_info); } return p; }