Migrate from MediaCodecList.getCodecCount to iterate getCodecInfos member function in HardwareVideoEncoderFactory
GetCodecCount is deprecated in API 21+ and getCodecInfos is encouraged to be used instead. See guidance: https://developer.android.com/reference/android/media/MediaCodecList#getCodecCount() Bug: webrtc:386857228 Change-Id: I01ce9ed6da25aade4679012e4ca5e308d7672ee8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/373240 Reviewed-by: Zoé Lepaul <xalep@webrtc.org> Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43721}
This commit is contained in:
parent
c6b7acb9cd
commit
83861d5649
@ -155,14 +155,8 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable MediaCodecInfo findCodecForType(VideoCodecMimeType type) {
|
private @Nullable MediaCodecInfo findCodecForType(VideoCodecMimeType type) {
|
||||||
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
|
final MediaCodecList mediaCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
|
||||||
MediaCodecInfo info = null;
|
for (MediaCodecInfo info : mediaCodecList.getCodecInfos()) {
|
||||||
try {
|
|
||||||
info = MediaCodecList.getCodecInfoAt(i);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Logging.e(TAG, "Cannot retrieve encoder codec info", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info == null || !info.isEncoder()) {
|
if (info == null || !info.isEncoder()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user