| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | package org.webrtc; |
| 12 |
| 13 | import java.util.Map; |
| 14 | import java.util.HashMap; |
| 15 |
| 16 | /** Container for static helper functions related to dealing with H264 codecs. */ |
| 17 | class H264Utils { |
| 18 | public static final String H264_FMTP_PROFILE_LEVEL_ID = "profile-level-id"; |
| 19 | public static final String H264_FMTP_LEVEL_ASYMMETRY_ALLOWED = "level-asymmetry-allowed"; |
| 20 | public static final String H264_FMTP_PACKETIZATION_MODE = "packetization-mode"; |
| 21 |
| 22 | public static final String H264_PROFILE_CONSTRAINED_BASELINE = "42e0"; |
| 23 | public static final String H264_PROFILE_CONSTRAINED_HIGH = "640c"; |
| 24 | public static final String H264_LEVEL_3_1 = "1f"; // 31 in hex. |
| 25 | public static final String H264_CONSTRAINED_HIGH_3_1 = |
| 26 | H264_PROFILE_CONSTRAINED_HIGH + H264_LEVEL_3_1; |
| 27 | public static final String H264_CONSTRAINED_BASELINE_3_1 = |
| 28 | H264_PROFILE_CONSTRAINED_BASELINE + H264_LEVEL_3_1; |
| 29 |
| 30 | public static Map<String, String> getDefaultH264Params(boolean isHighProfile) { |
| 31 | final Map<String, String> params = new HashMap<>(); |
| 32 | params.put(VideoCodecInfo.H264_FMTP_LEVEL_ASYMMETRY_ALLOWED, "1"); |
| 33 | params.put(VideoCodecInfo.H264_FMTP_PACKETIZATION_MODE, "1"); |
| 34 | params.put(VideoCodecInfo.H264_FMTP_PROFILE_LEVEL_ID, |
| 35 | isHighProfile ? VideoCodecInfo.H264_CONSTRAINED_HIGH_3_1 |
| 36 | : VideoCodecInfo.H264_CONSTRAINED_BASELINE_3_1); |
| 37 | return params; |
| 38 | } |
| 39 |
| 40 | public static VideoCodecInfo DEFAULT_H264_BASELINE_PROFILE_CODEC = |
| 41 | new VideoCodecInfo("H264", getDefaultH264Params(/* isHighProfile= */ false)); |
| 42 | public static VideoCodecInfo DEFAULT_H264_HIGH_PROFILE_CODEC = |
| 43 | new VideoCodecInfo("H264", getDefaultH264Params(/* isHighProfile= */ true)); |
| 44 |
| 45 | public static boolean isSameH264Profile( |
| 46 | Map<String, String> params1, Map<String, String> params2) { |
| 47 | return nativeIsSameH264Profile(params1, params2); |
| 48 | } |
| 49 |
| 50 | private static native boolean nativeIsSameH264Profile( |
| 51 | Map<String, String> params1, Map<String, String> params2); |
| 52 | } |
| 53 |