2 * Copyright (C) 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package android.media;
18 import android.media.MediaDrm;
20 import java.util.Arrays;
21 import java.util.HashMap;
23 import java.util.UUID;
26 * Encapsulates initialization data required by a {@link MediaDrm} instance.
28 public abstract class DrmInitData {
31 * Retrieves initialization data for a given DRM scheme, specified by its UUID.
33 * @param schemeUuid The DRM scheme's UUID.
34 * @return The initialization data for the scheme, or null if the scheme is not supported.
36 public abstract SchemeInitData get(UUID schemeUuid);
39 * Scheme initialization data.
41 public static final class SchemeInitData {
44 * The mimeType of {@link #data}.
46 public final String mimeType;
48 * The initialization data.
50 public final byte[] data;
53 * @param mimeType The mimeType of the initialization data.
54 * @param data The initialization data.
58 public SchemeInitData(String mimeType, byte[] data) {
59 this.mimeType = mimeType;
64 public boolean equals(Object obj) {
65 if (!(obj instanceof SchemeInitData)) {
72 SchemeInitData other = (SchemeInitData) obj;
73 return mimeType.equals(other.mimeType) && Arrays.equals(data, other.data);
77 public int hashCode() {
78 return mimeType.hashCode() + 31 * Arrays.hashCode(data);