最近需要为定制的Camera添加一种特殊的数据格式,原本camera3_profiles_rkxxxx.xml有三种BLOB,YCbCr_420_888,IMPLEMENTATION_DEFINED,这三种分别对应JPEG,YUV_420_888, PRIVATE。我新增的格式无论是替代已有的三种,还是添加一种,都会导致xml无法正常解析,找了一段时间资料,发现这部分内容很少有人提及,大部分摄像头都用YCbCr_420_888这种格式搞定了,所以只能自己从头分析研究这个xml文件的解析流程,希望能找到出路。
camera3_profiles_rkxxxx.xml的读取是在hardware/rockchip/camera/common/platformdata/ChromeCameraProfiles.cpp中。
status_t ChromeCameraProfiles::init()
{
status_t status = OK;
LOGI("@%s", __FUNCTION__);
// determine the xml file name
getXmlConfigName();
status = CameraProfiles::init();
if (status) {
LOGE("CameraProfiles base init error:%d", status);
return status;
}
// Parse common sections
getDataFromXmlFile();
createConfParser();
LOGI("@%s exit!", __FUNCTION__);
return OK;
}
在hardware/rockchip/camera/common/platformdata/CameraProfiles.cpp中读取xml中的内容getDataFromXmlFile,createConfParser。
具体的细节数据操作在hardware/rockchip/camera/common/platformdata/CameraMetadataHelper.cpp中,其中使用的相关section和tag的函数如get_camera_metadata_section_name和get_camera_metadata_tag_name,实现代码在system/media/camera/src/Camera_metadata.c中。
在回到我们的目标,是为了实现添加Camera支持的数据格式。camera3_profiles_rkxxxx.xml中关于数据格式的解析是使用下面这个函数:
/**
* This function will handle all the android static metadata related elements of sensor.
*
* It will be called in the function startElement
* This method parses the input from the XML file, that can be manipulated.
* So extra care is applied in the validation of strings
*
* \param name: the element's name.
* \param atts: the element's attribute.
*/
void ChromeCameraProfiles::handleAndroidStaticMetadata(const char *name, const char **atts)
{
if (!validateStaticMetadata(name, atts))
return;
// Find tag
const metadata_tag_t *tagInfo = findTagInfo(name, android_static_

最低0.47元/天 解锁文章
654

被折叠的 条评论
为什么被折叠?



