bring over phonelibs minus frida-gum and qsml

This commit is contained in:
George Hotz
2020-01-17 10:37:11 -08:00
parent 6abffe0ede
commit da6863f427
2473 changed files with 759632 additions and 0 deletions
@@ -0,0 +1,115 @@
/*
* Copyright (C) 2012 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.
*/
#include <media/stagefright/MediaErrors.h>
#include <utils/Errors.h>
#include <utils/Vector.h>
#ifndef CRYPTO_API_H_
#define CRYPTO_API_H_
namespace android {
struct AString;
struct CryptoPlugin;
struct CryptoFactory {
CryptoFactory() {}
virtual ~CryptoFactory() {}
virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) const = 0;
virtual status_t createPlugin(
const uint8_t uuid[16], const void *data, size_t size,
CryptoPlugin **plugin) = 0;
private:
CryptoFactory(const CryptoFactory &);
CryptoFactory &operator=(const CryptoFactory &);
};
struct CryptoPlugin {
enum Mode {
kMode_Unencrypted = 0,
kMode_AES_CTR = 1,
// Neither key nor iv are being used in this mode.
// Each subsample is encrypted w/ an iv of all zeroes.
kMode_AES_WV = 2, // FIX constant
};
struct SubSample {
uint32_t mNumBytesOfClearData;
uint32_t mNumBytesOfEncryptedData;
};
CryptoPlugin() {}
virtual ~CryptoPlugin() {}
// If this method returns false, a non-secure decoder will be used to
// decode the data after decryption. The decrypt API below will have
// to support insecure decryption of the data (secure = false) for
// media data of the given mime type.
virtual bool requiresSecureDecoderComponent(const char *mime) const = 0;
// To implement resolution constraints, the crypto plugin needs to know
// the resolution of the video being decrypted. The media player should
// call this method when the resolution is determined and any time it
// is subsequently changed.
virtual void notifyResolution(uint32_t /* width */, uint32_t /* height */) {}
// A MediaDrm session may be associated with a MediaCrypto session. The
// associated MediaDrm session is used to load decryption keys
// into the crypto/drm plugin. The keys are then referenced by key-id
// in the 'key' parameter to the decrypt() method.
// Should return NO_ERROR on success, ERROR_DRM_SESSION_NOT_OPENED if
// the session is not opened and a code from MediaErrors.h otherwise.
virtual status_t setMediaDrmSession(const Vector<uint8_t> & /*sessionId */) {
return ERROR_UNSUPPORTED;
}
// If the error returned falls into the range
// ERROR_DRM_VENDOR_MIN..ERROR_DRM_VENDOR_MAX, errorDetailMsg should be
// filled in with an appropriate string.
// At the java level these special errors will then trigger a
// MediaCodec.CryptoException that gives clients access to both
// the error code and the errorDetailMsg.
// Returns a non-negative result to indicate the number of bytes written
// to the dstPtr, or a negative result to indicate an error.
virtual ssize_t decrypt(
bool secure,
const uint8_t key[16],
const uint8_t iv[16],
Mode mode,
const void *srcPtr,
const SubSample *subSamples, size_t numSubSamples,
void *dstPtr,
AString *errorDetailMsg) = 0;
private:
CryptoPlugin(const CryptoPlugin &);
CryptoPlugin &operator=(const CryptoPlugin &);
};
} // namespace android
extern "C" {
extern android::CryptoFactory *createCryptoFactory();
}
#endif // CRYPTO_API_H_
@@ -0,0 +1,164 @@
/*
* Copyright (C) 2012 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.
*/
#ifndef HDCP_API_H_
#define HDCP_API_H_
#include <utils/Errors.h>
#include <system/window.h>
namespace android {
// Two different kinds of modules are covered under the same HDCPModule
// structure below, a module either implements decryption or encryption.
struct HDCPModule {
typedef void (*ObserverFunc)(void *cookie, int msg, int ext1, int ext2);
// The msg argument in calls to the observer notification function.
enum {
// Sent in response to a call to "HDCPModule::initAsync" once
// initialization has either been successfully completed,
// i.e. the HDCP session is now fully setup (AKE, Locality Check,
// SKE and any authentication with repeaters completed) or failed.
// ext1 should be a suitable error code (status_t), ext2 is
// unused for ENCRYPTION and in the case of HDCP_INITIALIZATION_COMPLETE
// holds the local TCP port the module is listening on.
HDCP_INITIALIZATION_COMPLETE,
HDCP_INITIALIZATION_FAILED,
// Sent upon completion of a call to "HDCPModule::shutdownAsync".
// ext1 should be a suitable error code, ext2 is unused.
HDCP_SHUTDOWN_COMPLETE,
HDCP_SHUTDOWN_FAILED,
HDCP_UNAUTHENTICATED_CONNECTION,
HDCP_UNAUTHORIZED_CONNECTION,
HDCP_REVOKED_CONNECTION,
HDCP_TOPOLOGY_EXECEEDED,
HDCP_UNKNOWN_ERROR,
// DECRYPTION only: Indicates that a client has successfully connected,
// a secure session established and the module is ready to accept
// future calls to "decrypt".
HDCP_SESSION_ESTABLISHED,
};
// HDCPModule capability bit masks
enum {
// HDCP_CAPS_ENCRYPT: mandatory, meaning the HDCP module can encrypt
// from an input byte-array buffer to an output byte-array buffer
HDCP_CAPS_ENCRYPT = (1 << 0),
// HDCP_CAPS_ENCRYPT_NATIVE: the HDCP module supports encryption from
// a native buffer to an output byte-array buffer. The format of the
// input native buffer is specific to vendor's encoder implementation.
// It is the same format as that used by the encoder when
// "storeMetaDataInBuffers" extension is enabled on its output port.
HDCP_CAPS_ENCRYPT_NATIVE = (1 << 1),
};
// Module can call the notification function to signal completion/failure
// of asynchronous operations (such as initialization) or out of band
// events.
HDCPModule(void *cookie, ObserverFunc observerNotify) {};
virtual ~HDCPModule() {};
// ENCRYPTION: Request to setup an HDCP session with the host specified
// by addr and listening on the specified port.
// DECRYPTION: Request to setup an HDCP session, addr is the interface
// address the module should bind its socket to. port will be 0.
// The module will pick the port to listen on itself and report its choice
// in the "ext2" argument of the HDCP_INITIALIZATION_COMPLETE callback.
virtual status_t initAsync(const char *addr, unsigned port) = 0;
// Request to shutdown the active HDCP session.
virtual status_t shutdownAsync() = 0;
// Returns the capability bitmask of this HDCP session.
virtual uint32_t getCaps() {
return HDCP_CAPS_ENCRYPT;
}
// ENCRYPTION only:
// Encrypt data according to the HDCP spec. "size" bytes of data are
// available at "inData" (virtual address), "size" may not be a multiple
// of 128 bits (16 bytes). An equal number of encrypted bytes should be
// written to the buffer at "outData" (virtual address).
// This operation is to be synchronous, i.e. this call does not return
// until outData contains size bytes of encrypted data.
// streamCTR will be assigned by the caller (to 0 for the first PES stream,
// 1 for the second and so on)
// inputCTR _will_be_maintained_by_the_callee_ for each PES stream.
virtual status_t encrypt(
const void *inData, size_t size, uint32_t streamCTR,
uint64_t *outInputCTR, void *outData) {
return INVALID_OPERATION;
}
// Encrypt data according to the HDCP spec. "size" bytes of data starting
// at location "offset" are available in "buffer" (buffer handle). "size"
// may not be a multiple of 128 bits (16 bytes). An equal number of
// encrypted bytes should be written to the buffer at "outData" (virtual
// address). This operation is to be synchronous, i.e. this call does not
// return until outData contains size bytes of encrypted data.
// streamCTR will be assigned by the caller (to 0 for the first PES stream,
// 1 for the second and so on)
// inputCTR _will_be_maintained_by_the_callee_ for each PES stream.
virtual status_t encryptNative(
buffer_handle_t buffer, size_t offset, size_t size,
uint32_t streamCTR, uint64_t *outInputCTR, void *outData) {
return INVALID_OPERATION;
}
// DECRYPTION only:
// Decrypt data according to the HDCP spec.
// "size" bytes of encrypted data are available at "inData"
// (virtual address), "size" may not be a multiple of 128 bits (16 bytes).
// An equal number of decrypted bytes should be written to the buffer
// at "outData" (virtual address).
// This operation is to be synchronous, i.e. this call does not return
// until outData contains size bytes of decrypted data.
// Both streamCTR and inputCTR will be provided by the caller.
virtual status_t decrypt(
const void *inData, size_t size,
uint32_t streamCTR, uint64_t inputCTR,
void *outData) {
return INVALID_OPERATION;
}
private:
HDCPModule(const HDCPModule &);
HDCPModule &operator=(const HDCPModule &);
};
} // namespace android
// A shared library exporting the following methods should be included to
// support HDCP functionality. The shared library must be called
// "libstagefright_hdcp.so", it will be dynamically loaded into the
// mediaserver process.
extern "C" {
// Create a module for ENCRYPTION.
extern android::HDCPModule *createHDCPModule(
void *cookie, android::HDCPModule::ObserverFunc);
// Create a module for DECRYPTION.
extern android::HDCPModule *createHDCPModuleForDecryption(
void *cookie, android::HDCPModule::ObserverFunc);
}
#endif // HDCP_API_H_
@@ -0,0 +1,288 @@
/*
* Copyright (C) 2009 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.
*/
#ifndef HARDWARE_API_H_
#define HARDWARE_API_H_
#include <media/hardware/OMXPluginBase.h>
#include <media/hardware/MetadataBufferType.h>
#include <system/window.h>
#include <utils/RefBase.h>
#include <OMX_Component.h>
namespace android {
// A pointer to this struct is passed to the OMX_SetParameter when the extension
// index for the 'OMX.google.android.index.enableAndroidNativeBuffers' extension
// is given.
//
// When Android native buffer use is disabled for a port (the default state),
// the OMX node should operate as normal, and expect UseBuffer calls to set its
// buffers. This is the mode that will be used when CPU access to the buffer is
// required.
//
// When Android native buffer use has been enabled for a given port, the video
// color format for the port is to be interpreted as an Android pixel format
// rather than an OMX color format. Enabling Android native buffers may also
// change how the component receives the native buffers. If store-metadata-mode
// is enabled on the port, the component will receive the buffers as specified
// in the section below. Otherwise, unless the node supports the
// 'OMX.google.android.index.useAndroidNativeBuffer2' extension, it should
// expect to receive UseAndroidNativeBuffer calls (via OMX_SetParameter) rather
// than UseBuffer calls for that port.
struct EnableAndroidNativeBuffersParams {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_U32 nPortIndex;
OMX_BOOL enable;
};
// A pointer to this struct is passed to OMX_SetParameter() when the extension index
// "OMX.google.android.index.storeMetaDataInBuffers" or
// "OMX.google.android.index.storeANWBufferInMetadata" is given.
//
// When meta data is stored in the video buffers passed between OMX clients
// and OMX components, interpretation of the buffer data is up to the
// buffer receiver, and the data may or may not be the actual video data, but
// some information helpful for the receiver to locate the actual data.
// The buffer receiver thus needs to know how to interpret what is stored
// in these buffers, with mechanisms pre-determined externally. How to
// interpret the meta data is outside of the scope of this parameter.
//
// Currently, this is used to pass meta data from video source (camera component, for instance) to
// video encoder to avoid memcpying of input video frame data, as well as to pass dynamic output
// buffer to video decoder. To do this, bStoreMetaData is set to OMX_TRUE.
//
// If bStoreMetaData is set to false, real YUV frame data will be stored in input buffers, and
// the output buffers contain either real YUV frame data, or are themselves native handles as
// directed by enable/use-android-native-buffer parameter settings.
// In addition, if no OMX_SetParameter() call is made on a port with the corresponding extension
// index, the component should not assume that the client is not using metadata mode for the port.
//
// If the component supports this using the "OMX.google.android.index.storeANWBufferInMetadata"
// extension and bStoreMetaData is set to OMX_TRUE, data is passed using the VideoNativeMetadata
// layout as defined below. Each buffer will be accompanied by a fence. The fence must signal
// before the buffer can be used (e.g. read from or written into). When returning such buffer to
// the client, component must provide a new fence that must signal before the returned buffer can
// be used (e.g. read from or written into). The component owns the incoming fenceFd, and must close
// it when fence has signaled. The client will own and close the returned fence file descriptor.
//
// If the component supports this using the "OMX.google.android.index.storeMetaDataInBuffers"
// extension and bStoreMetaData is set to OMX_TRUE, data is passed using VideoGrallocMetadata
// (the layout of which is the VideoGrallocMetadata defined below). Camera input can be also passed
// as "CameraSource", the layout of which is vendor dependent.
//
// Metadata buffers are registered with the component using UseBuffer calls, or can be allocated
// by the component for encoder-metadata-output buffers.
struct StoreMetaDataInBuffersParams {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_U32 nPortIndex;
OMX_BOOL bStoreMetaData;
};
// Meta data buffer layout used to transport output frames to the decoder for
// dynamic buffer handling.
struct VideoGrallocMetadata {
MetadataBufferType eType; // must be kMetadataBufferTypeGrallocSource
#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
OMX_PTR pHandle;
#else
buffer_handle_t pHandle;
#endif
};
// Legacy name for VideoGrallocMetadata struct.
struct VideoDecoderOutputMetaData : public VideoGrallocMetadata {};
struct VideoNativeMetadata {
MetadataBufferType eType; // must be kMetadataBufferTypeANWBuffer
#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
OMX_PTR pBuffer;
#else
struct ANativeWindowBuffer* pBuffer;
#endif
int nFenceFd; // -1 if unused
};
// A pointer to this struct is passed to OMX_SetParameter() when the extension
// index "OMX.google.android.index.prepareForAdaptivePlayback" is given.
//
// This method is used to signal a video decoder, that the user has requested
// seamless resolution change support (if bEnable is set to OMX_TRUE).
// nMaxFrameWidth and nMaxFrameHeight are the dimensions of the largest
// anticipated frames in the video. If bEnable is OMX_FALSE, no resolution
// change is expected, and the nMaxFrameWidth/Height fields are unused.
//
// If the decoder supports dynamic output buffers, it may ignore this
// request. Otherwise, it shall request resources in such a way so that it
// avoids full port-reconfiguration (due to output port-definition change)
// during resolution changes.
//
// DO NOT USE THIS STRUCTURE AS IT WILL BE REMOVED. INSTEAD, IMPLEMENT
// METADATA SUPPORT FOR VIDEO DECODERS.
struct PrepareForAdaptivePlaybackParams {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_U32 nPortIndex;
OMX_BOOL bEnable;
OMX_U32 nMaxFrameWidth;
OMX_U32 nMaxFrameHeight;
};
// A pointer to this struct is passed to OMX_SetParameter when the extension
// index for the 'OMX.google.android.index.useAndroidNativeBuffer' extension is
// given. This call will only be performed if a prior call was made with the
// 'OMX.google.android.index.enableAndroidNativeBuffers' extension index,
// enabling use of Android native buffers.
struct UseAndroidNativeBufferParams {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_U32 nPortIndex;
OMX_PTR pAppPrivate;
OMX_BUFFERHEADERTYPE **bufferHeader;
const sp<ANativeWindowBuffer>& nativeBuffer;
};
// A pointer to this struct is passed to OMX_GetParameter when the extension
// index for the 'OMX.google.android.index.getAndroidNativeBufferUsage'
// extension is given. The usage bits returned from this query will be used to
// allocate the Gralloc buffers that get passed to the useAndroidNativeBuffer
// command.
struct GetAndroidNativeBufferUsageParams {
OMX_U32 nSize; // IN
OMX_VERSIONTYPE nVersion; // IN
OMX_U32 nPortIndex; // IN
OMX_U32 nUsage; // OUT
};
// An enum OMX_COLOR_FormatAndroidOpaque to indicate an opaque colorformat
// is declared in media/stagefright/openmax/OMX_IVCommon.h
// This will inform the encoder that the actual
// colorformat will be relayed by the GRalloc Buffers.
// OMX_COLOR_FormatAndroidOpaque = 0x7F000001,
// A pointer to this struct is passed to OMX_SetParameter when the extension
// index for the 'OMX.google.android.index.prependSPSPPSToIDRFrames' extension
// is given.
// A successful result indicates that future IDR frames will be prefixed by
// SPS/PPS.
struct PrependSPSPPSToIDRFramesParams {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_BOOL bEnable;
};
// Structure describing a media image (frame)
// Currently only supporting YUV
struct MediaImage {
enum Type {
MEDIA_IMAGE_TYPE_UNKNOWN = 0,
MEDIA_IMAGE_TYPE_YUV,
};
enum PlaneIndex {
Y = 0,
U,
V,
MAX_NUM_PLANES
};
Type mType;
uint32_t mNumPlanes; // number of planes
uint32_t mWidth; // width of largest plane (unpadded, as in nFrameWidth)
uint32_t mHeight; // height of largest plane (unpadded, as in nFrameHeight)
uint32_t mBitDepth; // useable bit depth
struct PlaneInfo {
uint32_t mOffset; // offset of first pixel of the plane in bytes
// from buffer offset
uint32_t mColInc; // column increment in bytes
uint32_t mRowInc; // row increment in bytes
uint32_t mHorizSubsampling; // subsampling compared to the largest plane
uint32_t mVertSubsampling; // subsampling compared to the largest plane
};
PlaneInfo mPlane[MAX_NUM_PLANES];
};
// A pointer to this struct is passed to OMX_GetParameter when the extension
// index for the 'OMX.google.android.index.describeColorFormat'
// extension is given. This method can be called from any component state
// other than invalid. The color-format, frame width/height, and stride/
// slice-height parameters are ones that are associated with a raw video
// port (input or output), but the stride/slice height parameters may be
// incorrect. bUsingNativeBuffers is OMX_TRUE if native android buffers will
// be used (while specifying this color format).
//
// The component shall fill out the MediaImage structure that
// corresponds to the described raw video format, and the potentially corrected
// stride and slice-height info.
//
// The behavior is slightly different if bUsingNativeBuffers is OMX_TRUE,
// though most implementations can ignore this difference. When using native buffers,
// the component may change the configured color format to an optimized format.
// Additionally, when allocating these buffers for flexible usecase, the framework
// will set the SW_READ/WRITE_OFTEN usage flags. In this case (if bUsingNativeBuffers
// is OMX_TRUE), the component shall fill out the MediaImage information for the
// scenario when these SW-readable/writable buffers are locked using gralloc_lock.
// Note, that these buffers may also be locked using gralloc_lock_ycbcr, which must
// be supported for vendor-specific formats.
//
// For non-YUV packed planar/semiplanar image formats, or if bUsingNativeBuffers
// is OMX_TRUE and the component does not support this color format with native
// buffers, the component shall set mNumPlanes to 0, and mType to MEDIA_IMAGE_TYPE_UNKNOWN.
struct DescribeColorFormatParams {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
// input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE
OMX_COLOR_FORMATTYPE eColorFormat;
OMX_U32 nFrameWidth;
OMX_U32 nFrameHeight;
OMX_U32 nStride;
OMX_U32 nSliceHeight;
OMX_BOOL bUsingNativeBuffers;
// output: fill out the MediaImage fields
MediaImage sMediaImage;
};
// A pointer to this struct is passed to OMX_SetParameter or OMX_GetParameter
// when the extension index for the
// 'OMX.google.android.index.configureVideoTunnelMode' extension is given.
// If the extension is supported then tunneled playback mode should be supported
// by the codec. If bTunneled is set to OMX_TRUE then the video decoder should
// operate in "tunneled" mode and output its decoded frames directly to the
// sink. In this case nAudioHwSync is the HW SYNC ID of the audio HAL Output
// stream to sync the video with. If bTunneled is set to OMX_FALSE, "tunneled"
// mode should be disabled and nAudioHwSync should be ignored.
// OMX_GetParameter is used to query tunneling configuration. bTunneled should
// return whether decoder is operating in tunneled mode, and if it is,
// pSidebandWindow should contain the codec allocated sideband window handle.
struct ConfigureVideoTunnelModeParams {
OMX_U32 nSize; // IN
OMX_VERSIONTYPE nVersion; // IN
OMX_U32 nPortIndex; // IN
OMX_BOOL bTunneled; // IN/OUT
OMX_U32 nAudioHwSync; // IN
OMX_PTR pSidebandWindow; // OUT
};
} // namespace android
extern android::OMXPluginBase *createOMXPlugin();
#endif // HARDWARE_API_H_
@@ -0,0 +1,127 @@
/*
* Copyright (C) 2011 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.
*/
#ifndef METADATA_BUFFER_TYPE_H
#define METADATA_BUFFER_TYPE_H
#ifdef __cplusplus
extern "C" {
namespace android {
#endif
/*
* MetadataBufferType defines the type of the metadata buffers that
* can be passed to video encoder component for encoding, via Stagefright
* media recording framework. To see how to work with the metadata buffers
* in media recording framework, please consult HardwareAPI.h
*
* The creator of metadata buffers and video encoder share common knowledge
* on what is actually being stored in these metadata buffers, and
* how the information can be used by the video encoder component
* to locate the actual pixel data as the source input for video
* encoder, plus whatever other information that is necessary. Stagefright
* media recording framework does not need to know anything specific about the
* metadata buffers, except for receving each individual metadata buffer
* as the source input, making a copy of the metadata buffer, and passing the
* copy via OpenMAX API to the video encoder component.
*
* The creator of the metadata buffers must ensure that the first
* 4 bytes in every metadata buffer indicates its buffer type,
* and the rest of the metadata buffer contains the
* actual metadata information. When a video encoder component receives
* a metadata buffer, it uses the first 4 bytes in that buffer to find
* out the type of the metadata buffer, and takes action appropriate
* to that type of metadata buffers (for instance, locate the actual
* pixel data input and then encoding the input data to produce a
* compressed output buffer).
*
* The following shows the layout of a metadata buffer,
* where buffer type is a 4-byte field of MetadataBufferType,
* and the payload is the metadata information.
*
* --------------------------------------------------------------
* | buffer type | payload |
* --------------------------------------------------------------
*
*/
typedef enum {
/*
* kMetadataBufferTypeCameraSource is used to indicate that
* the source of the metadata buffer is the camera component.
*/
kMetadataBufferTypeCameraSource = 0,
/*
* kMetadataBufferTypeGrallocSource is used to indicate that
* the payload of the metadata buffers can be interpreted as
* a buffer_handle_t.
* So in this case,the metadata that the encoder receives
* will have a byte stream that consists of two parts:
* 1. First, there is an integer indicating that it is a GRAlloc
* source (kMetadataBufferTypeGrallocSource)
* 2. This is followed by the buffer_handle_t that is a handle to the
* GRalloc buffer. The encoder needs to interpret this GRalloc handle
* and encode the frames.
* --------------------------------------------------------------
* | kMetadataBufferTypeGrallocSource | buffer_handle_t buffer |
* --------------------------------------------------------------
*
* See the VideoGrallocMetadata structure.
*/
kMetadataBufferTypeGrallocSource = 1,
/*
* kMetadataBufferTypeGraphicBuffer is used to indicate that
* the payload of the metadata buffers can be interpreted as
* an ANativeWindowBuffer, and that a fence is provided.
*
* In this case, the metadata will have a byte stream that consists of three parts:
* 1. First, there is an integer indicating that the metadata
* contains an ANativeWindowBuffer (kMetadataBufferTypeANWBuffer)
* 2. This is followed by the pointer to the ANativeWindowBuffer.
* Codec must not free this buffer as it does not actually own this buffer.
* 3. Finally, there is an integer containing a fence file descriptor.
* The codec must wait on the fence before encoding or decoding into this
* buffer. When the buffer is returned, codec must replace this file descriptor
* with a new fence, that will be waited on before the buffer is replaced
* (encoder) or read (decoder).
* ---------------------------------
* | kMetadataBufferTypeANWBuffer |
* ---------------------------------
* | ANativeWindowBuffer *buffer |
* ---------------------------------
* | int fenceFd |
* ---------------------------------
*
* See the VideoNativeMetadata structure.
*/
kMetadataBufferTypeANWBuffer = 2,
/* This value is used by framework, but is never used inside a metadata buffer */
kMetadataBufferTypeInvalid = -1,
// Add more here...
} MetadataBufferType;
#ifdef __cplusplus
} // namespace android
}
#endif
#endif // METADATA_BUFFER_TYPE_H
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2009 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.
*/
#ifndef OMX_PLUGIN_BASE_H_
#define OMX_PLUGIN_BASE_H_
#include <sys/types.h>
#include <OMX_Component.h>
#include <utils/String8.h>
#include <utils/Vector.h>
namespace android {
struct OMXPluginBase {
OMXPluginBase() {}
virtual ~OMXPluginBase() {}
virtual OMX_ERRORTYPE makeComponentInstance(
const char *name,
const OMX_CALLBACKTYPE *callbacks,
OMX_PTR appData,
OMX_COMPONENTTYPE **component) = 0;
virtual OMX_ERRORTYPE destroyComponentInstance(
OMX_COMPONENTTYPE *component) = 0;
virtual OMX_ERRORTYPE enumerateComponents(
OMX_STRING name,
size_t size,
OMX_U32 index) = 0;
virtual OMX_ERRORTYPE getRolesOfComponent(
const char *name,
Vector<String8> *roles) = 0;
private:
OMXPluginBase(const OMXPluginBase &);
OMXPluginBase &operator=(const OMXPluginBase &);
};
} // namespace android
#endif // OMX_PLUGIN_BASE_H_