From 693cc4853990cbbe6857bbb3058cee4e302344d0 Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Wed, 14 Aug 2024 20:13:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- utils/src/histreamer_ability_parser.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/utils/src/histreamer_ability_parser.cpp b/utils/src/histreamer_ability_parser.cpp index 41528443..8243a237 100644 --- a/utils/src/histreamer_ability_parser.cpp +++ b/utils/src/histreamer_ability_parser.cpp @@ -57,7 +57,9 @@ void FromJson(const cJSON *jsonObject, AudioEncoderIn &audioEncoderIn) } cJSON *sampleRateItem = nullptr; cJSON_ArrayForEach(sampleRateItem, sampleRate) { - audioEncoderIn.sample_rate.push_back((uint32_t)sampleRateItem->valuedouble); + if (sampleRateItem && sampleRateItem->type == cJSON_Number) { + audioEncoderIn.sample_rate.push_back((uint32_t)sampleRateItem->valuedouble); + } } } @@ -149,7 +151,9 @@ void FromJson(const cJSON *jsonObject, AudioDecoderIn &audioDecoderIn) const cJSON *channelLayoutJson = cJSON_GetObjectItem(jsonObject, AUDIO_CHANNEL_LAYOUT.c_str()); const cJSON *layout = nullptr; cJSON_ArrayForEach(layout, channelLayoutJson) { - audioDecoderIn.channel_layout.push_back((AudioChannelLayout)layout->valuedouble); + if (layout && layout->type == cJSON_Number) { + audioDecoderIn.channel_layout.push_back((AudioChannelLayout)layout->valuedouble); + } } } @@ -171,7 +175,9 @@ void FromJson(const cJSON *jsonObject, AudioDecoderOut &audioDecoderOut) cJSON *sampleFormatJson = cJSON_GetObjectItem(jsonObject, AUDIO_SAMPLE_FORMAT.c_str()); cJSON *format = nullptr; cJSON_ArrayForEach(format, sampleFormatJson) { - audioDecoderOut.sample_fmt.push_back((AudioSampleFormat)format->valuedouble); + if (format && format->type == cJSON_Number) { + audioDecoderOut.sample_fmt.push_back((AudioSampleFormat)format->valuedouble); + } } } @@ -230,7 +236,9 @@ void FromJson(const cJSON *jsonObject, VideoEncoderIn &videoEncoderIn) cJSON *videoPixelFmt = cJSON_GetObjectItem(jsonObject, VIDEO_PIXEL_FMT.c_str()); cJSON *pixelFmt = nullptr; cJSON_ArrayForEach(pixelFmt, videoPixelFmt) { - videoEncoderIn.pixel_fmt.push_back((VideoPixelFormat)pixelFmt->valuedouble); + if (pixelFmt && pixelFmt->type == cJSON_Number) { + videoEncoderIn.pixel_fmt.push_back((VideoPixelFormat)pixelFmt->valuedouble); + } } } @@ -303,7 +311,9 @@ void FromJson(const cJSON *jsonObject, VideoDecoderIn &videoDecoderIn) cJSON *videoBitStreamFmtJson = cJSON_GetObjectItem(jsonObject, VIDEO_BIT_STREAM_FMT.c_str()); cJSON *fmt = nullptr; cJSON_ArrayForEach(fmt, videoBitStreamFmtJson) { - videoDecoderIn.vd_bit_stream_fmt.push_back((VideoBitStreamFormat)(fmt->valuedouble)); + if (fmt && fmt->type == cJSON_Number) { + videoDecoderIn.vd_bit_stream_fmt.push_back((VideoBitStreamFormat)(fmt->valuedouble)); + } } } @@ -326,7 +336,9 @@ void FromJson(const cJSON *jsonObject, VideoDecoderOut &videoDecoderOut) cJSON *videoPixelFmtJson = cJSON_GetObjectItem(jsonObject, VIDEO_PIXEL_FMT.c_str()); cJSON *fmt = nullptr; cJSON_ArrayForEach(fmt, videoPixelFmtJson) { - videoDecoderOut.pixel_fmt.push_back((VideoPixelFormat)(fmt->valuedouble)); + if (fmt && fmt->type == cJSON_Number) { + videoDecoderOut.pixel_fmt.push_back((VideoPixelFormat)(fmt->valuedouble)); + } } } -- Gitee