feat: add Harmony OHCodec hwdec adapter

This commit is contained in:
BoatingCloud committed 2026-08-29 12:36:14 +08:00
1 parent 9fdf08073e
commit 3f6132637b
14 files changed
+579 -1

No files matched your search

+50
View File
@@ -225,6 +225,7 @@ sources = files(
'video/filter/vf_format.c',
'video/filter/vf_sub.c',
'video/fmt-conversion.c',
'video/harmony_hwdec.c',
'video/hwdec.c',
'video/image_loader.c',
'video/image_writer.c',
@@ -931,6 +932,35 @@ if features['harmony-audio']
dependencies += harmony_audio
endif
harmony_ohcodec_opt = get_option('harmony-ohcodec').require(
ohos,
error_message: 'HarmonyOS OHCodec is only available on OHOS targets!',
)
harmony_ohcodec_libs = [
cc.find_library('native_media_codecbase', required: harmony_ohcodec_opt),
cc.find_library('native_media_core', required: harmony_ohcodec_opt),
cc.find_library('native_media_vdec', required: harmony_ohcodec_opt),
cc.find_library('native_window', required: harmony_ohcodec_opt),
]
harmony_ohcodec_headers = cc.has_header('multimedia/player_framework/native_avcapability.h',
required: harmony_ohcodec_opt) and \
cc.has_header('multimedia/player_framework/native_avcodec_videodecoder.h',
required: harmony_ohcodec_opt) and \
cc.has_header('multimedia/player_framework/native_avbuffer.h',
required: harmony_ohcodec_opt) and \
cc.has_header('native_window/external_window.h',
required: harmony_ohcodec_opt)
features += {'harmony-ohcodec': harmony_ohcodec_headers and harmony_ohcodec_libs[0].found() and
harmony_ohcodec_libs[1].found() and harmony_ohcodec_libs[2].found() and
harmony_ohcodec_libs[3].found()}
if harmony_ohcodec_opt.enabled() and not features['harmony-ohcodec']
error('HarmonyOS OHCodec headers or native media libraries were not found')
endif
if features['harmony-ohcodec']
dependencies += harmony_ohcodec_libs
sources += files('video/out/hwdec/hwdec_ohcodec.c')
endif
opensles = cc.find_library('OpenSLES', required: get_option('opensles'))
features += {'opensles': opensles.found()}
if features['opensles']
@@ -1333,6 +1363,26 @@ if plain_gl.allowed()
features += {'gl': true}
endif
harmony_ohcodec_gl_opt = get_option('harmony-ohcodec-gl').require(
features['harmony-ohcodec'] and features['gl'] and ohos,
error_message: 'HarmonyOS OHCodec GPU interop requires OHCodec and OpenGL!',
)
harmony_ohcodec_gl_egl = cc.find_library('EGL', required: harmony_ohcodec_gl_opt)
harmony_ohcodec_gl_lib = cc.find_library('native_buffer', required: harmony_ohcodec_gl_opt)
harmony_ohcodec_gl_headers = cc.has_header('native_buffer/native_buffer.h',
required: harmony_ohcodec_gl_opt) and \
cc.has_header('EGL/eglext.h', required: harmony_ohcodec_gl_opt) and \
cc.has_header('GLES2/gl2ext.h', required: harmony_ohcodec_gl_opt)
features += {'harmony-ohcodec-gl': harmony_ohcodec_gl_headers and
harmony_ohcodec_gl_egl.found() and harmony_ohcodec_gl_lib.found()}
if harmony_ohcodec_gl_opt.enabled() and not features['harmony-ohcodec-gl']
error('HarmonyOS OHCodec GPU interop headers or EGL/native_buffer libraries were not found')
endif
if features['harmony-ohcodec-gl']
dependencies += [harmony_ohcodec_gl_egl, harmony_ohcodec_gl_lib]
sources += files('video/out/hwdec/hwdec_ohcodec_gl.c')
endif
if features['egl'] or features['egl-android'] or features['egl-angle-win32']
sources += files('video/out/opengl/egl_helpers.c')
endif