mm-video-v4l2: add support for AVC and HEVC secure encoding
Add support for AVC and HEVC secure encoding.
Change-Id: Ia8d21803b666aa9fb7ea173c6d9a53e82dc32d34
diff --git a/mm-core/src/registry_table_android.c b/mm-core/src/registry_table_android.c
index 417f3d1..6146d3a 100644
--- a/mm-core/src/registry_table_android.c
+++ b/mm-core/src/registry_table_android.c
@@ -57,9 +57,11 @@
OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.mpeg4sw", "libOmxSwVencMpeg4.so", "video_encoder.mpeg4"),
OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.h263sw", "libOmxSwVencMpeg4.so", "video_encoder.h263"),
OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.avc", "libOmxVenc.so", "video_encoder.avc"),
+ OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.avc.secure", "libOmxVenc.so", "video_encoder.avc"),
OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.vp8", "libOmxVenc.so", "video_encoder.vp8"),
OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.hevc", "libOmxVenc.so", "video_encoder.hevc"),
OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.hevc.cq", "libOmxVenc.so", "video_encoder.hevc"),
+ OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.hevc.secure", "libOmxVenc.so", "video_encoder.hevc"),
OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.heic", "libOmxVenc.so", "image_encoder.heic"),
OMX_REGISTRY_ENTRY("OMX.qti.vdec.vpp", "libOmxVpp.so", "iv_processor.yuv"),
#endif // VIDC_STUB_HAL
diff --git a/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp b/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp
index 87f6e73..906a0be 100644
--- a/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp
+++ b/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp
@@ -4317,7 +4317,8 @@
DEBUG_PRINT_ERROR("ERROR: No more roles");
eRet = OMX_ErrorNoMore;
}
- } else if (!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.avc",OMX_MAX_STRINGNAME_SIZE)) {
+ } else if (!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.avc",OMX_MAX_STRINGNAME_SIZE) ||
+ !strncmp((char*)m_nkind, "OMX.qcom.video.encoder.avc.secure",OMX_MAX_STRINGNAME_SIZE)) {
if ((0 == index) && role) {
strlcpy((char *)role, "video_encoder.avc",OMX_MAX_STRINGNAME_SIZE);
DEBUG_PRINT_LOW("component_role_enum: role %s",role);
@@ -4335,6 +4336,7 @@
}
} else if (!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.hevc", OMX_MAX_STRINGNAME_SIZE) ||
!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.hevc.cq", OMX_MAX_STRINGNAME_SIZE) ||
+ !strncmp((char*)m_nkind, "OMX.qcom.video.encoder.hevc.secure", OMX_MAX_STRINGNAME_SIZE) ||
!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.heic", OMX_MAX_STRINGNAME_SIZE)) {
if ((0 == index) && role) {
strlcpy((char *)role, "video_encoder.hevc", OMX_MAX_STRINGNAME_SIZE);
diff --git a/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp b/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp
index 138530f..5759b72 100644
--- a/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp
+++ b/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp
@@ -231,6 +231,11 @@
OMX_MAX_STRINGNAME_SIZE)) {
strlcpy((char *)m_cRole, "video_encoder.avc",OMX_MAX_STRINGNAME_SIZE);
codec_type = OMX_VIDEO_CodingAVC;
+ } else if(!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.avc.secure",\
+ OMX_MAX_STRINGNAME_SIZE)) {
+ strlcpy((char *)m_cRole, "video_encoder.avc",OMX_MAX_STRINGNAME_SIZE);
+ codec_type = OMX_VIDEO_CodingAVC;
+ secure_session = true;
} else if (!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.vp8", \
OMX_MAX_STRINGNAME_SIZE)) {
strlcpy((char *)m_cRole, "video_encoder.vp8",OMX_MAX_STRINGNAME_SIZE);
@@ -245,6 +250,11 @@
OMX_MAX_STRINGNAME_SIZE)) {
strlcpy((char *)m_cRole, "video_encoder.hevc", OMX_MAX_STRINGNAME_SIZE);
codec_type = OMX_VIDEO_CodingImageHEIC;
+ } else if (!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.hevc.secure", \
+ OMX_MAX_STRINGNAME_SIZE)) {
+ strlcpy((char *)m_cRole, "video_encoder.hevc", OMX_MAX_STRINGNAME_SIZE);
+ codec_type = OMX_VIDEO_CodingHEVC;
+ secure_session = true;
} else {
DEBUG_PRINT_ERROR("ERROR: Unknown Component");
eRet = OMX_ErrorInvalidComponentName;
@@ -949,6 +959,8 @@
m_sParamProfileLevel.eLevel = pParam->eLevel;
if (!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.avc",\
+ OMX_MAX_STRINGNAME_SIZE) ||
+ !strncmp((char *)m_nkind, "OMX.qcom.video.encoder.avc.secure",\
OMX_MAX_STRINGNAME_SIZE)) {
m_sParamAVC.eProfile = (OMX_VIDEO_AVCPROFILETYPE)m_sParamProfileLevel.eProfile;
m_sParamAVC.eLevel = (OMX_VIDEO_AVCLEVELTYPE)m_sParamProfileLevel.eLevel;
@@ -966,6 +978,8 @@
OMX_MAX_STRINGNAME_SIZE) ||
!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.hevc.cq",\
OMX_MAX_STRINGNAME_SIZE) ||
+ !strncmp((char*)m_nkind, "OMX.qcom.video.encoder.hevc.secure",\
+ OMX_MAX_STRINGNAME_SIZE) ||
!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.heic",\
OMX_MAX_STRINGNAME_SIZE)) {
m_sParamHEVC.eProfile = (OMX_VIDEO_HEVCPROFILETYPE)m_sParamProfileLevel.eProfile;
@@ -992,7 +1006,8 @@
return OMX_ErrorIncorrectStateOperation;
}
- if (!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.avc",OMX_MAX_STRINGNAME_SIZE)) {
+ if (!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.avc",OMX_MAX_STRINGNAME_SIZE) ||
+ !strncmp((char*)m_nkind, "OMX.qcom.video.encoder.avc.secure",OMX_MAX_STRINGNAME_SIZE)) {
if (!strncmp((char*)comp_role->cRole,"video_encoder.avc",OMX_MAX_STRINGNAME_SIZE)) {
strlcpy((char*)m_cRole,"video_encoder.avc",OMX_MAX_STRINGNAME_SIZE);
} else {
@@ -1007,7 +1022,8 @@
eRet =OMX_ErrorUnsupportedSetting;
}
} else if (!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.hevc",OMX_MAX_STRINGNAME_SIZE) ||
- !strncmp((char*)m_nkind, "OMX.qcom.video.encoder.hevc.cq",OMX_MAX_STRINGNAME_SIZE)) {
+ !strncmp((char*)m_nkind, "OMX.qcom.video.encoder.hevc.cq",OMX_MAX_STRINGNAME_SIZE) ||
+ !strncmp((char*)m_nkind, "OMX.qcom.video.encoder.hevc.secure",OMX_MAX_STRINGNAME_SIZE)) {
if (!strncmp((const char*)comp_role->cRole,"video_encoder.hevc",OMX_MAX_STRINGNAME_SIZE)) {
strlcpy((char*)m_cRole,"video_encoder.hevc",OMX_MAX_STRINGNAME_SIZE);
} else {
@@ -1562,6 +1578,8 @@
m_sParamProfileLevel.eLevel = (OMX_VIDEO_AVCLEVELTYPE)eLevel;
if (!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.avc",\
+ OMX_MAX_STRINGNAME_SIZE) ||
+ !strncmp((char *)m_nkind, "OMX.qcom.video.encoder.avc.secure",\
OMX_MAX_STRINGNAME_SIZE)) {
m_sParamAVC.eProfile = (OMX_VIDEO_AVCPROFILETYPE)eProfile;
m_sParamAVC.eLevel = (OMX_VIDEO_AVCLEVELTYPE)eLevel;
@@ -1579,6 +1597,8 @@
OMX_MAX_STRINGNAME_SIZE) ||
!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.hevc.cq",\
OMX_MAX_STRINGNAME_SIZE) ||
+ !strncmp((char *)m_nkind, "OMX.qcom.video.encoder.hevc.secure",\
+ OMX_MAX_STRINGNAME_SIZE) ||
!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.heic",\
OMX_MAX_STRINGNAME_SIZE)) {
m_sParamHEVC.eProfile = (OMX_VIDEO_HEVCPROFILETYPE)eProfile;
diff --git a/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp b/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp
index a2b00f2..ff0bdb7 100644
--- a/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp
+++ b/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp
@@ -1538,6 +1538,17 @@
fdesc.index++;
}
+ if(venc_handle->is_secure_session()) {
+ control.id = V4L2_CID_MPEG_VIDC_VIDEO_SECURE;
+ control.value = 1;
+ DEBUG_PRINT_HIGH("ioctl: open secure device");
+ ret=ioctl(m_nDriver_fd, VIDIOC_S_CTRL,&control);
+ if (ret) {
+ DEBUG_PRINT_ERROR("ioctl: open secure dev fail, rc %d", ret);
+ return false;
+ }
+ }
+
if (venc_handle->is_secure_session()) {
m_sOutput_buff_property.alignment = SZ_1M;
m_sInput_buff_property.alignment = SZ_1M;
@@ -1592,17 +1603,6 @@
ret = ioctl(m_nDriver_fd,VIDIOC_REQBUFS, &bufreq);
m_sOutput_buff_property.mincount = m_sOutput_buff_property.actualcount = bufreq.count;
- if(venc_handle->is_secure_session()) {
- control.id = V4L2_CID_MPEG_VIDC_VIDEO_SECURE;
- control.value = 1;
- DEBUG_PRINT_HIGH("ioctl: open secure device");
- ret=ioctl(m_nDriver_fd, VIDIOC_S_CTRL,&control);
- if (ret) {
- DEBUG_PRINT_ERROR("ioctl: open secure dev fail, rc %d", ret);
- return false;
- }
- }
-
resume_in_stopped = 0;
metadatamode = 0;