{
LOGI("ENTER");
- JsonArray *rootArray = json_object_get_array_member(root, "box");
- unsigned int elements = json_array_get_length(rootArray);
+ if (!json_object_has_member(root, "box")) {
+ LOGE("member box not exists");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
- for (unsigned int elem_idx = 0; elem_idx < elements; ++elem_idx) {
- JsonNode *pNode = json_array_get_element(rootArray, elem_idx);
- JsonObject *pObject = json_node_get_object(pNode);
+ JsonObject *pObject = json_object_get_object_member(root, "box");
- name = json_object_get_string_member(pObject, "name");
- LOGI("layer: %s", name.c_str());
+ name = json_object_get_string_member(pObject, "name");
+ LOGI("layer: %s", name.c_str());
- JsonArray *array = json_object_get_array_member(pObject, "index");
- unsigned int elements2 = json_array_get_length(array);
+ JsonArray *array = json_object_get_array_member(pObject, "index");
+ unsigned int elements2 = json_array_get_length(array);
- LOGI("range dim: size[%u]", elements2);
+ LOGI("range dim: size[%u]", elements2);
- for (unsigned int elem2_idx = 0; elem2_idx < elements2; ++elem2_idx)
- if (static_cast<int>(
- json_array_get_int_element(array, elem2_idx)) == 1)
- dimInfo.SetValidIndex(elem2_idx);
-
- try {
- type = GetSupportedType(pObject, "box_type", supportedBoxTypes);
- coordinate = GetSupportedType(pObject, "box_coordinate",
- supportedBoxCoordinateTypes);
- decodingType = GetSupportedType(pObject, "decoding_type",
- supportedBoxDecodingTypes);
- } catch (const std::exception &e) {
- LOGE("Invalid %s", e.what());
- return MEDIA_VISION_ERROR_INVALID_OPERATION;
- }
+ for (unsigned int elem2_idx = 0; elem2_idx < elements2; ++elem2_idx)
+ if (static_cast<int>(json_array_get_int_element(array, elem2_idx)) == 1)
+ dimInfo.SetValidIndex(elem2_idx);
+
+ try {
+ type = GetSupportedType(pObject, "box_type", supportedBoxTypes);
+ coordinate = GetSupportedType(pObject, "box_coordinate",
+ supportedBoxCoordinateTypes);
+ decodingType = GetSupportedType(pObject, "decoding_type",
+ supportedBoxDecodingTypes);
+ } catch (const std::exception &e) {
+ LOGE("Invalid %s", e.what());
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
- array = json_object_get_array_member(pObject, "box_order");
- elements2 = json_array_get_length(array);
- LOGI("box order should have 4 elements and it has [%u]", elements2);
+ array = json_object_get_array_member(pObject, "box_order");
+ elements2 = json_array_get_length(array);
+ LOGI("box order should have 4 elements and it has [%u]", elements2);
- for (unsigned int elem2_idx = 0; elem2_idx < elements2; ++elem2_idx) {
- auto val = static_cast<int>(
- json_array_get_int_element(array, elem2_idx));
- order.push_back(val);
- LOGI("%d", val);
- }
+ for (unsigned int elem2_idx = 0; elem2_idx < elements2; ++elem2_idx) {
+ auto val =
+ static_cast<int>(json_array_get_int_element(array, elem2_idx));
+ order.push_back(val);
+ LOGI("%d", val);
}
LOGI("LEAVE");
{
LOGI("ENTER");
- // box
- JsonArray *rootArray = json_object_get_array_member(root, "box");
- unsigned int elements = json_array_get_length(rootArray);
-
- // TODO: handling error
- for (unsigned int elem = 0; elem < elements; ++elem) {
- JsonNode *pNode = json_array_get_element(rootArray, elem);
- JsonObject *pObject = json_node_get_object(pNode);
+ if (!json_object_has_member(root, "box")) {
+ LOGE("member box not exists");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
- if (!json_object_has_member(pObject, "decoding_info")) {
- LOGE("decoding_info is mandatory. Invalid metadata");
- LOGI("LEAVE");
+ JsonObject *pObject = json_object_get_object_member(root, "box");
- return MEDIA_VISION_ERROR_INVALID_OPERATION;
- }
+ if (!json_object_has_member(pObject, "decoding_info")) {
+ LOGE("decoding_info is mandatory. Invalid metadata");
+ LOGI("LEAVE");
- int ret = MEDIA_VISION_ERROR_NONE;
- JsonObject *cObject =
- json_object_get_object_member(pObject, "decoding_info");
- if (json_object_has_member(cObject, "anchor")) {
- ret = GetDecodeInfo().ParseAnchorParam(cObject);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Fail to ParseAnchorParam[%d]", ret);
- return ret;
- }
- } else if (json_object_has_member(cObject, "cell")) {
- ret = GetDecodeInfo().ParseCellParam(cObject);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Fail to ParseCellParam[%d]", ret);
- return ret;
- }
- } else {
- LOGE("anchor is mandatory. Invalid metadata");
- LOGI("LEAVE");
-
- return MEDIA_VISION_ERROR_INVALID_OPERATION;
- }
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
- ret = GetDecodeInfo().ParseNms(cObject);
+ int ret = MEDIA_VISION_ERROR_NONE;
+ JsonObject *cObject =
+ json_object_get_object_member(pObject, "decoding_info");
+ if (json_object_has_member(cObject, "anchor")) {
+ ret = GetDecodeInfo().ParseAnchorParam(cObject);
if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Fail to ParseNms[%d]", ret);
+ LOGE("Fail to ParseAnchorParam[%d]", ret);
return ret;
}
-
- ret = GetDecodeInfo().ParseRotate(cObject);
+ } else if (json_object_has_member(cObject, "cell")) {
+ ret = GetDecodeInfo().ParseCellParam(cObject);
if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Fail to ParseRotate[%d]", ret);
+ LOGE("Fail to ParseCellParam[%d]", ret);
return ret;
}
+ } else {
+ LOGE("anchor is mandatory. Invalid metadata");
+ LOGI("LEAVE");
- ret = GetDecodeInfo().ParseRoiOption(cObject);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Fail to ParseRoiOption[%d]", ret);
- return ret;
- }
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+
+ ret = GetDecodeInfo().ParseNms(cObject);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Fail to ParseNms[%d]", ret);
+ return ret;
+ }
+
+ ret = GetDecodeInfo().ParseRotate(cObject);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Fail to ParseRotate[%d]", ret);
+ return ret;
+ }
+
+ ret = GetDecodeInfo().ParseRoiOption(cObject);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Fail to ParseRoiOption[%d]", ret);
+ return ret;
}
LOGI("LEAVE");