1 /*
2  *  Copyright 2013 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.Locale;
14 
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 {
23     OFFER,
24     PRANSWER,
25     ANSWER;
26 
canonicalForm()27     public String canonicalForm() {
28       return name().toLowerCase(Locale.US);
29     }
30 
31     @CalledByNative("Type")
fromCanonicalForm(String canonical)32     public static Type fromCanonicalForm(String canonical) {
33       return Type.valueOf(Type.class, canonical.toUpperCase(Locale.US));
34     }
35   }
36 
37   public final Type type;
38   public final String description;
39 
40   @CalledByNative
SessionDescription(Type type, String description)41   public SessionDescription(Type type, String description) {
42     this.type = type;
43     this.description = description;
44   }
45 
46   @CalledByNative
getDescription()47   String getDescription() {
48     return description;
49   }
50 
51   @CalledByNative
getTypeInCanonicalForm()52   String getTypeInCanonicalForm() {
53     return type.canonicalForm();
54   }
55 }
56