Coded alarm modification.

Signed-off-by: zhenghongda <18810008421@163.com>
This commit is contained in:
zhenghongda 2024-10-24 13:56:13 +00:00
parent 6036066663
commit 646899ae43
3 changed files with 15 additions and 12 deletions

View File

@ -74,7 +74,7 @@
#ifdef OHOS_DRM
#define MOV_DRM_PSSH_TITLE_LEN (8)
static const uint8_t g_pssh_title_buf[] = {
static const uint8_t g_pssh_title_buf[4] = { // 4:bufSize
0x70, 0x73, 0x73, 0x68
};
#endif
@ -6839,12 +6839,15 @@ static int mov_read_pssh_ex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint8_t pssh_buf[AV_DRM_MAX_DRM_PSSH_LEN];
size_t old_side_data_size = 0;
uint32_t old_side_data_count = 0;
uint32_t pssh_exist_flag = 0;
int pssh_exist_flag = 0;
if ((c == NULL) || (c->fc == NULL) || (c->fc->nb_streams < 1) || (c->fc->streams == NULL) || (pb == NULL) ||
(atom.size > (AV_DRM_MAX_DRM_PSSH_LEN - MOV_DRM_PSSH_TITLE_LEN)) || (atom.size == 0)) {
(atom.size > (AV_DRM_MAX_DRM_PSSH_LEN - MOV_DRM_PSSH_TITLE_LEN)) || (atom.size <= 0)) {
return 0;
}
st = c->fc->streams[c->fc->nb_streams-1];
if (st == NULL) {
return 0;
}
memset(pssh_buf, 0, sizeof(pssh_buf));
AV_WB32(pssh_buf, (atom.size + MOV_DRM_PSSH_TITLE_LEN));

View File

@ -343,7 +343,7 @@ static void mpegts_set_drm_algo_and_blocks(uint8_t algo, AV_DrmCencInfo *cenc_in
static int mpegts_get_drm_info(const uint8_t *src, uint32_t src_len, AV_DrmInfo *drm_info)
{
uint32_t offset = 0;
if (src_len <= DRM_MIN_DRM_INFO_LEN) {
if (src == NULL || src_len <= DRM_MIN_DRM_INFO_LEN) {
av_log(NULL, AV_LOG_ERROR, "algo not found");
return -1;
}
@ -412,7 +412,7 @@ static void mpegts_avstream_set_drm_info(AVStream *avstream, AV_DrmInfo *info)
AV_DrmInfo *new_side_data = NULL;
size_t old_side_data_size = 0;
uint32_t old_side_data_count = 0;
uint32_t pssh_exist_flag = 0;
int pssh_exist_flag = 0;
ff_mutex_lock(&g_mpegts_drm_info_mutex);
old_side_data = (AV_DrmInfo *)av_stream_get_side_data(avstream, AV_PKT_DATA_ENCRYPTION_INIT_INFO,
&old_side_data_size);
@ -437,7 +437,7 @@ static void mpegts_avstream_set_drm_info(AVStream *avstream, AV_DrmInfo *info)
static void mpegts_get_cenc_info(const uint8_t *src, uint32_t src_len, AV_DrmCencInfo *cenc_info)
{
uint32_t offset = 0;
if (src_len <= DRM_MIN_DRM_INFO_LEN) {
if (src == NULL || src_len <= DRM_MIN_DRM_INFO_LEN) {
av_log(NULL, AV_LOG_ERROR, "algo not found");
return;
}
@ -833,11 +833,11 @@ static int mpegts_drm_get_cenc_info(AVStream *avstream, enum AVCodecID codec_id,
static void mpegts_packet_add_cenc_info(AVFormatContext *s, AVPacket *pkt)
{
AV_DrmCencInfo cenc_info;
if (pkt == NULL || pkt->data == NULL || pkt->size == 0) {
if (pkt == NULL || pkt->data == NULL || pkt->size <= 0 || pkt->stream_index < 0) {
av_log(NULL, AV_LOG_ERROR, "pkt parameter err\n");
return;
}
if ((s == NULL) || (s->streams == NULL) || (pkt->stream_index >= s->nb_streams) ||
if ((s == NULL) || (s->streams == NULL) || ((uint32_t)(pkt->stream_index) >= s->nb_streams) ||
(s->streams[pkt->stream_index] == NULL) || (s->streams[pkt->stream_index]->codecpar == NULL)) {
av_log(NULL, AV_LOG_ERROR, "s parameter err\n");
return;
@ -851,7 +851,7 @@ static void mpegts_packet_add_cenc_info(AVFormatContext *s, AVPacket *pkt)
return;
}
cenc_info.sub_samples[0].clear_header_len = pkt->size;
cenc_info.sub_samples[0].clear_header_len = (uint32_t)(pkt->size);
cenc_info.sub_samples[0].pay_load_len = 0;
cenc_info.sub_sample_num = 1;
cenc_info.algo = AV_DRM_ALG_CENC_UNENCRYPTED;

View File

@ -192,7 +192,7 @@ AV_DrmCencInfo *av_encryption_info_add_side_data_ex(const AVEncryptionInfo *info
uint32_t i;
if ((info == NULL) || (info->key_id_size != AV_DRM_KEY_ID_SIZE) || (info->iv_size > AV_DRM_IV_SIZE) ||
(info->iv_size == 0) || (info->subsample_count > AV_DRM_MAX_SUB_SAMPLE_NUM) || (info->key_id == NULL) ||
(info->iv == NULL) || (info->subsamples == NULL) || (side_data_size == NULL)) {
(info->iv == NULL) || (info->subsamples == NULL) || (side_data_size == NULL) || (pkt_data_size <= 0)) {
return NULL;
}
@ -220,10 +220,10 @@ AV_DrmCencInfo *av_encryption_info_add_side_data_ex(const AVEncryptionInfo *info
((info->scheme == MKBETAG('c','e','n','s')) || (info->scheme == MKBETAG('s','m','4','r')))) {
cenc_info->sub_sample_num = 1; // 1: sub_sample num
cenc_info->sub_samples[0].clear_header_len = 0;
cenc_info->sub_samples[0].pay_load_len = (pkt_data_size / 16) * 16; // 16: block size
cenc_info->sub_samples[0].pay_load_len = (uint32_t)((pkt_data_size / 16) * 16); // 16: block size
if ((pkt_data_size % 16) != 0) { // 16: block size
cenc_info->sub_sample_num = 2; // 2: sub_sample num
cenc_info->sub_samples[1].clear_header_len = pkt_data_size % 16; // 16: block size
cenc_info->sub_samples[1].clear_header_len = (uint32_t)(pkt_data_size % 16); // 16: block size
cenc_info->sub_samples[1].pay_load_len = 0;
}
}