HarmonyOS-鸿蒙app开发 —基于java媒体编解码能力查询开发指导

HarmonyOS-鸿蒙app开发 —基于java媒体编解码能力查询开发指导

场景介绍

媒体编解码能力查询主要指查询设备所支持的编解码器的MIME(Multipurpose Internet Mail Extensions,媒体类型)列表,并判断设备是否支持指定MIME对应的编码器/解码器。

接口说明

表1 媒体编解码能力查询类CodecDescriptionList的主要接口

接口名

功能描述

getSupportedMimes()

获取某设备所支持的编解码器的MIME列表。

isDecodeSupportedByMime(String mime)

判断某设备是否支持指定MIME对应的解码器。

isEncodeSupportedByMime(String mime)

判断某设备是否支持指定MIME对应的编码器。

isDecoderSupportedByFormat(Format format)

判断某设备是否支持指定媒体格式对应的解码器。

isEncoderSupportedByFormat(Format format)

判断某设备是否支持指定媒体格式对应的编码器。

开发步骤

  1. 调用CodecDescriptionList类的静态getSupportedMimes()方法,获取某设备所支持的编解码器的MIME列表。代码示例如下:
    1. List<String> mimes = CodecDescriptionList.getSupportedMimes();
  2. 调用CodecDescriptionList类的静态isDecodeSupportedByMime方法,判断某设备是否支持指定MIME对应的解码器,支持返回true,否则返回false。代码示例如下:
    1. boolean result = CodecDescriptionList.isDecodeSupportedByMime(Format.VIDEO_VP9);
  3. 调用CodecDescriptionList类的静态isEncodeSupportedByMime方法,判断某设备是否支持指定MIME对应的编码器,支持返回true,否则返回false。代码示例如下:
    1. boolean result = CodecDescriptionList.isEncodeSupportedByMime(Format.AUDIO_FLAC);
  4. 调用CodecDescriptionList类的静态isDecoderSupportedByFormat/isEncoderSupportedByFormat方法,判断某设备是否支持指定Format的编解码器,支持返回true,否则返回false。代码示例如下:
    1. Format format = new Format();
    2. format.putStringValue(Format.MIME, Format.VIDEO_AVC);
    3. format.putIntValue(Format.WIDTH, 2560);
    4. format.putIntValue(Format.HEIGHT, 1440);
    5. format.putIntValue(Format.FRAME_RATE, 30);
    6. format.putIntValue(Format.FRAME_INTERVAL, 1);
    7. boolean result = CodecDescriptionList.isDecoderSupportedByFormat(format);
    8. result = CodecDescriptionList.isEncoderSupportedByFormat(format);
0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x