1 /*
2  * Copyright (C) 2009 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 
17 #ifndef MEDIA_ERRORS_H_
18 
19 #define MEDIA_ERRORS_H_
20 
21 #include <utils/Errors.h>
22 
23 namespace android {
24 
25 enum {
26     // status_t map for errors in the media framework
27     // OK or NO_ERROR or 0 represents no error.
28 
29     // See system/core/include/utils/Errors.h
30     // System standard errors from -1 through (possibly) -133
31     //
32     // Errors with special meanings and side effects.
33     // INVALID_OPERATION:  Operation attempted in an illegal state (will try to signal to app).
34     // DEAD_OBJECT:        Signal from CodecBase to MediaCodec that MediaServer has died.
35     // NAME_NOT_FOUND:     Signal from CodecBase to MediaCodec that the component was not found.
36 
37     // Media errors
38     MEDIA_ERROR_BASE        = -1000,
39 
40     ERROR_ALREADY_CONNECTED = MEDIA_ERROR_BASE,
41     ERROR_NOT_CONNECTED     = MEDIA_ERROR_BASE - 1,
42     ERROR_UNKNOWN_HOST      = MEDIA_ERROR_BASE - 2,
43     ERROR_CANNOT_CONNECT    = MEDIA_ERROR_BASE - 3,
44     ERROR_IO                = MEDIA_ERROR_BASE - 4,
45     ERROR_CONNECTION_LOST   = MEDIA_ERROR_BASE - 5,
46     ERROR_MALFORMED         = MEDIA_ERROR_BASE - 7,
47     ERROR_OUT_OF_RANGE      = MEDIA_ERROR_BASE - 8,
48     ERROR_BUFFER_TOO_SMALL  = MEDIA_ERROR_BASE - 9,
49     ERROR_UNSUPPORTED       = MEDIA_ERROR_BASE - 10,
50     ERROR_END_OF_STREAM     = MEDIA_ERROR_BASE - 11,
51 
52     // Not technically an error.
53     INFO_FORMAT_CHANGED    = MEDIA_ERROR_BASE - 12,
54     INFO_DISCONTINUITY     = MEDIA_ERROR_BASE - 13,
55     INFO_OUTPUT_BUFFERS_CHANGED = MEDIA_ERROR_BASE - 14,
56 
57     // The following constant values should be in sync with
58     // drm/drm_framework_common.h
59     DRM_ERROR_BASE = -2000,
60 
61     ERROR_DRM_UNKNOWN                        = DRM_ERROR_BASE,
62     ERROR_DRM_NO_LICENSE                     = DRM_ERROR_BASE - 1,
63     ERROR_DRM_LICENSE_EXPIRED                = DRM_ERROR_BASE - 2,
64     ERROR_DRM_SESSION_NOT_OPENED             = DRM_ERROR_BASE - 3,
65     ERROR_DRM_DECRYPT_UNIT_NOT_INITIALIZED   = DRM_ERROR_BASE - 4,
66     ERROR_DRM_DECRYPT                        = DRM_ERROR_BASE - 5,
67     ERROR_DRM_CANNOT_HANDLE                  = DRM_ERROR_BASE - 6,
68     ERROR_DRM_TAMPER_DETECTED                = DRM_ERROR_BASE - 7,
69     ERROR_DRM_NOT_PROVISIONED                = DRM_ERROR_BASE - 8,
70     ERROR_DRM_DEVICE_REVOKED                 = DRM_ERROR_BASE - 9,
71     ERROR_DRM_RESOURCE_BUSY                  = DRM_ERROR_BASE - 10,
72     ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION = DRM_ERROR_BASE - 11,
73     ERROR_DRM_LAST_USED_ERRORCODE            = DRM_ERROR_BASE - 11,
74 
75     ERROR_DRM_VENDOR_MAX                     = DRM_ERROR_BASE - 500,
76     ERROR_DRM_VENDOR_MIN                     = DRM_ERROR_BASE - 999,
77 
78     // Heartbeat Error Codes
79     HEARTBEAT_ERROR_BASE = -3000,
80     ERROR_HEARTBEAT_TERMINATE_REQUESTED                     = HEARTBEAT_ERROR_BASE,
81 
82     // NDK Error codes
83     // frameworks/av/include/ndk/NdkMediaError.h
84     // from -10000 (0xFFFFD8F0 - 0xFFFFD8EC)
85     // from -20000 (0xFFFFB1E0 - 0xFFFFB1D7)
86 
87     // Codec errors are permitted from 0x80001000 through 0x9000FFFF
88     ERROR_CODEC_MAX    = (signed)0x9000FFFF,
89     ERROR_CODEC_MIN    = (signed)0x80001000,
90 
91     // System unknown errors from 0x80000000 - 0x80000007 (INT32_MIN + 7)
92     // See system/core/include/utils/Errors.h
93 };
94 
95 // action codes for MediaCodecs that tell the upper layer and application
96 // the severity of any error.
97 enum ActionCode {
98     ACTION_CODE_FATAL,
99     ACTION_CODE_TRANSIENT,
100     ACTION_CODE_RECOVERABLE,
101 };
102 
103 // returns true if err is a recognized DRM error code
isCryptoError(status_t err)104 static inline bool isCryptoError(status_t err) {
105     return (ERROR_DRM_LAST_USED_ERRORCODE <= err && err <= ERROR_DRM_UNKNOWN)
106             || (ERROR_DRM_VENDOR_MIN <= err && err <= ERROR_DRM_VENDOR_MAX);
107 }
108 
109 }  // namespace android
110 
111 #endif  // MEDIA_ERRORS_H_
112