📄 play_psfdemux.c
字号:
one_data_entry_enabled = TRUE; if( context->DataPidList.share_ecm == 0 && context->DataPidList.ecm_pids[i] != 0x1fff ) { // associate the ecm pid to the data pid cipher.index = context->DataPidList.data_pid_entries[i]; // pid index cipher.pid_cipher_index = 0; cipher.cipher_index = context->cipher_index[ context->DataPidList.cipher_indices[i] ]; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryAddCipher, &cipher, sizeof(cipher), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "SetHwDataPlayback Error RMDemuxTaskPropertyID_PidEntryAddCipher")); return err; } RMDBGLOG((ENABLE, "============== add cipher %d %d \n", cipher.index, cipher.cipher_index)); // and the corresponding ecm pid entry.index = context->DataPidList.ecm_pid_entries[i]; entry.PidEntry.pid = context->DataPidList.ecm_pids[i]; entry.PidEntry.input_type = EMhwlibPid_Ts; entry.PidEntry.flags = TS_FLAGS; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntry, &entry, sizeof(entry), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%SetHwDataPlayback Error data RMDemuxTaskPropertyID_PidEntry", context->id)); return err; } err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryEnable, &entry.index, sizeof(entry.index), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%SetHwDataPlayback Error data RMDemuxTaskPropertyID_PidEntryEnable", context->id)); return err; } RMDBGLOG((ENABLE, "============== with ecm pid %d 0x%x \n", entry.index, entry.PidEntry.pid )); } } else { // disable the pid and ecm pid entry.index = context->DataPidList.data_pid_entries[i]; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryDisable, &entry.index, sizeof(entry.index), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%SetHwDataPlayback Error data RMDemuxTaskPropertyID_PidEntryDisable", context->id)); return err; } RMDBGLOG((ENABLE, "============== disabled data pid %d 0x%x\n", entry.index, context->DataPidList.elementary_pids[i] )); entry.index = context->DataPidList.ecm_pid_entries[i]; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryDisable, &entry.index, sizeof(entry.index), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%SetHwDataPlayback Error data RMDemuxTaskPropertyID_PidEntryDisable", context->id)); return err; } RMDBGLOG((ENABLE, "============== disabled ecm pid %d 0x%x\n", entry.index, context->DataPidList.ecm_pids[i] )); } } if( context->DataPidList.share_ecm && one_data_entry_enabled ) { if( context->DataPidList.ecm_pids[0] != 0x1fff ) { // associate this ecm pid to all data pids for( i=0; i<context->DataPidList.count; i++ ) { cipher.index = context->DataPidList.data_pid_entries[i]; cipher.pid_cipher_index = 0; cipher.cipher_index = context->cipher_index[ context->DataPidList.cipher_indices[0] ]; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryAddCipher, &cipher, sizeof(cipher), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "SetHwDataPlayback Error RMDemuxTaskPropertyID_PidEntryAddCipher")); return err; } } // enable the ecm pid entry entry.index = context->DataPidList.ecm_pid_entries[0]; entry.PidEntry.pid = context->DataPidList.ecm_pids[0]; entry.PidEntry.input_type = EMhwlibPid_Ts; entry.PidEntry.flags = TS_FLAGS; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntry, &entry, sizeof(entry), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%SetHwDataPlayback Error data RMDemuxTaskPropertyID_PidEntry", context->id)); return err; } err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryEnable, &entry.index, sizeof(entry.index), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%SetHwDataPlayback Error data RMDemuxTaskPropertyID_PidEntryEnable", context->id)); return err; } } } return RM_OK;}#endif //#ifdef MULTI2_EIGHT_KEYS#ifdef USE_HW_FIXED_PID_ENTRY/* set the fixed Pid entries available only for EM8634 */static RMstatus SetPatCatPidAsRecipherPid(struct context_per_task *context ){ RMstatus err; RMuint32 dummy; struct EMhwlibOutputMask_type out; /* PAT */ err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PATPidEntryDisable, &dummy, sizeof(dummy), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "SetPatCatPidAsRecipherPid Error RMDemuxTaskPropertyID_PATPidEntryEnable")); return err; } out.output_mask[0] = PAT_OUTPUT_MASK | RECIPHER_OUTPUT_MASK; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PATPidEntryAddOutputs, &out, sizeof(out), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "SetPatCatPidAsRecipherPid Error RMDemuxTaskPropertyID_PATPidEntryAddOutputs")); return err; } err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PATPidEntryEnable, &dummy, sizeof(dummy), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "SetPatCatPidAsRecipherPid Error RMDemuxTaskPropertyID_PATPidEntryEnable")); return err; } /* CAT */ err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_CATPidEntryDisable, &dummy, sizeof(dummy), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "SetPatCatPidAsRecipherPid Error RMDemuxTaskPropertyID_CATPidEntryEnable")); return err; } out.output_mask[0] = CAT_OUTPUT_MASK | RECIPHER_OUTPUT_MASK; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_CATPidEntryAddOutputs, &out, sizeof(out), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "SetPatCatPidAsRecipherPid Error RMDemuxTaskPropertyID_CATPidEntryAddOutputs")); return err; } err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_CATPidEntryEnable, &dummy, sizeof(dummy), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "SetPatCatPidAsRecipherPid Error RMDemuxTaskPropertyID_CATPidEntryEnable")); return err; } return RM_OK;}#endif /* #ifdef USE_HW_FIXED_PID_ENTRY */static RMstatus SetPidAsRecipherPid(struct context_per_task *context, RMuint32 index ){ RMstatus err; struct EMhwlibPidEntryInfo_type pidentryinfo; struct EMhwlibEntryOutputMask_type outputmask; struct DemuxTask_PidEntryRecipher_type pidrecipherentry; RMDBGLOG((LOCALDBG, "%ld_SetPidAsRecipherPid vpid=%x apid=%x pcrpid=%x\n", context->id, context->video_pid, context->audio_pid, context->pcr_pid)); err = RUAExchangeProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryInfo, &index, sizeof(index), &pidentryinfo, sizeof(pidentryinfo) ); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%ld_SetPidAsRecipherPid Error RMDemuxTaskPropertyID_PidEntryInfo", context->id)); return err; } err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryDisable, &index, sizeof(index), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%ld_SetPidAsRecipherPid Error RMDemuxTaskPropertyID_PidEntryDisable", context->id)); return err; } outputmask.entry_index = context->pid_table[index].index; outputmask.output_mask[0] = 0; if ( context->pid_table[index].type == VIDEO_PID_ENTRY || context->pid_table[index].type == AUDIO_PID_ENTRY ) { /* disconnect playback for video and audio since no concurrent playback and recipher */ outputmask.output_mask[0] = 0xffffffff; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryRemoveOutputs, &outputmask, sizeof(outputmask), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%ld_SetPidAsRecipherPid Error video RMDemuxTaskPropertyID_PidEntryRemoveOutputs", context->id)); return err; } pidrecipherentry.index = context->pid_table[index].index; pidrecipherentry.enable = TRUE; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryRecipher, &pidrecipherentry, sizeof(pidrecipherentry), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%ld_SetPidAsRecipherPid Error RMDemuxTaskPropertyID_PidEntryReciphe", context->id)); return err; } } if ( context->pid_table[index].type != ECM0_PID_ENTRY && context->pid_table[index].type != ECM1_PID_ENTRY ) { /* do not send multi2 ecm to the AES reciphered stream */ outputmask.output_mask[0] = RECIPHER_OUTPUT_MASK; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryAddOutputs, &outputmask, sizeof(outputmask), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%ld_SetPidAsRecipherPid Error video RMDemuxTaskPropertyID_PidentryAddoutputs", context->id)); return err; } } if( pidentryinfo.enable ) { err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryEnable, &index, sizeof(index), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%ld_SetPidAsRecipherPid Error video RMDemuxTaskPropertyID_PidEntryEnable", context->id)); return err; } } return RM_OK;}/* this function hardcodes the cipher related info for reciphering *//* recipher is defined as AES cipher, CBC+OFB, 128 bits key and iv, one key for the stream *//* assumes that one entry in cipher table is ready for reciphering, one key index is ready *//* they are available from context->recipher_cipher_entry and context->recipher_xxx_key_index */static RMstatus SetPidForRecipher(struct context_per_task *context, enum EMhwlibRecipherMode force, RMuint32 key_index, enum EMhwlibScramblingBits key_select ){ RMuint32 i; RMstatus err; RMuint32 key_size = 16; /* in bytes */ RMDBGLOG((LOCALDBG, " %ld_SetPidForRecipher \n",context->id)); /* setup the option for reciphering */ { struct DemuxTask_RecipherOptions_type pidrecipheroptions; pidrecipheroptions.cipher_index = context->recipher_cipher_entry; pidrecipheroptions.mode = force; pidrecipheroptions.scrambling_bits = (RMuint32)key_select; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_RecipherOptions, &pidrecipheroptions, sizeof(pidrecipheroptions), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%ld_SetPidForRecipher Error RMDemuxTaskPropertyID_RecipherOptions", context->id)); return err; } } /* set up the key in the cipher table */#ifdef USE_XPU_WRITE_KEY { union Demux_Cipher_Key key; /* key should be loaded from low addr to high addr one double word at a time */ /* mips is little endian, so casting should work */ key.aes128BitKey.pKey = (RMuint32*)context->recipher_even_key; key.aes128BitKey.pIV = (RMuint32*)context->recipher_even_key; err = SetRecipherKeyThroughXPU(context, &key, EMhwlibCipher_AES, key_index, key_size ); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%ld_SetPidForRecipher Error SetKeyThoughXPU ", context->id)); return err; } }#else { struct DemuxTask_AESKey_type aes_key; aes_key.key_index = key_index; aes_key.key_size = key_size; if( key_select == EMhwlibScramblingBits_10 ) RMMemcpy(aes_key.key, context->recipher_even_key, aes_key.key_size); else if ( key_select == EMhwlibScramblingBits_11 ) RMMemcpy(aes_key.key, context->recipher_odd_key, aes_key.key_size); else return RM_ERROR; RMMemcpy(aes_key.iv, context->recipher_iv, aes_key.key_size); err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_AESKey, &aes_key, sizeof(aes_key), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%ld_SetPidForRecipher Error RMDemuxTaskPropertyID_AESKey", context->id)); return err; } }#endif /* #ifdef USE_XPU_WRITE_KEY */ { struct DemuxTask_OutbandKeyChange_type outband; outband.cipher_index = context->recipher_cipher_entry; outband.key_index = key_index; outband.cipher_type = EMhwlibCipher_AES; outband.scrambling = key_select; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_OutbandKeyChange, &outband, sizeof(outband), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%ld_SetPidForRecipher Error RMDemuxTaskPropertyID_OutbandKeyChange", context->id)); return err; } } /* go through all pids to set enable recipher for video and audio pids */ /* and folk the output for all clear PSI pids, and ciphered video and audio */#ifdef USE_HW_FIXED_PID_ENTRY err = SetPatCatPidAsRecipherPid( context ); if( RMFAILED(err) ){ RMDBGLOG(( ENABLE, "Set recipher failed for PAT CAT\n" )); return RM_ERROR; }#endif for (i = 0; i < context->pid_table_count; i++) { err = SetPidAsRecipherPid( context, i ); if( RMFAILED(err) ){ RMDBGLOG(( ENABLE, "Set recipher failed for pid %ld\n", i )); return RM_ERROR; } } return RM_OK;} static RMstatus SetHwAVPlayback(struct context_per_task *context){ RMstatus err; struct DemuxTask_PidEntry_type entry; struct DemuxTask_PidEntryAddCipher_type cipher; RMDBGLOG((ENABLE, "============== %ld_SetHwAVPlayback vpid=%x apid=%x pcrpid=%x\n", context->id, context->video_pid, context->audio_pid, context->pcr_pid)); if (context->video_pid != 0x1fff) { /* set the video pid */ entry.index = context->video_pidentry; entry.PidEntry.pid = context->video_pid; if(context->demux_opt->send_scrambled_packets_for_invalid_key) entry.PidEntry.input_type = EMhwlibPid_Ts1; else entry.PidEntry.input_type = EMhwlibPid_Ts; entry.PidEntry.flags = TS_FLAGS; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntry, &entry, sizeof(entry), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error video RMDemuxTaskPropertyID_PidEntry", context->id)); return err; } err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryEnable, &entry.index, sizeof(entry.index), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error video RMDemuxTaskPropertyID_PidEntryEnable", context->id)); return err; } } else { /* disable the video pid */ entry.index = context->video_pidentry; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryDisable, &entry.index, sizeof(entry.index), 0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -