调用OH_AVCodec相关接口,使用视频硬件编解码器处理视频。
// To create a decoder using a codec name, if the application has special requirements, such as selecting a decoder that supports a certain resolution specification, // the capability can be queried first, and then the decoder can be created based on the codec name. OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, false); const char *name = OH_AVCapability_GetName(capability); // Create a decoder through mimetype // Hard solution: Create H264 decoder. When there are multiple optional decoders, the system will create the most suitable decoder OH_AVCodec *videoDec = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC); // Hard solution: Create H265 decoder OH_AVCodec *videoDecH = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_HEVC);

具体使用方法请参考基础耗时:Time分析。通过systrace确认av_codec_service进程的负载,如下图所示。业务频繁唤醒且有实际函数运行,说明视频处于硬解码状态。
