blob: f1f1145399e8888eaff8dad4e542b5b6f7d0d397 [file] [log] [blame]
Sami Kalliomäkie2410e92017-06-02 14:46:12 +02001/*
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
11package org.webrtc;
12
Anders Carlsson1e1dd772017-11-16 15:44:14 +010013import java.util.Arrays;
14import java.util.Locale;
Sami Kalliomäkie2410e92017-06-02 14:46:12 +020015import java.util.Map;
16
17/**
18 * Represent a video codec as encoded in SDP.
19 */
20public class VideoCodecInfo {
sakalc36daec2017-09-11 06:53:27 -070021 // Keys for H264 VideoCodecInfo properties.
22 public static final String H264_FMTP_PROFILE_LEVEL_ID = "profile-level-id";
23 public static final String H264_FMTP_LEVEL_ASYMMETRY_ALLOWED = "level-asymmetry-allowed";
24 public static final String H264_FMTP_PACKETIZATION_MODE = "packetization-mode";
25
Sami Kalliomäki828cf242017-10-30 13:49:31 +010026 public static final String H264_PROFILE_CONSTRAINED_BASELINE = "42e0";
sakalc36daec2017-09-11 06:53:27 -070027 public static final String H264_PROFILE_CONSTRAINED_HIGH = "640c";
28 public static final String H264_LEVEL_3_1 = "1f"; // 31 in hex.
29 public static final String H264_CONSTRAINED_HIGH_3_1 =
30 H264_PROFILE_CONSTRAINED_HIGH + H264_LEVEL_3_1;
31 public static final String H264_CONSTRAINED_BASELINE_3_1 =
32 H264_PROFILE_CONSTRAINED_BASELINE + H264_LEVEL_3_1;
33
Sami Kalliomäkie2410e92017-06-02 14:46:12 +020034 public final String name;
35 public final Map<String, String> params;
Anders Carlssondc1b9f12017-11-10 13:15:04 +010036 @Deprecated public final int payload;
Sami Kalliomäkie2410e92017-06-02 14:46:12 +020037
Magnus Jedvert9060eb12017-12-12 12:52:54 +010038 @CalledByNative
Anders Carlssondc1b9f12017-11-10 13:15:04 +010039 public VideoCodecInfo(String name, Map<String, String> params) {
40 this.payload = 0;
41 this.name = name;
42 this.params = params;
43 }
44
45 @Deprecated
Sami Kalliomäkie2410e92017-06-02 14:46:12 +020046 public VideoCodecInfo(int payload, String name, Map<String, String> params) {
47 this.payload = payload;
48 this.name = name;
49 this.params = params;
50 }
Anders Carlsson1e1dd772017-11-16 15:44:14 +010051
52 @Override
53 public boolean equals(Object obj) {
54 if (obj == null)
55 return false;
56 if (obj == this)
57 return true;
58 if (!(obj instanceof VideoCodecInfo))
59 return false;
60
61 VideoCodecInfo otherInfo = (VideoCodecInfo) obj;
62 return name.equalsIgnoreCase(otherInfo.name) && params.equals(otherInfo.params);
63 }
64
65 @Override
66 public int hashCode() {
67 Object[] values = {name.toUpperCase(Locale.ROOT), params};
68 return Arrays.hashCode(values);
69 }
Magnus Jedvert9060eb12017-12-12 12:52:54 +010070
71 @CalledByNative
72 String getName() {
73 return name;
74 }
75
76 @CalledByNative
77 Map getParams() {
78 return params;
79 }
Sami Kalliomäkie2410e92017-06-02 14:46:12 +020080}