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