henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 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. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 11 | package org.webrtc; |
| 12 | |
sakal | 037b93a | 2017-01-16 04:57:32 -0800 | [diff] [blame] | 13 | import java.util.Locale; |
| 14 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 15 | /** |
| 16 | * Description of an RFC 4566 Session. |
| 17 | * SDPs are passed as serialized Strings in Java-land and are materialized |
| 18 | * to SessionDescriptionInterface as appropriate in the JNI layer. |
| 19 | */ |
| 20 | public class SessionDescription { |
| 21 | /** Java-land enum version of SessionDescriptionInterface's type() string. */ |
| 22 | public static enum Type { |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 23 | OFFER, |
| 24 | PRANSWER, |
| 25 | ANSWER; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 26 | |
| 27 | public String canonicalForm() { |
sakal | 037b93a | 2017-01-16 04:57:32 -0800 | [diff] [blame] | 28 | return name().toLowerCase(Locale.US); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 29 | } |
| 30 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame^] | 31 | @CalledByNative("Type") |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 32 | public static Type fromCanonicalForm(String canonical) { |
sakal | 037b93a | 2017-01-16 04:57:32 -0800 | [diff] [blame] | 33 | return Type.valueOf(Type.class, canonical.toUpperCase(Locale.US)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 34 | } |
| 35 | } |
| 36 | |
| 37 | public final Type type; |
| 38 | public final String description; |
| 39 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame^] | 40 | @CalledByNative |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 41 | public SessionDescription(Type type, String description) { |
| 42 | this.type = type; |
| 43 | this.description = description; |
| 44 | } |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame^] | 45 | |
| 46 | @CalledByNative |
| 47 | String getDescription() { |
| 48 | return description; |
| 49 | } |
| 50 | |
| 51 | @CalledByNative |
| 52 | String getTypeInCanonicalForm() { |
| 53 | return type.canonicalForm(); |
| 54 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 55 | } |