diff options
Diffstat (limited to '9/platforms/android-21/arch-mips/usr/include/media')
7 files changed, 1202 insertions, 0 deletions
diff --git a/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaCodec.h b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaCodec.h new file mode 100644 index 0000000..c07f4c9 --- /dev/null +++ b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaCodec.h @@ -0,0 +1,235 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * This file defines an NDK API. + * Do not remove methods. + * Do not change method signatures. + * Do not change the value of constants. + * Do not change the size of any of the classes defined in here. + * Do not reference types that are not part of the NDK. + * Do not #include files that aren't part of the NDK. + */ + +#ifndef _NDK_MEDIA_CODEC_H +#define _NDK_MEDIA_CODEC_H + +#include <android/native_window.h> + +#include "NdkMediaCrypto.h" +#include "NdkMediaError.h" +#include "NdkMediaFormat.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +struct AMediaCodec; +typedef struct AMediaCodec AMediaCodec; + +struct AMediaCodecBufferInfo { + int32_t offset; + int32_t size; + int64_t presentationTimeUs; + uint32_t flags; +}; +typedef struct AMediaCodecBufferInfo AMediaCodecBufferInfo; +typedef struct AMediaCodecCryptoInfo AMediaCodecCryptoInfo; + +enum { + AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM = 4, + AMEDIACODEC_CONFIGURE_FLAG_ENCODE = 1, + AMEDIACODEC_INFO_OUTPUT_BUFFERS_CHANGED = -3, + AMEDIACODEC_INFO_OUTPUT_FORMAT_CHANGED = -2, + AMEDIACODEC_INFO_TRY_AGAIN_LATER = -1 +}; + +/** + * Create codec by name. Use this if you know the exact codec you want to use. + * When configuring, you will need to specify whether to use the codec as an + * encoder or decoder. + */ +AMediaCodec* AMediaCodec_createCodecByName(const char *name); + +/** + * Create codec by mime type. Most applications will use this, specifying a + * mime type obtained from media extractor. + */ +AMediaCodec* AMediaCodec_createDecoderByType(const char *mime_type); + +/** + * Create encoder by name. + */ +AMediaCodec* AMediaCodec_createEncoderByType(const char *mime_type); + +/** + * delete the codec and free its resources + */ +media_status_t AMediaCodec_delete(AMediaCodec*); + +/** + * Configure the codec. For decoding you would typically get the format from an extractor. + */ +media_status_t AMediaCodec_configure( + AMediaCodec*, + const AMediaFormat* format, + ANativeWindow* surface, + AMediaCrypto *crypto, + uint32_t flags); + +/** + * Start the codec. A codec must be configured before it can be started, and must be started + * before buffers can be sent to it. + */ +media_status_t AMediaCodec_start(AMediaCodec*); + +/** + * Stop the codec. + */ +media_status_t AMediaCodec_stop(AMediaCodec*); + +/* + * Flush the codec's input and output. All indices previously returned from calls to + * AMediaCodec_dequeueInputBuffer and AMediaCodec_dequeueOutputBuffer become invalid. + */ +media_status_t AMediaCodec_flush(AMediaCodec*); + +/** + * Get an input buffer. The specified buffer index must have been previously obtained from + * dequeueInputBuffer, and not yet queued. + */ +uint8_t* AMediaCodec_getInputBuffer(AMediaCodec*, size_t idx, size_t *out_size); + +/** + * Get an output buffer. The specified buffer index must have been previously obtained from + * dequeueOutputBuffer, and not yet queued. + */ +uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec*, size_t idx, size_t *out_size); + +/** + * Get the index of the next available input buffer. An app will typically use this with + * getInputBuffer() to get a pointer to the buffer, then copy the data to be encoded or decoded + * into the buffer before passing it to the codec. + */ +ssize_t AMediaCodec_dequeueInputBuffer(AMediaCodec*, int64_t timeoutUs); + +/** + * Send the specified buffer to the codec for processing. + */ +media_status_t AMediaCodec_queueInputBuffer(AMediaCodec*, + size_t idx, off_t offset, size_t size, uint64_t time, uint32_t flags); + +/** + * Send the specified buffer to the codec for processing. + */ +media_status_t AMediaCodec_queueSecureInputBuffer(AMediaCodec*, + size_t idx, off_t offset, AMediaCodecCryptoInfo*, uint64_t time, uint32_t flags); + +/** + * Get the index of the next available buffer of processed data. + */ +ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec*, AMediaCodecBufferInfo *info, int64_t timeoutUs); +AMediaFormat* AMediaCodec_getOutputFormat(AMediaCodec*); + +/** + * If you are done with a buffer, use this call to return the buffer to + * the codec. If you previously specified a surface when configuring this + * video decoder you can optionally render the buffer. + */ +media_status_t AMediaCodec_releaseOutputBuffer(AMediaCodec*, size_t idx, bool render); + +/** + * If you are done with a buffer, use this call to update its surface timestamp + * and return it to the codec to render it on the output surface. If you + * have not specified an output surface when configuring this video codec, + * this call will simply return the buffer to the codec. + * + * For more details, see the Java documentation for MediaCodec.releaseOutputBuffer. + */ +media_status_t AMediaCodec_releaseOutputBufferAtTime( + AMediaCodec *mData, size_t idx, int64_t timestampNs); + + +typedef enum { + AMEDIACODECRYPTOINFO_MODE_CLEAR = 0, + AMEDIACODECRYPTOINFO_MODE_AES_CTR = 1 +} cryptoinfo_mode_t; + +/** + * Create an AMediaCodecCryptoInfo from scratch. Use this if you need to use custom + * crypto info, rather than one obtained from AMediaExtractor. + * + * AMediaCodecCryptoInfo describes the structure of an (at least + * partially) encrypted input sample. + * A buffer's data is considered to be partitioned into "subsamples", + * each subsample starts with a (potentially empty) run of plain, + * unencrypted bytes followed by a (also potentially empty) run of + * encrypted bytes. + * numBytesOfClearData can be null to indicate that all data is encrypted. + * This information encapsulates per-sample metadata as outlined in + * ISO/IEC FDIS 23001-7:2011 "Common encryption in ISO base media file format files". + */ +AMediaCodecCryptoInfo *AMediaCodecCryptoInfo_new( + int numsubsamples, + uint8_t key[16], + uint8_t iv[16], + cryptoinfo_mode_t mode, + size_t *clearbytes, + size_t *encryptedbytes); + +/** + * delete an AMediaCodecCryptoInfo created previously with AMediaCodecCryptoInfo_new, or + * obtained from AMediaExtractor + */ +media_status_t AMediaCodecCryptoInfo_delete(AMediaCodecCryptoInfo*); + +/** + * The number of subsamples that make up the buffer's contents. + */ +size_t AMediaCodecCryptoInfo_getNumSubSamples(AMediaCodecCryptoInfo*); + +/** + * A 16-byte opaque key + */ +media_status_t AMediaCodecCryptoInfo_getKey(AMediaCodecCryptoInfo*, uint8_t *dst); + +/** + * A 16-byte initialization vector + */ +media_status_t AMediaCodecCryptoInfo_getIV(AMediaCodecCryptoInfo*, uint8_t *dst); + +/** + * The type of encryption that has been applied, + * one of AMEDIACODECRYPTOINFO_MODE_CLEAR or AMEDIACODECRYPTOINFO_MODE_AES_CTR. + */ +cryptoinfo_mode_t AMediaCodecCryptoInfo_getMode(AMediaCodecCryptoInfo*); + +/** + * The number of leading unencrypted bytes in each subsample. + */ +media_status_t AMediaCodecCryptoInfo_getClearBytes(AMediaCodecCryptoInfo*, size_t *dst); + +/** + * The number of trailing encrypted bytes in each subsample. + */ +media_status_t AMediaCodecCryptoInfo_getEncryptedBytes(AMediaCodecCryptoInfo*, size_t *dst); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif //_NDK_MEDIA_CODEC_H diff --git a/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaCrypto.h b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaCrypto.h new file mode 100644 index 0000000..90374c5 --- /dev/null +++ b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaCrypto.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/* + * This file defines an NDK API. + * Do not remove methods. + * Do not change method signatures. + * Do not change the value of constants. + * Do not change the size of any of the classes defined in here. + * Do not reference types that are not part of the NDK. + * Do not #include files that aren't part of the NDK. + */ + +#ifndef _NDK_MEDIA_CRYPTO_H +#define _NDK_MEDIA_CRYPTO_H + +#include <sys/types.h> +#include <stdbool.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct AMediaCrypto; +typedef struct AMediaCrypto AMediaCrypto; + +typedef uint8_t AMediaUUID[16]; + +bool AMediaCrypto_isCryptoSchemeSupported(const AMediaUUID uuid); + +bool AMediaCrypto_requiresSecureDecoderComponent(const char *mime); + +AMediaCrypto* AMediaCrypto_new(const AMediaUUID uuid, const void *initData, size_t initDataSize); + +void AMediaCrypto_delete(AMediaCrypto* crypto); + + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _NDK_MEDIA_CRYPTO_H diff --git a/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaDrm.h b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaDrm.h new file mode 100644 index 0000000..10afdd9 --- /dev/null +++ b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaDrm.h @@ -0,0 +1,455 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * This file defines an NDK API. + * Do not remove methods. + * Do not change method signatures. + * Do not change the value of constants. + * Do not change the size of any of the classes defined in here. + * Do not reference types that are not part of the NDK. + * Do not #include files that aren't part of the NDK. + */ + +#ifndef _NDK_MEDIA_DRM_H +#define _NDK_MEDIA_DRM_H + +#include "NdkMediaError.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> +#include <stdbool.h> + +struct AMediaDrm; +typedef struct AMediaDrm AMediaDrm; + +typedef struct { + const uint8_t *ptr; + size_t length; +} AMediaDrmByteArray; + +typedef AMediaDrmByteArray AMediaDrmSessionId; +typedef AMediaDrmByteArray AMediaDrmScope; +typedef AMediaDrmByteArray AMediaDrmKeySetId; +typedef AMediaDrmByteArray AMediaDrmSecureStop; + + +typedef enum AMediaDrmEventType { + /** + * This event type indicates that the app needs to request a certificate from + * the provisioning server. The request message data is obtained using + * AMediaDrm_getProvisionRequest. + */ + EVENT_PROVISION_REQUIRED = 1, + + /** + * This event type indicates that the app needs to request keys from a license + * server. The request message data is obtained using AMediaDrm_getKeyRequest. + */ + EVENT_KEY_REQUIRED = 2, + + /** + * This event type indicates that the licensed usage duration for keys in a session + * has expired. The keys are no longer valid. + */ + EVENT_KEY_EXPIRED = 3, + + /** + * This event may indicate some specific vendor-defined condition, see your + * DRM provider documentation for details + */ + EVENT_VENDOR_DEFINED = 4 +} AMediaDrmEventType; + +typedef void (*AMediaDrmEventListener)(AMediaDrm *, const AMediaDrmSessionId *sessionId, + AMediaDrmEventType eventType, int extra, const uint8_t *data, size_t dataSize); + + +/** + * Query if the given scheme identified by its UUID is supported on this device, and + * whether the drm plugin is able to handle the media container format specified by mimeType. + * + * uuid identifies the universal unique ID of the crypto scheme. uuid must be 16 bytes. + * mimeType is the MIME type of the media container, e.g. "video/mp4". If mimeType + * is not known or required, it can be provided as NULL. + */ +bool AMediaDrm_isCryptoSchemeSupported(const uint8_t *uuid, const char *mimeType); + +/** + * Create a MediaDrm instance from a UUID + * uuid identifies the universal unique ID of the crypto scheme. uuid must be 16 bytes. + */ +AMediaDrm* AMediaDrm_createByUUID(const uint8_t *uuid); + +/** + * Release a MediaDrm object + */ +void AMediaDrm_release(AMediaDrm *); + +/** + * Register a callback to be invoked when an event occurs + * + * listener is the callback that will be invoked on event + */ +media_status_t AMediaDrm_setOnEventListener(AMediaDrm *, AMediaDrmEventListener listener); + +/** + * Open a new session with the MediaDrm object. A session ID is returned. + * + * returns MEDIADRM_NOT_PROVISIONED_ERROR if provisioning is needed + * returns MEDIADRM_RESOURCE_BUSY_ERROR if required resources are in use + */ +media_status_t AMediaDrm_openSession(AMediaDrm *, AMediaDrmSessionId *sessionId); + +/** + * Close a session on the MediaDrm object that was previously opened + * with AMediaDrm_openSession. + */ +media_status_t AMediaDrm_closeSession(AMediaDrm *, const AMediaDrmSessionId *sessionId); + +typedef enum AMediaDrmKeyType { + /** + * This key request type species that the keys will be for online use, they will + * not be saved to the device for subsequent use when the device is not connected + * to a network. + */ + KEY_TYPE_STREAMING = 1, + + /** + * This key request type specifies that the keys will be for offline use, they + * will be saved to the device for use when the device is not connected to a network. + */ + KEY_TYPE_OFFLINE = 2, + + /** + * This key request type specifies that previously saved offline keys should be released. + */ + KEY_TYPE_RELEASE = 3 +} AMediaDrmKeyType; + +/** + * Data type containing {key, value} pair + */ +typedef struct AMediaDrmKeyValuePair { + const char *mKey; + const char *mValue; +} AMediaDrmKeyValue; + +/** + * A key request/response exchange occurs between the app and a license server + * to obtain or release keys used to decrypt encrypted content. + * AMediaDrm_getKeyRequest is used to obtain an opaque key request byte array that + * is delivered to the license server. The opaque key request byte array is + * returned in KeyRequest.data. The recommended URL to deliver the key request to + * is returned in KeyRequest.defaultUrl. + * + * After the app has received the key request response from the server, + * it should deliver to the response to the DRM engine plugin using the method + * AMediaDrm_provideKeyResponse. + * + * scope may be a sessionId or a keySetId, depending on the specified keyType. + * When the keyType is KEY_TYPE_STREAMING or KEY_TYPE_OFFLINE, scope should be set + * to the sessionId the keys will be provided to. When the keyType is + * KEY_TYPE_RELEASE, scope should be set to the keySetId of the keys being released. + * Releasing keys from a device invalidates them for all sessions. + * + * init container-specific data, its meaning is interpreted based on the mime type + * provided in the mimeType parameter. It could contain, for example, the content + * ID, key ID or other data obtained from the content metadata that is required in + * generating the key request. init may be null when keyType is KEY_TYPE_RELEASE. + * + * initSize is the number of bytes of initData + * + * mimeType identifies the mime type of the content. + * + * keyType specifes the type of the request. The request may be to acquire keys for + * streaming or offline content, or to release previously acquired keys, which are + * identified by a keySetId. + * + * optionalParameters are included in the key request message to allow a client + * application to provide additional message parameters to the server. + * + * numOptionalParameters indicates the number of optional parameters provided + * by the caller + * + * On exit: + * 1. The keyRequest pointer will reference the opaque key request data. It + * will reside in memory owned by the AMediaDrm object, and will remain + * accessible until the next call to AMediaDrm_getKeyRequest or until the + * MediaDrm object is released. + * 2. keyRequestSize will be set to the size of the request + * + * returns MEDIADRM_NOT_PROVISIONED_ERROR if reprovisioning is needed, due to a + * problem with the device certificate. +*/ +media_status_t AMediaDrm_getKeyRequest(AMediaDrm *, const AMediaDrmScope *scope, + const uint8_t *init, size_t initSize, const char *mimeType, AMediaDrmKeyType keyType, + const AMediaDrmKeyValue *optionalParameters, size_t numOptionalParameters, + const uint8_t **keyRequest, size_t *keyRequestSize); + +/** + * A key response is received from the license server by the app, then it is + * provided to the DRM engine plugin using provideKeyResponse. When the + * response is for an offline key request, a keySetId is returned that can be + * used to later restore the keys to a new session with AMediaDrm_restoreKeys. + * When the response is for a streaming or release request, a null keySetId is + * returned. + * + * scope may be a sessionId or keySetId depending on the type of the + * response. Scope should be set to the sessionId when the response is for either + * streaming or offline key requests. Scope should be set to the keySetId when + * the response is for a release request. + * + * response points to the opaque response from the server + * responseSize should be set to the size of the response in bytes + */ + +media_status_t AMediaDrm_provideKeyResponse(AMediaDrm *, const AMediaDrmScope *scope, + const uint8_t *response, size_t responseSize, AMediaDrmKeySetId *keySetId); + +/** + * Restore persisted offline keys into a new session. keySetId identifies the + * keys to load, obtained from a prior call to AMediaDrm_provideKeyResponse. + * + * sessionId is the session ID for the DRM session + * keySetId identifies the saved key set to restore + */ +media_status_t AMediaDrm_restoreKeys(AMediaDrm *, const AMediaDrmSessionId *sessionId, + const AMediaDrmKeySetId *keySetId); + +/** + * Remove the current keys from a session. + * + * keySetId identifies keys to remove + */ +media_status_t AMediaDrm_removeKeys(AMediaDrm *, const AMediaDrmSessionId *keySetId); + +/** + * Request an informative description of the key status for the session. The status is + * in the form of {key, value} pairs. Since DRM license policies vary by vendor, + * the specific status field names are determined by each DRM vendor. Refer to your + * DRM provider documentation for definitions of the field names for a particular + * DRM engine plugin. + * + * On entry, numPairs should be set by the caller to the maximum number of pairs + * that can be returned (the size of the array). On exit, numPairs will be set + * to the number of entries written to the array. If the number of {key, value} pairs + * to be returned is greater than *numPairs, MEDIADRM_SHORT_BUFFER will be returned + * and numPairs will be set to the number of pairs available. + */ +media_status_t AMediaDrm_queryKeyStatus(AMediaDrm *, const AMediaDrmSessionId *sessionId, + AMediaDrmKeyValue *keyValuePairs, size_t *numPairs); + + +/** + * A provision request/response exchange occurs between the app and a provisioning + * server to retrieve a device certificate. If provisionining is required, the + * EVENT_PROVISION_REQUIRED event will be sent to the event handler. + * getProvisionRequest is used to obtain the opaque provision request byte array that + * should be delivered to the provisioning server. + * On exit: + * 1. The provision request data will be referenced by provisionRequest, in + * memory owned by the AMediaDrm object. It will remain accessible until the + * next call to getProvisionRequest. + * 2. provisionRequestSize will be set to the size of the request data. + * 3. serverUrl will reference a NULL terminated string containing the URL + * the provisioning request should be sent to. It will remain accessible until + * the next call to getProvisionRequest. + */ +media_status_t AMediaDrm_getProvisionRequest(AMediaDrm *, const uint8_t **provisionRequest, + size_t *provisionRequestSize, const char **serverUrl); + + +/** + * After a provision response is received by the app, it is provided to the DRM + * engine plugin using this method. + * + * response is the opaque provisioning response byte array to provide to the + * DRM engine plugin. + * responseSize is the length of the provisioning response in bytes. + * + * returns MEDIADRM_DEVICE_REVOKED_ERROR if the response indicates that the + * server rejected the request + */ +media_status_t AMediaDrm_provideProvisionResponse(AMediaDrm *, + const uint8_t *response, size_t responseSize); + + +/** + * A means of enforcing limits on the number of concurrent streams per subscriber + * across devices is provided via SecureStop. This is achieved by securely + * monitoring the lifetime of sessions. + * + * Information from the server related to the current playback session is written + * to persistent storage on the device when each MediaCrypto object is created. + * + * In the normal case, playback will be completed, the session destroyed and the + * Secure Stops will be queried. The app queries secure stops and forwards the + * secure stop message to the server which verifies the signature and notifies the + * server side database that the session destruction has been confirmed. The persisted + * record on the client is only removed after positive confirmation that the server + * received the message using releaseSecureStops(). + * + * numSecureStops is set by the caller to the maximum number of secure stops to + * return. On exit, *numSecureStops will be set to the number actually returned. + * If *numSecureStops is too small for the number of secure stops available, + * MEDIADRM_SHORT_BUFFER will be returned and *numSecureStops will be set to the + * number required. + */ +media_status_t AMediaDrm_getSecureStops(AMediaDrm *, + AMediaDrmSecureStop *secureStops, size_t *numSecureStops); + +/** + * Process the SecureStop server response message ssRelease. After authenticating + * the message, remove the SecureStops identified in the response. + * + * ssRelease is the server response indicating which secure stops to release + */ +media_status_t AMediaDrm_releaseSecureStops(AMediaDrm *, + const AMediaDrmSecureStop *ssRelease); + +/** + * String property name: identifies the maker of the DRM engine plugin + */ +const char *PROPERTY_VENDOR = "vendor"; + +/** + * String property name: identifies the version of the DRM engine plugin + */ +const char *PROPERTY_VERSION = "version"; + +/** + * String property name: describes the DRM engine plugin + */ +const char *PROPERTY_DESCRIPTION = "description"; + +/** + * String property name: a comma-separated list of cipher and mac algorithms + * supported by CryptoSession. The list may be empty if the DRM engine + * plugin does not support CryptoSession operations. + */ +const char *PROPERTY_ALGORITHMS = "algorithms"; + +/** + * Read a DRM engine plugin String property value, given the property name string. + * + * propertyName identifies the property to query + * On return, propertyValue will be set to point to the property value. The + * memory that the value resides in is owned by the NDK MediaDrm API and + * will remain valid until the next call to AMediaDrm_getPropertyString. + */ +media_status_t AMediaDrm_getPropertyString(AMediaDrm *, const char *propertyName, + const char **propertyValue); + +/** + * Byte array property name: the device unique identifier is established during + * device provisioning and provides a means of uniquely identifying each device. + */ +const char *PROPERTY_DEVICE_UNIQUE_ID = "deviceUniqueId"; + +/** + * Read a DRM engine plugin byte array property value, given the property name string. + * On return, *propertyValue will be set to point to the property value. The + * memory that the value resides in is owned by the NDK MediaDrm API and + * will remain valid until the next call to AMediaDrm_getPropertyByteArray. + */ +media_status_t AMediaDrm_getPropertyByteArray(AMediaDrm *, const char *propertyName, + AMediaDrmByteArray *propertyValue); + +/** + * Set a DRM engine plugin String property value. + */ +media_status_t AMediaDrm_setPropertyString(AMediaDrm *, const char *propertyName, + const char *value); + +/** + * Set a DRM engine plugin byte array property value. + */ +media_status_t AMediaDrm_setPropertyByteArray(AMediaDrm *, const char *propertyName, + const uint8_t *value, size_t valueSize); + +/** + * In addition to supporting decryption of DASH Common Encrypted Media, the + * MediaDrm APIs provide the ability to securely deliver session keys from + * an operator's session key server to a client device, based on the factory-installed + * root of trust, and then perform encrypt, decrypt, sign and verify operations + * with the session key on arbitrary user data. + * + * Operators create session key servers that receive session key requests and provide + * encrypted session keys which can be used for general purpose crypto operations. + * + * Generic encrypt/decrypt/sign/verify methods are based on the established session + * keys. These keys are exchanged using the getKeyRequest/provideKeyResponse methods. + * + * Applications of this capability include securing various types of purchased or + * private content, such as applications, books and other media, photos or media + * delivery protocols. + */ + +/* + * Encrypt the data referenced by input of length dataSize using algorithm specified + * by cipherAlgorithm, and write the encrypted result into output. The caller must + * ensure that the output buffer is large enough to accept dataSize bytes. The key + * to use is identified by the 16 byte keyId. The key must have been loaded into + * the session using provideKeyResponse. + */ +media_status_t AMediaDrm_encrypt(AMediaDrm *, const AMediaDrmSessionId *sessionId, + const char *cipherAlgorithm, uint8_t *keyId, uint8_t *iv, + const uint8_t *input, uint8_t *output, size_t dataSize); + +/* + * Decrypt the data referenced by input of length dataSize using algorithm specified + * by cipherAlgorithm, and write the decrypted result into output. The caller must + * ensure that the output buffer is large enough to accept dataSize bytes. The key + * to use is identified by the 16 byte keyId. The key must have been loaded into + * the session using provideKeyResponse. + */ +media_status_t AMediaDrm_decrypt(AMediaDrm *, const AMediaDrmSessionId *sessionId, + const char *cipherAlgorithm, uint8_t *keyId, uint8_t *iv, + const uint8_t *input, uint8_t *output, size_t dataSize); + +/* + * Generate a signature using the specified macAlgorithm over the message data + * referenced by message of size messageSize and store the signature in the + * buffer referenced signature of max size *signatureSize. If the buffer is not + * large enough to hold the signature, MEDIADRM_SHORT_BUFFER is returned and + * *signatureSize is set to the buffer size required. The key to use is identified + * by the 16 byte keyId. The key must have been loaded into the session using + * provideKeyResponse. + */ +media_status_t AMediaDrm_sign(AMediaDrm *, const AMediaDrmSessionId *sessionId, + const char *macAlgorithm, uint8_t *keyId, uint8_t *message, size_t messageSize, + uint8_t *signature, size_t *signatureSize); + +/* + * Perform a signature verification using the specified macAlgorithm over the message + * data referenced by the message parameter of size messageSize. Returns MEDIADRM_OK + * if the signature matches, otherwise MEDAIDRM_VERIFY_FAILED is returned. The key to + * use is identified by the 16 byte keyId. The key must have been loaded into the + * session using provideKeyResponse. + */ +media_status_t AMediaDrm_verify(AMediaDrm *, const AMediaDrmSessionId *sessionId, + const char *macAlgorithm, uint8_t *keyId, const uint8_t *message, size_t messageSize, + const uint8_t *signature, size_t signatureSize); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif //_NDK_MEDIA_DRM_H diff --git a/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaError.h b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaError.h new file mode 100644 index 0000000..12613eb --- /dev/null +++ b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaError.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/* + * This file defines an NDK API. + * Do not remove methods. + * Do not change method signatures. + * Do not change the value of constants. + * Do not change the size of any of the classes defined in here. + * Do not reference types that are not part of the NDK. + * Do not #include files that aren't part of the NDK. + */ + +#ifndef _NDK_MEDIA_ERROR_H +#define _NDK_MEDIA_ERROR_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + AMEDIA_OK = 0, + + AMEDIA_ERROR_BASE = -10000, + AMEDIA_ERROR_UNKNOWN = AMEDIA_ERROR_BASE, + AMEDIA_ERROR_MALFORMED = AMEDIA_ERROR_BASE - 1, + AMEDIA_ERROR_UNSUPPORTED = AMEDIA_ERROR_BASE - 2, + AMEDIA_ERROR_INVALID_OBJECT = AMEDIA_ERROR_BASE - 3, + AMEDIA_ERROR_INVALID_PARAMETER = AMEDIA_ERROR_BASE - 4, + + AMEDIA_DRM_ERROR_BASE = -20000, + AMEDIA_DRM_NOT_PROVISIONED = AMEDIA_DRM_ERROR_BASE - 1, + AMEDIA_DRM_RESOURCE_BUSY = AMEDIA_DRM_ERROR_BASE - 2, + AMEDIA_DRM_DEVICE_REVOKED = AMEDIA_DRM_ERROR_BASE - 3, + AMEDIA_DRM_SHORT_BUFFER = AMEDIA_DRM_ERROR_BASE - 4, + AMEDIA_DRM_SESSION_NOT_OPENED = AMEDIA_DRM_ERROR_BASE - 5, + AMEDIA_DRM_TAMPER_DETECTED = AMEDIA_DRM_ERROR_BASE - 6, + AMEDIA_DRM_VERIFY_FAILED = AMEDIA_DRM_ERROR_BASE - 7, + AMEDIA_DRM_NEED_KEY = AMEDIA_DRM_ERROR_BASE - 8, + AMEDIA_DRM_LICENSE_EXPIRED = AMEDIA_DRM_ERROR_BASE - 9, + +} media_status_t; + + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _NDK_MEDIA_ERROR_H diff --git a/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaExtractor.h b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaExtractor.h new file mode 100644 index 0000000..7a4e702 --- /dev/null +++ b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaExtractor.h @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/* + * This file defines an NDK API. + * Do not remove methods. + * Do not change method signatures. + * Do not change the value of constants. + * Do not change the size of any of the classes defined in here. + * Do not reference types that are not part of the NDK. + * Do not #include files that aren't part of the NDK. + */ + +#ifndef _NDK_MEDIA_EXTRACTOR_H +#define _NDK_MEDIA_EXTRACTOR_H + +#include <sys/types.h> + +#include "NdkMediaCodec.h" +#include "NdkMediaFormat.h" +#include "NdkMediaCrypto.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct AMediaExtractor; +typedef struct AMediaExtractor AMediaExtractor; + + +/** + * Create new media extractor + */ +AMediaExtractor* AMediaExtractor_new(); + +/** + * Delete a previously created media extractor + */ +media_status_t AMediaExtractor_delete(AMediaExtractor*); + +/** + * Set the file descriptor from which the extractor will read. + */ +media_status_t AMediaExtractor_setDataSourceFd(AMediaExtractor*, int fd, off64_t offset, off64_t length); + +/** + * Set the URI from which the extractor will read. + */ +media_status_t AMediaExtractor_setDataSource(AMediaExtractor*, const char *location); // TODO support headers + +/** + * Return the number of tracks in the previously specified media file + */ +size_t AMediaExtractor_getTrackCount(AMediaExtractor*); + +/** + * Return the format of the specified track. The caller must free the returned format + */ +AMediaFormat* AMediaExtractor_getTrackFormat(AMediaExtractor*, size_t idx); + +/** + * Select the specified track. Subsequent calls to readSampleData, getSampleTrackIndex and + * getSampleTime only retrieve information for the subset of tracks selected. + * Selecting the same track multiple times has no effect, the track is + * only selected once. + */ +media_status_t AMediaExtractor_selectTrack(AMediaExtractor*, size_t idx); + +/** + * Unselect the specified track. Subsequent calls to readSampleData, getSampleTrackIndex and + * getSampleTime only retrieve information for the subset of tracks selected.. + */ +media_status_t AMediaExtractor_unselectTrack(AMediaExtractor*, size_t idx); + +/** + * Read the current sample. + */ +ssize_t AMediaExtractor_readSampleData(AMediaExtractor*, uint8_t *buffer, size_t capacity); + +/** + * Read the current sample's flags. + */ +uint32_t AMediaExtractor_getSampleFlags(AMediaExtractor*); // see definitions below + +/** + * Returns the track index the current sample originates from (or -1 + * if no more samples are available) + */ +int AMediaExtractor_getSampleTrackIndex(AMediaExtractor*); + +/** + * Returns the current sample's presentation time in microseconds. + * or -1 if no more samples are available. + */ +int64_t AMediaExtractor_getSampleTime(AMediaExtractor*); + +/** + * Advance to the next sample. Returns false if no more sample data + * is available (end of stream). + */ +bool AMediaExtractor_advance(AMediaExtractor*); + +typedef enum { + AMEDIAEXTRACTOR_SEEK_PREVIOUS_SYNC, + AMEDIAEXTRACTOR_SEEK_NEXT_SYNC, + AMEDIAEXTRACTOR_SEEK_CLOSEST_SYNC +} SeekMode; + +/** + * + */ +media_status_t AMediaExtractor_seekTo(AMediaExtractor*, int64_t seekPosUs, SeekMode mode); + +/** + * mapping of crypto scheme uuid to the scheme specific data for that scheme + */ +typedef struct PsshEntry { + AMediaUUID uuid; + size_t datalen; + void *data; +} PsshEntry; + +/** + * list of crypto schemes and their data + */ +typedef struct PsshInfo { + size_t numentries; + PsshEntry entries[0]; +} PsshInfo; + +/** + * Get the PSSH info if present. + */ +PsshInfo* AMediaExtractor_getPsshInfo(AMediaExtractor*); + + +AMediaCodecCryptoInfo *AMediaExtractor_getSampleCryptoInfo(AMediaExtractor *); + + +enum { + AMEDIAEXTRACTOR_SAMPLE_FLAG_SYNC = 1, + AMEDIAEXTRACTOR_SAMPLE_FLAG_ENCRYPTED = 2, +}; + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _NDK_MEDIA_EXTRACTOR_H diff --git a/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaFormat.h b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaFormat.h new file mode 100644 index 0000000..ab29791 --- /dev/null +++ b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaFormat.h @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * This file defines an NDK API. + * Do not remove methods. + * Do not change method signatures. + * Do not change the value of constants. + * Do not change the size of any of the classes defined in here. + * Do not reference types that are not part of the NDK. + * Do not #include files that aren't part of the NDK. + */ + +#ifndef _NDK_MEDIA_FORMAT_H +#define _NDK_MEDIA_FORMAT_H + +#include <sys/types.h> + +#include "NdkMediaError.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct AMediaFormat; +typedef struct AMediaFormat AMediaFormat; + +AMediaFormat *AMediaFormat_new(); +media_status_t AMediaFormat_delete(AMediaFormat*); + +/** + * Human readable representation of the format. The returned string is owned by the format, + * and remains valid until the next call to toString, or until the format is deleted. + */ +const char* AMediaFormat_toString(AMediaFormat*); + +bool AMediaFormat_getInt32(AMediaFormat*, const char *name, int32_t *out); +bool AMediaFormat_getInt64(AMediaFormat*, const char *name, int64_t *out); +bool AMediaFormat_getFloat(AMediaFormat*, const char *name, float *out); +/** + * The returned data is owned by the format and remains valid as long as the named entry + * is part of the format. + */ +bool AMediaFormat_getBuffer(AMediaFormat*, const char *name, void** data, size_t *size); +/** + * The returned string is owned by the format, and remains valid until the next call to getString, + * or until the format is deleted. + */ +bool AMediaFormat_getString(AMediaFormat*, const char *name, const char **out); + + +void AMediaFormat_setInt32(AMediaFormat*, const char* name, int32_t value); +void AMediaFormat_setInt64(AMediaFormat*, const char* name, int64_t value); +void AMediaFormat_setFloat(AMediaFormat*, const char* name, float value); +/** + * The provided string is copied into the format. + */ +void AMediaFormat_setString(AMediaFormat*, const char* name, const char* value); +/** + * The provided data is copied into the format. + */ +void AMediaFormat_setBuffer(AMediaFormat*, const char* name, void* data, size_t size); + + + +/** + * XXX should these be ints/enums that we look up in a table as needed? + */ +extern const char* AMEDIAFORMAT_KEY_AAC_PROFILE; +extern const char* AMEDIAFORMAT_KEY_BIT_RATE; +extern const char* AMEDIAFORMAT_KEY_CHANNEL_COUNT; +extern const char* AMEDIAFORMAT_KEY_CHANNEL_MASK; +extern const char* AMEDIAFORMAT_KEY_COLOR_FORMAT; +extern const char* AMEDIAFORMAT_KEY_DURATION; +extern const char* AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL; +extern const char* AMEDIAFORMAT_KEY_FRAME_RATE; +extern const char* AMEDIAFORMAT_KEY_HEIGHT; +extern const char* AMEDIAFORMAT_KEY_IS_ADTS; +extern const char* AMEDIAFORMAT_KEY_IS_AUTOSELECT; +extern const char* AMEDIAFORMAT_KEY_IS_DEFAULT; +extern const char* AMEDIAFORMAT_KEY_IS_FORCED_SUBTITLE; +extern const char* AMEDIAFORMAT_KEY_I_FRAME_INTERVAL; +extern const char* AMEDIAFORMAT_KEY_LANGUAGE; +extern const char* AMEDIAFORMAT_KEY_MAX_HEIGHT; +extern const char* AMEDIAFORMAT_KEY_MAX_INPUT_SIZE; +extern const char* AMEDIAFORMAT_KEY_MAX_WIDTH; +extern const char* AMEDIAFORMAT_KEY_MIME; +extern const char* AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP; +extern const char* AMEDIAFORMAT_KEY_REPEAT_PREVIOUS_FRAME_AFTER; +extern const char* AMEDIAFORMAT_KEY_SAMPLE_RATE; +extern const char* AMEDIAFORMAT_KEY_WIDTH; +extern const char* AMEDIAFORMAT_KEY_STRIDE; + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _NDK_MEDIA_FORMAT_H diff --git a/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaMuxer.h b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaMuxer.h new file mode 100644 index 0000000..90d946c --- /dev/null +++ b/9/platforms/android-21/arch-mips/usr/include/media/NdkMediaMuxer.h @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/* + * This file defines an NDK API. + * Do not remove methods. + * Do not change method signatures. + * Do not change the value of constants. + * Do not change the size of any of the classes defined in here. + * Do not reference types that are not part of the NDK. + * Do not #include files that aren't part of the NDK. + */ + +#ifndef _NDK_MEDIA_MUXER_H +#define _NDK_MEDIA_MUXER_H + +#include <sys/types.h> + +#include "NdkMediaCodec.h" +#include "NdkMediaError.h" +#include "NdkMediaFormat.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct AMediaMuxer; +typedef struct AMediaMuxer AMediaMuxer; + +typedef enum { + AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4 = 0, + AMEDIAMUXER_OUTPUT_FORMAT_WEBM = 1, +} OutputFormat; + +/** + * Create new media muxer + */ +AMediaMuxer* AMediaMuxer_new(int fd, OutputFormat format); + +/** + * Delete a previously created media muxer + */ +media_status_t AMediaMuxer_delete(AMediaMuxer*); + +/** + * Set and store the geodata (latitude and longitude) in the output file. + * This method should be called before AMediaMuxer_start. The geodata is stored + * in udta box if the output format is AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4, and is + * ignored for other output formats. + * The geodata is stored according to ISO-6709 standard. + * + * Both values are specified in degrees. + * Latitude must be in the range [-90, 90]. + * Longitude must be in the range [-180, 180]. + */ +media_status_t AMediaMuxer_setLocation(AMediaMuxer*, float latitude, float longitude); + +/** + * Sets the orientation hint for output video playback. + * This method should be called before AMediaMuxer_start. Calling this + * method will not rotate the video frame when muxer is generating the file, + * but add a composition matrix containing the rotation angle in the output + * video if the output format is AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4, so that a + * video player can choose the proper orientation for playback. + * Note that some video players may choose to ignore the composition matrix + * during playback. + * The angle is specified in degrees, clockwise. + * The supported angles are 0, 90, 180, and 270 degrees. + */ +media_status_t AMediaMuxer_setOrientationHint(AMediaMuxer*, int degrees); + +/** + * Adds a track with the specified format. + * Returns the index of the new track or a negative value in case of failure, + * which can be interpreted as a media_status_t. + */ +ssize_t AMediaMuxer_addTrack(AMediaMuxer*, const AMediaFormat* format); + +/** + * Start the muxer. Should be called after AMediaMuxer_addTrack and + * before AMediaMuxer_writeSampleData. + */ +media_status_t AMediaMuxer_start(AMediaMuxer*); + +/** + * Stops the muxer. + * Once the muxer stops, it can not be restarted. + */ +media_status_t AMediaMuxer_stop(AMediaMuxer*); + +/** + * Writes an encoded sample into the muxer. + * The application needs to make sure that the samples are written into + * the right tracks. Also, it needs to make sure the samples for each track + * are written in chronological order (e.g. in the order they are provided + * by the encoder.) + */ +media_status_t AMediaMuxer_writeSampleData(AMediaMuxer *muxer, + size_t trackIdx, const uint8_t *data, const AMediaCodecBufferInfo *info); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _NDK_MEDIA_MUXER_H |