1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.mozilla.thirdparty.com.google.android.exoplayer2.drm; 17 18 import androidx.annotation.IntDef; 19 import java.lang.annotation.Documented; 20 import java.lang.annotation.Retention; 21 import java.lang.annotation.RetentionPolicy; 22 23 /** 24 * Thrown when the requested DRM scheme is not supported. 25 */ 26 public final class UnsupportedDrmException extends Exception { 27 28 /** 29 * The reason for the exception. One of {@link #REASON_UNSUPPORTED_SCHEME} or {@link 30 * #REASON_INSTANTIATION_ERROR}. 31 */ 32 @Documented 33 @Retention(RetentionPolicy.SOURCE) 34 @IntDef({REASON_UNSUPPORTED_SCHEME, REASON_INSTANTIATION_ERROR}) 35 public @interface Reason {} 36 /** 37 * The requested DRM scheme is unsupported by the device. 38 */ 39 public static final int REASON_UNSUPPORTED_SCHEME = 1; 40 /** 41 * There device advertises support for the requested DRM scheme, but there was an error 42 * instantiating it. The cause can be retrieved using {@link #getCause()}. 43 */ 44 public static final int REASON_INSTANTIATION_ERROR = 2; 45 46 /** 47 * Either {@link #REASON_UNSUPPORTED_SCHEME} or {@link #REASON_INSTANTIATION_ERROR}. 48 */ 49 @Reason public final int reason; 50 51 /** 52 * @param reason {@link #REASON_UNSUPPORTED_SCHEME} or {@link #REASON_INSTANTIATION_ERROR}. 53 */ UnsupportedDrmException(@eason int reason)54 public UnsupportedDrmException(@Reason int reason) { 55 this.reason = reason; 56 } 57 58 /** 59 * @param reason {@link #REASON_UNSUPPORTED_SCHEME} or {@link #REASON_INSTANTIATION_ERROR}. 60 * @param cause The cause of this exception. 61 */ UnsupportedDrmException(@eason int reason, Exception cause)62 public UnsupportedDrmException(@Reason int reason, Exception cause) { 63 super(cause); 64 this.reason = reason; 65 } 66 67 } 68