Sami Kalliomäki | e2410e9 | 2017-06-02 14:46:12 +0200 | [diff] [blame] | 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 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 13 | import javax.annotation.Nullable; |
Anders Carlsson | 1e1dd77 | 2017-11-16 15:44:14 +0100 | [diff] [blame] | 14 | import java.util.Arrays; |
| 15 | import java.util.Locale; |
Sami Kalliomäki | e2410e9 | 2017-06-02 14:46:12 +0200 | [diff] [blame] | 16 | import java.util.Map; |
| 17 | |
| 18 | /** |
| 19 | * Represent a video codec as encoded in SDP. |
| 20 | */ |
| 21 | public class VideoCodecInfo { |
sakal | c36daec | 2017-09-11 06:53:27 -0700 | [diff] [blame] | 22 | // Keys for H264 VideoCodecInfo properties. |
| 23 | public static final String H264_FMTP_PROFILE_LEVEL_ID = "profile-level-id"; |
| 24 | public static final String H264_FMTP_LEVEL_ASYMMETRY_ALLOWED = "level-asymmetry-allowed"; |
| 25 | public static final String H264_FMTP_PACKETIZATION_MODE = "packetization-mode"; |
| 26 | |
Sami Kalliomäki | 828cf24 | 2017-10-30 13:49:31 +0100 | [diff] [blame] | 27 | public static final String H264_PROFILE_CONSTRAINED_BASELINE = "42e0"; |
sakal | c36daec | 2017-09-11 06:53:27 -0700 | [diff] [blame] | 28 | public static final String H264_PROFILE_CONSTRAINED_HIGH = "640c"; |
| 29 | public static final String H264_LEVEL_3_1 = "1f"; // 31 in hex. |
| 30 | public static final String H264_CONSTRAINED_HIGH_3_1 = |
| 31 | H264_PROFILE_CONSTRAINED_HIGH + H264_LEVEL_3_1; |
| 32 | public static final String H264_CONSTRAINED_BASELINE_3_1 = |
| 33 | H264_PROFILE_CONSTRAINED_BASELINE + H264_LEVEL_3_1; |
| 34 | |
Sami Kalliomäki | e2410e9 | 2017-06-02 14:46:12 +0200 | [diff] [blame] | 35 | public final String name; |
| 36 | public final Map<String, String> params; |
Anders Carlsson | dc1b9f1 | 2017-11-10 13:15:04 +0100 | [diff] [blame] | 37 | @Deprecated public final int payload; |
Sami Kalliomäki | e2410e9 | 2017-06-02 14:46:12 +0200 | [diff] [blame] | 38 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 39 | @CalledByNative |
Anders Carlsson | dc1b9f1 | 2017-11-10 13:15:04 +0100 | [diff] [blame] | 40 | public VideoCodecInfo(String name, Map<String, String> params) { |
| 41 | this.payload = 0; |
| 42 | this.name = name; |
| 43 | this.params = params; |
| 44 | } |
| 45 | |
| 46 | @Deprecated |
Sami Kalliomäki | e2410e9 | 2017-06-02 14:46:12 +0200 | [diff] [blame] | 47 | public VideoCodecInfo(int payload, String name, Map<String, String> params) { |
| 48 | this.payload = payload; |
| 49 | this.name = name; |
| 50 | this.params = params; |
| 51 | } |
Anders Carlsson | 1e1dd77 | 2017-11-16 15:44:14 +0100 | [diff] [blame] | 52 | |
| 53 | @Override |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 54 | public boolean equals(@Nullable Object obj) { |
Anders Carlsson | 1e1dd77 | 2017-11-16 15:44:14 +0100 | [diff] [blame] | 55 | if (obj == null) |
| 56 | return false; |
| 57 | if (obj == this) |
| 58 | return true; |
| 59 | if (!(obj instanceof VideoCodecInfo)) |
| 60 | return false; |
| 61 | |
| 62 | VideoCodecInfo otherInfo = (VideoCodecInfo) obj; |
| 63 | return name.equalsIgnoreCase(otherInfo.name) && params.equals(otherInfo.params); |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public int hashCode() { |
| 68 | Object[] values = {name.toUpperCase(Locale.ROOT), params}; |
| 69 | return Arrays.hashCode(values); |
| 70 | } |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 71 | |
| 72 | @CalledByNative |
| 73 | String getName() { |
| 74 | return name; |
| 75 | } |
| 76 | |
| 77 | @CalledByNative |
| 78 | Map getParams() { |
| 79 | return params; |
| 80 | } |
Sami Kalliomäki | e2410e9 | 2017-06-02 14:46:12 +0200 | [diff] [blame] | 81 | } |