зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1379190: P3. Remove omx-plugin 3rd party libs. r=cpearce
They weren't used on android API < 16. MozReview-Commit-ID: F6WHG9ApGdC --HG-- extra : rebase_source : be3a222cb27d081b5e73d660602706f226088ffd
This commit is contained in:
Родитель
77f31bcb34
Коммит
305c960af0
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* 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 I420_COLOR_CONVERTER_H
|
||||
#define I420_COLOR_CONVERTER_H
|
||||
|
||||
#include <II420ColorConverter.h>
|
||||
|
||||
// This is a wrapper around the I420 color converter functions in
|
||||
// II420ColorConverter, which is loaded from a shared library.
|
||||
class I420ColorConverter: public II420ColorConverter {
|
||||
public:
|
||||
I420ColorConverter();
|
||||
~I420ColorConverter();
|
||||
|
||||
// Returns true if the converter functions are successfully loaded.
|
||||
bool isLoaded();
|
||||
private:
|
||||
void* mHandle;
|
||||
};
|
||||
|
||||
#endif /* I420_COLOR_CONVERTER_H */
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
* 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 II420_COLOR_CONVERTER_H
|
||||
|
||||
#define II420_COLOR_CONVERTER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <android/rect.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct II420ColorConverter {
|
||||
|
||||
/*
|
||||
* getDecoderOutputFormat
|
||||
* Returns the color format (OMX_COLOR_FORMATTYPE) of the decoder output.
|
||||
* If it is I420 (OMX_COLOR_FormatYUV420Planar), no conversion is needed,
|
||||
* and convertDecoderOutputToI420() can be a no-op.
|
||||
*/
|
||||
int (*getDecoderOutputFormat)();
|
||||
|
||||
/*
|
||||
* convertDecoderOutputToI420
|
||||
* @Desc Converts from the decoder output format to I420 format.
|
||||
* @note Caller (e.g. VideoEditor) owns the buffers
|
||||
* @param decoderBits (IN) Pointer to the buffer contains decoder output
|
||||
* @param decoderWidth (IN) Buffer width, as reported by the decoder
|
||||
* metadata (kKeyWidth)
|
||||
* @param decoderHeight (IN) Buffer height, as reported by the decoder
|
||||
* metadata (kKeyHeight)
|
||||
* @param decoderRect (IN) The rectangle of the actual frame, as
|
||||
* reported by decoder metadata (kKeyCropRect)
|
||||
* @param dstBits (OUT) Pointer to the output I420 buffer
|
||||
* @return -1 Any error
|
||||
* @return 0 No Error
|
||||
*/
|
||||
int (*convertDecoderOutputToI420)(
|
||||
void* decoderBits, int decoderWidth, int decoderHeight,
|
||||
ARect decoderRect, void* dstBits);
|
||||
|
||||
/*
|
||||
* getEncoderIntputFormat
|
||||
* Returns the color format (OMX_COLOR_FORMATTYPE) of the encoder input.
|
||||
* If it is I420 (OMX_COLOR_FormatYUV420Planar), no conversion is needed,
|
||||
* and convertI420ToEncoderInput() and getEncoderInputBufferInfo() can
|
||||
* be no-ops.
|
||||
*/
|
||||
int (*getEncoderInputFormat)();
|
||||
|
||||
/* convertI420ToEncoderInput
|
||||
* @Desc This function converts from I420 to the encoder input format
|
||||
* @note Caller (e.g. VideoEditor) owns the buffers
|
||||
* @param srcBits (IN) Pointer to the input I420 buffer
|
||||
* @param srcWidth (IN) Width of the I420 frame
|
||||
* @param srcHeight (IN) Height of the I420 frame
|
||||
* @param encoderWidth (IN) Encoder buffer width, as calculated by
|
||||
* getEncoderBufferInfo()
|
||||
* @param encoderHeight (IN) Encoder buffer height, as calculated by
|
||||
* getEncoderBufferInfo()
|
||||
* @param encoderRect (IN) Rect coordinates of the actual frame inside
|
||||
* the encoder buffer, as calculated by
|
||||
* getEncoderBufferInfo().
|
||||
* @param encoderBits (OUT) Pointer to the output buffer. The size of
|
||||
* this buffer is calculated by
|
||||
* getEncoderBufferInfo()
|
||||
* @return -1 Any error
|
||||
* @return 0 No Error
|
||||
*/
|
||||
int (*convertI420ToEncoderInput)(
|
||||
void* srcBits, int srcWidth, int srcHeight,
|
||||
int encoderWidth, int encoderHeight, ARect encoderRect,
|
||||
void* encoderBits);
|
||||
|
||||
/* getEncoderInputBufferInfo
|
||||
* @Desc This function returns metadata for the encoder input buffer
|
||||
* based on the actual I420 frame width and height.
|
||||
* @note This API should be be used to obtain the necessary information
|
||||
* before calling convertI420ToEncoderInput().
|
||||
* VideoEditor knows only the width and height of the I420 buffer,
|
||||
* but it also needs know the width, height, and size of the
|
||||
* encoder input buffer. The encoder input buffer width and height
|
||||
* are used to set the metadata for the encoder.
|
||||
* @param srcWidth (IN) Width of the I420 frame
|
||||
* @param srcHeight (IN) Height of the I420 frame
|
||||
* @param encoderWidth (OUT) Encoder buffer width needed
|
||||
* @param encoderHeight (OUT) Encoder buffer height needed
|
||||
* @param encoderRect (OUT) Rect coordinates of the actual frame inside
|
||||
* the encoder buffer
|
||||
* @param encoderBufferSize (OUT) The size of the buffer that need to be
|
||||
* allocated by the caller before invoking
|
||||
* convertI420ToEncoderInput().
|
||||
* @return -1 Any error
|
||||
* @return 0 No Error
|
||||
*/
|
||||
int (*getEncoderInputBufferInfo)(
|
||||
int srcWidth, int srcHeight,
|
||||
int* encoderWidth, int* encoderHeight,
|
||||
ARect* encoderRect, int* encoderBufferSize);
|
||||
|
||||
} II420ColorConverter;
|
||||
|
||||
/* The only function that the shared library needs to expose: It fills the
|
||||
function pointers in II420ColorConverter */
|
||||
void getI420ColorConverter(II420ColorConverter *converter);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // II420_COLOR_CONVERTER_H
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
The source from this directory was copied from the Android OS source.
|
||||
Patches have been applied on top of the original source.
|
||||
|
||||
The git branch used from AOSP was android-4.0.4_r2.1.
|
|
@ -1,126 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 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 ANDROID_NATIVE_WINDOW_H
|
||||
#define ANDROID_NATIVE_WINDOW_H
|
||||
|
||||
#include <android/rect.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Pixel formats that a window can use.
|
||||
*/
|
||||
enum {
|
||||
WINDOW_FORMAT_RGBA_8888 = 1,
|
||||
WINDOW_FORMAT_RGBX_8888 = 2,
|
||||
WINDOW_FORMAT_RGB_565 = 4,
|
||||
};
|
||||
|
||||
struct ANativeWindow;
|
||||
typedef struct ANativeWindow ANativeWindow;
|
||||
|
||||
typedef struct ANativeWindow_Buffer {
|
||||
// The number of pixels that are show horizontally.
|
||||
int32_t width;
|
||||
|
||||
// The number of pixels that are shown vertically.
|
||||
int32_t height;
|
||||
|
||||
// The number of *pixels* that a line in the buffer takes in
|
||||
// memory. This may be >= width.
|
||||
int32_t stride;
|
||||
|
||||
// The format of the buffer. One of WINDOW_FORMAT_*
|
||||
int32_t format;
|
||||
|
||||
// The actual bits.
|
||||
void* bits;
|
||||
|
||||
// Do not touch.
|
||||
uint32_t reserved[6];
|
||||
} ANativeWindow_Buffer;
|
||||
|
||||
/**
|
||||
* Acquire a reference on the given ANativeWindow object. This prevents the object
|
||||
* from being deleted until the reference is removed.
|
||||
*/
|
||||
void ANativeWindow_acquire(ANativeWindow* window);
|
||||
|
||||
/**
|
||||
* Remove a reference that was previously acquired with ANativeWindow_acquire().
|
||||
*/
|
||||
void ANativeWindow_release(ANativeWindow* window);
|
||||
|
||||
/*
|
||||
* Return the current width in pixels of the window surface. Returns a
|
||||
* negative value on error.
|
||||
*/
|
||||
int32_t ANativeWindow_getWidth(ANativeWindow* window);
|
||||
|
||||
/*
|
||||
* Return the current height in pixels of the window surface. Returns a
|
||||
* negative value on error.
|
||||
*/
|
||||
int32_t ANativeWindow_getHeight(ANativeWindow* window);
|
||||
|
||||
/*
|
||||
* Return the current pixel format of the window surface. Returns a
|
||||
* negative value on error.
|
||||
*/
|
||||
int32_t ANativeWindow_getFormat(ANativeWindow* window);
|
||||
|
||||
/*
|
||||
* Change the format and size of the window buffers.
|
||||
*
|
||||
* The width and height control the number of pixels in the buffers, not the
|
||||
* dimensions of the window on screen. If these are different than the
|
||||
* window's physical size, then it buffer will be scaled to match that size
|
||||
* when compositing it to the screen.
|
||||
*
|
||||
* For all of these parameters, if 0 is supplied then the window's base
|
||||
* value will come back in force.
|
||||
*
|
||||
* width and height must be either both zero or both non-zero.
|
||||
*
|
||||
*/
|
||||
int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window,
|
||||
int32_t width, int32_t height, int32_t format);
|
||||
|
||||
/**
|
||||
* Lock the window's next drawing surface for writing.
|
||||
* inOutDirtyBounds is used as an in/out parameter, upon entering the
|
||||
* function, it contains the dirty region, that is, the region the caller
|
||||
* intends to redraw. When the function returns, inOutDirtyBounds is updated
|
||||
* with the actual area the caller needs to redraw -- this region is often
|
||||
* extended by ANativeWindow_lock.
|
||||
*/
|
||||
int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer,
|
||||
ARect* inOutDirtyBounds);
|
||||
|
||||
/**
|
||||
* Unlock the window's drawing surface after previously locking it,
|
||||
* posting the new buffer to the display.
|
||||
*/
|
||||
int32_t ANativeWindow_unlockAndPost(ANativeWindow* window);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // ANDROID_NATIVE_WINDOW_H
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 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 ANDROID_RECT_H
|
||||
#define ANDROID_RECT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ARect {
|
||||
#ifdef __cplusplus
|
||||
typedef int32_t value_type;
|
||||
#endif
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t right;
|
||||
int32_t bottom;
|
||||
} ARect;
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // ANDROID_RECT_H
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008 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 ANDROID_BINDER_H
|
||||
#define ANDROID_BINDER_H
|
||||
|
||||
#include <binder/IBinder.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
namespace android {
|
||||
|
||||
class BBinder : public IBinder
|
||||
{
|
||||
public:
|
||||
BBinder();
|
||||
|
||||
virtual const String16& getInterfaceDescriptor() const;
|
||||
virtual bool isBinderAlive() const;
|
||||
virtual status_t pingBinder();
|
||||
virtual status_t dump(int fd, const Vector<String16>& args);
|
||||
|
||||
virtual status_t transact( uint32_t code,
|
||||
const Parcel& data,
|
||||
Parcel* reply,
|
||||
uint32_t flags = 0);
|
||||
|
||||
virtual status_t linkToDeath(const sp<DeathRecipient>& recipient,
|
||||
void* cookie = NULL,
|
||||
uint32_t flags = 0);
|
||||
|
||||
virtual status_t unlinkToDeath( const wp<DeathRecipient>& recipient,
|
||||
void* cookie = NULL,
|
||||
uint32_t flags = 0,
|
||||
wp<DeathRecipient>* outRecipient = NULL);
|
||||
|
||||
virtual void attachObject( const void* objectID,
|
||||
void* object,
|
||||
void* cleanupCookie,
|
||||
object_cleanup_func func);
|
||||
virtual void* findObject(const void* objectID) const;
|
||||
virtual void detachObject(const void* objectID);
|
||||
|
||||
virtual BBinder* localBinder();
|
||||
|
||||
protected:
|
||||
virtual ~BBinder();
|
||||
|
||||
virtual status_t onTransact( uint32_t code,
|
||||
const Parcel& data,
|
||||
Parcel* reply,
|
||||
uint32_t flags = 0);
|
||||
|
||||
private:
|
||||
BBinder(const BBinder& o);
|
||||
BBinder& operator=(const BBinder& o);
|
||||
|
||||
class Extras;
|
||||
|
||||
Extras* mExtras;
|
||||
void* mReserved0;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class BpRefBase : public virtual RefBase
|
||||
{
|
||||
protected:
|
||||
BpRefBase(const sp<IBinder>& o);
|
||||
virtual ~BpRefBase();
|
||||
virtual void onFirstRef();
|
||||
virtual void onLastStrongRef(const void* id);
|
||||
virtual bool onIncStrongAttempted(uint32_t flags, const void* id);
|
||||
|
||||
inline IBinder* remote() { return mRemote; }
|
||||
inline IBinder* remote() const { return mRemote; }
|
||||
|
||||
private:
|
||||
BpRefBase(const BpRefBase& o);
|
||||
BpRefBase& operator=(const BpRefBase& o);
|
||||
|
||||
IBinder* const mRemote;
|
||||
RefBase::weakref_type* mRefs;
|
||||
volatile int32_t mState;
|
||||
};
|
||||
|
||||
}; // namespace android
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_BINDER_H
|
|
@ -1,159 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008 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 ANDROID_IBINDER_H
|
||||
#define ANDROID_IBINDER_H
|
||||
|
||||
#include <utils/Errors.h>
|
||||
#include <utils/RefBase.h>
|
||||
#include <utils/String16.h>
|
||||
#include <utils/Vector.h>
|
||||
|
||||
|
||||
#define B_PACK_CHARS(c1, c2, c3, c4) \
|
||||
((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4))
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
namespace android {
|
||||
|
||||
class BBinder;
|
||||
class BpBinder;
|
||||
class IInterface;
|
||||
class Parcel;
|
||||
|
||||
/**
|
||||
* Base class and low-level protocol for a remotable object.
|
||||
* You can derive from this class to create an object for which other
|
||||
* processes can hold references to it. Communication between processes
|
||||
* (method calls, property get and set) is down through a low-level
|
||||
* protocol implemented on top of the transact() API.
|
||||
*/
|
||||
class IBinder : public virtual RefBase
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
FIRST_CALL_TRANSACTION = 0x00000001,
|
||||
LAST_CALL_TRANSACTION = 0x00ffffff,
|
||||
|
||||
PING_TRANSACTION = B_PACK_CHARS('_','P','N','G'),
|
||||
DUMP_TRANSACTION = B_PACK_CHARS('_','D','M','P'),
|
||||
INTERFACE_TRANSACTION = B_PACK_CHARS('_', 'N', 'T', 'F'),
|
||||
|
||||
// Corresponds to TF_ONE_WAY -- an asynchronous call.
|
||||
FLAG_ONEWAY = 0x00000001
|
||||
};
|
||||
|
||||
IBinder();
|
||||
|
||||
/**
|
||||
* Check if this IBinder implements the interface named by
|
||||
* @a descriptor. If it does, the base pointer to it is returned,
|
||||
* which you can safely static_cast<> to the concrete C++ interface.
|
||||
*/
|
||||
virtual sp<IInterface> queryLocalInterface(const String16& descriptor);
|
||||
|
||||
/**
|
||||
* Return the canonical name of the interface provided by this IBinder
|
||||
* object.
|
||||
*/
|
||||
virtual const String16& getInterfaceDescriptor() const = 0;
|
||||
|
||||
virtual bool isBinderAlive() const = 0;
|
||||
virtual status_t pingBinder() = 0;
|
||||
virtual status_t dump(int fd, const Vector<String16>& args) = 0;
|
||||
|
||||
virtual status_t transact( uint32_t code,
|
||||
const Parcel& data,
|
||||
Parcel* reply,
|
||||
uint32_t flags = 0) = 0;
|
||||
|
||||
/**
|
||||
* This method allows you to add data that is transported through
|
||||
* IPC along with your IBinder pointer. When implementing a Binder
|
||||
* object, override it to write your desired data in to @a outData.
|
||||
* You can then call getConstantData() on your IBinder to retrieve
|
||||
* that data, from any process. You MUST return the number of bytes
|
||||
* written in to the parcel (including padding).
|
||||
*/
|
||||
class DeathRecipient : public virtual RefBase
|
||||
{
|
||||
public:
|
||||
virtual void binderDied(const wp<IBinder>& who) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Register the @a recipient for a notification if this binder
|
||||
* goes away. If this binder object unexpectedly goes away
|
||||
* (typically because its hosting process has been killed),
|
||||
* then DeathRecipient::binderDied() will be called with a reference
|
||||
* to this.
|
||||
*
|
||||
* The @a cookie is optional -- if non-NULL, it should be a
|
||||
* memory address that you own (that is, you know it is unique).
|
||||
*
|
||||
* @note You will only receive death notifications for remote binders,
|
||||
* as local binders by definition can't die without you dying as well.
|
||||
* Trying to use this function on a local binder will result in an
|
||||
* INVALID_OPERATION code being returned and nothing happening.
|
||||
*
|
||||
* @note This link always holds a weak reference to its recipient.
|
||||
*
|
||||
* @note You will only receive a weak reference to the dead
|
||||
* binder. You should not try to promote this to a strong reference.
|
||||
* (Nor should you need to, as there is nothing useful you can
|
||||
* directly do with it now that it has passed on.)
|
||||
*/
|
||||
virtual status_t linkToDeath(const sp<DeathRecipient>& recipient,
|
||||
void* cookie = NULL,
|
||||
uint32_t flags = 0) = 0;
|
||||
|
||||
/**
|
||||
* Remove a previously registered death notification.
|
||||
* The @a recipient will no longer be called if this object
|
||||
* dies. The @a cookie is optional. If non-NULL, you can
|
||||
* supply a NULL @a recipient, and the recipient previously
|
||||
* added with that cookie will be unlinked.
|
||||
*/
|
||||
virtual status_t unlinkToDeath( const wp<DeathRecipient>& recipient,
|
||||
void* cookie = NULL,
|
||||
uint32_t flags = 0,
|
||||
wp<DeathRecipient>* outRecipient = NULL) = 0;
|
||||
|
||||
virtual bool checkSubclass(const void* subclassID) const;
|
||||
|
||||
typedef void (*object_cleanup_func)(const void* id, void* obj, void* cleanupCookie);
|
||||
|
||||
virtual void attachObject( const void* objectID,
|
||||
void* object,
|
||||
void* cleanupCookie,
|
||||
object_cleanup_func func) = 0;
|
||||
virtual void* findObject(const void* objectID) const = 0;
|
||||
virtual void detachObject(const void* objectID) = 0;
|
||||
|
||||
virtual BBinder* localBinder();
|
||||
virtual BpBinder* remoteBinder();
|
||||
|
||||
protected:
|
||||
virtual ~IBinder();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}; // namespace android
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_IBINDER_H
|
|
@ -1,150 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_IINTERFACE_H
|
||||
#define ANDROID_IINTERFACE_H
|
||||
|
||||
#include <binder/Binder.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
class IInterface : public virtual RefBase
|
||||
{
|
||||
public:
|
||||
IInterface();
|
||||
sp<IBinder> asBinder();
|
||||
sp<const IBinder> asBinder() const;
|
||||
|
||||
protected:
|
||||
virtual ~IInterface();
|
||||
virtual IBinder* onAsBinder() = 0;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
template<typename INTERFACE>
|
||||
inline sp<INTERFACE> interface_cast(const sp<IBinder>& obj)
|
||||
{
|
||||
return INTERFACE::asInterface(obj);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
template<typename INTERFACE>
|
||||
class BnInterface : public INTERFACE, public BBinder
|
||||
{
|
||||
public:
|
||||
virtual sp<IInterface> queryLocalInterface(const String16& _descriptor);
|
||||
virtual const String16& getInterfaceDescriptor() const;
|
||||
|
||||
protected:
|
||||
virtual IBinder* onAsBinder();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
template<typename INTERFACE>
|
||||
class BpInterface : public INTERFACE, public BpRefBase
|
||||
{
|
||||
public:
|
||||
BpInterface(const sp<IBinder>& remote);
|
||||
|
||||
protected:
|
||||
virtual IBinder* onAsBinder();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#define DECLARE_META_INTERFACE(INTERFACE) \
|
||||
static const android::String16 descriptor; \
|
||||
static android::sp<I##INTERFACE> asInterface( \
|
||||
const android::sp<android::IBinder>& obj); \
|
||||
virtual const android::String16& getInterfaceDescriptor() const; \
|
||||
I##INTERFACE(); \
|
||||
virtual ~I##INTERFACE(); \
|
||||
|
||||
|
||||
#define IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \
|
||||
const android::String16 I##INTERFACE::descriptor(NAME); \
|
||||
const android::String16& \
|
||||
I##INTERFACE::getInterfaceDescriptor() const { \
|
||||
return I##INTERFACE::descriptor; \
|
||||
} \
|
||||
android::sp<I##INTERFACE> I##INTERFACE::asInterface( \
|
||||
const android::sp<android::IBinder>& obj) \
|
||||
{ \
|
||||
android::sp<I##INTERFACE> intr; \
|
||||
if (obj != NULL) { \
|
||||
intr = static_cast<I##INTERFACE*>( \
|
||||
obj->queryLocalInterface( \
|
||||
I##INTERFACE::descriptor).get()); \
|
||||
if (intr == NULL) { \
|
||||
intr = new Bp##INTERFACE(obj); \
|
||||
} \
|
||||
} \
|
||||
return intr; \
|
||||
} \
|
||||
I##INTERFACE::I##INTERFACE() { } \
|
||||
I##INTERFACE::~I##INTERFACE() { } \
|
||||
|
||||
|
||||
#define CHECK_INTERFACE(interface, data, reply) \
|
||||
if (!data.checkInterface(this)) { return PERMISSION_DENIED; } \
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// No user-serviceable parts after this...
|
||||
|
||||
template<typename INTERFACE>
|
||||
inline sp<IInterface> BnInterface<INTERFACE>::queryLocalInterface(
|
||||
const String16& _descriptor)
|
||||
{
|
||||
if (_descriptor == INTERFACE::descriptor) return this;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<typename INTERFACE>
|
||||
inline const String16& BnInterface<INTERFACE>::getInterfaceDescriptor() const
|
||||
{
|
||||
return INTERFACE::getInterfaceDescriptor();
|
||||
}
|
||||
|
||||
template<typename INTERFACE>
|
||||
IBinder* BnInterface<INTERFACE>::onAsBinder()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
template<typename INTERFACE>
|
||||
inline BpInterface<INTERFACE>::BpInterface(const sp<IBinder>& remote)
|
||||
: BpRefBase(remote)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename INTERFACE>
|
||||
inline IBinder* BpInterface<INTERFACE>::onAsBinder()
|
||||
{
|
||||
return remote();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_IINTERFACE_H
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007 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 ANDROID_CUTILS_ATOMIC_H
|
||||
#define ANDROID_CUTILS_ATOMIC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A handful of basic atomic operations. The appropriate pthread
|
||||
* functions should be used instead of these whenever possible.
|
||||
*
|
||||
* The "acquire" and "release" terms can be defined intuitively in terms
|
||||
* of the placement of memory barriers in a simple lock implementation:
|
||||
* - wait until compare-and-swap(lock-is-free --> lock-is-held) succeeds
|
||||
* - barrier
|
||||
* - [do work]
|
||||
* - barrier
|
||||
* - store(lock-is-free)
|
||||
* In very crude terms, the initial (acquire) barrier prevents any of the
|
||||
* "work" from happening before the lock is held, and the later (release)
|
||||
* barrier ensures that all of the work happens before the lock is released.
|
||||
* (Think of cached writes, cache read-ahead, and instruction reordering
|
||||
* around the CAS and store instructions.)
|
||||
*
|
||||
* The barriers must apply to both the compiler and the CPU. Note it is
|
||||
* legal for instructions that occur before an "acquire" barrier to be
|
||||
* moved down below it, and for instructions that occur after a "release"
|
||||
* barrier to be moved up above it.
|
||||
*
|
||||
* The ARM-driven implementation we use here is short on subtlety,
|
||||
* and actually requests a full barrier from the compiler and the CPU.
|
||||
* The only difference between acquire and release is in whether they
|
||||
* are issued before or after the atomic operation with which they
|
||||
* are associated. To ease the transition to C/C++ atomic intrinsics,
|
||||
* you should not rely on this, and instead assume that only the minimal
|
||||
* acquire/release protection is provided.
|
||||
*
|
||||
* NOTE: all int32_t* values are expected to be aligned on 32-bit boundaries.
|
||||
* If they are not, atomicity is not guaranteed.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Basic arithmetic and bitwise operations. These all provide a
|
||||
* barrier with "release" ordering, and return the previous value.
|
||||
*
|
||||
* These have the same characteristics (e.g. what happens on overflow)
|
||||
* as the equivalent non-atomic C operations.
|
||||
*/
|
||||
int32_t android_atomic_inc(volatile int32_t* addr);
|
||||
int32_t android_atomic_dec(volatile int32_t* addr);
|
||||
int32_t android_atomic_add(int32_t value, volatile int32_t* addr);
|
||||
int32_t android_atomic_and(int32_t value, volatile int32_t* addr);
|
||||
int32_t android_atomic_or(int32_t value, volatile int32_t* addr);
|
||||
|
||||
/*
|
||||
* Perform an atomic load with "acquire" or "release" ordering.
|
||||
*
|
||||
* This is only necessary if you need the memory barrier. A 32-bit read
|
||||
* from a 32-bit aligned address is atomic on all supported platforms.
|
||||
*/
|
||||
int32_t android_atomic_acquire_load(volatile const int32_t* addr);
|
||||
int32_t android_atomic_release_load(volatile const int32_t* addr);
|
||||
|
||||
/*
|
||||
* Perform an atomic store with "acquire" or "release" ordering.
|
||||
*
|
||||
* This is only necessary if you need the memory barrier. A 32-bit write
|
||||
* to a 32-bit aligned address is atomic on all supported platforms.
|
||||
*/
|
||||
void android_atomic_acquire_store(int32_t value, volatile int32_t* addr);
|
||||
void android_atomic_release_store(int32_t value, volatile int32_t* addr);
|
||||
|
||||
/*
|
||||
* Compare-and-set operation with "acquire" or "release" ordering.
|
||||
*
|
||||
* This returns zero if the new value was successfully stored, which will
|
||||
* only happen when *addr == oldvalue.
|
||||
*
|
||||
* (The return value is inverted from implementations on other platforms,
|
||||
* but matches the ARM ldrex/strex result.)
|
||||
*
|
||||
* Implementations that use the release CAS in a loop may be less efficient
|
||||
* than possible, because we re-issue the memory barrier on each iteration.
|
||||
*/
|
||||
int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue,
|
||||
volatile int32_t* addr);
|
||||
int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue,
|
||||
volatile int32_t* addr);
|
||||
|
||||
/*
|
||||
* Aliases for code using an older version of this header. These are now
|
||||
* deprecated and should not be used. The definitions will be removed
|
||||
* in a future release.
|
||||
*/
|
||||
#define android_atomic_write android_atomic_release_store
|
||||
#define android_atomic_cmpxchg android_atomic_release_cas
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // ANDROID_CUTILS_ATOMIC_H
|
|
@ -1,482 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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.
|
||||
*/
|
||||
|
||||
//
|
||||
// C/C++ logging functions. See the logging documentation for API details.
|
||||
//
|
||||
// We'd like these to be available from C code (in case we import some from
|
||||
// somewhere), so this has a C interface.
|
||||
//
|
||||
// The output will be correct when the log file is shared between multiple
|
||||
// threads and/or multiple processes so long as the operating system
|
||||
// supports O_APPEND. These calls have mutex-protected data structures
|
||||
// and so are NOT reentrant. Do not use LOG in a signal handler.
|
||||
//
|
||||
#ifndef _LIBS_CUTILS_LOG_H
|
||||
#define _LIBS_CUTILS_LOG_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_PTHREADS
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <cutils/uio.h>
|
||||
#include <cutils/logd.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Normally we strip LOGV (VERBOSE messages) from release builds.
|
||||
* You can modify this (for example with "#define LOG_NDEBUG 0"
|
||||
* at the top of your source file) to change that behavior.
|
||||
*/
|
||||
#ifndef LOG_NDEBUG
|
||||
#ifdef NDEBUG
|
||||
#define LOG_NDEBUG 1
|
||||
#else
|
||||
#define LOG_NDEBUG 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This is the local tag used for the following simplified
|
||||
* logging macros. You can change this preprocessor definition
|
||||
* before using the other macros to change the tag.
|
||||
*/
|
||||
#ifndef LOG_TAG
|
||||
#define LOG_TAG NULL
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Simplified macro to send a verbose log message using the current LOG_TAG.
|
||||
*/
|
||||
#ifndef LOGV
|
||||
#if LOG_NDEBUG
|
||||
#define LOGV(...) ((void)0)
|
||||
#else
|
||||
#define LOGV(...) ((void)LOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
|
||||
|
||||
#ifndef LOGV_IF
|
||||
#if LOG_NDEBUG
|
||||
#define LOGV_IF(cond, ...) ((void)0)
|
||||
#else
|
||||
#define LOGV_IF(cond, ...) \
|
||||
( (CONDITION(cond)) \
|
||||
? ((void)LOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
|
||||
: (void)0 )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Simplified macro to send a debug log message using the current LOG_TAG.
|
||||
*/
|
||||
#ifndef LOGD
|
||||
#define LOGD(...) ((void)LOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef LOGD_IF
|
||||
#define LOGD_IF(cond, ...) \
|
||||
( (CONDITION(cond)) \
|
||||
? ((void)LOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
|
||||
: (void)0 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Simplified macro to send an info log message using the current LOG_TAG.
|
||||
*/
|
||||
#ifndef LOGI
|
||||
#define LOGI(...) ((void)LOG(LOG_INFO, LOG_TAG, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef LOGI_IF
|
||||
#define LOGI_IF(cond, ...) \
|
||||
( (CONDITION(cond)) \
|
||||
? ((void)LOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \
|
||||
: (void)0 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Simplified macro to send a warning log message using the current LOG_TAG.
|
||||
*/
|
||||
#ifndef LOGW
|
||||
#define LOGW(...) ((void)LOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef LOGW_IF
|
||||
#define LOGW_IF(cond, ...) \
|
||||
( (CONDITION(cond)) \
|
||||
? ((void)LOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \
|
||||
: (void)0 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Simplified macro to send an error log message using the current LOG_TAG.
|
||||
*/
|
||||
#ifndef LOGE
|
||||
#define LOGE(...) ((void)LOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef LOGE_IF
|
||||
#define LOGE_IF(cond, ...) \
|
||||
( (CONDITION(cond)) \
|
||||
? ((void)LOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
|
||||
: (void)0 )
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Conditional based on whether the current LOG_TAG is enabled at
|
||||
* verbose priority.
|
||||
*/
|
||||
#ifndef IF_LOGV
|
||||
#if LOG_NDEBUG
|
||||
#define IF_LOGV() if (false)
|
||||
#else
|
||||
#define IF_LOGV() IF_LOG(LOG_VERBOSE, LOG_TAG)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Conditional based on whether the current LOG_TAG is enabled at
|
||||
* debug priority.
|
||||
*/
|
||||
#ifndef IF_LOGD
|
||||
#define IF_LOGD() IF_LOG(LOG_DEBUG, LOG_TAG)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Conditional based on whether the current LOG_TAG is enabled at
|
||||
* info priority.
|
||||
*/
|
||||
#ifndef IF_LOGI
|
||||
#define IF_LOGI() IF_LOG(LOG_INFO, LOG_TAG)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Conditional based on whether the current LOG_TAG is enabled at
|
||||
* warn priority.
|
||||
*/
|
||||
#ifndef IF_LOGW
|
||||
#define IF_LOGW() IF_LOG(LOG_WARN, LOG_TAG)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Conditional based on whether the current LOG_TAG is enabled at
|
||||
* error priority.
|
||||
*/
|
||||
#ifndef IF_LOGE
|
||||
#define IF_LOGE() IF_LOG(LOG_ERROR, LOG_TAG)
|
||||
#endif
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Simplified macro to send a verbose system log message using the current LOG_TAG.
|
||||
*/
|
||||
#ifndef SLOGV
|
||||
#if LOG_NDEBUG
|
||||
#define SLOGV(...) ((void)0)
|
||||
#else
|
||||
#define SLOGV(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
|
||||
|
||||
#ifndef SLOGV_IF
|
||||
#if LOG_NDEBUG
|
||||
#define SLOGV_IF(cond, ...) ((void)0)
|
||||
#else
|
||||
#define SLOGV_IF(cond, ...) \
|
||||
( (CONDITION(cond)) \
|
||||
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
|
||||
: (void)0 )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Simplified macro to send a debug system log message using the current LOG_TAG.
|
||||
*/
|
||||
#ifndef SLOGD
|
||||
#define SLOGD(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef SLOGD_IF
|
||||
#define SLOGD_IF(cond, ...) \
|
||||
( (CONDITION(cond)) \
|
||||
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
|
||||
: (void)0 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Simplified macro to send an info system log message using the current LOG_TAG.
|
||||
*/
|
||||
#ifndef SLOGI
|
||||
#define SLOGI(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef SLOGI_IF
|
||||
#define SLOGI_IF(cond, ...) \
|
||||
( (CONDITION(cond)) \
|
||||
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
|
||||
: (void)0 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Simplified macro to send a warning system log message using the current LOG_TAG.
|
||||
*/
|
||||
#ifndef SLOGW
|
||||
#define SLOGW(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef SLOGW_IF
|
||||
#define SLOGW_IF(cond, ...) \
|
||||
( (CONDITION(cond)) \
|
||||
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
|
||||
: (void)0 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Simplified macro to send an error system log message using the current LOG_TAG.
|
||||
*/
|
||||
#ifndef SLOGE
|
||||
#define SLOGE(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
|
||||
#endif
|
||||
|
||||
#ifndef SLOGE_IF
|
||||
#define SLOGE_IF(cond, ...) \
|
||||
( (CONDITION(cond)) \
|
||||
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
|
||||
: (void)0 )
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Log a fatal error. If the given condition fails, this stops program
|
||||
* execution like a normal assertion, but also generating the given message.
|
||||
* It is NOT stripped from release builds. Note that the condition test
|
||||
* is -inverted- from the normal assert() semantics.
|
||||
*/
|
||||
#ifndef LOG_ALWAYS_FATAL_IF
|
||||
#define LOG_ALWAYS_FATAL_IF(cond, ...) \
|
||||
( (CONDITION(cond)) \
|
||||
? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \
|
||||
: (void)0 )
|
||||
#endif
|
||||
|
||||
#ifndef LOG_ALWAYS_FATAL
|
||||
#define LOG_ALWAYS_FATAL(...) \
|
||||
( ((void)android_printAssert(NULL, LOG_TAG, ## __VA_ARGS__)) )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that
|
||||
* are stripped out of release builds.
|
||||
*/
|
||||
#if LOG_NDEBUG
|
||||
|
||||
#ifndef LOG_FATAL_IF
|
||||
#define LOG_FATAL_IF(cond, ...) ((void)0)
|
||||
#endif
|
||||
#ifndef LOG_FATAL
|
||||
#define LOG_FATAL(...) ((void)0)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifndef LOG_FATAL_IF
|
||||
#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ## __VA_ARGS__)
|
||||
#endif
|
||||
#ifndef LOG_FATAL
|
||||
#define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Assertion that generates a log message when the assertion fails.
|
||||
* Stripped out of release builds. Uses the current LOG_TAG.
|
||||
*/
|
||||
#ifndef LOG_ASSERT
|
||||
#define LOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__)
|
||||
//#define LOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond)
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Basic log message macro.
|
||||
*
|
||||
* Example:
|
||||
* LOG(LOG_WARN, NULL, "Failed with error %d", errno);
|
||||
*
|
||||
* The second argument may be NULL or "" to indicate the "global" tag.
|
||||
*/
|
||||
#ifndef LOG
|
||||
#define LOG(priority, tag, ...) \
|
||||
LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Log macro that allows you to specify a number for the priority.
|
||||
*/
|
||||
#ifndef LOG_PRI
|
||||
#define LOG_PRI(priority, tag, ...) \
|
||||
android_printLog(priority, tag, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Log macro that allows you to pass in a varargs ("args" is a va_list).
|
||||
*/
|
||||
#ifndef LOG_PRI_VA
|
||||
#define LOG_PRI_VA(priority, tag, fmt, args) \
|
||||
android_vprintLog(priority, NULL, tag, fmt, args)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Conditional given a desired logging priority and tag.
|
||||
*/
|
||||
#ifndef IF_LOG
|
||||
#define IF_LOG(priority, tag) \
|
||||
if (android_testLog(ANDROID_##priority, tag))
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Event logging.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Event log entry types. These must match up with the declarations in
|
||||
* java/android/android/util/EventLog.java.
|
||||
*/
|
||||
typedef enum {
|
||||
EVENT_TYPE_INT = 0,
|
||||
EVENT_TYPE_LONG = 1,
|
||||
EVENT_TYPE_STRING = 2,
|
||||
EVENT_TYPE_LIST = 3,
|
||||
} AndroidEventLogType;
|
||||
|
||||
|
||||
#ifndef LOG_EVENT_INT
|
||||
#define LOG_EVENT_INT(_tag, _value) { \
|
||||
int intBuf = _value; \
|
||||
(void) android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, \
|
||||
sizeof(intBuf)); \
|
||||
}
|
||||
#endif
|
||||
#ifndef LOG_EVENT_LONG
|
||||
#define LOG_EVENT_LONG(_tag, _value) { \
|
||||
long long longBuf = _value; \
|
||||
(void) android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, \
|
||||
sizeof(longBuf)); \
|
||||
}
|
||||
#endif
|
||||
#ifndef LOG_EVENT_STRING
|
||||
#define LOG_EVENT_STRING(_tag, _value) \
|
||||
((void) 0) /* not implemented -- must combine len with string */
|
||||
#endif
|
||||
/* TODO: something for LIST */
|
||||
|
||||
/*
|
||||
* ===========================================================================
|
||||
*
|
||||
* The stuff in the rest of this file should not be used directly.
|
||||
*/
|
||||
|
||||
#define android_printLog(prio, tag, fmt...) \
|
||||
__android_log_print(prio, tag, fmt)
|
||||
|
||||
#define android_vprintLog(prio, cond, tag, fmt...) \
|
||||
__android_log_vprint(prio, tag, fmt)
|
||||
|
||||
/* XXX Macros to work around syntax errors in places where format string
|
||||
* arg is not passed to LOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF
|
||||
* (happens only in debug builds).
|
||||
*/
|
||||
|
||||
/* Returns 2nd arg. Used to substitute default value if caller's vararg list
|
||||
* is empty.
|
||||
*/
|
||||
#define __android_second(dummy, second, ...) second
|
||||
|
||||
/* If passed multiple args, returns ',' followed by all but 1st arg, otherwise
|
||||
* returns nothing.
|
||||
*/
|
||||
#define __android_rest(first, ...) , ## __VA_ARGS__
|
||||
|
||||
#define android_printAssert(cond, tag, fmt...) \
|
||||
__android_log_assert(cond, tag, \
|
||||
__android_second(0, ## fmt, NULL) __android_rest(fmt))
|
||||
|
||||
#define android_writeLog(prio, tag, text) \
|
||||
__android_log_write(prio, tag, text)
|
||||
|
||||
#define android_bWriteLog(tag, payload, len) \
|
||||
__android_log_bwrite(tag, payload, len)
|
||||
#define android_btWriteLog(tag, type, payload, len) \
|
||||
__android_log_btwrite(tag, type, payload, len)
|
||||
|
||||
// TODO: remove these prototypes and their users
|
||||
#define android_testLog(prio, tag) (1)
|
||||
#define android_writevLog(vec,num) do{}while(0)
|
||||
#define android_write1Log(str,len) do{}while (0)
|
||||
#define android_setMinPriority(tag, prio) do{}while(0)
|
||||
//#define android_logToCallback(func) do{}while(0)
|
||||
#define android_logToFile(tag, file) (0)
|
||||
#define android_logToFd(tag, fd) (0)
|
||||
|
||||
typedef enum {
|
||||
LOG_ID_MAIN = 0,
|
||||
LOG_ID_RADIO = 1,
|
||||
LOG_ID_EVENTS = 2,
|
||||
LOG_ID_SYSTEM = 3,
|
||||
|
||||
LOG_ID_MAX
|
||||
} log_id_t;
|
||||
|
||||
/*
|
||||
* Send a simple string to the log.
|
||||
*/
|
||||
int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text);
|
||||
int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _LIBS_CUTILS_LOG_H
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* 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 _ANDROID_CUTILS_LOGD_H
|
||||
#define _ANDROID_CUTILS_LOGD_H
|
||||
|
||||
/* the stable/frozen log-related definitions have been
|
||||
* moved to this header, which is exposed by the NDK
|
||||
*/
|
||||
#include <android/log.h>
|
||||
|
||||
/* the rest is only used internally by the system */
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_PTHREADS
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <cutils/uio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int __android_log_bwrite(int32_t tag, const void *payload, size_t len);
|
||||
int __android_log_btwrite(int32_t tag, char type, const void *payload,
|
||||
size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _LOGD_H */
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* 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 NATIVE_HANDLE_H_
|
||||
#define NATIVE_HANDLE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct native_handle
|
||||
{
|
||||
int version; /* sizeof(native_handle_t) */
|
||||
int numFds; /* number of file-descriptors at &data[0] */
|
||||
int numInts; /* number of ints at &data[numFds] */
|
||||
int data[0]; /* numFds + numInts ints */
|
||||
} native_handle_t;
|
||||
|
||||
/*
|
||||
* native_handle_close
|
||||
*
|
||||
* closes the file descriptors contained in this native_handle_t
|
||||
*
|
||||
* return 0 on success, or a negative error code on failure
|
||||
*
|
||||
*/
|
||||
int native_handle_close(const native_handle_t* h);
|
||||
|
||||
|
||||
/*
|
||||
* native_handle_create
|
||||
*
|
||||
* creates a native_handle_t and initializes it. must be destroyed with
|
||||
* native_handle_delete().
|
||||
*
|
||||
*/
|
||||
native_handle_t* native_handle_create(int numFds, int numInts);
|
||||
|
||||
/*
|
||||
* native_handle_delete
|
||||
*
|
||||
* frees a native_handle_t allocated with native_handle_create().
|
||||
* This ONLY frees the memory allocated for the native_handle_t, but doesn't
|
||||
* close the file descriptors; which can be achieved with native_handle_close().
|
||||
*
|
||||
* return 0 on success, or a negative error code on failure
|
||||
*
|
||||
*/
|
||||
int native_handle_delete(native_handle_t* h);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NATIVE_HANDLE_H_ */
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007 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.
|
||||
*/
|
||||
|
||||
//
|
||||
// implementation of sys/uio.h for platforms that don't have it (Win32)
|
||||
//
|
||||
#ifndef _LIBS_CUTILS_UIO_H
|
||||
#define _LIBS_CUTILS_UIO_H
|
||||
|
||||
#ifdef HAVE_SYS_UIO_H
|
||||
#include <sys/uio.h>
|
||||
#else
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct iovec {
|
||||
const void* iov_base;
|
||||
size_t iov_len;
|
||||
};
|
||||
|
||||
extern int readv( int fd, struct iovec* vecs, int count );
|
||||
extern int writev( int fd, const struct iovec* vecs, int count );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !HAVE_SYS_UIO_H */
|
||||
|
||||
#endif /* _LIBS_UTILS_UIO_H */
|
||||
|
|
@ -1,377 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 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 __DRM_MANAGER_CLIENT_H__
|
||||
#define __DRM_MANAGER_CLIENT_H__
|
||||
|
||||
#include <utils/threads.h>
|
||||
#include <binder/IInterface.h>
|
||||
#include "drm_framework_common.h"
|
||||
|
||||
namespace android {
|
||||
|
||||
class DrmInfo;
|
||||
class DrmRights;
|
||||
class DrmMetadata;
|
||||
class DrmInfoEvent;
|
||||
class DrmInfoStatus;
|
||||
class DrmInfoRequest;
|
||||
class DrmSupportInfo;
|
||||
class DrmConstraints;
|
||||
class DrmConvertedStatus;
|
||||
class DrmManagerClientImpl;
|
||||
|
||||
/**
|
||||
* The Native application will instantiate this class and access DRM Framework
|
||||
* services through this class.
|
||||
*
|
||||
*/
|
||||
class DrmManagerClient {
|
||||
public:
|
||||
DrmManagerClient();
|
||||
|
||||
virtual ~DrmManagerClient();
|
||||
|
||||
public:
|
||||
class OnInfoListener: virtual public RefBase {
|
||||
|
||||
public:
|
||||
virtual ~OnInfoListener() {}
|
||||
|
||||
public:
|
||||
virtual void onInfo(const DrmInfoEvent& event) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* APIs which will be used by native modules (e.g. StageFright)
|
||||
*
|
||||
*/
|
||||
public:
|
||||
/**
|
||||
* Open the decrypt session to decrypt the given protected content
|
||||
*
|
||||
* @param[in] fd File descriptor of the protected content to be decrypted
|
||||
* @param[in] offset Start position of the content
|
||||
* @param[in] length The length of the protected content
|
||||
* @return
|
||||
* Handle for the decryption session
|
||||
*/
|
||||
sp<DecryptHandle> openDecryptSession(int fd, off64_t offset, off64_t length);
|
||||
|
||||
/**
|
||||
* Open the decrypt session to decrypt the given protected content
|
||||
*
|
||||
* @param[in] uri Path of the protected content to be decrypted
|
||||
* @return
|
||||
* Handle for the decryption session
|
||||
*/
|
||||
sp<DecryptHandle> openDecryptSession(const char* uri);
|
||||
|
||||
/**
|
||||
* Close the decrypt session for the given handle
|
||||
*
|
||||
* @param[in] decryptHandle Handle for the decryption session
|
||||
* @return status_t
|
||||
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||
*/
|
||||
status_t closeDecryptSession(sp<DecryptHandle> &decryptHandle);
|
||||
|
||||
/**
|
||||
* Consumes the rights for a content.
|
||||
* If the reserve parameter is true the rights is reserved until the same
|
||||
* application calls this api again with the reserve parameter set to false.
|
||||
*
|
||||
* @param[in] decryptHandle Handle for the decryption session
|
||||
* @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc)
|
||||
* @param[in] reserve True if the rights should be reserved.
|
||||
* @return status_t
|
||||
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure.
|
||||
* In case license has been expired, DRM_ERROR_LICENSE_EXPIRED will be returned.
|
||||
*/
|
||||
status_t consumeRights(sp<DecryptHandle> &decryptHandle, int action, bool reserve);
|
||||
|
||||
/**
|
||||
* Informs the DRM engine about the playback actions performed on the DRM files.
|
||||
*
|
||||
* @param[in] decryptHandle Handle for the decryption session
|
||||
* @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE)
|
||||
* @param[in] position Position in the file (in milliseconds) where the start occurs.
|
||||
* Only valid together with Playback::START.
|
||||
* @return status_t
|
||||
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||
*/
|
||||
status_t setPlaybackStatus(
|
||||
sp<DecryptHandle> &decryptHandle, int playbackStatus, int64_t position);
|
||||
|
||||
/**
|
||||
* Initialize decryption for the given unit of the protected content
|
||||
*
|
||||
* @param[in] decryptHandle Handle for the decryption session
|
||||
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
||||
* @param[in] headerInfo Information for initializing decryption of this decrypUnit
|
||||
* @return status_t
|
||||
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||
*/
|
||||
status_t initializeDecryptUnit(
|
||||
sp<DecryptHandle> &decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo);
|
||||
|
||||
/**
|
||||
* Decrypt the protected content buffers for the given unit
|
||||
* This method will be called any number of times, based on number of
|
||||
* encrypted streams received from application.
|
||||
*
|
||||
* @param[in] decryptHandle Handle for the decryption session
|
||||
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
||||
* @param[in] encBuffer Encrypted data block
|
||||
* @param[out] decBuffer Decrypted data block
|
||||
* @param[in] IV Optional buffer
|
||||
* @return status_t
|
||||
* Returns the error code for this API
|
||||
* DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED
|
||||
* DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
|
||||
* DRM_ERROR_DECRYPT for failure.
|
||||
*/
|
||||
status_t decrypt(
|
||||
sp<DecryptHandle> &decryptHandle, int decryptUnitId,
|
||||
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV = NULL);
|
||||
|
||||
/**
|
||||
* Finalize decryption for the given unit of the protected content
|
||||
*
|
||||
* @param[in] decryptHandle Handle for the decryption session
|
||||
* @param[in] decryptUnitId ID which specifies decryption unit, such as track ID
|
||||
* @return status_t
|
||||
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||
*/
|
||||
status_t finalizeDecryptUnit(
|
||||
sp<DecryptHandle> &decryptHandle, int decryptUnitId);
|
||||
|
||||
/**
|
||||
* Reads the specified number of bytes from an open DRM file.
|
||||
*
|
||||
* @param[in] decryptHandle Handle for the decryption session
|
||||
* @param[out] buffer Reference to the buffer that should receive the read data.
|
||||
* @param[in] numBytes Number of bytes to read.
|
||||
* @param[in] offset Offset with which to update the file position.
|
||||
*
|
||||
* @return Number of bytes read. Returns -1 for Failure.
|
||||
*/
|
||||
ssize_t pread(sp<DecryptHandle> &decryptHandle,
|
||||
void* buffer, ssize_t numBytes, off64_t offset);
|
||||
|
||||
/**
|
||||
* Validates whether an action on the DRM content is allowed or not.
|
||||
*
|
||||
* @param[in] path Path of the protected content
|
||||
* @param[in] action Action to validate. (Action::DEFAULT, Action::PLAY, etc)
|
||||
* @param[in] description Detailed description of the action
|
||||
* @return true if the action is allowed.
|
||||
*/
|
||||
bool validateAction(const String8& path, int action, const ActionDescription& description);
|
||||
|
||||
/**
|
||||
* APIs which are just the underlying implementation for the Java API
|
||||
*
|
||||
*/
|
||||
public:
|
||||
/**
|
||||
* Register a callback to be invoked when the caller required to
|
||||
* receive necessary information
|
||||
*
|
||||
* @param[in] infoListener Listener
|
||||
* @return status_t
|
||||
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||
*/
|
||||
status_t setOnInfoListener(const sp<DrmManagerClient::OnInfoListener>& infoListener);
|
||||
|
||||
/**
|
||||
* Get constraint information associated with input content
|
||||
*
|
||||
* @param[in] path Path of the protected content
|
||||
* @param[in] action Actions defined such as,
|
||||
* Action::DEFAULT, Action::PLAY, etc
|
||||
* @return DrmConstraints
|
||||
* key-value pairs of constraint are embedded in it
|
||||
* @note
|
||||
* In case of error, return NULL
|
||||
*/
|
||||
DrmConstraints* getConstraints(const String8* path, const int action);
|
||||
|
||||
/**
|
||||
* Get metadata information associated with input content
|
||||
*
|
||||
* @param[in] path Path of the protected content
|
||||
* @return DrmMetadata
|
||||
* key-value pairs of metadata
|
||||
* @note
|
||||
* In case of error, return NULL
|
||||
*/
|
||||
DrmMetadata* getMetadata(const String8* path);
|
||||
|
||||
/**
|
||||
* Check whether the given mimetype or path can be handled
|
||||
*
|
||||
* @param[in] path Path of the content needs to be handled
|
||||
* @param[in] mimetype Mimetype of the content needs to be handled
|
||||
* @return
|
||||
* True if DrmManager can handle given path or mime type.
|
||||
*/
|
||||
bool canHandle(const String8& path, const String8& mimeType);
|
||||
|
||||
/**
|
||||
* Executes given drm information based on its type
|
||||
*
|
||||
* @param[in] drmInfo Information needs to be processed
|
||||
* @return DrmInfoStatus
|
||||
* instance as a result of processing given input
|
||||
*/
|
||||
DrmInfoStatus* processDrmInfo(const DrmInfo* drmInfo);
|
||||
|
||||
/**
|
||||
* Retrieves necessary information for registration, unregistration or rights
|
||||
* acquisition information.
|
||||
*
|
||||
* @param[in] drmInfoRequest Request information to retrieve drmInfo
|
||||
* @return DrmInfo
|
||||
* instance as a result of processing given input
|
||||
*/
|
||||
DrmInfo* acquireDrmInfo(const DrmInfoRequest* drmInfoRequest);
|
||||
|
||||
/**
|
||||
* Save DRM rights to specified rights path
|
||||
* and make association with content path
|
||||
*
|
||||
* @param[in] drmRights DrmRights to be saved
|
||||
* @param[in] rightsPath File path where rights to be saved
|
||||
* @param[in] contentPath File path where content was saved
|
||||
* @return status_t
|
||||
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||
*/
|
||||
status_t saveRights(
|
||||
const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath);
|
||||
|
||||
/**
|
||||
* Retrieves the mime type embedded inside the original content
|
||||
*
|
||||
* @param[in] path the path of the protected content
|
||||
* @return String8
|
||||
* Returns mime-type of the original content, such as "video/mpeg"
|
||||
*/
|
||||
String8 getOriginalMimeType(const String8& path);
|
||||
|
||||
/**
|
||||
* Retrieves the type of the protected object (content, rights, etc..)
|
||||
* by using specified path or mimetype. At least one parameter should be non null
|
||||
* to retrieve DRM object type
|
||||
*
|
||||
* @param[in] path Path of the content or null.
|
||||
* @param[in] mimeType Mime type of the content or null.
|
||||
* @return type of the DRM content,
|
||||
* such as DrmObjectType::CONTENT, DrmObjectType::RIGHTS_OBJECT
|
||||
*/
|
||||
int getDrmObjectType(const String8& path, const String8& mimeType);
|
||||
|
||||
/**
|
||||
* Check whether the given content has valid rights or not
|
||||
*
|
||||
* @param[in] path Path of the protected content
|
||||
* @param[in] action Action to perform
|
||||
* @return the status of the rights for the protected content,
|
||||
* such as RightsStatus::RIGHTS_VALID, RightsStatus::RIGHTS_EXPIRED, etc.
|
||||
*/
|
||||
int checkRightsStatus(const String8& path, int action);
|
||||
|
||||
/**
|
||||
* Removes the rights associated with the given protected content
|
||||
*
|
||||
* @param[in] path Path of the protected content
|
||||
* @return status_t
|
||||
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||
*/
|
||||
status_t removeRights(const String8& path);
|
||||
|
||||
/**
|
||||
* Removes all the rights information of each plug-in associated with
|
||||
* DRM framework. Will be used in master reset
|
||||
*
|
||||
* @return status_t
|
||||
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||
*/
|
||||
status_t removeAllRights();
|
||||
|
||||
/**
|
||||
* This API is for Forward Lock DRM.
|
||||
* Each time the application tries to download a new DRM file
|
||||
* which needs to be converted, then the application has to
|
||||
* begin with calling this API.
|
||||
*
|
||||
* @param[in] convertId Handle for the convert session
|
||||
* @param[in] mimeType Description/MIME type of the input data packet
|
||||
* @return Return handle for the convert session
|
||||
*/
|
||||
int openConvertSession(const String8& mimeType);
|
||||
|
||||
/**
|
||||
* Passes the input data which need to be converted. The resultant
|
||||
* converted data and the status is returned in the DrmConvertedInfo
|
||||
* object. This method will be called each time there are new block
|
||||
* of data received by the application.
|
||||
*
|
||||
* @param[in] convertId Handle for the convert session
|
||||
* @param[in] inputData Input Data which need to be converted
|
||||
* @return Return object contains the status of the data conversion,
|
||||
* the output converted data and offset. In this case the
|
||||
* application will ignore the offset information.
|
||||
*/
|
||||
DrmConvertedStatus* convertData(int convertId, const DrmBuffer* inputData);
|
||||
|
||||
/**
|
||||
* When there is no more data which need to be converted or when an
|
||||
* error occurs that time the application has to inform the Drm agent
|
||||
* via this API. Upon successful conversion of the complete data,
|
||||
* the agent will inform that where the header and body signature
|
||||
* should be added. This signature appending is needed to integrity
|
||||
* protect the converted file.
|
||||
*
|
||||
* @param[in] convertId Handle for the convert session
|
||||
* @return Return object contains the status of the data conversion,
|
||||
* the header and body signature data. It also informs
|
||||
* the application on which offset these signature data
|
||||
* should be appended.
|
||||
*/
|
||||
DrmConvertedStatus* closeConvertSession(int convertId);
|
||||
|
||||
/**
|
||||
* Retrieves all DrmSupportInfo instance that native DRM framework can handle.
|
||||
* This interface is meant to be used by JNI layer
|
||||
*
|
||||
* @param[out] length Number of elements in drmSupportInfoArray
|
||||
* @param[out] drmSupportInfoArray Array contains all DrmSupportInfo
|
||||
* that native DRM framework can handle
|
||||
* @return status_t
|
||||
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
|
||||
*/
|
||||
status_t getAllSupportInfo(int* length, DrmSupportInfo** drmSupportInfoArray);
|
||||
|
||||
private:
|
||||
int mUniqueId;
|
||||
sp<DrmManagerClientImpl> mDrmManagerClientImpl;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif /* __DRM_MANAGER_CLIENT_H__ */
|
||||
|
|
@ -1,336 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 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 __DRM_FRAMEWORK_COMMON_H__
|
||||
#define __DRM_FRAMEWORK_COMMON_H__
|
||||
|
||||
#include <utils/Vector.h>
|
||||
#include <utils/KeyedVector.h>
|
||||
#include <utils/RefBase.h>
|
||||
#include <utils/String8.h>
|
||||
#include <utils/Errors.h>
|
||||
|
||||
#define INVALID_VALUE -1
|
||||
|
||||
namespace android {
|
||||
|
||||
/**
|
||||
* Error code for DRM Frameowrk
|
||||
*/
|
||||
enum {
|
||||
// The following constant values should be in sync with
|
||||
// media/stagefright/MediaErrors.h
|
||||
ERROR_BASE = -2000,
|
||||
|
||||
DRM_ERROR_UNKNOWN = ERROR_BASE,
|
||||
DRM_ERROR_NO_LICENSE = ERROR_BASE - 1,
|
||||
DRM_ERROR_LICENSE_EXPIRED = ERROR_BASE - 2,
|
||||
DRM_ERROR_SESSION_NOT_OPENED = ERROR_BASE - 3,
|
||||
DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED = ERROR_BASE - 4,
|
||||
DRM_ERROR_DECRYPT = ERROR_BASE - 5,
|
||||
DRM_ERROR_CANNOT_HANDLE = ERROR_BASE - 6,
|
||||
DRM_ERROR_TAMPER_DETECTED = ERROR_BASE - 7,
|
||||
|
||||
DRM_NO_ERROR = NO_ERROR
|
||||
};
|
||||
|
||||
/**
|
||||
* copy control settings used in DecryptHandle::copyControlVector
|
||||
*/
|
||||
enum DrmCopyControl {
|
||||
DRM_COPY_CONTROL_BASE = 1000,
|
||||
// the key used to set the value for HDCP
|
||||
// if the associated value is 1, then HDCP is required
|
||||
// otherwise, HDCP is not required
|
||||
DRM_COPY_CONTROL_HDCP = DRM_COPY_CONTROL_BASE
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines DRM Buffer
|
||||
*/
|
||||
class DrmBuffer {
|
||||
public:
|
||||
char* data;
|
||||
int length;
|
||||
|
||||
DrmBuffer() :
|
||||
data(NULL),
|
||||
length(0) {
|
||||
}
|
||||
|
||||
DrmBuffer(char* dataBytes, int dataLength) :
|
||||
data(dataBytes),
|
||||
length(dataLength) {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines detailed description of the action
|
||||
*/
|
||||
class ActionDescription {
|
||||
public:
|
||||
ActionDescription(int _outputType, int _configuration) :
|
||||
outputType(_outputType),
|
||||
configuration(_configuration) {
|
||||
}
|
||||
|
||||
public:
|
||||
int outputType; /* BLUETOOTH , HDMI*/
|
||||
int configuration; /* RESOLUTION_720_480 , RECORDABLE etc.*/
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines constants related to DRM types
|
||||
*/
|
||||
class DrmObjectType {
|
||||
private:
|
||||
DrmObjectType();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Field specifies the unknown type
|
||||
*/
|
||||
static const int UNKNOWN = 0x00;
|
||||
/**
|
||||
* Field specifies the protected content type
|
||||
*/
|
||||
static const int CONTENT = 0x01;
|
||||
/**
|
||||
* Field specifies the rights information
|
||||
*/
|
||||
static const int RIGHTS_OBJECT = 0x02;
|
||||
/**
|
||||
* Field specifies the trigger information
|
||||
*/
|
||||
static const int TRIGGER_OBJECT = 0x03;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines constants related to play back
|
||||
*/
|
||||
class Playback {
|
||||
private:
|
||||
Playback();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constant field signifies playback start
|
||||
*/
|
||||
static const int START = 0x00;
|
||||
/**
|
||||
* Constant field signifies playback stop
|
||||
*/
|
||||
static const int STOP = 0x01;
|
||||
/**
|
||||
* Constant field signifies playback paused
|
||||
*/
|
||||
static const int PAUSE = 0x02;
|
||||
/**
|
||||
* Constant field signifies playback resumed
|
||||
*/
|
||||
static const int RESUME = 0x03;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines actions that can be performed on protected content
|
||||
*/
|
||||
class Action {
|
||||
private:
|
||||
Action();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constant field signifies that the default action
|
||||
*/
|
||||
static const int DEFAULT = 0x00;
|
||||
/**
|
||||
* Constant field signifies that the content can be played
|
||||
*/
|
||||
static const int PLAY = 0x01;
|
||||
/**
|
||||
* Constant field signifies that the content can be set as ring tone
|
||||
*/
|
||||
static const int RINGTONE = 0x02;
|
||||
/**
|
||||
* Constant field signifies that the content can be transfered
|
||||
*/
|
||||
static const int TRANSFER = 0x03;
|
||||
/**
|
||||
* Constant field signifies that the content can be set as output
|
||||
*/
|
||||
static const int OUTPUT = 0x04;
|
||||
/**
|
||||
* Constant field signifies that preview is allowed
|
||||
*/
|
||||
static const int PREVIEW = 0x05;
|
||||
/**
|
||||
* Constant field signifies that the content can be executed
|
||||
*/
|
||||
static const int EXECUTE = 0x06;
|
||||
/**
|
||||
* Constant field signifies that the content can displayed
|
||||
*/
|
||||
static const int DISPLAY = 0x07;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines constants related to status of the rights
|
||||
*/
|
||||
class RightsStatus {
|
||||
private:
|
||||
RightsStatus();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constant field signifies that the rights are valid
|
||||
*/
|
||||
static const int RIGHTS_VALID = 0x00;
|
||||
/**
|
||||
* Constant field signifies that the rights are invalid
|
||||
*/
|
||||
static const int RIGHTS_INVALID = 0x01;
|
||||
/**
|
||||
* Constant field signifies that the rights are expired for the content
|
||||
*/
|
||||
static const int RIGHTS_EXPIRED = 0x02;
|
||||
/**
|
||||
* Constant field signifies that the rights are not acquired for the content
|
||||
*/
|
||||
static const int RIGHTS_NOT_ACQUIRED = 0x03;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines API set for decryption
|
||||
*/
|
||||
class DecryptApiType {
|
||||
private:
|
||||
DecryptApiType();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Decrypt API set for non encrypted content
|
||||
*/
|
||||
static const int NON_ENCRYPTED = 0x00;
|
||||
/**
|
||||
* Decrypt API set for ES based DRM
|
||||
*/
|
||||
static const int ELEMENTARY_STREAM_BASED = 0x01;
|
||||
/**
|
||||
* POSIX based Decrypt API set for container based DRM
|
||||
*/
|
||||
static const int CONTAINER_BASED = 0x02;
|
||||
/**
|
||||
* Decrypt API for Widevine streams
|
||||
*/
|
||||
static const int WV_BASED = 0x3;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines decryption information
|
||||
*/
|
||||
class DecryptInfo {
|
||||
public:
|
||||
/**
|
||||
* size of memory to be allocated to get the decrypted content.
|
||||
*/
|
||||
int decryptBufferLength;
|
||||
/**
|
||||
* reserved for future purpose
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines decryption handle
|
||||
*/
|
||||
class DecryptHandle : public RefBase {
|
||||
public:
|
||||
/**
|
||||
* Decryption session Handle
|
||||
*/
|
||||
int decryptId;
|
||||
/**
|
||||
* Mimetype of the content to be used to select the media extractor
|
||||
* For e.g., "video/mpeg" or "audio/mp3"
|
||||
*/
|
||||
String8 mimeType;
|
||||
/**
|
||||
* Defines which decryption pattern should be used to decrypt the given content
|
||||
* DrmFramework provides two different set of decryption APIs.
|
||||
* 1. Decrypt APIs for elementary stream based DRM
|
||||
* (file format is not encrypted but ES is encrypted)
|
||||
* e.g., Marlin DRM (MP4 file format), WM-DRM (asf file format)
|
||||
*
|
||||
* DecryptApiType::ELEMENTARY_STREAM_BASED
|
||||
* Decryption API set for ES based DRM
|
||||
* initializeDecryptUnit(), decrypt(), and finalizeDecryptUnit()
|
||||
* 2. Decrypt APIs for container based DRM (file format itself is encrypted)
|
||||
* e.g., OMA DRM (dcf file format)
|
||||
*
|
||||
* DecryptApiType::CONTAINER_BASED
|
||||
* POSIX based Decryption API set for container based DRM
|
||||
* pread()
|
||||
*/
|
||||
int decryptApiType;
|
||||
/**
|
||||
* Defines the status of the rights like
|
||||
* RIGHTS_VALID, RIGHTS_INVALID, RIGHTS_EXPIRED or RIGHTS_NOT_ACQUIRED
|
||||
*/
|
||||
int status;
|
||||
/**
|
||||
* Information required to decrypt content
|
||||
* e.g. size of memory to be allocated to get the decrypted content.
|
||||
*/
|
||||
DecryptInfo* decryptInfo;
|
||||
/**
|
||||
* Defines a vector for the copy control settings sent from the DRM plugin
|
||||
* to the player
|
||||
*/
|
||||
KeyedVector<DrmCopyControl, int> copyControlVector;
|
||||
|
||||
/**
|
||||
* Defines a vector for any extra data the DRM plugin wants to send
|
||||
* to the native code
|
||||
*/
|
||||
KeyedVector<String8, String8> extendedData;
|
||||
|
||||
public:
|
||||
DecryptHandle():
|
||||
decryptId(INVALID_VALUE),
|
||||
mimeType(""),
|
||||
decryptApiType(INVALID_VALUE),
|
||||
status(INVALID_VALUE),
|
||||
decryptInfo(NULL) {
|
||||
|
||||
}
|
||||
|
||||
~DecryptHandle() {
|
||||
delete decryptInfo; decryptInfo = NULL;
|
||||
}
|
||||
|
||||
bool operator<(const DecryptHandle& handle) const {
|
||||
return (decryptId < handle.decryptId);
|
||||
}
|
||||
|
||||
bool operator==(const DecryptHandle& handle) const {
|
||||
return (decryptId == handle.decryptId);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif /* __DRM_FRAMEWORK_COMMON_H__ */
|
||||
|
|
@ -1,164 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008 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 ANDROID_FB_INTERFACE_H
|
||||
#define ANDROID_FB_INTERFACE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <cutils/native_handle.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define GRALLOC_HARDWARE_FB0 "fb0"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct framebuffer_device_t {
|
||||
struct hw_device_t common;
|
||||
|
||||
/* flags describing some attributes of the framebuffer */
|
||||
const uint32_t flags;
|
||||
|
||||
/* dimensions of the framebuffer in pixels */
|
||||
const uint32_t width;
|
||||
const uint32_t height;
|
||||
|
||||
/* frambuffer stride in pixels */
|
||||
const int stride;
|
||||
|
||||
/* framebuffer pixel format */
|
||||
const int format;
|
||||
|
||||
/* resolution of the framebuffer's display panel in pixel per inch*/
|
||||
const float xdpi;
|
||||
const float ydpi;
|
||||
|
||||
/* framebuffer's display panel refresh rate in frames per second */
|
||||
const float fps;
|
||||
|
||||
/* min swap interval supported by this framebuffer */
|
||||
const int minSwapInterval;
|
||||
|
||||
/* max swap interval supported by this framebuffer */
|
||||
const int maxSwapInterval;
|
||||
|
||||
int reserved[8];
|
||||
|
||||
/*
|
||||
* requests a specific swap-interval (same definition than EGL)
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*setSwapInterval)(struct framebuffer_device_t* window,
|
||||
int interval);
|
||||
|
||||
/*
|
||||
* This hook is OPTIONAL.
|
||||
*
|
||||
* It is non NULL If the framebuffer driver supports "update-on-demand"
|
||||
* and the given rectangle is the area of the screen that gets
|
||||
* updated during (*post)().
|
||||
*
|
||||
* This is useful on devices that are able to DMA only a portion of
|
||||
* the screen to the display panel, upon demand -- as opposed to
|
||||
* constantly refreshing the panel 60 times per second, for instance.
|
||||
*
|
||||
* Only the area defined by this rectangle is guaranteed to be valid, that
|
||||
* is, the driver is not allowed to post anything outside of this
|
||||
* rectangle.
|
||||
*
|
||||
* The rectangle evaluated during (*post)() and specifies which area
|
||||
* of the buffer passed in (*post)() shall to be posted.
|
||||
*
|
||||
* return -EINVAL if width or height <=0, or if left or top < 0
|
||||
*/
|
||||
int (*setUpdateRect)(struct framebuffer_device_t* window,
|
||||
int left, int top, int width, int height);
|
||||
|
||||
/*
|
||||
* Post <buffer> to the display (display it on the screen)
|
||||
* The buffer must have been allocated with the
|
||||
* GRALLOC_USAGE_HW_FB usage flag.
|
||||
* buffer must be the same width and height as the display and must NOT
|
||||
* be locked.
|
||||
*
|
||||
* The buffer is shown during the next VSYNC.
|
||||
*
|
||||
* If the same buffer is posted again (possibly after some other buffer),
|
||||
* post() will block until the the first post is completed.
|
||||
*
|
||||
* Internally, post() is expected to lock the buffer so that a
|
||||
* subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or
|
||||
* USAGE_*_WRITE will block until it is safe; that is typically once this
|
||||
* buffer is shown and another buffer has been posted.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer);
|
||||
|
||||
|
||||
/*
|
||||
* The (*compositionComplete)() method must be called after the
|
||||
* compositor has finished issuing GL commands for client buffers.
|
||||
*/
|
||||
|
||||
int (*compositionComplete)(struct framebuffer_device_t* dev);
|
||||
|
||||
/*
|
||||
* This hook is OPTIONAL.
|
||||
*
|
||||
* If non NULL it will be caused by SurfaceFlinger on dumpsys
|
||||
*/
|
||||
void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len);
|
||||
|
||||
/*
|
||||
* (*enableScreen)() is used to either blank (enable=0) or
|
||||
* unblank (enable=1) the screen this framebuffer is attached to.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*enableScreen)(struct framebuffer_device_t* dev, int enable);
|
||||
|
||||
void* reserved_proc[6];
|
||||
|
||||
} framebuffer_device_t;
|
||||
|
||||
|
||||
/** convenience API for opening and closing a supported device */
|
||||
|
||||
static inline int framebuffer_open(const struct hw_module_t* module,
|
||||
struct framebuffer_device_t** device) {
|
||||
return module->methods->open(module,
|
||||
GRALLOC_HARDWARE_FB0, (struct hw_device_t**)device);
|
||||
}
|
||||
|
||||
static inline int framebuffer_close(struct framebuffer_device_t* device) {
|
||||
return device->common.close(&device->common);
|
||||
}
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // ANDROID_FB_INTERFACE_H
|
|
@ -1,261 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008 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 ANDROID_GRALLOC_INTERFACE_H
|
||||
#define ANDROID_GRALLOC_INTERFACE_H
|
||||
|
||||
#include <system/window.h>
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <cutils/native_handle.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/fb.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define GRALLOC_API_VERSION 1
|
||||
|
||||
/**
|
||||
* The id of this module
|
||||
*/
|
||||
#define GRALLOC_HARDWARE_MODULE_ID "gralloc"
|
||||
|
||||
/**
|
||||
* Name of the graphics device to open
|
||||
*/
|
||||
|
||||
#define GRALLOC_HARDWARE_GPU0 "gpu0"
|
||||
|
||||
enum {
|
||||
/* buffer is never read in software */
|
||||
GRALLOC_USAGE_SW_READ_NEVER = 0x00000000,
|
||||
/* buffer is rarely read in software */
|
||||
GRALLOC_USAGE_SW_READ_RARELY = 0x00000002,
|
||||
/* buffer is often read in software */
|
||||
GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003,
|
||||
/* mask for the software read values */
|
||||
GRALLOC_USAGE_SW_READ_MASK = 0x0000000F,
|
||||
|
||||
/* buffer is never written in software */
|
||||
GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000,
|
||||
/* buffer is never written in software */
|
||||
GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020,
|
||||
/* buffer is never written in software */
|
||||
GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030,
|
||||
/* mask for the software write values */
|
||||
GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0,
|
||||
|
||||
/* buffer will be used as an OpenGL ES texture */
|
||||
GRALLOC_USAGE_HW_TEXTURE = 0x00000100,
|
||||
/* buffer will be used as an OpenGL ES render target */
|
||||
GRALLOC_USAGE_HW_RENDER = 0x00000200,
|
||||
/* buffer will be used by the 2D hardware blitter */
|
||||
GRALLOC_USAGE_HW_2D = 0x00000400,
|
||||
/* buffer will be used by the HWComposer HAL module */
|
||||
GRALLOC_USAGE_HW_COMPOSER = 0x00000800,
|
||||
/* buffer will be used with the framebuffer device */
|
||||
GRALLOC_USAGE_HW_FB = 0x00001000,
|
||||
/* buffer will be used with the HW video encoder */
|
||||
GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000,
|
||||
/* mask for the software usage bit-mask */
|
||||
GRALLOC_USAGE_HW_MASK = 0x00011F00,
|
||||
|
||||
/* buffer should be displayed full-screen on an external display when
|
||||
* possible
|
||||
*/
|
||||
GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000,
|
||||
|
||||
/* Must have a hardware-protected path to external display sink for
|
||||
* this buffer. If a hardware-protected path is not available, then
|
||||
* either don't composite only this buffer (preferred) to the
|
||||
* external sink, or (less desirable) do not route the entire
|
||||
* composition to the external sink.
|
||||
*/
|
||||
GRALLOC_USAGE_PROTECTED = 0x00004000,
|
||||
|
||||
/* implementation-specific private usage flags */
|
||||
GRALLOC_USAGE_PRIVATE_0 = 0x10000000,
|
||||
GRALLOC_USAGE_PRIVATE_1 = 0x20000000,
|
||||
GRALLOC_USAGE_PRIVATE_2 = 0x40000000,
|
||||
GRALLOC_USAGE_PRIVATE_3 = 0x80000000,
|
||||
GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000,
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
|
||||
* and the fields of this data structure must begin with hw_module_t
|
||||
* followed by module specific information.
|
||||
*/
|
||||
typedef struct gralloc_module_t {
|
||||
struct hw_module_t common;
|
||||
|
||||
/*
|
||||
* (*registerBuffer)() must be called before a buffer_handle_t that has not
|
||||
* been created with (*alloc_device_t::alloc)() can be used.
|
||||
*
|
||||
* This is intended to be used with buffer_handle_t's that have been
|
||||
* received in this process through IPC.
|
||||
*
|
||||
* This function checks that the handle is indeed a valid one and prepares
|
||||
* it for use with (*lock)() and (*unlock)().
|
||||
*
|
||||
* It is not necessary to call (*registerBuffer)() on a handle created
|
||||
* with (*alloc_device_t::alloc)().
|
||||
*
|
||||
* returns an error if this buffer_handle_t is not valid.
|
||||
*/
|
||||
int (*registerBuffer)(struct gralloc_module_t const* module,
|
||||
buffer_handle_t handle);
|
||||
|
||||
/*
|
||||
* (*unregisterBuffer)() is called once this handle is no longer needed in
|
||||
* this process. After this call, it is an error to call (*lock)(),
|
||||
* (*unlock)(), or (*registerBuffer)().
|
||||
*
|
||||
* This function doesn't close or free the handle itself; this is done
|
||||
* by other means, usually through libcutils's native_handle_close() and
|
||||
* native_handle_free().
|
||||
*
|
||||
* It is an error to call (*unregisterBuffer)() on a buffer that wasn't
|
||||
* explicitly registered first.
|
||||
*/
|
||||
int (*unregisterBuffer)(struct gralloc_module_t const* module,
|
||||
buffer_handle_t handle);
|
||||
|
||||
/*
|
||||
* The (*lock)() method is called before a buffer is accessed for the
|
||||
* specified usage. This call may block, for instance if the h/w needs
|
||||
* to finish rendering or if CPU caches need to be synchronized.
|
||||
*
|
||||
* The caller promises to modify only pixels in the area specified
|
||||
* by (l,t,w,h).
|
||||
*
|
||||
* The content of the buffer outside of the specified area is NOT modified
|
||||
* by this call.
|
||||
*
|
||||
* If usage specifies GRALLOC_USAGE_SW_*, vaddr is filled with the address
|
||||
* of the buffer in virtual memory.
|
||||
*
|
||||
* THREADING CONSIDERATIONS:
|
||||
*
|
||||
* It is legal for several different threads to lock a buffer from
|
||||
* read access, none of the threads are blocked.
|
||||
*
|
||||
* However, locking a buffer simultaneously for write or read/write is
|
||||
* undefined, but:
|
||||
* - shall not result in termination of the process
|
||||
* - shall not block the caller
|
||||
* It is acceptable to return an error or to leave the buffer's content
|
||||
* into an indeterminate state.
|
||||
*
|
||||
* If the buffer was created with a usage mask incompatible with the
|
||||
* requested usage flags here, -EINVAL is returned.
|
||||
*
|
||||
*/
|
||||
|
||||
int (*lock)(struct gralloc_module_t const* module,
|
||||
buffer_handle_t handle, int usage,
|
||||
int l, int t, int w, int h,
|
||||
void** vaddr);
|
||||
|
||||
|
||||
/*
|
||||
* The (*unlock)() method must be called after all changes to the buffer
|
||||
* are completed.
|
||||
*/
|
||||
|
||||
int (*unlock)(struct gralloc_module_t const* module,
|
||||
buffer_handle_t handle);
|
||||
|
||||
|
||||
/* reserved for future use */
|
||||
int (*perform)(struct gralloc_module_t const* module,
|
||||
int operation, ... );
|
||||
|
||||
/* reserved for future use */
|
||||
void* reserved_proc[7];
|
||||
} gralloc_module_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* Every device data structure must begin with hw_device_t
|
||||
* followed by module specific public methods and attributes.
|
||||
*/
|
||||
|
||||
typedef struct alloc_device_t {
|
||||
struct hw_device_t common;
|
||||
|
||||
/*
|
||||
* (*alloc)() Allocates a buffer in graphic memory with the requested
|
||||
* parameters and returns a buffer_handle_t and the stride in pixels to
|
||||
* allow the implementation to satisfy hardware constraints on the width
|
||||
* of a pixmap (eg: it may have to be multiple of 8 pixels).
|
||||
* The CALLER TAKES OWNERSHIP of the buffer_handle_t.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
|
||||
int (*alloc)(struct alloc_device_t* dev,
|
||||
int w, int h, int format, int usage,
|
||||
buffer_handle_t* handle, int* stride);
|
||||
|
||||
/*
|
||||
* (*free)() Frees a previously allocated buffer.
|
||||
* Behavior is undefined if the buffer is still mapped in any process,
|
||||
* but shall not result in termination of the program or security breaches
|
||||
* (allowing a process to get access to another process' buffers).
|
||||
* THIS FUNCTION TAKES OWNERSHIP of the buffer_handle_t which becomes
|
||||
* invalid after the call.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*free)(struct alloc_device_t* dev,
|
||||
buffer_handle_t handle);
|
||||
|
||||
/* This hook is OPTIONAL.
|
||||
*
|
||||
* If non NULL it will be caused by SurfaceFlinger on dumpsys
|
||||
*/
|
||||
void (*dump)(struct alloc_device_t *dev, char *buff, int buff_len);
|
||||
|
||||
void* reserved_proc[7];
|
||||
} alloc_device_t;
|
||||
|
||||
|
||||
/** convenience API for opening and closing a supported device */
|
||||
|
||||
static inline int gralloc_open(const struct hw_module_t* module,
|
||||
struct alloc_device_t** device) {
|
||||
return module->methods->open(module,
|
||||
GRALLOC_HARDWARE_GPU0, (struct hw_device_t**)device);
|
||||
}
|
||||
|
||||
static inline int gralloc_close(struct alloc_device_t* device) {
|
||||
return device->common.close(&device->common);
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // ANDROID_ALLOC_INTERFACE_H
|
|
@ -1,139 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008 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 ANDROID_INCLUDE_HARDWARE_HARDWARE_H
|
||||
#define ANDROID_INCLUDE_HARDWARE_HARDWARE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <cutils/native_handle.h>
|
||||
#include <system/graphics.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Value for the hw_module_t.tag field
|
||||
*/
|
||||
|
||||
#define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D))
|
||||
|
||||
#define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T')
|
||||
#define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T')
|
||||
|
||||
struct hw_module_t;
|
||||
struct hw_module_methods_t;
|
||||
struct hw_device_t;
|
||||
|
||||
/**
|
||||
* Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
|
||||
* and the fields of this data structure must begin with hw_module_t
|
||||
* followed by module specific information.
|
||||
*/
|
||||
typedef struct hw_module_t {
|
||||
/** tag must be initialized to HARDWARE_MODULE_TAG */
|
||||
uint32_t tag;
|
||||
|
||||
/** major version number for the module */
|
||||
uint16_t version_major;
|
||||
|
||||
/** minor version number of the module */
|
||||
uint16_t version_minor;
|
||||
|
||||
/** Identifier of module */
|
||||
const char *id;
|
||||
|
||||
/** Name of this module */
|
||||
const char *name;
|
||||
|
||||
/** Author/owner/implementor of the module */
|
||||
const char *author;
|
||||
|
||||
/** Modules methods */
|
||||
struct hw_module_methods_t* methods;
|
||||
|
||||
/** module's dso */
|
||||
void* dso;
|
||||
|
||||
/** padding to 128 bytes, reserved for future use */
|
||||
uint32_t reserved[32-7];
|
||||
|
||||
} hw_module_t;
|
||||
|
||||
typedef struct hw_module_methods_t {
|
||||
/** Open a specific device */
|
||||
int (*open)(const struct hw_module_t* module, const char* id,
|
||||
struct hw_device_t** device);
|
||||
|
||||
} hw_module_methods_t;
|
||||
|
||||
/**
|
||||
* Every device data structure must begin with hw_device_t
|
||||
* followed by module specific public methods and attributes.
|
||||
*/
|
||||
typedef struct hw_device_t {
|
||||
/** tag must be initialized to HARDWARE_DEVICE_TAG */
|
||||
uint32_t tag;
|
||||
|
||||
/** version number for hw_device_t */
|
||||
uint32_t version;
|
||||
|
||||
/** reference to the module this device belongs to */
|
||||
struct hw_module_t* module;
|
||||
|
||||
/** padding reserved for future use */
|
||||
uint32_t reserved[12];
|
||||
|
||||
/** Close this device */
|
||||
int (*close)(struct hw_device_t* device);
|
||||
|
||||
} hw_device_t;
|
||||
|
||||
/**
|
||||
* Name of the hal_module_info
|
||||
*/
|
||||
#define HAL_MODULE_INFO_SYM HMI
|
||||
|
||||
/**
|
||||
* Name of the hal_module_info as a string
|
||||
*/
|
||||
#define HAL_MODULE_INFO_SYM_AS_STR "HMI"
|
||||
|
||||
/**
|
||||
* Get the module info associated with a module by id.
|
||||
*
|
||||
* @return: 0 == success, <0 == error and *module == NULL
|
||||
*/
|
||||
int hw_get_module(const char *id, const struct hw_module_t **module);
|
||||
|
||||
/**
|
||||
* Get the module info associated with a module instance by class 'class_id'
|
||||
* and instance 'inst'.
|
||||
*
|
||||
* Some modules types necessitate multiple instances. For example audio supports
|
||||
* multiple concurrent interfaces and thus 'audio' is the module class
|
||||
* and 'primary' or 'a2dp' are module interfaces. This implies that the files
|
||||
* providing these modules would be named audio.primary.<variant>.so and
|
||||
* audio.a2dp.<variant>.so
|
||||
*
|
||||
* @return: 0 == success, <0 == error and *module == NULL
|
||||
*/
|
||||
int hw_get_module_by_class(const char *class_id, const char *inst,
|
||||
const struct hw_module_t **module);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */
|
|
@ -1,197 +0,0 @@
|
|||
/*
|
||||
* 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 ANDROID_IOMX_H_
|
||||
|
||||
#define ANDROID_IOMX_H_
|
||||
|
||||
#include <binder/IInterface.h>
|
||||
#include <ui/GraphicBuffer.h>
|
||||
#include <utils/List.h>
|
||||
#include <utils/String8.h>
|
||||
|
||||
#include <OMX_Core.h>
|
||||
#include <OMX_Video.h>
|
||||
|
||||
#include "jni.h"
|
||||
|
||||
namespace android {
|
||||
|
||||
class IMemory;
|
||||
class IOMXObserver;
|
||||
class IOMXRenderer;
|
||||
class Surface;
|
||||
|
||||
class IOMX : public IInterface {
|
||||
public:
|
||||
DECLARE_META_INTERFACE(OMX);
|
||||
|
||||
typedef void *buffer_id;
|
||||
typedef void *node_id;
|
||||
|
||||
// Given the calling process' pid, returns true iff
|
||||
// the implementation of the OMX interface lives in the same
|
||||
// process.
|
||||
virtual bool livesLocally(pid_t pid) = 0;
|
||||
|
||||
struct ComponentInfo {
|
||||
String8 mName;
|
||||
List<String8> mRoles;
|
||||
};
|
||||
virtual status_t listNodes(List<ComponentInfo> *list) = 0;
|
||||
|
||||
virtual status_t allocateNode(
|
||||
const char *name, const sp<IOMXObserver> &observer,
|
||||
node_id *node) = 0;
|
||||
|
||||
virtual status_t freeNode(node_id node) = 0;
|
||||
|
||||
virtual status_t sendCommand(
|
||||
node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param) = 0;
|
||||
|
||||
virtual status_t getParameter(
|
||||
node_id node, OMX_INDEXTYPE index,
|
||||
void *params, size_t size) = 0;
|
||||
|
||||
virtual status_t setParameter(
|
||||
node_id node, OMX_INDEXTYPE index,
|
||||
const void *params, size_t size) = 0;
|
||||
|
||||
virtual status_t getConfig(
|
||||
node_id node, OMX_INDEXTYPE index,
|
||||
void *params, size_t size) = 0;
|
||||
|
||||
virtual status_t setConfig(
|
||||
node_id node, OMX_INDEXTYPE index,
|
||||
const void *params, size_t size) = 0;
|
||||
|
||||
virtual status_t getState(
|
||||
node_id node, OMX_STATETYPE* state) = 0;
|
||||
|
||||
virtual status_t storeMetaDataInBuffers(
|
||||
node_id node, OMX_U32 port_index, OMX_BOOL enable) = 0;
|
||||
|
||||
virtual status_t enableGraphicBuffers(
|
||||
node_id node, OMX_U32 port_index, OMX_BOOL enable) = 0;
|
||||
|
||||
virtual status_t getGraphicBufferUsage(
|
||||
node_id node, OMX_U32 port_index, OMX_U32* usage) = 0;
|
||||
|
||||
virtual status_t useBuffer(
|
||||
node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms,
|
||||
buffer_id *buffer) = 0;
|
||||
|
||||
virtual status_t useGraphicBuffer(
|
||||
node_id node, OMX_U32 port_index,
|
||||
const sp<GraphicBuffer> &graphicBuffer, buffer_id *buffer) = 0;
|
||||
|
||||
// This API clearly only makes sense if the caller lives in the
|
||||
// same process as the callee, i.e. is the media_server, as the
|
||||
// returned "buffer_data" pointer is just that, a pointer into local
|
||||
// address space.
|
||||
virtual status_t allocateBuffer(
|
||||
node_id node, OMX_U32 port_index, size_t size,
|
||||
buffer_id *buffer, void **buffer_data) = 0;
|
||||
|
||||
virtual status_t allocateBufferWithBackup(
|
||||
node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms,
|
||||
buffer_id *buffer) = 0;
|
||||
|
||||
virtual status_t freeBuffer(
|
||||
node_id node, OMX_U32 port_index, buffer_id buffer) = 0;
|
||||
|
||||
virtual status_t fillBuffer(node_id node, buffer_id buffer) = 0;
|
||||
|
||||
virtual status_t emptyBuffer(
|
||||
node_id node,
|
||||
buffer_id buffer,
|
||||
OMX_U32 range_offset, OMX_U32 range_length,
|
||||
OMX_U32 flags, OMX_TICKS timestamp) = 0;
|
||||
|
||||
virtual status_t getExtensionIndex(
|
||||
node_id node,
|
||||
const char *parameter_name,
|
||||
OMX_INDEXTYPE *index) = 0;
|
||||
};
|
||||
|
||||
struct omx_message {
|
||||
enum {
|
||||
EVENT,
|
||||
EMPTY_BUFFER_DONE,
|
||||
FILL_BUFFER_DONE,
|
||||
|
||||
} type;
|
||||
|
||||
IOMX::node_id node;
|
||||
|
||||
union {
|
||||
// if type == EVENT
|
||||
struct {
|
||||
OMX_EVENTTYPE event;
|
||||
OMX_U32 data1;
|
||||
OMX_U32 data2;
|
||||
} event_data;
|
||||
|
||||
// if type == EMPTY_BUFFER_DONE
|
||||
struct {
|
||||
IOMX::buffer_id buffer;
|
||||
} buffer_data;
|
||||
|
||||
// if type == FILL_BUFFER_DONE
|
||||
struct {
|
||||
IOMX::buffer_id buffer;
|
||||
OMX_U32 range_offset;
|
||||
OMX_U32 range_length;
|
||||
OMX_U32 flags;
|
||||
OMX_TICKS timestamp;
|
||||
OMX_PTR platform_private;
|
||||
OMX_PTR data_ptr;
|
||||
} extended_buffer_data;
|
||||
|
||||
} u;
|
||||
};
|
||||
|
||||
class IOMXObserver : public IInterface {
|
||||
public:
|
||||
DECLARE_META_INTERFACE(OMXObserver);
|
||||
|
||||
virtual void onMessage(const omx_message &msg) = 0;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class BnOMX : public BnInterface<IOMX> {
|
||||
public:
|
||||
virtual status_t onTransact(
|
||||
uint32_t code, const Parcel &data, Parcel *reply,
|
||||
uint32_t flags = 0);
|
||||
};
|
||||
|
||||
class BnOMXObserver : public BnInterface<IOMXObserver> {
|
||||
public:
|
||||
virtual status_t onTransact(
|
||||
uint32_t code, const Parcel &data, Parcel *reply,
|
||||
uint32_t flags = 0);
|
||||
};
|
||||
|
||||
struct CodecProfileLevel {
|
||||
OMX_U32 mProfile;
|
||||
OMX_U32 mLevel;
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_IOMX_H_
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* 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 MEDIA_BUFFER_H_
|
||||
|
||||
#define MEDIA_BUFFER_H_
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include <utils/Errors.h>
|
||||
#include <utils/RefBase.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
struct ABuffer;
|
||||
class GraphicBuffer;
|
||||
class MediaBuffer;
|
||||
class MediaBufferObserver;
|
||||
class MetaData;
|
||||
|
||||
class MediaBufferObserver {
|
||||
public:
|
||||
MediaBufferObserver() {}
|
||||
virtual ~MediaBufferObserver() {}
|
||||
|
||||
virtual void signalBufferReturned(MediaBuffer *buffer) = 0;
|
||||
|
||||
private:
|
||||
MediaBufferObserver(const MediaBufferObserver &);
|
||||
MediaBufferObserver &operator=(const MediaBufferObserver &);
|
||||
};
|
||||
|
||||
class MediaBuffer {
|
||||
public:
|
||||
// The underlying data remains the responsibility of the caller!
|
||||
MediaBuffer(void *data, size_t size);
|
||||
|
||||
MediaBuffer(size_t size);
|
||||
|
||||
MediaBuffer(const sp<GraphicBuffer>& graphicBuffer);
|
||||
|
||||
MediaBuffer(const sp<ABuffer> &buffer);
|
||||
|
||||
// Decrements the reference count and returns the buffer to its
|
||||
// associated MediaBufferGroup if the reference count drops to 0.
|
||||
void release();
|
||||
|
||||
// Increments the reference count.
|
||||
void add_ref();
|
||||
|
||||
void *data() const;
|
||||
size_t size() const;
|
||||
|
||||
size_t range_offset() const;
|
||||
size_t range_length() const;
|
||||
|
||||
void set_range(size_t offset, size_t length);
|
||||
|
||||
sp<GraphicBuffer> graphicBuffer() const;
|
||||
|
||||
sp<MetaData> meta_data();
|
||||
|
||||
// Clears meta data and resets the range to the full extent.
|
||||
void reset();
|
||||
|
||||
void setObserver(MediaBufferObserver *group);
|
||||
|
||||
// Returns a clone of this MediaBuffer increasing its reference count.
|
||||
// The clone references the same data but has its own range and
|
||||
// MetaData.
|
||||
MediaBuffer *clone();
|
||||
|
||||
int refcount() const;
|
||||
|
||||
protected:
|
||||
virtual ~MediaBuffer();
|
||||
|
||||
private:
|
||||
friend class MediaBufferGroup;
|
||||
friend class OMXDecoder;
|
||||
|
||||
// For use by OMXDecoder, reference count must be 1, drop reference
|
||||
// count to 0 without signalling the observer.
|
||||
void claim();
|
||||
|
||||
MediaBufferObserver *mObserver;
|
||||
MediaBuffer *mNextBuffer;
|
||||
int mRefCount;
|
||||
|
||||
void *mData;
|
||||
size_t mSize, mRangeOffset, mRangeLength;
|
||||
sp<GraphicBuffer> mGraphicBuffer;
|
||||
sp<ABuffer> mBuffer;
|
||||
|
||||
bool mOwnsData;
|
||||
|
||||
sp<MetaData> mMetaData;
|
||||
|
||||
MediaBuffer *mOriginal;
|
||||
|
||||
void setNextBuffer(MediaBuffer *buffer);
|
||||
MediaBuffer *nextBuffer();
|
||||
|
||||
MediaBuffer(const MediaBuffer &);
|
||||
MediaBuffer &operator=(const MediaBuffer &);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // MEDIA_BUFFER_H_
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* 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 MEDIA_ERRORS_H_
|
||||
|
||||
#define MEDIA_ERRORS_H_
|
||||
|
||||
#include <utils/Errors.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
enum {
|
||||
MEDIA_ERROR_BASE = -1000,
|
||||
|
||||
ERROR_ALREADY_CONNECTED = MEDIA_ERROR_BASE,
|
||||
ERROR_NOT_CONNECTED = MEDIA_ERROR_BASE - 1,
|
||||
ERROR_UNKNOWN_HOST = MEDIA_ERROR_BASE - 2,
|
||||
ERROR_CANNOT_CONNECT = MEDIA_ERROR_BASE - 3,
|
||||
ERROR_IO = MEDIA_ERROR_BASE - 4,
|
||||
ERROR_CONNECTION_LOST = MEDIA_ERROR_BASE - 5,
|
||||
ERROR_MALFORMED = MEDIA_ERROR_BASE - 7,
|
||||
ERROR_OUT_OF_RANGE = MEDIA_ERROR_BASE - 8,
|
||||
ERROR_BUFFER_TOO_SMALL = MEDIA_ERROR_BASE - 9,
|
||||
ERROR_UNSUPPORTED = MEDIA_ERROR_BASE - 10,
|
||||
ERROR_END_OF_STREAM = MEDIA_ERROR_BASE - 11,
|
||||
|
||||
// Not technically an error.
|
||||
INFO_FORMAT_CHANGED = MEDIA_ERROR_BASE - 12,
|
||||
INFO_DISCONTINUITY = MEDIA_ERROR_BASE - 13,
|
||||
|
||||
// The following constant values should be in sync with
|
||||
// drm/drm_framework_common.h
|
||||
DRM_ERROR_BASE = -2000,
|
||||
|
||||
ERROR_DRM_UNKNOWN = DRM_ERROR_BASE,
|
||||
ERROR_DRM_NO_LICENSE = DRM_ERROR_BASE - 1,
|
||||
ERROR_DRM_LICENSE_EXPIRED = DRM_ERROR_BASE - 2,
|
||||
ERROR_DRM_SESSION_NOT_OPENED = DRM_ERROR_BASE - 3,
|
||||
ERROR_DRM_DECRYPT_UNIT_NOT_INITIALIZED = DRM_ERROR_BASE - 4,
|
||||
ERROR_DRM_DECRYPT = DRM_ERROR_BASE - 5,
|
||||
ERROR_DRM_CANNOT_HANDLE = DRM_ERROR_BASE - 6,
|
||||
ERROR_DRM_TAMPER_DETECTED = DRM_ERROR_BASE - 7,
|
||||
|
||||
// Heartbeat Error Codes
|
||||
HEARTBEAT_ERROR_BASE = -3000,
|
||||
|
||||
ERROR_HEARTBEAT_AUTHENTICATION_FAILURE = HEARTBEAT_ERROR_BASE,
|
||||
ERROR_HEARTBEAT_NO_ACTIVE_PURCHASE_AGREEMENT = HEARTBEAT_ERROR_BASE - 1,
|
||||
ERROR_HEARTBEAT_CONCURRENT_PLAYBACK = HEARTBEAT_ERROR_BASE - 2,
|
||||
ERROR_HEARTBEAT_UNUSUAL_ACTIVITY = HEARTBEAT_ERROR_BASE - 3,
|
||||
ERROR_HEARTBEAT_STREAMING_UNAVAILABLE = HEARTBEAT_ERROR_BASE - 4,
|
||||
ERROR_HEARTBEAT_CANNOT_ACTIVATE_RENTAL = HEARTBEAT_ERROR_BASE - 5,
|
||||
ERROR_HEARTBEAT_TERMINATE_REQUESTED = HEARTBEAT_ERROR_BASE - 6,
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // MEDIA_ERRORS_H_
|
|
@ -1,122 +0,0 @@
|
|||
/*
|
||||
* 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 MEDIA_SOURCE_H_
|
||||
|
||||
#define MEDIA_SOURCE_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <media/stagefright/MediaErrors.h>
|
||||
#include <utils/RefBase.h>
|
||||
#include <utils/Vector.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class MediaBuffer;
|
||||
class MetaData;
|
||||
|
||||
struct MediaSource : public virtual RefBase {
|
||||
MediaSource();
|
||||
|
||||
// To be called before any other methods on this object, except
|
||||
// getFormat().
|
||||
virtual status_t start(MetaData *params = NULL) = 0;
|
||||
|
||||
// Any blocking read call returns immediately with a result of NO_INIT.
|
||||
// It is an error to call any methods other than start after this call
|
||||
// returns. Any buffers the object may be holding onto at the time of
|
||||
// the stop() call are released.
|
||||
// Also, it is imperative that any buffers output by this object and
|
||||
// held onto by callers be released before a call to stop() !!!
|
||||
virtual status_t stop() = 0;
|
||||
|
||||
// Returns the format of the data output by this media source.
|
||||
virtual sp<MetaData> getFormat() = 0;
|
||||
|
||||
struct ReadOptions;
|
||||
|
||||
// Returns a new buffer of data. Call blocks until a
|
||||
// buffer is available, an error is encountered of the end of the stream
|
||||
// is reached.
|
||||
// End of stream is signalled by a result of ERROR_END_OF_STREAM.
|
||||
// A result of INFO_FORMAT_CHANGED indicates that the format of this
|
||||
// MediaSource has changed mid-stream, the client can continue reading
|
||||
// but should be prepared for buffers of the new configuration.
|
||||
virtual status_t read(
|
||||
MediaBuffer **buffer, const ReadOptions *options = NULL) = 0;
|
||||
|
||||
// Options that modify read() behaviour. The default is to
|
||||
// a) not request a seek
|
||||
// b) not be late, i.e. lateness_us = 0
|
||||
struct ReadOptions {
|
||||
enum SeekMode {
|
||||
SEEK_PREVIOUS_SYNC,
|
||||
SEEK_NEXT_SYNC,
|
||||
SEEK_CLOSEST_SYNC,
|
||||
SEEK_CLOSEST,
|
||||
};
|
||||
|
||||
ReadOptions();
|
||||
|
||||
// Reset everything back to defaults.
|
||||
void reset();
|
||||
|
||||
void setSeekTo(int64_t time_us, SeekMode mode = SEEK_CLOSEST_SYNC);
|
||||
void clearSeekTo();
|
||||
bool getSeekTo(int64_t *time_us, SeekMode *mode) const;
|
||||
|
||||
void setLateBy(int64_t lateness_us);
|
||||
int64_t getLateBy() const;
|
||||
|
||||
private:
|
||||
enum Options {
|
||||
kSeekTo_Option = 1,
|
||||
};
|
||||
|
||||
uint32_t mOptions;
|
||||
int64_t mSeekTimeUs;
|
||||
SeekMode mSeekMode;
|
||||
int64_t mLatenessUs;
|
||||
};
|
||||
|
||||
// Causes this source to suspend pulling data from its upstream source
|
||||
// until a subsequent read-with-seek. Currently only supported by
|
||||
// OMXCodec.
|
||||
virtual status_t pause() {
|
||||
return ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// The consumer of this media source requests that the given buffers
|
||||
// are to be returned exclusively in response to read calls.
|
||||
// This will be called after a successful start() and before the
|
||||
// first read() call.
|
||||
// Callee assumes ownership of the buffers if no error is returned.
|
||||
virtual status_t setBuffers(const Vector<MediaBuffer *> &buffers) {
|
||||
return ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~MediaSource();
|
||||
|
||||
private:
|
||||
MediaSource(const MediaSource &);
|
||||
MediaSource &operator=(const MediaSource &);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // MEDIA_SOURCE_H_
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,947 +0,0 @@
|
|||
/* ------------------------------------------------------------------
|
||||
* Copyright (C) 1998-2009 PacketVideo
|
||||
*
|
||||
* 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.
|
||||
* -------------------------------------------------------------------
|
||||
*/
|
||||
/**
|
||||
* Copyright (c) 2008 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file OMX_IVCommon.h - OpenMax IL version 1.1.2
|
||||
* The structures needed by Video and Image components to exchange
|
||||
* parameters and configuration data with the components.
|
||||
*/
|
||||
#ifndef OMX_IVCommon_h
|
||||
#define OMX_IVCommon_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* Each OMX header must include all required header files to allow the header
|
||||
* to compile without errors. The includes below are required for this header
|
||||
* file to compile successfully
|
||||
*/
|
||||
|
||||
#include <OMX_Core.h>
|
||||
|
||||
/** @defgroup iv OpenMAX IL Imaging and Video Domain
|
||||
* Common structures for OpenMAX IL Imaging and Video domains
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Enumeration defining possible uncompressed image/video formats.
|
||||
*
|
||||
* ENUMS:
|
||||
* Unused : Placeholder value when format is N/A
|
||||
* Monochrome : black and white
|
||||
* 8bitRGB332 : Red 7:5, Green 4:2, Blue 1:0
|
||||
* 12bitRGB444 : Red 11:8, Green 7:4, Blue 3:0
|
||||
* 16bitARGB4444 : Alpha 15:12, Red 11:8, Green 7:4, Blue 3:0
|
||||
* 16bitARGB1555 : Alpha 15, Red 14:10, Green 9:5, Blue 4:0
|
||||
* 16bitRGB565 : Red 15:11, Green 10:5, Blue 4:0
|
||||
* 16bitBGR565 : Blue 15:11, Green 10:5, Red 4:0
|
||||
* 18bitRGB666 : Red 17:12, Green 11:6, Blue 5:0
|
||||
* 18bitARGB1665 : Alpha 17, Red 16:11, Green 10:5, Blue 4:0
|
||||
* 19bitARGB1666 : Alpha 18, Red 17:12, Green 11:6, Blue 5:0
|
||||
* 24bitRGB888 : Red 24:16, Green 15:8, Blue 7:0
|
||||
* 24bitBGR888 : Blue 24:16, Green 15:8, Red 7:0
|
||||
* 24bitARGB1887 : Alpha 23, Red 22:15, Green 14:7, Blue 6:0
|
||||
* 25bitARGB1888 : Alpha 24, Red 23:16, Green 15:8, Blue 7:0
|
||||
* 32bitBGRA8888 : Blue 31:24, Green 23:16, Red 15:8, Alpha 7:0
|
||||
* 32bitARGB8888 : Alpha 31:24, Red 23:16, Green 15:8, Blue 7:0
|
||||
* YUV411Planar : U,Y are subsampled by a factor of 4 horizontally
|
||||
* YUV411PackedPlanar : packed per payload in planar slices
|
||||
* YUV420Planar : Three arrays Y,U,V.
|
||||
* YUV420PackedPlanar : packed per payload in planar slices
|
||||
* YUV420SemiPlanar : Two arrays, one is all Y, the other is U and V
|
||||
* YUV422Planar : Three arrays Y,U,V.
|
||||
* YUV422PackedPlanar : packed per payload in planar slices
|
||||
* YUV422SemiPlanar : Two arrays, one is all Y, the other is U and V
|
||||
* YCbYCr : Organized as 16bit YUYV (i.e. YCbYCr)
|
||||
* YCrYCb : Organized as 16bit YVYU (i.e. YCrYCb)
|
||||
* CbYCrY : Organized as 16bit UYVY (i.e. CbYCrY)
|
||||
* CrYCbY : Organized as 16bit VYUY (i.e. CrYCbY)
|
||||
* YUV444Interleaved : Each pixel contains equal parts YUV
|
||||
* RawBayer8bit : SMIA camera output format
|
||||
* RawBayer10bit : SMIA camera output format
|
||||
* RawBayer8bitcompressed : SMIA camera output format
|
||||
*/
|
||||
typedef enum OMX_COLOR_FORMATTYPE {
|
||||
OMX_COLOR_FormatUnused,
|
||||
OMX_COLOR_FormatMonochrome,
|
||||
OMX_COLOR_Format8bitRGB332,
|
||||
OMX_COLOR_Format12bitRGB444,
|
||||
OMX_COLOR_Format16bitARGB4444,
|
||||
OMX_COLOR_Format16bitARGB1555,
|
||||
OMX_COLOR_Format16bitRGB565,
|
||||
OMX_COLOR_Format16bitBGR565,
|
||||
OMX_COLOR_Format18bitRGB666,
|
||||
OMX_COLOR_Format18bitARGB1665,
|
||||
OMX_COLOR_Format19bitARGB1666,
|
||||
OMX_COLOR_Format24bitRGB888,
|
||||
OMX_COLOR_Format24bitBGR888,
|
||||
OMX_COLOR_Format24bitARGB1887,
|
||||
OMX_COLOR_Format25bitARGB1888,
|
||||
OMX_COLOR_Format32bitBGRA8888,
|
||||
OMX_COLOR_Format32bitARGB8888,
|
||||
OMX_COLOR_FormatYUV411Planar,
|
||||
OMX_COLOR_FormatYUV411PackedPlanar,
|
||||
OMX_COLOR_FormatYUV420Planar,
|
||||
OMX_COLOR_FormatYUV420PackedPlanar,
|
||||
OMX_COLOR_FormatYUV420SemiPlanar,
|
||||
OMX_COLOR_FormatYUV422Planar,
|
||||
OMX_COLOR_FormatYUV422PackedPlanar,
|
||||
OMX_COLOR_FormatYUV422SemiPlanar,
|
||||
OMX_COLOR_FormatYCbYCr,
|
||||
OMX_COLOR_FormatYCrYCb,
|
||||
OMX_COLOR_FormatCbYCrY,
|
||||
OMX_COLOR_FormatCrYCbY,
|
||||
OMX_COLOR_FormatYUV444Interleaved,
|
||||
OMX_COLOR_FormatRawBayer8bit,
|
||||
OMX_COLOR_FormatRawBayer10bit,
|
||||
OMX_COLOR_FormatRawBayer8bitcompressed,
|
||||
OMX_COLOR_FormatL2,
|
||||
OMX_COLOR_FormatL4,
|
||||
OMX_COLOR_FormatL8,
|
||||
OMX_COLOR_FormatL16,
|
||||
OMX_COLOR_FormatL24,
|
||||
OMX_COLOR_FormatL32,
|
||||
OMX_COLOR_FormatYUV420PackedSemiPlanar,
|
||||
OMX_COLOR_FormatYUV422PackedSemiPlanar,
|
||||
OMX_COLOR_Format18BitBGR666,
|
||||
OMX_COLOR_Format24BitARGB6666,
|
||||
OMX_COLOR_Format24BitABGR6666,
|
||||
OMX_COLOR_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_COLOR_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
/**<Reserved android opaque colorformat. Tells the encoder that
|
||||
* the actual colorformat will be relayed by the
|
||||
* Gralloc Buffers.
|
||||
* FIXME: In the process of reserving some enum values for
|
||||
* Android-specific OMX IL colorformats. Change this enum to
|
||||
* an acceptable range once that is done.
|
||||
* */
|
||||
OMX_COLOR_FormatAndroidOpaque = 0x7F000789,
|
||||
OMX_TI_COLOR_FormatYUV420PackedSemiPlanar = 0x7F000100,
|
||||
OMX_QCOM_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00,
|
||||
OMX_COLOR_FormatMax = 0x7FFFFFFF
|
||||
} OMX_COLOR_FORMATTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Defines the matrix for conversion from RGB to YUV or vice versa.
|
||||
* iColorMatrix should be initialized with the fixed point values
|
||||
* used in converting between formats.
|
||||
*/
|
||||
typedef struct OMX_CONFIG_COLORCONVERSIONTYPE {
|
||||
OMX_U32 nSize; /**< Size of the structure in bytes */
|
||||
OMX_VERSIONTYPE nVersion; /**< OMX specification version info */
|
||||
OMX_U32 nPortIndex; /**< Port that this struct applies to */
|
||||
OMX_S32 xColorMatrix[3][3]; /**< Stored in signed Q16 format */
|
||||
OMX_S32 xColorOffset[4]; /**< Stored in signed Q16 format */
|
||||
}OMX_CONFIG_COLORCONVERSIONTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Structure defining percent to scale each frame dimension. For example:
|
||||
* To make the width 50% larger, use fWidth = 1.5 and to make the width
|
||||
* 1/2 the original size, use fWidth = 0.5
|
||||
*/
|
||||
typedef struct OMX_CONFIG_SCALEFACTORTYPE {
|
||||
OMX_U32 nSize; /**< Size of the structure in bytes */
|
||||
OMX_VERSIONTYPE nVersion; /**< OMX specification version info */
|
||||
OMX_U32 nPortIndex; /**< Port that this struct applies to */
|
||||
OMX_S32 xWidth; /**< Fixed point value stored as Q16 */
|
||||
OMX_S32 xHeight; /**< Fixed point value stored as Q16 */
|
||||
}OMX_CONFIG_SCALEFACTORTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Enumeration of possible image filter types
|
||||
*/
|
||||
typedef enum OMX_IMAGEFILTERTYPE {
|
||||
OMX_ImageFilterNone,
|
||||
OMX_ImageFilterNoise,
|
||||
OMX_ImageFilterEmboss,
|
||||
OMX_ImageFilterNegative,
|
||||
OMX_ImageFilterSketch,
|
||||
OMX_ImageFilterOilPaint,
|
||||
OMX_ImageFilterHatch,
|
||||
OMX_ImageFilterGpen,
|
||||
OMX_ImageFilterAntialias,
|
||||
OMX_ImageFilterDeRing,
|
||||
OMX_ImageFilterSolarize,
|
||||
OMX_ImageFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_ImageFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
OMX_ImageFilterMax = 0x7FFFFFFF
|
||||
} OMX_IMAGEFILTERTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Image filter configuration
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* eImageFilter : Image filter type enumeration
|
||||
*/
|
||||
typedef struct OMX_CONFIG_IMAGEFILTERTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_IMAGEFILTERTYPE eImageFilter;
|
||||
} OMX_CONFIG_IMAGEFILTERTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Customized U and V for color enhancement
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* bColorEnhancement : Enable/disable color enhancement
|
||||
* nCustomizedU : Practical values: 16-240, range: 0-255, value set for
|
||||
* U component
|
||||
* nCustomizedV : Practical values: 16-240, range: 0-255, value set for
|
||||
* V component
|
||||
*/
|
||||
typedef struct OMX_CONFIG_COLORENHANCEMENTTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_BOOL bColorEnhancement;
|
||||
OMX_U8 nCustomizedU;
|
||||
OMX_U8 nCustomizedV;
|
||||
} OMX_CONFIG_COLORENHANCEMENTTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Define color key and color key mask
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nARGBColor : 32bit Alpha, Red, Green, Blue Color
|
||||
* nARGBMask : 32bit Mask for Alpha, Red, Green, Blue channels
|
||||
*/
|
||||
typedef struct OMX_CONFIG_COLORKEYTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_U32 nARGBColor;
|
||||
OMX_U32 nARGBMask;
|
||||
} OMX_CONFIG_COLORKEYTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* List of color blend types for pre/post processing
|
||||
*
|
||||
* ENUMS:
|
||||
* None : No color blending present
|
||||
* AlphaConstant : Function is (alpha_constant * src) +
|
||||
* (1 - alpha_constant) * dst)
|
||||
* AlphaPerPixel : Function is (alpha * src) + (1 - alpha) * dst)
|
||||
* Alternate : Function is alternating pixels from src and dst
|
||||
* And : Function is (src & dst)
|
||||
* Or : Function is (src | dst)
|
||||
* Invert : Function is ~src
|
||||
*/
|
||||
typedef enum OMX_COLORBLENDTYPE {
|
||||
OMX_ColorBlendNone,
|
||||
OMX_ColorBlendAlphaConstant,
|
||||
OMX_ColorBlendAlphaPerPixel,
|
||||
OMX_ColorBlendAlternate,
|
||||
OMX_ColorBlendAnd,
|
||||
OMX_ColorBlendOr,
|
||||
OMX_ColorBlendInvert,
|
||||
OMX_ColorBlendKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_ColorBlendVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
OMX_ColorBlendMax = 0x7FFFFFFF
|
||||
} OMX_COLORBLENDTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Color blend configuration
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nRGBAlphaConstant : Constant global alpha values when global alpha is used
|
||||
* eColorBlend : Color blend type enumeration
|
||||
*/
|
||||
typedef struct OMX_CONFIG_COLORBLENDTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_U32 nRGBAlphaConstant;
|
||||
OMX_COLORBLENDTYPE eColorBlend;
|
||||
} OMX_CONFIG_COLORBLENDTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Hold frame dimension
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nWidth : Frame width in pixels
|
||||
* nHeight : Frame height in pixels
|
||||
*/
|
||||
typedef struct OMX_FRAMESIZETYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_U32 nWidth;
|
||||
OMX_U32 nHeight;
|
||||
} OMX_FRAMESIZETYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Rotation configuration
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nRotation : +/- integer rotation value
|
||||
*/
|
||||
typedef struct OMX_CONFIG_ROTATIONTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_S32 nRotation;
|
||||
} OMX_CONFIG_ROTATIONTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Possible mirroring directions for pre/post processing
|
||||
*
|
||||
* ENUMS:
|
||||
* None : No mirroring
|
||||
* Vertical : Vertical mirroring, flip on X axis
|
||||
* Horizontal : Horizontal mirroring, flip on Y axis
|
||||
* Both : Both vertical and horizontal mirroring
|
||||
*/
|
||||
typedef enum OMX_MIRRORTYPE {
|
||||
OMX_MirrorNone = 0,
|
||||
OMX_MirrorVertical,
|
||||
OMX_MirrorHorizontal,
|
||||
OMX_MirrorBoth,
|
||||
OMX_MirrorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_MirrorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
OMX_MirrorMax = 0x7FFFFFFF
|
||||
} OMX_MIRRORTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Mirroring configuration
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* eMirror : Mirror type enumeration
|
||||
*/
|
||||
typedef struct OMX_CONFIG_MIRRORTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_MIRRORTYPE eMirror;
|
||||
} OMX_CONFIG_MIRRORTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Position information only
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nX : X coordinate for the point
|
||||
* nY : Y coordinate for the point
|
||||
*/
|
||||
typedef struct OMX_CONFIG_POINTTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_S32 nX;
|
||||
OMX_S32 nY;
|
||||
} OMX_CONFIG_POINTTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Frame size plus position
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nLeft : X Coordinate of the top left corner of the rectangle
|
||||
* nTop : Y Coordinate of the top left corner of the rectangle
|
||||
* nWidth : Width of the rectangle
|
||||
* nHeight : Height of the rectangle
|
||||
*/
|
||||
typedef struct OMX_CONFIG_RECTTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_S32 nLeft;
|
||||
OMX_S32 nTop;
|
||||
OMX_U32 nWidth;
|
||||
OMX_U32 nHeight;
|
||||
} OMX_CONFIG_RECTTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Deblocking state; it is required to be set up before starting the codec
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* bDeblocking : Enable/disable deblocking mode
|
||||
*/
|
||||
typedef struct OMX_PARAM_DEBLOCKINGTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_BOOL bDeblocking;
|
||||
} OMX_PARAM_DEBLOCKINGTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Stabilization state
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* bStab : Enable/disable frame stabilization state
|
||||
*/
|
||||
typedef struct OMX_CONFIG_FRAMESTABTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_BOOL bStab;
|
||||
} OMX_CONFIG_FRAMESTABTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* White Balance control type
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* SunLight : Referenced in JSR-234
|
||||
* Flash : Optimal for device's integrated flash
|
||||
*/
|
||||
typedef enum OMX_WHITEBALCONTROLTYPE {
|
||||
OMX_WhiteBalControlOff = 0,
|
||||
OMX_WhiteBalControlAuto,
|
||||
OMX_WhiteBalControlSunLight,
|
||||
OMX_WhiteBalControlCloudy,
|
||||
OMX_WhiteBalControlShade,
|
||||
OMX_WhiteBalControlTungsten,
|
||||
OMX_WhiteBalControlFluorescent,
|
||||
OMX_WhiteBalControlIncandescent,
|
||||
OMX_WhiteBalControlFlash,
|
||||
OMX_WhiteBalControlHorizon,
|
||||
OMX_WhiteBalControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_WhiteBalControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
OMX_WhiteBalControlMax = 0x7FFFFFFF
|
||||
} OMX_WHITEBALCONTROLTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* White Balance control configuration
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* eWhiteBalControl : White balance enumeration
|
||||
*/
|
||||
typedef struct OMX_CONFIG_WHITEBALCONTROLTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_WHITEBALCONTROLTYPE eWhiteBalControl;
|
||||
} OMX_CONFIG_WHITEBALCONTROLTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Exposure control type
|
||||
*/
|
||||
typedef enum OMX_EXPOSURECONTROLTYPE {
|
||||
OMX_ExposureControlOff = 0,
|
||||
OMX_ExposureControlAuto,
|
||||
OMX_ExposureControlNight,
|
||||
OMX_ExposureControlBackLight,
|
||||
OMX_ExposureControlSpotLight,
|
||||
OMX_ExposureControlSports,
|
||||
OMX_ExposureControlSnow,
|
||||
OMX_ExposureControlBeach,
|
||||
OMX_ExposureControlLargeAperture,
|
||||
OMX_ExposureControlSmallApperture,
|
||||
OMX_ExposureControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_ExposureControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
OMX_ExposureControlMax = 0x7FFFFFFF
|
||||
} OMX_EXPOSURECONTROLTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* White Balance control configuration
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* eExposureControl : Exposure control enumeration
|
||||
*/
|
||||
typedef struct OMX_CONFIG_EXPOSURECONTROLTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_EXPOSURECONTROLTYPE eExposureControl;
|
||||
} OMX_CONFIG_EXPOSURECONTROLTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Defines sensor supported mode.
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nFrameRate : Single shot mode is indicated by a 0
|
||||
* bOneShot : Enable for single shot, disable for streaming
|
||||
* sFrameSize : Framesize
|
||||
*/
|
||||
typedef struct OMX_PARAM_SENSORMODETYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_U32 nFrameRate;
|
||||
OMX_BOOL bOneShot;
|
||||
OMX_FRAMESIZETYPE sFrameSize;
|
||||
} OMX_PARAM_SENSORMODETYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Defines contrast level
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nContrast : Values allowed for contrast -100 to 100, zero means no change
|
||||
*/
|
||||
typedef struct OMX_CONFIG_CONTRASTTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_S32 nContrast;
|
||||
} OMX_CONFIG_CONTRASTTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Defines brightness level
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nBrightness : 0-100%
|
||||
*/
|
||||
typedef struct OMX_CONFIG_BRIGHTNESSTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_U32 nBrightness;
|
||||
} OMX_CONFIG_BRIGHTNESSTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Defines backlight level configuration for a video sink, e.g. LCD panel
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nBacklight : Values allowed for backlight 0-100%
|
||||
* nTimeout : Number of milliseconds before backlight automatically turns
|
||||
* off. A value of 0x0 disables backight timeout
|
||||
*/
|
||||
typedef struct OMX_CONFIG_BACKLIGHTTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_U32 nBacklight;
|
||||
OMX_U32 nTimeout;
|
||||
} OMX_CONFIG_BACKLIGHTTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Defines setting for Gamma
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nGamma : Values allowed for gamma -100 to 100, zero means no change
|
||||
*/
|
||||
typedef struct OMX_CONFIG_GAMMATYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_S32 nGamma;
|
||||
} OMX_CONFIG_GAMMATYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Define for setting saturation
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nSaturation : Values allowed for saturation -100 to 100, zero means
|
||||
* no change
|
||||
*/
|
||||
typedef struct OMX_CONFIG_SATURATIONTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_S32 nSaturation;
|
||||
} OMX_CONFIG_SATURATIONTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Define for setting Lightness
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* nLightness : Values allowed for lightness -100 to 100, zero means no
|
||||
* change
|
||||
*/
|
||||
typedef struct OMX_CONFIG_LIGHTNESSTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_S32 nLightness;
|
||||
} OMX_CONFIG_LIGHTNESSTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Plane blend configuration
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Index of input port associated with the plane.
|
||||
* nDepth : Depth of the plane in relation to the screen. Higher
|
||||
* numbered depths are "behind" lower number depths.
|
||||
* This number defaults to the Port Index number.
|
||||
* nAlpha : Transparency blending component for the entire plane.
|
||||
* See blending modes for more detail.
|
||||
*/
|
||||
typedef struct OMX_CONFIG_PLANEBLENDTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_U32 nDepth;
|
||||
OMX_U32 nAlpha;
|
||||
} OMX_CONFIG_PLANEBLENDTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Define interlace type
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* bEnable : Enable control variable for this functionality
|
||||
* (see below)
|
||||
* nInterleavePortIndex : Index of input or output port associated with
|
||||
* the interleaved plane.
|
||||
* pPlanarPortIndexes[4] : Index of input or output planar ports.
|
||||
*/
|
||||
typedef struct OMX_PARAM_INTERLEAVETYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_BOOL bEnable;
|
||||
OMX_U32 nInterleavePortIndex;
|
||||
} OMX_PARAM_INTERLEAVETYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Defines the picture effect used for an input picture
|
||||
*/
|
||||
typedef enum OMX_TRANSITIONEFFECTTYPE {
|
||||
OMX_EffectNone,
|
||||
OMX_EffectFadeFromBlack,
|
||||
OMX_EffectFadeToBlack,
|
||||
OMX_EffectUnspecifiedThroughConstantColor,
|
||||
OMX_EffectDissolve,
|
||||
OMX_EffectWipe,
|
||||
OMX_EffectUnspecifiedMixOfTwoScenes,
|
||||
OMX_EffectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_EffectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
OMX_EffectMax = 0x7FFFFFFF
|
||||
} OMX_TRANSITIONEFFECTTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Structure used to configure current transition effect
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* eEffect : Effect to enable
|
||||
*/
|
||||
typedef struct OMX_CONFIG_TRANSITIONEFFECTTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_TRANSITIONEFFECTTYPE eEffect;
|
||||
} OMX_CONFIG_TRANSITIONEFFECTTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Defines possible data unit types for encoded video data. The data unit
|
||||
* types are used both for encoded video input for playback as well as
|
||||
* encoded video output from recording.
|
||||
*/
|
||||
typedef enum OMX_DATAUNITTYPE {
|
||||
OMX_DataUnitCodedPicture,
|
||||
OMX_DataUnitVideoSegment,
|
||||
OMX_DataUnitSeveralSegments,
|
||||
OMX_DataUnitArbitraryStreamSection,
|
||||
OMX_DataUnitKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_DataUnitVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
OMX_DataUnitMax = 0x7FFFFFFF
|
||||
} OMX_DATAUNITTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Defines possible encapsulation types for coded video data unit. The
|
||||
* encapsulation information is used both for encoded video input for
|
||||
* playback as well as encoded video output from recording.
|
||||
*/
|
||||
typedef enum OMX_DATAUNITENCAPSULATIONTYPE {
|
||||
OMX_DataEncapsulationElementaryStream,
|
||||
OMX_DataEncapsulationGenericPayload,
|
||||
OMX_DataEncapsulationRtpPayload,
|
||||
OMX_DataEncapsulationKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_DataEncapsulationVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
OMX_DataEncapsulationMax = 0x7FFFFFFF
|
||||
} OMX_DATAUNITENCAPSULATIONTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Structure used to configure the type of being decoded/encoded
|
||||
*/
|
||||
typedef struct OMX_PARAM_DATAUNITTYPE {
|
||||
OMX_U32 nSize; /**< Size of the structure in bytes */
|
||||
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
|
||||
OMX_U32 nPortIndex; /**< Port that this structure applies to */
|
||||
OMX_DATAUNITTYPE eUnitType;
|
||||
OMX_DATAUNITENCAPSULATIONTYPE eEncapsulationType;
|
||||
} OMX_PARAM_DATAUNITTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Defines dither types
|
||||
*/
|
||||
typedef enum OMX_DITHERTYPE {
|
||||
OMX_DitherNone,
|
||||
OMX_DitherOrdered,
|
||||
OMX_DitherErrorDiffusion,
|
||||
OMX_DitherOther,
|
||||
OMX_DitherKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_DitherVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
OMX_DitherMax = 0x7FFFFFFF
|
||||
} OMX_DITHERTYPE;
|
||||
|
||||
|
||||
/**
|
||||
* Structure used to configure current type of dithering
|
||||
*/
|
||||
typedef struct OMX_CONFIG_DITHERTYPE {
|
||||
OMX_U32 nSize; /**< Size of the structure in bytes */
|
||||
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
|
||||
OMX_U32 nPortIndex; /**< Port that this structure applies to */
|
||||
OMX_DITHERTYPE eDither; /**< Type of dithering to use */
|
||||
} OMX_CONFIG_DITHERTYPE;
|
||||
|
||||
typedef struct OMX_CONFIG_CAPTUREMODETYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex; /**< Port that this structure applies to */
|
||||
OMX_BOOL bContinuous; /**< If true then ignore frame rate and emit capture
|
||||
* data as fast as possible (otherwise obey port's frame rate). */
|
||||
OMX_BOOL bFrameLimited; /**< If true then terminate capture after the port emits the
|
||||
* specified number of frames (otherwise the port does not
|
||||
* terminate the capture until instructed to do so by the client).
|
||||
* Even if set, the client may manually terminate the capture prior
|
||||
* to reaching the limit. */
|
||||
OMX_U32 nFrameLimit; /**< Limit on number of frames emitted during a capture (only
|
||||
* valid if bFrameLimited is set). */
|
||||
} OMX_CONFIG_CAPTUREMODETYPE;
|
||||
|
||||
typedef enum OMX_METERINGTYPE {
|
||||
|
||||
OMX_MeteringModeAverage, /**< Center-weighted average metering. */
|
||||
OMX_MeteringModeSpot, /**< Spot (partial) metering. */
|
||||
OMX_MeteringModeMatrix, /**< Matrix or evaluative metering. */
|
||||
|
||||
OMX_MeteringKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_MeteringVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
OMX_EVModeMax = 0x7fffffff
|
||||
} OMX_METERINGTYPE;
|
||||
|
||||
typedef struct OMX_CONFIG_EXPOSUREVALUETYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_METERINGTYPE eMetering;
|
||||
OMX_S32 xEVCompensation; /**< Fixed point value stored as Q16 */
|
||||
OMX_U32 nApertureFNumber; /**< e.g. nApertureFNumber = 2 implies "f/2" - Q16 format */
|
||||
OMX_BOOL bAutoAperture; /**< Whether aperture number is defined automatically */
|
||||
OMX_U32 nShutterSpeedMsec; /**< Shutterspeed in milliseconds */
|
||||
OMX_BOOL bAutoShutterSpeed; /**< Whether shutter speed is defined automatically */
|
||||
OMX_U32 nSensitivity; /**< e.g. nSensitivity = 100 implies "ISO 100" */
|
||||
OMX_BOOL bAutoSensitivity; /**< Whether sensitivity is defined automatically */
|
||||
} OMX_CONFIG_EXPOSUREVALUETYPE;
|
||||
|
||||
/**
|
||||
* Focus region configuration
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* bCenter : Use center region as focus region of interest
|
||||
* bLeft : Use left region as focus region of interest
|
||||
* bRight : Use right region as focus region of interest
|
||||
* bTop : Use top region as focus region of interest
|
||||
* bBottom : Use bottom region as focus region of interest
|
||||
* bTopLeft : Use top left region as focus region of interest
|
||||
* bTopRight : Use top right region as focus region of interest
|
||||
* bBottomLeft : Use bottom left region as focus region of interest
|
||||
* bBottomRight : Use bottom right region as focus region of interest
|
||||
*/
|
||||
typedef struct OMX_CONFIG_FOCUSREGIONTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_BOOL bCenter;
|
||||
OMX_BOOL bLeft;
|
||||
OMX_BOOL bRight;
|
||||
OMX_BOOL bTop;
|
||||
OMX_BOOL bBottom;
|
||||
OMX_BOOL bTopLeft;
|
||||
OMX_BOOL bTopRight;
|
||||
OMX_BOOL bBottomLeft;
|
||||
OMX_BOOL bBottomRight;
|
||||
} OMX_CONFIG_FOCUSREGIONTYPE;
|
||||
|
||||
/**
|
||||
* Focus Status type
|
||||
*/
|
||||
typedef enum OMX_FOCUSSTATUSTYPE {
|
||||
OMX_FocusStatusOff = 0,
|
||||
OMX_FocusStatusRequest,
|
||||
OMX_FocusStatusReached,
|
||||
OMX_FocusStatusUnableToReach,
|
||||
OMX_FocusStatusLost,
|
||||
OMX_FocusStatusKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_FocusStatusVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
OMX_FocusStatusMax = 0x7FFFFFFF
|
||||
} OMX_FOCUSSTATUSTYPE;
|
||||
|
||||
/**
|
||||
* Focus status configuration
|
||||
*
|
||||
* STRUCT MEMBERS:
|
||||
* nSize : Size of the structure in bytes
|
||||
* nVersion : OMX specification version information
|
||||
* nPortIndex : Port that this structure applies to
|
||||
* eFocusStatus : Specifies the focus status
|
||||
* bCenterStatus : Use center region as focus region of interest
|
||||
* bLeftStatus : Use left region as focus region of interest
|
||||
* bRightStatus : Use right region as focus region of interest
|
||||
* bTopStatus : Use top region as focus region of interest
|
||||
* bBottomStatus : Use bottom region as focus region of interest
|
||||
* bTopLeftStatus : Use top left region as focus region of interest
|
||||
* bTopRightStatus : Use top right region as focus region of interest
|
||||
* bBottomLeftStatus : Use bottom left region as focus region of interest
|
||||
* bBottomRightStatus : Use bottom right region as focus region of interest
|
||||
*/
|
||||
typedef struct OMX_PARAM_FOCUSSTATUSTYPE {
|
||||
OMX_U32 nSize;
|
||||
OMX_VERSIONTYPE nVersion;
|
||||
OMX_U32 nPortIndex;
|
||||
OMX_FOCUSSTATUSTYPE eFocusStatus;
|
||||
OMX_BOOL bCenterStatus;
|
||||
OMX_BOOL bLeftStatus;
|
||||
OMX_BOOL bRightStatus;
|
||||
OMX_BOOL bTopStatus;
|
||||
OMX_BOOL bBottomStatus;
|
||||
OMX_BOOL bTopLeftStatus;
|
||||
OMX_BOOL bTopRightStatus;
|
||||
OMX_BOOL bBottomLeftStatus;
|
||||
OMX_BOOL bBottomRightStatus;
|
||||
} OMX_PARAM_FOCUSSTATUSTYPE;
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/* File EOF */
|
|
@ -1,275 +0,0 @@
|
|||
/* ------------------------------------------------------------------
|
||||
* Copyright (C) 1998-2009 PacketVideo
|
||||
*
|
||||
* 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.
|
||||
* -------------------------------------------------------------------
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2008 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file OMX_Index.h - OpenMax IL version 1.1.2
|
||||
* The OMX_Index header file contains the definitions for both applications
|
||||
* and components .
|
||||
*/
|
||||
|
||||
|
||||
#ifndef OMX_Index_h
|
||||
#define OMX_Index_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/* Each OMX header must include all required header files to allow the
|
||||
* header to compile without errors. The includes below are required
|
||||
* for this header file to compile successfully
|
||||
*/
|
||||
#include <OMX_Types.h>
|
||||
|
||||
|
||||
/** The OMX_INDEXTYPE enumeration is used to select a structure when either
|
||||
* getting or setting parameters and/or configuration data. Each entry in
|
||||
* this enumeration maps to an OMX specified structure. When the
|
||||
* OMX_GetParameter, OMX_SetParameter, OMX_GetConfig or OMX_SetConfig methods
|
||||
* are used, the second parameter will always be an entry from this enumeration
|
||||
* and the third entry will be the structure shown in the comments for the entry.
|
||||
* For example, if the application is initializing a cropping function, the
|
||||
* OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop as the second parameter
|
||||
* and would send a pointer to an initialized OMX_RECTTYPE structure as the
|
||||
* third parameter.
|
||||
*
|
||||
* The enumeration entries named with the OMX_Config prefix are sent using
|
||||
* the OMX_SetConfig command and the enumeration entries named with the
|
||||
* OMX_PARAM_ prefix are sent using the OMX_SetParameter command.
|
||||
*/
|
||||
typedef enum OMX_INDEXTYPE {
|
||||
|
||||
OMX_IndexComponentStartUnused = 0x01000000,
|
||||
OMX_IndexParamPriorityMgmt, /**< reference: OMX_PRIORITYMGMTTYPE */
|
||||
OMX_IndexParamAudioInit, /**< reference: OMX_PORT_PARAM_TYPE */
|
||||
OMX_IndexParamImageInit, /**< reference: OMX_PORT_PARAM_TYPE */
|
||||
OMX_IndexParamVideoInit, /**< reference: OMX_PORT_PARAM_TYPE */
|
||||
OMX_IndexParamOtherInit, /**< reference: OMX_PORT_PARAM_TYPE */
|
||||
OMX_IndexParamNumAvailableStreams, /**< reference: OMX_PARAM_U32TYPE */
|
||||
OMX_IndexParamActiveStream, /**< reference: OMX_PARAM_U32TYPE */
|
||||
OMX_IndexParamSuspensionPolicy, /**< reference: OMX_PARAM_SUSPENSIONPOLICYTYPE */
|
||||
OMX_IndexParamComponentSuspended, /**< reference: OMX_PARAM_SUSPENSIONTYPE */
|
||||
OMX_IndexConfigCapturing, /**< reference: OMX_CONFIG_BOOLEANTYPE */
|
||||
OMX_IndexConfigCaptureMode, /**< reference: OMX_CONFIG_CAPTUREMODETYPE */
|
||||
OMX_IndexAutoPauseAfterCapture, /**< reference: OMX_CONFIG_BOOLEANTYPE */
|
||||
OMX_IndexParamContentURI, /**< reference: OMX_PARAM_CONTENTURITYPE */
|
||||
OMX_IndexParamCustomContentPipe, /**< reference: OMX_PARAM_CONTENTPIPETYPE */
|
||||
OMX_IndexParamDisableResourceConcealment, /**< reference: OMX_RESOURCECONCEALMENTTYPE */
|
||||
OMX_IndexConfigMetadataItemCount, /**< reference: OMX_CONFIG_METADATAITEMCOUNTTYPE */
|
||||
OMX_IndexConfigContainerNodeCount, /**< reference: OMX_CONFIG_CONTAINERNODECOUNTTYPE */
|
||||
OMX_IndexConfigMetadataItem, /**< reference: OMX_CONFIG_METADATAITEMTYPE */
|
||||
OMX_IndexConfigCounterNodeID, /**< reference: OMX_CONFIG_CONTAINERNODEIDTYPE */
|
||||
OMX_IndexParamMetadataFilterType, /**< reference: OMX_PARAM_METADATAFILTERTYPE */
|
||||
OMX_IndexParamMetadataKeyFilter, /**< reference: OMX_PARAM_METADATAFILTERTYPE */
|
||||
OMX_IndexConfigPriorityMgmt, /**< reference: OMX_PRIORITYMGMTTYPE */
|
||||
OMX_IndexParamStandardComponentRole, /**< reference: OMX_PARAM_COMPONENTROLETYPE */
|
||||
|
||||
OMX_IndexPortStartUnused = 0x02000000,
|
||||
OMX_IndexParamPortDefinition, /**< reference: OMX_PARAM_PORTDEFINITIONTYPE */
|
||||
OMX_IndexParamCompBufferSupplier, /**< reference: OMX_PARAM_BUFFERSUPPLIERTYPE */
|
||||
OMX_IndexReservedStartUnused = 0x03000000,
|
||||
|
||||
/* Audio parameters and configurations */
|
||||
OMX_IndexAudioStartUnused = 0x04000000,
|
||||
OMX_IndexParamAudioPortFormat, /**< reference: OMX_AUDIO_PARAM_PORTFORMATTYPE */
|
||||
OMX_IndexParamAudioPcm, /**< reference: OMX_AUDIO_PARAM_PCMMODETYPE */
|
||||
OMX_IndexParamAudioAac, /**< reference: OMX_AUDIO_PARAM_AACPROFILETYPE */
|
||||
OMX_IndexParamAudioRa, /**< reference: OMX_AUDIO_PARAM_RATYPE */
|
||||
OMX_IndexParamAudioMp3, /**< reference: OMX_AUDIO_PARAM_MP3TYPE */
|
||||
OMX_IndexParamAudioAdpcm, /**< reference: OMX_AUDIO_PARAM_ADPCMTYPE */
|
||||
OMX_IndexParamAudioG723, /**< reference: OMX_AUDIO_PARAM_G723TYPE */
|
||||
OMX_IndexParamAudioG729, /**< reference: OMX_AUDIO_PARAM_G729TYPE */
|
||||
OMX_IndexParamAudioAmr, /**< reference: OMX_AUDIO_PARAM_AMRTYPE */
|
||||
OMX_IndexParamAudioWma, /**< reference: OMX_AUDIO_PARAM_WMATYPE */
|
||||
OMX_IndexParamAudioSbc, /**< reference: OMX_AUDIO_PARAM_SBCTYPE */
|
||||
OMX_IndexParamAudioMidi, /**< reference: OMX_AUDIO_PARAM_MIDITYPE */
|
||||
OMX_IndexParamAudioGsm_FR, /**< reference: OMX_AUDIO_PARAM_GSMFRTYPE */
|
||||
OMX_IndexParamAudioMidiLoadUserSound, /**< reference: OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE */
|
||||
OMX_IndexParamAudioG726, /**< reference: OMX_AUDIO_PARAM_G726TYPE */
|
||||
OMX_IndexParamAudioGsm_EFR, /**< reference: OMX_AUDIO_PARAM_GSMEFRTYPE */
|
||||
OMX_IndexParamAudioGsm_HR, /**< reference: OMX_AUDIO_PARAM_GSMHRTYPE */
|
||||
OMX_IndexParamAudioPdc_FR, /**< reference: OMX_AUDIO_PARAM_PDCFRTYPE */
|
||||
OMX_IndexParamAudioPdc_EFR, /**< reference: OMX_AUDIO_PARAM_PDCEFRTYPE */
|
||||
OMX_IndexParamAudioPdc_HR, /**< reference: OMX_AUDIO_PARAM_PDCHRTYPE */
|
||||
OMX_IndexParamAudioTdma_FR, /**< reference: OMX_AUDIO_PARAM_TDMAFRTYPE */
|
||||
OMX_IndexParamAudioTdma_EFR, /**< reference: OMX_AUDIO_PARAM_TDMAEFRTYPE */
|
||||
OMX_IndexParamAudioQcelp8, /**< reference: OMX_AUDIO_PARAM_QCELP8TYPE */
|
||||
OMX_IndexParamAudioQcelp13, /**< reference: OMX_AUDIO_PARAM_QCELP13TYPE */
|
||||
OMX_IndexParamAudioEvrc, /**< reference: OMX_AUDIO_PARAM_EVRCTYPE */
|
||||
OMX_IndexParamAudioSmv, /**< reference: OMX_AUDIO_PARAM_SMVTYPE */
|
||||
OMX_IndexParamAudioVorbis, /**< reference: OMX_AUDIO_PARAM_VORBISTYPE */
|
||||
|
||||
OMX_IndexConfigAudioMidiImmediateEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE */
|
||||
OMX_IndexConfigAudioMidiControl, /**< reference: OMX_AUDIO_CONFIG_MIDICONTROLTYPE */
|
||||
OMX_IndexConfigAudioMidiSoundBankProgram, /**< reference: OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE */
|
||||
OMX_IndexConfigAudioMidiStatus, /**< reference: OMX_AUDIO_CONFIG_MIDISTATUSTYPE */
|
||||
OMX_IndexConfigAudioMidiMetaEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE */
|
||||
OMX_IndexConfigAudioMidiMetaEventData, /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE */
|
||||
OMX_IndexConfigAudioVolume, /**< reference: OMX_AUDIO_CONFIG_VOLUMETYPE */
|
||||
OMX_IndexConfigAudioBalance, /**< reference: OMX_AUDIO_CONFIG_BALANCETYPE */
|
||||
OMX_IndexConfigAudioChannelMute, /**< reference: OMX_AUDIO_CONFIG_CHANNELMUTETYPE */
|
||||
OMX_IndexConfigAudioMute, /**< reference: OMX_AUDIO_CONFIG_MUTETYPE */
|
||||
OMX_IndexConfigAudioLoudness, /**< reference: OMX_AUDIO_CONFIG_LOUDNESSTYPE */
|
||||
OMX_IndexConfigAudioEchoCancelation, /**< reference: OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE */
|
||||
OMX_IndexConfigAudioNoiseReduction, /**< reference: OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE */
|
||||
OMX_IndexConfigAudioBass, /**< reference: OMX_AUDIO_CONFIG_BASSTYPE */
|
||||
OMX_IndexConfigAudioTreble, /**< reference: OMX_AUDIO_CONFIG_TREBLETYPE */
|
||||
OMX_IndexConfigAudioStereoWidening, /**< reference: OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE */
|
||||
OMX_IndexConfigAudioChorus, /**< reference: OMX_AUDIO_CONFIG_CHORUSTYPE */
|
||||
OMX_IndexConfigAudioEqualizer, /**< reference: OMX_AUDIO_CONFIG_EQUALIZERTYPE */
|
||||
OMX_IndexConfigAudioReverberation, /**< reference: OMX_AUDIO_CONFIG_REVERBERATIONTYPE */
|
||||
OMX_IndexConfigAudioChannelVolume, /**< reference: OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE */
|
||||
|
||||
/* Image specific parameters and configurations */
|
||||
OMX_IndexImageStartUnused = 0x05000000,
|
||||
OMX_IndexParamImagePortFormat, /**< reference: OMX_IMAGE_PARAM_PORTFORMATTYPE */
|
||||
OMX_IndexParamFlashControl, /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */
|
||||
OMX_IndexConfigFocusControl, /**< reference: OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE */
|
||||
OMX_IndexParamQFactor, /**< reference: OMX_IMAGE_PARAM_QFACTORTYPE */
|
||||
OMX_IndexParamQuantizationTable, /**< reference: OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE */
|
||||
OMX_IndexParamHuffmanTable, /**< reference: OMX_IMAGE_PARAM_HUFFMANTTABLETYPE */
|
||||
OMX_IndexConfigFlashControl, /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */
|
||||
|
||||
/* Video specific parameters and configurations */
|
||||
OMX_IndexVideoStartUnused = 0x06000000,
|
||||
OMX_IndexParamVideoPortFormat, /**< reference: OMX_VIDEO_PARAM_PORTFORMATTYPE */
|
||||
OMX_IndexParamVideoQuantization, /**< reference: OMX_VIDEO_PARAM_QUANTIZATIONTYPE */
|
||||
OMX_IndexParamVideoFastUpdate, /**< reference: OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE */
|
||||
OMX_IndexParamVideoBitrate, /**< reference: OMX_VIDEO_PARAM_BITRATETYPE */
|
||||
OMX_IndexParamVideoMotionVector, /**< reference: OMX_VIDEO_PARAM_MOTIONVECTORTYPE */
|
||||
OMX_IndexParamVideoIntraRefresh, /**< reference: OMX_VIDEO_PARAM_INTRAREFRESHTYPE */
|
||||
OMX_IndexParamVideoErrorCorrection, /**< reference: OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE */
|
||||
OMX_IndexParamVideoVBSMC, /**< reference: OMX_VIDEO_PARAM_VBSMCTYPE */
|
||||
OMX_IndexParamVideoMpeg2, /**< reference: OMX_VIDEO_PARAM_MPEG2TYPE */
|
||||
OMX_IndexParamVideoMpeg4, /**< reference: OMX_VIDEO_PARAM_MPEG4TYPE */
|
||||
OMX_IndexParamVideoWmv, /**< reference: OMX_VIDEO_PARAM_WMVTYPE */
|
||||
OMX_IndexParamVideoRv, /**< reference: OMX_VIDEO_PARAM_RVTYPE */
|
||||
OMX_IndexParamVideoAvc, /**< reference: OMX_VIDEO_PARAM_AVCTYPE */
|
||||
OMX_IndexParamVideoH263, /**< reference: OMX_VIDEO_PARAM_H263TYPE */
|
||||
OMX_IndexParamVideoProfileLevelQuerySupported, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */
|
||||
OMX_IndexParamVideoProfileLevelCurrent, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */
|
||||
OMX_IndexConfigVideoBitrate, /**< reference: OMX_VIDEO_CONFIG_BITRATETYPE */
|
||||
OMX_IndexConfigVideoFramerate, /**< reference: OMX_CONFIG_FRAMERATETYPE */
|
||||
OMX_IndexConfigVideoIntraVOPRefresh, /**< reference: OMX_CONFIG_INTRAREFRESHVOPTYPE */
|
||||
OMX_IndexConfigVideoIntraMBRefresh, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */
|
||||
OMX_IndexConfigVideoMBErrorReporting, /**< reference: OMX_CONFIG_MBERRORREPORTINGTYPE */
|
||||
OMX_IndexParamVideoMacroblocksPerFrame, /**< reference: OMX_PARAM_MACROBLOCKSTYPE */
|
||||
OMX_IndexConfigVideoMacroBlockErrorMap, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */
|
||||
OMX_IndexParamVideoSliceFMO, /**< reference: OMX_VIDEO_PARAM_AVCSLICEFMO */
|
||||
OMX_IndexConfigVideoAVCIntraPeriod, /**< reference: OMX_VIDEO_CONFIG_AVCINTRAPERIOD */
|
||||
OMX_IndexConfigVideoNalSize, /**< reference: OMX_VIDEO_CONFIG_NALSIZE */
|
||||
|
||||
/* Image & Video common Configurations */
|
||||
OMX_IndexCommonStartUnused = 0x07000000,
|
||||
OMX_IndexParamCommonDeblocking, /**< reference: OMX_PARAM_DEBLOCKINGTYPE */
|
||||
OMX_IndexParamCommonSensorMode, /**< reference: OMX_PARAM_SENSORMODETYPE */
|
||||
OMX_IndexParamCommonInterleave, /**< reference: OMX_PARAM_INTERLEAVETYPE */
|
||||
OMX_IndexConfigCommonColorFormatConversion, /**< reference: OMX_CONFIG_COLORCONVERSIONTYPE */
|
||||
OMX_IndexConfigCommonScale, /**< reference: OMX_CONFIG_SCALEFACTORTYPE */
|
||||
OMX_IndexConfigCommonImageFilter, /**< reference: OMX_CONFIG_IMAGEFILTERTYPE */
|
||||
OMX_IndexConfigCommonColorEnhancement, /**< reference: OMX_CONFIG_COLORENHANCEMENTTYPE */
|
||||
OMX_IndexConfigCommonColorKey, /**< reference: OMX_CONFIG_COLORKEYTYPE */
|
||||
OMX_IndexConfigCommonColorBlend, /**< reference: OMX_CONFIG_COLORBLENDTYPE */
|
||||
OMX_IndexConfigCommonFrameStabilisation,/**< reference: OMX_CONFIG_FRAMESTABTYPE */
|
||||
OMX_IndexConfigCommonRotate, /**< reference: OMX_CONFIG_ROTATIONTYPE */
|
||||
OMX_IndexConfigCommonMirror, /**< reference: OMX_CONFIG_MIRRORTYPE */
|
||||
OMX_IndexConfigCommonOutputPosition, /**< reference: OMX_CONFIG_POINTTYPE */
|
||||
OMX_IndexConfigCommonInputCrop, /**< reference: OMX_CONFIG_RECTTYPE */
|
||||
OMX_IndexConfigCommonOutputCrop, /**< reference: OMX_CONFIG_RECTTYPE */
|
||||
OMX_IndexConfigCommonDigitalZoom, /**< reference: OMX_CONFIG_SCALEFACTORTYPE */
|
||||
OMX_IndexConfigCommonOpticalZoom, /**< reference: OMX_CONFIG_SCALEFACTORTYPE*/
|
||||
OMX_IndexConfigCommonWhiteBalance, /**< reference: OMX_CONFIG_WHITEBALCONTROLTYPE */
|
||||
OMX_IndexConfigCommonExposure, /**< reference: OMX_CONFIG_EXPOSURECONTROLTYPE */
|
||||
OMX_IndexConfigCommonContrast, /**< reference: OMX_CONFIG_CONTRASTTYPE */
|
||||
OMX_IndexConfigCommonBrightness, /**< reference: OMX_CONFIG_BRIGHTNESSTYPE */
|
||||
OMX_IndexConfigCommonBacklight, /**< reference: OMX_CONFIG_BACKLIGHTTYPE */
|
||||
OMX_IndexConfigCommonGamma, /**< reference: OMX_CONFIG_GAMMATYPE */
|
||||
OMX_IndexConfigCommonSaturation, /**< reference: OMX_CONFIG_SATURATIONTYPE */
|
||||
OMX_IndexConfigCommonLightness, /**< reference: OMX_CONFIG_LIGHTNESSTYPE */
|
||||
OMX_IndexConfigCommonExclusionRect, /**< reference: OMX_CONFIG_RECTTYPE */
|
||||
OMX_IndexConfigCommonDithering, /**< reference: OMX_CONFIG_DITHERTYPE */
|
||||
OMX_IndexConfigCommonPlaneBlend, /**< reference: OMX_CONFIG_PLANEBLENDTYPE */
|
||||
OMX_IndexConfigCommonExposureValue, /**< reference: OMX_CONFIG_EXPOSUREVALUETYPE */
|
||||
OMX_IndexConfigCommonOutputSize, /**< reference: OMX_FRAMESIZETYPE */
|
||||
OMX_IndexParamCommonExtraQuantData, /**< reference: OMX_OTHER_EXTRADATATYPE */
|
||||
OMX_IndexConfigCommonFocusRegion, /**< reference: OMX_CONFIG_FOCUSREGIONTYPE */
|
||||
OMX_IndexConfigCommonFocusStatus, /**< reference: OMX_PARAM_FOCUSSTATUSTYPE */
|
||||
OMX_IndexConfigCommonTransitionEffect, /**< reference: OMX_CONFIG_TRANSITIONEFFECTTYPE */
|
||||
|
||||
/* Reserved Configuration range */
|
||||
OMX_IndexOtherStartUnused = 0x08000000,
|
||||
OMX_IndexParamOtherPortFormat, /**< reference: OMX_OTHER_PARAM_PORTFORMATTYPE */
|
||||
OMX_IndexConfigOtherPower, /**< reference: OMX_OTHER_CONFIG_POWERTYPE */
|
||||
OMX_IndexConfigOtherStats, /**< reference: OMX_OTHER_CONFIG_STATSTYPE */
|
||||
|
||||
|
||||
/* Reserved Time range */
|
||||
OMX_IndexTimeStartUnused = 0x09000000,
|
||||
OMX_IndexConfigTimeScale, /**< reference: OMX_TIME_CONFIG_SCALETYPE */
|
||||
OMX_IndexConfigTimeClockState, /**< reference: OMX_TIME_CONFIG_CLOCKSTATETYPE */
|
||||
OMX_IndexConfigTimeActiveRefClock, /**< reference: OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE */
|
||||
OMX_IndexConfigTimeCurrentMediaTime, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */
|
||||
OMX_IndexConfigTimeCurrentWallTime, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */
|
||||
OMX_IndexConfigTimeCurrentAudioReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */
|
||||
OMX_IndexConfigTimeCurrentVideoReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */
|
||||
OMX_IndexConfigTimeMediaTimeRequest, /**< reference: OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE (write only) */
|
||||
OMX_IndexConfigTimeClientStartTime, /**<reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */
|
||||
OMX_IndexConfigTimePosition, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE */
|
||||
OMX_IndexConfigTimeSeekMode, /**< reference: OMX_TIME_CONFIG_SEEKMODETYPE */
|
||||
|
||||
|
||||
OMX_IndexKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
/* Vendor specific area */
|
||||
OMX_IndexVendorStartUnused = 0x7F000000,
|
||||
/* Vendor specific structures should be in the range of 0x7F000000
|
||||
to 0x7FFFFFFE. This range is not broken out by vendor, so
|
||||
private indexes are not guaranteed unique and therefore should
|
||||
only be sent to the appropriate component. */
|
||||
|
||||
OMX_IndexMax = 0x7FFFFFFF
|
||||
|
||||
} OMX_INDEXTYPE;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/* File EOF */
|
|
@ -1,365 +0,0 @@
|
|||
/* ------------------------------------------------------------------
|
||||
* Copyright (C) 1998-2009 PacketVideo
|
||||
*
|
||||
* 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.
|
||||
* -------------------------------------------------------------------
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2008 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/** OMX_Types.h - OpenMax IL version 1.1.2
|
||||
* The OMX_Types header file contains the primitive type definitions used by
|
||||
* the core, the application and the component. This file may need to be
|
||||
* modified to be used on systems that do not have "char" set to 8 bits,
|
||||
* "short" set to 16 bits and "long" set to 32 bits.
|
||||
*/
|
||||
|
||||
#ifndef OMX_Types_h
|
||||
#define OMX_Types_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/** The OMX_API and OMX_APIENTRY are platform specific definitions used
|
||||
* to declare OMX function prototypes. They are modified to meet the
|
||||
* requirements for a particular platform */
|
||||
#ifdef __SYMBIAN32__
|
||||
# ifdef __OMX_EXPORTS
|
||||
# define OMX_API __declspec(dllexport)
|
||||
# else
|
||||
# ifdef _WIN32
|
||||
# define OMX_API __declspec(dllexport)
|
||||
# else
|
||||
# define OMX_API __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# ifdef _WIN32
|
||||
# ifdef __OMX_EXPORTS
|
||||
# define OMX_API __declspec(dllexport)
|
||||
# else
|
||||
//# define OMX_API __declspec(dllimport)
|
||||
#define OMX_API
|
||||
# endif
|
||||
# else
|
||||
# ifdef __OMX_EXPORTS
|
||||
# define OMX_API
|
||||
# else
|
||||
# define OMX_API extern
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef OMX_APIENTRY
|
||||
#define OMX_APIENTRY
|
||||
#endif
|
||||
|
||||
/** OMX_IN is used to identify inputs to an OMX function. This designation
|
||||
will also be used in the case of a pointer that points to a parameter
|
||||
that is used as an output. */
|
||||
#ifndef OMX_IN
|
||||
#define OMX_IN
|
||||
#endif
|
||||
|
||||
/** OMX_OUT is used to identify outputs from an OMX function. This
|
||||
designation will also be used in the case of a pointer that points
|
||||
to a parameter that is used as an input. */
|
||||
#ifndef OMX_OUT
|
||||
#define OMX_OUT
|
||||
#endif
|
||||
|
||||
|
||||
/** OMX_INOUT is used to identify parameters that may be either inputs or
|
||||
outputs from an OMX function at the same time. This designation will
|
||||
also be used in the case of a pointer that points to a parameter that
|
||||
is used both as an input and an output. */
|
||||
#ifndef OMX_INOUT
|
||||
#define OMX_INOUT
|
||||
#endif
|
||||
|
||||
/** OMX_ALL is used to as a wildcard to select all entities of the same type
|
||||
* when specifying the index, or referring to a object by an index. (i.e.
|
||||
* use OMX_ALL to indicate all N channels). When used as a port index
|
||||
* for a config or parameter this OMX_ALL denotes that the config or
|
||||
* parameter applies to the entire component not just one port. */
|
||||
#define OMX_ALL 0xFFFFFFFF
|
||||
|
||||
/** In the following we define groups that help building doxygen documentation */
|
||||
|
||||
/** @defgroup core OpenMAX IL core
|
||||
* Functions and structure related to the OMX IL core
|
||||
*/
|
||||
|
||||
/** @defgroup comp OpenMAX IL component
|
||||
* Functions and structure related to the OMX IL component
|
||||
*/
|
||||
|
||||
/** @defgroup rpm Resource and Policy Management
|
||||
* Structures for resource and policy management of components
|
||||
*/
|
||||
|
||||
/** @defgroup buf Buffer Management
|
||||
* Buffer handling functions and structures
|
||||
*/
|
||||
|
||||
/** @defgroup tun Tunneling
|
||||
* @ingroup core comp
|
||||
* Structures and functions to manage tunnels among component ports
|
||||
*/
|
||||
|
||||
/** @defgroup cp Content Pipes
|
||||
* @ingroup core
|
||||
*/
|
||||
|
||||
/** @defgroup metadata Metadata handling
|
||||
*
|
||||
*/
|
||||
|
||||
/** OMX_U8 is an 8 bit unsigned quantity that is byte aligned */
|
||||
typedef unsigned char OMX_U8;
|
||||
|
||||
/** OMX_S8 is an 8 bit signed quantity that is byte aligned */
|
||||
typedef signed char OMX_S8;
|
||||
|
||||
/** OMX_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */
|
||||
typedef unsigned short OMX_U16;
|
||||
|
||||
/** OMX_S16 is a 16 bit signed quantity that is 16 bit word aligned */
|
||||
typedef signed short OMX_S16;
|
||||
|
||||
/** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */
|
||||
typedef unsigned long OMX_U32;
|
||||
|
||||
/** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */
|
||||
typedef signed long OMX_S32;
|
||||
|
||||
|
||||
/* Users with compilers that cannot accept the "long long" designation should
|
||||
define the OMX_SKIP64BIT macro. It should be noted that this may cause
|
||||
some components to fail to compile if the component was written to require
|
||||
64 bit integral types. However, these components would NOT compile anyway
|
||||
since the compiler does not support the way the component was written.
|
||||
*/
|
||||
#ifndef OMX_SKIP64BIT
|
||||
#ifdef __SYMBIAN32__
|
||||
/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */
|
||||
typedef unsigned long long OMX_U64;
|
||||
|
||||
/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */
|
||||
typedef signed long long OMX_S64;
|
||||
|
||||
#elif defined(WIN32)
|
||||
|
||||
/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */
|
||||
typedef unsigned __int64 OMX_U64;
|
||||
|
||||
/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */
|
||||
typedef signed __int64 OMX_S64;
|
||||
|
||||
#else /* WIN32 */
|
||||
|
||||
/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */
|
||||
typedef unsigned long long OMX_U64;
|
||||
|
||||
/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */
|
||||
typedef signed long long OMX_S64;
|
||||
|
||||
#endif /* WIN32 */
|
||||
#endif
|
||||
|
||||
|
||||
/** The OMX_BOOL type is intended to be used to represent a true or a false
|
||||
value when passing parameters to and from the OMX core and components. The
|
||||
OMX_BOOL is a 32 bit quantity and is aligned on a 32 bit word boundary.
|
||||
*/
|
||||
typedef enum OMX_BOOL {
|
||||
OMX_FALSE = 0,
|
||||
OMX_TRUE = !OMX_FALSE,
|
||||
OMX_BOOL_MAX = 0x7FFFFFFF
|
||||
} OMX_BOOL;
|
||||
|
||||
/** The OMX_PTR type is intended to be used to pass pointers between the OMX
|
||||
applications and the OMX Core and components. This is a 32 bit pointer and
|
||||
is aligned on a 32 bit boundary.
|
||||
*/
|
||||
typedef void* OMX_PTR;
|
||||
|
||||
/** The OMX_STRING type is intended to be used to pass "C" type strings between
|
||||
the application and the core and component. The OMX_STRING type is a 32
|
||||
bit pointer to a zero terminated string. The pointer is word aligned and
|
||||
the string is byte aligned.
|
||||
*/
|
||||
typedef char* OMX_STRING;
|
||||
|
||||
/** The OMX_BYTE type is intended to be used to pass arrays of bytes such as
|
||||
buffers between the application and the component and core. The OMX_BYTE
|
||||
type is a 32 bit pointer to a zero terminated string. The pointer is word
|
||||
aligned and the string is byte aligned.
|
||||
*/
|
||||
typedef unsigned char* OMX_BYTE;
|
||||
|
||||
/** OMX_UUIDTYPE is a very long unique identifier to uniquely identify
|
||||
at runtime. This identifier should be generated by a component in a way
|
||||
that guarantees that every instance of the identifier running on the system
|
||||
is unique. */
|
||||
typedef unsigned char OMX_UUIDTYPE[128];
|
||||
|
||||
/** The OMX_DIRTYPE enumeration is used to indicate if a port is an input or
|
||||
an output port. This enumeration is common across all component types.
|
||||
*/
|
||||
typedef enum OMX_DIRTYPE
|
||||
{
|
||||
OMX_DirInput, /**< Port is an input port */
|
||||
OMX_DirOutput, /**< Port is an output port */
|
||||
OMX_DirMax = 0x7FFFFFFF
|
||||
} OMX_DIRTYPE;
|
||||
|
||||
/** The OMX_ENDIANTYPE enumeration is used to indicate the bit ordering
|
||||
for numerical data (i.e. big endian, or little endian).
|
||||
*/
|
||||
typedef enum OMX_ENDIANTYPE
|
||||
{
|
||||
OMX_EndianBig, /**< big endian */
|
||||
OMX_EndianLittle, /**< little endian */
|
||||
OMX_EndianMax = 0x7FFFFFFF
|
||||
} OMX_ENDIANTYPE;
|
||||
|
||||
|
||||
/** The OMX_NUMERICALDATATYPE enumeration is used to indicate if data
|
||||
is signed or unsigned
|
||||
*/
|
||||
typedef enum OMX_NUMERICALDATATYPE
|
||||
{
|
||||
OMX_NumericalDataSigned, /**< signed data */
|
||||
OMX_NumericalDataUnsigned, /**< unsigned data */
|
||||
OMX_NumercialDataMax = 0x7FFFFFFF
|
||||
} OMX_NUMERICALDATATYPE;
|
||||
|
||||
|
||||
/** Unsigned bounded value type */
|
||||
typedef struct OMX_BU32 {
|
||||
OMX_U32 nValue; /**< actual value */
|
||||
OMX_U32 nMin; /**< minimum for value (i.e. nValue >= nMin) */
|
||||
OMX_U32 nMax; /**< maximum for value (i.e. nValue <= nMax) */
|
||||
} OMX_BU32;
|
||||
|
||||
|
||||
/** Signed bounded value type */
|
||||
typedef struct OMX_BS32 {
|
||||
OMX_S32 nValue; /**< actual value */
|
||||
OMX_S32 nMin; /**< minimum for value (i.e. nValue >= nMin) */
|
||||
OMX_S32 nMax; /**< maximum for value (i.e. nValue <= nMax) */
|
||||
} OMX_BS32;
|
||||
|
||||
|
||||
/** Structure representing some time or duration in microseconds. This structure
|
||||
* must be interpreted as a signed 64 bit value. The quantity is signed to accommodate
|
||||
* negative deltas and preroll scenarios. The quantity is represented in microseconds
|
||||
* to accomodate high resolution timestamps (e.g. DVD presentation timestamps based
|
||||
* on a 90kHz clock) and to allow more accurate and synchronized delivery (e.g.
|
||||
* individual audio samples delivered at 192 kHz). The quantity is 64 bit to
|
||||
* accommodate a large dynamic range (signed 32 bit values would allow only for plus
|
||||
* or minus 35 minutes).
|
||||
*
|
||||
* Implementations with limited precision may convert the signed 64 bit value to
|
||||
* a signed 32 bit value internally but risk loss of precision.
|
||||
*/
|
||||
#ifndef OMX_SKIP64BIT
|
||||
typedef OMX_S64 OMX_TICKS;
|
||||
#else
|
||||
typedef struct OMX_TICKS
|
||||
{
|
||||
OMX_U32 nLowPart; /** low bits of the signed 64 bit tick value */
|
||||
OMX_U32 nHighPart; /** high bits of the signed 64 bit tick value */
|
||||
} OMX_TICKS;
|
||||
#endif
|
||||
#define OMX_TICKS_PER_SECOND 1000000
|
||||
|
||||
/** Define the public interface for the OMX Handle. The core will not use
|
||||
this value internally, but the application should only use this value.
|
||||
*/
|
||||
typedef void* OMX_HANDLETYPE;
|
||||
|
||||
typedef struct OMX_MARKTYPE
|
||||
{
|
||||
OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will
|
||||
generate a mark event upon
|
||||
processing the mark. */
|
||||
OMX_PTR pMarkData; /**< Application specific data associated with
|
||||
the mark sent on a mark event to disambiguate
|
||||
this mark from others. */
|
||||
} OMX_MARKTYPE;
|
||||
|
||||
|
||||
/** OMX_NATIVE_DEVICETYPE is used to map a OMX video port to the
|
||||
* platform & operating specific object used to reference the display
|
||||
* or can be used by a audio port for native audio rendering */
|
||||
typedef void* OMX_NATIVE_DEVICETYPE;
|
||||
|
||||
/** OMX_NATIVE_WINDOWTYPE is used to map a OMX video port to the
|
||||
* platform & operating specific object used to reference the window */
|
||||
typedef void* OMX_NATIVE_WINDOWTYPE;
|
||||
|
||||
/** The OMX_VERSIONTYPE union is used to specify the version for
|
||||
a structure or component. For a component, the version is entirely
|
||||
specified by the component vendor. Components doing the same function
|
||||
from different vendors may or may not have the same version. For
|
||||
structures, the version shall be set by the entity that allocates the
|
||||
structure. For structures specified in the OMX 1.1 specification, the
|
||||
value of the version shall be set to 1.1.0.0 in all cases. Access to the
|
||||
OMX_VERSIONTYPE can be by a single 32 bit access (e.g. by nVersion) or
|
||||
by accessing one of the structure elements to, for example, check only
|
||||
the Major revision.
|
||||
*/
|
||||
typedef union OMX_VERSIONTYPE
|
||||
{
|
||||
struct
|
||||
{
|
||||
OMX_U8 nVersionMajor; /**< Major version accessor element */
|
||||
OMX_U8 nVersionMinor; /**< Minor version accessor element */
|
||||
OMX_U8 nRevision; /**< Revision version accessor element */
|
||||
OMX_U8 nStep; /**< Step version accessor element */
|
||||
} s;
|
||||
OMX_U32 nVersion; /**< 32 bit value to make accessing the
|
||||
version easily done in a single word
|
||||
size copy/compare operation */
|
||||
} OMX_VERSIONTYPE;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
/* File EOF */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_PIXELFLINGER_FORMAT_H
|
||||
#define ANDROID_PIXELFLINGER_FORMAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
enum GGLPixelFormat {
|
||||
// these constants need to match those
|
||||
// in graphics/PixelFormat.java, ui/PixelFormat.h, BlitHardware.h
|
||||
GGL_PIXEL_FORMAT_UNKNOWN = 0,
|
||||
GGL_PIXEL_FORMAT_NONE = 0,
|
||||
|
||||
GGL_PIXEL_FORMAT_RGBA_8888 = 1, // 4x8-bit ARGB
|
||||
GGL_PIXEL_FORMAT_RGBX_8888 = 2, // 3x8-bit RGB stored in 32-bit chunks
|
||||
GGL_PIXEL_FORMAT_RGB_888 = 3, // 3x8-bit RGB
|
||||
GGL_PIXEL_FORMAT_RGB_565 = 4, // 16-bit RGB
|
||||
GGL_PIXEL_FORMAT_BGRA_8888 = 5, // 4x8-bit BGRA
|
||||
GGL_PIXEL_FORMAT_RGBA_5551 = 6, // 16-bit RGBA
|
||||
GGL_PIXEL_FORMAT_RGBA_4444 = 7, // 16-bit RGBA
|
||||
|
||||
GGL_PIXEL_FORMAT_A_8 = 8, // 8-bit A
|
||||
GGL_PIXEL_FORMAT_L_8 = 9, // 8-bit L (R=G=B = L)
|
||||
GGL_PIXEL_FORMAT_LA_88 = 0xA, // 16-bit LA
|
||||
GGL_PIXEL_FORMAT_RGB_332 = 0xB, // 8-bit RGB (non paletted)
|
||||
|
||||
// reserved range. don't use.
|
||||
GGL_PIXEL_FORMAT_RESERVED_10 = 0x10,
|
||||
GGL_PIXEL_FORMAT_RESERVED_11 = 0x11,
|
||||
GGL_PIXEL_FORMAT_RESERVED_12 = 0x12,
|
||||
GGL_PIXEL_FORMAT_RESERVED_13 = 0x13,
|
||||
GGL_PIXEL_FORMAT_RESERVED_14 = 0x14,
|
||||
GGL_PIXEL_FORMAT_RESERVED_15 = 0x15,
|
||||
GGL_PIXEL_FORMAT_RESERVED_16 = 0x16,
|
||||
GGL_PIXEL_FORMAT_RESERVED_17 = 0x17,
|
||||
|
||||
// reserved/special formats
|
||||
GGL_PIXEL_FORMAT_Z_16 = 0x18,
|
||||
GGL_PIXEL_FORMAT_S_8 = 0x19,
|
||||
GGL_PIXEL_FORMAT_SZ_24 = 0x1A,
|
||||
GGL_PIXEL_FORMAT_SZ_8 = 0x1B,
|
||||
|
||||
// reserved range. don't use.
|
||||
GGL_PIXEL_FORMAT_RESERVED_20 = 0x20,
|
||||
GGL_PIXEL_FORMAT_RESERVED_21 = 0x21,
|
||||
};
|
||||
|
||||
enum GGLFormatComponents {
|
||||
GGL_STENCIL_INDEX = 0x1901,
|
||||
GGL_DEPTH_COMPONENT = 0x1902,
|
||||
GGL_ALPHA = 0x1906,
|
||||
GGL_RGB = 0x1907,
|
||||
GGL_RGBA = 0x1908,
|
||||
GGL_LUMINANCE = 0x1909,
|
||||
GGL_LUMINANCE_ALPHA = 0x190A,
|
||||
};
|
||||
|
||||
enum GGLFormatComponentIndex {
|
||||
GGL_INDEX_ALPHA = 0,
|
||||
GGL_INDEX_RED = 1,
|
||||
GGL_INDEX_GREEN = 2,
|
||||
GGL_INDEX_BLUE = 3,
|
||||
GGL_INDEX_STENCIL = 0,
|
||||
GGL_INDEX_DEPTH = 1,
|
||||
GGL_INDEX_Y = 0,
|
||||
GGL_INDEX_CB = 1,
|
||||
GGL_INDEX_CR = 2,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
#ifdef __cplusplus
|
||||
enum {
|
||||
ALPHA = GGL_INDEX_ALPHA,
|
||||
RED = GGL_INDEX_RED,
|
||||
GREEN = GGL_INDEX_GREEN,
|
||||
BLUE = GGL_INDEX_BLUE,
|
||||
STENCIL = GGL_INDEX_STENCIL,
|
||||
DEPTH = GGL_INDEX_DEPTH,
|
||||
LUMA = GGL_INDEX_Y,
|
||||
CHROMAB = GGL_INDEX_CB,
|
||||
CHROMAR = GGL_INDEX_CR,
|
||||
};
|
||||
inline uint32_t mask(int i) const {
|
||||
return ((1<<(c[i].h-c[i].l))-1)<<c[i].l;
|
||||
}
|
||||
inline uint32_t bits(int i) const {
|
||||
return c[i].h - c[i].l;
|
||||
}
|
||||
#endif
|
||||
uint8_t size; // bytes per pixel
|
||||
uint8_t bitsPerPixel;
|
||||
union {
|
||||
struct {
|
||||
uint8_t ah; // alpha high bit position + 1
|
||||
uint8_t al; // alpha low bit position
|
||||
uint8_t rh; // red high bit position + 1
|
||||
uint8_t rl; // red low bit position
|
||||
uint8_t gh; // green high bit position + 1
|
||||
uint8_t gl; // green low bit position
|
||||
uint8_t bh; // blue high bit position + 1
|
||||
uint8_t bl; // blue low bit position
|
||||
};
|
||||
struct {
|
||||
uint8_t h;
|
||||
uint8_t l;
|
||||
} __attribute__((__packed__)) c[4];
|
||||
} __attribute__((__packed__));
|
||||
uint16_t components; // GGLFormatComponents
|
||||
} GGLFormat;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" const GGLFormat* gglGetPixelFormatTable(size_t* numEntries = 0);
|
||||
#else
|
||||
const GGLFormat* gglGetPixelFormatTable(size_t* numEntries);
|
||||
#endif
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_PIXELFLINGER_FORMAT_H
|
|
@ -1,330 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007 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 ANDROID_PIXELFLINGER_H
|
||||
#define ANDROID_PIXELFLINGER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <pixelflinger/format.h>
|
||||
|
||||
// GGL types
|
||||
|
||||
typedef int8_t GGLbyte; // b
|
||||
typedef int16_t GGLshort; // s
|
||||
typedef int32_t GGLint; // i
|
||||
typedef ssize_t GGLsizei; // i
|
||||
typedef int32_t GGLfixed; // x
|
||||
typedef int32_t GGLclampx; // x
|
||||
typedef float GGLfloat; // f
|
||||
typedef float GGLclampf; // f
|
||||
typedef double GGLdouble; // d
|
||||
typedef double GGLclampd; // d
|
||||
typedef uint8_t GGLubyte; // ub
|
||||
typedef uint8_t GGLboolean; // ub
|
||||
typedef uint16_t GGLushort; // us
|
||||
typedef uint32_t GGLuint; // ui
|
||||
typedef unsigned int GGLenum; // ui
|
||||
typedef unsigned int GGLbitfield; // ui
|
||||
typedef void GGLvoid;
|
||||
typedef int32_t GGLfixed32;
|
||||
typedef int32_t GGLcolor;
|
||||
typedef int32_t GGLcoord;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define GGL_MAX_VIEWPORT_DIMS 4096
|
||||
#define GGL_MAX_TEXTURE_SIZE 4096
|
||||
#define GGL_MAX_ALIASED_POINT_SIZE 0x7FFFFFF
|
||||
#define GGL_MAX_SMOOTH_POINT_SIZE 2048
|
||||
#define GGL_MAX_SMOOTH_LINE_WIDTH 2048
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// All these names are compatible with their OpenGL equivalents
|
||||
// some of them are listed only for completeness
|
||||
enum GGLNames {
|
||||
GGL_FALSE = 0,
|
||||
GGL_TRUE = 1,
|
||||
|
||||
// enable/disable
|
||||
GGL_SCISSOR_TEST = 0x0C11,
|
||||
GGL_TEXTURE_2D = 0x0DE1,
|
||||
GGL_ALPHA_TEST = 0x0BC0,
|
||||
GGL_BLEND = 0x0BE2,
|
||||
GGL_COLOR_LOGIC_OP = 0x0BF2,
|
||||
GGL_DITHER = 0x0BD0,
|
||||
GGL_STENCIL_TEST = 0x0B90,
|
||||
GGL_DEPTH_TEST = 0x0B71,
|
||||
GGL_AA = 0x80000001,
|
||||
GGL_W_LERP = 0x80000004,
|
||||
GGL_POINT_SMOOTH_NICE = 0x80000005,
|
||||
|
||||
// buffers, pixel drawing/reading
|
||||
GGL_COLOR = 0x1800,
|
||||
|
||||
// fog
|
||||
GGL_FOG = 0x0B60,
|
||||
|
||||
// shade model
|
||||
GGL_FLAT = 0x1D00,
|
||||
GGL_SMOOTH = 0x1D01,
|
||||
|
||||
// Texture parameter name
|
||||
GGL_TEXTURE_MIN_FILTER = 0x2801,
|
||||
GGL_TEXTURE_MAG_FILTER = 0x2800,
|
||||
GGL_TEXTURE_WRAP_S = 0x2802,
|
||||
GGL_TEXTURE_WRAP_T = 0x2803,
|
||||
GGL_TEXTURE_WRAP_R = 0x2804,
|
||||
|
||||
// Texture Filter
|
||||
GGL_NEAREST = 0x2600,
|
||||
GGL_LINEAR = 0x2601,
|
||||
GGL_NEAREST_MIPMAP_NEAREST = 0x2700,
|
||||
GGL_LINEAR_MIPMAP_NEAREST = 0x2701,
|
||||
GGL_NEAREST_MIPMAP_LINEAR = 0x2702,
|
||||
GGL_LINEAR_MIPMAP_LINEAR = 0x2703,
|
||||
|
||||
// Texture Wrap Mode
|
||||
GGL_CLAMP = 0x2900,
|
||||
GGL_REPEAT = 0x2901,
|
||||
GGL_CLAMP_TO_EDGE = 0x812F,
|
||||
|
||||
// Texture Env Mode
|
||||
GGL_REPLACE = 0x1E01,
|
||||
GGL_MODULATE = 0x2100,
|
||||
GGL_DECAL = 0x2101,
|
||||
GGL_ADD = 0x0104,
|
||||
|
||||
// Texture Env Parameter
|
||||
GGL_TEXTURE_ENV_MODE = 0x2200,
|
||||
GGL_TEXTURE_ENV_COLOR = 0x2201,
|
||||
|
||||
// Texture Env Target
|
||||
GGL_TEXTURE_ENV = 0x2300,
|
||||
|
||||
// Texture coord generation
|
||||
GGL_TEXTURE_GEN_MODE = 0x2500,
|
||||
GGL_S = 0x2000,
|
||||
GGL_T = 0x2001,
|
||||
GGL_R = 0x2002,
|
||||
GGL_Q = 0x2003,
|
||||
GGL_ONE_TO_ONE = 0x80000002,
|
||||
GGL_AUTOMATIC = 0x80000003,
|
||||
|
||||
// AlphaFunction
|
||||
GGL_NEVER = 0x0200,
|
||||
GGL_LESS = 0x0201,
|
||||
GGL_EQUAL = 0x0202,
|
||||
GGL_LEQUAL = 0x0203,
|
||||
GGL_GREATER = 0x0204,
|
||||
GGL_NOTEQUAL = 0x0205,
|
||||
GGL_GEQUAL = 0x0206,
|
||||
GGL_ALWAYS = 0x0207,
|
||||
|
||||
// LogicOp
|
||||
GGL_CLEAR = 0x1500, // 0
|
||||
GGL_AND = 0x1501, // s & d
|
||||
GGL_AND_REVERSE = 0x1502, // s & ~d
|
||||
GGL_COPY = 0x1503, // s
|
||||
GGL_AND_INVERTED = 0x1504, // ~s & d
|
||||
GGL_NOOP = 0x1505, // d
|
||||
GGL_XOR = 0x1506, // s ^ d
|
||||
GGL_OR = 0x1507, // s | d
|
||||
GGL_NOR = 0x1508, // ~(s | d)
|
||||
GGL_EQUIV = 0x1509, // ~(s ^ d)
|
||||
GGL_INVERT = 0x150A, // ~d
|
||||
GGL_OR_REVERSE = 0x150B, // s | ~d
|
||||
GGL_COPY_INVERTED = 0x150C, // ~s
|
||||
GGL_OR_INVERTED = 0x150D, // ~s | d
|
||||
GGL_NAND = 0x150E, // ~(s & d)
|
||||
GGL_SET = 0x150F, // 1
|
||||
|
||||
// blending equation & function
|
||||
GGL_ZERO = 0, // SD
|
||||
GGL_ONE = 1, // SD
|
||||
GGL_SRC_COLOR = 0x0300, // D
|
||||
GGL_ONE_MINUS_SRC_COLOR = 0x0301, // D
|
||||
GGL_SRC_ALPHA = 0x0302, // SD
|
||||
GGL_ONE_MINUS_SRC_ALPHA = 0x0303, // SD
|
||||
GGL_DST_ALPHA = 0x0304, // SD
|
||||
GGL_ONE_MINUS_DST_ALPHA = 0x0305, // SD
|
||||
GGL_DST_COLOR = 0x0306, // S
|
||||
GGL_ONE_MINUS_DST_COLOR = 0x0307, // S
|
||||
GGL_SRC_ALPHA_SATURATE = 0x0308, // S
|
||||
|
||||
// clear bits
|
||||
GGL_DEPTH_BUFFER_BIT = 0x00000100,
|
||||
GGL_STENCIL_BUFFER_BIT = 0x00000400,
|
||||
GGL_COLOR_BUFFER_BIT = 0x00004000,
|
||||
|
||||
// errors
|
||||
GGL_NO_ERROR = 0,
|
||||
GGL_INVALID_ENUM = 0x0500,
|
||||
GGL_INVALID_VALUE = 0x0501,
|
||||
GGL_INVALID_OPERATION = 0x0502,
|
||||
GGL_STACK_OVERFLOW = 0x0503,
|
||||
GGL_STACK_UNDERFLOW = 0x0504,
|
||||
GGL_OUT_OF_MEMORY = 0x0505
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
typedef struct {
|
||||
GGLsizei version; // always set to sizeof(GGLSurface)
|
||||
GGLuint width; // width in pixels
|
||||
GGLuint height; // height in pixels
|
||||
GGLint stride; // stride in pixels
|
||||
GGLubyte* data; // pointer to the bits
|
||||
GGLubyte format; // pixel format
|
||||
GGLubyte rfu[3]; // must be zero
|
||||
// these values are dependent on the used format
|
||||
union {
|
||||
GGLint compressedFormat;
|
||||
GGLint vstride;
|
||||
};
|
||||
void* reserved;
|
||||
} GGLSurface;
|
||||
|
||||
|
||||
typedef struct {
|
||||
// immediate rendering
|
||||
void (*pointx)(void *con, const GGLcoord* v, GGLcoord r);
|
||||
void (*linex)(void *con,
|
||||
const GGLcoord* v0, const GGLcoord* v1, GGLcoord width);
|
||||
void (*recti)(void* c, GGLint l, GGLint t, GGLint r, GGLint b);
|
||||
void (*trianglex)(void* c,
|
||||
GGLcoord const* v0, GGLcoord const* v1, GGLcoord const* v2);
|
||||
|
||||
// scissor
|
||||
void (*scissor)(void* c, GGLint x, GGLint y, GGLsizei width, GGLsizei height);
|
||||
|
||||
// Set the textures and color buffers
|
||||
void (*activeTexture)(void* c, GGLuint tmu);
|
||||
void (*bindTexture)(void* c, const GGLSurface* surface);
|
||||
void (*colorBuffer)(void* c, const GGLSurface* surface);
|
||||
void (*readBuffer)(void* c, const GGLSurface* surface);
|
||||
void (*depthBuffer)(void* c, const GGLSurface* surface);
|
||||
void (*bindTextureLod)(void* c, GGLuint tmu, const GGLSurface* surface);
|
||||
|
||||
// enable/disable features
|
||||
void (*enable)(void* c, GGLenum name);
|
||||
void (*disable)(void* c, GGLenum name);
|
||||
void (*enableDisable)(void* c, GGLenum name, GGLboolean en);
|
||||
|
||||
// specify the fragment's color
|
||||
void (*shadeModel)(void* c, GGLenum mode);
|
||||
void (*color4xv)(void* c, const GGLclampx* color);
|
||||
// specify color iterators (16.16)
|
||||
void (*colorGrad12xv)(void* c, const GGLcolor* grad);
|
||||
|
||||
// specify Z coordinate iterators (0.32)
|
||||
void (*zGrad3xv)(void* c, const GGLfixed32* grad);
|
||||
|
||||
// specify W coordinate iterators (16.16)
|
||||
void (*wGrad3xv)(void* c, const GGLfixed* grad);
|
||||
|
||||
// specify fog iterator & color (16.16)
|
||||
void (*fogGrad3xv)(void* c, const GGLfixed* grad);
|
||||
void (*fogColor3xv)(void* c, const GGLclampx* color);
|
||||
|
||||
// specify blending parameters
|
||||
void (*blendFunc)(void* c, GGLenum src, GGLenum dst);
|
||||
void (*blendFuncSeparate)(void* c, GGLenum src, GGLenum dst,
|
||||
GGLenum srcAlpha, GGLenum dstAplha);
|
||||
|
||||
// texture environnement (REPLACE / MODULATE / DECAL / BLEND)
|
||||
void (*texEnvi)(void* c, GGLenum target,
|
||||
GGLenum pname,
|
||||
GGLint param);
|
||||
|
||||
void (*texEnvxv)(void* c, GGLenum target,
|
||||
GGLenum pname, const GGLfixed* params);
|
||||
|
||||
// texture parameters (Wrapping, filter)
|
||||
void (*texParameteri)(void* c, GGLenum target,
|
||||
GGLenum pname,
|
||||
GGLint param);
|
||||
|
||||
// texture iterators (16.16)
|
||||
void (*texCoord2i)(void* c, GGLint s, GGLint t);
|
||||
void (*texCoord2x)(void* c, GGLfixed s, GGLfixed t);
|
||||
|
||||
// s, dsdx, dsdy, scale, t, dtdx, dtdy, tscale
|
||||
// This api uses block floating-point for S and T texture coordinates.
|
||||
// All values are given in 16.16, scaled by 'scale'. In other words,
|
||||
// set scale to 0, for 16.16 values.
|
||||
void (*texCoordGradScale8xv)(void* c, GGLint tmu, const int32_t* grad8);
|
||||
|
||||
void (*texGeni)(void* c, GGLenum coord, GGLenum pname, GGLint param);
|
||||
|
||||
// masking
|
||||
void (*colorMask)(void* c, GGLboolean red,
|
||||
GGLboolean green,
|
||||
GGLboolean blue,
|
||||
GGLboolean alpha);
|
||||
|
||||
void (*depthMask)(void* c, GGLboolean flag);
|
||||
|
||||
void (*stencilMask)(void* c, GGLuint mask);
|
||||
|
||||
// alpha func
|
||||
void (*alphaFuncx)(void* c, GGLenum func, GGLclampx ref);
|
||||
|
||||
// depth func
|
||||
void (*depthFunc)(void* c, GGLenum func);
|
||||
|
||||
// logic op
|
||||
void (*logicOp)(void* c, GGLenum opcode);
|
||||
|
||||
// clear
|
||||
void (*clear)(void* c, GGLbitfield mask);
|
||||
void (*clearColorx)(void* c,
|
||||
GGLclampx r, GGLclampx g, GGLclampx b, GGLclampx a);
|
||||
void (*clearDepthx)(void* c, GGLclampx depth);
|
||||
void (*clearStencil)(void* c, GGLint s);
|
||||
|
||||
// framebuffer operations
|
||||
void (*copyPixels)(void* c, GGLint x, GGLint y,
|
||||
GGLsizei width, GGLsizei height, GGLenum type);
|
||||
void (*rasterPos2x)(void* c, GGLfixed x, GGLfixed y);
|
||||
void (*rasterPos2i)(void* c, GGLint x, GGLint y);
|
||||
} GGLContext;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// construct / destroy the context
|
||||
ssize_t gglInit(GGLContext** context);
|
||||
ssize_t gglUninit(GGLContext* context);
|
||||
|
||||
GGLint gglBitBlit(
|
||||
GGLContext* c,
|
||||
int tmu,
|
||||
GGLint crop[4],
|
||||
GGLint where[4]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_PIXELFLINGER_H
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* 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 COLOR_CONVERTER_H_
|
||||
|
||||
#define COLOR_CONVERTER_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <utils/Errors.h>
|
||||
|
||||
#include <OMX_Video.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
struct ColorConverter {
|
||||
ColorConverter(OMX_COLOR_FORMATTYPE from, OMX_COLOR_FORMATTYPE to);
|
||||
~ColorConverter();
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
status_t convert(
|
||||
const void *srcBits,
|
||||
size_t srcWidth, size_t srcHeight,
|
||||
size_t srcCropLeft, size_t srcCropTop,
|
||||
size_t srcCropRight, size_t srcCropBottom,
|
||||
void *dstBits,
|
||||
size_t dstWidth, size_t dstHeight,
|
||||
size_t dstCropLeft, size_t dstCropTop,
|
||||
size_t dstCropRight, size_t dstCropBottom);
|
||||
|
||||
private:
|
||||
struct BitmapParams {
|
||||
BitmapParams(
|
||||
void *bits,
|
||||
size_t width, size_t height,
|
||||
size_t cropLeft, size_t cropTop,
|
||||
size_t cropRight, size_t cropBottom);
|
||||
|
||||
size_t cropWidth() const;
|
||||
size_t cropHeight() const;
|
||||
|
||||
void *mBits;
|
||||
size_t mWidth, mHeight;
|
||||
size_t mCropLeft, mCropTop, mCropRight, mCropBottom;
|
||||
};
|
||||
|
||||
OMX_COLOR_FORMATTYPE mSrcFormat, mDstFormat;
|
||||
uint8_t *mClip;
|
||||
|
||||
uint8_t *initClip();
|
||||
|
||||
status_t convertCbYCrY(
|
||||
const BitmapParams &src, const BitmapParams &dst);
|
||||
|
||||
status_t convertYUV420Planar(
|
||||
const BitmapParams &src, const BitmapParams &dst);
|
||||
|
||||
status_t convertQCOMYUV420SemiPlanar(
|
||||
const BitmapParams &src, const BitmapParams &dst);
|
||||
|
||||
status_t convertYUV420SemiPlanar(
|
||||
const BitmapParams &src, const BitmapParams &dst);
|
||||
|
||||
status_t convertTIYUV420PackedSemiPlanar(
|
||||
const BitmapParams &src, const BitmapParams &dst);
|
||||
|
||||
ColorConverter(const ColorConverter &);
|
||||
ColorConverter &operator=(const ColorConverter &);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // COLOR_CONVERTER_H_
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* 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 DATA_SOURCE_H_
|
||||
|
||||
#define DATA_SOURCE_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <media/stagefright/MediaErrors.h>
|
||||
#include <utils/Errors.h>
|
||||
#include <utils/KeyedVector.h>
|
||||
#include <utils/List.h>
|
||||
#include <utils/RefBase.h>
|
||||
#include <utils/threads.h>
|
||||
#include <drm/DrmManagerClient.h>
|
||||
|
||||
#if !defined(STAGEFRIGHT_EXPORT)
|
||||
#define STAGEFRIGHT_EXPORT
|
||||
#endif
|
||||
|
||||
namespace android {
|
||||
|
||||
struct AMessage;
|
||||
class String8;
|
||||
|
||||
class STAGEFRIGHT_EXPORT DataSource : public RefBase {
|
||||
public:
|
||||
enum Flags {
|
||||
kWantsPrefetching = 1,
|
||||
kStreamedFromLocalHost = 2,
|
||||
kIsCachingDataSource = 4,
|
||||
kIsHTTPBasedSource = 8,
|
||||
};
|
||||
|
||||
static sp<DataSource> CreateFromURI(
|
||||
const char *uri,
|
||||
const KeyedVector<String8, String8> *headers = NULL);
|
||||
|
||||
DataSource() {}
|
||||
|
||||
virtual status_t initCheck() const = 0;
|
||||
|
||||
virtual ssize_t readAt(off64_t offset, void *data, size_t size) = 0;
|
||||
|
||||
// Convenience methods:
|
||||
bool getUInt16(off64_t offset, uint16_t *x);
|
||||
|
||||
// May return ERROR_UNSUPPORTED.
|
||||
virtual status_t getSize(off64_t *size);
|
||||
|
||||
virtual uint32_t flags() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual status_t reconnectAtOffset(off64_t offset) {
|
||||
return ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool sniff(String8 *mimeType, float *confidence, sp<AMessage> *meta);
|
||||
|
||||
// The sniffer can optionally fill in "meta" with an AMessage containing
|
||||
// a dictionary of values that helps the corresponding extractor initialize
|
||||
// its state without duplicating effort already exerted by the sniffer.
|
||||
typedef bool (*SnifferFunc)(
|
||||
const sp<DataSource> &source, String8 *mimeType,
|
||||
float *confidence, sp<AMessage> *meta);
|
||||
|
||||
static void RegisterSniffer(SnifferFunc func);
|
||||
static void RegisterDefaultSniffers();
|
||||
|
||||
// for DRM
|
||||
virtual sp<DecryptHandle> DrmInitialization() {
|
||||
return NULL;
|
||||
}
|
||||
virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client) {};
|
||||
|
||||
virtual String8 getUri() {
|
||||
return String8();
|
||||
}
|
||||
|
||||
virtual String8 getMIMEType() const;
|
||||
|
||||
protected:
|
||||
virtual ~DataSource() {}
|
||||
|
||||
private:
|
||||
static Mutex gSnifferMutex;
|
||||
static List<SnifferFunc> gSniffers;
|
||||
|
||||
DataSource(const DataSource &);
|
||||
DataSource &operator=(const DataSource &);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // DATA_SOURCE_H_
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* 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 MEDIA_EXTRACTOR_H_
|
||||
|
||||
#define MEDIA_EXTRACTOR_H_
|
||||
|
||||
#include <utils/RefBase.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class DataSource;
|
||||
struct MediaSource;
|
||||
class MetaData;
|
||||
|
||||
class MediaExtractor : public RefBase {
|
||||
public:
|
||||
static sp<MediaExtractor> Create(
|
||||
const sp<DataSource> &source, const char *mime = NULL);
|
||||
|
||||
virtual size_t countTracks() = 0;
|
||||
virtual sp<MediaSource> getTrack(size_t index) = 0;
|
||||
|
||||
enum GetTrackMetaDataFlags {
|
||||
kIncludeExtensiveMetaData = 1
|
||||
};
|
||||
virtual sp<MetaData> getTrackMetaData(
|
||||
size_t index, uint32_t flags = 0) = 0;
|
||||
|
||||
// Return container specific meta-data. The default implementation
|
||||
// returns an empty metadata object.
|
||||
virtual sp<MetaData> getMetaData();
|
||||
|
||||
enum Flags {
|
||||
CAN_SEEK_BACKWARD = 1, // the "seek 10secs back button"
|
||||
CAN_SEEK_FORWARD = 2, // the "seek 10secs forward button"
|
||||
CAN_PAUSE = 4,
|
||||
CAN_SEEK = 8, // the "seek bar"
|
||||
};
|
||||
|
||||
// If subclasses do _not_ override this, the default is
|
||||
// CAN_SEEK_BACKWARD | CAN_SEEK_FORWARD | CAN_SEEK | CAN_PAUSE
|
||||
virtual uint32_t flags() const;
|
||||
|
||||
// for DRM
|
||||
virtual void setDrmFlag(bool flag) {
|
||||
mIsDrm = flag;
|
||||
};
|
||||
virtual bool getDrmFlag() {
|
||||
return mIsDrm;
|
||||
}
|
||||
virtual char* getDrmTrackInfo(size_t trackID, int *len) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
protected:
|
||||
MediaExtractor() {}
|
||||
virtual ~MediaExtractor() {}
|
||||
|
||||
private:
|
||||
bool mIsDrm;
|
||||
|
||||
MediaExtractor(const MediaExtractor &);
|
||||
MediaExtractor &operator=(const MediaExtractor &);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // MEDIA_EXTRACTOR_H_
|
|
@ -1,231 +0,0 @@
|
|||
/*
|
||||
* 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 META_DATA_H_
|
||||
|
||||
#define META_DATA_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <utils/RefBase.h>
|
||||
#include <utils/KeyedVector.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
// The following keys map to int32_t data unless indicated otherwise.
|
||||
enum {
|
||||
kKeyMIMEType = 'mime', // cstring
|
||||
kKeyWidth = 'widt', // int32_t, image pixel
|
||||
kKeyHeight = 'heig', // int32_t, image pixel
|
||||
kKeyDisplayWidth = 'dWid', // int32_t, display/presentation
|
||||
kKeyDisplayHeight = 'dHgt', // int32_t, display/presentation
|
||||
|
||||
// a rectangle, if absent assumed to be (0, 0, width - 1, height - 1)
|
||||
kKeyCropRect = 'crop',
|
||||
|
||||
kKeyRotation = 'rotA', // int32_t (angle in degrees)
|
||||
kKeyIFramesInterval = 'ifiv', // int32_t
|
||||
kKeyStride = 'strd', // int32_t
|
||||
kKeySliceHeight = 'slht', // int32_t
|
||||
kKeyChannelCount = '#chn', // int32_t
|
||||
kKeySampleRate = 'srte', // int32_t (audio sampling rate Hz)
|
||||
kKeyFrameRate = 'frmR', // int32_t (video frame rate fps)
|
||||
kKeyBitRate = 'brte', // int32_t (bps)
|
||||
kKeyESDS = 'esds', // raw data
|
||||
kKeyAVCC = 'avcc', // raw data
|
||||
kKeyD263 = 'd263', // raw data
|
||||
kKeyVorbisInfo = 'vinf', // raw data
|
||||
kKeyVorbisBooks = 'vboo', // raw data
|
||||
kKeyWantsNALFragments = 'NALf',
|
||||
kKeyIsSyncFrame = 'sync', // int32_t (bool)
|
||||
kKeyIsCodecConfig = 'conf', // int32_t (bool)
|
||||
kKeyTime = 'time', // int64_t (usecs)
|
||||
kKeyDecodingTime = 'decT', // int64_t (decoding timestamp in usecs)
|
||||
kKeyNTPTime = 'ntpT', // uint64_t (ntp-timestamp)
|
||||
kKeyTargetTime = 'tarT', // int64_t (usecs)
|
||||
kKeyDriftTime = 'dftT', // int64_t (usecs)
|
||||
kKeyAnchorTime = 'ancT', // int64_t (usecs)
|
||||
kKeyDuration = 'dura', // int64_t (usecs)
|
||||
kKeyColorFormat = 'colf',
|
||||
kKeyPlatformPrivate = 'priv', // pointer
|
||||
kKeyDecoderComponent = 'decC', // cstring
|
||||
kKeyBufferID = 'bfID',
|
||||
kKeyMaxInputSize = 'inpS',
|
||||
kKeyThumbnailTime = 'thbT', // int64_t (usecs)
|
||||
kKeyTrackID = 'trID',
|
||||
kKeyIsDRM = 'idrm', // int32_t (bool)
|
||||
|
||||
kKeyAlbum = 'albu', // cstring
|
||||
kKeyArtist = 'arti', // cstring
|
||||
kKeyAlbumArtist = 'aart', // cstring
|
||||
kKeyComposer = 'comp', // cstring
|
||||
kKeyGenre = 'genr', // cstring
|
||||
kKeyTitle = 'titl', // cstring
|
||||
kKeyYear = 'year', // cstring
|
||||
kKeyAlbumArt = 'albA', // compressed image data
|
||||
kKeyAlbumArtMIME = 'alAM', // cstring
|
||||
kKeyAuthor = 'auth', // cstring
|
||||
kKeyCDTrackNumber = 'cdtr', // cstring
|
||||
kKeyDiscNumber = 'dnum', // cstring
|
||||
kKeyDate = 'date', // cstring
|
||||
kKeyWriter = 'writ', // cstring
|
||||
kKeyCompilation = 'cpil', // cstring
|
||||
kKeyLocation = 'loc ', // cstring
|
||||
kKeyTimeScale = 'tmsl', // int32_t
|
||||
|
||||
// video profile and level
|
||||
kKeyVideoProfile = 'vprf', // int32_t
|
||||
kKeyVideoLevel = 'vlev', // int32_t
|
||||
|
||||
// Set this key to enable authoring files in 64-bit offset
|
||||
kKey64BitFileOffset = 'fobt', // int32_t (bool)
|
||||
kKey2ByteNalLength = '2NAL', // int32_t (bool)
|
||||
|
||||
// Identify the file output format for authoring
|
||||
// Please see <media/mediarecorder.h> for the supported
|
||||
// file output formats.
|
||||
kKeyFileType = 'ftyp', // int32_t
|
||||
|
||||
// Track authoring progress status
|
||||
// kKeyTrackTimeStatus is used to track progress in elapsed time
|
||||
kKeyTrackTimeStatus = 'tktm', // int64_t
|
||||
|
||||
kKeyNotRealTime = 'ntrt', // bool (int32_t)
|
||||
|
||||
// Ogg files can be tagged to be automatically looping...
|
||||
kKeyAutoLoop = 'autL', // bool (int32_t)
|
||||
|
||||
kKeyValidSamples = 'valD', // int32_t
|
||||
|
||||
kKeyIsUnreadable = 'unre', // bool (int32_t)
|
||||
|
||||
// An indication that a video buffer has been rendered.
|
||||
kKeyRendered = 'rend', // bool (int32_t)
|
||||
|
||||
// The language code for this media
|
||||
kKeyMediaLanguage = 'lang', // cstring
|
||||
|
||||
// To store the timed text format data
|
||||
kKeyTextFormatData = 'text', // raw data
|
||||
|
||||
kKeyRequiresSecureBuffers = 'secu', // bool (int32_t)
|
||||
};
|
||||
|
||||
enum {
|
||||
kTypeESDS = 'esds',
|
||||
kTypeAVCC = 'avcc',
|
||||
kTypeD263 = 'd263',
|
||||
};
|
||||
|
||||
class MetaData : public RefBase {
|
||||
public:
|
||||
MetaData();
|
||||
MetaData(const MetaData &from);
|
||||
|
||||
enum Type {
|
||||
TYPE_NONE = 'none',
|
||||
TYPE_C_STRING = 'cstr',
|
||||
TYPE_INT32 = 'in32',
|
||||
TYPE_INT64 = 'in64',
|
||||
TYPE_FLOAT = 'floa',
|
||||
TYPE_POINTER = 'ptr ',
|
||||
TYPE_RECT = 'rect',
|
||||
};
|
||||
|
||||
void clear();
|
||||
bool remove(uint32_t key);
|
||||
|
||||
bool setCString(uint32_t key, const char *value);
|
||||
bool setInt32(uint32_t key, int32_t value);
|
||||
bool setInt64(uint32_t key, int64_t value);
|
||||
bool setFloat(uint32_t key, float value);
|
||||
bool setPointer(uint32_t key, void *value);
|
||||
|
||||
bool setRect(
|
||||
uint32_t key,
|
||||
int32_t left, int32_t top,
|
||||
int32_t right, int32_t bottom);
|
||||
|
||||
bool findCString(uint32_t key, const char **value);
|
||||
bool findInt32(uint32_t key, int32_t *value);
|
||||
bool findInt64(uint32_t key, int64_t *value);
|
||||
bool findFloat(uint32_t key, float *value);
|
||||
bool findPointer(uint32_t key, void **value);
|
||||
|
||||
bool findRect(
|
||||
uint32_t key,
|
||||
int32_t *left, int32_t *top,
|
||||
int32_t *right, int32_t *bottom);
|
||||
|
||||
bool setData(uint32_t key, uint32_t type, const void *data, size_t size);
|
||||
|
||||
bool findData(uint32_t key, uint32_t *type,
|
||||
const void **data, size_t *size) const;
|
||||
|
||||
protected:
|
||||
virtual ~MetaData();
|
||||
|
||||
private:
|
||||
struct typed_data {
|
||||
typed_data();
|
||||
~typed_data();
|
||||
|
||||
typed_data(const MetaData::typed_data &);
|
||||
typed_data &operator=(const MetaData::typed_data &);
|
||||
|
||||
void clear();
|
||||
void setData(uint32_t type, const void *data, size_t size);
|
||||
void getData(uint32_t *type, const void **data, size_t *size) const;
|
||||
|
||||
private:
|
||||
uint32_t mType;
|
||||
size_t mSize;
|
||||
|
||||
union {
|
||||
void *ext_data;
|
||||
float reservoir;
|
||||
} u;
|
||||
|
||||
bool usesReservoir() const {
|
||||
return mSize <= sizeof(u.reservoir);
|
||||
}
|
||||
|
||||
void allocateStorage(size_t size);
|
||||
void freeStorage();
|
||||
|
||||
void *storage() {
|
||||
return usesReservoir() ? &u.reservoir : u.ext_data;
|
||||
}
|
||||
|
||||
const void *storage() const {
|
||||
return usesReservoir() ? &u.reservoir : u.ext_data;
|
||||
}
|
||||
};
|
||||
|
||||
struct Rect {
|
||||
int32_t mLeft, mTop, mRight, mBottom;
|
||||
};
|
||||
|
||||
KeyedVector<uint32_t, typed_data> mItems;
|
||||
|
||||
// MetaData &operator=(const MetaData &);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // META_DATA_H_
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* 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_CLIENT_H_
|
||||
|
||||
#define OMX_CLIENT_H_
|
||||
|
||||
#include <media/IOMX.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class OMXClient {
|
||||
public:
|
||||
OMXClient();
|
||||
|
||||
status_t connect();
|
||||
void disconnect();
|
||||
|
||||
sp<IOMX> interface() {
|
||||
return mOMX;
|
||||
}
|
||||
|
||||
private:
|
||||
sp<IOMX> mOMX;
|
||||
|
||||
OMXClient(const OMXClient &);
|
||||
OMXClient &operator=(const OMXClient &);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // OMX_CLIENT_H_
|
|
@ -1,378 +0,0 @@
|
|||
/*
|
||||
* 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_CODEC_H_
|
||||
|
||||
#define OMX_CODEC_H_
|
||||
|
||||
#include <android/native_window.h>
|
||||
#include <media/IOMX.h>
|
||||
#include <media/stagefright/MediaBuffer.h>
|
||||
#include <media/stagefright/MediaSource.h>
|
||||
#include <utils/threads.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class MemoryDealer;
|
||||
struct OMXCodecObserver;
|
||||
struct CodecProfileLevel;
|
||||
|
||||
struct OMXCodec : public MediaSource,
|
||||
public MediaBufferObserver {
|
||||
enum CreationFlags {
|
||||
kPreferSoftwareCodecs = 1,
|
||||
kIgnoreCodecSpecificData = 2,
|
||||
|
||||
// The client wants to access the output buffer's video
|
||||
// data for example for thumbnail extraction.
|
||||
kClientNeedsFramebuffer = 4,
|
||||
|
||||
// Request for software or hardware codecs. If request
|
||||
// can not be fullfilled, Create() returns NULL.
|
||||
kSoftwareCodecsOnly = 8,
|
||||
kHardwareCodecsOnly = 16,
|
||||
|
||||
// Store meta data in video buffers
|
||||
kStoreMetaDataInVideoBuffers = 32,
|
||||
|
||||
// Only submit one input buffer at one time.
|
||||
kOnlySubmitOneInputBufferAtOneTime = 64,
|
||||
|
||||
// Enable GRALLOC_USAGE_PROTECTED for output buffers from native window
|
||||
kEnableGrallocUsageProtected = 128,
|
||||
|
||||
// Secure decoding mode
|
||||
kUseSecureInputBuffers = 256,
|
||||
};
|
||||
static sp<MediaSource> Create(
|
||||
const sp<IOMX> &omx,
|
||||
const sp<MetaData> &meta, bool createEncoder,
|
||||
const sp<MediaSource> &source,
|
||||
const char *matchComponentName = NULL,
|
||||
uint32_t flags = 0,
|
||||
const sp<ANativeWindow> &nativeWindow = NULL);
|
||||
|
||||
static void setComponentRole(
|
||||
const sp<IOMX> &omx, IOMX::node_id node, bool isEncoder,
|
||||
const char *mime);
|
||||
|
||||
virtual status_t start(MetaData *params = NULL);
|
||||
virtual status_t stop();
|
||||
|
||||
virtual sp<MetaData> getFormat();
|
||||
|
||||
virtual status_t read(
|
||||
MediaBuffer **buffer, const ReadOptions *options = NULL);
|
||||
|
||||
virtual status_t pause();
|
||||
|
||||
// from MediaBufferObserver
|
||||
virtual void signalBufferReturned(MediaBuffer *buffer);
|
||||
|
||||
// for use by ACodec
|
||||
static void findMatchingCodecs(
|
||||
const char *mime,
|
||||
bool createEncoder, const char *matchComponentName,
|
||||
uint32_t flags,
|
||||
Vector<String8> *matchingCodecs);
|
||||
|
||||
protected:
|
||||
virtual ~OMXCodec();
|
||||
|
||||
private:
|
||||
|
||||
// Make sure mLock is accessible to OMXCodecObserver
|
||||
friend class OMXCodecObserver;
|
||||
|
||||
// Call this with mLock hold
|
||||
void on_message(const omx_message &msg);
|
||||
|
||||
enum State {
|
||||
DEAD,
|
||||
LOADED,
|
||||
LOADED_TO_IDLE,
|
||||
IDLE_TO_EXECUTING,
|
||||
EXECUTING,
|
||||
EXECUTING_TO_IDLE,
|
||||
IDLE_TO_LOADED,
|
||||
RECONFIGURING,
|
||||
ERROR
|
||||
};
|
||||
|
||||
enum {
|
||||
kPortIndexInput = 0,
|
||||
kPortIndexOutput = 1
|
||||
};
|
||||
|
||||
enum PortStatus {
|
||||
ENABLED,
|
||||
DISABLING,
|
||||
DISABLED,
|
||||
ENABLING,
|
||||
SHUTTING_DOWN,
|
||||
};
|
||||
|
||||
enum Quirks {
|
||||
kNeedsFlushBeforeDisable = 1,
|
||||
kWantsNALFragments = 2,
|
||||
kRequiresLoadedToIdleAfterAllocation = 4,
|
||||
kRequiresAllocateBufferOnInputPorts = 8,
|
||||
kRequiresFlushCompleteEmulation = 16,
|
||||
kRequiresAllocateBufferOnOutputPorts = 32,
|
||||
kRequiresFlushBeforeShutdown = 64,
|
||||
kDefersOutputBufferAllocation = 128,
|
||||
kDecoderLiesAboutNumberOfChannels = 256,
|
||||
kInputBufferSizesAreBogus = 512,
|
||||
kSupportsMultipleFramesPerInputBuffer = 1024,
|
||||
kAvoidMemcopyInputRecordingFrames = 2048,
|
||||
kRequiresLargerEncoderOutputBuffer = 4096,
|
||||
kOutputBuffersAreUnreadable = 8192,
|
||||
};
|
||||
|
||||
enum BufferStatus {
|
||||
OWNED_BY_US,
|
||||
OWNED_BY_COMPONENT,
|
||||
OWNED_BY_NATIVE_WINDOW,
|
||||
OWNED_BY_CLIENT,
|
||||
};
|
||||
|
||||
struct BufferInfo {
|
||||
IOMX::buffer_id mBuffer;
|
||||
BufferStatus mStatus;
|
||||
sp<IMemory> mMem;
|
||||
size_t mSize;
|
||||
void *mData;
|
||||
MediaBuffer *mMediaBuffer;
|
||||
};
|
||||
|
||||
struct CodecSpecificData {
|
||||
size_t mSize;
|
||||
uint8_t mData[1];
|
||||
};
|
||||
|
||||
sp<IOMX> mOMX;
|
||||
bool mOMXLivesLocally;
|
||||
IOMX::node_id mNode;
|
||||
uint32_t mQuirks;
|
||||
|
||||
// Flags specified in the creation of the codec.
|
||||
uint32_t mFlags;
|
||||
|
||||
bool mIsEncoder;
|
||||
char *mMIME;
|
||||
char *mComponentName;
|
||||
sp<MetaData> mOutputFormat;
|
||||
sp<MediaSource> mSource;
|
||||
Vector<CodecSpecificData *> mCodecSpecificData;
|
||||
size_t mCodecSpecificDataIndex;
|
||||
|
||||
sp<MemoryDealer> mDealer[2];
|
||||
|
||||
State mState;
|
||||
Vector<BufferInfo> mPortBuffers[2];
|
||||
PortStatus mPortStatus[2];
|
||||
bool mInitialBufferSubmit;
|
||||
bool mSignalledEOS;
|
||||
status_t mFinalStatus;
|
||||
bool mNoMoreOutputData;
|
||||
bool mOutputPortSettingsHaveChanged;
|
||||
int64_t mSeekTimeUs;
|
||||
ReadOptions::SeekMode mSeekMode;
|
||||
int64_t mTargetTimeUs;
|
||||
bool mOutputPortSettingsChangedPending;
|
||||
|
||||
MediaBuffer *mLeftOverBuffer;
|
||||
|
||||
Mutex mLock;
|
||||
Condition mAsyncCompletion;
|
||||
|
||||
bool mPaused;
|
||||
|
||||
sp<ANativeWindow> mNativeWindow;
|
||||
|
||||
// The index in each of the mPortBuffers arrays of the buffer that will be
|
||||
// submitted to OMX next. This only applies when using buffers from a
|
||||
// native window.
|
||||
size_t mNextNativeBufferIndex[2];
|
||||
|
||||
// A list of indices into mPortStatus[kPortIndexOutput] filled with data.
|
||||
List<size_t> mFilledBuffers;
|
||||
Condition mBufferFilled;
|
||||
|
||||
// Used to record the decoding time for an output picture from
|
||||
// a video encoder.
|
||||
List<int64_t> mDecodingTimeList;
|
||||
|
||||
OMXCodec(const sp<IOMX> &omx, IOMX::node_id node,
|
||||
uint32_t quirks, uint32_t flags,
|
||||
bool isEncoder, const char *mime, const char *componentName,
|
||||
const sp<MediaSource> &source,
|
||||
const sp<ANativeWindow> &nativeWindow);
|
||||
|
||||
void addCodecSpecificData(const void *data, size_t size);
|
||||
void clearCodecSpecificData();
|
||||
|
||||
void setComponentRole();
|
||||
|
||||
void setAMRFormat(bool isWAMR, int32_t bitRate);
|
||||
status_t setAACFormat(int32_t numChannels, int32_t sampleRate, int32_t bitRate);
|
||||
void setG711Format(int32_t numChannels);
|
||||
|
||||
status_t setVideoPortFormatType(
|
||||
OMX_U32 portIndex,
|
||||
OMX_VIDEO_CODINGTYPE compressionFormat,
|
||||
OMX_COLOR_FORMATTYPE colorFormat);
|
||||
|
||||
void setVideoInputFormat(
|
||||
const char *mime, const sp<MetaData>& meta);
|
||||
|
||||
status_t setupBitRate(int32_t bitRate);
|
||||
status_t setupErrorCorrectionParameters();
|
||||
status_t setupH263EncoderParameters(const sp<MetaData>& meta);
|
||||
status_t setupMPEG4EncoderParameters(const sp<MetaData>& meta);
|
||||
status_t setupAVCEncoderParameters(const sp<MetaData>& meta);
|
||||
status_t findTargetColorFormat(
|
||||
const sp<MetaData>& meta, OMX_COLOR_FORMATTYPE *colorFormat);
|
||||
|
||||
status_t isColorFormatSupported(
|
||||
OMX_COLOR_FORMATTYPE colorFormat, int portIndex);
|
||||
|
||||
// If profile/level is set in the meta data, its value in the meta
|
||||
// data will be used; otherwise, the default value will be used.
|
||||
status_t getVideoProfileLevel(const sp<MetaData>& meta,
|
||||
const CodecProfileLevel& defaultProfileLevel,
|
||||
CodecProfileLevel& profileLevel);
|
||||
|
||||
status_t setVideoOutputFormat(
|
||||
const char *mime, OMX_U32 width, OMX_U32 height);
|
||||
|
||||
void setImageOutputFormat(
|
||||
OMX_COLOR_FORMATTYPE format, OMX_U32 width, OMX_U32 height);
|
||||
|
||||
void setJPEGInputFormat(
|
||||
OMX_U32 width, OMX_U32 height, OMX_U32 compressedSize);
|
||||
|
||||
void setMinBufferSize(OMX_U32 portIndex, OMX_U32 size);
|
||||
|
||||
void setRawAudioFormat(
|
||||
OMX_U32 portIndex, int32_t sampleRate, int32_t numChannels);
|
||||
|
||||
status_t allocateBuffers();
|
||||
status_t allocateBuffersOnPort(OMX_U32 portIndex);
|
||||
status_t allocateOutputBuffersFromNativeWindow();
|
||||
|
||||
status_t queueBufferToNativeWindow(BufferInfo *info);
|
||||
status_t cancelBufferToNativeWindow(BufferInfo *info);
|
||||
BufferInfo* dequeueBufferFromNativeWindow();
|
||||
status_t pushBlankBuffersToNativeWindow();
|
||||
|
||||
status_t freeBuffersOnPort(
|
||||
OMX_U32 portIndex, bool onlyThoseWeOwn = false);
|
||||
|
||||
status_t freeBuffer(OMX_U32 portIndex, size_t bufIndex);
|
||||
|
||||
bool drainInputBuffer(IOMX::buffer_id buffer);
|
||||
void fillOutputBuffer(IOMX::buffer_id buffer);
|
||||
bool drainInputBuffer(BufferInfo *info);
|
||||
void fillOutputBuffer(BufferInfo *info);
|
||||
|
||||
void drainInputBuffers();
|
||||
void fillOutputBuffers();
|
||||
|
||||
bool drainAnyInputBuffer();
|
||||
BufferInfo *findInputBufferByDataPointer(void *ptr);
|
||||
BufferInfo *findEmptyInputBuffer();
|
||||
|
||||
// Returns true iff a flush was initiated and a completion event is
|
||||
// upcoming, false otherwise (A flush was not necessary as we own all
|
||||
// the buffers on that port).
|
||||
// This method will ONLY ever return false for a component with quirk
|
||||
// "kRequiresFlushCompleteEmulation".
|
||||
bool flushPortAsync(OMX_U32 portIndex);
|
||||
|
||||
void disablePortAsync(OMX_U32 portIndex);
|
||||
status_t enablePortAsync(OMX_U32 portIndex);
|
||||
|
||||
static size_t countBuffersWeOwn(const Vector<BufferInfo> &buffers);
|
||||
static bool isIntermediateState(State state);
|
||||
|
||||
void onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2);
|
||||
void onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data);
|
||||
void onStateChange(OMX_STATETYPE newState);
|
||||
void onPortSettingsChanged(OMX_U32 portIndex);
|
||||
|
||||
void setState(State newState);
|
||||
|
||||
status_t init();
|
||||
void initOutputFormat(const sp<MetaData> &inputFormat);
|
||||
status_t initNativeWindow();
|
||||
|
||||
void initNativeWindowCrop();
|
||||
|
||||
void dumpPortStatus(OMX_U32 portIndex);
|
||||
|
||||
status_t configureCodec(const sp<MetaData> &meta);
|
||||
|
||||
static uint32_t getComponentQuirks(
|
||||
const char *componentName, bool isEncoder);
|
||||
|
||||
void restorePatchedDataPointer(BufferInfo *info);
|
||||
|
||||
status_t applyRotation();
|
||||
status_t waitForBufferFilled_l();
|
||||
|
||||
int64_t retrieveDecodingTimeUs(bool isCodecSpecific);
|
||||
|
||||
status_t parseAVCCodecSpecificData(
|
||||
const void *data, size_t size,
|
||||
unsigned *profile, unsigned *level);
|
||||
|
||||
OMXCodec(const OMXCodec &);
|
||||
OMXCodec &operator=(const OMXCodec &);
|
||||
};
|
||||
|
||||
struct CodecCapabilities {
|
||||
String8 mComponentName;
|
||||
Vector<CodecProfileLevel> mProfileLevels;
|
||||
Vector<OMX_U32> mColorFormats;
|
||||
};
|
||||
|
||||
// Return a vector of componentNames with supported profile/level pairs
|
||||
// supporting the given mime type, if queryDecoders==true, returns components
|
||||
// that decode content of the given type, otherwise returns components
|
||||
// that encode content of the given type.
|
||||
// profile and level indications only make sense for h.263, mpeg4 and avc
|
||||
// video.
|
||||
// If hwCodecOnly==true, only returns hardware-based components, software and
|
||||
// hardware otherwise.
|
||||
// The profile/level values correspond to
|
||||
// OMX_VIDEO_H263PROFILETYPE, OMX_VIDEO_MPEG4PROFILETYPE,
|
||||
// OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263LEVELTYPE, OMX_VIDEO_MPEG4LEVELTYPE
|
||||
// and OMX_VIDEO_AVCLEVELTYPE respectively.
|
||||
|
||||
status_t QueryCodecs(
|
||||
const sp<IOMX> &omx,
|
||||
const char *mimeType, bool queryDecoders, bool hwCodecOnly,
|
||||
Vector<CodecCapabilities> *results);
|
||||
|
||||
status_t QueryCodecs(
|
||||
const sp<IOMX> &omx,
|
||||
const char *mimeType, bool queryDecoders,
|
||||
Vector<CodecCapabilities> *results);
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // OMX_CODEC_H_
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* 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 SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H
|
||||
#define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If the HAL needs to create service threads to handle graphics related
|
||||
* tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority
|
||||
* if they can block the main rendering thread in any way.
|
||||
*
|
||||
* the priority of the current thread can be set with:
|
||||
*
|
||||
* #include <sys/resource.h>
|
||||
* setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);
|
||||
*
|
||||
*/
|
||||
|
||||
#define HAL_PRIORITY_URGENT_DISPLAY (-8)
|
||||
|
||||
/**
|
||||
* pixel format definitions
|
||||
*/
|
||||
|
||||
enum {
|
||||
HAL_PIXEL_FORMAT_RGBA_8888 = 1,
|
||||
HAL_PIXEL_FORMAT_RGBX_8888 = 2,
|
||||
HAL_PIXEL_FORMAT_RGB_888 = 3,
|
||||
HAL_PIXEL_FORMAT_RGB_565 = 4,
|
||||
HAL_PIXEL_FORMAT_BGRA_8888 = 5,
|
||||
HAL_PIXEL_FORMAT_RGBA_5551 = 6,
|
||||
HAL_PIXEL_FORMAT_RGBA_4444 = 7,
|
||||
|
||||
/* 0x8 - 0xFF range unavailable */
|
||||
|
||||
/*
|
||||
* 0x100 - 0x1FF
|
||||
*
|
||||
* This range is reserved for pixel formats that are specific to the HAL
|
||||
* implementation. Implementations can use any value in this range to
|
||||
* communicate video pixel formats between their HAL modules. These formats
|
||||
* must not have an alpha channel. Additionally, an EGLimage created from a
|
||||
* gralloc buffer of one of these formats must be supported for use with the
|
||||
* GL_OES_EGL_image_external OpenGL ES extension.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Android YUV format:
|
||||
*
|
||||
* This format is exposed outside of the HAL to software decoders and
|
||||
* applications. EGLImageKHR must support it in conjunction with the
|
||||
* OES_EGL_image_external extension.
|
||||
*
|
||||
* YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed
|
||||
* by (W/2) x (H/2) Cr and Cb planes.
|
||||
*
|
||||
* This format assumes
|
||||
* - an even width
|
||||
* - an even height
|
||||
* - a horizontal stride multiple of 16 pixels
|
||||
* - a vertical stride equal to the height
|
||||
*
|
||||
* y_size = stride * height
|
||||
* c_size = ALIGN(stride/2, 16) * height/2
|
||||
* size = y_size + c_size * 2
|
||||
* cr_offset = y_size
|
||||
* cb_offset = y_size + c_size
|
||||
*
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar
|
||||
|
||||
|
||||
|
||||
/* Legacy formats (deprecated), used by ImageFormat.java */
|
||||
HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16
|
||||
HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21
|
||||
HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Transformation definitions
|
||||
*
|
||||
* IMPORTANT NOTE:
|
||||
* HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}.
|
||||
*
|
||||
*/
|
||||
|
||||
enum {
|
||||
/* flip source image horizontally (around the vertical axis) */
|
||||
HAL_TRANSFORM_FLIP_H = 0x01,
|
||||
/* flip source image vertically (around the horizontal axis)*/
|
||||
HAL_TRANSFORM_FLIP_V = 0x02,
|
||||
/* rotate source image 90 degrees clockwise */
|
||||
HAL_TRANSFORM_ROT_90 = 0x04,
|
||||
/* rotate source image 180 degrees */
|
||||
HAL_TRANSFORM_ROT_180 = 0x03,
|
||||
/* rotate source image 270 degrees clockwise */
|
||||
HAL_TRANSFORM_ROT_270 = 0x07,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */
|
|
@ -1,632 +0,0 @@
|
|||
/*
|
||||
* 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 SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
|
||||
#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <system/graphics.h>
|
||||
#include <cutils/native_handle.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
|
||||
(((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d))
|
||||
|
||||
#define ANDROID_NATIVE_WINDOW_MAGIC \
|
||||
ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
|
||||
|
||||
#define ANDROID_NATIVE_BUFFER_MAGIC \
|
||||
ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
typedef const native_handle_t* buffer_handle_t;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
typedef struct android_native_rect_t
|
||||
{
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t right;
|
||||
int32_t bottom;
|
||||
} android_native_rect_t;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
typedef struct android_native_base_t
|
||||
{
|
||||
/* a magic value defined by the actual EGL native type */
|
||||
int magic;
|
||||
|
||||
/* the sizeof() of the actual EGL native type */
|
||||
int version;
|
||||
|
||||
void* reserved[4];
|
||||
|
||||
/* reference-counting interface */
|
||||
void (*incRef)(struct android_native_base_t* base);
|
||||
void (*decRef)(struct android_native_base_t* base);
|
||||
} android_native_base_t;
|
||||
|
||||
typedef struct ANativeWindowBuffer
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
ANativeWindowBuffer() {
|
||||
common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
|
||||
common.version = sizeof(ANativeWindowBuffer);
|
||||
memset(common.reserved, 0, sizeof(common.reserved));
|
||||
}
|
||||
|
||||
// Implement the methods that sp<ANativeWindowBuffer> expects so that it
|
||||
// can be used to automatically refcount ANativeWindowBuffer's.
|
||||
void incStrong(const void* id) const {
|
||||
common.incRef(const_cast<android_native_base_t*>(&common));
|
||||
}
|
||||
void decStrong(const void* id) const {
|
||||
common.decRef(const_cast<android_native_base_t*>(&common));
|
||||
}
|
||||
#endif
|
||||
|
||||
struct android_native_base_t common;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int stride;
|
||||
int format;
|
||||
int usage;
|
||||
|
||||
void* reserved[2];
|
||||
|
||||
buffer_handle_t handle;
|
||||
|
||||
void* reserved_proc[8];
|
||||
} ANativeWindowBuffer_t;
|
||||
|
||||
// Old typedef for backwards compatibility.
|
||||
typedef ANativeWindowBuffer_t android_native_buffer_t;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/* attributes queriable with query() */
|
||||
enum {
|
||||
NATIVE_WINDOW_WIDTH = 0,
|
||||
NATIVE_WINDOW_HEIGHT = 1,
|
||||
NATIVE_WINDOW_FORMAT = 2,
|
||||
|
||||
/* The minimum number of buffers that must remain un-dequeued after a buffer
|
||||
* has been queued. This value applies only if set_buffer_count was used to
|
||||
* override the number of buffers and if a buffer has since been queued.
|
||||
* Users of the set_buffer_count ANativeWindow method should query this
|
||||
* value before calling set_buffer_count. If it is necessary to have N
|
||||
* buffers simultaneously dequeued as part of the steady-state operation,
|
||||
* and this query returns M then N+M buffers should be requested via
|
||||
* native_window_set_buffer_count.
|
||||
*
|
||||
* Note that this value does NOT apply until a single buffer has been
|
||||
* queued. In particular this means that it is possible to:
|
||||
*
|
||||
* 1. Query M = min undequeued buffers
|
||||
* 2. Set the buffer count to N + M
|
||||
* 3. Dequeue all N + M buffers
|
||||
* 4. Cancel M buffers
|
||||
* 5. Queue, dequeue, queue, dequeue, ad infinitum
|
||||
*/
|
||||
NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,
|
||||
|
||||
/* Check whether queueBuffer operations on the ANativeWindow send the buffer
|
||||
* to the window compositor. The query sets the returned 'value' argument
|
||||
* to 1 if the ANativeWindow DOES send queued buffers directly to the window
|
||||
* compositor and 0 if the buffers do not go directly to the window
|
||||
* compositor.
|
||||
*
|
||||
* This can be used to determine whether protected buffer content should be
|
||||
* sent to the ANativeWindow. Note, however, that a result of 1 does NOT
|
||||
* indicate that queued buffers will be protected from applications or users
|
||||
* capturing their contents. If that behavior is desired then some other
|
||||
* mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
|
||||
* conjunction with this query.
|
||||
*/
|
||||
NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,
|
||||
|
||||
/* Get the concrete type of a ANativeWindow. See below for the list of
|
||||
* possible return values.
|
||||
*
|
||||
* This query should not be used outside the Android framework and will
|
||||
* likely be removed in the near future.
|
||||
*/
|
||||
NATIVE_WINDOW_CONCRETE_TYPE = 5,
|
||||
|
||||
|
||||
/*
|
||||
* Default width and height of the ANativeWindow, these are the dimensions
|
||||
* of the window irrespective of the NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
|
||||
* call.
|
||||
*/
|
||||
NATIVE_WINDOW_DEFAULT_WIDTH = 6,
|
||||
NATIVE_WINDOW_DEFAULT_HEIGHT = 7,
|
||||
|
||||
/*
|
||||
* transformation that will most-likely be applied to buffers. This is only
|
||||
* a hint, the actual transformation applied might be different.
|
||||
*
|
||||
* INTENDED USE:
|
||||
*
|
||||
* The transform hint can be used by a producer, for instance the GLES
|
||||
* driver, to pre-rotate the rendering such that the final transformation
|
||||
* in the composer is identity. This can be very useful when used in
|
||||
* conjunction with the h/w composer HAL, in situations where it
|
||||
* cannot handle arbitrary rotations.
|
||||
*
|
||||
* 1. Before dequeuing a buffer, the GL driver (or any other ANW client)
|
||||
* queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.
|
||||
*
|
||||
* 2. The GL driver overrides the width and height of the ANW to
|
||||
* account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying
|
||||
* NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions
|
||||
* according to NATIVE_WINDOW_TRANSFORM_HINT and calling
|
||||
* native_window_set_buffers_dimensions().
|
||||
*
|
||||
* 3. The GL driver dequeues a buffer of the new pre-rotated size.
|
||||
*
|
||||
* 4. The GL driver renders to the buffer such that the image is
|
||||
* already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT
|
||||
* to the rendering.
|
||||
*
|
||||
* 5. The GL driver calls native_window_set_transform to apply
|
||||
* inverse transformation to the buffer it just rendered.
|
||||
* In order to do this, the GL driver needs
|
||||
* to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is
|
||||
* done easily:
|
||||
*
|
||||
* int hintTransform, inverseTransform;
|
||||
* query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);
|
||||
* inverseTransform = hintTransform;
|
||||
* if (hintTransform & HAL_TRANSFORM_ROT_90)
|
||||
* inverseTransform ^= HAL_TRANSFORM_ROT_180;
|
||||
*
|
||||
*
|
||||
* 6. The GL driver queues the pre-transformed buffer.
|
||||
*
|
||||
* 7. The composer combines the buffer transform with the display
|
||||
* transform. If the buffer transform happens to cancel out the
|
||||
* display transform then no rotation is needed.
|
||||
*
|
||||
*/
|
||||
NATIVE_WINDOW_TRANSFORM_HINT = 8,
|
||||
};
|
||||
|
||||
/* valid operations for the (*perform)() hook */
|
||||
enum {
|
||||
NATIVE_WINDOW_SET_USAGE = 0,
|
||||
NATIVE_WINDOW_CONNECT = 1, /* deprecated */
|
||||
NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */
|
||||
NATIVE_WINDOW_SET_CROP = 3,
|
||||
NATIVE_WINDOW_SET_BUFFER_COUNT = 4,
|
||||
NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */
|
||||
NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6,
|
||||
NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7,
|
||||
NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8,
|
||||
NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9,
|
||||
NATIVE_WINDOW_SET_SCALING_MODE = 10,
|
||||
NATIVE_WINDOW_LOCK = 11, /* private */
|
||||
NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */
|
||||
NATIVE_WINDOW_API_CONNECT = 13, /* private */
|
||||
NATIVE_WINDOW_API_DISCONNECT = 14, /* private */
|
||||
};
|
||||
|
||||
/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
|
||||
enum {
|
||||
/* Buffers will be queued by EGL via eglSwapBuffers after being filled using
|
||||
* OpenGL ES.
|
||||
*/
|
||||
NATIVE_WINDOW_API_EGL = 1,
|
||||
|
||||
/* Buffers will be queued after being filled using the CPU
|
||||
*/
|
||||
NATIVE_WINDOW_API_CPU = 2,
|
||||
|
||||
/* Buffers will be queued by Stagefright after being filled by a video
|
||||
* decoder. The video decoder can either be a software or hardware decoder.
|
||||
*/
|
||||
NATIVE_WINDOW_API_MEDIA = 3,
|
||||
|
||||
/* Buffers will be queued by the the camera HAL.
|
||||
*/
|
||||
NATIVE_WINDOW_API_CAMERA = 4,
|
||||
};
|
||||
|
||||
/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
|
||||
enum {
|
||||
/* flip source image horizontally */
|
||||
NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
|
||||
/* flip source image vertically */
|
||||
NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
|
||||
/* rotate source image 90 degrees clock-wise */
|
||||
NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
|
||||
/* rotate source image 180 degrees */
|
||||
NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
|
||||
/* rotate source image 270 degrees clock-wise */
|
||||
NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
|
||||
};
|
||||
|
||||
/* parameter for NATIVE_WINDOW_SET_SCALING_MODE */
|
||||
enum {
|
||||
/* the window content is not updated (frozen) until a buffer of
|
||||
* the window size is received (enqueued)
|
||||
*/
|
||||
NATIVE_WINDOW_SCALING_MODE_FREEZE = 0,
|
||||
/* the buffer is scaled in both dimensions to match the window size */
|
||||
NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1,
|
||||
};
|
||||
|
||||
/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
|
||||
enum {
|
||||
NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */
|
||||
NATIVE_WINDOW_SURFACE = 1, /* Surface */
|
||||
NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT = 2, /* SurfaceTextureClient */
|
||||
};
|
||||
|
||||
/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
|
||||
*
|
||||
* Special timestamp value to indicate that timestamps should be auto-generated
|
||||
* by the native window when queueBuffer is called. This is equal to INT64_MIN,
|
||||
* defined directly to avoid problems with C99/C++ inclusion of stdint.h.
|
||||
*/
|
||||
static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
|
||||
|
||||
struct ANativeWindow
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
ANativeWindow()
|
||||
: flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
|
||||
{
|
||||
common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
|
||||
common.version = sizeof(ANativeWindow);
|
||||
memset(common.reserved, 0, sizeof(common.reserved));
|
||||
}
|
||||
|
||||
/* Implement the methods that sp<ANativeWindow> expects so that it
|
||||
can be used to automatically refcount ANativeWindow's. */
|
||||
void incStrong(const void* id) const {
|
||||
common.incRef(const_cast<android_native_base_t*>(&common));
|
||||
}
|
||||
void decStrong(const void* id) const {
|
||||
common.decRef(const_cast<android_native_base_t*>(&common));
|
||||
}
|
||||
#endif
|
||||
|
||||
struct android_native_base_t common;
|
||||
|
||||
/* flags describing some attributes of this surface or its updater */
|
||||
const uint32_t flags;
|
||||
|
||||
/* min swap interval supported by this updated */
|
||||
const int minSwapInterval;
|
||||
|
||||
/* max swap interval supported by this updated */
|
||||
const int maxSwapInterval;
|
||||
|
||||
/* horizontal and vertical resolution in DPI */
|
||||
const float xdpi;
|
||||
const float ydpi;
|
||||
|
||||
/* Some storage reserved for the OEM's driver. */
|
||||
intptr_t oem[4];
|
||||
|
||||
/*
|
||||
* Set the swap interval for this surface.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*setSwapInterval)(struct ANativeWindow* window,
|
||||
int interval);
|
||||
|
||||
/*
|
||||
* Hook called by EGL to acquire a buffer. After this call, the buffer
|
||||
* is not locked, so its content cannot be modified. This call may block if
|
||||
* no buffers are available.
|
||||
*
|
||||
* The window holds a reference to the buffer between dequeueBuffer and
|
||||
* either queueBuffer or cancelBuffer, so clients only need their own
|
||||
* reference if they might use the buffer after queueing or canceling it.
|
||||
* Holding a reference to a buffer after queueing or canceling it is only
|
||||
* allowed if a specific buffer count has been set.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*dequeueBuffer)(struct ANativeWindow* window,
|
||||
struct ANativeWindowBuffer** buffer);
|
||||
|
||||
/*
|
||||
* hook called by EGL to lock a buffer. This MUST be called before modifying
|
||||
* the content of a buffer. The buffer must have been acquired with
|
||||
* dequeueBuffer first.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*lockBuffer)(struct ANativeWindow* window,
|
||||
struct ANativeWindowBuffer* buffer);
|
||||
/*
|
||||
* Hook called by EGL when modifications to the render buffer are done.
|
||||
* This unlocks and post the buffer.
|
||||
*
|
||||
* The window holds a reference to the buffer between dequeueBuffer and
|
||||
* either queueBuffer or cancelBuffer, so clients only need their own
|
||||
* reference if they might use the buffer after queueing or canceling it.
|
||||
* Holding a reference to a buffer after queueing or canceling it is only
|
||||
* allowed if a specific buffer count has been set.
|
||||
*
|
||||
* Buffers MUST be queued in the same order than they were dequeued.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*queueBuffer)(struct ANativeWindow* window,
|
||||
struct ANativeWindowBuffer* buffer);
|
||||
|
||||
/*
|
||||
* hook used to retrieve information about the native window.
|
||||
*
|
||||
* Returns 0 on success or -errno on error.
|
||||
*/
|
||||
int (*query)(const struct ANativeWindow* window,
|
||||
int what, int* value);
|
||||
|
||||
/*
|
||||
* hook used to perform various operations on the surface.
|
||||
* (*perform)() is a generic mechanism to add functionality to
|
||||
* ANativeWindow while keeping backward binary compatibility.
|
||||
*
|
||||
* DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions
|
||||
* defined below.
|
||||
*
|
||||
* (*perform)() returns -ENOENT if the 'what' parameter is not supported
|
||||
* by the surface's implementation.
|
||||
*
|
||||
* The valid operations are:
|
||||
* NATIVE_WINDOW_SET_USAGE
|
||||
* NATIVE_WINDOW_CONNECT (deprecated)
|
||||
* NATIVE_WINDOW_DISCONNECT (deprecated)
|
||||
* NATIVE_WINDOW_SET_CROP
|
||||
* NATIVE_WINDOW_SET_BUFFER_COUNT
|
||||
* NATIVE_WINDOW_SET_BUFFERS_GEOMETRY (deprecated)
|
||||
* NATIVE_WINDOW_SET_BUFFERS_TRANSFORM
|
||||
* NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
|
||||
* NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
|
||||
* NATIVE_WINDOW_SET_BUFFERS_FORMAT
|
||||
* NATIVE_WINDOW_SET_SCALING_MODE
|
||||
* NATIVE_WINDOW_LOCK (private)
|
||||
* NATIVE_WINDOW_UNLOCK_AND_POST (private)
|
||||
* NATIVE_WINDOW_API_CONNECT (private)
|
||||
* NATIVE_WINDOW_API_DISCONNECT (private)
|
||||
*
|
||||
*/
|
||||
|
||||
int (*perform)(struct ANativeWindow* window,
|
||||
int operation, ... );
|
||||
|
||||
/*
|
||||
* Hook used to cancel a buffer that has been dequeued.
|
||||
* No synchronization is performed between dequeue() and cancel(), so
|
||||
* either external synchronization is needed, or these functions must be
|
||||
* called from the same thread.
|
||||
*
|
||||
* The window holds a reference to the buffer between dequeueBuffer and
|
||||
* either queueBuffer or cancelBuffer, so clients only need their own
|
||||
* reference if they might use the buffer after queueing or canceling it.
|
||||
* Holding a reference to a buffer after queueing or canceling it is only
|
||||
* allowed if a specific buffer count has been set.
|
||||
*/
|
||||
int (*cancelBuffer)(struct ANativeWindow* window,
|
||||
struct ANativeWindowBuffer* buffer);
|
||||
|
||||
|
||||
void* reserved_proc[2];
|
||||
};
|
||||
|
||||
/* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
|
||||
* android_native_window_t is deprecated.
|
||||
*/
|
||||
typedef struct ANativeWindow ANativeWindow;
|
||||
typedef struct ANativeWindow android_native_window_t;
|
||||
|
||||
/*
|
||||
* native_window_set_usage(..., usage)
|
||||
* Sets the intended usage flags for the next buffers
|
||||
* acquired with (*lockBuffer)() and on.
|
||||
* By default (if this function is never called), a usage of
|
||||
* GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
|
||||
* is assumed.
|
||||
* Calling this function will usually cause following buffers to be
|
||||
* reallocated.
|
||||
*/
|
||||
|
||||
static inline int native_window_set_usage(
|
||||
struct ANativeWindow* window, int usage)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
|
||||
}
|
||||
|
||||
/* deprecated. Always returns 0. Don't call. */
|
||||
static inline int native_window_connect(
|
||||
struct ANativeWindow* window, int api) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* deprecated. Always returns 0. Don't call. */
|
||||
static inline int native_window_disconnect(
|
||||
struct ANativeWindow* window, int api) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_crop(..., crop)
|
||||
* Sets which region of the next queued buffers needs to be considered.
|
||||
* A buffer's crop region is scaled to match the surface's size.
|
||||
*
|
||||
* The specified crop region applies to all buffers queued after it is called.
|
||||
*
|
||||
* if 'crop' is NULL, subsequently queued buffers won't be cropped.
|
||||
*
|
||||
* An error is returned if for instance the crop region is invalid,
|
||||
* out of the buffer's bound or if the window is invalid.
|
||||
*/
|
||||
static inline int native_window_set_crop(
|
||||
struct ANativeWindow* window,
|
||||
android_native_rect_t const * crop)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffer_count(..., count)
|
||||
* Sets the number of buffers associated with this native window.
|
||||
*/
|
||||
static inline int native_window_set_buffer_count(
|
||||
struct ANativeWindow* window,
|
||||
size_t bufferCount)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_geometry(..., int w, int h, int format)
|
||||
* All buffers dequeued after this call will have the dimensions and format
|
||||
* specified. A successful call to this function has the same effect as calling
|
||||
* native_window_set_buffers_size and native_window_set_buffers_format.
|
||||
*
|
||||
* XXX: This function is deprecated. The native_window_set_buffers_dimensions
|
||||
* and native_window_set_buffers_format functions should be used instead.
|
||||
*/
|
||||
static inline int native_window_set_buffers_geometry(
|
||||
struct ANativeWindow* window,
|
||||
int w, int h, int format)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
|
||||
w, h, format);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_dimensions(..., int w, int h)
|
||||
* All buffers dequeued after this call will have the dimensions specified.
|
||||
* In particular, all buffers will have a fixed-size, independent form the
|
||||
* native-window size. They will be scaled according to the scaling mode
|
||||
* (see native_window_set_scaling_mode) upon window composition.
|
||||
*
|
||||
* If w and h are 0, the normal behavior is restored. That is, dequeued buffers
|
||||
* following this call will be sized to match the window's size.
|
||||
*
|
||||
* Calling this function will reset the window crop to a NULL value, which
|
||||
* disables cropping of the buffers.
|
||||
*/
|
||||
static inline int native_window_set_buffers_dimensions(
|
||||
struct ANativeWindow* window,
|
||||
int w, int h)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
|
||||
w, h);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_format(..., int format)
|
||||
* All buffers dequeued after this call will have the format specified.
|
||||
*
|
||||
* If the specified format is 0, the default buffer format will be used.
|
||||
*/
|
||||
static inline int native_window_set_buffers_format(
|
||||
struct ANativeWindow* window,
|
||||
int format)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_transform(..., int transform)
|
||||
* All buffers queued after this call will be displayed transformed according
|
||||
* to the transform parameter specified.
|
||||
*/
|
||||
static inline int native_window_set_buffers_transform(
|
||||
struct ANativeWindow* window,
|
||||
int transform)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
|
||||
transform);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_buffers_timestamp(..., int64_t timestamp)
|
||||
* All buffers queued after this call will be associated with the timestamp
|
||||
* parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
|
||||
* (the default), timestamps will be generated automatically when queueBuffer is
|
||||
* called. The timestamp is measured in nanoseconds, and is normally monotonically
|
||||
* increasing. The timestamp should be unaffected by time-of-day adjustments,
|
||||
* and for a camera should be strictly monotonic but for a media player may be
|
||||
* reset when the position is set.
|
||||
*/
|
||||
static inline int native_window_set_buffers_timestamp(
|
||||
struct ANativeWindow* window,
|
||||
int64_t timestamp)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
|
||||
timestamp);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_set_scaling_mode(..., int mode)
|
||||
* All buffers queued after this call will be associated with the scaling mode
|
||||
* specified.
|
||||
*/
|
||||
static inline int native_window_set_scaling_mode(
|
||||
struct ANativeWindow* window,
|
||||
int mode)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
|
||||
mode);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* native_window_api_connect(..., int api)
|
||||
* connects an API to this window. only one API can be connected at a time.
|
||||
* Returns -EINVAL if for some reason the window cannot be connected, which
|
||||
* can happen if it's connected to some other API.
|
||||
*/
|
||||
static inline int native_window_api_connect(
|
||||
struct ANativeWindow* window, int api)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
|
||||
}
|
||||
|
||||
/*
|
||||
* native_window_api_disconnect(..., int api)
|
||||
* disconnect the API from this window.
|
||||
* An error is returned if for instance the window wasn't connected in the
|
||||
* first place.
|
||||
*/
|
||||
static inline int native_window_api_disconnect(
|
||||
struct ANativeWindow* window, int api)
|
||||
{
|
||||
return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
|
||||
}
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */
|
|
@ -1,159 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007 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 ANDROID_GRAPHIC_BUFFER_H
|
||||
#define ANDROID_GRAPHIC_BUFFER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <ui/android_native_buffer.h>
|
||||
#include <ui/PixelFormat.h>
|
||||
#include <ui/Rect.h>
|
||||
#include <utils/Flattenable.h>
|
||||
#include <pixelflinger/pixelflinger.h>
|
||||
|
||||
struct ANativeWindowBuffer;
|
||||
|
||||
namespace android {
|
||||
|
||||
class GraphicBufferMapper;
|
||||
|
||||
// ===========================================================================
|
||||
// GraphicBuffer
|
||||
// ===========================================================================
|
||||
|
||||
class GraphicBuffer
|
||||
: public EGLNativeBase<
|
||||
ANativeWindowBuffer,
|
||||
GraphicBuffer,
|
||||
LightRefBase<GraphicBuffer> >, public Flattenable
|
||||
{
|
||||
public:
|
||||
|
||||
enum {
|
||||
USAGE_SW_READ_NEVER = GRALLOC_USAGE_SW_READ_NEVER,
|
||||
USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY,
|
||||
USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN,
|
||||
USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK,
|
||||
|
||||
USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER,
|
||||
USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY,
|
||||
USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN,
|
||||
USAGE_SW_WRITE_MASK = GRALLOC_USAGE_SW_WRITE_MASK,
|
||||
|
||||
USAGE_SOFTWARE_MASK = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK,
|
||||
|
||||
USAGE_PROTECTED = GRALLOC_USAGE_PROTECTED,
|
||||
|
||||
USAGE_HW_TEXTURE = GRALLOC_USAGE_HW_TEXTURE,
|
||||
USAGE_HW_RENDER = GRALLOC_USAGE_HW_RENDER,
|
||||
USAGE_HW_2D = GRALLOC_USAGE_HW_2D,
|
||||
USAGE_HW_COMPOSER = GRALLOC_USAGE_HW_COMPOSER,
|
||||
USAGE_HW_VIDEO_ENCODER = GRALLOC_USAGE_HW_VIDEO_ENCODER,
|
||||
USAGE_HW_MASK = GRALLOC_USAGE_HW_MASK
|
||||
};
|
||||
|
||||
GraphicBuffer();
|
||||
|
||||
// creates w * h buffer
|
||||
GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
|
||||
|
||||
// create a buffer from an existing handle
|
||||
GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage,
|
||||
uint32_t stride, native_handle_t* handle, bool keepOwnership);
|
||||
|
||||
// create a buffer from an existing ANativeWindowBuffer
|
||||
GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership);
|
||||
|
||||
// return status
|
||||
status_t initCheck() const;
|
||||
|
||||
uint32_t getWidth() const { return width; }
|
||||
uint32_t getHeight() const { return height; }
|
||||
uint32_t getStride() const { return stride; }
|
||||
uint32_t getUsage() const { return usage; }
|
||||
PixelFormat getPixelFormat() const { return format; }
|
||||
Rect getBounds() const { return Rect(width, height); }
|
||||
|
||||
status_t reallocate(uint32_t w, uint32_t h, PixelFormat f, uint32_t usage);
|
||||
|
||||
status_t lock(uint32_t usage, void** vaddr);
|
||||
status_t lock(uint32_t usage, const Rect& rect, void** vaddr);
|
||||
status_t lock(GGLSurface* surface, uint32_t usage);
|
||||
status_t unlock();
|
||||
|
||||
ANativeWindowBuffer* getNativeBuffer() const;
|
||||
|
||||
void setIndex(int index);
|
||||
int getIndex() const;
|
||||
|
||||
// for debugging
|
||||
static void dumpAllocationsToSystemLog();
|
||||
|
||||
private:
|
||||
virtual ~GraphicBuffer();
|
||||
|
||||
enum {
|
||||
ownNone = 0,
|
||||
ownHandle = 1,
|
||||
ownData = 2,
|
||||
};
|
||||
|
||||
inline const GraphicBufferMapper& getBufferMapper() const {
|
||||
return mBufferMapper;
|
||||
}
|
||||
inline GraphicBufferMapper& getBufferMapper() {
|
||||
return mBufferMapper;
|
||||
}
|
||||
uint8_t mOwner;
|
||||
|
||||
private:
|
||||
friend class Surface;
|
||||
friend class BpSurface;
|
||||
friend class BnSurface;
|
||||
friend class SurfaceTextureClient;
|
||||
friend class LightRefBase<GraphicBuffer>;
|
||||
GraphicBuffer(const GraphicBuffer& rhs);
|
||||
GraphicBuffer& operator = (const GraphicBuffer& rhs);
|
||||
const GraphicBuffer& operator = (const GraphicBuffer& rhs) const;
|
||||
|
||||
status_t initSize(uint32_t w, uint32_t h, PixelFormat format,
|
||||
uint32_t usage);
|
||||
|
||||
void free_handle();
|
||||
|
||||
// Flattenable interface
|
||||
size_t getFlattenedSize() const;
|
||||
size_t getFdCount() const;
|
||||
status_t flatten(void* buffer, size_t size,
|
||||
int fds[], size_t count) const;
|
||||
status_t unflatten(void const* buffer, size_t size,
|
||||
int fds[], size_t count);
|
||||
|
||||
|
||||
GraphicBufferMapper& mBufferMapper;
|
||||
ssize_t mInitCheck;
|
||||
int mIndex;
|
||||
|
||||
// If we're wrapping another buffer then this reference will make sure it
|
||||
// doesn't get freed.
|
||||
sp<ANativeWindowBuffer> mWrappedBuffer;
|
||||
};
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_GRAPHIC_BUFFER_H
|
|
@ -1,137 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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.
|
||||
*/
|
||||
|
||||
//
|
||||
|
||||
// Pixel formats used across the system.
|
||||
// These formats might not all be supported by all renderers, for instance
|
||||
// skia or SurfaceFlinger are not required to support all of these formats
|
||||
// (either as source or destination)
|
||||
|
||||
// XXX: we should consolidate these formats and skia's
|
||||
|
||||
#ifndef UI_PIXELFORMAT_H
|
||||
#define UI_PIXELFORMAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <utils/Errors.h>
|
||||
#include <pixelflinger/format.h>
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
enum {
|
||||
//
|
||||
// these constants need to match those
|
||||
// in graphics/PixelFormat.java & pixelflinger/format.h
|
||||
//
|
||||
PIXEL_FORMAT_UNKNOWN = 0,
|
||||
PIXEL_FORMAT_NONE = 0,
|
||||
|
||||
// logical pixel formats used by the SurfaceFlinger -----------------------
|
||||
PIXEL_FORMAT_CUSTOM = -4,
|
||||
// Custom pixel-format described by a PixelFormatInfo structure
|
||||
|
||||
PIXEL_FORMAT_TRANSLUCENT = -3,
|
||||
// System chooses a format that supports translucency (many alpha bits)
|
||||
|
||||
PIXEL_FORMAT_TRANSPARENT = -2,
|
||||
// System chooses a format that supports transparency
|
||||
// (at least 1 alpha bit)
|
||||
|
||||
PIXEL_FORMAT_OPAQUE = -1,
|
||||
// System chooses an opaque format (no alpha bits required)
|
||||
|
||||
// real pixel formats supported for rendering -----------------------------
|
||||
|
||||
PIXEL_FORMAT_RGBA_8888 = HAL_PIXEL_FORMAT_RGBA_8888, // 4x8-bit RGBA
|
||||
PIXEL_FORMAT_RGBX_8888 = HAL_PIXEL_FORMAT_RGBX_8888, // 4x8-bit RGB0
|
||||
PIXEL_FORMAT_RGB_888 = HAL_PIXEL_FORMAT_RGB_888, // 3x8-bit RGB
|
||||
PIXEL_FORMAT_RGB_565 = HAL_PIXEL_FORMAT_RGB_565, // 16-bit RGB
|
||||
PIXEL_FORMAT_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888, // 4x8-bit BGRA
|
||||
PIXEL_FORMAT_RGBA_5551 = HAL_PIXEL_FORMAT_RGBA_5551, // 16-bit ARGB
|
||||
PIXEL_FORMAT_RGBA_4444 = HAL_PIXEL_FORMAT_RGBA_4444, // 16-bit ARGB
|
||||
PIXEL_FORMAT_A_8 = GGL_PIXEL_FORMAT_A_8, // 8-bit A
|
||||
PIXEL_FORMAT_L_8 = GGL_PIXEL_FORMAT_L_8, // 8-bit L (R=G=B=L)
|
||||
PIXEL_FORMAT_LA_88 = GGL_PIXEL_FORMAT_LA_88, // 16-bit LA
|
||||
PIXEL_FORMAT_RGB_332 = GGL_PIXEL_FORMAT_RGB_332, // 8-bit RGB
|
||||
|
||||
// New formats can be added if they're also defined in
|
||||
// pixelflinger/format.h
|
||||
};
|
||||
|
||||
typedef int32_t PixelFormat;
|
||||
|
||||
struct PixelFormatInfo
|
||||
{
|
||||
enum {
|
||||
INDEX_ALPHA = 0,
|
||||
INDEX_RED = 1,
|
||||
INDEX_GREEN = 2,
|
||||
INDEX_BLUE = 3
|
||||
};
|
||||
|
||||
enum { // components
|
||||
ALPHA = 1,
|
||||
RGB = 2,
|
||||
RGBA = 3,
|
||||
LUMINANCE = 4,
|
||||
LUMINANCE_ALPHA = 5,
|
||||
OTHER = 0xFF
|
||||
};
|
||||
|
||||
struct szinfo {
|
||||
uint8_t h;
|
||||
uint8_t l;
|
||||
};
|
||||
|
||||
inline PixelFormatInfo() : version(sizeof(PixelFormatInfo)) { }
|
||||
size_t getScanlineSize(unsigned int width) const;
|
||||
size_t getSize(size_t ci) const {
|
||||
return (ci <= 3) ? (cinfo[ci].h - cinfo[ci].l) : 0;
|
||||
}
|
||||
size_t version;
|
||||
PixelFormat format;
|
||||
size_t bytesPerPixel;
|
||||
size_t bitsPerPixel;
|
||||
union {
|
||||
szinfo cinfo[4];
|
||||
struct {
|
||||
uint8_t h_alpha;
|
||||
uint8_t l_alpha;
|
||||
uint8_t h_red;
|
||||
uint8_t l_red;
|
||||
uint8_t h_green;
|
||||
uint8_t l_green;
|
||||
uint8_t h_blue;
|
||||
uint8_t l_blue;
|
||||
};
|
||||
};
|
||||
uint8_t components;
|
||||
uint8_t reserved0[3];
|
||||
uint32_t reserved1;
|
||||
};
|
||||
|
||||
// Consider caching the results of these functions are they're not
|
||||
// guaranteed to be fast.
|
||||
ssize_t bytesPerPixel(PixelFormat format);
|
||||
ssize_t bitsPerPixel(PixelFormat format);
|
||||
status_t getPixelFormatInfo(PixelFormat format, PixelFormatInfo* info);
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // UI_PIXELFORMAT_H
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2006 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 ANDROID_UI_POINT
|
||||
#define ANDROID_UI_POINT
|
||||
|
||||
#include <utils/TypeHelpers.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class Point
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
|
||||
// we don't provide copy-ctor and operator= on purpose
|
||||
// because we want the compiler generated versions
|
||||
|
||||
// Default constructor doesn't initialize the Point
|
||||
inline Point() {
|
||||
}
|
||||
inline Point(int x, int y) : x(x), y(y) {
|
||||
}
|
||||
|
||||
inline bool operator == (const Point& rhs) const {
|
||||
return (x == rhs.x) && (y == rhs.y);
|
||||
}
|
||||
inline bool operator != (const Point& rhs) const {
|
||||
return !operator == (rhs);
|
||||
}
|
||||
|
||||
inline bool isOrigin() const {
|
||||
return !(x|y);
|
||||
}
|
||||
|
||||
// operator < defines an order which allows to use points in sorted
|
||||
// vectors.
|
||||
bool operator < (const Point& rhs) const {
|
||||
return y<rhs.y || (y==rhs.y && x<rhs.x);
|
||||
}
|
||||
|
||||
inline Point& operator - () {
|
||||
x = -x;
|
||||
y = -y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Point& operator += (const Point& rhs) {
|
||||
x += rhs.x;
|
||||
y += rhs.y;
|
||||
return *this;
|
||||
}
|
||||
inline Point& operator -= (const Point& rhs) {
|
||||
x -= rhs.x;
|
||||
y -= rhs.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const Point operator + (const Point& rhs) const {
|
||||
const Point result(x+rhs.x, y+rhs.y);
|
||||
return result;
|
||||
}
|
||||
const Point operator - (const Point& rhs) const {
|
||||
const Point result(x-rhs.x, y-rhs.y);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
ANDROID_BASIC_TYPES_TRAITS(Point)
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_UI_POINT
|
|
@ -1,149 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2006 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 ANDROID_UI_RECT
|
||||
#define ANDROID_UI_RECT
|
||||
|
||||
#include <utils/TypeHelpers.h>
|
||||
#include <ui/Point.h>
|
||||
|
||||
#include <android/rect.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class Rect : public ARect
|
||||
{
|
||||
public:
|
||||
typedef ARect::value_type value_type;
|
||||
|
||||
// we don't provide copy-ctor and operator= on purpose
|
||||
// because we want the compiler generated versions
|
||||
|
||||
inline Rect() {
|
||||
}
|
||||
inline Rect(int32_t w, int32_t h) {
|
||||
left = top = 0; right = w; bottom = h;
|
||||
}
|
||||
inline Rect(int32_t l, int32_t t, int32_t r, int32_t b) {
|
||||
left = l; top = t; right = r; bottom = b;
|
||||
}
|
||||
inline Rect(const Point& lt, const Point& rb) {
|
||||
left = lt.x; top = lt.y; right = rb.x; bottom = rb.y;
|
||||
}
|
||||
|
||||
void makeInvalid();
|
||||
|
||||
inline void clear() {
|
||||
left = top = right = bottom = 0;
|
||||
}
|
||||
|
||||
// a valid rectangle has a non negative width and height
|
||||
inline bool isValid() const {
|
||||
return (width()>=0) && (height()>=0);
|
||||
}
|
||||
|
||||
// an empty rect has a zero width or height, or is invalid
|
||||
inline bool isEmpty() const {
|
||||
return (width()<=0) || (height()<=0);
|
||||
}
|
||||
|
||||
inline void set(const Rect& rhs) {
|
||||
operator = (rhs);
|
||||
}
|
||||
|
||||
// rectangle's width
|
||||
inline int32_t width() const {
|
||||
return right-left;
|
||||
}
|
||||
|
||||
// rectangle's height
|
||||
inline int32_t height() const {
|
||||
return bottom-top;
|
||||
}
|
||||
|
||||
void setLeftTop(const Point& lt) {
|
||||
left = lt.x;
|
||||
top = lt.y;
|
||||
}
|
||||
|
||||
void setRightBottom(const Point& rb) {
|
||||
right = rb.x;
|
||||
bottom = rb.y;
|
||||
}
|
||||
|
||||
// the following 4 functions return the 4 corners of the rect as Point
|
||||
Point leftTop() const {
|
||||
return Point(left, top);
|
||||
}
|
||||
Point rightBottom() const {
|
||||
return Point(right, bottom);
|
||||
}
|
||||
Point rightTop() const {
|
||||
return Point(right, top);
|
||||
}
|
||||
Point leftBottom() const {
|
||||
return Point(left, bottom);
|
||||
}
|
||||
|
||||
// comparisons
|
||||
inline bool operator == (const Rect& rhs) const {
|
||||
return (left == rhs.left) && (top == rhs.top) &&
|
||||
(right == rhs.right) && (bottom == rhs.bottom);
|
||||
}
|
||||
|
||||
inline bool operator != (const Rect& rhs) const {
|
||||
return !operator == (rhs);
|
||||
}
|
||||
|
||||
// operator < defines an order which allows to use rectangles in sorted
|
||||
// vectors.
|
||||
bool operator < (const Rect& rhs) const;
|
||||
|
||||
Rect& offsetToOrigin() {
|
||||
right -= left;
|
||||
bottom -= top;
|
||||
left = top = 0;
|
||||
return *this;
|
||||
}
|
||||
Rect& offsetTo(const Point& p) {
|
||||
return offsetTo(p.x, p.y);
|
||||
}
|
||||
Rect& offsetBy(const Point& dp) {
|
||||
return offsetBy(dp.x, dp.y);
|
||||
}
|
||||
Rect& operator += (const Point& rhs) {
|
||||
return offsetBy(rhs.x, rhs.y);
|
||||
}
|
||||
Rect& operator -= (const Point& rhs) {
|
||||
return offsetBy(-rhs.x, -rhs.y);
|
||||
}
|
||||
const Rect operator + (const Point& rhs) const;
|
||||
const Rect operator - (const Point& rhs) const;
|
||||
|
||||
void translate(int32_t dx, int32_t dy) { // legacy, don't use.
|
||||
offsetBy(dx, dy);
|
||||
}
|
||||
|
||||
Rect& offsetTo(int32_t x, int32_t y);
|
||||
Rect& offsetBy(int32_t x, int32_t y);
|
||||
bool intersect(const Rect& with, Rect* result) const;
|
||||
};
|
||||
|
||||
ANDROID_BASIC_TYPES_TRAITS(Rect)
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_UI_RECT
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* 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 ANDROID_ANDROID_NATIVES_PRIV_H
|
||||
#define ANDROID_ANDROID_NATIVES_PRIV_H
|
||||
|
||||
#include <ui/egl/android_natives.h>
|
||||
|
||||
#endif /* ANDROID_ANDROID_NATIVES_PRIV_H */
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* 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 ANDROID_ANDROID_NATIVES_H
|
||||
#define ANDROID_ANDROID_NATIVES_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <hardware/gralloc.h>
|
||||
#include <system/window.h>
|
||||
// FIXME: remove this header, it's for legacy use. native_window is pulled from frameworks/base/native/include/android/
|
||||
#include <android/native_window.h>
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/* FIXME: this is legacy for pixmaps */
|
||||
typedef struct egl_native_pixmap_t
|
||||
{
|
||||
int32_t version; /* must be 32 */
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
int32_t stride;
|
||||
uint8_t* data;
|
||||
uint8_t format;
|
||||
uint8_t rfu[3];
|
||||
union {
|
||||
uint32_t compressedFormat;
|
||||
int32_t vstride;
|
||||
};
|
||||
int32_t reserved;
|
||||
} egl_native_pixmap_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <utils/RefBase.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
/*
|
||||
* This helper class turns an EGL android_native_xxx type into a C++
|
||||
* reference-counted object; with proper type conversions.
|
||||
*/
|
||||
template <typename NATIVE_TYPE, typename TYPE, typename REF>
|
||||
class EGLNativeBase : public NATIVE_TYPE, public REF
|
||||
{
|
||||
public:
|
||||
// Disambiguate between the incStrong in REF and NATIVE_TYPE
|
||||
void incStrong(const void* id) const {
|
||||
REF::incStrong(id);
|
||||
}
|
||||
void decStrong(const void* id) const {
|
||||
REF::decStrong(id);
|
||||
}
|
||||
|
||||
protected:
|
||||
typedef EGLNativeBase<NATIVE_TYPE, TYPE, REF> BASE;
|
||||
EGLNativeBase() : NATIVE_TYPE(), REF() {
|
||||
NATIVE_TYPE::common.incRef = incRef;
|
||||
NATIVE_TYPE::common.decRef = decRef;
|
||||
}
|
||||
static inline TYPE* getSelf(NATIVE_TYPE* self) {
|
||||
return static_cast<TYPE*>(self);
|
||||
}
|
||||
static inline TYPE const* getSelf(NATIVE_TYPE const* self) {
|
||||
return static_cast<TYPE const *>(self);
|
||||
}
|
||||
static inline TYPE* getSelf(android_native_base_t* base) {
|
||||
return getSelf(reinterpret_cast<NATIVE_TYPE*>(base));
|
||||
}
|
||||
static inline TYPE const * getSelf(android_native_base_t const* base) {
|
||||
return getSelf(reinterpret_cast<NATIVE_TYPE const*>(base));
|
||||
}
|
||||
static void incRef(android_native_base_t* base) {
|
||||
EGLNativeBase* self = getSelf(base);
|
||||
self->incStrong(self);
|
||||
}
|
||||
static void decRef(android_native_base_t* base) {
|
||||
EGLNativeBase* self = getSelf(base);
|
||||
self->decStrong(self);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
#endif // __cplusplus
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif /* ANDROID_ANDROID_NATIVES_H */
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007 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 ANDROID_ERRORS_H
|
||||
#define ANDROID_ERRORS_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
// use this type to return error codes
|
||||
#ifdef HAVE_MS_C_RUNTIME
|
||||
typedef int status_t;
|
||||
#else
|
||||
typedef int32_t status_t;
|
||||
#endif
|
||||
|
||||
/* the MS C runtime lacks a few error codes */
|
||||
|
||||
/*
|
||||
* Error codes.
|
||||
* All error codes are negative values.
|
||||
*/
|
||||
|
||||
// Win32 #defines NO_ERROR as well. It has the same value, so there's no
|
||||
// real conflict, though it's a bit awkward.
|
||||
#ifdef _WIN32
|
||||
# undef NO_ERROR
|
||||
#endif
|
||||
|
||||
enum {
|
||||
OK = 0, // Everything's swell.
|
||||
NO_ERROR = 0, // No errors.
|
||||
|
||||
UNKNOWN_ERROR = 0x80000000,
|
||||
|
||||
NO_MEMORY = -ENOMEM,
|
||||
INVALID_OPERATION = -ENOSYS,
|
||||
BAD_VALUE = -EINVAL,
|
||||
BAD_TYPE = 0x80000001,
|
||||
NAME_NOT_FOUND = -ENOENT,
|
||||
PERMISSION_DENIED = -EPERM,
|
||||
NO_INIT = -ENODEV,
|
||||
ALREADY_EXISTS = -EEXIST,
|
||||
DEAD_OBJECT = -EPIPE,
|
||||
FAILED_TRANSACTION = 0x80000002,
|
||||
JPARKS_BROKE_IT = -EPIPE,
|
||||
#if !defined(HAVE_MS_C_RUNTIME)
|
||||
BAD_INDEX = -EOVERFLOW,
|
||||
NOT_ENOUGH_DATA = -ENODATA,
|
||||
WOULD_BLOCK = -EWOULDBLOCK,
|
||||
TIMED_OUT = -ETIMEDOUT,
|
||||
UNKNOWN_TRANSACTION = -EBADMSG,
|
||||
#else
|
||||
BAD_INDEX = -E2BIG,
|
||||
NOT_ENOUGH_DATA = 0x80000003,
|
||||
WOULD_BLOCK = 0x80000004,
|
||||
TIMED_OUT = 0x80000005,
|
||||
UNKNOWN_TRANSACTION = 0x80000006,
|
||||
#endif
|
||||
FDS_NOT_ALLOWED = 0x80000007,
|
||||
};
|
||||
|
||||
// Restore define; enumeration is in "android" namespace, so the value defined
|
||||
// there won't work for Win32 code in a different namespace.
|
||||
#ifdef _WIN32
|
||||
# define NO_ERROR 0L
|
||||
#endif
|
||||
|
||||
}; // namespace android
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_ERRORS_H
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 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 ANDROID_UTILS_FLATTENABLE_H
|
||||
#define ANDROID_UTILS_FLATTENABLE_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <utils/Errors.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class Flattenable
|
||||
{
|
||||
public:
|
||||
// size in bytes of the flattened object
|
||||
virtual size_t getFlattenedSize() const = 0;
|
||||
|
||||
// number of file descriptors to flatten
|
||||
virtual size_t getFdCount() const = 0;
|
||||
|
||||
// flattens the object into buffer.
|
||||
// size should be at least of getFlattenedSize()
|
||||
// file descriptors are written in the fds[] array but ownership is
|
||||
// not transfered (ie: they must be dupped by the caller of
|
||||
// flatten() if needed).
|
||||
virtual status_t flatten(void* buffer, size_t size,
|
||||
int fds[], size_t count) const = 0;
|
||||
|
||||
// unflattens the object from buffer.
|
||||
// size should be equal to the value of getFlattenedSize() when the
|
||||
// object was flattened.
|
||||
// unflattened file descriptors are found in the fds[] array and
|
||||
// don't need to be dupped(). ie: the caller of unflatten doesn't
|
||||
// keep ownership. If a fd is not retained by unflatten() it must be
|
||||
// explicitly closed.
|
||||
virtual status_t unflatten(void const* buffer, size_t size,
|
||||
int fds[], size_t count) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~Flattenable() = 0;
|
||||
|
||||
};
|
||||
|
||||
}; // namespace android
|
||||
|
||||
|
||||
#endif /* ANDROID_UTILS_FLATTENABLE_H */
|
|
@ -1,201 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_KEYED_VECTOR_H
|
||||
#define ANDROID_KEYED_VECTOR_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <utils/SortedVector.h>
|
||||
#include <utils/TypeHelpers.h>
|
||||
#include <utils/Errors.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace android {
|
||||
|
||||
template <typename KEY, typename VALUE>
|
||||
class KeyedVector
|
||||
{
|
||||
public:
|
||||
typedef KEY key_type;
|
||||
typedef VALUE value_type;
|
||||
|
||||
inline KeyedVector();
|
||||
|
||||
/*
|
||||
* empty the vector
|
||||
*/
|
||||
|
||||
inline void clear() { mVector.clear(); }
|
||||
|
||||
/*!
|
||||
* vector stats
|
||||
*/
|
||||
|
||||
//! returns number of items in the vector
|
||||
inline size_t size() const { return mVector.size(); }
|
||||
//! returns wether or not the vector is empty
|
||||
inline bool isEmpty() const { return mVector.isEmpty(); }
|
||||
//! returns how many items can be stored without reallocating the backing store
|
||||
inline size_t capacity() const { return mVector.capacity(); }
|
||||
//! setst the capacity. capacity can never be reduced less than size()
|
||||
inline ssize_t setCapacity(size_t size) { return mVector.setCapacity(size); }
|
||||
|
||||
/*!
|
||||
* accessors
|
||||
*/
|
||||
const VALUE& valueFor(const KEY& key) const;
|
||||
const VALUE& valueAt(size_t index) const;
|
||||
const KEY& keyAt(size_t index) const;
|
||||
ssize_t indexOfKey(const KEY& key) const;
|
||||
|
||||
/*!
|
||||
* modifing the array
|
||||
*/
|
||||
|
||||
VALUE& editValueFor(const KEY& key);
|
||||
VALUE& editValueAt(size_t index);
|
||||
|
||||
/*!
|
||||
* add/insert/replace items
|
||||
*/
|
||||
|
||||
ssize_t add(const KEY& key, const VALUE& item);
|
||||
ssize_t replaceValueFor(const KEY& key, const VALUE& item);
|
||||
ssize_t replaceValueAt(size_t index, const VALUE& item);
|
||||
|
||||
/*!
|
||||
* remove items
|
||||
*/
|
||||
|
||||
ssize_t removeItem(const KEY& key);
|
||||
ssize_t removeItemsAt(size_t index, size_t count = 1);
|
||||
|
||||
private:
|
||||
SortedVector< key_value_pair_t<KEY, VALUE> > mVector;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Variation of KeyedVector that holds a default value to return when
|
||||
* valueFor() is called with a key that doesn't exist.
|
||||
*/
|
||||
template <typename KEY, typename VALUE>
|
||||
class DefaultKeyedVector : public KeyedVector<KEY, VALUE>
|
||||
{
|
||||
public:
|
||||
inline DefaultKeyedVector(const VALUE& defValue = VALUE());
|
||||
const VALUE& valueFor(const KEY& key) const;
|
||||
|
||||
private:
|
||||
VALUE mDefault;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
KeyedVector<KEY,VALUE>::KeyedVector()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
ssize_t KeyedVector<KEY,VALUE>::indexOfKey(const KEY& key) const {
|
||||
return mVector.indexOf( key_value_pair_t<KEY,VALUE>(key) );
|
||||
}
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
const VALUE& KeyedVector<KEY,VALUE>::valueFor(const KEY& key) const {
|
||||
ssize_t i = indexOfKey(key);
|
||||
assert(i>=0);
|
||||
return mVector.itemAt(i).value;
|
||||
}
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
const VALUE& KeyedVector<KEY,VALUE>::valueAt(size_t index) const {
|
||||
return mVector.itemAt(index).value;
|
||||
}
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
const KEY& KeyedVector<KEY,VALUE>::keyAt(size_t index) const {
|
||||
return mVector.itemAt(index).key;
|
||||
}
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
VALUE& KeyedVector<KEY,VALUE>::editValueFor(const KEY& key) {
|
||||
ssize_t i = indexOfKey(key);
|
||||
assert(i>=0);
|
||||
return mVector.editItemAt(i).value;
|
||||
}
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
VALUE& KeyedVector<KEY,VALUE>::editValueAt(size_t index) {
|
||||
return mVector.editItemAt(index).value;
|
||||
}
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
ssize_t KeyedVector<KEY,VALUE>::add(const KEY& key, const VALUE& value) {
|
||||
return mVector.add( key_value_pair_t<KEY,VALUE>(key, value) );
|
||||
}
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
ssize_t KeyedVector<KEY,VALUE>::replaceValueFor(const KEY& key, const VALUE& value) {
|
||||
key_value_pair_t<KEY,VALUE> pair(key, value);
|
||||
mVector.remove(pair);
|
||||
return mVector.add(pair);
|
||||
}
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
ssize_t KeyedVector<KEY,VALUE>::replaceValueAt(size_t index, const VALUE& item) {
|
||||
if (index<size()) {
|
||||
mVector.editItemAt(index).value = item;
|
||||
return index;
|
||||
}
|
||||
return BAD_INDEX;
|
||||
}
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
ssize_t KeyedVector<KEY,VALUE>::removeItem(const KEY& key) {
|
||||
return mVector.remove(key_value_pair_t<KEY,VALUE>(key));
|
||||
}
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
ssize_t KeyedVector<KEY, VALUE>::removeItemsAt(size_t index, size_t count) {
|
||||
return mVector.removeItemsAt(index, count);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
DefaultKeyedVector<KEY,VALUE>::DefaultKeyedVector(const VALUE& defValue)
|
||||
: mDefault(defValue)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename KEY, typename VALUE> inline
|
||||
const VALUE& DefaultKeyedVector<KEY,VALUE>::valueFor(const KEY& key) const {
|
||||
ssize_t i = indexOfKey(key);
|
||||
return i >= 0 ? KeyedVector<KEY,VALUE>::valueAt(i) : mDefault;
|
||||
}
|
||||
|
||||
}; // namespace android
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_KEYED_VECTOR_H
|
|
@ -1,332 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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.
|
||||
*/
|
||||
|
||||
//
|
||||
// Templated list class. Normally we'd use STL, but we don't have that.
|
||||
// This class mimics STL's interfaces.
|
||||
//
|
||||
// Objects are copied into the list with the '=' operator or with copy-
|
||||
// construction, so if the compiler's auto-generated versions won't work for
|
||||
// you, define your own.
|
||||
//
|
||||
// The only class you want to use from here is "List".
|
||||
//
|
||||
#ifndef _LIBS_UTILS_LIST_H
|
||||
#define _LIBS_UTILS_LIST_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
/*
|
||||
* Doubly-linked list. Instantiate with "List<MyClass> myList".
|
||||
*
|
||||
* Objects added to the list are copied using the assignment operator,
|
||||
* so this must be defined.
|
||||
*/
|
||||
template<typename T>
|
||||
class List
|
||||
{
|
||||
protected:
|
||||
/*
|
||||
* One element in the list.
|
||||
*/
|
||||
class _Node {
|
||||
public:
|
||||
explicit _Node(const T& val) : mVal(val) {}
|
||||
~_Node() {}
|
||||
inline T& getRef() { return mVal; }
|
||||
inline const T& getRef() const { return mVal; }
|
||||
inline _Node* getPrev() const { return mpPrev; }
|
||||
inline _Node* getNext() const { return mpNext; }
|
||||
inline void setVal(const T& val) { mVal = val; }
|
||||
inline void setPrev(_Node* ptr) { mpPrev = ptr; }
|
||||
inline void setNext(_Node* ptr) { mpNext = ptr; }
|
||||
private:
|
||||
friend class List;
|
||||
friend class _ListIterator;
|
||||
T mVal;
|
||||
_Node* mpPrev;
|
||||
_Node* mpNext;
|
||||
};
|
||||
|
||||
/*
|
||||
* Iterator for walking through the list.
|
||||
*/
|
||||
|
||||
template <typename TYPE>
|
||||
struct CONST_ITERATOR {
|
||||
typedef _Node const * NodePtr;
|
||||
typedef const TYPE Type;
|
||||
};
|
||||
|
||||
template <typename TYPE>
|
||||
struct NON_CONST_ITERATOR {
|
||||
typedef _Node* NodePtr;
|
||||
typedef TYPE Type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename U,
|
||||
template <class> class Constness
|
||||
>
|
||||
class _ListIterator {
|
||||
typedef _ListIterator<U, Constness> _Iter;
|
||||
typedef typename Constness<U>::NodePtr _NodePtr;
|
||||
typedef typename Constness<U>::Type _Type;
|
||||
|
||||
explicit _ListIterator(_NodePtr ptr) : mpNode(ptr) {}
|
||||
|
||||
public:
|
||||
_ListIterator() {}
|
||||
_ListIterator(const _Iter& rhs) : mpNode(rhs.mpNode) {}
|
||||
~_ListIterator() {}
|
||||
|
||||
// this will handle conversions from iterator to const_iterator
|
||||
// (and also all convertible iterators)
|
||||
// Here, in this implementation, the iterators can be converted
|
||||
// if the nodes can be converted
|
||||
template<typename V> explicit
|
||||
_ListIterator(const V& rhs) : mpNode(rhs.mpNode) {}
|
||||
|
||||
|
||||
/*
|
||||
* Dereference operator. Used to get at the juicy insides.
|
||||
*/
|
||||
_Type& operator*() const { return mpNode->getRef(); }
|
||||
_Type* operator->() const { return &(mpNode->getRef()); }
|
||||
|
||||
/*
|
||||
* Iterator comparison.
|
||||
*/
|
||||
inline bool operator==(const _Iter& right) const {
|
||||
return mpNode == right.mpNode; }
|
||||
|
||||
inline bool operator!=(const _Iter& right) const {
|
||||
return mpNode != right.mpNode; }
|
||||
|
||||
/*
|
||||
* handle comparisons between iterator and const_iterator
|
||||
*/
|
||||
template<typename OTHER>
|
||||
inline bool operator==(const OTHER& right) const {
|
||||
return mpNode == right.mpNode; }
|
||||
|
||||
template<typename OTHER>
|
||||
inline bool operator!=(const OTHER& right) const {
|
||||
return mpNode != right.mpNode; }
|
||||
|
||||
/*
|
||||
* Incr/decr, used to move through the list.
|
||||
*/
|
||||
inline _Iter& operator++() { // pre-increment
|
||||
mpNode = mpNode->getNext();
|
||||
return *this;
|
||||
}
|
||||
const _Iter operator++(int) { // post-increment
|
||||
_Iter tmp(*this);
|
||||
mpNode = mpNode->getNext();
|
||||
return tmp;
|
||||
}
|
||||
inline _Iter& operator--() { // pre-increment
|
||||
mpNode = mpNode->getPrev();
|
||||
return *this;
|
||||
}
|
||||
const _Iter operator--(int) { // post-increment
|
||||
_Iter tmp(*this);
|
||||
mpNode = mpNode->getPrev();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline _NodePtr getNode() const { return mpNode; }
|
||||
|
||||
_NodePtr mpNode; /* should be private, but older gcc fails */
|
||||
private:
|
||||
friend class List;
|
||||
};
|
||||
|
||||
public:
|
||||
List() {
|
||||
prep();
|
||||
}
|
||||
List(const List<T>& src) { // copy-constructor
|
||||
prep();
|
||||
insert(begin(), src.begin(), src.end());
|
||||
}
|
||||
virtual ~List() {
|
||||
clear();
|
||||
delete[] (unsigned char*) mpMiddle;
|
||||
}
|
||||
|
||||
typedef _ListIterator<T, NON_CONST_ITERATOR> iterator;
|
||||
typedef _ListIterator<T, CONST_ITERATOR> const_iterator;
|
||||
|
||||
List<T>& operator=(const List<T>& right);
|
||||
|
||||
/* returns true if the list is empty */
|
||||
inline bool empty() const { return mpMiddle->getNext() == mpMiddle; }
|
||||
|
||||
/* return #of elements in list */
|
||||
size_t size() const {
|
||||
return size_t(distance(begin(), end()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the first element or one past the last element. The
|
||||
* _Node* we're returning is converted to an "iterator" by a
|
||||
* constructor in _ListIterator.
|
||||
*/
|
||||
inline iterator begin() {
|
||||
return iterator(mpMiddle->getNext());
|
||||
}
|
||||
inline const_iterator begin() const {
|
||||
return const_iterator(const_cast<_Node const*>(mpMiddle->getNext()));
|
||||
}
|
||||
inline iterator end() {
|
||||
return iterator(mpMiddle);
|
||||
}
|
||||
inline const_iterator end() const {
|
||||
return const_iterator(const_cast<_Node const*>(mpMiddle));
|
||||
}
|
||||
|
||||
/* add the object to the head or tail of the list */
|
||||
void push_front(const T& val) { insert(begin(), val); }
|
||||
void push_back(const T& val) { insert(end(), val); }
|
||||
|
||||
/* insert before the current node; returns iterator at new node */
|
||||
iterator insert(iterator posn, const T& val)
|
||||
{
|
||||
_Node* newNode = new _Node(val); // alloc & copy-construct
|
||||
newNode->setNext(posn.getNode());
|
||||
newNode->setPrev(posn.getNode()->getPrev());
|
||||
posn.getNode()->getPrev()->setNext(newNode);
|
||||
posn.getNode()->setPrev(newNode);
|
||||
return iterator(newNode);
|
||||
}
|
||||
|
||||
/* insert a range of elements before the current node */
|
||||
void insert(iterator posn, const_iterator first, const_iterator last) {
|
||||
for ( ; first != last; ++first)
|
||||
insert(posn, *first);
|
||||
}
|
||||
|
||||
/* remove one entry; returns iterator at next node */
|
||||
iterator erase(iterator posn) {
|
||||
_Node* pNext = posn.getNode()->getNext();
|
||||
_Node* pPrev = posn.getNode()->getPrev();
|
||||
pPrev->setNext(pNext);
|
||||
pNext->setPrev(pPrev);
|
||||
delete posn.getNode();
|
||||
return iterator(pNext);
|
||||
}
|
||||
|
||||
/* remove a range of elements */
|
||||
iterator erase(iterator first, iterator last) {
|
||||
while (first != last)
|
||||
erase(first++); // don't erase than incr later!
|
||||
return iterator(last);
|
||||
}
|
||||
|
||||
/* remove all contents of the list */
|
||||
void clear() {
|
||||
_Node* pCurrent = mpMiddle->getNext();
|
||||
_Node* pNext;
|
||||
|
||||
while (pCurrent != mpMiddle) {
|
||||
pNext = pCurrent->getNext();
|
||||
delete pCurrent;
|
||||
pCurrent = pNext;
|
||||
}
|
||||
mpMiddle->setPrev(mpMiddle);
|
||||
mpMiddle->setNext(mpMiddle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Measure the distance between two iterators. On exist, "first"
|
||||
* will be equal to "last". The iterators must refer to the same
|
||||
* list.
|
||||
*
|
||||
* FIXME: This is actually a generic iterator function. It should be a
|
||||
* template function at the top-level with specializations for things like
|
||||
* vector<>, which can just do pointer math). Here we limit it to
|
||||
* _ListIterator of the same type but different constness.
|
||||
*/
|
||||
template<
|
||||
typename U,
|
||||
template <class> class CL,
|
||||
template <class> class CR
|
||||
>
|
||||
ptrdiff_t distance(
|
||||
_ListIterator<U, CL> first, _ListIterator<U, CR> last) const
|
||||
{
|
||||
ptrdiff_t count = 0;
|
||||
while (first != last) {
|
||||
++first;
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private:
|
||||
/*
|
||||
* I want a _Node but don't need it to hold valid data. More
|
||||
* to the point, I don't want T's constructor to fire, since it
|
||||
* might have side-effects or require arguments. So, we do this
|
||||
* slightly uncouth storage alloc.
|
||||
*/
|
||||
void prep() {
|
||||
mpMiddle = (_Node*) new unsigned char[sizeof(_Node)];
|
||||
mpMiddle->setPrev(mpMiddle);
|
||||
mpMiddle->setNext(mpMiddle);
|
||||
}
|
||||
|
||||
/*
|
||||
* This node plays the role of "pointer to head" and "pointer to tail".
|
||||
* It sits in the middle of a circular list of nodes. The iterator
|
||||
* runs around the circle until it encounters this one.
|
||||
*/
|
||||
_Node* mpMiddle;
|
||||
};
|
||||
|
||||
/*
|
||||
* Assignment operator.
|
||||
*
|
||||
* The simplest way to do this would be to clear out the target list and
|
||||
* fill it with the source. However, we can speed things along by
|
||||
* re-using existing elements.
|
||||
*/
|
||||
template<class T>
|
||||
List<T>& List<T>::operator=(const List<T>& right)
|
||||
{
|
||||
if (this == &right)
|
||||
return *this; // self-assignment
|
||||
iterator firstDst = begin();
|
||||
iterator lastDst = end();
|
||||
const_iterator firstSrc = right.begin();
|
||||
const_iterator lastSrc = right.end();
|
||||
while (firstSrc != lastSrc && firstDst != lastDst)
|
||||
*firstDst++ = *firstSrc++;
|
||||
if (firstSrc == lastSrc) // ran out of elements in source?
|
||||
erase(firstDst, lastDst); // yes, erase any extras
|
||||
else
|
||||
insert(lastDst, firstSrc, lastSrc); // copy remaining over
|
||||
return *this;
|
||||
}
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // _LIBS_UTILS_LIST_H
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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.
|
||||
*/
|
||||
|
||||
//
|
||||
// C/C++ logging functions. See the logging documentation for API details.
|
||||
//
|
||||
// We'd like these to be available from C code (in case we import some from
|
||||
// somewhere), so this has a C interface.
|
||||
//
|
||||
// The output will be correct when the log file is shared between multiple
|
||||
// threads and/or multiple processes so long as the operating system
|
||||
// supports O_APPEND. These calls have mutex-protected data structures
|
||||
// and so are NOT reentrant. Do not use LOG in a signal handler.
|
||||
//
|
||||
#ifndef _LIBS_UTILS_LOG_H
|
||||
#define _LIBS_UTILS_LOG_H
|
||||
|
||||
#include <cutils/log.h>
|
||||
|
||||
#endif // _LIBS_UTILS_LOG_H
|
|
@ -1,528 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_REF_BASE_H
|
||||
#define ANDROID_REF_BASE_H
|
||||
|
||||
#include <cutils/atomic.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <utils/StrongPointer.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
namespace android {
|
||||
|
||||
class TextOutput;
|
||||
TextOutput& printWeakPointer(TextOutput& to, const void* val);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#define COMPARE_WEAK(_op_) \
|
||||
inline bool operator _op_ (const sp<T>& o) const { \
|
||||
return m_ptr _op_ o.m_ptr; \
|
||||
} \
|
||||
inline bool operator _op_ (const T* o) const { \
|
||||
return m_ptr _op_ o; \
|
||||
} \
|
||||
template<typename U> \
|
||||
inline bool operator _op_ (const sp<U>& o) const { \
|
||||
return m_ptr _op_ o.m_ptr; \
|
||||
} \
|
||||
template<typename U> \
|
||||
inline bool operator _op_ (const U* o) const { \
|
||||
return m_ptr _op_ o; \
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
class ReferenceMover;
|
||||
class ReferenceConverterBase {
|
||||
public:
|
||||
virtual size_t getReferenceTypeSize() const = 0;
|
||||
virtual void* getReferenceBase(void const*) const = 0;
|
||||
inline virtual ~ReferenceConverterBase() { }
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class RefBase
|
||||
{
|
||||
public:
|
||||
void incStrong(const void* id) const;
|
||||
void decStrong(const void* id) const;
|
||||
|
||||
void forceIncStrong(const void* id) const;
|
||||
|
||||
//! DEBUGGING ONLY: Get current strong ref count.
|
||||
int32_t getStrongCount() const;
|
||||
|
||||
class weakref_type
|
||||
{
|
||||
public:
|
||||
RefBase* refBase() const;
|
||||
|
||||
void incWeak(const void* id);
|
||||
void decWeak(const void* id);
|
||||
|
||||
// acquires a strong reference if there is already one.
|
||||
bool attemptIncStrong(const void* id);
|
||||
|
||||
// acquires a weak reference if there is already one.
|
||||
// This is not always safe. see ProcessState.cpp and BpBinder.cpp
|
||||
// for proper use.
|
||||
bool attemptIncWeak(const void* id);
|
||||
|
||||
//! DEBUGGING ONLY: Get current weak ref count.
|
||||
int32_t getWeakCount() const;
|
||||
|
||||
//! DEBUGGING ONLY: Print references held on object.
|
||||
void printRefs() const;
|
||||
|
||||
//! DEBUGGING ONLY: Enable tracking for this object.
|
||||
// enable -- enable/disable tracking
|
||||
// retain -- when tracking is enable, if true, then we save a stack trace
|
||||
// for each reference and dereference; when retain == false, we
|
||||
// match up references and dereferences and keep only the
|
||||
// outstanding ones.
|
||||
|
||||
void trackMe(bool enable, bool retain);
|
||||
};
|
||||
|
||||
weakref_type* createWeak(const void* id) const;
|
||||
|
||||
weakref_type* getWeakRefs() const;
|
||||
|
||||
//! DEBUGGING ONLY: Print references held on object.
|
||||
inline void printRefs() const { getWeakRefs()->printRefs(); }
|
||||
|
||||
//! DEBUGGING ONLY: Enable tracking of object.
|
||||
inline void trackMe(bool enable, bool retain)
|
||||
{
|
||||
getWeakRefs()->trackMe(enable, retain);
|
||||
}
|
||||
|
||||
typedef RefBase basetype;
|
||||
|
||||
protected:
|
||||
RefBase();
|
||||
virtual ~RefBase();
|
||||
|
||||
//! Flags for extendObjectLifetime()
|
||||
enum {
|
||||
OBJECT_LIFETIME_STRONG = 0x0000,
|
||||
OBJECT_LIFETIME_WEAK = 0x0001,
|
||||
OBJECT_LIFETIME_MASK = 0x0001
|
||||
};
|
||||
|
||||
void extendObjectLifetime(int32_t mode);
|
||||
|
||||
//! Flags for onIncStrongAttempted()
|
||||
enum {
|
||||
FIRST_INC_STRONG = 0x0001
|
||||
};
|
||||
|
||||
virtual void onFirstRef();
|
||||
virtual void onLastStrongRef(const void* id);
|
||||
virtual bool onIncStrongAttempted(uint32_t flags, const void* id);
|
||||
virtual void onLastWeakRef(const void* id);
|
||||
|
||||
private:
|
||||
friend class ReferenceMover;
|
||||
static void moveReferences(void* d, void const* s, size_t n,
|
||||
const ReferenceConverterBase& caster);
|
||||
|
||||
private:
|
||||
friend class weakref_type;
|
||||
class weakref_impl;
|
||||
|
||||
RefBase(const RefBase& o);
|
||||
RefBase& operator=(const RefBase& o);
|
||||
|
||||
weakref_impl* const mRefs;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template <class T>
|
||||
class LightRefBase
|
||||
{
|
||||
public:
|
||||
inline LightRefBase() : mCount(0) { }
|
||||
inline void incStrong(const void* id) const {
|
||||
android_atomic_inc(&mCount);
|
||||
}
|
||||
inline void decStrong(const void* id) const {
|
||||
if (android_atomic_dec(&mCount) == 1) {
|
||||
delete static_cast<const T*>(this);
|
||||
}
|
||||
}
|
||||
//! DEBUGGING ONLY: Get current strong ref count.
|
||||
inline int32_t getStrongCount() const {
|
||||
return mCount;
|
||||
}
|
||||
|
||||
typedef LightRefBase<T> basetype;
|
||||
|
||||
protected:
|
||||
inline ~LightRefBase() { }
|
||||
|
||||
private:
|
||||
friend class ReferenceMover;
|
||||
inline static void moveReferences(void* d, void const* s, size_t n,
|
||||
const ReferenceConverterBase& caster) { }
|
||||
|
||||
private:
|
||||
mutable volatile int32_t mCount;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template <typename T>
|
||||
class wp
|
||||
{
|
||||
public:
|
||||
typedef typename RefBase::weakref_type weakref_type;
|
||||
|
||||
inline wp() : m_ptr(0) { }
|
||||
|
||||
wp(T* other);
|
||||
wp(const wp<T>& other);
|
||||
wp(const sp<T>& other);
|
||||
template<typename U> wp(U* other);
|
||||
template<typename U> wp(const sp<U>& other);
|
||||
template<typename U> wp(const wp<U>& other);
|
||||
|
||||
~wp();
|
||||
|
||||
// Assignment
|
||||
|
||||
wp& operator = (T* other);
|
||||
wp& operator = (const wp<T>& other);
|
||||
wp& operator = (const sp<T>& other);
|
||||
|
||||
template<typename U> wp& operator = (U* other);
|
||||
template<typename U> wp& operator = (const wp<U>& other);
|
||||
template<typename U> wp& operator = (const sp<U>& other);
|
||||
|
||||
void set_object_and_refs(T* other, weakref_type* refs);
|
||||
|
||||
// promotion to sp
|
||||
|
||||
sp<T> promote() const;
|
||||
|
||||
// Reset
|
||||
|
||||
void clear();
|
||||
|
||||
// Accessors
|
||||
|
||||
inline weakref_type* get_refs() const { return m_refs; }
|
||||
|
||||
inline T* unsafe_get() const { return m_ptr; }
|
||||
|
||||
// Operators
|
||||
|
||||
COMPARE_WEAK(==)
|
||||
COMPARE_WEAK(!=)
|
||||
COMPARE_WEAK(>)
|
||||
COMPARE_WEAK(<)
|
||||
COMPARE_WEAK(<=)
|
||||
COMPARE_WEAK(>=)
|
||||
|
||||
inline bool operator == (const wp<T>& o) const {
|
||||
return (m_ptr == o.m_ptr) && (m_refs == o.m_refs);
|
||||
}
|
||||
template<typename U>
|
||||
inline bool operator == (const wp<U>& o) const {
|
||||
return m_ptr == o.m_ptr;
|
||||
}
|
||||
|
||||
inline bool operator > (const wp<T>& o) const {
|
||||
return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr);
|
||||
}
|
||||
template<typename U>
|
||||
inline bool operator > (const wp<U>& o) const {
|
||||
return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr);
|
||||
}
|
||||
|
||||
inline bool operator < (const wp<T>& o) const {
|
||||
return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr);
|
||||
}
|
||||
template<typename U>
|
||||
inline bool operator < (const wp<U>& o) const {
|
||||
return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr);
|
||||
}
|
||||
inline bool operator != (const wp<T>& o) const { return m_refs != o.m_refs; }
|
||||
template<typename U> inline bool operator != (const wp<U>& o) const { return !operator == (o); }
|
||||
inline bool operator <= (const wp<T>& o) const { return !operator > (o); }
|
||||
template<typename U> inline bool operator <= (const wp<U>& o) const { return !operator > (o); }
|
||||
inline bool operator >= (const wp<T>& o) const { return !operator < (o); }
|
||||
template<typename U> inline bool operator >= (const wp<U>& o) const { return !operator < (o); }
|
||||
|
||||
private:
|
||||
template<typename Y> friend class sp;
|
||||
template<typename Y> friend class wp;
|
||||
|
||||
T* m_ptr;
|
||||
weakref_type* m_refs;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
TextOutput& operator<<(TextOutput& to, const wp<T>& val);
|
||||
|
||||
#undef COMPARE_WEAK
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// No user serviceable parts below here.
|
||||
|
||||
template<typename T>
|
||||
wp<T>::wp(T* other)
|
||||
: m_ptr(other)
|
||||
{
|
||||
if (other) m_refs = other->createWeak(this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
wp<T>::wp(const wp<T>& other)
|
||||
: m_ptr(other.m_ptr), m_refs(other.m_refs)
|
||||
{
|
||||
if (m_ptr) m_refs->incWeak(this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
wp<T>::wp(const sp<T>& other)
|
||||
: m_ptr(other.m_ptr)
|
||||
{
|
||||
if (m_ptr) {
|
||||
m_refs = m_ptr->createWeak(this);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T> template<typename U>
|
||||
wp<T>::wp(U* other)
|
||||
: m_ptr(other)
|
||||
{
|
||||
if (other) m_refs = other->createWeak(this);
|
||||
}
|
||||
|
||||
template<typename T> template<typename U>
|
||||
wp<T>::wp(const wp<U>& other)
|
||||
: m_ptr(other.m_ptr)
|
||||
{
|
||||
if (m_ptr) {
|
||||
m_refs = other.m_refs;
|
||||
m_refs->incWeak(this);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T> template<typename U>
|
||||
wp<T>::wp(const sp<U>& other)
|
||||
: m_ptr(other.m_ptr)
|
||||
{
|
||||
if (m_ptr) {
|
||||
m_refs = m_ptr->createWeak(this);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
wp<T>::~wp()
|
||||
{
|
||||
if (m_ptr) m_refs->decWeak(this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
wp<T>& wp<T>::operator = (T* other)
|
||||
{
|
||||
weakref_type* newRefs =
|
||||
other ? other->createWeak(this) : 0;
|
||||
if (m_ptr) m_refs->decWeak(this);
|
||||
m_ptr = other;
|
||||
m_refs = newRefs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
wp<T>& wp<T>::operator = (const wp<T>& other)
|
||||
{
|
||||
weakref_type* otherRefs(other.m_refs);
|
||||
T* otherPtr(other.m_ptr);
|
||||
if (otherPtr) otherRefs->incWeak(this);
|
||||
if (m_ptr) m_refs->decWeak(this);
|
||||
m_ptr = otherPtr;
|
||||
m_refs = otherRefs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
wp<T>& wp<T>::operator = (const sp<T>& other)
|
||||
{
|
||||
weakref_type* newRefs =
|
||||
other != NULL ? other->createWeak(this) : 0;
|
||||
T* otherPtr(other.m_ptr);
|
||||
if (m_ptr) m_refs->decWeak(this);
|
||||
m_ptr = otherPtr;
|
||||
m_refs = newRefs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T> template<typename U>
|
||||
wp<T>& wp<T>::operator = (U* other)
|
||||
{
|
||||
weakref_type* newRefs =
|
||||
other ? other->createWeak(this) : 0;
|
||||
if (m_ptr) m_refs->decWeak(this);
|
||||
m_ptr = other;
|
||||
m_refs = newRefs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T> template<typename U>
|
||||
wp<T>& wp<T>::operator = (const wp<U>& other)
|
||||
{
|
||||
weakref_type* otherRefs(other.m_refs);
|
||||
U* otherPtr(other.m_ptr);
|
||||
if (otherPtr) otherRefs->incWeak(this);
|
||||
if (m_ptr) m_refs->decWeak(this);
|
||||
m_ptr = otherPtr;
|
||||
m_refs = otherRefs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T> template<typename U>
|
||||
wp<T>& wp<T>::operator = (const sp<U>& other)
|
||||
{
|
||||
weakref_type* newRefs =
|
||||
other != NULL ? other->createWeak(this) : 0;
|
||||
U* otherPtr(other.m_ptr);
|
||||
if (m_ptr) m_refs->decWeak(this);
|
||||
m_ptr = otherPtr;
|
||||
m_refs = newRefs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void wp<T>::set_object_and_refs(T* other, weakref_type* refs)
|
||||
{
|
||||
if (other) refs->incWeak(this);
|
||||
if (m_ptr) m_refs->decWeak(this);
|
||||
m_ptr = other;
|
||||
m_refs = refs;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
sp<T> wp<T>::promote() const
|
||||
{
|
||||
sp<T> result;
|
||||
if (m_ptr && m_refs->attemptIncStrong(&result)) {
|
||||
result.set_pointer(m_ptr);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void wp<T>::clear()
|
||||
{
|
||||
if (m_ptr) {
|
||||
m_refs->decWeak(this);
|
||||
m_ptr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline TextOutput& operator<<(TextOutput& to, const wp<T>& val)
|
||||
{
|
||||
return printWeakPointer(to, val.unsafe_get());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// this class just serves as a namespace so TYPE::moveReferences can stay
|
||||
// private.
|
||||
|
||||
class ReferenceMover {
|
||||
// StrongReferenceCast and WeakReferenceCast do the impedance matching
|
||||
// between the generic (void*) implementation in Refbase and the strongly typed
|
||||
// template specializations below.
|
||||
|
||||
template <typename TYPE>
|
||||
struct StrongReferenceCast : public ReferenceConverterBase {
|
||||
virtual size_t getReferenceTypeSize() const { return sizeof( sp<TYPE> ); }
|
||||
virtual void* getReferenceBase(void const* p) const {
|
||||
sp<TYPE> const* sptr(reinterpret_cast<sp<TYPE> const*>(p));
|
||||
return static_cast<typename TYPE::basetype *>(sptr->get());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TYPE>
|
||||
struct WeakReferenceCast : public ReferenceConverterBase {
|
||||
virtual size_t getReferenceTypeSize() const { return sizeof( wp<TYPE> ); }
|
||||
virtual void* getReferenceBase(void const* p) const {
|
||||
wp<TYPE> const* sptr(reinterpret_cast<wp<TYPE> const*>(p));
|
||||
return static_cast<typename TYPE::basetype *>(sptr->unsafe_get());
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
template<typename TYPE> static inline
|
||||
void move_references(sp<TYPE>* d, sp<TYPE> const* s, size_t n) {
|
||||
memmove(d, s, n*sizeof(sp<TYPE>));
|
||||
StrongReferenceCast<TYPE> caster;
|
||||
TYPE::moveReferences(d, s, n, caster);
|
||||
}
|
||||
template<typename TYPE> static inline
|
||||
void move_references(wp<TYPE>* d, wp<TYPE> const* s, size_t n) {
|
||||
memmove(d, s, n*sizeof(wp<TYPE>));
|
||||
WeakReferenceCast<TYPE> caster;
|
||||
TYPE::moveReferences(d, s, n, caster);
|
||||
}
|
||||
};
|
||||
|
||||
// specialization for moving sp<> and wp<> types.
|
||||
// these are used by the [Sorted|Keyed]Vector<> implementations
|
||||
// sp<> and wp<> need to be handled specially, because they do not
|
||||
// have trivial copy operation in the general case (see RefBase.cpp
|
||||
// when DEBUG ops are enabled), but can be implemented very
|
||||
// efficiently in most cases.
|
||||
|
||||
template<typename TYPE> inline
|
||||
void move_forward_type(sp<TYPE>* d, sp<TYPE> const* s, size_t n) {
|
||||
ReferenceMover::move_references(d, s, n);
|
||||
}
|
||||
|
||||
template<typename TYPE> inline
|
||||
void move_backward_type(sp<TYPE>* d, sp<TYPE> const* s, size_t n) {
|
||||
ReferenceMover::move_references(d, s, n);
|
||||
}
|
||||
|
||||
template<typename TYPE> inline
|
||||
void move_forward_type(wp<TYPE>* d, wp<TYPE> const* s, size_t n) {
|
||||
ReferenceMover::move_references(d, s, n);
|
||||
}
|
||||
|
||||
template<typename TYPE> inline
|
||||
void move_backward_type(wp<TYPE>* d, wp<TYPE> const* s, size_t n) {
|
||||
ReferenceMover::move_references(d, s, n);
|
||||
}
|
||||
|
||||
|
||||
}; // namespace android
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_REF_BASE_H
|
|
@ -1,146 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_SHARED_BUFFER_H
|
||||
#define ANDROID_SHARED_BUFFER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace android {
|
||||
|
||||
class SharedBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
/* flags to use with release() */
|
||||
enum {
|
||||
eKeepStorage = 0x00000001
|
||||
};
|
||||
|
||||
/*! allocate a buffer of size 'size' and acquire() it.
|
||||
* call release() to free it.
|
||||
*/
|
||||
static SharedBuffer* alloc(size_t size);
|
||||
|
||||
/*! free the memory associated with the SharedBuffer.
|
||||
* Fails if there are any users associated with this SharedBuffer.
|
||||
* In other words, the buffer must have been release by all its
|
||||
* users.
|
||||
*/
|
||||
static ssize_t dealloc(const SharedBuffer* released);
|
||||
|
||||
//! get the SharedBuffer from the data pointer
|
||||
static inline const SharedBuffer* sharedBuffer(const void* data);
|
||||
|
||||
//! access the data for read
|
||||
inline const void* data() const;
|
||||
|
||||
//! access the data for read/write
|
||||
inline void* data();
|
||||
|
||||
//! get size of the buffer
|
||||
inline size_t size() const;
|
||||
|
||||
//! get back a SharedBuffer object from its data
|
||||
static inline SharedBuffer* bufferFromData(void* data);
|
||||
|
||||
//! get back a SharedBuffer object from its data
|
||||
static inline const SharedBuffer* bufferFromData(const void* data);
|
||||
|
||||
//! get the size of a SharedBuffer object from its data
|
||||
static inline size_t sizeFromData(const void* data);
|
||||
|
||||
//! edit the buffer (get a writtable, or non-const, version of it)
|
||||
SharedBuffer* edit() const;
|
||||
|
||||
//! edit the buffer, resizing if needed
|
||||
SharedBuffer* editResize(size_t size) const;
|
||||
|
||||
//! like edit() but fails if a copy is required
|
||||
SharedBuffer* attemptEdit() const;
|
||||
|
||||
//! resize and edit the buffer, loose it's content.
|
||||
SharedBuffer* reset(size_t size) const;
|
||||
|
||||
//! acquire/release a reference on this buffer
|
||||
void acquire() const;
|
||||
|
||||
/*! release a reference on this buffer, with the option of not
|
||||
* freeing the memory associated with it if it was the last reference
|
||||
* returns the previous reference count
|
||||
*/
|
||||
int32_t release(uint32_t flags = 0) const;
|
||||
|
||||
//! returns wether or not we're the only owner
|
||||
inline bool onlyOwner() const;
|
||||
|
||||
|
||||
private:
|
||||
inline SharedBuffer() { }
|
||||
inline ~SharedBuffer() { }
|
||||
inline SharedBuffer(const SharedBuffer&);
|
||||
|
||||
// 16 bytes. must be sized to preserve correct alingment.
|
||||
mutable int32_t mRefs;
|
||||
size_t mSize;
|
||||
uint32_t mReserved[2];
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const SharedBuffer* SharedBuffer::sharedBuffer(const void* data) {
|
||||
return data ? reinterpret_cast<const SharedBuffer *>(data)-1 : 0;
|
||||
}
|
||||
|
||||
const void* SharedBuffer::data() const {
|
||||
return this + 1;
|
||||
}
|
||||
|
||||
void* SharedBuffer::data() {
|
||||
return this + 1;
|
||||
}
|
||||
|
||||
size_t SharedBuffer::size() const {
|
||||
return mSize;
|
||||
}
|
||||
|
||||
SharedBuffer* SharedBuffer::bufferFromData(void* data)
|
||||
{
|
||||
return ((SharedBuffer*)data)-1;
|
||||
}
|
||||
|
||||
const SharedBuffer* SharedBuffer::bufferFromData(const void* data)
|
||||
{
|
||||
return ((const SharedBuffer*)data)-1;
|
||||
}
|
||||
|
||||
size_t SharedBuffer::sizeFromData(const void* data)
|
||||
{
|
||||
return (((const SharedBuffer*)data)-1)->mSize;
|
||||
}
|
||||
|
||||
bool SharedBuffer::onlyOwner() const {
|
||||
return (mRefs == 1);
|
||||
}
|
||||
|
||||
}; // namespace android
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_VECTOR_H
|
|
@ -1,283 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_SORTED_VECTOR_H
|
||||
#define ANDROID_SORTED_VECTOR_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <utils/Vector.h>
|
||||
#include <utils/VectorImpl.h>
|
||||
#include <utils/TypeHelpers.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace android {
|
||||
|
||||
template <class TYPE>
|
||||
class SortedVector : private SortedVectorImpl
|
||||
{
|
||||
friend class Vector<TYPE>;
|
||||
|
||||
public:
|
||||
typedef TYPE value_type;
|
||||
|
||||
/*!
|
||||
* Constructors and destructors
|
||||
*/
|
||||
|
||||
SortedVector();
|
||||
SortedVector(const SortedVector<TYPE>& rhs);
|
||||
virtual ~SortedVector();
|
||||
|
||||
/*! copy operator */
|
||||
const SortedVector<TYPE>& operator = (const SortedVector<TYPE>& rhs) const;
|
||||
SortedVector<TYPE>& operator = (const SortedVector<TYPE>& rhs);
|
||||
|
||||
/*
|
||||
* empty the vector
|
||||
*/
|
||||
|
||||
inline void clear() { VectorImpl::clear(); }
|
||||
|
||||
/*!
|
||||
* vector stats
|
||||
*/
|
||||
|
||||
//! returns number of items in the vector
|
||||
inline size_t size() const { return VectorImpl::size(); }
|
||||
//! returns wether or not the vector is empty
|
||||
inline bool isEmpty() const { return VectorImpl::isEmpty(); }
|
||||
//! returns how many items can be stored without reallocating the backing store
|
||||
inline size_t capacity() const { return VectorImpl::capacity(); }
|
||||
//! setst the capacity. capacity can never be reduced less than size()
|
||||
inline ssize_t setCapacity(size_t size) { return VectorImpl::setCapacity(size); }
|
||||
|
||||
/*!
|
||||
* C-style array access
|
||||
*/
|
||||
|
||||
//! read-only C-style access
|
||||
inline const TYPE* array() const;
|
||||
|
||||
//! read-write C-style access. BE VERY CAREFUL when modifying the array
|
||||
//! you ust keep it sorted! You usually don't use this function.
|
||||
TYPE* editArray();
|
||||
|
||||
//! finds the index of an item
|
||||
ssize_t indexOf(const TYPE& item) const;
|
||||
|
||||
//! finds where this item should be inserted
|
||||
size_t orderOf(const TYPE& item) const;
|
||||
|
||||
|
||||
/*!
|
||||
* accessors
|
||||
*/
|
||||
|
||||
//! read-only access to an item at a given index
|
||||
inline const TYPE& operator [] (size_t index) const;
|
||||
//! alternate name for operator []
|
||||
inline const TYPE& itemAt(size_t index) const;
|
||||
//! stack-usage of the vector. returns the top of the stack (last element)
|
||||
const TYPE& top() const;
|
||||
//! same as operator [], but allows to access the vector backward (from the end) with a negative index
|
||||
const TYPE& mirrorItemAt(ssize_t index) const;
|
||||
|
||||
/*!
|
||||
* modifing the array
|
||||
*/
|
||||
|
||||
//! add an item in the right place (and replace the one that is there)
|
||||
ssize_t add(const TYPE& item);
|
||||
|
||||
//! editItemAt() MUST NOT change the order of this item
|
||||
TYPE& editItemAt(size_t index) {
|
||||
return *( static_cast<TYPE *>(VectorImpl::editItemLocation(index)) );
|
||||
}
|
||||
|
||||
//! merges a vector into this one
|
||||
ssize_t merge(const Vector<TYPE>& vector);
|
||||
ssize_t merge(const SortedVector<TYPE>& vector);
|
||||
|
||||
//! removes an item
|
||||
ssize_t remove(const TYPE&);
|
||||
|
||||
//! remove several items
|
||||
inline ssize_t removeItemsAt(size_t index, size_t count = 1);
|
||||
//! remove one item
|
||||
inline ssize_t removeAt(size_t index) { return removeItemsAt(index); }
|
||||
|
||||
protected:
|
||||
virtual void do_construct(void* storage, size_t num) const;
|
||||
virtual void do_destroy(void* storage, size_t num) const;
|
||||
virtual void do_copy(void* dest, const void* from, size_t num) const;
|
||||
virtual void do_splat(void* dest, const void* item, size_t num) const;
|
||||
virtual void do_move_forward(void* dest, const void* from, size_t num) const;
|
||||
virtual void do_move_backward(void* dest, const void* from, size_t num) const;
|
||||
virtual int do_compare(const void* lhs, const void* rhs) const;
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// No user serviceable parts from here...
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template<class TYPE> inline
|
||||
SortedVector<TYPE>::SortedVector()
|
||||
: SortedVectorImpl(sizeof(TYPE),
|
||||
((traits<TYPE>::has_trivial_ctor ? HAS_TRIVIAL_CTOR : 0)
|
||||
|(traits<TYPE>::has_trivial_dtor ? HAS_TRIVIAL_DTOR : 0)
|
||||
|(traits<TYPE>::has_trivial_copy ? HAS_TRIVIAL_COPY : 0))
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
SortedVector<TYPE>::SortedVector(const SortedVector<TYPE>& rhs)
|
||||
: SortedVectorImpl(rhs) {
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
SortedVector<TYPE>::~SortedVector() {
|
||||
finish_vector();
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
SortedVector<TYPE>& SortedVector<TYPE>::operator = (const SortedVector<TYPE>& rhs) {
|
||||
SortedVectorImpl::operator = (rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
const SortedVector<TYPE>& SortedVector<TYPE>::operator = (const SortedVector<TYPE>& rhs) const {
|
||||
SortedVectorImpl::operator = (rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
const TYPE* SortedVector<TYPE>::array() const {
|
||||
return static_cast<const TYPE *>(arrayImpl());
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
TYPE* SortedVector<TYPE>::editArray() {
|
||||
return static_cast<TYPE *>(editArrayImpl());
|
||||
}
|
||||
|
||||
|
||||
template<class TYPE> inline
|
||||
const TYPE& SortedVector<TYPE>::operator[](size_t index) const {
|
||||
assert( index<size() );
|
||||
return *(array() + index);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
const TYPE& SortedVector<TYPE>::itemAt(size_t index) const {
|
||||
return operator[](index);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
const TYPE& SortedVector<TYPE>::mirrorItemAt(ssize_t index) const {
|
||||
assert( (index>0 ? index : -index)<size() );
|
||||
return *(array() + ((index<0) ? (size()-index) : index));
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
const TYPE& SortedVector<TYPE>::top() const {
|
||||
return *(array() + size() - 1);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t SortedVector<TYPE>::add(const TYPE& item) {
|
||||
return SortedVectorImpl::add(&item);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t SortedVector<TYPE>::indexOf(const TYPE& item) const {
|
||||
return SortedVectorImpl::indexOf(&item);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
size_t SortedVector<TYPE>::orderOf(const TYPE& item) const {
|
||||
return SortedVectorImpl::orderOf(&item);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t SortedVector<TYPE>::merge(const Vector<TYPE>& vector) {
|
||||
return SortedVectorImpl::merge(reinterpret_cast<const VectorImpl&>(vector));
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t SortedVector<TYPE>::merge(const SortedVector<TYPE>& vector) {
|
||||
return SortedVectorImpl::merge(reinterpret_cast<const SortedVectorImpl&>(vector));
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t SortedVector<TYPE>::remove(const TYPE& item) {
|
||||
return SortedVectorImpl::remove(&item);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t SortedVector<TYPE>::removeItemsAt(size_t index, size_t count) {
|
||||
return VectorImpl::removeItemsAt(index, count);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template<class TYPE>
|
||||
void SortedVector<TYPE>::do_construct(void* storage, size_t num) const {
|
||||
construct_type( reinterpret_cast<TYPE*>(storage), num );
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void SortedVector<TYPE>::do_destroy(void* storage, size_t num) const {
|
||||
destroy_type( reinterpret_cast<TYPE*>(storage), num );
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void SortedVector<TYPE>::do_copy(void* dest, const void* from, size_t num) const {
|
||||
copy_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void SortedVector<TYPE>::do_splat(void* dest, const void* item, size_t num) const {
|
||||
splat_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(item), num );
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void SortedVector<TYPE>::do_move_forward(void* dest, const void* from, size_t num) const {
|
||||
move_forward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void SortedVector<TYPE>::do_move_backward(void* dest, const void* from, size_t num) const {
|
||||
move_backward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
int SortedVector<TYPE>::do_compare(const void* lhs, const void* rhs) const {
|
||||
return compare_type( *reinterpret_cast<const TYPE*>(lhs), *reinterpret_cast<const TYPE*>(rhs) );
|
||||
}
|
||||
|
||||
}; // namespace android
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_SORTED_VECTOR_H
|
|
@ -1,238 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_STRING16_H
|
||||
#define ANDROID_STRING16_H
|
||||
|
||||
#include <utils/Errors.h>
|
||||
#include <utils/SharedBuffer.h>
|
||||
#include <utils/Unicode.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
extern "C" {
|
||||
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace android {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class String8;
|
||||
class TextOutput;
|
||||
|
||||
//! This is a string holding UTF-16 characters.
|
||||
class String16
|
||||
{
|
||||
public:
|
||||
String16();
|
||||
String16(const String16& o);
|
||||
String16(const String16& o,
|
||||
size_t len,
|
||||
size_t begin=0);
|
||||
explicit String16(const char16_t* o);
|
||||
explicit String16(const char16_t* o, size_t len);
|
||||
explicit String16(const String8& o);
|
||||
explicit String16(const char* o);
|
||||
explicit String16(const char* o, size_t len);
|
||||
|
||||
~String16();
|
||||
|
||||
inline const char16_t* string() const;
|
||||
inline size_t size() const;
|
||||
|
||||
inline const SharedBuffer* sharedBuffer() const;
|
||||
|
||||
void setTo(const String16& other);
|
||||
status_t setTo(const char16_t* other);
|
||||
status_t setTo(const char16_t* other, size_t len);
|
||||
status_t setTo(const String16& other,
|
||||
size_t len,
|
||||
size_t begin=0);
|
||||
|
||||
status_t append(const String16& other);
|
||||
status_t append(const char16_t* other, size_t len);
|
||||
|
||||
inline String16& operator=(const String16& other);
|
||||
|
||||
inline String16& operator+=(const String16& other);
|
||||
inline String16 operator+(const String16& other) const;
|
||||
|
||||
status_t insert(size_t pos, const char16_t* chrs);
|
||||
status_t insert(size_t pos,
|
||||
const char16_t* chrs, size_t len);
|
||||
|
||||
ssize_t findFirst(char16_t c) const;
|
||||
ssize_t findLast(char16_t c) const;
|
||||
|
||||
bool startsWith(const String16& prefix) const;
|
||||
bool startsWith(const char16_t* prefix) const;
|
||||
|
||||
status_t makeLower();
|
||||
|
||||
status_t replaceAll(char16_t replaceThis,
|
||||
char16_t withThis);
|
||||
|
||||
status_t remove(size_t len, size_t begin=0);
|
||||
|
||||
inline int compare(const String16& other) const;
|
||||
|
||||
inline bool operator<(const String16& other) const;
|
||||
inline bool operator<=(const String16& other) const;
|
||||
inline bool operator==(const String16& other) const;
|
||||
inline bool operator!=(const String16& other) const;
|
||||
inline bool operator>=(const String16& other) const;
|
||||
inline bool operator>(const String16& other) const;
|
||||
|
||||
inline bool operator<(const char16_t* other) const;
|
||||
inline bool operator<=(const char16_t* other) const;
|
||||
inline bool operator==(const char16_t* other) const;
|
||||
inline bool operator!=(const char16_t* other) const;
|
||||
inline bool operator>=(const char16_t* other) const;
|
||||
inline bool operator>(const char16_t* other) const;
|
||||
|
||||
inline operator const char16_t*() const;
|
||||
|
||||
private:
|
||||
const char16_t* mString;
|
||||
};
|
||||
|
||||
TextOutput& operator<<(TextOutput& to, const String16& val);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// No user servicable parts below.
|
||||
|
||||
inline int compare_type(const String16& lhs, const String16& rhs)
|
||||
{
|
||||
return lhs.compare(rhs);
|
||||
}
|
||||
|
||||
inline int strictly_order_type(const String16& lhs, const String16& rhs)
|
||||
{
|
||||
return compare_type(lhs, rhs) < 0;
|
||||
}
|
||||
|
||||
inline const char16_t* String16::string() const
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
inline size_t String16::size() const
|
||||
{
|
||||
return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1;
|
||||
}
|
||||
|
||||
inline const SharedBuffer* String16::sharedBuffer() const
|
||||
{
|
||||
return SharedBuffer::bufferFromData(mString);
|
||||
}
|
||||
|
||||
inline String16& String16::operator=(const String16& other)
|
||||
{
|
||||
setTo(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline String16& String16::operator+=(const String16& other)
|
||||
{
|
||||
append(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline String16 String16::operator+(const String16& other) const
|
||||
{
|
||||
String16 tmp(*this);
|
||||
tmp += other;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline int String16::compare(const String16& other) const
|
||||
{
|
||||
return strzcmp16(mString, size(), other.mString, other.size());
|
||||
}
|
||||
|
||||
inline bool String16::operator<(const String16& other) const
|
||||
{
|
||||
return strzcmp16(mString, size(), other.mString, other.size()) < 0;
|
||||
}
|
||||
|
||||
inline bool String16::operator<=(const String16& other) const
|
||||
{
|
||||
return strzcmp16(mString, size(), other.mString, other.size()) <= 0;
|
||||
}
|
||||
|
||||
inline bool String16::operator==(const String16& other) const
|
||||
{
|
||||
return strzcmp16(mString, size(), other.mString, other.size()) == 0;
|
||||
}
|
||||
|
||||
inline bool String16::operator!=(const String16& other) const
|
||||
{
|
||||
return strzcmp16(mString, size(), other.mString, other.size()) != 0;
|
||||
}
|
||||
|
||||
inline bool String16::operator>=(const String16& other) const
|
||||
{
|
||||
return strzcmp16(mString, size(), other.mString, other.size()) >= 0;
|
||||
}
|
||||
|
||||
inline bool String16::operator>(const String16& other) const
|
||||
{
|
||||
return strzcmp16(mString, size(), other.mString, other.size()) > 0;
|
||||
}
|
||||
|
||||
inline bool String16::operator<(const char16_t* other) const
|
||||
{
|
||||
return strcmp16(mString, other) < 0;
|
||||
}
|
||||
|
||||
inline bool String16::operator<=(const char16_t* other) const
|
||||
{
|
||||
return strcmp16(mString, other) <= 0;
|
||||
}
|
||||
|
||||
inline bool String16::operator==(const char16_t* other) const
|
||||
{
|
||||
return strcmp16(mString, other) == 0;
|
||||
}
|
||||
|
||||
inline bool String16::operator!=(const char16_t* other) const
|
||||
{
|
||||
return strcmp16(mString, other) != 0;
|
||||
}
|
||||
|
||||
inline bool String16::operator>=(const char16_t* other) const
|
||||
{
|
||||
return strcmp16(mString, other) >= 0;
|
||||
}
|
||||
|
||||
inline bool String16::operator>(const char16_t* other) const
|
||||
{
|
||||
return strcmp16(mString, other) > 0;
|
||||
}
|
||||
|
||||
inline String16::operator const char16_t*() const
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
}; // namespace android
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_STRING16_H
|
|
@ -1,383 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_STRING8_H
|
||||
#define ANDROID_STRING8_H
|
||||
|
||||
#include <utils/Errors.h>
|
||||
#include <utils/SharedBuffer.h>
|
||||
#include <utils/Unicode.h>
|
||||
|
||||
#include <string.h> // for strcmp
|
||||
#include <stdarg.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace android {
|
||||
|
||||
class String16;
|
||||
class TextOutput;
|
||||
|
||||
//! This is a string holding UTF-8 characters. Does not allow the value more
|
||||
// than 0x10FFFF, which is not valid unicode codepoint.
|
||||
class String8
|
||||
{
|
||||
public:
|
||||
String8();
|
||||
String8(const String8& o);
|
||||
explicit String8(const char* o);
|
||||
explicit String8(const char* o, size_t numChars);
|
||||
|
||||
explicit String8(const String16& o);
|
||||
explicit String8(const char16_t* o);
|
||||
explicit String8(const char16_t* o, size_t numChars);
|
||||
explicit String8(const char32_t* o);
|
||||
explicit String8(const char32_t* o, size_t numChars);
|
||||
~String8();
|
||||
|
||||
static inline const String8 empty();
|
||||
|
||||
static String8 format(const char* fmt, ...) __attribute__((format (printf, 1, 2)));
|
||||
static String8 formatV(const char* fmt, va_list args);
|
||||
|
||||
inline const char* string() const;
|
||||
inline size_t size() const;
|
||||
inline size_t length() const;
|
||||
inline size_t bytes() const;
|
||||
inline bool isEmpty() const;
|
||||
|
||||
inline const SharedBuffer* sharedBuffer() const;
|
||||
|
||||
void clear();
|
||||
|
||||
void setTo(const String8& other);
|
||||
status_t setTo(const char* other);
|
||||
status_t setTo(const char* other, size_t numChars);
|
||||
status_t setTo(const char16_t* other, size_t numChars);
|
||||
status_t setTo(const char32_t* other,
|
||||
size_t length);
|
||||
|
||||
status_t append(const String8& other);
|
||||
status_t append(const char* other);
|
||||
status_t append(const char* other, size_t numChars);
|
||||
|
||||
status_t appendFormat(const char* fmt, ...)
|
||||
__attribute__((format (printf, 2, 3)));
|
||||
status_t appendFormatV(const char* fmt, va_list args);
|
||||
|
||||
// Note that this function takes O(N) time to calculate the value.
|
||||
// No cache value is stored.
|
||||
size_t getUtf32Length() const;
|
||||
int32_t getUtf32At(size_t index,
|
||||
size_t *next_index) const;
|
||||
void getUtf32(char32_t* dst) const;
|
||||
|
||||
inline String8& operator=(const String8& other);
|
||||
inline String8& operator=(const char* other);
|
||||
|
||||
inline String8& operator+=(const String8& other);
|
||||
inline String8 operator+(const String8& other) const;
|
||||
|
||||
inline String8& operator+=(const char* other);
|
||||
inline String8 operator+(const char* other) const;
|
||||
|
||||
inline int compare(const String8& other) const;
|
||||
|
||||
inline bool operator<(const String8& other) const;
|
||||
inline bool operator<=(const String8& other) const;
|
||||
inline bool operator==(const String8& other) const;
|
||||
inline bool operator!=(const String8& other) const;
|
||||
inline bool operator>=(const String8& other) const;
|
||||
inline bool operator>(const String8& other) const;
|
||||
|
||||
inline bool operator<(const char* other) const;
|
||||
inline bool operator<=(const char* other) const;
|
||||
inline bool operator==(const char* other) const;
|
||||
inline bool operator!=(const char* other) const;
|
||||
inline bool operator>=(const char* other) const;
|
||||
inline bool operator>(const char* other) const;
|
||||
|
||||
inline operator const char*() const;
|
||||
|
||||
char* lockBuffer(size_t size);
|
||||
void unlockBuffer();
|
||||
status_t unlockBuffer(size_t size);
|
||||
|
||||
// return the index of the first byte of other in this at or after
|
||||
// start, or -1 if not found
|
||||
ssize_t find(const char* other, size_t start = 0) const;
|
||||
|
||||
void toLower();
|
||||
void toLower(size_t start, size_t numChars);
|
||||
void toUpper();
|
||||
void toUpper(size_t start, size_t numChars);
|
||||
|
||||
/*
|
||||
* These methods operate on the string as if it were a path name.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Set the filename field to a specific value.
|
||||
*
|
||||
* Normalizes the filename, removing a trailing '/' if present.
|
||||
*/
|
||||
void setPathName(const char* name);
|
||||
void setPathName(const char* name, size_t numChars);
|
||||
|
||||
/*
|
||||
* Get just the filename component.
|
||||
*
|
||||
* "/tmp/foo/bar.c" --> "bar.c"
|
||||
*/
|
||||
String8 getPathLeaf(void) const;
|
||||
|
||||
/*
|
||||
* Remove the last (file name) component, leaving just the directory
|
||||
* name.
|
||||
*
|
||||
* "/tmp/foo/bar.c" --> "/tmp/foo"
|
||||
* "/tmp" --> "" // ????? shouldn't this be "/" ???? XXX
|
||||
* "bar.c" --> ""
|
||||
*/
|
||||
String8 getPathDir(void) const;
|
||||
|
||||
/*
|
||||
* Retrieve the front (root dir) component. Optionally also return the
|
||||
* remaining components.
|
||||
*
|
||||
* "/tmp/foo/bar.c" --> "tmp" (remain = "foo/bar.c")
|
||||
* "/tmp" --> "tmp" (remain = "")
|
||||
* "bar.c" --> "bar.c" (remain = "")
|
||||
*/
|
||||
String8 walkPath(String8* outRemains = NULL) const;
|
||||
|
||||
/*
|
||||
* Return the filename extension. This is the last '.' and any number
|
||||
* of characters that follow it. The '.' is included in case we
|
||||
* decide to expand our definition of what constitutes an extension.
|
||||
*
|
||||
* "/tmp/foo/bar.c" --> ".c"
|
||||
* "/tmp" --> ""
|
||||
* "/tmp/foo.bar/baz" --> ""
|
||||
* "foo.jpeg" --> ".jpeg"
|
||||
* "foo." --> ""
|
||||
*/
|
||||
String8 getPathExtension(void) const;
|
||||
|
||||
/*
|
||||
* Return the path without the extension. Rules for what constitutes
|
||||
* an extension are described in the comment for getPathExtension().
|
||||
*
|
||||
* "/tmp/foo/bar.c" --> "/tmp/foo/bar"
|
||||
*/
|
||||
String8 getBasePath(void) const;
|
||||
|
||||
/*
|
||||
* Add a component to the pathname. We guarantee that there is
|
||||
* exactly one path separator between the old path and the new.
|
||||
* If there is no existing name, we just copy the new name in.
|
||||
*
|
||||
* If leaf is a fully qualified path (i.e. starts with '/', it
|
||||
* replaces whatever was there before.
|
||||
*/
|
||||
String8& appendPath(const char* leaf);
|
||||
String8& appendPath(const String8& leaf) { return appendPath(leaf.string()); }
|
||||
|
||||
/*
|
||||
* Like appendPath(), but does not affect this string. Returns a new one instead.
|
||||
*/
|
||||
String8 appendPathCopy(const char* leaf) const
|
||||
{ String8 p(*this); p.appendPath(leaf); return p; }
|
||||
String8 appendPathCopy(const String8& leaf) const { return appendPathCopy(leaf.string()); }
|
||||
|
||||
/*
|
||||
* Converts all separators in this string to /, the default path separator.
|
||||
*
|
||||
* If the default OS separator is backslash, this converts all
|
||||
* backslashes to slashes, in-place. Otherwise it does nothing.
|
||||
* Returns self.
|
||||
*/
|
||||
String8& convertToResPath();
|
||||
|
||||
private:
|
||||
status_t real_append(const char* other, size_t numChars);
|
||||
char* find_extension(void) const;
|
||||
|
||||
const char* mString;
|
||||
};
|
||||
|
||||
TextOutput& operator<<(TextOutput& to, const String16& val);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// No user servicable parts below.
|
||||
|
||||
inline int compare_type(const String8& lhs, const String8& rhs)
|
||||
{
|
||||
return lhs.compare(rhs);
|
||||
}
|
||||
|
||||
inline int strictly_order_type(const String8& lhs, const String8& rhs)
|
||||
{
|
||||
return compare_type(lhs, rhs) < 0;
|
||||
}
|
||||
|
||||
inline const String8 String8::empty() {
|
||||
return String8();
|
||||
}
|
||||
|
||||
inline const char* String8::string() const
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
inline size_t String8::length() const
|
||||
{
|
||||
return SharedBuffer::sizeFromData(mString)-1;
|
||||
}
|
||||
|
||||
inline size_t String8::size() const
|
||||
{
|
||||
return length();
|
||||
}
|
||||
|
||||
inline bool String8::isEmpty() const
|
||||
{
|
||||
return length() == 0;
|
||||
}
|
||||
|
||||
inline size_t String8::bytes() const
|
||||
{
|
||||
return SharedBuffer::sizeFromData(mString)-1;
|
||||
}
|
||||
|
||||
inline const SharedBuffer* String8::sharedBuffer() const
|
||||
{
|
||||
return SharedBuffer::bufferFromData(mString);
|
||||
}
|
||||
|
||||
inline String8& String8::operator=(const String8& other)
|
||||
{
|
||||
setTo(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline String8& String8::operator=(const char* other)
|
||||
{
|
||||
setTo(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline String8& String8::operator+=(const String8& other)
|
||||
{
|
||||
append(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline String8 String8::operator+(const String8& other) const
|
||||
{
|
||||
String8 tmp(*this);
|
||||
tmp += other;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline String8& String8::operator+=(const char* other)
|
||||
{
|
||||
append(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline String8 String8::operator+(const char* other) const
|
||||
{
|
||||
String8 tmp(*this);
|
||||
tmp += other;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline int String8::compare(const String8& other) const
|
||||
{
|
||||
return strcmp(mString, other.mString);
|
||||
}
|
||||
|
||||
inline bool String8::operator<(const String8& other) const
|
||||
{
|
||||
return strcmp(mString, other.mString) < 0;
|
||||
}
|
||||
|
||||
inline bool String8::operator<=(const String8& other) const
|
||||
{
|
||||
return strcmp(mString, other.mString) <= 0;
|
||||
}
|
||||
|
||||
inline bool String8::operator==(const String8& other) const
|
||||
{
|
||||
return strcmp(mString, other.mString) == 0;
|
||||
}
|
||||
|
||||
inline bool String8::operator!=(const String8& other) const
|
||||
{
|
||||
return strcmp(mString, other.mString) != 0;
|
||||
}
|
||||
|
||||
inline bool String8::operator>=(const String8& other) const
|
||||
{
|
||||
return strcmp(mString, other.mString) >= 0;
|
||||
}
|
||||
|
||||
inline bool String8::operator>(const String8& other) const
|
||||
{
|
||||
return strcmp(mString, other.mString) > 0;
|
||||
}
|
||||
|
||||
inline bool String8::operator<(const char* other) const
|
||||
{
|
||||
return strcmp(mString, other) < 0;
|
||||
}
|
||||
|
||||
inline bool String8::operator<=(const char* other) const
|
||||
{
|
||||
return strcmp(mString, other) <= 0;
|
||||
}
|
||||
|
||||
inline bool String8::operator==(const char* other) const
|
||||
{
|
||||
return strcmp(mString, other) == 0;
|
||||
}
|
||||
|
||||
inline bool String8::operator!=(const char* other) const
|
||||
{
|
||||
return strcmp(mString, other) != 0;
|
||||
}
|
||||
|
||||
inline bool String8::operator>=(const char* other) const
|
||||
{
|
||||
return strcmp(mString, other) >= 0;
|
||||
}
|
||||
|
||||
inline bool String8::operator>(const char* other) const
|
||||
{
|
||||
return strcmp(mString, other) > 0;
|
||||
}
|
||||
|
||||
inline String8::operator const char*() const
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_STRING8_H
|
|
@ -1,220 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_STRONG_POINTER_H
|
||||
#define ANDROID_STRONG_POINTER_H
|
||||
|
||||
#include <cutils/atomic.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
namespace android {
|
||||
|
||||
class TextOutput;
|
||||
TextOutput& printStrongPointer(TextOutput& to, const void* val);
|
||||
|
||||
template<typename T> class wp;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#define COMPARE(_op_) \
|
||||
inline bool operator _op_ (const sp<T>& o) const { \
|
||||
return m_ptr _op_ o.m_ptr; \
|
||||
} \
|
||||
inline bool operator _op_ (const T* o) const { \
|
||||
return m_ptr _op_ o; \
|
||||
} \
|
||||
template<typename U> \
|
||||
inline bool operator _op_ (const sp<U>& o) const { \
|
||||
return m_ptr _op_ o.m_ptr; \
|
||||
} \
|
||||
template<typename U> \
|
||||
inline bool operator _op_ (const U* o) const { \
|
||||
return m_ptr _op_ o; \
|
||||
} \
|
||||
inline bool operator _op_ (const wp<T>& o) const { \
|
||||
return m_ptr _op_ o.m_ptr; \
|
||||
} \
|
||||
template<typename U> \
|
||||
inline bool operator _op_ (const wp<U>& o) const { \
|
||||
return m_ptr _op_ o.m_ptr; \
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template <typename T>
|
||||
class sp
|
||||
{
|
||||
public:
|
||||
inline sp() : m_ptr(0) { }
|
||||
|
||||
sp(T* other);
|
||||
sp(const sp<T>& other);
|
||||
template<typename U> sp(U* other);
|
||||
template<typename U> sp(const sp<U>& other);
|
||||
|
||||
~sp();
|
||||
|
||||
// Assignment
|
||||
|
||||
sp& operator = (T* other);
|
||||
sp& operator = (const sp<T>& other);
|
||||
|
||||
template<typename U> sp& operator = (const sp<U>& other);
|
||||
template<typename U> sp& operator = (U* other);
|
||||
|
||||
//! Special optimization for use by ProcessState (and nobody else).
|
||||
void force_set(T* other);
|
||||
|
||||
// Reset
|
||||
|
||||
void clear();
|
||||
|
||||
// Accessors
|
||||
|
||||
inline T& operator* () const { return *m_ptr; }
|
||||
inline T* operator-> () const { return m_ptr; }
|
||||
inline T* get() const { return m_ptr; }
|
||||
|
||||
// Operators
|
||||
|
||||
COMPARE(==)
|
||||
COMPARE(!=)
|
||||
COMPARE(>)
|
||||
COMPARE(<)
|
||||
COMPARE(<=)
|
||||
COMPARE(>=)
|
||||
|
||||
private:
|
||||
template<typename Y> friend class sp;
|
||||
template<typename Y> friend class wp;
|
||||
void set_pointer(T* ptr);
|
||||
T* m_ptr;
|
||||
};
|
||||
|
||||
#undef COMPARE
|
||||
|
||||
template <typename T>
|
||||
TextOutput& operator<<(TextOutput& to, const sp<T>& val);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// No user serviceable parts below here.
|
||||
|
||||
template<typename T>
|
||||
sp<T>::sp(T* other)
|
||||
: m_ptr(other)
|
||||
{
|
||||
if (other) other->incStrong(this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
sp<T>::sp(const sp<T>& other)
|
||||
: m_ptr(other.m_ptr)
|
||||
{
|
||||
if (m_ptr) m_ptr->incStrong(this);
|
||||
}
|
||||
|
||||
template<typename T> template<typename U>
|
||||
sp<T>::sp(U* other) : m_ptr(other)
|
||||
{
|
||||
if (other) ((T*)other)->incStrong(this);
|
||||
}
|
||||
|
||||
template<typename T> template<typename U>
|
||||
sp<T>::sp(const sp<U>& other)
|
||||
: m_ptr(other.m_ptr)
|
||||
{
|
||||
if (m_ptr) m_ptr->incStrong(this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
sp<T>::~sp()
|
||||
{
|
||||
if (m_ptr) m_ptr->decStrong(this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
sp<T>& sp<T>::operator = (const sp<T>& other) {
|
||||
T* otherPtr(other.m_ptr);
|
||||
if (otherPtr) otherPtr->incStrong(this);
|
||||
if (m_ptr) m_ptr->decStrong(this);
|
||||
m_ptr = otherPtr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
sp<T>& sp<T>::operator = (T* other)
|
||||
{
|
||||
if (other) other->incStrong(this);
|
||||
if (m_ptr) m_ptr->decStrong(this);
|
||||
m_ptr = other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T> template<typename U>
|
||||
sp<T>& sp<T>::operator = (const sp<U>& other)
|
||||
{
|
||||
T* otherPtr(other.m_ptr);
|
||||
if (otherPtr) otherPtr->incStrong(this);
|
||||
if (m_ptr) m_ptr->decStrong(this);
|
||||
m_ptr = otherPtr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T> template<typename U>
|
||||
sp<T>& sp<T>::operator = (U* other)
|
||||
{
|
||||
if (other) ((T*)other)->incStrong(this);
|
||||
if (m_ptr) m_ptr->decStrong(this);
|
||||
m_ptr = other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void sp<T>::force_set(T* other)
|
||||
{
|
||||
other->forceIncStrong(this);
|
||||
m_ptr = other;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void sp<T>::clear()
|
||||
{
|
||||
if (m_ptr) {
|
||||
m_ptr->decStrong(this);
|
||||
m_ptr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void sp<T>::set_pointer(T* ptr) {
|
||||
m_ptr = ptr;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline TextOutput& operator<<(TextOutput& to, const sp<T>& val)
|
||||
{
|
||||
return printStrongPointer(to, val.get());
|
||||
}
|
||||
|
||||
}; // namespace android
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_STRONG_POINTER_H
|
|
@ -1,144 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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.
|
||||
*/
|
||||
|
||||
//
|
||||
// Timer functions.
|
||||
//
|
||||
#ifndef _LIBS_UTILS_TIMERS_H
|
||||
#define _LIBS_UTILS_TIMERS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// C API
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef int64_t nsecs_t; // nano-seconds
|
||||
|
||||
static inline nsecs_t seconds_to_nanoseconds(nsecs_t secs)
|
||||
{
|
||||
return secs*1000000000;
|
||||
}
|
||||
|
||||
static inline nsecs_t milliseconds_to_nanoseconds(nsecs_t secs)
|
||||
{
|
||||
return secs*1000000;
|
||||
}
|
||||
|
||||
static inline nsecs_t microseconds_to_nanoseconds(nsecs_t secs)
|
||||
{
|
||||
return secs*1000;
|
||||
}
|
||||
|
||||
static inline nsecs_t nanoseconds_to_seconds(nsecs_t secs)
|
||||
{
|
||||
return secs/1000000000;
|
||||
}
|
||||
|
||||
static inline nsecs_t nanoseconds_to_milliseconds(nsecs_t secs)
|
||||
{
|
||||
return secs/1000000;
|
||||
}
|
||||
|
||||
static inline nsecs_t nanoseconds_to_microseconds(nsecs_t secs)
|
||||
{
|
||||
return secs/1000;
|
||||
}
|
||||
|
||||
static inline nsecs_t s2ns(nsecs_t v) {return seconds_to_nanoseconds(v);}
|
||||
static inline nsecs_t ms2ns(nsecs_t v) {return milliseconds_to_nanoseconds(v);}
|
||||
static inline nsecs_t us2ns(nsecs_t v) {return microseconds_to_nanoseconds(v);}
|
||||
static inline nsecs_t ns2s(nsecs_t v) {return nanoseconds_to_seconds(v);}
|
||||
static inline nsecs_t ns2ms(nsecs_t v) {return nanoseconds_to_milliseconds(v);}
|
||||
static inline nsecs_t ns2us(nsecs_t v) {return nanoseconds_to_microseconds(v);}
|
||||
|
||||
static inline nsecs_t seconds(nsecs_t v) { return s2ns(v); }
|
||||
static inline nsecs_t milliseconds(nsecs_t v) { return ms2ns(v); }
|
||||
static inline nsecs_t microseconds(nsecs_t v) { return us2ns(v); }
|
||||
|
||||
enum {
|
||||
SYSTEM_TIME_REALTIME = 0, // system-wide realtime clock
|
||||
SYSTEM_TIME_MONOTONIC = 1, // monotonic time since unspecified starting point
|
||||
SYSTEM_TIME_PROCESS = 2, // high-resolution per-process clock
|
||||
SYSTEM_TIME_THREAD = 3 // high-resolution per-thread clock
|
||||
};
|
||||
|
||||
// return the system-time according to the specified clock
|
||||
#ifdef __cplusplus
|
||||
nsecs_t systemTime(int clock = SYSTEM_TIME_MONOTONIC);
|
||||
#else
|
||||
nsecs_t systemTime(int clock);
|
||||
#endif // def __cplusplus
|
||||
|
||||
/**
|
||||
* Returns the number of milliseconds to wait between the reference time and the timeout time.
|
||||
* If the timeout is in the past relative to the reference time, returns 0.
|
||||
* If the timeout is more than INT_MAX milliseconds in the future relative to the reference time,
|
||||
* such as when timeoutTime == LLONG_MAX, returns -1 to indicate an infinite timeout delay.
|
||||
* Otherwise, returns the difference between the reference time and timeout time
|
||||
* rounded up to the next millisecond.
|
||||
*/
|
||||
int toMillisecondTimeoutDelay(nsecs_t referenceTime, nsecs_t timeoutTime);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// C++ API
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace android {
|
||||
/*
|
||||
* Time the duration of something.
|
||||
*
|
||||
* Includes some timeval manipulation functions.
|
||||
*/
|
||||
class DurationTimer {
|
||||
public:
|
||||
DurationTimer() {}
|
||||
~DurationTimer() {}
|
||||
|
||||
// Start the timer.
|
||||
void start();
|
||||
// Stop the timer.
|
||||
void stop();
|
||||
// Get the duration in microseconds.
|
||||
long long durationUsecs() const;
|
||||
|
||||
// Subtract two timevals. Returns the difference (ptv1-ptv2) in
|
||||
// microseconds.
|
||||
static long long subtractTimevals(const struct timeval* ptv1,
|
||||
const struct timeval* ptv2);
|
||||
|
||||
// Add the specified amount of time to the timeval.
|
||||
static void addToTimeval(struct timeval* ptv, long usec);
|
||||
|
||||
private:
|
||||
struct timeval mStartWhen;
|
||||
struct timeval mStopWhen;
|
||||
};
|
||||
|
||||
}; // android
|
||||
#endif // def __cplusplus
|
||||
|
||||
#endif // _LIBS_UTILS_TIMERS_H
|
|
@ -1,246 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_TYPE_HELPERS_H
|
||||
#define ANDROID_TYPE_HELPERS_H
|
||||
|
||||
#include <new>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace android {
|
||||
|
||||
/*
|
||||
* Types traits
|
||||
*/
|
||||
|
||||
template <typename T> struct trait_trivial_ctor { enum { value = false }; };
|
||||
template <typename T> struct trait_trivial_dtor { enum { value = false }; };
|
||||
template <typename T> struct trait_trivial_copy { enum { value = false }; };
|
||||
template <typename T> struct trait_trivial_move { enum { value = false }; };
|
||||
template <typename T> struct trait_pointer { enum { value = false }; };
|
||||
template <typename T> struct trait_pointer<T*> { enum { value = true }; };
|
||||
|
||||
template <typename TYPE>
|
||||
struct traits {
|
||||
enum {
|
||||
// whether this type is a pointer
|
||||
is_pointer = trait_pointer<TYPE>::value,
|
||||
// whether this type's constructor is a no-op
|
||||
has_trivial_ctor = is_pointer || trait_trivial_ctor<TYPE>::value,
|
||||
// whether this type's destructor is a no-op
|
||||
has_trivial_dtor = is_pointer || trait_trivial_dtor<TYPE>::value,
|
||||
// whether this type type can be copy-constructed with memcpy
|
||||
has_trivial_copy = is_pointer || trait_trivial_copy<TYPE>::value,
|
||||
// whether this type can be moved with memmove
|
||||
has_trivial_move = is_pointer || trait_trivial_move<TYPE>::value
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
struct aggregate_traits {
|
||||
enum {
|
||||
is_pointer = false,
|
||||
has_trivial_ctor =
|
||||
traits<T>::has_trivial_ctor && traits<U>::has_trivial_ctor,
|
||||
has_trivial_dtor =
|
||||
traits<T>::has_trivial_dtor && traits<U>::has_trivial_dtor,
|
||||
has_trivial_copy =
|
||||
traits<T>::has_trivial_copy && traits<U>::has_trivial_copy,
|
||||
has_trivial_move =
|
||||
traits<T>::has_trivial_move && traits<U>::has_trivial_move
|
||||
};
|
||||
};
|
||||
|
||||
#define ANDROID_BASIC_TYPES_TRAITS( T ) \
|
||||
template<> struct trait_trivial_ctor< T > { enum { value = true }; }; \
|
||||
template<> struct trait_trivial_dtor< T > { enum { value = true }; }; \
|
||||
template<> struct trait_trivial_copy< T > { enum { value = true }; }; \
|
||||
template<> struct trait_trivial_move< T > { enum { value = true }; };
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* basic types traits
|
||||
*/
|
||||
|
||||
ANDROID_BASIC_TYPES_TRAITS( void )
|
||||
ANDROID_BASIC_TYPES_TRAITS( bool )
|
||||
ANDROID_BASIC_TYPES_TRAITS( char )
|
||||
ANDROID_BASIC_TYPES_TRAITS( unsigned char )
|
||||
ANDROID_BASIC_TYPES_TRAITS( short )
|
||||
ANDROID_BASIC_TYPES_TRAITS( unsigned short )
|
||||
ANDROID_BASIC_TYPES_TRAITS( int )
|
||||
ANDROID_BASIC_TYPES_TRAITS( unsigned int )
|
||||
ANDROID_BASIC_TYPES_TRAITS( long )
|
||||
ANDROID_BASIC_TYPES_TRAITS( unsigned long )
|
||||
ANDROID_BASIC_TYPES_TRAITS( long long )
|
||||
ANDROID_BASIC_TYPES_TRAITS( unsigned long long )
|
||||
ANDROID_BASIC_TYPES_TRAITS( float )
|
||||
ANDROID_BASIC_TYPES_TRAITS( double )
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
/*
|
||||
* compare and order types
|
||||
*/
|
||||
|
||||
template<typename TYPE> inline
|
||||
int strictly_order_type(const TYPE& lhs, const TYPE& rhs) {
|
||||
return (lhs < rhs) ? 1 : 0;
|
||||
}
|
||||
|
||||
template<typename TYPE> inline
|
||||
int compare_type(const TYPE& lhs, const TYPE& rhs) {
|
||||
return strictly_order_type(rhs, lhs) - strictly_order_type(lhs, rhs);
|
||||
}
|
||||
|
||||
/*
|
||||
* create, destroy, copy and move types...
|
||||
*/
|
||||
|
||||
template<typename TYPE> inline
|
||||
void construct_type(TYPE* p, size_t n) {
|
||||
if (!traits<TYPE>::has_trivial_ctor) {
|
||||
while (n--) {
|
||||
new(p++) TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename TYPE> inline
|
||||
void destroy_type(TYPE* p, size_t n) {
|
||||
if (!traits<TYPE>::has_trivial_dtor) {
|
||||
while (n--) {
|
||||
p->~TYPE();
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename TYPE> inline
|
||||
void copy_type(TYPE* d, const TYPE* s, size_t n) {
|
||||
if (!traits<TYPE>::has_trivial_copy) {
|
||||
while (n--) {
|
||||
new(d) TYPE(*s);
|
||||
d++, s++;
|
||||
}
|
||||
} else {
|
||||
memcpy(d,s,n*sizeof(TYPE));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename TYPE> inline
|
||||
void splat_type(TYPE* where, const TYPE* what, size_t n) {
|
||||
if (!traits<TYPE>::has_trivial_copy) {
|
||||
while (n--) {
|
||||
new(where) TYPE(*what);
|
||||
where++;
|
||||
}
|
||||
} else {
|
||||
while (n--) {
|
||||
*where++ = *what;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename TYPE> inline
|
||||
void move_forward_type(TYPE* d, const TYPE* s, size_t n = 1) {
|
||||
if ((traits<TYPE>::has_trivial_dtor && traits<TYPE>::has_trivial_copy)
|
||||
|| traits<TYPE>::has_trivial_move)
|
||||
{
|
||||
memmove(d,s,n*sizeof(TYPE));
|
||||
} else {
|
||||
d += n;
|
||||
s += n;
|
||||
while (n--) {
|
||||
--d, --s;
|
||||
if (!traits<TYPE>::has_trivial_copy) {
|
||||
new(d) TYPE(*s);
|
||||
} else {
|
||||
*d = *s;
|
||||
}
|
||||
if (!traits<TYPE>::has_trivial_dtor) {
|
||||
s->~TYPE();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename TYPE> inline
|
||||
void move_backward_type(TYPE* d, const TYPE* s, size_t n = 1) {
|
||||
if ((traits<TYPE>::has_trivial_dtor && traits<TYPE>::has_trivial_copy)
|
||||
|| traits<TYPE>::has_trivial_move)
|
||||
{
|
||||
memmove(d,s,n*sizeof(TYPE));
|
||||
} else {
|
||||
while (n--) {
|
||||
if (!traits<TYPE>::has_trivial_copy) {
|
||||
new(d) TYPE(*s);
|
||||
} else {
|
||||
*d = *s;
|
||||
}
|
||||
if (!traits<TYPE>::has_trivial_dtor) {
|
||||
s->~TYPE();
|
||||
}
|
||||
d++, s++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* a key/value pair
|
||||
*/
|
||||
|
||||
template <typename KEY, typename VALUE>
|
||||
struct key_value_pair_t {
|
||||
KEY key;
|
||||
VALUE value;
|
||||
key_value_pair_t() { }
|
||||
key_value_pair_t(const key_value_pair_t& o) : key(o.key), value(o.value) { }
|
||||
key_value_pair_t(const KEY& k, const VALUE& v) : key(k), value(v) { }
|
||||
key_value_pair_t(const KEY& k) : key(k) { }
|
||||
inline bool operator < (const key_value_pair_t& o) const {
|
||||
return strictly_order_type(key, o.key);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V>
|
||||
struct trait_trivial_ctor< key_value_pair_t<K, V> >
|
||||
{ enum { value = aggregate_traits<K,V>::has_trivial_ctor }; };
|
||||
template <typename K, typename V>
|
||||
struct trait_trivial_dtor< key_value_pair_t<K, V> >
|
||||
{ enum { value = aggregate_traits<K,V>::has_trivial_dtor }; };
|
||||
template <typename K, typename V>
|
||||
struct trait_trivial_copy< key_value_pair_t<K, V> >
|
||||
{ enum { value = aggregate_traits<K,V>::has_trivial_copy }; };
|
||||
template <typename K, typename V>
|
||||
struct trait_trivial_move< key_value_pair_t<K, V> >
|
||||
{ enum { value = aggregate_traits<K,V>::has_trivial_move }; };
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
}; // namespace android
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_TYPE_HELPERS_H
|
|
@ -1,170 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_UNICODE_H
|
||||
#define ANDROID_UNICODE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
#if !defined(__cplusplus) || __cplusplus == 199711L // C or C++98
|
||||
typedef uint32_t char32_t;
|
||||
typedef uint16_t char16_t;
|
||||
#endif
|
||||
|
||||
// Standard string functions on char16_t strings.
|
||||
int strcmp16(const char16_t *, const char16_t *);
|
||||
int strncmp16(const char16_t *s1, const char16_t *s2, size_t n);
|
||||
size_t strlen16(const char16_t *);
|
||||
size_t strnlen16(const char16_t *, size_t);
|
||||
char16_t *strcpy16(char16_t *, const char16_t *);
|
||||
char16_t *strncpy16(char16_t *, const char16_t *, size_t);
|
||||
|
||||
// Version of comparison that supports embedded nulls.
|
||||
// This is different than strncmp() because we don't stop
|
||||
// at a nul character and consider the strings to be different
|
||||
// if the lengths are different (thus we need to supply the
|
||||
// lengths of both strings). This can also be used when
|
||||
// your string is not nul-terminated as it will have the
|
||||
// equivalent result as strcmp16 (unlike strncmp16).
|
||||
int strzcmp16(const char16_t *s1, size_t n1, const char16_t *s2, size_t n2);
|
||||
|
||||
// Version of strzcmp16 for comparing strings in different endianness.
|
||||
int strzcmp16_h_n(const char16_t *s1H, size_t n1, const char16_t *s2N, size_t n2);
|
||||
|
||||
// Standard string functions on char32_t strings.
|
||||
size_t strlen32(const char32_t *);
|
||||
size_t strnlen32(const char32_t *, size_t);
|
||||
|
||||
/**
|
||||
* Measure the length of a UTF-32 string in UTF-8. If the string is invalid
|
||||
* such as containing a surrogate character, -1 will be returned.
|
||||
*/
|
||||
ssize_t utf32_to_utf8_length(const char32_t *src, size_t src_len);
|
||||
|
||||
/**
|
||||
* Stores a UTF-8 string converted from "src" in "dst", if "dst_length" is not
|
||||
* large enough to store the string, the part of the "src" string is stored
|
||||
* into "dst" as much as possible. See the examples for more detail.
|
||||
* Returns the size actually used for storing the string.
|
||||
* dst" is not null-terminated when dst_len is fully used (like strncpy).
|
||||
*
|
||||
* Example 1
|
||||
* "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84)
|
||||
* "src_len" == 2
|
||||
* "dst_len" >= 7
|
||||
* ->
|
||||
* Returned value == 6
|
||||
* "dst" becomes \xE3\x81\x82\xE3\x81\x84\0
|
||||
* (note that "dst" is null-terminated)
|
||||
*
|
||||
* Example 2
|
||||
* "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84)
|
||||
* "src_len" == 2
|
||||
* "dst_len" == 5
|
||||
* ->
|
||||
* Returned value == 3
|
||||
* "dst" becomes \xE3\x81\x82\0
|
||||
* (note that "dst" is null-terminated, but \u3044 is not stored in "dst"
|
||||
* since "dst" does not have enough size to store the character)
|
||||
*
|
||||
* Example 3
|
||||
* "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84)
|
||||
* "src_len" == 2
|
||||
* "dst_len" == 6
|
||||
* ->
|
||||
* Returned value == 6
|
||||
* "dst" becomes \xE3\x81\x82\xE3\x81\x84
|
||||
* (note that "dst" is NOT null-terminated, like strncpy)
|
||||
*/
|
||||
void utf32_to_utf8(const char32_t* src, size_t src_len, char* dst);
|
||||
|
||||
/**
|
||||
* Returns the unicode value at "index".
|
||||
* Returns -1 when the index is invalid (equals to or more than "src_len").
|
||||
* If returned value is positive, it is able to be converted to char32_t, which
|
||||
* is unsigned. Then, if "next_index" is not NULL, the next index to be used is
|
||||
* stored in "next_index". "next_index" can be NULL.
|
||||
*/
|
||||
int32_t utf32_from_utf8_at(const char *src, size_t src_len, size_t index, size_t *next_index);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the UTF-8 length of UTF-16 string "src".
|
||||
*/
|
||||
ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len);
|
||||
|
||||
/**
|
||||
* Converts a UTF-16 string to UTF-8. The destination buffer must be large
|
||||
* enough to fit the UTF-16 as measured by utf16_to_utf8_length with an added
|
||||
* NULL terminator.
|
||||
*/
|
||||
void utf16_to_utf8(const char16_t* src, size_t src_len, char* dst);
|
||||
|
||||
/**
|
||||
* Returns the length of "src" when "src" is valid UTF-8 string.
|
||||
* Returns 0 if src is NULL or 0-length string. Returns -1 when the source
|
||||
* is an invalid string.
|
||||
*
|
||||
* This function should be used to determine whether "src" is valid UTF-8
|
||||
* characters with valid unicode codepoints. "src" must be null-terminated.
|
||||
*
|
||||
* If you are going to use other utf8_to_... functions defined in this header
|
||||
* with string which may not be valid UTF-8 with valid codepoint (form 0 to
|
||||
* 0x10FFFF), you should use this function before calling others, since the
|
||||
* other functions do not check whether the string is valid UTF-8 or not.
|
||||
*
|
||||
* If you do not care whether "src" is valid UTF-8 or not, you should use
|
||||
* strlen() as usual, which should be much faster.
|
||||
*/
|
||||
ssize_t utf8_length(const char *src);
|
||||
|
||||
/**
|
||||
* Measure the length of a UTF-32 string.
|
||||
*/
|
||||
size_t utf8_to_utf32_length(const char *src, size_t src_len);
|
||||
|
||||
/**
|
||||
* Stores a UTF-32 string converted from "src" in "dst". "dst" must be large
|
||||
* enough to store the entire converted string as measured by
|
||||
* utf8_to_utf32_length plus space for a NULL terminator.
|
||||
*/
|
||||
void utf8_to_utf32(const char* src, size_t src_len, char32_t* dst);
|
||||
|
||||
/**
|
||||
* Returns the UTF-16 length of UTF-8 string "src".
|
||||
*/
|
||||
ssize_t utf8_to_utf16_length(const uint8_t* src, size_t srcLen);
|
||||
|
||||
/**
|
||||
* Convert UTF-8 to UTF-16 including surrogate pairs.
|
||||
* Returns a pointer to the end of the string (where a null terminator might go
|
||||
* if you wanted to add one).
|
||||
*/
|
||||
char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* src, size_t srcLen, char16_t* dst);
|
||||
|
||||
/**
|
||||
* Convert UTF-8 to UTF-16 including surrogate pairs. The destination buffer
|
||||
* must be large enough to hold the result as measured by utf8_to_utf16_length
|
||||
* plus an added NULL terminator.
|
||||
*/
|
||||
void utf8_to_utf16(const uint8_t* src, size_t srcLen, char16_t* dst);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,424 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_VECTOR_H
|
||||
#define ANDROID_VECTOR_H
|
||||
|
||||
#include <new>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <cutils/log.h>
|
||||
|
||||
#include <utils/VectorImpl.h>
|
||||
#include <utils/TypeHelpers.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace android {
|
||||
|
||||
template <typename TYPE>
|
||||
class SortedVector;
|
||||
|
||||
/*!
|
||||
* The main templated vector class ensuring type safety
|
||||
* while making use of VectorImpl.
|
||||
* This is the class users want to use.
|
||||
*/
|
||||
|
||||
template <class TYPE>
|
||||
class Vector : private VectorImpl
|
||||
{
|
||||
public:
|
||||
typedef TYPE value_type;
|
||||
|
||||
/*!
|
||||
* Constructors and destructors
|
||||
*/
|
||||
|
||||
Vector();
|
||||
Vector(const Vector<TYPE>& rhs);
|
||||
explicit Vector(const SortedVector<TYPE>& rhs);
|
||||
virtual ~Vector();
|
||||
|
||||
/*! copy operator */
|
||||
const Vector<TYPE>& operator = (const Vector<TYPE>& rhs) const;
|
||||
Vector<TYPE>& operator = (const Vector<TYPE>& rhs);
|
||||
|
||||
const Vector<TYPE>& operator = (const SortedVector<TYPE>& rhs) const;
|
||||
Vector<TYPE>& operator = (const SortedVector<TYPE>& rhs);
|
||||
|
||||
/*
|
||||
* empty the vector
|
||||
*/
|
||||
|
||||
inline void clear() { VectorImpl::clear(); }
|
||||
|
||||
/*!
|
||||
* vector stats
|
||||
*/
|
||||
|
||||
//! returns number of items in the vector
|
||||
inline size_t size() const { return VectorImpl::size(); }
|
||||
//! returns whether or not the vector is empty
|
||||
inline bool isEmpty() const { return VectorImpl::isEmpty(); }
|
||||
//! returns how many items can be stored without reallocating the backing store
|
||||
inline size_t capacity() const { return VectorImpl::capacity(); }
|
||||
//! sets the capacity. capacity can never be reduced less than size()
|
||||
inline ssize_t setCapacity(size_t size) { return VectorImpl::setCapacity(size); }
|
||||
|
||||
/*!
|
||||
* set the size of the vector. items are appended with the default
|
||||
* constructor, or removed from the end as needed.
|
||||
*/
|
||||
inline ssize_t resize(size_t size) { return VectorImpl::resize(size); }
|
||||
|
||||
/*!
|
||||
* C-style array access
|
||||
*/
|
||||
|
||||
//! read-only C-style access
|
||||
inline const TYPE* array() const;
|
||||
//! read-write C-style access
|
||||
TYPE* editArray();
|
||||
|
||||
/*!
|
||||
* accessors
|
||||
*/
|
||||
|
||||
//! read-only access to an item at a given index
|
||||
inline const TYPE& operator [] (size_t index) const;
|
||||
//! alternate name for operator []
|
||||
inline const TYPE& itemAt(size_t index) const;
|
||||
//! stack-usage of the vector. returns the top of the stack (last element)
|
||||
const TYPE& top() const;
|
||||
|
||||
/*!
|
||||
* modifying the array
|
||||
*/
|
||||
|
||||
//! copy-on write support, grants write access to an item
|
||||
TYPE& editItemAt(size_t index);
|
||||
//! grants right access to the top of the stack (last element)
|
||||
TYPE& editTop();
|
||||
|
||||
/*!
|
||||
* append/insert another vector
|
||||
*/
|
||||
|
||||
//! insert another vector at a given index
|
||||
ssize_t insertVectorAt(const Vector<TYPE>& vector, size_t index);
|
||||
|
||||
//! append another vector at the end of this one
|
||||
ssize_t appendVector(const Vector<TYPE>& vector);
|
||||
|
||||
|
||||
//! insert an array at a given index
|
||||
ssize_t insertArrayAt(const TYPE* array, size_t index, size_t length);
|
||||
|
||||
//! append an array at the end of this vector
|
||||
ssize_t appendArray(const TYPE* array, size_t length);
|
||||
|
||||
/*!
|
||||
* add/insert/replace items
|
||||
*/
|
||||
|
||||
//! insert one or several items initialized with their default constructor
|
||||
inline ssize_t insertAt(size_t index, size_t numItems = 1);
|
||||
//! insert one or several items initialized from a prototype item
|
||||
ssize_t insertAt(const TYPE& prototype_item, size_t index, size_t numItems = 1);
|
||||
//! pop the top of the stack (removes the last element). No-op if the stack's empty
|
||||
inline void pop();
|
||||
//! pushes an item initialized with its default constructor
|
||||
inline void push();
|
||||
//! pushes an item on the top of the stack
|
||||
void push(const TYPE& item);
|
||||
//! same as push() but returns the index the item was added at (or an error)
|
||||
inline ssize_t add();
|
||||
//! same as push() but returns the index the item was added at (or an error)
|
||||
ssize_t add(const TYPE& item);
|
||||
//! replace an item with a new one initialized with its default constructor
|
||||
inline ssize_t replaceAt(size_t index);
|
||||
//! replace an item with a new one
|
||||
ssize_t replaceAt(const TYPE& item, size_t index);
|
||||
|
||||
/*!
|
||||
* remove items
|
||||
*/
|
||||
|
||||
//! remove several items
|
||||
inline ssize_t removeItemsAt(size_t index, size_t count = 1);
|
||||
//! remove one item
|
||||
inline ssize_t removeAt(size_t index) { return removeItemsAt(index); }
|
||||
|
||||
/*!
|
||||
* sort (stable) the array
|
||||
*/
|
||||
|
||||
typedef int (*compar_t)(const TYPE* lhs, const TYPE* rhs);
|
||||
typedef int (*compar_r_t)(const TYPE* lhs, const TYPE* rhs, void* state);
|
||||
|
||||
inline status_t sort(compar_t cmp);
|
||||
inline status_t sort(compar_r_t cmp, void* state);
|
||||
|
||||
// for debugging only
|
||||
inline size_t getItemSize() const { return itemSize(); }
|
||||
|
||||
|
||||
/*
|
||||
* these inlines add some level of compatibility with STL. eventually
|
||||
* we should probably turn things around.
|
||||
*/
|
||||
typedef TYPE* iterator;
|
||||
typedef TYPE const* const_iterator;
|
||||
|
||||
inline iterator begin() { return editArray(); }
|
||||
inline iterator end() { return editArray() + size(); }
|
||||
inline const_iterator begin() const { return array(); }
|
||||
inline const_iterator end() const { return array() + size(); }
|
||||
inline void reserve(size_t n) { setCapacity(n); }
|
||||
inline bool empty() const{ return isEmpty(); }
|
||||
inline void push_back(const TYPE& item) { insertAt(item, size(), 1); }
|
||||
inline void push_front(const TYPE& item) { insertAt(item, 0, 1); }
|
||||
inline iterator erase(iterator pos) {
|
||||
ssize_t index = removeItemsAt(pos-array());
|
||||
return begin() + index;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void do_construct(void* storage, size_t num) const;
|
||||
virtual void do_destroy(void* storage, size_t num) const;
|
||||
virtual void do_copy(void* dest, const void* from, size_t num) const;
|
||||
virtual void do_splat(void* dest, const void* item, size_t num) const;
|
||||
virtual void do_move_forward(void* dest, const void* from, size_t num) const;
|
||||
virtual void do_move_backward(void* dest, const void* from, size_t num) const;
|
||||
};
|
||||
|
||||
// Vector<T> can be trivially moved using memcpy() because moving does not
|
||||
// require any change to the underlying SharedBuffer contents or reference count.
|
||||
template<typename T> struct trait_trivial_move<Vector<T> > { enum { value = true }; };
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// No user serviceable parts from here...
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template<class TYPE> inline
|
||||
Vector<TYPE>::Vector()
|
||||
: VectorImpl(sizeof(TYPE),
|
||||
((traits<TYPE>::has_trivial_ctor ? HAS_TRIVIAL_CTOR : 0)
|
||||
|(traits<TYPE>::has_trivial_dtor ? HAS_TRIVIAL_DTOR : 0)
|
||||
|(traits<TYPE>::has_trivial_copy ? HAS_TRIVIAL_COPY : 0))
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
Vector<TYPE>::Vector(const Vector<TYPE>& rhs)
|
||||
: VectorImpl(rhs) {
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
Vector<TYPE>::Vector(const SortedVector<TYPE>& rhs)
|
||||
: VectorImpl(static_cast<const VectorImpl&>(rhs)) {
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
Vector<TYPE>::~Vector() {
|
||||
finish_vector();
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) {
|
||||
VectorImpl::operator = (rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
const Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) const {
|
||||
VectorImpl::operator = (static_cast<const VectorImpl&>(rhs));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
Vector<TYPE>& Vector<TYPE>::operator = (const SortedVector<TYPE>& rhs) {
|
||||
VectorImpl::operator = (static_cast<const VectorImpl&>(rhs));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
const Vector<TYPE>& Vector<TYPE>::operator = (const SortedVector<TYPE>& rhs) const {
|
||||
VectorImpl::operator = (rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
const TYPE* Vector<TYPE>::array() const {
|
||||
return static_cast<const TYPE *>(arrayImpl());
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
TYPE* Vector<TYPE>::editArray() {
|
||||
return static_cast<TYPE *>(editArrayImpl());
|
||||
}
|
||||
|
||||
|
||||
template<class TYPE> inline
|
||||
const TYPE& Vector<TYPE>::operator[](size_t index) const {
|
||||
LOG_FATAL_IF(index>=size(),
|
||||
"%s: index=%u out of range (%u)", __PRETTY_FUNCTION__,
|
||||
int(index), int(size()));
|
||||
return *(array() + index);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
const TYPE& Vector<TYPE>::itemAt(size_t index) const {
|
||||
return operator[](index);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
const TYPE& Vector<TYPE>::top() const {
|
||||
return *(array() + size() - 1);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
TYPE& Vector<TYPE>::editItemAt(size_t index) {
|
||||
return *( static_cast<TYPE *>(editItemLocation(index)) );
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
TYPE& Vector<TYPE>::editTop() {
|
||||
return *( static_cast<TYPE *>(editItemLocation(size()-1)) );
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t Vector<TYPE>::insertVectorAt(const Vector<TYPE>& vector, size_t index) {
|
||||
return VectorImpl::insertVectorAt(reinterpret_cast<const VectorImpl&>(vector), index);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t Vector<TYPE>::appendVector(const Vector<TYPE>& vector) {
|
||||
return VectorImpl::appendVector(reinterpret_cast<const VectorImpl&>(vector));
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t Vector<TYPE>::insertArrayAt(const TYPE* array, size_t index, size_t length) {
|
||||
return VectorImpl::insertArrayAt(array, index, length);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t Vector<TYPE>::appendArray(const TYPE* array, size_t length) {
|
||||
return VectorImpl::appendArray(array, length);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t Vector<TYPE>::insertAt(const TYPE& item, size_t index, size_t numItems) {
|
||||
return VectorImpl::insertAt(&item, index, numItems);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
void Vector<TYPE>::push(const TYPE& item) {
|
||||
return VectorImpl::push(&item);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t Vector<TYPE>::add(const TYPE& item) {
|
||||
return VectorImpl::add(&item);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t Vector<TYPE>::replaceAt(const TYPE& item, size_t index) {
|
||||
return VectorImpl::replaceAt(&item, index);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t Vector<TYPE>::insertAt(size_t index, size_t numItems) {
|
||||
return VectorImpl::insertAt(index, numItems);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
void Vector<TYPE>::pop() {
|
||||
VectorImpl::pop();
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
void Vector<TYPE>::push() {
|
||||
VectorImpl::push();
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t Vector<TYPE>::add() {
|
||||
return VectorImpl::add();
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t Vector<TYPE>::replaceAt(size_t index) {
|
||||
return VectorImpl::replaceAt(index);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
ssize_t Vector<TYPE>::removeItemsAt(size_t index, size_t count) {
|
||||
return VectorImpl::removeItemsAt(index, count);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
status_t Vector<TYPE>::sort(Vector<TYPE>::compar_t cmp) {
|
||||
return VectorImpl::sort((VectorImpl::compar_t)cmp);
|
||||
}
|
||||
|
||||
template<class TYPE> inline
|
||||
status_t Vector<TYPE>::sort(Vector<TYPE>::compar_r_t cmp, void* state) {
|
||||
return VectorImpl::sort((VectorImpl::compar_r_t)cmp, state);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template<class TYPE>
|
||||
void Vector<TYPE>::do_construct(void* storage, size_t num) const {
|
||||
construct_type( reinterpret_cast<TYPE*>(storage), num );
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void Vector<TYPE>::do_destroy(void* storage, size_t num) const {
|
||||
destroy_type( reinterpret_cast<TYPE*>(storage), num );
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void Vector<TYPE>::do_copy(void* dest, const void* from, size_t num) const {
|
||||
copy_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void Vector<TYPE>::do_splat(void* dest, const void* item, size_t num) const {
|
||||
splat_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(item), num );
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void Vector<TYPE>::do_move_forward(void* dest, const void* from, size_t num) const {
|
||||
move_forward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
void Vector<TYPE>::do_move_backward(void* dest, const void* from, size_t num) const {
|
||||
move_backward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
|
||||
}
|
||||
|
||||
}; // namespace android
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_VECTOR_H
|
||||
|
|
@ -1,184 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2005 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 ANDROID_VECTOR_IMPL_H
|
||||
#define ANDROID_VECTOR_IMPL_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <utils/Errors.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// No user serviceable parts in here...
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace android {
|
||||
|
||||
/*!
|
||||
* Implementation of the guts of the vector<> class
|
||||
* this ensures backward binary compatibility and
|
||||
* reduces code size.
|
||||
* For performance reasons, we expose mStorage and mCount
|
||||
* so these fields are set in stone.
|
||||
*
|
||||
*/
|
||||
|
||||
class VectorImpl
|
||||
{
|
||||
public:
|
||||
enum { // flags passed to the ctor
|
||||
HAS_TRIVIAL_CTOR = 0x00000001,
|
||||
HAS_TRIVIAL_DTOR = 0x00000002,
|
||||
HAS_TRIVIAL_COPY = 0x00000004,
|
||||
};
|
||||
|
||||
VectorImpl(size_t itemSize, uint32_t flags);
|
||||
VectorImpl(const VectorImpl& rhs);
|
||||
virtual ~VectorImpl();
|
||||
|
||||
/*! must be called from subclasses destructor */
|
||||
void finish_vector();
|
||||
|
||||
VectorImpl& operator = (const VectorImpl& rhs);
|
||||
|
||||
/*! C-style array access */
|
||||
inline const void* arrayImpl() const { return mStorage; }
|
||||
void* editArrayImpl();
|
||||
|
||||
/*! vector stats */
|
||||
inline size_t size() const { return mCount; }
|
||||
inline bool isEmpty() const { return mCount == 0; }
|
||||
size_t capacity() const;
|
||||
ssize_t setCapacity(size_t size);
|
||||
ssize_t resize(size_t size);
|
||||
|
||||
/*! append/insert another vector or array */
|
||||
ssize_t insertVectorAt(const VectorImpl& vector, size_t index);
|
||||
ssize_t appendVector(const VectorImpl& vector);
|
||||
ssize_t insertArrayAt(const void* array, size_t index, size_t length);
|
||||
ssize_t appendArray(const void* array, size_t length);
|
||||
|
||||
/*! add/insert/replace items */
|
||||
ssize_t insertAt(size_t where, size_t numItems = 1);
|
||||
ssize_t insertAt(const void* item, size_t where, size_t numItems = 1);
|
||||
void pop();
|
||||
void push();
|
||||
void push(const void* item);
|
||||
ssize_t add();
|
||||
ssize_t add(const void* item);
|
||||
ssize_t replaceAt(size_t index);
|
||||
ssize_t replaceAt(const void* item, size_t index);
|
||||
|
||||
/*! remove items */
|
||||
ssize_t removeItemsAt(size_t index, size_t count = 1);
|
||||
void clear();
|
||||
|
||||
const void* itemLocation(size_t index) const;
|
||||
void* editItemLocation(size_t index);
|
||||
|
||||
typedef int (*compar_t)(const void* lhs, const void* rhs);
|
||||
typedef int (*compar_r_t)(const void* lhs, const void* rhs, void* state);
|
||||
status_t sort(compar_t cmp);
|
||||
status_t sort(compar_r_t cmp, void* state);
|
||||
|
||||
protected:
|
||||
size_t itemSize() const;
|
||||
void release_storage();
|
||||
|
||||
virtual void do_construct(void* storage, size_t num) const = 0;
|
||||
virtual void do_destroy(void* storage, size_t num) const = 0;
|
||||
virtual void do_copy(void* dest, const void* from, size_t num) const = 0;
|
||||
virtual void do_splat(void* dest, const void* item, size_t num) const = 0;
|
||||
virtual void do_move_forward(void* dest, const void* from, size_t num) const = 0;
|
||||
virtual void do_move_backward(void* dest, const void* from, size_t num) const = 0;
|
||||
|
||||
private:
|
||||
void* _grow(size_t where, size_t amount);
|
||||
void _shrink(size_t where, size_t amount);
|
||||
|
||||
inline void _do_construct(void* storage, size_t num) const;
|
||||
inline void _do_destroy(void* storage, size_t num) const;
|
||||
inline void _do_copy(void* dest, const void* from, size_t num) const;
|
||||
inline void _do_splat(void* dest, const void* item, size_t num) const;
|
||||
inline void _do_move_forward(void* dest, const void* from, size_t num) const;
|
||||
inline void _do_move_backward(void* dest, const void* from, size_t num) const;
|
||||
|
||||
// These 2 fields are exposed in the inlines below,
|
||||
// so they're set in stone.
|
||||
void * mStorage; // base address of the vector
|
||||
size_t mCount; // number of items
|
||||
|
||||
const uint32_t mFlags;
|
||||
const size_t mItemSize;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class SortedVectorImpl : public VectorImpl
|
||||
{
|
||||
public:
|
||||
SortedVectorImpl(size_t itemSize, uint32_t flags);
|
||||
SortedVectorImpl(const VectorImpl& rhs);
|
||||
virtual ~SortedVectorImpl();
|
||||
|
||||
SortedVectorImpl& operator = (const SortedVectorImpl& rhs);
|
||||
|
||||
//! finds the index of an item
|
||||
ssize_t indexOf(const void* item) const;
|
||||
|
||||
//! finds where this item should be inserted
|
||||
size_t orderOf(const void* item) const;
|
||||
|
||||
//! add an item in the right place (or replaces it if there is one)
|
||||
ssize_t add(const void* item);
|
||||
|
||||
//! merges a vector into this one
|
||||
ssize_t merge(const VectorImpl& vector);
|
||||
ssize_t merge(const SortedVectorImpl& vector);
|
||||
|
||||
//! removes an item
|
||||
ssize_t remove(const void* item);
|
||||
|
||||
protected:
|
||||
virtual int do_compare(const void* lhs, const void* rhs) const = 0;
|
||||
|
||||
private:
|
||||
ssize_t _indexOrderOf(const void* item, size_t* order = 0) const;
|
||||
|
||||
// these are made private, because they can't be used on a SortedVector
|
||||
// (they don't have an implementation either)
|
||||
ssize_t add();
|
||||
void pop();
|
||||
void push();
|
||||
void push(const void* item);
|
||||
ssize_t insertVectorAt(const VectorImpl& vector, size_t index);
|
||||
ssize_t appendVector(const VectorImpl& vector);
|
||||
ssize_t insertArrayAt(const void* array, size_t index, size_t length);
|
||||
ssize_t appendArray(const void* array, size_t length);
|
||||
ssize_t insertAt(size_t where, size_t numItems = 1);
|
||||
ssize_t insertAt(const void* item, size_t where, size_t numItems = 1);
|
||||
ssize_t replaceAt(size_t index);
|
||||
ssize_t replaceAt(const void* item, size_t index);
|
||||
};
|
||||
|
||||
}; // namespace android
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#endif // ANDROID_VECTOR_IMPL_H
|
||||
|
|
@ -1,564 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007 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 _LIBS_UTILS_THREADS_H
|
||||
#define _LIBS_UTILS_THREADS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <system/graphics.h>
|
||||
|
||||
#if defined(HAVE_PTHREADS)
|
||||
# include <pthread.h>
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// C API
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void* android_thread_id_t;
|
||||
|
||||
typedef int (*android_thread_func_t)(void*);
|
||||
|
||||
enum {
|
||||
/*
|
||||
* ***********************************************
|
||||
* ** Keep in sync with android.os.Process.java **
|
||||
* ***********************************************
|
||||
*
|
||||
* This maps directly to the "nice" priorities we use in Android.
|
||||
* A thread priority should be chosen inverse-proportionally to
|
||||
* the amount of work the thread is expected to do. The more work
|
||||
* a thread will do, the less favorable priority it should get so that
|
||||
* it doesn't starve the system. Threads not behaving properly might
|
||||
* be "punished" by the kernel.
|
||||
* Use the levels below when appropriate. Intermediate values are
|
||||
* acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below.
|
||||
*/
|
||||
ANDROID_PRIORITY_LOWEST = 19,
|
||||
|
||||
/* use for background tasks */
|
||||
ANDROID_PRIORITY_BACKGROUND = 10,
|
||||
|
||||
/* most threads run at normal priority */
|
||||
ANDROID_PRIORITY_NORMAL = 0,
|
||||
|
||||
/* threads currently running a UI that the user is interacting with */
|
||||
ANDROID_PRIORITY_FOREGROUND = -2,
|
||||
|
||||
/* the main UI thread has a slightly more favorable priority */
|
||||
ANDROID_PRIORITY_DISPLAY = -4,
|
||||
|
||||
/* ui service treads might want to run at a urgent display (uncommon) */
|
||||
ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY,
|
||||
|
||||
/* all normal audio threads */
|
||||
ANDROID_PRIORITY_AUDIO = -16,
|
||||
|
||||
/* service audio threads (uncommon) */
|
||||
ANDROID_PRIORITY_URGENT_AUDIO = -19,
|
||||
|
||||
/* should never be used in practice. regular process might not
|
||||
* be allowed to use this level */
|
||||
ANDROID_PRIORITY_HIGHEST = -20,
|
||||
|
||||
ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL,
|
||||
ANDROID_PRIORITY_MORE_FAVORABLE = -1,
|
||||
ANDROID_PRIORITY_LESS_FAVORABLE = +1,
|
||||
};
|
||||
|
||||
enum {
|
||||
ANDROID_TGROUP_DEFAULT = 0,
|
||||
ANDROID_TGROUP_BG_NONINTERACT = 1,
|
||||
ANDROID_TGROUP_FG_BOOST = 2,
|
||||
ANDROID_TGROUP_MAX = ANDROID_TGROUP_FG_BOOST,
|
||||
};
|
||||
|
||||
// Create and run a new thread.
|
||||
extern int androidCreateThread(android_thread_func_t, void *);
|
||||
|
||||
// Create thread with lots of parameters
|
||||
extern int androidCreateThreadEtc(android_thread_func_t entryFunction,
|
||||
void *userData,
|
||||
const char* threadName,
|
||||
int32_t threadPriority,
|
||||
size_t threadStackSize,
|
||||
android_thread_id_t *threadId);
|
||||
|
||||
// Get some sort of unique identifier for the current thread.
|
||||
extern android_thread_id_t androidGetThreadId();
|
||||
|
||||
// Low-level thread creation -- never creates threads that can
|
||||
// interact with the Java VM.
|
||||
extern int androidCreateRawThreadEtc(android_thread_func_t entryFunction,
|
||||
void *userData,
|
||||
const char* threadName,
|
||||
int32_t threadPriority,
|
||||
size_t threadStackSize,
|
||||
android_thread_id_t *threadId);
|
||||
|
||||
// Used by the Java Runtime to control how threads are created, so that
|
||||
// they can be proper and lovely Java threads.
|
||||
typedef int (*android_create_thread_fn)(android_thread_func_t entryFunction,
|
||||
void *userData,
|
||||
const char* threadName,
|
||||
int32_t threadPriority,
|
||||
size_t threadStackSize,
|
||||
android_thread_id_t *threadId);
|
||||
|
||||
extern void androidSetCreateThreadFunc(android_create_thread_fn func);
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Extra functions working with raw pids.
|
||||
|
||||
// Get pid for the current thread.
|
||||
extern pid_t androidGetTid();
|
||||
|
||||
// Change the scheduling group of a particular thread. The group
|
||||
// should be one of the ANDROID_TGROUP constants. Returns BAD_VALUE if
|
||||
// grp is out of range, else another non-zero value with errno set if
|
||||
// the operation failed. Thread ID zero means current thread.
|
||||
extern int androidSetThreadSchedulingGroup(pid_t tid, int grp);
|
||||
|
||||
// Change the priority AND scheduling group of a particular thread. The priority
|
||||
// should be one of the ANDROID_PRIORITY constants. Returns INVALID_OPERATION
|
||||
// if the priority set failed, else another value if just the group set failed;
|
||||
// in either case errno is set. Thread ID zero means current thread.
|
||||
extern int androidSetThreadPriority(pid_t tid, int prio);
|
||||
|
||||
// Get the current priority of a particular thread. Returns one of the
|
||||
// ANDROID_PRIORITY constants or a negative result in case of error.
|
||||
extern int androidGetThreadPriority(pid_t tid);
|
||||
|
||||
// Get the current scheduling group of a particular thread. Normally returns
|
||||
// one of the ANDROID_TGROUP constants other than ANDROID_TGROUP_DEFAULT.
|
||||
// Returns ANDROID_TGROUP_DEFAULT if no pthread support (e.g. on host) or if
|
||||
// scheduling groups are disabled. Returns INVALID_OPERATION if unexpected error.
|
||||
// Thread ID zero means current thread.
|
||||
extern int androidGetThreadSchedulingGroup(pid_t tid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// C++ API
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <utils/Errors.h>
|
||||
#include <utils/RefBase.h>
|
||||
#include <utils/Timers.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
typedef android_thread_id_t thread_id_t;
|
||||
|
||||
typedef android_thread_func_t thread_func_t;
|
||||
|
||||
enum {
|
||||
PRIORITY_LOWEST = ANDROID_PRIORITY_LOWEST,
|
||||
PRIORITY_BACKGROUND = ANDROID_PRIORITY_BACKGROUND,
|
||||
PRIORITY_NORMAL = ANDROID_PRIORITY_NORMAL,
|
||||
PRIORITY_FOREGROUND = ANDROID_PRIORITY_FOREGROUND,
|
||||
PRIORITY_DISPLAY = ANDROID_PRIORITY_DISPLAY,
|
||||
PRIORITY_URGENT_DISPLAY = ANDROID_PRIORITY_URGENT_DISPLAY,
|
||||
PRIORITY_AUDIO = ANDROID_PRIORITY_AUDIO,
|
||||
PRIORITY_URGENT_AUDIO = ANDROID_PRIORITY_URGENT_AUDIO,
|
||||
PRIORITY_HIGHEST = ANDROID_PRIORITY_HIGHEST,
|
||||
PRIORITY_DEFAULT = ANDROID_PRIORITY_DEFAULT,
|
||||
PRIORITY_MORE_FAVORABLE = ANDROID_PRIORITY_MORE_FAVORABLE,
|
||||
PRIORITY_LESS_FAVORABLE = ANDROID_PRIORITY_LESS_FAVORABLE,
|
||||
};
|
||||
|
||||
// Create and run a new thread.
|
||||
inline bool createThread(thread_func_t f, void *a) {
|
||||
return androidCreateThread(f, a) ? true : false;
|
||||
}
|
||||
|
||||
// Create thread with lots of parameters
|
||||
inline bool createThreadEtc(thread_func_t entryFunction,
|
||||
void *userData,
|
||||
const char* threadName = "android:unnamed_thread",
|
||||
int32_t threadPriority = PRIORITY_DEFAULT,
|
||||
size_t threadStackSize = 0,
|
||||
thread_id_t *threadId = 0)
|
||||
{
|
||||
return androidCreateThreadEtc(entryFunction, userData, threadName,
|
||||
threadPriority, threadStackSize, threadId) ? true : false;
|
||||
}
|
||||
|
||||
// Get some sort of unique identifier for the current thread.
|
||||
inline thread_id_t getThreadId() {
|
||||
return androidGetThreadId();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* Simple mutex class. The implementation is system-dependent.
|
||||
*
|
||||
* The mutex must be unlocked by the thread that locked it. They are not
|
||||
* recursive, i.e. the same thread can't lock it multiple times.
|
||||
*/
|
||||
class Mutex {
|
||||
public:
|
||||
enum {
|
||||
PRIVATE = 0,
|
||||
SHARED = 1
|
||||
};
|
||||
|
||||
Mutex();
|
||||
Mutex(const char* name);
|
||||
Mutex(int type, const char* name = NULL);
|
||||
~Mutex();
|
||||
|
||||
// lock or unlock the mutex
|
||||
status_t lock();
|
||||
void unlock();
|
||||
|
||||
// lock if possible; returns 0 on success, error otherwise
|
||||
status_t tryLock();
|
||||
|
||||
// Manages the mutex automatically. It'll be locked when Autolock is
|
||||
// constructed and released when Autolock goes out of scope.
|
||||
class Autolock {
|
||||
public:
|
||||
inline Autolock(Mutex& mutex) : mLock(mutex) { mLock.lock(); }
|
||||
inline Autolock(Mutex* mutex) : mLock(*mutex) { mLock.lock(); }
|
||||
inline ~Autolock() { mLock.unlock(); }
|
||||
private:
|
||||
Mutex& mLock;
|
||||
};
|
||||
|
||||
private:
|
||||
friend class Condition;
|
||||
|
||||
// A mutex cannot be copied
|
||||
Mutex(const Mutex&);
|
||||
Mutex& operator = (const Mutex&);
|
||||
|
||||
#if defined(HAVE_PTHREADS)
|
||||
pthread_mutex_t mMutex;
|
||||
#else
|
||||
void _init();
|
||||
void* mState;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(HAVE_PTHREADS)
|
||||
|
||||
inline Mutex::Mutex() {
|
||||
pthread_mutex_init(&mMutex, NULL);
|
||||
}
|
||||
inline Mutex::Mutex(const char* name) {
|
||||
pthread_mutex_init(&mMutex, NULL);
|
||||
}
|
||||
inline Mutex::Mutex(int type, const char* name) {
|
||||
if (type == SHARED) {
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
|
||||
pthread_mutex_init(&mMutex, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
} else {
|
||||
pthread_mutex_init(&mMutex, NULL);
|
||||
}
|
||||
}
|
||||
inline Mutex::~Mutex() {
|
||||
pthread_mutex_destroy(&mMutex);
|
||||
}
|
||||
inline status_t Mutex::lock() {
|
||||
return -pthread_mutex_lock(&mMutex);
|
||||
}
|
||||
inline void Mutex::unlock() {
|
||||
pthread_mutex_unlock(&mMutex);
|
||||
}
|
||||
inline status_t Mutex::tryLock() {
|
||||
return -pthread_mutex_trylock(&mMutex);
|
||||
}
|
||||
|
||||
#endif // HAVE_PTHREADS
|
||||
|
||||
/*
|
||||
* Automatic mutex. Declare one of these at the top of a function.
|
||||
* When the function returns, it will go out of scope, and release the
|
||||
* mutex.
|
||||
*/
|
||||
|
||||
typedef Mutex::Autolock AutoMutex;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#if defined(HAVE_PTHREADS)
|
||||
|
||||
/*
|
||||
* Simple mutex class. The implementation is system-dependent.
|
||||
*
|
||||
* The mutex must be unlocked by the thread that locked it. They are not
|
||||
* recursive, i.e. the same thread can't lock it multiple times.
|
||||
*/
|
||||
class RWLock {
|
||||
public:
|
||||
enum {
|
||||
PRIVATE = 0,
|
||||
SHARED = 1
|
||||
};
|
||||
|
||||
RWLock();
|
||||
RWLock(const char* name);
|
||||
RWLock(int type, const char* name = NULL);
|
||||
~RWLock();
|
||||
|
||||
status_t readLock();
|
||||
status_t tryReadLock();
|
||||
status_t writeLock();
|
||||
status_t tryWriteLock();
|
||||
void unlock();
|
||||
|
||||
class AutoRLock {
|
||||
public:
|
||||
inline AutoRLock(RWLock& rwlock) : mLock(rwlock) { mLock.readLock(); }
|
||||
inline ~AutoRLock() { mLock.unlock(); }
|
||||
private:
|
||||
RWLock& mLock;
|
||||
};
|
||||
|
||||
class AutoWLock {
|
||||
public:
|
||||
inline AutoWLock(RWLock& rwlock) : mLock(rwlock) { mLock.writeLock(); }
|
||||
inline ~AutoWLock() { mLock.unlock(); }
|
||||
private:
|
||||
RWLock& mLock;
|
||||
};
|
||||
|
||||
private:
|
||||
// A RWLock cannot be copied
|
||||
RWLock(const RWLock&);
|
||||
RWLock& operator = (const RWLock&);
|
||||
|
||||
pthread_rwlock_t mRWLock;
|
||||
};
|
||||
|
||||
inline RWLock::RWLock() {
|
||||
pthread_rwlock_init(&mRWLock, NULL);
|
||||
}
|
||||
inline RWLock::RWLock(const char* name) {
|
||||
pthread_rwlock_init(&mRWLock, NULL);
|
||||
}
|
||||
inline RWLock::RWLock(int type, const char* name) {
|
||||
if (type == SHARED) {
|
||||
pthread_rwlockattr_t attr;
|
||||
pthread_rwlockattr_init(&attr);
|
||||
pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
|
||||
pthread_rwlock_init(&mRWLock, &attr);
|
||||
pthread_rwlockattr_destroy(&attr);
|
||||
} else {
|
||||
pthread_rwlock_init(&mRWLock, NULL);
|
||||
}
|
||||
}
|
||||
inline RWLock::~RWLock() {
|
||||
pthread_rwlock_destroy(&mRWLock);
|
||||
}
|
||||
inline status_t RWLock::readLock() {
|
||||
return -pthread_rwlock_rdlock(&mRWLock);
|
||||
}
|
||||
inline status_t RWLock::tryReadLock() {
|
||||
return -pthread_rwlock_tryrdlock(&mRWLock);
|
||||
}
|
||||
inline status_t RWLock::writeLock() {
|
||||
return -pthread_rwlock_wrlock(&mRWLock);
|
||||
}
|
||||
inline status_t RWLock::tryWriteLock() {
|
||||
return -pthread_rwlock_trywrlock(&mRWLock);
|
||||
}
|
||||
inline void RWLock::unlock() {
|
||||
pthread_rwlock_unlock(&mRWLock);
|
||||
}
|
||||
|
||||
#endif // HAVE_PTHREADS
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* Condition variable class. The implementation is system-dependent.
|
||||
*
|
||||
* Condition variables are paired up with mutexes. Lock the mutex,
|
||||
* call wait(), then either re-wait() if things aren't quite what you want,
|
||||
* or unlock the mutex and continue. All threads calling wait() must
|
||||
* use the same mutex for a given Condition.
|
||||
*/
|
||||
class Condition {
|
||||
public:
|
||||
enum {
|
||||
PRIVATE = 0,
|
||||
SHARED = 1
|
||||
};
|
||||
|
||||
Condition();
|
||||
Condition(int type);
|
||||
~Condition();
|
||||
// Wait on the condition variable. Lock the mutex before calling.
|
||||
status_t wait(Mutex& mutex);
|
||||
// same with relative timeout
|
||||
status_t waitRelative(Mutex& mutex, nsecs_t reltime);
|
||||
// Signal the condition variable, allowing one thread to continue.
|
||||
void signal();
|
||||
// Signal the condition variable, allowing all threads to continue.
|
||||
void broadcast();
|
||||
|
||||
private:
|
||||
#if defined(HAVE_PTHREADS)
|
||||
pthread_cond_t mCond;
|
||||
#else
|
||||
void* mState;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(HAVE_PTHREADS)
|
||||
|
||||
inline Condition::Condition() {
|
||||
pthread_cond_init(&mCond, NULL);
|
||||
}
|
||||
inline Condition::Condition(int type) {
|
||||
if (type == SHARED) {
|
||||
pthread_condattr_t attr;
|
||||
pthread_condattr_init(&attr);
|
||||
pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
|
||||
pthread_cond_init(&mCond, &attr);
|
||||
pthread_condattr_destroy(&attr);
|
||||
} else {
|
||||
pthread_cond_init(&mCond, NULL);
|
||||
}
|
||||
}
|
||||
inline Condition::~Condition() {
|
||||
pthread_cond_destroy(&mCond);
|
||||
}
|
||||
inline status_t Condition::wait(Mutex& mutex) {
|
||||
return -pthread_cond_wait(&mCond, &mutex.mMutex);
|
||||
}
|
||||
inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) {
|
||||
#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE)
|
||||
struct timespec ts;
|
||||
ts.tv_sec = reltime/1000000000;
|
||||
ts.tv_nsec = reltime%1000000000;
|
||||
return -pthread_cond_timedwait_relative_np(&mCond, &mutex.mMutex, &ts);
|
||||
#else // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE
|
||||
struct timespec ts;
|
||||
#if defined(HAVE_POSIX_CLOCKS)
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
#else // HAVE_POSIX_CLOCKS
|
||||
// we don't support the clocks here.
|
||||
struct timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
ts.tv_sec = t.tv_sec;
|
||||
ts.tv_nsec= t.tv_usec*1000;
|
||||
#endif // HAVE_POSIX_CLOCKS
|
||||
ts.tv_sec += reltime/1000000000;
|
||||
ts.tv_nsec+= reltime%1000000000;
|
||||
if (ts.tv_nsec >= 1000000000) {
|
||||
ts.tv_nsec -= 1000000000;
|
||||
ts.tv_sec += 1;
|
||||
}
|
||||
return -pthread_cond_timedwait(&mCond, &mutex.mMutex, &ts);
|
||||
#endif // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE
|
||||
}
|
||||
inline void Condition::signal() {
|
||||
pthread_cond_signal(&mCond);
|
||||
}
|
||||
inline void Condition::broadcast() {
|
||||
pthread_cond_broadcast(&mCond);
|
||||
}
|
||||
|
||||
#endif // HAVE_PTHREADS
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* This is our spiffy thread object!
|
||||
*/
|
||||
|
||||
class Thread : virtual public RefBase
|
||||
{
|
||||
public:
|
||||
// Create a Thread object, but doesn't create or start the associated
|
||||
// thread. See the run() method.
|
||||
Thread(bool canCallJava = true);
|
||||
virtual ~Thread();
|
||||
|
||||
// Start the thread in threadLoop() which needs to be implemented.
|
||||
virtual status_t run( const char* name = 0,
|
||||
int32_t priority = PRIORITY_DEFAULT,
|
||||
size_t stack = 0);
|
||||
|
||||
// Ask this object's thread to exit. This function is asynchronous, when the
|
||||
// function returns the thread might still be running. Of course, this
|
||||
// function can be called from a different thread.
|
||||
virtual void requestExit();
|
||||
|
||||
// Good place to do one-time initializations
|
||||
virtual status_t readyToRun();
|
||||
|
||||
// Call requestExit() and wait until this object's thread exits.
|
||||
// BE VERY CAREFUL of deadlocks. In particular, it would be silly to call
|
||||
// this function from this object's thread. Will return WOULD_BLOCK in
|
||||
// that case.
|
||||
status_t requestExitAndWait();
|
||||
|
||||
// Wait until this object's thread exits. Returns immediately if not yet running.
|
||||
// Do not call from this object's thread; will return WOULD_BLOCK in that case.
|
||||
status_t join();
|
||||
|
||||
protected:
|
||||
// exitPending() returns true if requestExit() has been called.
|
||||
bool exitPending() const;
|
||||
|
||||
private:
|
||||
// Derived class must implement threadLoop(). The thread starts its life
|
||||
// here. There are two ways of using the Thread object:
|
||||
// 1) loop: if threadLoop() returns true, it will be called again if
|
||||
// requestExit() wasn't called.
|
||||
// 2) once: if threadLoop() returns false, the thread will exit upon return.
|
||||
virtual bool threadLoop() = 0;
|
||||
|
||||
private:
|
||||
Thread& operator=(const Thread&);
|
||||
static int _threadLoop(void* user);
|
||||
const bool mCanCallJava;
|
||||
// always hold mLock when reading or writing
|
||||
thread_id_t mThread;
|
||||
mutable Mutex mLock;
|
||||
Condition mThreadExitedCondition;
|
||||
status_t mStatus;
|
||||
// note that all accesses of mExitPending and mRunning need to hold mLock
|
||||
volatile bool mExitPending;
|
||||
volatile bool mRunning;
|
||||
sp<Thread> mHoldSelf;
|
||||
#if HAVE_ANDROID_OS
|
||||
int mTid;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _LIBS_UTILS_THREADS_H
|
|
@ -1,8 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#define MOZ_STAGEFRIGHT_OFF_T off64_t
|
||||
#define MOZ_ANDROID_KK
|
||||
#include "../OmxPlugin.cpp"
|
|
@ -1,32 +0,0 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
SOURCES += [
|
||||
'OmxPluginKitKat.cpp',
|
||||
]
|
||||
|
||||
SharedLibrary('omxpluginkk')
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'../include/ics',
|
||||
'../include/ics/media/stagefright/openmax',
|
||||
]
|
||||
|
||||
USE_LIBS += [
|
||||
'/media/omx-plugin/lib/ics/libstagefright/stagefright',
|
||||
'/media/omx-plugin/lib/ics/libutils/utils',
|
||||
'videoeditorplayer',
|
||||
]
|
||||
|
||||
# Don't use STL wrappers; this isn't Gecko code
|
||||
DISABLE_STL_WRAPPING = True
|
||||
NO_VISIBILITY_FLAGS = True
|
||||
|
||||
# Suppress warnings in third-party code.
|
||||
CXXFLAGS += [
|
||||
'-Wno-multichar',
|
||||
'-Wno-shadow',
|
||||
]
|
|
@ -1,193 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "mozilla/Types.h"
|
||||
#define STAGEFRIGHT_EXPORT __attribute__ ((visibility ("default")))
|
||||
#include "stagefright/ColorConverter.h"
|
||||
#include "stagefright/DataSource.h"
|
||||
#include "media/stagefright/MediaBuffer.h"
|
||||
#include "stagefright/MediaExtractor.h"
|
||||
#include "media/stagefright/MediaSource.h"
|
||||
#include "stagefright/MetaData.h"
|
||||
#include "media/stagefright/openmax/OMX_Types.h"
|
||||
#include "media/stagefright/openmax/OMX_Index.h"
|
||||
#include "media/stagefright/openmax/OMX_IVCommon.h"
|
||||
#include "media/stagefright/openmax/OMX_Video.h"
|
||||
#include "media/stagefright/openmax/OMX_Core.h"
|
||||
#include "stagefright/OMXCodec.h"
|
||||
#include "stagefright/OMXClient.h"
|
||||
|
||||
namespace android {
|
||||
MOZ_EXPORT void
|
||||
MediaBuffer::release()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT size_t
|
||||
MediaBuffer::range_offset() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOZ_EXPORT size_t
|
||||
MediaBuffer::range_length() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOZ_EXPORT sp<MetaData>
|
||||
MediaBuffer::meta_data()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOZ_EXPORT void*
|
||||
MediaBuffer::data() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOZ_EXPORT size_t
|
||||
MediaBuffer::size() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOZ_EXPORT bool
|
||||
MetaData::findInt32(uint32_t key, int32_t *value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_EXPORT bool
|
||||
MetaData::setInt32(uint32_t, int32_t)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_EXPORT bool
|
||||
MetaData::findInt64(uint32_t key, int64_t *value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_EXPORT bool
|
||||
MetaData::findPointer(uint32_t key, void **value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_EXPORT bool
|
||||
MetaData::findCString(uint32_t key, const char **value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_EXPORT bool
|
||||
MetaData::findRect(unsigned int key, int *cropLeft, int *cropTop,
|
||||
int *cropRight, int *cropBottom)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
MOZ_EXPORT MediaSource::ReadOptions::ReadOptions()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT void
|
||||
MediaSource::ReadOptions::setSeekTo(int64_t time_us, SeekMode mode)
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT sp<DataSource> DataSource::CreateFromURI(
|
||||
const char *uri,
|
||||
const KeyedVector<String8, String8> *headers) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOZ_EXPORT bool
|
||||
DataSource::getUInt16(off64_t offset, uint16_t *x)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_EXPORT status_t
|
||||
DataSource::getSize(off64_t *size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOZ_EXPORT String8
|
||||
DataSource::getMIMEType() const
|
||||
{
|
||||
return String8();
|
||||
}
|
||||
|
||||
MOZ_EXPORT void
|
||||
DataSource::RegisterDefaultSniffers()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT sp<MediaExtractor>
|
||||
MediaExtractor::Create(const sp<DataSource> &source, const char *mime)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOZ_EXPORT sp<MediaSource>
|
||||
OMXCodec::Create(
|
||||
const sp<IOMX> &omx,
|
||||
const sp<MetaData> &meta, bool createEncoder,
|
||||
const sp<MediaSource> &source,
|
||||
const char *matchComponentName,
|
||||
uint32_t flags,
|
||||
const sp<ANativeWindow> &nativeWindow)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOZ_EXPORT OMXClient::OMXClient()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT status_t OMXClient::connect()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
MOZ_EXPORT void OMXClient::disconnect()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT
|
||||
ColorConverter::ColorConverter(OMX_COLOR_FORMATTYPE, OMX_COLOR_FORMATTYPE) { }
|
||||
|
||||
MOZ_EXPORT
|
||||
ColorConverter::~ColorConverter() { }
|
||||
|
||||
MOZ_EXPORT bool
|
||||
ColorConverter::isValid() const { return false; }
|
||||
|
||||
MOZ_EXPORT status_t
|
||||
ColorConverter::convert(const void *srcBits,
|
||||
size_t srcWidth, size_t srcHeight,
|
||||
size_t srcCropLeft, size_t srcCropTop,
|
||||
size_t srcCropRight, size_t srcCropBottom,
|
||||
void *dstBits,
|
||||
size_t dstWidth, size_t dstHeight,
|
||||
size_t dstCropLeft, size_t dstCropTop,
|
||||
size_t dstCropRight, size_t dstCropBottom)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOZ_EXPORT status_t QueryCodecs(const sp<IOMX> &omx,
|
||||
const char *mimeType, bool queryDecoders,
|
||||
Vector<CodecCapabilities> *results)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
DIST_INSTALL = False
|
||||
|
||||
SOURCES += [
|
||||
'libstagefright.cpp',
|
||||
]
|
||||
# Some codec-related code uses multi-character constants; allow this.
|
||||
# XXX: could instead use the FOURCC macro to define these constants.
|
||||
if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
|
||||
SOURCES['libstagefright.cpp'].flags += ['-Wno-error=multichar']
|
||||
|
||||
SharedLibrary('stagefright')
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'/media/omx-plugin/include/ics',
|
||||
'/media/omx-plugin/include/ics/media/stagefright/openmax',
|
||||
]
|
||||
|
||||
USE_LIBS += [
|
||||
'/media/omx-plugin/lib/ics/libutils/utils',
|
||||
]
|
||||
|
||||
# Don't use STL wrappers; this isn't Gecko code
|
||||
DISABLE_STL_WRAPPING = True
|
||||
NO_VISIBILITY_FLAGS = True
|
||||
|
||||
if CONFIG['GNU_CXX']:
|
||||
CXXFLAGS += ['-Wno-shadow']
|
|
@ -1,84 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "mozilla/Types.h"
|
||||
#include "utils/RefBase.h"
|
||||
#include "utils/String16.h"
|
||||
#include "utils/String8.h"
|
||||
#include "utils/Vector.h"
|
||||
|
||||
namespace android {
|
||||
MOZ_EXPORT RefBase::RefBase() : mRefs(0)
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT RefBase::~RefBase()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT void RefBase::incStrong(const void *id) const
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT void RefBase::decStrong(const void *id) const
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT void RefBase::onFirstRef()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT void RefBase::onLastStrongRef(const void* id)
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT bool RefBase::onIncStrongAttempted(uint32_t flags, const void* id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_EXPORT void RefBase::onLastWeakRef(void const* id)
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT String16::String16(char const*)
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT String16::~String16()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT String8::String8()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT String8::String8(const String8 &)
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT String8::~String8()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT VectorImpl::VectorImpl(size_t, uint32_t)
|
||||
: mFlags(0), mItemSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT VectorImpl::VectorImpl(const VectorImpl &)
|
||||
: mFlags(0), mItemSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT VectorImpl::~VectorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT void VectorImpl::finish_vector()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
DIST_INSTALL = False
|
||||
|
||||
SOURCES += [
|
||||
'libutils.cpp',
|
||||
]
|
||||
|
||||
SharedLibrary('utils')
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'/media/omx-plugin/include/ics',
|
||||
'/media/omx-plugin/include/ics/media/stagefright/openmax',
|
||||
]
|
||||
|
||||
# Don't use STL wrappers; this isn't Gecko code
|
||||
DISABLE_STL_WRAPPING = True
|
||||
NO_VISIBILITY_FLAGS = True
|
||||
|
||||
if CONFIG['GNU_CXX']:
|
||||
CXXFLAGS += ['-Wno-shadow']
|
|
@ -1,23 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "mozilla/Types.h"
|
||||
#include "I420ColorConverter.h"
|
||||
|
||||
MOZ_EXPORT
|
||||
I420ColorConverter::I420ColorConverter()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT
|
||||
I420ColorConverter::~I420ColorConverter()
|
||||
{
|
||||
}
|
||||
|
||||
MOZ_EXPORT bool
|
||||
I420ColorConverter::isLoaded()
|
||||
{
|
||||
return false;
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
DIST_INSTALL = False
|
||||
|
||||
SOURCES += [
|
||||
'libvideoeditorplayer.cpp',
|
||||
]
|
||||
|
||||
SharedLibrary('videoeditorplayer')
|
||||
|
||||
# Don't use STL wrappers; this isn't Gecko code
|
||||
DISABLE_STL_WRAPPING = True
|
||||
NO_VISIBILITY_FLAGS = True
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'/media/omx-plugin/include/ics',
|
||||
]
|
|
@ -1,46 +0,0 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# Copyright 2013 Mozilla Foundation and Mozilla contributors
|
||||
#
|
||||
# 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.
|
||||
|
||||
with Files("**"):
|
||||
BUG_COMPONENT = ("Core", "Audio/Video: Playback")
|
||||
|
||||
SOURCES += [
|
||||
'OmxPlugin.cpp',
|
||||
]
|
||||
|
||||
SharedLibrary('omxplugin')
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'include/ics',
|
||||
'include/ics/media/stagefright/openmax',
|
||||
]
|
||||
|
||||
if CONFIG['GNU_CXX']:
|
||||
# Stagefright header files define many multichar constants.
|
||||
CXXFLAGS += [
|
||||
'-Wno-multichar',
|
||||
'-Wno-shadow',
|
||||
]
|
||||
|
||||
USE_LIBS += [
|
||||
'/media/omx-plugin/lib/ics/libstagefright/stagefright',
|
||||
'/media/omx-plugin/lib/ics/libutils/utils',
|
||||
'videoeditorplayer',
|
||||
]
|
||||
|
||||
# Don't use STL wrappers; this isn't Gecko code
|
||||
DISABLE_STL_WRAPPING = True
|
||||
NO_VISIBILITY_FLAGS = True
|
Загрузка…
Ссылка в новой задаче