• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2017 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
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 
getDefaultH264Params(boolean isHighProfile)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 
isSameH264Profile( Map<String, String> params1, Map<String, String> params2)45   public static boolean isSameH264Profile(
46       Map<String, String> params1, Map<String, String> params2) {
47     return nativeIsSameH264Profile(params1, params2);
48   }
49 
nativeIsSameH264Profile( Map<String, String> params1, Map<String, String> params2)50   private static native boolean nativeIsSameH264Profile(
51       Map<String, String> params1, Map<String, String> params2);
52 }
53