• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 android.media;
17 
18 import android.media.MediaDrm;
19 
20 import java.util.Arrays;
21 import java.util.HashMap;
22 import java.util.Map;
23 import java.util.UUID;
24 
25 /**
26  * Encapsulates initialization data required by a {@link MediaDrm} instance.
27  */
28 public abstract class DrmInitData {
29 
30     /**
31      * Prevent public constuctor access
32      */
DrmInitData()33     /* package private */ DrmInitData() {
34     }
35 
36     /**
37      * Retrieves initialization data for a given DRM scheme, specified by its UUID.
38      *
39      * @param schemeUuid The DRM scheme's UUID.
40      * @return The initialization data for the scheme, or null if the scheme is not supported.
41      */
get(UUID schemeUuid)42     public abstract SchemeInitData get(UUID schemeUuid);
43 
44     /**
45      * Scheme initialization data.
46      */
47     public static final class SchemeInitData {
48 
49         /**
50          * The mimeType of {@link #data}.
51          */
52         public final String mimeType;
53         /**
54          * The initialization data.
55          */
56         public final byte[] data;
57 
58         /**
59          * @param mimeType The mimeType of the initialization data.
60          * @param data The initialization data.
61          *
62          * @hide
63          */
SchemeInitData(String mimeType, byte[] data)64         public SchemeInitData(String mimeType, byte[] data) {
65             this.mimeType = mimeType;
66             this.data = data;
67         }
68 
69         @Override
equals(Object obj)70         public boolean equals(Object obj) {
71             if (!(obj instanceof SchemeInitData)) {
72                 return false;
73             }
74             if (obj == this) {
75                 return true;
76             }
77 
78             SchemeInitData other = (SchemeInitData) obj;
79             return mimeType.equals(other.mimeType) && Arrays.equals(data, other.data);
80         }
81 
82         @Override
hashCode()83         public int hashCode() {
84             return mimeType.hashCode() + 31 * Arrays.hashCode(data);
85         }
86 
87     }
88 
89 }
90