M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions
+470
View File
@@ -0,0 +1,470 @@
/*
* 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_AUDIOEFFECT_H
#define ANDROID_AUDIOEFFECT_H
#include <stdint.h>
#include <sys/types.h>
#include <media/IAudioFlinger.h>
#include <media/IEffect.h>
#include <media/IEffectClient.h>
#include <media/EffectApi.h>
#include <media/AudioSystem.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>
#include <binder/IInterface.h>
namespace android {
// ----------------------------------------------------------------------------
class effect_param_cblk_t;
// ----------------------------------------------------------------------------
class AudioEffect : public RefBase
{
public:
/*
* Static methods for effect libraries management.
*/
/*
* Loads the effect library which path is given as first argument.
* This must be the full path of a dynamic library (.so) implementing one or
* more effect engines and exposing the effect library interface described in
* EffectApi.h. The function returns a handle on the library for use by
* further call to unloadEffectLibrary() to unload the library.
*
* Parameters:
* libPath: full path of the dynamic library file in the file system.
* handle: address where to return the library handle
*
* Returned status (from utils/Errors.h) can be:
* NO_ERROR successful operation.
* PERMISSION_DENIED could not get AudioFlinger interface or
* application does not have permission to configure audio
* NO_INIT effect factory not initialized or
* library could not be loaded or
* library does not implement required functions
* BAD_VALUE invalid libPath string or handle
*
* Returned value:
* *handle updated with library handle
*/
static status_t loadEffectLibrary(const char *libPath, int *handle);
/*
* Unloads the effect library which handle is given as argument.
*
* Parameters:
* handle: library handle
*
* Returned status (from utils/Errors.h) can be:
* NO_ERROR successful operation.
* PERMISSION_DENIED could not get AudioFlinger interface or
* application does not have permission to configure audio
* NO_INIT effect factory not initialized
* BAD_VALUE invalid handle
*/
static status_t unloadEffectLibrary(int handle);
/*
* Static methods for effects enumeration.
*/
/*
* Returns the number of effects available. This method together
* with queryEffect() is used to enumerate all effects:
* The enumeration sequence is:
* queryNumberEffects(&num_effects);
* for (i = 0; i < num_effects; i++)
* queryEffect(i,...);
*
* Parameters:
* numEffects: address where the number of effects should be returned.
*
* Returned status (from utils/Errors.h) can be:
* NO_ERROR successful operation.
* PERMISSION_DENIED could not get AudioFlinger interface
* NO_INIT effect library failed to initialize
* BAD_VALUE invalid numEffects pointer
*
* Returned value
* *numEffects: updated with number of effects available
*/
static status_t queryNumberEffects(uint32_t *numEffects);
/*
* Returns an effect descriptor during effect
* enumeration.
*
* Parameters:
* index: index of the queried effect.
* descriptor: address where the effect descriptor should be returned.
*
* Returned status (from utils/Errors.h) can be:
* NO_ERROR successful operation.
* PERMISSION_DENIED could not get AudioFlinger interface
* NO_INIT effect library failed to initialize
* BAD_VALUE invalid descriptor pointer or index
* INVALID_OPERATION effect list has changed since last execution of queryNumberEffects()
*
* Returned value
* *descriptor: updated with effect descriptor
*/
static status_t queryEffect(uint32_t index, effect_descriptor_t *descriptor);
/*
* Returns the descriptor for the specified effect uuid.
*
* Parameters:
* uuid: pointer to effect uuid.
* descriptor: address where the effect descriptor should be returned.
*
* Returned status (from utils/Errors.h) can be:
* NO_ERROR successful operation.
* PERMISSION_DENIED could not get AudioFlinger interface
* NO_INIT effect library failed to initialize
* BAD_VALUE invalid uuid or descriptor pointers
* NAME_NOT_FOUND no effect with this uuid found
*
* Returned value
* *descriptor updated with effect descriptor
*/
static status_t getEffectDescriptor(effect_uuid_t *uuid, effect_descriptor_t *descriptor);
/*
* Events used by callback function (effect_callback_t).
*/
enum event_type {
EVENT_CONTROL_STATUS_CHANGED = 0,
EVENT_ENABLE_STATUS_CHANGED = 1,
EVENT_PARAMETER_CHANGED = 2,
EVENT_ERROR = 3
};
/* Callback function notifying client application of a change in effect engine state or
* configuration.
* An effect engine can be shared by several applications but only one has the control
* of the engine activity and configuration at a time.
* The EVENT_CONTROL_STATUS_CHANGED event is received when an application loses or
* retrieves the control of the effect engine. Loss of control happens
* if another application requests the use of the engine by creating an AudioEffect for
* the same effect type but with a higher priority. Control is returned when the
* application having the control deletes its AudioEffect object.
* The EVENT_ENABLE_STATUS_CHANGED event is received by all applications not having the
* control of the effect engine when the effect is enabled or disabled.
* The EVENT_PARAMETER_CHANGED event is received by all applications not having the
* control of the effect engine when an effect parameter is changed.
* The EVENT_ERROR event is received when the media server process dies.
*
* Parameters:
*
* event: type of event notified (see enum AudioEffect::event_type).
* user: Pointer to context for use by the callback receiver.
* info: Pointer to optional parameter according to event type:
* - EVENT_CONTROL_STATUS_CHANGED: boolean indicating if control is granted (true)
* or stolen (false).
* - EVENT_ENABLE_STATUS_CHANGED: boolean indicating if effect is now enabled (true)
* or disabled (false).
* - EVENT_PARAMETER_CHANGED: pointer to a effect_param_t structure.
* - EVENT_ERROR: status_t indicating the error (DEAD_OBJECT when media server dies).
*/
typedef void (*effect_callback_t)(int32_t event, void* user, void *info);
/* Constructor.
* AudioEffect is the base class for creating and controlling an effect engine from
* the application process. Creating an AudioEffect object will create the effect engine
* in the AudioFlinger if no engine of the specified type exists. If one exists, this engine
* will be used. The application creating the AudioEffect object (or a derived class like
* Reverb for instance) will either receive control of the effect engine or not, depending
* on the priority parameter. If priority is higher than the priority used by the current
* effect engine owner, the control will be transfered to the new application. Otherwise
* control will remain to the previous application. In this case, the new application will be
* notified of changes in effect engine state or control ownership by the effect callback.
* After creating the AudioEffect, the application must call the initCheck() method and
* check the creation status before trying to control the effect engine (see initCheck()).
* If the effect is to be applied to an AudioTrack or MediaPlayer only the application
* must specify the audio session ID corresponding to this player.
*/
/* Simple Constructor.
*/
AudioEffect();
/* Constructor.
*
* Parameters:
*
* type: type of effect created: can be null if uuid is specified. This corresponds to
* the OpenSL ES interface implemented by this effect.
* uuid: Uuid of effect created: can be null if type is specified. This uuid corresponds to
* a particular implementation of an effect type.
* priority: requested priority for effect control: the priority level corresponds to the
* value of priority parameter: negative values indicate lower priorities, positive values
* higher priorities, 0 being the normal priority.
* cbf: optional callback function (see effect_callback_t)
* user: pointer to context for use by the callback receiver.
* sessionID: audio session this effect is associated to. If 0, the effect will be global to
* the output mix. If not 0, the effect will be applied to all players
* (AudioTrack or MediaPLayer) within the same audio session.
* output: HAL audio output stream to which this effect must be attached. Leave at 0 for
* automatic output selection by AudioFlinger.
*/
AudioEffect(const effect_uuid_t *type,
const effect_uuid_t *uuid = NULL,
int32_t priority = 0,
effect_callback_t cbf = 0,
void* user = 0,
int sessionId = 0,
audio_io_handle_t output = 0
);
/* Constructor.
* Same as above but with type and uuid specified by character strings
*/
AudioEffect(const char *typeStr,
const char *uuidStr = NULL,
int32_t priority = 0,
effect_callback_t cbf = 0,
void* user = 0,
int sessionId = 0,
audio_io_handle_t output = 0
);
/* Terminates the AudioEffect and unregisters it from AudioFlinger.
* The effect engine is also destroyed if this AudioEffect was the last controlling
* the engine.
*/
~AudioEffect();
/* Initialize an uninitialized AudioEffect.
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR or ALREADY_EXISTS: successful initialization
* - INVALID_OPERATION: AudioEffect is already initialized
* - BAD_VALUE: invalid parameter
* - NO_INIT: audio flinger or audio hardware not initialized
* */
status_t set(const effect_uuid_t *type,
const effect_uuid_t *uuid = NULL,
int32_t priority = 0,
effect_callback_t cbf = 0,
void* user = 0,
int sessionId = 0,
audio_io_handle_t output = 0
);
/* Result of constructing the AudioEffect. This must be checked
* before using any AudioEffect API.
* initCheck() can return:
* - NO_ERROR: the effect engine is successfully created and the application has control.
* - ALREADY_EXISTS: the effect engine is successfully created but the application does not
* have control.
* - NO_INIT: the effect creation failed.
*
*/
status_t initCheck() const;
/* Returns the unique effect Id for the controlled effect engine. This ID is unique
* system wide and is used for instance in the case of auxiliary effects to attach
* the effect to an AudioTrack or MediaPlayer.
*
*/
int32_t id() const { return mId; }
/* Returns a descriptor for the effect (see effect_descriptor_t in EffectApi.h).
*/
effect_descriptor_t descriptor() const;
/* Returns effect control priority of this AudioEffect object.
*/
int32_t priority() const { return mPriority; }
/* Enables or disables the effect engine.
*
* Parameters:
* enabled: requested enable state.
*
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation
* - INVALID_OPERATION: the application does not have control of the effect engine or the
* effect is already in the requested state.
*/
virtual status_t setEnabled(bool enabled);
bool getEnabled() const;
/* Sets a parameter value.
*
* Parameters:
* param: pointer to effect_param_t structure containing the parameter
* and its value (See EffectApi.h).
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation.
* - INVALID_OPERATION: the application does not have control of the effect engine.
* - BAD_VALUE: invalid parameter identifier or value.
* - DEAD_OBJECT: the effect engine has been deleted.
*/
virtual status_t setParameter(effect_param_t *param);
/* Prepare a new parameter value that will be set by next call to
* setParameterCommit(). This method can be used to set multiple parameters
* in a synchronous manner or to avoid multiple binder calls for each
* parameter.
*
* Parameters:
* param: pointer to effect_param_t structure containing the parameter
* and its value (See EffectApi.h).
*
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation.
* - INVALID_OPERATION: the application does not have control of the effect engine.
* - NO_MEMORY: no more space available in shared memory used for deferred parameter
* setting.
*/
virtual status_t setParameterDeferred(effect_param_t *param);
/* Commit all parameter values previously prepared by setParameterDeferred().
*
* Parameters:
* none
*
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation.
* - INVALID_OPERATION: No new parameter values ready for commit.
* - BAD_VALUE: invalid parameter identifier or value: there is no indication
* as to which of the parameters caused this error.
* - DEAD_OBJECT: the effect engine has been deleted.
*/
virtual status_t setParameterCommit();
/* Gets a parameter value.
*
* Parameters:
* param: pointer to effect_param_t structure containing the parameter
* and the returned value (See EffectApi.h).
*
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation.
* - INVALID_OPERATION: the AudioEffect was not successfully initialized.
* - BAD_VALUE: invalid parameter identifier.
* - DEAD_OBJECT: the effect engine has been deleted.
*/
virtual status_t getParameter(effect_param_t *param);
/* Sends a command and receives a response to/from effect engine.
* See EffectApi.h for details on effect command() function, valid command codes
* and formats.
*/
virtual status_t command(uint32_t cmdCode,
uint32_t cmdSize,
void *cmdData,
uint32_t *replySize,
void *replyData);
/*
* Utility functions.
*/
/* Converts the string passed as first argument to the effect_uuid_t
* pointed to by second argument
*/
static status_t stringToGuid(const char *str, effect_uuid_t *guid);
/* Converts the effect_uuid_t pointed to by first argument to the
* string passed as second argument
*/
static status_t guidToString(const effect_uuid_t *guid, char *str, size_t maxLen);
protected:
volatile int32_t mEnabled; // enable state
int32_t mSessionId; // audio session ID
int32_t mPriority; // priority for effect control
status_t mStatus; // effect status
effect_callback_t mCbf; // callback function for status, control and
// parameter changes notifications
void* mUserData; // client context for callback function
effect_descriptor_t mDescriptor; // effect descriptor
int32_t mId; // system wide unique effect engine instance ID
private:
// Implements the IEffectClient interface
class EffectClient : public android::BnEffectClient, public android::IBinder::DeathRecipient
{
public:
EffectClient(AudioEffect *effect) : mEffect(effect){}
// IEffectClient
virtual void controlStatusChanged(bool controlGranted) {
mEffect->controlStatusChanged(controlGranted);
}
virtual void enableStatusChanged(bool enabled) {
mEffect->enableStatusChanged(enabled);
}
virtual void commandExecuted(uint32_t cmdCode,
uint32_t cmdSize,
void *pCmdData,
uint32_t replySize,
void *pReplyData) {
mEffect->commandExecuted(cmdCode, cmdSize, pCmdData, replySize, pReplyData);
}
// IBinder::DeathRecipient
virtual void binderDied(const wp<IBinder>& who) {mEffect->binderDied();}
private:
AudioEffect *mEffect;
};
friend class EffectClient;
// IEffectClient
void controlStatusChanged(bool controlGranted);
void enableStatusChanged(bool enabled);
void commandExecuted(uint32_t cmdCode,
uint32_t cmdSize,
void *pCmdData,
uint32_t replySize,
void *pReplyData);
void binderDied();
sp<IEffect> mIEffect; // IEffect binder interface
sp<EffectClient> mIEffectClient; // IEffectClient implementation
sp<IMemory> mCblkMemory; // shared memory for deferred parameter setting
effect_param_cblk_t* mCblk; // control block for deferred parameter setting
};
}; // namespace android
#endif // ANDROID_AUDIOEFFECT_H
+390
View File
@@ -0,0 +1,390 @@
/*
* 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 AUDIORECORD_H_
#define AUDIORECORD_H_
#include <stdint.h>
#include <sys/types.h>
#include <media/IAudioFlinger.h>
#include <media/IAudioRecord.h>
#include <media/AudioTrack.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>
#include <binder/IInterface.h>
#include <binder/IMemory.h>
#include <utils/threads.h>
namespace android {
// ----------------------------------------------------------------------------
class AudioRecord
{
public:
static const int DEFAULT_SAMPLE_RATE = 8000;
/* Events used by AudioRecord callback function (callback_t).
*
* to keep in sync with frameworks/base/media/java/android/media/AudioRecord.java
*/
enum event_type {
EVENT_MORE_DATA = 0, // Request to reqd more data from PCM buffer.
EVENT_OVERRUN = 1, // PCM buffer overrun occured.
EVENT_MARKER = 2, // Record head is at the specified marker position
// (See setMarkerPosition()).
EVENT_NEW_POS = 3, // Record head is at a new position
// (See setPositionUpdatePeriod()).
};
/* Create Buffer on the stack and pass it to obtainBuffer()
* and releaseBuffer().
*/
class Buffer
{
public:
enum {
MUTE = 0x00000001
};
uint32_t flags;
int channelCount;
int format;
size_t frameCount;
size_t size;
union {
void* raw;
short* i16;
int8_t* i8;
};
};
/* These are static methods to control the system-wide AudioFlinger
* only privileged processes can have access to them
*/
// static status_t setMasterMute(bool mute);
/* As a convenience, if a callback is supplied, a handler thread
* is automatically created with the appropriate priority. This thread
* invokes the callback when a new buffer becomes ready or an overrun condition occurs.
* Parameters:
*
* event: type of event notified (see enum AudioRecord::event_type).
* user: Pointer to context for use by the callback receiver.
* info: Pointer to optional parameter according to event type:
* - EVENT_MORE_DATA: pointer to AudioRecord::Buffer struct. The callback must not read
* more bytes than indicated by 'size' field and update 'size' if less bytes are
* read.
* - EVENT_OVERRUN: unused.
* - EVENT_MARKER: pointer to an uin32_t containing the marker position in frames.
* - EVENT_NEW_POS: pointer to an uin32_t containing the new position in frames.
*/
typedef void (*callback_t)(int event, void* user, void *info);
/* Returns the minimum frame count required for the successful creation of
* an AudioRecord object.
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation
* - NO_INIT: audio server or audio hardware not initialized
* - BAD_VALUE: unsupported configuration
*/
static status_t getMinFrameCount(int* frameCount,
uint32_t sampleRate,
int format,
int channelCount);
/* Constructs an uninitialized AudioRecord. No connection with
* AudioFlinger takes place.
*/
AudioRecord();
/* Creates an AudioRecord track and registers it with AudioFlinger.
* Once created, the track needs to be started before it can be used.
* Unspecified values are set to the audio hardware's current
* values.
*
* Parameters:
*
* inputSource: Select the audio input to record to (e.g. AUDIO_SOURCE_DEFAULT).
* sampleRate: Track sampling rate in Hz.
* format: Audio format (e.g AudioSystem::PCM_16_BIT for signed
* 16 bits per sample).
* channels: Channel mask: see AudioSystem::audio_channels.
* frameCount: Total size of track PCM buffer in frames. This defines the
* latency of the track.
* flags: A bitmask of acoustic values from enum record_flags. It enables
* AGC, NS, and IIR.
* cbf: Callback function. If not null, this function is called periodically
* to provide new PCM data.
* notificationFrames: The callback function is called each time notificationFrames PCM
* frames are ready in record track output buffer.
* user Context for use by the callback receiver.
*/
enum record_flags {
RECORD_AGC_ENABLE = 1,
RECORD_NS_ENABLE = 2,
RECORD_IIR_ENABLE = 4
};
AudioRecord(int inputSource,
uint32_t sampleRate = 0,
int format = 0,
uint32_t channels = AudioSystem::CHANNEL_IN_MONO,
int frameCount = 0,
uint32_t flags = 0,
callback_t cbf = 0,
void* user = 0,
int notificationFrames = 0,
int sessionId = 0);
/* Terminates the AudioRecord and unregisters it from AudioFlinger.
* Also destroys all resources assotiated with the AudioRecord.
*/
~AudioRecord();
/* Initialize an uninitialized AudioRecord.
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful intialization
* - INVALID_OPERATION: AudioRecord is already intitialized or record device is already in use
* - BAD_VALUE: invalid parameter (channels, format, sampleRate...)
* - NO_INIT: audio server or audio hardware not initialized
* - PERMISSION_DENIED: recording is not allowed for the requesting process
* */
status_t set(int inputSource = 0,
uint32_t sampleRate = 0,
int format = 0,
uint32_t channels = AudioSystem::CHANNEL_IN_MONO,
int frameCount = 0,
uint32_t flags = 0,
callback_t cbf = 0,
void* user = 0,
int notificationFrames = 0,
bool threadCanCallJava = false,
int sessionId = 0);
/* Result of constructing the AudioRecord. This must be checked
* before using any AudioRecord API (except for set()), using
* an uninitialized AudioRecord produces undefined results.
* See set() method above for possible return codes.
*/
status_t initCheck() const;
/* Returns this track's latency in milliseconds.
* This includes the latency due to AudioRecord buffer size
* and audio hardware driver.
*/
uint32_t latency() const;
/* getters, see constructor */
int format() const;
int channelCount() const;
int channels() const;
uint32_t frameCount() const;
int frameSize() const;
int inputSource() const;
/* After it's created the track is not active. Call start() to
* make it active. If set, the callback will start being called.
*/
status_t start();
/* Stop a track. If set, the callback will cease being called and
* obtainBuffer returns STOPPED. Note that obtainBuffer() still works
* and will fill up buffers until the pool is exhausted.
*/
status_t stop();
bool stopped() const;
/* get sample rate for this record track
*/
uint32_t getSampleRate();
/* Sets marker position. When record reaches the number of frames specified,
* a callback with event type EVENT_MARKER is called. Calling setMarkerPosition
* with marker == 0 cancels marker notification callback.
* If the AudioRecord has been opened with no callback function associated,
* the operation will fail.
*
* Parameters:
*
* marker: marker position expressed in frames.
*
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation
* - INVALID_OPERATION: the AudioRecord has no callback installed.
*/
status_t setMarkerPosition(uint32_t marker);
status_t getMarkerPosition(uint32_t *marker);
/* Sets position update period. Every time the number of frames specified has been recorded,
* a callback with event type EVENT_NEW_POS is called.
* Calling setPositionUpdatePeriod with updatePeriod == 0 cancels new position notification
* callback.
* If the AudioRecord has been opened with no callback function associated,
* the operation will fail.
*
* Parameters:
*
* updatePeriod: position update notification period expressed in frames.
*
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation
* - INVALID_OPERATION: the AudioRecord has no callback installed.
*/
status_t setPositionUpdatePeriod(uint32_t updatePeriod);
status_t getPositionUpdatePeriod(uint32_t *updatePeriod);
/* Gets record head position. The position is the total number of frames
* recorded since record start.
*
* Parameters:
*
* position: Address where to return record head position within AudioRecord buffer.
*
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation
* - BAD_VALUE: position is NULL
*/
status_t getPosition(uint32_t *position);
/* returns a handle on the audio input used by this AudioRecord.
*
* Parameters:
* none.
*
* Returned value:
* handle on audio hardware input
*/
audio_io_handle_t getInput();
/* returns the audio session ID associated to this AudioRecord.
*
* Parameters:
* none.
*
* Returned value:
* AudioRecord session ID.
*/
int getSessionId();
/* obtains a buffer of "frameCount" frames. The buffer must be
* filled entirely. If the track is stopped, obtainBuffer() returns
* STOPPED instead of NO_ERROR as long as there are buffers availlable,
* at which point NO_MORE_BUFFERS is returned.
* Buffers will be returned until the pool (buffercount())
* is exhausted, at which point obtainBuffer() will either block
* or return WOULD_BLOCK depending on the value of the "blocking"
* parameter.
*/
enum {
NO_MORE_BUFFERS = 0x80000001,
STOPPED = 1
};
status_t obtainBuffer(Buffer* audioBuffer, int32_t waitCount);
void releaseBuffer(Buffer* audioBuffer);
/* As a convenience we provide a read() interface to the audio buffer.
* This is implemented on top of lockBuffer/unlockBuffer.
*/
ssize_t read(void* buffer, size_t size);
/* Return the amount of input frames lost in the audio driver since the last call of this function.
* Audio driver is expected to reset the value to 0 and restart counting upon returning the current value by this function call.
* Such loss typically occurs when the user space process is blocked longer than the capacity of audio driver buffers.
* Unit: the number of input audio frames
*/
unsigned int getInputFramesLost();
private:
/* copying audio tracks is not allowed */
AudioRecord(const AudioRecord& other);
AudioRecord& operator = (const AudioRecord& other);
/* a small internal class to handle the callback */
class ClientRecordThread : public Thread
{
public:
ClientRecordThread(AudioRecord& receiver, bool bCanCallJava = false);
private:
friend class AudioRecord;
virtual bool threadLoop();
virtual status_t readyToRun() { return NO_ERROR; }
virtual void onFirstRef() {}
AudioRecord& mReceiver;
Mutex mLock;
};
bool processAudioBuffer(const sp<ClientRecordThread>& thread);
status_t openRecord(uint32_t sampleRate,
int format,
int channelCount,
int frameCount,
uint32_t flags,
audio_io_handle_t input);
sp<IAudioRecord> mAudioRecord;
sp<IMemory> mCblkMemory;
sp<ClientRecordThread> mClientRecordThread;
Mutex mRecordThreadLock;
uint32_t mFrameCount;
audio_track_cblk_t* mCblk;
int32_t mFormat;
uint8_t mChannelCount;
uint8_t mInputSource;
uint8_t mReserved;
status_t mStatus;
uint32_t mLatency;
volatile int32_t mActive;
callback_t mCbf;
void* mUserData;
uint32_t mNotificationFrames;
uint32_t mRemainingFrames;
uint32_t mMarkerPosition;
bool mMarkerReached;
uint32_t mNewPosition;
uint32_t mUpdatePeriod;
uint32_t mFlags;
uint32_t mChannels;
audio_io_handle_t mInput;
bool mFirstread;
int mSessionId;
};
}; // namespace android
#endif /*AUDIORECORD_H_*/
+538
View File
@@ -0,0 +1,538 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
*
* 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_AUDIOSYSTEM_H_
#define ANDROID_AUDIOSYSTEM_H_
#include <utils/RefBase.h>
#include <utils/threads.h>
#include <media/IAudioFlinger.h>
namespace android {
typedef void (*audio_error_callback)(status_t err);
typedef int audio_io_handle_t;
class IAudioPolicyService;
class String8;
class AudioSystem
{
public:
enum stream_type {
DEFAULT =-1,
VOICE_CALL = 0,
SYSTEM = 1,
RING = 2,
MUSIC = 3,
ALARM = 4,
NOTIFICATION = 5,
BLUETOOTH_SCO = 6,
ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be routed to speaker
DTMF = 8,
TTS = 9,
FM = 10,
NUM_STREAM_TYPES
};
// Audio sub formats (see AudioSystem::audio_format).
enum pcm_sub_format {
PCM_SUB_16_BIT = 0x1, // must be 1 for backward compatibility
PCM_SUB_8_BIT = 0x2, // must be 2 for backward compatibility
};
// MP3 sub format field definition : can use 11 LSBs in the same way as MP3 frame header to specify
// bit rate, stereo mode, version...
enum mp3_sub_format {
//TODO
};
// AMR NB/WB sub format field definition: specify frame block interleaving, bandwidth efficient or octet aligned,
// encoding mode for recording...
enum amr_sub_format {
//TODO
};
// AAC sub format field definition: specify profile or bitrate for recording...
enum aac_sub_format {
//TODO
};
// VORBIS sub format field definition: specify quality for recording...
enum vorbis_sub_format {
//TODO
};
// Audio format consists in a main format field (upper 8 bits) and a sub format field (lower 24 bits).
// The main format indicates the main codec type. The sub format field indicates options and parameters
// for each format. The sub format is mainly used for record to indicate for instance the requested bitrate
// or profile. It can also be used for certain formats to give informations not present in the encoded
// audio stream (e.g. octet alignement for AMR).
enum audio_format {
INVALID_FORMAT = -1,
FORMAT_DEFAULT = 0,
PCM = 0x00000000, // must be 0 for backward compatibility
MP3 = 0x01000000,
AMR_NB = 0x02000000,
AMR_WB = 0x03000000,
AAC = 0x04000000,
HE_AAC_V1 = 0x05000000,
HE_AAC_V2 = 0x06000000,
VORBIS = 0x07000000,
EVRC = 0x08000000,
QCELP = 0x09000000,
VOIP_PCM_INPUT = 0x0A000000,
MAIN_FORMAT_MASK = 0xFF000000,
SUB_FORMAT_MASK = 0x00FFFFFF,
// Aliases
PCM_16_BIT = (PCM|PCM_SUB_16_BIT),
PCM_8_BIT = (PCM|PCM_SUB_8_BIT)
};
// Channel mask definitions must be kept in sync with JAVA values in /media/java/android/media/AudioFormat.java
enum audio_channels {
// output channels
CHANNEL_OUT_FRONT_LEFT = 0x4,
CHANNEL_OUT_FRONT_RIGHT = 0x8,
CHANNEL_OUT_FRONT_CENTER = 0x10,
CHANNEL_OUT_LOW_FREQUENCY = 0x20,
CHANNEL_OUT_BACK_LEFT = 0x40,
CHANNEL_OUT_BACK_RIGHT = 0x80,
CHANNEL_OUT_FRONT_LEFT_OF_CENTER = 0x100,
CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x200,
CHANNEL_OUT_BACK_CENTER = 0x400,
CHANNEL_OUT_MONO = CHANNEL_OUT_FRONT_LEFT,
CHANNEL_OUT_STEREO = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT),
CHANNEL_OUT_QUAD = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT),
CHANNEL_OUT_SURROUND = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_BACK_CENTER),
CHANNEL_OUT_5POINT1 = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT),
CHANNEL_OUT_7POINT1 = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT |
CHANNEL_OUT_FRONT_LEFT_OF_CENTER | CHANNEL_OUT_FRONT_RIGHT_OF_CENTER),
CHANNEL_OUT_ALL = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT |
CHANNEL_OUT_FRONT_LEFT_OF_CENTER | CHANNEL_OUT_FRONT_RIGHT_OF_CENTER | CHANNEL_OUT_BACK_CENTER),
// input channels
CHANNEL_IN_LEFT = 0x4,
CHANNEL_IN_RIGHT = 0x8,
CHANNEL_IN_FRONT = 0x10,
CHANNEL_IN_BACK = 0x20,
CHANNEL_IN_LEFT_PROCESSED = 0x40,
CHANNEL_IN_RIGHT_PROCESSED = 0x80,
CHANNEL_IN_FRONT_PROCESSED = 0x100,
CHANNEL_IN_BACK_PROCESSED = 0x200,
CHANNEL_IN_PRESSURE = 0x400,
CHANNEL_IN_X_AXIS = 0x800,
CHANNEL_IN_Y_AXIS = 0x1000,
CHANNEL_IN_Z_AXIS = 0x2000,
CHANNEL_IN_VOICE_UPLINK = 0x4000,
CHANNEL_IN_VOICE_DNLINK = 0x8000,
CHANNEL_IN_MONO = CHANNEL_IN_FRONT,
CHANNEL_IN_STEREO = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT),
CHANNEL_IN_ALL = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT | CHANNEL_IN_FRONT | CHANNEL_IN_BACK|
CHANNEL_IN_LEFT_PROCESSED | CHANNEL_IN_RIGHT_PROCESSED | CHANNEL_IN_FRONT_PROCESSED | CHANNEL_IN_BACK_PROCESSED|
CHANNEL_IN_PRESSURE | CHANNEL_IN_X_AXIS | CHANNEL_IN_Y_AXIS | CHANNEL_IN_Z_AXIS |
CHANNEL_IN_VOICE_UPLINK | CHANNEL_IN_VOICE_DNLINK)
};
enum audio_mode {
MODE_INVALID = -2,
MODE_CURRENT = -1,
MODE_NORMAL = 0,
MODE_RINGTONE,
MODE_IN_CALL,
MODE_IN_COMMUNICATION,
NUM_MODES // not a valid entry, denotes end-of-list
};
enum audio_in_acoustics {
AGC_ENABLE = 0x0001,
AGC_DISABLE = 0,
NS_ENABLE = 0x0002,
NS_DISABLE = 0,
TX_IIR_ENABLE = 0x0004,
TX_DISABLE = 0
};
// special audio session values
enum audio_sessions {
SESSION_OUTPUT_STAGE = -1, // session for effects attached to a particular output stream
// (value must be less than 0)
SESSION_OUTPUT_MIX = 0, // session for effects applied to output mix. These effects can
// be moved by audio policy manager to another output stream
// (value must be 0)
};
/* These are static methods to control the system-wide AudioFlinger
* only privileged processes can have access to them
*/
// mute/unmute microphone
static status_t muteMicrophone(bool state);
static status_t isMicrophoneMuted(bool *state);
// set/get master volume
static status_t setMasterVolume(float value);
static status_t getMasterVolume(float* volume);
// mute/unmute audio outputs
static status_t setMasterMute(bool mute);
static status_t getMasterMute(bool* mute);
// set/get stream volume on specified output
static status_t setStreamVolume(int stream, float value, int output);
static status_t getStreamVolume(int stream, float* volume, int output);
// mute/unmute stream
static status_t setStreamMute(int stream, bool mute);
static status_t getStreamMute(int stream, bool* mute);
// set audio mode in audio hardware (see AudioSystem::audio_mode)
static status_t setMode(int mode);
// returns true in *state if tracks are active on the specified stream
static status_t isStreamActive(int stream, bool *state);
// set/get audio hardware parameters. The function accepts a list of parameters
// key value pairs in the form: key1=value1;key2=value2;...
// Some keys are reserved for standard parameters (See AudioParameter class).
static status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs);
static String8 getParameters(audio_io_handle_t ioHandle, const String8& keys);
static void setErrorCallback(audio_error_callback cb);
// helper function to obtain AudioFlinger service handle
static const sp<IAudioFlinger>& get_audio_flinger();
static float linearToLog(int volume);
static int logToLinear(float volume);
static status_t getOutputSamplingRate(int* samplingRate, int stream = DEFAULT);
static status_t getOutputFrameCount(int* frameCount, int stream = DEFAULT);
static status_t getOutputLatency(uint32_t* latency, int stream = DEFAULT);
static bool routedToA2dpOutput(int streamType);
static status_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount,
size_t* buffSize);
static status_t setVoiceVolume(float volume);
static status_t setFmVolume(float volume);
// return the number of audio frames written by AudioFlinger to audio HAL and
// audio dsp to DAC since the output on which the specificed stream is playing
// has exited standby.
// returned status (from utils/Errors.h) can be:
// - NO_ERROR: successful operation, halFrames and dspFrames point to valid data
// - INVALID_OPERATION: Not supported on current hardware platform
// - BAD_VALUE: invalid parameter
// NOTE: this feature is not supported on all hardware platforms and it is
// necessary to check returned status before using the returned values.
static status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int stream = DEFAULT);
static unsigned int getInputFramesLost(audio_io_handle_t ioHandle);
static int newAudioSessionId();
//
// AudioPolicyService interface
//
enum audio_devices {
// output devices
DEVICE_OUT_EARPIECE = 0x1,
DEVICE_OUT_SPEAKER = 0x2,
DEVICE_OUT_WIRED_HEADSET = 0x4,
DEVICE_OUT_WIRED_HEADPHONE = 0x8,
DEVICE_OUT_BLUETOOTH_SCO = 0x10,
DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 0x20,
DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 0x40,
DEVICE_OUT_BLUETOOTH_A2DP = 0x80,
DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200,
DEVICE_OUT_AUX_DIGITAL = 0x400,
DEVICE_OUT_FM = 0x800,
DEVICE_OUT_ANC_HEADSET = 0x1000,
DEVICE_OUT_ANC_HEADPHONE = 0x2000,
DEVICE_OUT_FM_TX = 0x4000,
DEVICE_OUT_DEFAULT = 0x8000,
// Since no free bits available in output device , using free bits from input device list
DEVICE_OUT_DIRECTOUTPUT = 0x8000000,
DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE | DEVICE_OUT_SPEAKER | DEVICE_OUT_WIRED_HEADSET |
DEVICE_OUT_WIRED_HEADPHONE | DEVICE_OUT_FM | DEVICE_OUT_BLUETOOTH_SCO | DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
DEVICE_OUT_BLUETOOTH_SCO_CARKIT | DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | DEVICE_OUT_AUX_DIGITAL | DEVICE_OUT_FM |
DEVICE_OUT_ANC_HEADSET | DEVICE_OUT_ANC_HEADPHONE | DEVICE_OUT_FM_TX | DEVICE_OUT_DIRECTOUTPUT |
DEVICE_OUT_DEFAULT),
DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER),
// input devices
DEVICE_IN_COMMUNICATION = 0x10000,
DEVICE_IN_AMBIENT = 0x20000,
DEVICE_IN_BUILTIN_MIC = 0x40000,
DEVICE_IN_VOICE_CALL = 0x80000,
DEVICE_IN_BACK_MIC = 0x100000,
DEVICE_IN_BLUETOOTH_SCO_HEADSET = 0x200000,
DEVICE_IN_WIRED_HEADSET = 0x400000,
DEVICE_IN_AUX_DIGITAL = 0x800000,
DEVICE_IN_ANC_HEADSET = 0x1000000,
DEVICE_IN_FM_RX = 0x2000000,
DEVICE_IN_FM_RX_A2DP = 0x4000000,
DEVICE_IN_DEFAULT = 0x80000000,
DEVICE_IN_ALL = (DEVICE_IN_COMMUNICATION | DEVICE_IN_AMBIENT | DEVICE_IN_BUILTIN_MIC |
DEVICE_IN_BLUETOOTH_SCO_HEADSET | DEVICE_IN_WIRED_HEADSET | DEVICE_IN_AUX_DIGITAL |
DEVICE_IN_VOICE_CALL | DEVICE_IN_BACK_MIC | DEVICE_IN_FM_RX | DEVICE_IN_FM_RX_A2DP | DEVICE_IN_ANC_HEADSET | DEVICE_IN_DEFAULT)
};
// device connection states used for setDeviceConnectionState()
enum device_connection_state {
DEVICE_STATE_UNAVAILABLE,
DEVICE_STATE_AVAILABLE,
NUM_DEVICE_STATES
};
// request to open a direct output with getOutput() (by opposition to sharing an output with other AudioTracks)
enum output_flags {
OUTPUT_FLAG_INDIRECT = 0x0,
OUTPUT_FLAG_DIRECT = 0x1,
OUTPUT_FLAG_SESSION = 0x2
};
// device categories used for setForceUse()
enum forced_config {
FORCE_NONE,
FORCE_SPEAKER,
FORCE_HEADPHONES,
FORCE_BT_SCO,
FORCE_BT_A2DP,
FORCE_WIRED_ACCESSORY,
FORCE_BT_CAR_DOCK,
FORCE_BT_DESK_DOCK,
NUM_FORCE_CONFIG,
FORCE_DEFAULT = FORCE_NONE
};
// usages used for setForceUse()
enum force_use {
FOR_COMMUNICATION,
FOR_MEDIA,
FOR_RECORD,
FOR_DOCK,
NUM_FORCE_USE
};
// types of io configuration change events received with ioConfigChanged()
enum io_config_event {
OUTPUT_OPENED,
OUTPUT_CLOSED,
OUTPUT_CONFIG_CHANGED,
INPUT_OPENED,
INPUT_CLOSED,
INPUT_CONFIG_CHANGED,
STREAM_CONFIG_CHANGED,
A2DP_OUTPUT_STATE,
EFFECT_CONFIG_CHANGED,
NUM_CONFIG_EVENTS
};
// audio output descritor used to cache output configurations in client process to avoid frequent calls
// through IAudioFlinger
class OutputDescriptor {
public:
OutputDescriptor()
: samplingRate(0), format(0), channels(0), frameCount(0), latency(0) {}
uint32_t samplingRate;
int32_t format;
int32_t channels;
size_t frameCount;
uint32_t latency;
};
//
// IAudioPolicyService interface (see AudioPolicyInterface for method descriptions)
//
static status_t setDeviceConnectionState(audio_devices device, device_connection_state state, const char *device_address);
static device_connection_state getDeviceConnectionState(audio_devices device, const char *device_address);
static status_t setPhoneState(int state);
static status_t setRingerMode(uint32_t mode, uint32_t mask);
static status_t setForceUse(force_use usage, forced_config config);
static forced_config getForceUse(force_use usage);
static audio_io_handle_t getOutput(stream_type stream,
uint32_t samplingRate = 0,
uint32_t format = FORMAT_DEFAULT,
uint32_t channels = CHANNEL_OUT_STEREO,
output_flags flags = OUTPUT_FLAG_INDIRECT);
static audio_io_handle_t getSession(stream_type stream,
uint32_t format = FORMAT_DEFAULT,
output_flags flags = OUTPUT_FLAG_DIRECT,
int32_t sessionId = -1);
static void closeSession(audio_io_handle_t output);
static status_t pauseSession(audio_io_handle_t output, stream_type stream);
static status_t resumeSession(audio_io_handle_t output, stream_type stream);
static status_t startOutput(audio_io_handle_t output,
AudioSystem::stream_type stream,
int session = 0);
static status_t stopOutput(audio_io_handle_t output,
AudioSystem::stream_type stream,
int session = 0);
static void releaseOutput(audio_io_handle_t output);
static audio_io_handle_t getInput(int inputSource,
uint32_t samplingRate = 0,
uint32_t format = FORMAT_DEFAULT,
uint32_t channels = CHANNEL_IN_MONO,
audio_in_acoustics acoustics = (audio_in_acoustics)0);
static status_t startInput(audio_io_handle_t input);
static status_t stopInput(audio_io_handle_t input);
static void releaseInput(audio_io_handle_t input);
static status_t initStreamVolume(stream_type stream,
int indexMin,
int indexMax);
static status_t setStreamVolumeIndex(stream_type stream, int index);
static status_t getStreamVolumeIndex(stream_type stream, int *index);
static uint32_t getStrategyForStream(stream_type stream);
static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
static status_t registerEffect(effect_descriptor_t *desc,
audio_io_handle_t output,
uint32_t strategy,
int session,
int id);
static status_t unregisterEffect(int id);
static const sp<IAudioPolicyService>& get_audio_policy_service();
// ----------------------------------------------------------------------------
static uint32_t popCount(uint32_t u);
static bool isOutputDevice(audio_devices device);
static bool isInputDevice(audio_devices device);
static bool isA2dpDevice(audio_devices device);
static bool isBluetoothScoDevice(audio_devices device);
static bool isLowVisibility(stream_type stream);
static bool isOutputChannel(uint32_t channel);
static bool isInputChannel(uint32_t channel);
static bool isValidFormat(uint32_t format);
static bool isLinearPCM(uint32_t format);
static bool isModeInCall();
private:
class AudioFlingerClient: public IBinder::DeathRecipient, public BnAudioFlingerClient
{
public:
AudioFlingerClient() {
}
// DeathRecipient
virtual void binderDied(const wp<IBinder>& who);
// IAudioFlingerClient
// indicate a change in the configuration of an output or input: keeps the cached
// values for output/input parameters upto date in client process
virtual void ioConfigChanged(int event, int ioHandle, void *param2);
};
class AudioPolicyServiceClient: public IBinder::DeathRecipient
{
public:
AudioPolicyServiceClient() {
}
// DeathRecipient
virtual void binderDied(const wp<IBinder>& who);
};
static sp<AudioFlingerClient> gAudioFlingerClient;
static sp<AudioPolicyServiceClient> gAudioPolicyServiceClient;
friend class AudioFlingerClient;
friend class AudioPolicyServiceClient;
static Mutex gLock;
static sp<IAudioFlinger> gAudioFlinger;
static audio_error_callback gAudioErrorCallback;
static size_t gInBuffSize;
// previous parameters for recording buffer size queries
static uint32_t gPrevInSamplingRate;
static int gPrevInFormat;
static int gPrevInChannelCount;
static int gPhoneState;
static sp<IAudioPolicyService> gAudioPolicyService;
// mapping between stream types and outputs
static DefaultKeyedVector<int, audio_io_handle_t> gStreamOutputMap;
// list of output descritor containing cached parameters (sampling rate, framecount, channel count...)
static DefaultKeyedVector<audio_io_handle_t, OutputDescriptor *> gOutputs;
};
class AudioParameter {
public:
AudioParameter() {}
AudioParameter(const String8& keyValuePairs);
virtual ~AudioParameter();
// reserved parameter keys for changing standard parameters with setParameters() function.
// Using these keys is mandatory for AudioFlinger to properly monitor audio output/input
// configuration changes and act accordingly.
// keyRouting: to change audio routing, value is an int in AudioSystem::audio_devices
// keySamplingRate: to change sampling rate routing, value is an int
// keyFormat: to change audio format, value is an int in AudioSystem::audio_format
// keyChannels: to change audio channel configuration, value is an int in AudioSystem::audio_channels
// keyFrameCount: to change audio output frame count, value is an int
// keyInputSource: to change audio input source, value is an int in audio_source
// (defined in media/mediarecorder.h)
static const char *keyRouting;
static const char *keySamplingRate;
static const char *keyFormat;
static const char *keyChannels;
static const char *keyFrameCount;
static const char *keyInputSource;
String8 toString();
status_t add(const String8& key, const String8& value);
status_t addInt(const String8& key, const int value);
status_t addFloat(const String8& key, const float value);
status_t remove(const String8& key);
status_t get(const String8& key, String8& value);
status_t getInt(const String8& key, int& value);
status_t getFloat(const String8& key, float& value);
status_t getAt(size_t index, String8& key, String8& value);
size_t size() { return mParameters.size(); }
private:
String8 mKeyValuePairs;
KeyedVector <String8, String8> mParameters;
};
}; // namespace android
#endif /*ANDROID_AUDIOSYSTEM_H_*/
+517
View File
@@ -0,0 +1,517 @@
/*
* Copyright (C) 2007 The Android Open Source Project
* Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
*
* 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_AUDIOTRACK_H
#define ANDROID_AUDIOTRACK_H
#include <stdint.h>
#include <sys/types.h>
#include <media/IAudioFlinger.h>
#include <media/IAudioTrack.h>
#include <media/AudioSystem.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>
#include <binder/IInterface.h>
#include <binder/IMemory.h>
#include <utils/threads.h>
namespace android {
// ----------------------------------------------------------------------------
class audio_track_cblk_t;
// ----------------------------------------------------------------------------
class AudioTrack
{
public:
enum channel_index {
MONO = 0,
LEFT = 0,
RIGHT = 1
};
/* Events used by AudioTrack callback function (audio_track_cblk_t).
*/
enum event_type {
EVENT_MORE_DATA = 0, // Request to write more data to PCM buffer.
EVENT_UNDERRUN = 1, // PCM buffer underrun occured.
EVENT_LOOP_END = 2, // Sample loop end was reached; playback restarted from loop start if loop count was not 0.
EVENT_MARKER = 3, // Playback head is at the specified marker position (See setMarkerPosition()).
EVENT_NEW_POS = 4, // Playback head is at a new position (See setPositionUpdatePeriod()).
EVENT_BUFFER_END = 5 // Playback head is at the end of the buffer.
};
/* Create Buffer on the stack and pass it to obtainBuffer()
* and releaseBuffer().
*/
class Buffer
{
public:
enum {
MUTE = 0x00000001
};
uint32_t flags;
int channelCount;
int format;
size_t frameCount;
size_t size;
union {
void* raw;
short* i16;
int8_t* i8;
};
};
/* As a convenience, if a callback is supplied, a handler thread
* is automatically created with the appropriate priority. This thread
* invokes the callback when a new buffer becomes availlable or an underrun condition occurs.
* Parameters:
*
* event: type of event notified (see enum AudioTrack::event_type).
* user: Pointer to context for use by the callback receiver.
* info: Pointer to optional parameter according to event type:
* - EVENT_MORE_DATA: pointer to AudioTrack::Buffer struct. The callback must not write
* more bytes than indicated by 'size' field and update 'size' if less bytes are
* written.
* - EVENT_UNDERRUN: unused.
* - EVENT_LOOP_END: pointer to an int indicating the number of loops remaining.
* - EVENT_MARKER: pointer to an uin32_t containing the marker position in frames.
* - EVENT_NEW_POS: pointer to an uin32_t containing the new position in frames.
* - EVENT_BUFFER_END: unused.
*/
typedef void (*callback_t)(int event, void* user, void *info);
/* Returns the minimum frame count required for the successful creation of
* an AudioTrack object.
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation
* - NO_INIT: audio server or audio hardware not initialized
*/
static status_t getMinFrameCount(int* frameCount,
int streamType =-1,
uint32_t sampleRate = 0);
/* Constructs an uninitialized AudioTrack. No connection with
* AudioFlinger takes place.
*/
AudioTrack();
/* Creates an audio track and registers it with AudioFlinger.
* Once created, the track needs to be started before it can be used.
* Unspecified values are set to the audio hardware's current
* values.
*
* Parameters:
*
* streamType: Select the type of audio stream this track is attached to
* (e.g. AudioSystem::MUSIC).
* sampleRate: Track sampling rate in Hz.
* format: Audio format (e.g AudioSystem::PCM_16_BIT for signed
* 16 bits per sample).
* channels: Channel mask: see AudioSystem::audio_channels.
* frameCount: Total size of track PCM buffer in frames. This defines the
* latency of the track.
* flags: Reserved for future use.
* cbf: Callback function. If not null, this function is called periodically
* to request new PCM data.
* notificationFrames: The callback function is called each time notificationFrames PCM
* frames have been comsumed from track input buffer.
* user Context for use by the callback receiver.
*/
AudioTrack( int streamType,
uint32_t sampleRate = 0,
int format = 0,
int channels = 0,
int frameCount = 0,
uint32_t flags = 0,
callback_t cbf = 0,
void* user = 0,
int notificationFrames = 0,
int sessionId = 0);
/* Creates an audio track and registers it with AudioFlinger. With this constructor,
* The PCM data to be rendered by AudioTrack is passed in a shared memory buffer
* identified by the argument sharedBuffer. This prototype is for static buffer playback.
* PCM data must be present into memory before the AudioTrack is started.
* The Write() and Flush() methods are not supported in this case.
* It is recommented to pass a callback function to be notified of playback end by an
* EVENT_UNDERRUN event.
*/
AudioTrack( int streamType,
uint32_t sampleRate = 0,
int format = 0,
int channels = 0,
const sp<IMemory>& sharedBuffer = 0,
uint32_t flags = 0,
callback_t cbf = 0,
void* user = 0,
int notificationFrames = 0,
int sessionId = 0);
/* Creates an audio track and registers it with AudioFlinger. With this constructor,
* session ID of compressed stream can be registered AudioFlinger and AudioHardware,
* for routing purpose.
*/
AudioTrack( int streamType,
uint32_t sampleRate = 0,
int format = 0,
int channels = 0,
uint32_t flags = 0,
int sessionId = 0,
int lpaSessionId =-1);
/* Terminates the AudioTrack and unregisters it from AudioFlinger.
* Also destroys all resources assotiated with the AudioTrack.
*/
~AudioTrack();
/* Initialize an uninitialized AudioTrack.
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful intialization
* - INVALID_OPERATION: AudioTrack is already intitialized
* - BAD_VALUE: invalid parameter (channels, format, sampleRate...)
* - NO_INIT: audio server or audio hardware not initialized
* */
status_t set(int streamType =-1,
uint32_t sampleRate = 0,
int format = 0,
int channels = 0,
int frameCount = 0,
uint32_t flags = 0,
callback_t cbf = 0,
void* user = 0,
int notificationFrames = 0,
const sp<IMemory>& sharedBuffer = 0,
bool threadCanCallJava = false,
int sessionId = 0);
/* Initialize an AudioTrack and registers session Id for Tunneled audio decoding.
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful intialization
* - INVALID_OPERATION: AudioTrack is already intitialized
* - BAD_VALUE: invalid parameter (channels, format, sampleRate...)
* - NO_INIT: audio server or audio hardware not initialized
* */
status_t set(int streamType =-1,
uint32_t sampleRate = 0,
int format = 0,
int channels = 0,
uint32_t flags = 0,
int sessionId = 0,
int lpaSessionId =-1);
/* Result of constructing the AudioTrack. This must be checked
* before using any AudioTrack API (except for set()), using
* an uninitialized AudioTrack produces undefined results.
* See set() method above for possible return codes.
*/
status_t initCheck() const;
/* Returns this track's latency in milliseconds.
* This includes the latency due to AudioTrack buffer size, AudioMixer (if any)
* and audio hardware driver.
*/
uint32_t latency() const;
/* getters, see constructor */
int streamType() const;
int format() const;
int channelCount() const;
uint32_t frameCount() const;
int frameSize() const;
sp<IMemory>& sharedBuffer();
/* After it's created the track is not active. Call start() to
* make it active. If set, the callback will start being called.
*/
void start();
/* Stop a track. If set, the callback will cease being called and
* obtainBuffer returns STOPPED. Note that obtainBuffer() still works
* and will fill up buffers until the pool is exhausted.
*/
void stop();
bool stopped() const;
/* flush a stopped track. All pending buffers are discarded.
* This function has no effect if the track is not stoped.
*/
void flush();
/* Pause a track. If set, the callback will cease being called and
* obtainBuffer returns STOPPED. Note that obtainBuffer() still works
* and will fill up buffers until the pool is exhausted.
*/
void pause();
/* mute or unmutes this track.
* While mutted, the callback, if set, is still called.
*/
void mute(bool);
bool muted() const;
/* set volume for this track, mostly used for games' sound effects
* left and right volumes. Levels must be <= 1.0.
*/
status_t setVolume(float left, float right);
void getVolume(float* left, float* right);
/* set the send level for this track. An auxiliary effect should be attached
* to the track with attachEffect(). Level must be <= 1.0.
*/
status_t setAuxEffectSendLevel(float level);
void getAuxEffectSendLevel(float* level);
/* set sample rate for this track, mostly used for games' sound effects
*/
status_t setSampleRate(int sampleRate);
uint32_t getSampleRate();
/* Enables looping and sets the start and end points of looping.
*
* Parameters:
*
* loopStart: loop start expressed as the number of PCM frames played since AudioTrack start.
* loopEnd: loop end expressed as the number of PCM frames played since AudioTrack start.
* loopCount: number of loops to execute. Calling setLoop() with loopCount == 0 cancels any pending or
* active loop. loopCount = -1 means infinite looping.
*
* For proper operation the following condition must be respected:
* (loopEnd-loopStart) <= framecount()
*/
status_t setLoop(uint32_t loopStart, uint32_t loopEnd, int loopCount);
status_t getLoop(uint32_t *loopStart, uint32_t *loopEnd, int *loopCount);
/* Sets marker position. When playback reaches the number of frames specified, a callback with event
* type EVENT_MARKER is called. Calling setMarkerPosition with marker == 0 cancels marker notification
* callback.
* If the AudioTrack has been opened with no callback function associated, the operation will fail.
*
* Parameters:
*
* marker: marker position expressed in frames.
*
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation
* - INVALID_OPERATION: the AudioTrack has no callback installed.
*/
status_t setMarkerPosition(uint32_t marker);
status_t getMarkerPosition(uint32_t *marker);
/* Sets position update period. Every time the number of frames specified has been played,
* a callback with event type EVENT_NEW_POS is called.
* Calling setPositionUpdatePeriod with updatePeriod == 0 cancels new position notification
* callback.
* If the AudioTrack has been opened with no callback function associated, the operation will fail.
*
* Parameters:
*
* updatePeriod: position update notification period expressed in frames.
*
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation
* - INVALID_OPERATION: the AudioTrack has no callback installed.
*/
status_t setPositionUpdatePeriod(uint32_t updatePeriod);
status_t getPositionUpdatePeriod(uint32_t *updatePeriod);
/* Sets playback head position within AudioTrack buffer. The new position is specified
* in number of frames.
* This method must be called with the AudioTrack in paused or stopped state.
* Note that the actual position set is <position> modulo the AudioTrack buffer size in frames.
* Therefore using this method makes sense only when playing a "static" audio buffer
* as opposed to streaming.
* The getPosition() method on the other hand returns the total number of frames played since
* playback start.
*
* Parameters:
*
* position: New playback head position within AudioTrack buffer.
*
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation
* - INVALID_OPERATION: the AudioTrack is not stopped.
* - BAD_VALUE: The specified position is beyond the number of frames present in AudioTrack buffer
*/
status_t setPosition(uint32_t position);
status_t getPosition(uint32_t *position);
/* Forces AudioTrack buffer full condition. When playing a static buffer, this method avoids
* rewriting the buffer before restarting playback after a stop.
* This method must be called with the AudioTrack in paused or stopped state.
*
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation
* - INVALID_OPERATION: the AudioTrack is not stopped.
*/
status_t reload();
/* returns a handle on the audio output used by this AudioTrack.
*
* Parameters:
* none.
*
* Returned value:
* handle on audio hardware output
*/
audio_io_handle_t getOutput();
/* returns the unique ID associated to this track.
*
* Parameters:
* none.
*
* Returned value:
* AudioTrack ID.
*/
int getSessionId();
/* Attach track auxiliary output to specified effect. Used effectId = 0
* to detach track from effect.
*
* Parameters:
*
* effectId: effectId obtained from AudioEffect::id().
*
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful operation
* - INVALID_OPERATION: the effect is not an auxiliary effect.
* - BAD_VALUE: The specified effect ID is invalid
*/
status_t attachAuxEffect(int effectId);
/* obtains a buffer of "frameCount" frames. The buffer must be
* filled entirely. If the track is stopped, obtainBuffer() returns
* STOPPED instead of NO_ERROR as long as there are buffers availlable,
* at which point NO_MORE_BUFFERS is returned.
* Buffers will be returned until the pool (buffercount())
* is exhausted, at which point obtainBuffer() will either block
* or return WOULD_BLOCK depending on the value of the "blocking"
* parameter.
*/
enum {
NO_MORE_BUFFERS = 0x80000001,
STOPPED = 1
};
status_t obtainBuffer(Buffer* audioBuffer, int32_t waitCount);
void releaseBuffer(Buffer* audioBuffer);
/* As a convenience we provide a write() interface to the audio buffer.
* This is implemented on top of lockBuffer/unlockBuffer. For best
* performance
*
*/
ssize_t write(const void* buffer, size_t size);
/*
* Dumps the state of an audio track.
*/
status_t dump(int fd, const Vector<String16>& args) const;
private:
/* copying audio tracks is not allowed */
AudioTrack(const AudioTrack& other);
AudioTrack& operator = (const AudioTrack& other);
/* a small internal class to handle the callback */
class AudioTrackThread : public Thread
{
public:
AudioTrackThread(AudioTrack& receiver, bool bCanCallJava = false);
private:
friend class AudioTrack;
virtual bool threadLoop();
virtual status_t readyToRun();
virtual void onFirstRef();
AudioTrack& mReceiver;
Mutex mLock;
};
bool processAudioBuffer(const sp<AudioTrackThread>& thread);
status_t createTrack(int streamType,
uint32_t sampleRate,
int format,
int channelCount,
int frameCount,
uint32_t flags,
const sp<IMemory>& sharedBuffer,
audio_io_handle_t output,
bool enforceFrameCount);
sp<IAudioTrack> mAudioTrack;
sp<IMemory> mCblkMemory;
sp<AudioTrackThread> mAudioTrackThread;
float mVolume[2];
float mSendLevel;
uint32_t mFrameCount;
audio_track_cblk_t* mCblk;
uint8_t mStreamType;
uint8_t mFormat;
uint8_t mChannelCount;
uint8_t mMuted;
uint32_t mChannels;
status_t mStatus;
uint32_t mLatency;
volatile int32_t mActive;
callback_t mCbf;
void* mUserData;
uint32_t mNotificationFramesReq; // requested number of frames between each notification callback
uint32_t mNotificationFramesAct; // actual number of frames between each notification callback
sp<IMemory> mSharedBuffer;
int mLoopCount;
uint32_t mRemainingFrames;
uint32_t mMarkerPosition;
bool mMarkerReached;
uint32_t mNewPosition;
uint32_t mUpdatePeriod;
uint32_t mFlags;
audio_io_handle_t mAudioSession;
int mSessionId;
int mAuxEffectId;
};
}; // namespace android
#endif // ANDROID_AUDIOTRACK_H
+802
View File
@@ -0,0 +1,802 @@
/*
* Copyright (C) 2010 The Android Open Source Project
* Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
*
* 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_EFFECTAPI_H_
#define ANDROID_EFFECTAPI_H_
#include <errno.h>
#include <stdint.h>
#include <sys/types.h>
#if __cplusplus
extern "C" {
#endif
/////////////////////////////////////////////////
// Effect control interface
/////////////////////////////////////////////////
// The effect control interface is exposed by each effect engine implementation. It consists of
// a set of functions controlling the configuration, activation and process of the engine.
// The functions are grouped in a structure of type effect_interface_s:
// struct effect_interface_s {
// effect_process_t process;
// effect_command_t command;
// };
// effect_interface_t: Effect control interface handle.
// The effect_interface_t serves two purposes regarding the implementation of the effect engine:
// - 1 it is the address of a pointer to an effect_interface_s structure where the functions
// of the effect control API for a particular effect are located.
// - 2 it is the address of the context of a particular effect instance.
// A typical implementation in the effect library would define a structure as follows:
// struct effect_module_s {
// const struct effect_interface_s *itfe;
// effect_config_t config;
// effect_context_t context;
// }
// The implementation of EffectCreate() function would then allocate a structure of this
// type and return its address as effect_interface_t
typedef struct effect_interface_s **effect_interface_t;
// Effect API version 1.0
#define EFFECT_API_VERSION 0x0100 // Format 0xMMmm MM: Major version, mm: minor version
// Maximum length of character strings in structures defines by this API.
#define EFFECT_STRING_LEN_MAX 64
//
//--- Effect descriptor structure effect_descriptor_t
//
// Unique effect ID (can be generated from the following site:
// http://www.itu.int/ITU-T/asn1/uuid.html)
// This format is used for both "type" and "uuid" fields of the effect descriptor structure.
// - When used for effect type and the engine is implementing and effect corresponding to a standard
// OpenSL ES interface, this ID must be the one defined in OpenSLES_IID.h for that interface.
// - When used as uuid, it should be a unique UUID for this particular implementation.
typedef struct effect_uuid_s {
uint32_t timeLow;
uint16_t timeMid;
uint16_t timeHiAndVersion;
uint16_t clockSeq;
uint8_t node[6];
} effect_uuid_t;
// NULL UUID definition (matches SL_IID_NULL_)
#define EFFECT_UUID_INITIALIZER { 0xec7178ec, 0xe5e1, 0x4432, 0xa3f4, \
{ 0x46, 0x57, 0xe6, 0x79, 0x52, 0x10 } }
static const effect_uuid_t EFFECT_UUID_NULL_ = EFFECT_UUID_INITIALIZER;
const effect_uuid_t * const EFFECT_UUID_NULL = &EFFECT_UUID_NULL_;
const char * const EFFECT_UUID_NULL_STR = "ec7178ec-e5e1-4432-a3f4-4657e6795210";
// The effect descriptor contains necessary information to facilitate the enumeration of the effect
// engines present in a library.
typedef struct effect_descriptor_s {
effect_uuid_t type; // UUID of to the OpenSL ES interface implemented by this effect
effect_uuid_t uuid; // UUID for this particular implementation
uint16_t apiVersion; // Version of the effect API implemented: matches EFFECT_API_VERSION
uint32_t flags; // effect engine capabilities/requirements flags (see below)
uint16_t cpuLoad; // CPU load indication (see below)
uint16_t memoryUsage; // Data Memory usage (see below)
char name[EFFECT_STRING_LEN_MAX]; // human readable effect name
char implementor[EFFECT_STRING_LEN_MAX]; // human readable effect implementor name
} effect_descriptor_t;
// CPU load and memory usage indication: each effect implementation must provide an indication of
// its CPU and memory usage for the audio effect framework to limit the number of effects
// instantiated at a given time on a given platform.
// The CPU load is expressed in 0.1 MIPS units as estimated on an ARM9E core (ARMv5TE) with 0 WS.
// The memory usage is expressed in KB and includes only dynamically allocated memory
// Definitions for flags field of effect descriptor.
// +---------------------------+-----------+-----------------------------------
// | description | bits | values
// +---------------------------+-----------+-----------------------------------
// | connection mode | 0..1 | 0 insert: after track process
// | | | 1 auxiliary: connect to track auxiliary
// | | | output and use send level
// | | | 2 replace: replaces track process function;
// | | | must implement SRC, volume and mono to stereo.
// | | | 3 reserved
// +---------------------------+-----------+-----------------------------------
// | insertion preference | 2..4 | 0 none
// | | | 1 first of the chain
// | | | 2 last of the chain
// | | | 3 exclusive (only effect in the insert chain)
// | | | 4..7 reserved
// +---------------------------+-----------+-----------------------------------
// | Volume management | 5..6 | 0 none
// | | | 1 implements volume control
// | | | 2 requires volume indication
// | | | 3 reserved
// +---------------------------+-----------+-----------------------------------
// | Device indication | 7..8 | 0 none
// | | | 1 requires device updates
// | | | 2..3 reserved
// +---------------------------+-----------+-----------------------------------
// | Sample input mode | 9..10 | 0 direct: process() function or EFFECT_CMD_CONFIGURE
// | | | command must specify a buffer descriptor
// | | | 1 provider: process() function uses the
// | | | bufferProvider indicated by the
// | | | EFFECT_CMD_CONFIGURE command to request input.
// | | | buffers.
// | | | 2 both: both input modes are supported
// | | | 3 reserved
// +---------------------------+-----------+-----------------------------------
// | Sample output mode | 11..12 | 0 direct: process() function or EFFECT_CMD_CONFIGURE
// | | | command must specify a buffer descriptor
// | | | 1 provider: process() function uses the
// | | | bufferProvider indicated by the
// | | | EFFECT_CMD_CONFIGURE command to request output
// | | | buffers.
// | | | 2 both: both output modes are supported
// | | | 3 reserved
// +---------------------------+-----------+-----------------------------------
// | Hardware acceleration | 13..15 | 0 No hardware acceleration
// | | | 1 non tunneled hw acceleration: the process() function
// | | | reads the samples, send them to HW accelerated
// | | | effect processor, reads back the processed samples
// | | | and returns them to the output buffer.
// | | | 2 tunneled hw acceleration: the process() function is
// | | | transparent. The effect interface is only used to
// | | | control the effect engine. This mode is relevant for
// | | | global effects actually applied by the audio
// | | | hardware on the output stream.
// +---------------------------+-----------+-----------------------------------
// | Audio Mode indication | 16..17 | 0 none
// | | | 1 requires audio mode updates
// | | | 2..3 reserved
// +---------------------------+-----------+-----------------------------------
// Insert mode
#define EFFECT_FLAG_TYPE_MASK 0x00000003
#define EFFECT_FLAG_TYPE_INSERT 0x00000000
#define EFFECT_FLAG_TYPE_AUXILIARY 0x00000001
#define EFFECT_FLAG_TYPE_REPLACE 0x00000002
// Insert preference
#define EFFECT_FLAG_INSERT_MASK 0x0000001C
#define EFFECT_FLAG_INSERT_ANY 0x00000000
#define EFFECT_FLAG_INSERT_FIRST 0x00000004
#define EFFECT_FLAG_INSERT_LAST 0x00000008
#define EFFECT_FLAG_INSERT_EXCLUSIVE 0x0000000C
// Volume control
#define EFFECT_FLAG_VOLUME_MASK 0x00000060
#define EFFECT_FLAG_VOLUME_CTRL 0x00000020
#define EFFECT_FLAG_VOLUME_IND 0x00000040
#define EFFECT_FLAG_VOLUME_NONE 0x00000000
// Device indication
#define EFFECT_FLAG_DEVICE_MASK 0x00000180
#define EFFECT_FLAG_DEVICE_IND 0x00000080
#define EFFECT_FLAG_DEVICE_NONE 0x00000000
// Sample input modes
#define EFFECT_FLAG_INPUT_MASK 0x00000600
#define EFFECT_FLAG_INPUT_DIRECT 0x00000000
#define EFFECT_FLAG_INPUT_PROVIDER 0x00000200
#define EFFECT_FLAG_INPUT_BOTH 0x00000400
// Sample output modes
#define EFFECT_FLAG_OUTPUT_MASK 0x00001800
#define EFFECT_FLAG_OUTPUT_DIRECT 0x00000000
#define EFFECT_FLAG_OUTPUT_PROVIDER 0x00000800
#define EFFECT_FLAG_OUTPUT_BOTH 0x00001000
// Hardware acceleration mode
#define EFFECT_FLAG_HW_ACC_MASK 0x00006000
#define EFFECT_FLAG_HW_ACC_SIMPLE 0x00002000
#define EFFECT_FLAG_HW_ACC_TUNNEL 0x00004000
// Audio mode indication
#define EFFECT_FLAG_AUDIO_MODE_MASK 0x00018000
#define EFFECT_FLAG_AUDIO_MODE_IND 0x00008000
#define EFFECT_FLAG_AUDIO_MODE_NONE 0x00000000
// Forward definition of type audio_buffer_t
typedef struct audio_buffer_s audio_buffer_t;
////////////////////////////////////////////////////////////////////////////////
//
// Function: process
//
// Description: Effect process function. Takes input samples as specified
// (count and location) in input buffer descriptor and output processed
// samples as specified in output buffer descriptor. If the buffer descriptor
// is not specified the function must use either the buffer or the
// buffer provider function installed by the EFFECT_CMD_CONFIGURE command.
// The effect framework will call the process() function after the EFFECT_CMD_ENABLE
// command is received and until the EFFECT_CMD_DISABLE is received. When the engine
// receives the EFFECT_CMD_DISABLE command it should turn off the effect gracefully
// and when done indicate that it is OK to stop calling the process() function by
// returning the -ENODATA status.
//
// NOTE: the process() function implementation should be "real-time safe" that is
// it should not perform blocking calls: malloc/free, sleep, read/write/open/close,
// pthread_cond_wait/pthread_mutex_lock...
//
// Input:
// effect_interface_t: handle to the effect interface this function
// is called on.
// inBuffer: buffer descriptor indicating where to read samples to process.
// If NULL, use the configuration passed by EFFECT_CMD_CONFIGURE command.
//
// inBuffer: buffer descriptor indicating where to write processed samples.
// If NULL, use the configuration passed by EFFECT_CMD_CONFIGURE command.
//
// Output:
// returned value: 0 successful operation
// -ENODATA the engine has finished the disable phase and the framework
// can stop calling process()
// -EINVAL invalid interface handle or
// invalid input/output buffer description
////////////////////////////////////////////////////////////////////////////////
typedef int32_t (*effect_process_t)(effect_interface_t self,
audio_buffer_t *inBuffer,
audio_buffer_t *outBuffer);
////////////////////////////////////////////////////////////////////////////////
//
// Function: command
//
// Description: Send a command and receive a response to/from effect engine.
//
// Input:
// effect_interface_t: handle to the effect interface this function
// is called on.
// cmdCode: command code: the command can be a standardized command defined in
// effect_command_e (see below) or a proprietary command.
// cmdSize: size of command in bytes
// pCmdData: pointer to command data
// pReplyData: pointer to reply data
//
// Input/Output:
// replySize: maximum size of reply data as input
// actual size of reply data as output
//
// Output:
// returned value: 0 successful operation
// -EINVAL invalid interface handle or
// invalid command/reply size or format according to command code
// The return code should be restricted to indicate problems related to the this
// API specification. Status related to the execution of a particular command should be
// indicated as part of the reply field.
//
// *pReplyData updated with command response
//
////////////////////////////////////////////////////////////////////////////////
typedef int32_t (*effect_command_t)(effect_interface_t self,
uint32_t cmdCode,
uint32_t cmdSize,
void *pCmdData,
uint32_t *replySize,
void *pReplyData);
// Effect control interface definition
struct effect_interface_s {
effect_process_t process;
effect_command_t command;
};
//
//--- Standardized command codes for command() function
//
enum effect_command_e {
EFFECT_CMD_INIT, // initialize effect engine
EFFECT_CMD_CONFIGURE, // configure effect engine (see effect_config_t)
EFFECT_CMD_RESET, // reset effect engine
EFFECT_CMD_ENABLE, // enable effect process
EFFECT_CMD_DISABLE, // disable effect process
EFFECT_CMD_SET_PARAM, // set parameter immediately (see effect_param_t)
EFFECT_CMD_SET_PARAM_DEFERRED, // set parameter deferred
EFFECT_CMD_SET_PARAM_COMMIT, // commit previous set parameter deferred
EFFECT_CMD_GET_PARAM, // get parameter
EFFECT_CMD_SET_DEVICE, // set audio device (see audio_device_e)
EFFECT_CMD_SET_VOLUME, // set volume
EFFECT_CMD_SET_AUDIO_MODE, // set the audio mode (normal, ring, ...)
EFFECT_CMD_FIRST_PROPRIETARY = 0x10000 // first proprietary command code
};
//==================================================================================================
// command: EFFECT_CMD_INIT
//--------------------------------------------------------------------------------------------------
// description:
// Initialize effect engine: All configurations return to default
//--------------------------------------------------------------------------------------------------
// command format:
// size: 0
// data: N/A
//--------------------------------------------------------------------------------------------------
// reply format:
// size: sizeof(int)
// data: status
//==================================================================================================
// command: EFFECT_CMD_CONFIGURE
//--------------------------------------------------------------------------------------------------
// description:
// Apply new audio parameters configurations for input and output buffers
//--------------------------------------------------------------------------------------------------
// command format:
// size: sizeof(effect_config_t)
// data: effect_config_t
//--------------------------------------------------------------------------------------------------
// reply format:
// size: sizeof(int)
// data: status
//==================================================================================================
// command: EFFECT_CMD_RESET
//--------------------------------------------------------------------------------------------------
// description:
// Reset the effect engine. Keep configuration but resets state and buffer content
//--------------------------------------------------------------------------------------------------
// command format:
// size: 0
// data: N/A
//--------------------------------------------------------------------------------------------------
// reply format:
// size: 0
// data: N/A
//==================================================================================================
// command: EFFECT_CMD_ENABLE
//--------------------------------------------------------------------------------------------------
// description:
// Enable the process. Called by the framework before the first call to process()
//--------------------------------------------------------------------------------------------------
// command format:
// size: 0
// data: N/A
//--------------------------------------------------------------------------------------------------
// reply format:
// size: sizeof(int)
// data: status
//==================================================================================================
// command: EFFECT_CMD_DISABLE
//--------------------------------------------------------------------------------------------------
// description:
// Disable the process. Called by the framework after the last call to process()
//--------------------------------------------------------------------------------------------------
// command format:
// size: 0
// data: N/A
//--------------------------------------------------------------------------------------------------
// reply format:
// size: sizeof(int)
// data: status
//==================================================================================================
// command: EFFECT_CMD_SET_PARAM
//--------------------------------------------------------------------------------------------------
// description:
// Set a parameter and apply it immediately
//--------------------------------------------------------------------------------------------------
// command format:
// size: sizeof(effect_param_t) + size of param and value
// data: effect_param_t + param + value. See effect_param_t definition below for value offset
//--------------------------------------------------------------------------------------------------
// reply format:
// size: sizeof(int)
// data: status
//==================================================================================================
// command: EFFECT_CMD_SET_PARAM_DEFERRED
//--------------------------------------------------------------------------------------------------
// description:
// Set a parameter but apply it only when receiving EFFECT_CMD_SET_PARAM_COMMIT command
//--------------------------------------------------------------------------------------------------
// command format:
// size: sizeof(effect_param_t) + size of param and value
// data: effect_param_t + param + value. See effect_param_t definition below for value offset
//--------------------------------------------------------------------------------------------------
// reply format:
// size: 0
// data: N/A
//==================================================================================================
// command: EFFECT_CMD_SET_PARAM_COMMIT
//--------------------------------------------------------------------------------------------------
// description:
// Apply all previously received EFFECT_CMD_SET_PARAM_DEFERRED commands
//--------------------------------------------------------------------------------------------------
// command format:
// size: 0
// data: N/A
//--------------------------------------------------------------------------------------------------
// reply format:
// size: sizeof(int)
// data: status
//==================================================================================================
// command: EFFECT_CMD_GET_PARAM
//--------------------------------------------------------------------------------------------------
// description:
// Get a parameter value
//--------------------------------------------------------------------------------------------------
// command format:
// size: sizeof(effect_param_t) + size of param
// data: effect_param_t + param
//--------------------------------------------------------------------------------------------------
// reply format:
// size: sizeof(effect_param_t) + size of param and value
// data: effect_param_t + param + value. See effect_param_t definition below for value offset
//==================================================================================================
// command: EFFECT_CMD_SET_DEVICE
//--------------------------------------------------------------------------------------------------
// description:
// Set the rendering device the audio output path is connected to. See audio_device_e for device
// values.
// The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this
// command when the device changes
//--------------------------------------------------------------------------------------------------
// command format:
// size: sizeof(uint32_t)
// data: audio_device_e
//--------------------------------------------------------------------------------------------------
// reply format:
// size: 0
// data: N/A
//==================================================================================================
// command: EFFECT_CMD_SET_VOLUME
//--------------------------------------------------------------------------------------------------
// description:
// Set and get volume. Used by audio framework to delegate volume control to effect engine.
// The effect implementation must set EFFECT_FLAG_VOLUME_IND or EFFECT_FLAG_VOLUME_CTRL flag in
// its descriptor to receive this command before every call to process() function
// If EFFECT_FLAG_VOLUME_CTRL flag is set in the effect descriptor, the effect engine must return
// the volume that should be applied before the effect is processed. The overall volume (the volume
// actually applied by the effect engine multiplied by the returned value) should match the value
// indicated in the command.
//--------------------------------------------------------------------------------------------------
// command format:
// size: n * sizeof(uint32_t)
// data: volume for each channel defined in effect_config_t for output buffer expressed in
// 8.24 fixed point format
//--------------------------------------------------------------------------------------------------
// reply format:
// size: n * sizeof(uint32_t) / 0
// data: - if EFFECT_FLAG_VOLUME_CTRL is set in effect descriptor:
// volume for each channel defined in effect_config_t for output buffer expressed in
// 8.24 fixed point format
// - if EFFECT_FLAG_VOLUME_CTRL is not set in effect descriptor:
// N/A
// It is legal to receive a null pointer as pReplyData in which case the effect framework has
// delegated volume control to another effect
//==================================================================================================
// command: EFFECT_CMD_SET_AUDIO_MODE
//--------------------------------------------------------------------------------------------------
// description:
// Set the audio mode. The effect implementation must set EFFECT_FLAG_AUDIO_MODE_IND flag in its
// descriptor to receive this command when the audio mode changes.
//--------------------------------------------------------------------------------------------------
// command format:
// size: sizeof(uint32_t)
// data: audio_mode_e
//--------------------------------------------------------------------------------------------------
// reply format:
// size: 0
// data: N/A
//==================================================================================================
// command: EFFECT_CMD_FIRST_PROPRIETARY
//--------------------------------------------------------------------------------------------------
// description:
// All proprietary effect commands must use command codes above this value. The size and format of
// command and response fields is free in this case
//==================================================================================================
// Audio buffer descriptor used by process(), bufferProvider() functions and buffer_config_t
// structure. Multi-channel audio is always interleaved. The channel order is from LSB to MSB with
// regard to the channel mask definition in audio_channels_e e.g :
// Stereo: left, right
// 5 point 1: front left, front right, front center, low frequency, back left, back right
// The buffer size is expressed in frame count, a frame being composed of samples for all
// channels at a given time. Frame size for unspecified format (AUDIO_FORMAT_OTHER) is 8 bit by
// definition
struct audio_buffer_s {
size_t frameCount; // number of frames in buffer
union {
void* raw; // raw pointer to start of buffer
int32_t* s32; // pointer to signed 32 bit data at start of buffer
int16_t* s16; // pointer to signed 16 bit data at start of buffer
uint8_t* u8; // pointer to unsigned 8 bit data at start of buffer
};
};
// The buffer_provider_s structure contains functions that can be used
// by the effect engine process() function to query and release input
// or output audio buffer.
// The getBuffer() function is called to retrieve a buffer where data
// should read from or written to by process() function.
// The releaseBuffer() function MUST be called when the buffer retrieved
// with getBuffer() is not needed anymore.
// The process function should use the buffer provider mechanism to retrieve
// input or output buffer if the inBuffer or outBuffer passed as argument is NULL
// and the buffer configuration (buffer_config_t) given by the EFFECT_CMD_CONFIGURE
// command did not specify an audio buffer.
typedef int32_t (* buffer_function_t)(void *cookie, audio_buffer_t *buffer);
typedef struct buffer_provider_s {
buffer_function_t getBuffer; // retrieve next buffer
buffer_function_t releaseBuffer; // release used buffer
void *cookie; // for use by client of buffer provider functions
} buffer_provider_t;
// The buffer_config_s structure specifies the input or output audio format
// to be used by the effect engine. It is part of the effect_config_t
// structure that defines both input and output buffer configurations and is
// passed by the EFFECT_CMD_CONFIGURE command.
typedef struct buffer_config_s {
audio_buffer_t buffer; // buffer for use by process() function if not passed explicitly
uint32_t samplingRate; // sampling rate
uint32_t channels; // channel mask (see audio_channels_e)
buffer_provider_t bufferProvider; // buffer provider
uint8_t format; // Audio format (see audio_format_e)
uint8_t accessMode; // read/write or accumulate in buffer (effect_buffer_access_e)
uint16_t mask; // indicates which of the above fields is valid
} buffer_config_t;
// Sample format
enum audio_format_e {
SAMPLE_FORMAT_PCM_S15, // PCM signed 16 bits
SAMPLE_FORMAT_PCM_U8, // PCM unsigned 8 bits
SAMPLE_FORMAT_PCM_S7_24, // PCM signed 7.24 fixed point representation
SAMPLE_FORMAT_OTHER // other format (e.g. compressed)
};
// Channel mask
enum audio_channels_e {
CHANNEL_FRONT_LEFT = 0x1, // front left channel
CHANNEL_FRONT_RIGHT = 0x2, // front right channel
CHANNEL_FRONT_CENTER = 0x4, // front center channel
CHANNEL_LOW_FREQUENCY = 0x8, // low frequency channel
CHANNEL_BACK_LEFT = 0x10, // back left channel
CHANNEL_BACK_RIGHT = 0x20, // back right channel
CHANNEL_FRONT_LEFT_OF_CENTER = 0x40, // front left of center channel
CHANNEL_FRONT_RIGHT_OF_CENTER = 0x80, // front right of center channel
CHANNEL_BACK_CENTER = 0x100, // back center channel
CHANNEL_MONO = CHANNEL_FRONT_LEFT,
CHANNEL_STEREO = (CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT),
CHANNEL_QUAD = (CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
CHANNEL_BACK_LEFT | CHANNEL_BACK_RIGHT),
CHANNEL_SURROUND = (CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
CHANNEL_FRONT_CENTER | CHANNEL_BACK_CENTER),
CHANNEL_5POINT1 = (CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
CHANNEL_FRONT_CENTER | CHANNEL_LOW_FREQUENCY | CHANNEL_BACK_LEFT | CHANNEL_BACK_RIGHT),
CHANNEL_7POINT1 = (CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
CHANNEL_FRONT_CENTER | CHANNEL_LOW_FREQUENCY | CHANNEL_BACK_LEFT | CHANNEL_BACK_RIGHT |
CHANNEL_FRONT_LEFT_OF_CENTER | CHANNEL_FRONT_RIGHT_OF_CENTER),
};
// Match this table with AudioSystem::audio_devices
// Render device
enum audio_device_e {
DEVICE_EARPIECE = 0x1, // earpiece
DEVICE_SPEAKER = 0x2, // speaker
DEVICE_WIRED_HEADSET = 0x4, // wired headset, with microphone
DEVICE_WIRED_HEADPHONE = 0x8, // wired headphone, without microphone
DEVICE_BLUETOOTH_SCO = 0x10, // generic bluetooth SCO
DEVICE_BLUETOOTH_SCO_HEADSET = 0x20, // bluetooth SCO headset
DEVICE_BLUETOOTH_SCO_CARKIT = 0x40, // bluetooth SCO car kit
DEVICE_BLUETOOTH_A2DP = 0x80, // generic bluetooth A2DP
DEVICE_BLUETOOTH_A2DP_HEADPHONES = 0x100, // bluetooth A2DP headphones
DEVICE_BLUETOOTH_A2DP_SPEAKER = 0x200, // bluetooth A2DP speakers
DEVICE_AUX_DIGITAL = 0x400, // digital output
DEVICE_AUX_HDMI = 0x800,
DEVICE_FM = 0x1000,
DEVICE_ANC_HEADSET = 0x2000,
DEVICE_ANC_HEADPHONE = 0x4000,
DEVICE_FM_TX = 0x8000,
};
// Audio mode
enum audio_mode_e {
AUDIO_MODE_NORMAL, // device idle
AUDIO_MODE_RINGTONE, // device ringing
AUDIO_MODE_IN_CALL // audio call connected (VoIP or telephony)
};
// Values for "accessMode" field of buffer_config_t:
// overwrite, read only, accumulate (read/modify/write)
enum effect_buffer_access_e {
EFFECT_BUFFER_ACCESS_WRITE,
EFFECT_BUFFER_ACCESS_READ,
EFFECT_BUFFER_ACCESS_ACCUMULATE
};
// Values for bit field "mask" in buffer_config_t. If a bit is set, the corresponding field
// in buffer_config_t must be taken into account when executing the EFFECT_CMD_CONFIGURE command
#define EFFECT_CONFIG_BUFFER 0x0001 // buffer field must be taken into account
#define EFFECT_CONFIG_SMP_RATE 0x0002 // samplingRate field must be taken into account
#define EFFECT_CONFIG_CHANNELS 0x0004 // channels field must be taken into account
#define EFFECT_CONFIG_FORMAT 0x0008 // format field must be taken into account
#define EFFECT_CONFIG_ACC_MODE 0x0010 // accessMode field must be taken into account
#define EFFECT_CONFIG_PROVIDER 0x0020 // bufferProvider field must be taken into account
#define EFFECT_CONFIG_ALL (EFFECT_CONFIG_BUFFER | EFFECT_CONFIG_SMP_RATE | \
EFFECT_CONFIG_CHANNELS | EFFECT_CONFIG_FORMAT | \
EFFECT_CONFIG_ACC_MODE | EFFECT_CONFIG_PROVIDER)
// effect_config_s structure describes the format of the pCmdData argument of EFFECT_CMD_CONFIGURE
// command to configure audio parameters and buffers for effect engine input and output.
typedef struct effect_config_s {
buffer_config_t inputCfg;
buffer_config_t outputCfg;;
} effect_config_t;
// effect_param_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_PARAM
// command and pCmdData and pReplyData of EFFECT_CMD_GET_PARAM command.
// psize and vsize represent the actual size of parameter and value.
//
// NOTE: the start of value field inside the data field is always on a 32 bit boundary:
//
// +-----------+
// | status | sizeof(int)
// +-----------+
// | psize | sizeof(int)
// +-----------+
// | vsize | sizeof(int)
// +-----------+
// | | | |
// ~ parameter ~ > psize |
// | | | > ((psize - 1)/sizeof(int) + 1) * sizeof(int)
// +-----------+ |
// | padding | |
// +-----------+
// | | |
// ~ value ~ > vsize
// | | |
// +-----------+
typedef struct effect_param_s {
int32_t status; // Transaction status (unused for command, used for reply)
uint32_t psize; // Parameter size
uint32_t vsize; // Value size
char data[]; // Start of Parameter + Value data
} effect_param_t;
/////////////////////////////////////////////////
// Effect library interface
/////////////////////////////////////////////////
// An effect library is required to implement and expose the following functions
// to enable effect enumeration and instantiation. The name of these functions must be as
// specified here as the effect framework will get the function address with dlsym():
//
// - effect_QueryNumberEffects_t EffectQueryNumberEffects;
// - effect_QueryEffect_t EffectQueryEffect;
// - effect_CreateEffect_t EffectCreate;
// - effect_ReleaseEffect_t EffectRelease;
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectQueryNumberEffects
//
// Description: Returns the number of different effects exposed by the
// library. Each effect must have a unique effect uuid (see
// effect_descriptor_t). This function together with EffectQueryEffect()
// is used to enumerate all effects present in the library.
//
// Input/Output:
// pNumEffects: address where the number of effects should be returned.
//
// Output:
// returned value: 0 successful operation.
// -ENODEV library failed to initialize
// -EINVAL invalid pNumEffects
// *pNumEffects: updated with number of effects in library
//
////////////////////////////////////////////////////////////////////////////////
typedef int32_t (*effect_QueryNumberEffects_t)(uint32_t *pNumEffects);
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectQueryEffect
//
// Description: Returns the descriptor of the effect engine which index is
// given as first argument.
// See effect_descriptor_t for details on effect descriptors.
// This function together with EffectQueryNumberEffects() is used to enumerate all
// effects present in the library. The enumeration sequence is:
// EffectQueryNumberEffects(&num_effects);
// for (i = 0; i < num_effects; i++)
// EffectQueryEffect(i,...);
//
// Input/Output:
// index: index of the effect
// pDescriptor: address where to return the effect descriptor.
//
// Output:
// returned value: 0 successful operation.
// -ENODEV library failed to initialize
// -EINVAL invalid pDescriptor or index
// -ENOSYS effect list has changed since last execution of
// EffectQueryNumberEffects()
// -ENOENT no more effect available
// *pDescriptor: updated with the effect descriptor.
//
////////////////////////////////////////////////////////////////////////////////
typedef int32_t (*effect_QueryEffect_t)(uint32_t index,
effect_descriptor_t *pDescriptor);
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectCreate
//
// Description: Creates an effect engine of the specified type and returns an
// effect control interface on this engine. The function will allocate the
// resources for an instance of the requested effect engine and return
// a handle on the effect control interface.
//
// Input:
// uuid: pointer to the effect uuid.
// sessionId: audio session to which this effect instance will be attached. All effects
// created with the same session ID are connected in series and process the same signal
// stream. Knowing that two effects are part of the same effect chain can help the
// library implement some kind of optimizations.
// ioId: identifies the output or input stream this effect is directed to at audio HAL.
// For future use especially with tunneled HW accelerated effects
//
// Input/Output:
// pInterface: address where to return the effect interface.
//
// Output:
// returned value: 0 successful operation.
// -ENODEV library failed to initialize
// -EINVAL invalid pEffectUuid or pInterface
// -ENOENT no effect with this uuid found
// *pInterface: updated with the effect interface handle.
//
////////////////////////////////////////////////////////////////////////////////
typedef int32_t (*effect_CreateEffect_t)(effect_uuid_t *uuid,
int32_t sessionId,
int32_t ioId,
effect_interface_t *pInterface);
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectRelease
//
// Description: Releases the effect engine whose handle is given as argument.
// All resources allocated to this particular instance of the effect are
// released.
//
// Input:
// interface: handle on the effect interface to be released.
//
// Output:
// returned value: 0 successful operation.
// -ENODEV library failed to initialize
// -EINVAL invalid interface handle
//
////////////////////////////////////////////////////////////////////////////////
typedef int32_t (*effect_ReleaseEffect_t)(effect_interface_t interface);
#if __cplusplus
} // extern "C"
#endif
#endif /*ANDROID_EFFECTAPI_H_*/
+43
View File
@@ -0,0 +1,43 @@
/*
* 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_EFFECTBASSBOOSTAPI_H_
#define ANDROID_EFFECTBASSBOOSTAPI_H_
#include <media/EffectApi.h>
#if __cplusplus
extern "C" {
#endif
#ifndef OPENSL_ES_H_
static const effect_uuid_t SL_IID_BASSBOOST_ = { 0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } };
const effect_uuid_t * const SL_IID_BASSBOOST = &SL_IID_BASSBOOST_;
#endif //OPENSL_ES_H_
/* enumerated parameter settings for BassBoost effect */
typedef enum
{
BASSBOOST_PARAM_STRENGTH_SUPPORTED,
BASSBOOST_PARAM_STRENGTH
} t_bassboost_params;
#if __cplusplus
} // extern "C"
#endif
#endif /*ANDROID_EFFECTBASSBOOSTAPI_H_*/
@@ -0,0 +1,69 @@
/*
* 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_EFFECTENVIRONMENTALREVERBAPI_H_
#define ANDROID_EFFECTENVIRONMENTALREVERBAPI_H_
#include <media/EffectApi.h>
#if __cplusplus
extern "C" {
#endif
#ifndef OPENSL_ES_H_
static const effect_uuid_t SL_IID_ENVIRONMENTALREVERB_ = { 0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, { 0x4e, 0x23, 0x4d, 0x6, 0x83, 0x9e } };
const effect_uuid_t * const SL_IID_ENVIRONMENTALREVERB = &SL_IID_ENVIRONMENTALREVERB_;
#endif //OPENSL_ES_H_
/* enumerated parameter settings for environmental reverb effect */
typedef enum
{
// Parameters below are as defined in OpenSL ES specification for environmental reverb interface
REVERB_PARAM_ROOM_LEVEL, // in millibels, range -6000 to 0
REVERB_PARAM_ROOM_HF_LEVEL, // in millibels, range -4000 to 0
REVERB_PARAM_DECAY_TIME, // in milliseconds, range 100 to 20000
REVERB_PARAM_DECAY_HF_RATIO, // in permilles, range 100 to 1000
REVERB_PARAM_REFLECTIONS_LEVEL, // in millibels, range -6000 to 0
REVERB_PARAM_REFLECTIONS_DELAY, // in milliseconds, range 0 to 65
REVERB_PARAM_REVERB_LEVEL, // in millibels, range -6000 to 0
REVERB_PARAM_REVERB_DELAY, // in milliseconds, range 0 to 65
REVERB_PARAM_DIFFUSION, // in permilles, range 0 to 1000
REVERB_PARAM_DENSITY, // in permilles, range 0 to 1000
REVERB_PARAM_PROPERTIES,
REVERB_PARAM_BYPASS
} t_env_reverb_params;
//t_reverb_settings is equal to SLEnvironmentalReverbSettings defined in OpenSL ES specification.
typedef struct s_reverb_settings {
int16_t roomLevel;
int16_t roomHFLevel;
uint32_t decayTime;
int16_t decayHFRatio;
int16_t reflectionsLevel;
uint32_t reflectionsDelay;
int16_t reverbLevel;
uint32_t reverbDelay;
int16_t diffusion;
int16_t density;
} __attribute__((packed)) t_reverb_settings;
#if __cplusplus
} // extern "C"
#endif
#endif /*ANDROID_EFFECTENVIRONMENTALREVERBAPI_H_*/
+58
View File
@@ -0,0 +1,58 @@
/*
* 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_EFFECTEQUALIZERAPI_H_
#define ANDROID_EFFECTEQUALIZERAPI_H_
#include <media/EffectApi.h>
#ifndef OPENSL_ES_H_
static const effect_uuid_t SL_IID_EQUALIZER_ = { 0x0bed4300, 0xddd6, 0x11db, 0x8f34, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } };
const effect_uuid_t * const SL_IID_EQUALIZER = &SL_IID_EQUALIZER_;
#endif //OPENSL_ES_H_
#if __cplusplus
extern "C" {
#endif
/* enumerated parameters for Equalizer effect */
typedef enum
{
EQ_PARAM_NUM_BANDS, // Gets the number of frequency bands that the equalizer supports.
EQ_PARAM_LEVEL_RANGE, // Returns the minimum and maximum band levels supported.
EQ_PARAM_BAND_LEVEL, // Gets/Sets the gain set for the given equalizer band.
EQ_PARAM_CENTER_FREQ, // Gets the center frequency of the given band.
EQ_PARAM_BAND_FREQ_RANGE, // Gets the frequency range of the given frequency band.
EQ_PARAM_GET_BAND, // Gets the band that has the most effect on the given frequency.
EQ_PARAM_CUR_PRESET, // Gets/Sets the current preset.
EQ_PARAM_GET_NUM_OF_PRESETS, // Gets the total number of presets the equalizer supports.
EQ_PARAM_GET_PRESET_NAME, // Gets the preset name based on the index.
EQ_PARAM_PROPERTIES // Gets/Sets all parameters at a time.
} t_equalizer_params;
//t_equalizer_settings groups all current equalizer setting for backup and restore.
typedef struct s_equalizer_settings {
uint16_t curPreset;
uint16_t numBands;
uint16_t bandLevels[];
} t_equalizer_settings;
#if __cplusplus
} // extern "C"
#endif
#endif /*ANDROID_EFFECTEQUALIZERAPI_H_*/
@@ -0,0 +1,55 @@
/*
* 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_EFFECTPRESETREVERBAPI_H_
#define ANDROID_EFFECTPRESETREVERBAPI_H_
#include <media/EffectApi.h>
#if __cplusplus
extern "C" {
#endif
#ifndef OPENSL_ES_H_
static const effect_uuid_t SL_IID_PRESETREVERB_ = { 0x47382d60, 0xddd8, 0x11db, 0xbf3a, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } };
const effect_uuid_t * const SL_IID_PRESETREVERB = &SL_IID_PRESETREVERB_;
#endif //OPENSL_ES_H_
/* enumerated parameter settings for preset reverb effect */
typedef enum
{
REVERB_PARAM_PRESET
} t_preset_reverb_params;
typedef enum
{
REVERB_PRESET_NONE,
REVERB_PRESET_SMALLROOM,
REVERB_PRESET_MEDIUMROOM,
REVERB_PRESET_LARGEROOM,
REVERB_PRESET_MEDIUMHALL,
REVERB_PRESET_LARGEHALL,
REVERB_PRESET_PLATE,
REVERB_PRESET_LAST = REVERB_PRESET_PLATE
} t_reverb_presets;
#if __cplusplus
} // extern "C"
#endif
#endif /*ANDROID_EFFECTPRESETREVERBAPI_H_*/
+43
View File
@@ -0,0 +1,43 @@
/*
* 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_EFFECTVIRTUALIZERAPI_H_
#define ANDROID_EFFECTVIRTUALIZERAPI_H_
#include <media/EffectApi.h>
#if __cplusplus
extern "C" {
#endif
#ifndef OPENSL_ES_H_
static const effect_uuid_t SL_IID_VIRTUALIZER_ = { 0x37cc2c00, 0xdddd, 0x11db, 0x8577, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } };
const effect_uuid_t * const SL_IID_VIRTUALIZER = &SL_IID_VIRTUALIZER_;
#endif //OPENSL_ES_H_
/* enumerated parameter settings for virtualizer effect */
typedef enum
{
VIRTUALIZER_PARAM_STRENGTH_SUPPORTED,
VIRTUALIZER_PARAM_STRENGTH
} t_virtualizer_params;
#if __cplusplus
} // extern "C"
#endif
#endif /*ANDROID_EFFECTVIRTUALIZERAPI_H_*/
+56
View File
@@ -0,0 +1,56 @@
/*
* 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_EFFECTVISUALIZERAPI_H_
#define ANDROID_EFFECTVISUALIZERAPI_H_
#include <media/EffectApi.h>
#if __cplusplus
extern "C" {
#endif
#ifndef OPENSL_ES_H_
static const effect_uuid_t SL_IID_VISUALIZATION_ =
{ 0xe46b26a0, 0xdddd, 0x11db, 0x8afd, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } };
const effect_uuid_t * const SL_IID_VISUALIZATION = &SL_IID_VISUALIZATION_;
#endif //OPENSL_ES_H_
#define VISUALIZER_CAPTURE_SIZE_MAX 1024 // maximum capture size in samples
#define VISUALIZER_CAPTURE_SIZE_MIN 128 // minimum capture size in samples
/* enumerated parameters for Visualizer effect */
typedef enum
{
VISU_PARAM_CAPTURE_SIZE, // Sets the number PCM samples in the capture.
} t_visualizer_params;
/* commands */
typedef enum
{
VISU_CMD_CAPTURE = EFFECT_CMD_FIRST_PROPRIETARY, // Gets the latest PCM capture.
}t_visualizer_cmds;
// VISU_CMD_CAPTURE retrieves the latest PCM snapshot captured by the visualizer engine.
// It returns the number of samples specified by VISU_PARAM_CAPTURE_SIZE
// in 8 bit unsigned format (0 = 0x80)
#if __cplusplus
} // extern "C"
#endif
#endif /*ANDROID_EFFECTVISUALIZERAPI_H_*/
+221
View File
@@ -0,0 +1,221 @@
/*
* 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_EFFECTSFACTORYAPI_H_
#define ANDROID_EFFECTSFACTORYAPI_H_
#include <errno.h>
#include <stdint.h>
#include <sys/types.h>
#include <media/EffectApi.h>
#if __cplusplus
extern "C" {
#endif
/////////////////////////////////////////////////
// Effect factory interface
/////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectQueryNumberEffects
//
// Description: Returns the number of different effects in all loaded libraries.
// Each effect must have a different effect uuid (see
// effect_descriptor_t). This function together with EffectQueryEffect()
// is used to enumerate all effects present in all loaded libraries.
// Each time EffectQueryNumberEffects() is called, the factory must
// reset the index of the effect descriptor returned by next call to
// EffectQueryEffect() to restart enumeration from the beginning.
//
// Input/Output:
// pNumEffects: address where the number of effects should be returned.
//
// Output:
// returned value: 0 successful operation.
// -ENODEV factory failed to initialize
// -EINVAL invalid pNumEffects
// *pNumEffects: updated with number of effects in factory
//
////////////////////////////////////////////////////////////////////////////////
int EffectQueryNumberEffects(uint32_t *pNumEffects);
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectQueryEffect
//
// Description: Returns a descriptor of the next available effect.
// See effect_descriptor_t for a details on effect descriptor.
// This function together with EffectQueryNumberEffects() is used to enumerate all
// effects present in all loaded libraries. The enumeration sequence is:
// EffectQueryNumberEffects(&num_effects);
// for (i = 0; i < num_effects; i++)
// EffectQueryEffect(i,...);
//
// Input/Output:
// pDescriptor: address where to return the effect descriptor.
//
// Output:
// returned value: 0 successful operation.
// -ENOENT no more effect available
// -ENODEV factory failed to initialize
// -EINVAL invalid pDescriptor
// -ENOSYS effect list has changed since last execution of EffectQueryNumberEffects()
// *pDescriptor: updated with the effect descriptor.
//
////////////////////////////////////////////////////////////////////////////////
int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor);
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectCreate
//
// Description: Creates an effect engine of the specified type and returns an
// effect control interface on this engine. The function will allocate the
// resources for an instance of the requested effect engine and return
// a handler on the effect control interface.
//
// Input:
// pEffectUuid: pointer to the effect uuid.
// sessionId: audio session to which this effect instance will be attached. All effects created
// with the same session ID are connected in series and process the same signal stream.
// Knowing that two effects are part of the same effect chain can help the library implement
// some kind of optimizations.
// ioId: identifies the output or input stream this effect is directed to at audio HAL. For future
// use especially with tunneled HW accelerated effects
//
// Input/Output:
// pInterface: address where to return the effect interface.
//
// Output:
// returned value: 0 successful operation.
// -ENODEV factory failed to initialize
// -EINVAL invalid pEffectUuid or pInterface
// -ENOENT no effect with this uuid found
// *pInterface: updated with the effect interface.
//
////////////////////////////////////////////////////////////////////////////////
int EffectCreate(effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t ioId, effect_interface_t *pInterface);
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectRelease
//
// Description: Releases the effect engine whose handler is given as argument.
// All resources allocated to this particular instance of the effect are
// released.
//
// Input:
// interface: handler on the effect interface to be released.
//
// Output:
// returned value: 0 successful operation.
// -ENODEV factory failed to initialize
// -EINVAL invalid interface handler
//
////////////////////////////////////////////////////////////////////////////////
int EffectRelease(effect_interface_t interface);
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectLoadLibrary
//
// Description: Loads the effect library which path is given as first argument.
// This must be the full path of a dynamic library (.so) implementing one or
// more effect engines and exposing the effect library interface described in
// EffectApi.h. The function returns a handle on the library for used by
// further call to EffectUnloadLibrary() to unload the library.
//
// Input:
// libPath: full path of the dynamic library file in the file system.
//
// handle: address where to return the library handle
//
// Output:
// returned value: 0 successful operation.
// -ENODEV effect factory not initialized or
// library could not be loaded or
// library does not implement required functions
// -EINVAL invalid libPath string or handle
//
////////////////////////////////////////////////////////////////////////////////
int EffectLoadLibrary(const char *libPath, int *handle);
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectUnloadLibrary
//
// Description: Unloads the effect library which handle is given as argument.
//
// Input:
// handle: library handle
//
// Output:
// returned value: 0 successful operation.
// -ENODEV effect factory not initialized
// -ENOENT invalid handle
//
////////////////////////////////////////////////////////////////////////////////
int EffectUnloadLibrary(int handle);
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectGetDescriptor
//
// Description: Returns the descriptor of the effect which uuid is pointed
// to by first argument.
//
// Input:
// pEffectUuid: pointer to the effect uuid.
//
// Input/Output:
// pDescriptor: address where to return the effect descriptor.
//
// Output:
// returned value: 0 successful operation.
// -ENODEV factory failed to initialize
// -EINVAL invalid pEffectUuid or pDescriptor
// -ENOENT no effect with this uuid found
// *pDescriptor: updated with the effect descriptor.
//
////////////////////////////////////////////////////////////////////////////////
int EffectGetDescriptor(effect_uuid_t *pEffectUuid, effect_descriptor_t *pDescriptor);
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectIsNullUuid
//
// Description: Helper function to compare effect uuid to EFFECT_UUID_NULL
//
// Input:
// pEffectUuid: pointer to effect uuid to compare to EFFECT_UUID_NULL.
//
// Output:
// returned value: 0 if uuid is different from EFFECT_UUID_NULL.
// 1 if uuid is equal to EFFECT_UUID_NULL.
//
////////////////////////////////////////////////////////////////////////////////
int EffectIsNullUuid(effect_uuid_t *pEffectUuid);
#if __cplusplus
} // extern "C"
#endif
#endif /*ANDROID_EFFECTSFACTORYAPI_H_*/
+211
View File
@@ -0,0 +1,211 @@
/*
* Copyright (C) 2007 The Android Open Source Project
* Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
*
* 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_IAUDIOFLINGER_H
#define ANDROID_IAUDIOFLINGER_H
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>
#include <binder/IInterface.h>
#include <media/IAudioTrack.h>
#include <media/IAudioRecord.h>
#include <media/IAudioFlingerClient.h>
#include <media/EffectApi.h>
#include <media/IEffect.h>
#include <media/IEffectClient.h>
#include <utils/String8.h>
namespace android {
// ----------------------------------------------------------------------------
class IAudioFlinger : public IInterface
{
public:
DECLARE_META_INTERFACE(AudioFlinger);
/* create an audio track and registers it with AudioFlinger.
* return null if the track cannot be created.
*/
virtual sp<IAudioTrack> createTrack(
pid_t pid,
int streamType,
uint32_t sampleRate,
int format,
int channelCount,
int frameCount,
uint32_t flags,
const sp<IMemory>& sharedBuffer,
int output,
int *sessionId,
status_t *status) = 0;
virtual void createSession(
pid_t pid,
uint32_t sampleRate,
int channelCount,
int *sessionId,
status_t *status) = 0;
virtual void deleteSession() = 0;
virtual void applyEffectsOn(
int16_t *buffer1,
int16_t *buffer2,
int size) = 0;
virtual sp<IAudioRecord> openRecord(
pid_t pid,
int input,
uint32_t sampleRate,
int format,
int channelCount,
int frameCount,
uint32_t flags,
int *sessionId,
status_t *status) = 0;
/* query the audio hardware state. This state never changes,
* and therefore can be cached.
*/
virtual uint32_t sampleRate(int output) const = 0;
virtual int channelCount(int output) const = 0;
virtual int format(int output) const = 0;
virtual size_t frameCount(int output) const = 0;
virtual uint32_t latency(int output) const = 0;
/* set/get the audio hardware state. This will probably be used by
* the preference panel, mostly.
*/
virtual status_t setMasterVolume(float value) = 0;
virtual status_t setMasterMute(bool muted) = 0;
virtual float masterVolume() const = 0;
virtual bool masterMute() const = 0;
/* set/get stream type state. This will probably be used by
* the preference panel, mostly.
*/
virtual status_t setStreamVolume(int stream, float value, int output) = 0;
virtual status_t setStreamMute(int stream, bool muted) = 0;
virtual float streamVolume(int stream, int output) const = 0;
virtual bool streamMute(int stream) const = 0;
// set audio mode
virtual status_t setMode(int mode) = 0;
// mic mute/state
virtual status_t setMicMute(bool state) = 0;
virtual bool getMicMute() const = 0;
// is any track active on this stream?
virtual bool isStreamActive(int stream) const = 0;
virtual status_t setParameters(int ioHandle, const String8& keyValuePairs) = 0;
virtual String8 getParameters(int ioHandle, const String8& keys) = 0;
// register a current process for audio output change notifications
virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0;
// retrieve the audio recording buffer size
virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount) = 0;
virtual int openOutput(uint32_t *pDevices,
uint32_t *pSamplingRate,
uint32_t *pFormat,
uint32_t *pChannels,
uint32_t *pLatencyMs,
uint32_t flags) = 0;
virtual int openSession(uint32_t *pDevices,
uint32_t *pFormat,
uint32_t flags,
int32_t stream,
int32_t sessionId){return 0;};
virtual status_t pauseSession(int output, int32_t stream) = 0;
virtual status_t resumeSession(int output, int32_t stream) = 0;
virtual status_t closeSession(int output) = 0;
virtual int openDuplicateOutput(int output1, int output2) = 0;
virtual status_t closeOutput(int output) = 0;
virtual status_t suspendOutput(int output) = 0;
virtual status_t restoreOutput(int output) = 0;
virtual int openInput(uint32_t *pDevices,
uint32_t *pSamplingRate,
uint32_t *pFormat,
uint32_t *pChannels,
uint32_t acoustics) = 0;
virtual status_t closeInput(int input) = 0;
virtual status_t setStreamOutput(uint32_t stream, int output) = 0;
virtual status_t setVoiceVolume(float volume) = 0;
virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) = 0;
virtual unsigned int getInputFramesLost(int ioHandle) = 0;
virtual int newAudioSessionId() = 0;
virtual status_t loadEffectLibrary(const char *libPath, int *handle) = 0;
virtual status_t unloadEffectLibrary(int handle) = 0;
virtual status_t queryNumberEffects(uint32_t *numEffects) = 0;
virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) = 0;
virtual status_t getEffectDescriptor(effect_uuid_t *pEffectUUID, effect_descriptor_t *pDescriptor) = 0;
virtual sp<IEffect> createEffect(pid_t pid,
effect_descriptor_t *pDesc,
const sp<IEffectClient>& client,
int32_t priority,
int output,
int sessionId,
status_t *status,
int *id,
int *enabled) = 0;
virtual status_t moveEffects(int session, int srcOutput, int dstOutput) = 0;
virtual status_t deregisterClient(const sp<IAudioFlingerClient>& client) { return false; };
virtual status_t setFmVolume(float volume) = 0;
};
// ----------------------------------------------------------------------------
class BnAudioFlinger : public BnInterface<IAudioFlinger>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
// ----------------------------------------------------------------------------
}; // namespace android
#endif // ANDROID_IAUDIOFLINGER_H
+55
View File
@@ -0,0 +1,55 @@
/*
* 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_IAUDIOFLINGERCLIENT_H
#define ANDROID_IAUDIOFLINGERCLIENT_H
#include <utils/RefBase.h>
#include <binder/IInterface.h>
#include <utils/KeyedVector.h>
namespace android {
// ----------------------------------------------------------------------------
class IAudioFlingerClient : public IInterface
{
public:
DECLARE_META_INTERFACE(AudioFlingerClient);
// Notifies a change of audio input/output configuration.
virtual void ioConfigChanged(int event, int ioHandle, void *param2) = 0;
};
// ----------------------------------------------------------------------------
class BnAudioFlingerClient : public BnInterface<IAudioFlingerClient>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
// ----------------------------------------------------------------------------
}; // namespace android
#endif // ANDROID_IAUDIOFLINGERCLIENT_H
+109
View File
@@ -0,0 +1,109 @@
/*
* 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_IAUDIOPOLICYSERVICE_H
#define ANDROID_IAUDIOPOLICYSERVICE_H
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>
#include <binder/IInterface.h>
#include <media/AudioSystem.h>
namespace android {
// ----------------------------------------------------------------------------
class IAudioPolicyService : public IInterface
{
public:
DECLARE_META_INTERFACE(AudioPolicyService);
//
// IAudioPolicyService interface (see AudioPolicyInterface for method descriptions)
//
virtual status_t setDeviceConnectionState(AudioSystem::audio_devices device,
AudioSystem::device_connection_state state,
const char *device_address) = 0;
virtual AudioSystem::device_connection_state getDeviceConnectionState(AudioSystem::audio_devices device,
const char *device_address) = 0;
virtual status_t setPhoneState(int state) = 0;
virtual status_t setRingerMode(uint32_t mode, uint32_t mask) = 0;
virtual status_t setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config) = 0;
virtual AudioSystem::forced_config getForceUse(AudioSystem::force_use usage) = 0;
virtual audio_io_handle_t getOutput(AudioSystem::stream_type stream,
uint32_t samplingRate = 0,
uint32_t format = AudioSystem::FORMAT_DEFAULT,
uint32_t channels = 0,
AudioSystem::output_flags flags = AudioSystem::OUTPUT_FLAG_INDIRECT) = 0;
virtual audio_io_handle_t getSession(AudioSystem::stream_type stream,
uint32_t format = AudioSystem::FORMAT_DEFAULT,
AudioSystem::output_flags flags = AudioSystem::OUTPUT_FLAG_DIRECT,
int32_t sessionId=-1) { return 0; }
virtual status_t pauseSession(audio_io_handle_t output, AudioSystem::stream_type stream) { return 0; }
virtual status_t resumeSession(audio_io_handle_t output, AudioSystem::stream_type stream) { return 0; }
virtual status_t closeSession(audio_io_handle_t output) = 0;
virtual status_t startOutput(audio_io_handle_t output,
AudioSystem::stream_type stream,
int session = 0) = 0;
virtual status_t stopOutput(audio_io_handle_t output,
AudioSystem::stream_type stream,
int session = 0) = 0;
virtual void releaseOutput(audio_io_handle_t output) = 0;
virtual audio_io_handle_t getInput(int inputSource,
uint32_t samplingRate = 0,
uint32_t format = AudioSystem::FORMAT_DEFAULT,
uint32_t channels = 0,
AudioSystem::audio_in_acoustics acoustics = (AudioSystem::audio_in_acoustics)0) = 0;
virtual status_t startInput(audio_io_handle_t input) = 0;
virtual status_t stopInput(audio_io_handle_t input) = 0;
virtual void releaseInput(audio_io_handle_t input) = 0;
virtual status_t initStreamVolume(AudioSystem::stream_type stream,
int indexMin,
int indexMax) = 0;
virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index) = 0;
virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index) = 0;
virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0;
virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0;
virtual status_t registerEffect(effect_descriptor_t *desc,
audio_io_handle_t output,
uint32_t strategy,
int session,
int id) = 0;
virtual status_t unregisterEffect(int id) = 0;
};
// ----------------------------------------------------------------------------
class BnAudioPolicyService : public BnInterface<IAudioPolicyService>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
// ----------------------------------------------------------------------------
}; // namespace android
#endif // ANDROID_IAUDIOPOLICYSERVICE_H
+68
View File
@@ -0,0 +1,68 @@
/*
* 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 IAUDIORECORD_H_
#define IAUDIORECORD_H_
#include <stdint.h>
#include <sys/types.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>
#include <binder/IInterface.h>
#include <binder/IMemory.h>
namespace android {
// ----------------------------------------------------------------------------
class IAudioRecord : public IInterface
{
public:
DECLARE_META_INTERFACE(AudioRecord);
/* After it's created the track is not active. Call start() to
* make it active. If set, the callback will start being called.
*/
virtual status_t start() = 0;
/* Stop a track. If set, the callback will cease being called and
* obtainBuffer will return an error. Buffers that are already released
* will be processed, unless flush() is called.
*/
virtual void stop() = 0;
/* get this tracks control block */
virtual sp<IMemory> getCblk() const = 0;
};
// ----------------------------------------------------------------------------
class BnAudioRecord : public BnInterface<IAudioRecord>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
// ----------------------------------------------------------------------------
}; // namespace android
#endif /*IAUDIORECORD_H_*/
+89
View File
@@ -0,0 +1,89 @@
/*
* 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_IAUDIOTRACK_H
#define ANDROID_IAUDIOTRACK_H
#include <stdint.h>
#include <sys/types.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>
#include <binder/IInterface.h>
#include <binder/IMemory.h>
namespace android {
// ----------------------------------------------------------------------------
class IAudioTrack : public IInterface
{
public:
DECLARE_META_INTERFACE(AudioTrack);
/* After it's created the track is not active. Call start() to
* make it active. If set, the callback will start being called.
*/
virtual status_t start() = 0;
/* Stop a track. If set, the callback will cease being called and
* obtainBuffer will return an error. Buffers that are already released
* will be processed, unless flush() is called.
*/
virtual void stop() = 0;
/* flush a stopped track. All pending buffers are discarded.
* This function has no effect if the track is not stoped.
*/
virtual void flush() = 0;
/* mute or unmutes this track.
* While mutted, the callback, if set, is still called.
*/
virtual void mute(bool) = 0;
/* Pause a track. If set, the callback will cease being called and
* obtainBuffer will return an error. Buffers that are already released
* will be processed, unless flush() is called.
*/
virtual void pause() = 0;
/* Attach track auxiliary output to specified effect. Use effectId = 0
* to detach track from effect.
*/
virtual status_t attachAuxEffect(int effectId) = 0;
/* get this tracks control block */
virtual sp<IMemory> getCblk() const = 0;
};
// ----------------------------------------------------------------------------
class BnAudioTrack : public BnInterface<IAudioTrack>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
// ----------------------------------------------------------------------------
}; // namespace android
#endif // ANDROID_IAUDIOTRACK_H
+60
View File
@@ -0,0 +1,60 @@
/*
* 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_IEFFECT_H
#define ANDROID_IEFFECT_H
#include <utils/RefBase.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>
#include <binder/IMemory.h>
namespace android {
class IEffect: public IInterface
{
public:
DECLARE_META_INTERFACE(Effect);
virtual status_t enable() = 0;
virtual status_t disable() = 0;
virtual status_t command(uint32_t cmdCode,
uint32_t cmdSize,
void *pCmdData,
uint32_t *pReplySize,
void *pReplyData) = 0;
virtual void disconnect() = 0;
virtual sp<IMemory> getCblk() const = 0;
};
// ----------------------------------------------------------------------------
class BnEffect: public BnInterface<IEffect>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
}; // namespace android
#endif // ANDROID_IEFFECT_H
+54
View File
@@ -0,0 +1,54 @@
/*
* 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_IEFFECTCLIENT_H
#define ANDROID_IEFFECTCLIENT_H
#include <utils/RefBase.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>
#include <binder/IMemory.h>
namespace android {
class IEffectClient: public IInterface
{
public:
DECLARE_META_INTERFACE(EffectClient);
virtual void controlStatusChanged(bool controlGranted) = 0;
virtual void enableStatusChanged(bool enabled) = 0;
virtual void commandExecuted(uint32_t cmdCode,
uint32_t cmdSize,
void *pCmdData,
uint32_t replySize,
void *pReplyData) = 0;
};
// ----------------------------------------------------------------------------
class BnEffectClient: public BnInterface<IEffectClient>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
}; // namespace android
#endif // ANDROID_IEFFECTCLIENT_H
+61
View File
@@ -0,0 +1,61 @@
/*
* 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_IMEDIADEATHNOTIFIER_H
#define ANDROID_IMEDIADEATHNOTIFIER_H
#include <utils/threads.h>
#include <media/IMediaPlayerService.h>
#include <utils/SortedVector.h>
namespace android {
class IMediaDeathNotifier: virtual public RefBase
{
public:
IMediaDeathNotifier() { addObitRecipient(this); }
virtual ~IMediaDeathNotifier() { removeObitRecipient(this); }
virtual void died() = 0;
static const sp<IMediaPlayerService>& getMediaPlayerService();
private:
IMediaDeathNotifier &operator=(const IMediaDeathNotifier &);
IMediaDeathNotifier(const IMediaDeathNotifier &);
static void addObitRecipient(const wp<IMediaDeathNotifier>& recipient);
static void removeObitRecipient(const wp<IMediaDeathNotifier>& recipient);
class DeathNotifier: public IBinder::DeathRecipient
{
public:
DeathNotifier() {}
virtual ~DeathNotifier();
virtual void binderDied(const wp<IBinder>& who);
};
friend class DeathNotifier;
static Mutex sServiceLock;
static sp<IMediaPlayerService> sMediaPlayerService;
static sp<DeathNotifier> sDeathNotifier;
static SortedVector< wp<IMediaDeathNotifier> > sObitRecipients;
};
}; // namespace android
#endif // ANDROID_IMEDIADEATHNOTIFIER_H
@@ -0,0 +1,54 @@
/*
**
** 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_IMEDIAMETADATARETRIEVER_H
#define ANDROID_IMEDIAMETADATARETRIEVER_H
#include <utils/RefBase.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>
#include <binder/IMemory.h>
namespace android {
class IMediaMetadataRetriever: public IInterface
{
public:
DECLARE_META_INTERFACE(MediaMetadataRetriever);
virtual void disconnect() = 0;
virtual status_t setDataSource(const char* srcUrl) = 0;
virtual status_t setDataSource(int fd, int64_t offset, int64_t length) = 0;
virtual sp<IMemory> getFrameAtTime(int64_t timeUs, int option) = 0;
virtual sp<IMemory> extractAlbumArt() = 0;
virtual const char* extractMetadata(int keyCode) = 0;
};
// ----------------------------------------------------------------------------
class BnMediaMetadataRetriever: public BnInterface<IMediaMetadataRetriever>
{
public:
virtual status_t onTransact(uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
}; // namespace android
#endif // ANDROID_IMEDIAMETADATARETRIEVER_H
+104
View File
@@ -0,0 +1,104 @@
/*
* 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_IMEDIAPLAYER_H
#define ANDROID_IMEDIAPLAYER_H
#include <utils/RefBase.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>
namespace android {
class Parcel;
class ISurface;
class IMediaPlayer: public IInterface
{
public:
DECLARE_META_INTERFACE(MediaPlayer);
virtual void disconnect() = 0;
virtual status_t setVideoSurface(const sp<ISurface>& surface) = 0;
virtual status_t prepareAsync() = 0;
virtual status_t start() = 0;
virtual status_t stop() = 0;
virtual status_t pause() = 0;
virtual status_t isPlaying(bool* state) = 0;
virtual status_t seekTo(int msec) = 0;
virtual status_t getCurrentPosition(int* msec) = 0;
virtual status_t getDuration(int* msec) = 0;
virtual status_t reset() = 0;
virtual status_t setAudioStreamType(int type) = 0;
virtual status_t setLooping(int loop) = 0;
virtual status_t setVolume(float leftVolume, float rightVolume) = 0;
virtual status_t suspend() = 0;
virtual status_t resume() = 0;
virtual status_t setAuxEffectSendLevel(float level) = 0;
virtual status_t attachAuxEffect(int effectId) = 0;
// Invoke a generic method on the player by using opaque parcels
// for the request and reply.
// @param request Parcel that must start with the media player
// interface token.
// @param[out] reply Parcel to hold the reply data. Cannot be null.
// @return OK if the invocation was made successfully.
virtual status_t invoke(const Parcel& request, Parcel *reply) = 0;
// Set a new metadata filter.
// @param filter A set of allow and drop rules serialized in a Parcel.
// @return OK if the invocation was made successfully.
virtual status_t setMetadataFilter(const Parcel& filter) = 0;
// Retrieve a set of metadata.
// @param update_only Include only the metadata that have changed
// since the last invocation of getMetadata.
// The set is built using the unfiltered
// notifications the native player sent to the
// MediaPlayerService during that period of
// time. If false, all the metadatas are considered.
// @param apply_filter If true, once the metadata set has been built based
// on the value update_only, the current filter is
// applied.
// @param[out] metadata On exit contains a set (possibly empty) of metadata.
// Valid only if the call returned OK.
// @return OK if the invocation was made successfully.
virtual status_t getMetadata(bool update_only,
bool apply_filter,
Parcel *metadata) = 0;
// Sets the given parameters for the player. Parameters are in 'key=value'
// format.
// @param params Key/value pairs of parameters to set for the player.
// @return OK if the invocation was made successfully.
virtual status_t setParameters(const String8& params) = 0;
};
// ----------------------------------------------------------------------------
class BnMediaPlayer: public BnInterface<IMediaPlayer>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
}; // namespace android
#endif // ANDROID_IMEDIAPLAYER_H
+48
View File
@@ -0,0 +1,48 @@
/*
* 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_IMEDIAPLAYERCLIENT_H
#define ANDROID_IMEDIAPLAYERCLIENT_H
#include <utils/RefBase.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>
namespace android {
class IMediaPlayerClient: public IInterface
{
public:
DECLARE_META_INTERFACE(MediaPlayerClient);
virtual void notify(int msg, int ext1, int ext2) = 0;
};
// ----------------------------------------------------------------------------
class BnMediaPlayerClient: public BnInterface<IMediaPlayerClient>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
}; // namespace android
#endif // ANDROID_IMEDIAPLAYERCLIENT_H
+66
View File
@@ -0,0 +1,66 @@
/*
* 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_IMEDIAPLAYERSERVICE_H
#define ANDROID_IMEDIAPLAYERSERVICE_H
#include <utils/Errors.h> // for status_t
#include <utils/KeyedVector.h>
#include <utils/RefBase.h>
#include <utils/String8.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>
#include <media/IMediaPlayerClient.h>
#include <media/IMediaPlayer.h>
#include <media/IMediaMetadataRetriever.h>
namespace android {
class IMediaRecorder;
class IOMX;
class IMediaPlayerService: public IInterface
{
public:
DECLARE_META_INTERFACE(MediaPlayerService);
virtual sp<IMediaRecorder> createMediaRecorder(pid_t pid) = 0;
virtual sp<IMediaMetadataRetriever> createMetadataRetriever(pid_t pid) = 0;
virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client,
const char* url, const KeyedVector<String8, String8> *headers = NULL,
int audioSessionId = 0) = 0;
virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client,
int fd, int64_t offset, int64_t length, int audioSessionId) = 0;
virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0;
virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0;
virtual sp<IOMX> getOMX() = 0;
};
// ----------------------------------------------------------------------------
class BnMediaPlayerService: public BnInterface<IMediaPlayerService>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
}; // namespace android
#endif // ANDROID_IMEDIAPLAYERSERVICE_H
+73
View File
@@ -0,0 +1,73 @@
/*
**
** Copyright 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_IMEDIARECORDER_H
#define ANDROID_IMEDIARECORDER_H
#include <binder/IInterface.h>
namespace android {
class ISurface;
class ICamera;
class IMediaRecorderClient;
class IMediaRecorder: public IInterface
{
public:
DECLARE_META_INTERFACE(MediaRecorder);
virtual status_t setCamera(const sp<ICamera>& camera) = 0;
virtual status_t setPreviewSurface(const sp<ISurface>& surface) = 0;
virtual status_t setVideoSource(int vs) = 0;
virtual status_t setAudioSource(int as) = 0;
virtual status_t setOutputFormat(int of) = 0;
virtual status_t setVideoEncoder(int ve) = 0;
virtual status_t setAudioEncoder(int ae) = 0;
virtual status_t setOutputFile(const char* path) = 0;
virtual status_t setOutputFile(int fd, int64_t offset, int64_t length) = 0;
virtual status_t setVideoSize(int width, int height) = 0;
virtual status_t setVideoFrameRate(int frames_per_second) = 0;
virtual status_t setParameters(const String8& params) = 0;
virtual status_t setListener(const sp<IMediaRecorderClient>& listener) = 0;
virtual status_t setCameraParameters(const String8& params) = 0;
virtual status_t prepare() = 0;
virtual status_t getMaxAmplitude(int* max) = 0;
virtual status_t start() = 0;
virtual status_t stop() = 0;
virtual status_t reset() = 0;
virtual status_t init() = 0;
virtual status_t close() = 0;
virtual status_t release() = 0;
virtual status_t takeLiveSnapshot() = 0;
};
// ----------------------------------------------------------------------------
class BnMediaRecorder: public BnInterface<IMediaRecorder>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
}; // namespace android
#endif // ANDROID_IMEDIARECORDER_H
+50
View File
@@ -0,0 +1,50 @@
/*
* 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_IMEDIARECORDERCLIENT_H
#define ANDROID_IMEDIARECORDERCLIENT_H
#include <utils/RefBase.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>
#include <binder/IMemory.h>
namespace android {
class IMediaRecorderClient: public IInterface
{
public:
DECLARE_META_INTERFACE(MediaRecorderClient);
virtual void notify(int msg, int ext1, int ext2) = 0;
virtual void dataCallback(int32_t msgType, const sp<IMemory>& imageData) = 0;
};
// ----------------------------------------------------------------------------
class BnMediaRecorderClient: public BnInterface<IMediaRecorderClient>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
}; // namespace android
#endif // ANDROID_IMEDIARECORDERCLIENT_H
+226
View File
@@ -0,0 +1,226 @@
/*
* 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.
*/
/*--------------------------------------------------------------------------
Copyright (c) 2010, The Linux Foundation. All rights reserved.
--------------------------------------------------------------------------*/
#ifndef ANDROID_IOMX_H_
#define ANDROID_IOMX_H_
#include <binder/IInterface.h>
#include <binder/MemoryHeapBase.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 ISurface;
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 useBuffer(
node_id node, OMX_U32 port_index, const sp<IMemory> &params,
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> &params,
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;
/* missing flags in below functions */
virtual sp<IOMXRenderer> createRenderer(
const sp<ISurface> &surface,
const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat,
size_t encodedWidth, size_t encodedHeight,
size_t displayWidth, size_t displayHeight,
int32_t rotationDegrees) = 0;
// Note: These methods are _not_ virtual, it exists as a wrapper around
// the virtual "createRenderer" method above facilitating extraction
// of the ISurface from a regular Surface or a java Surface object.
sp<IOMXRenderer> createRenderer(
const sp<Surface> &surface,
const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat,
size_t encodedWidth, size_t encodedHeight,
size_t displayWidth, size_t displayHeight,
int32_t rotationDegrees);
sp<IOMXRenderer> createRendererFromJavaSurface(
JNIEnv *env, jobject javaSurface,
const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat,
size_t encodedWidth, size_t encodedHeight,
size_t displayWidth, size_t displayHeight,
int32_t rotationDegrees);
};
struct omx_message {
enum {
EVENT,
EMPTY_BUFFER_DONE,
FILL_BUFFER_DONE,
REGISTER_BUFFERS
} 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;
OMX_U32 pmem_offset;
} extended_buffer_data;
} u;
};
class IOMXObserver : public IInterface {
public:
DECLARE_META_INTERFACE(OMXObserver);
virtual void onMessage(const omx_message &msg) = 0;
virtual void registerBuffers(const sp<IMemoryHeap> &mem) = 0;
};
class IOMXRenderer : public IInterface {
public:
DECLARE_META_INTERFACE(OMXRenderer);
virtual void render(IOMX::buffer_id buffer) = 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);
};
class BnOMXRenderer : public BnInterface<IOMXRenderer> {
public:
virtual status_t onTransact(
uint32_t code, const Parcel &data, Parcel *reply,
uint32_t flags = 0);
};
} // namespace android
#endif // ANDROID_IOMX_H_
+107
View File
@@ -0,0 +1,107 @@
/*
* 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 JETPLAYER_H_
#define JETPLAYER_H_
#include <utils/threads.h>
#include <nativehelper/jni.h>
#include <libsonivox/jet.h>
#include <libsonivox/eas_types.h>
#include "AudioTrack.h"
namespace android {
typedef void (*jetevent_callback)(int eventType, int val1, int val2, void *cookie);
class JetPlayer {
public:
// to keep in sync with the JetPlayer class constants
// defined in frameworks/base/media/java/android/media/JetPlayer.java
static const int JET_EVENT = 1;
static const int JET_USERID_UPDATE = 2;
static const int JET_NUMQUEUEDSEGMENT_UPDATE = 3;
static const int JET_PAUSE_UPDATE = 4;
JetPlayer(jobject javaJetPlayer,
int maxTracks = 32,
int trackBufferSize = 1200);
~JetPlayer();
int init();
int release();
int loadFromFile(const char* url);
int loadFromFD(const int fd, const long long offset, const long long length);
int closeFile();
int play();
int pause();
int queueSegment(int segmentNum, int libNum, int repeatCount, int transpose,
EAS_U32 muteFlags, EAS_U8 userID);
int setMuteFlags(EAS_U32 muteFlags, bool sync);
int setMuteFlag(int trackNum, bool muteFlag, bool sync);
int triggerClip(int clipId);
int clearQueue();
void setEventCallback(jetevent_callback callback);
int getMaxTracks() { return mMaxTracks; };
private:
static int renderThread(void*);
int render();
void fireUpdateOnStatusChange();
void fireEventsFromJetQueue();
JetPlayer() {} // no default constructor
void dump();
void dumpJetStatus(S_JET_STATUS* pJetStatus);
jetevent_callback mEventCallback;
jobject mJavaJetPlayerRef;
Mutex mMutex; // mutex to sync the render and playback thread with the JET calls
pid_t mTid;
Condition mCondition;
volatile bool mRender;
bool mPaused;
EAS_STATE mState;
int* mMemFailedVar;
int mMaxTracks; // max number of MIDI tracks, usually 32
EAS_DATA_HANDLE mEasData;
EAS_FILE_LOCATOR mEasJetFileLoc;
EAS_PCM* mAudioBuffer;// EAS renders the MIDI data into this buffer,
AudioTrack* mAudioTrack; // and we play it in this audio track
int mTrackBufferSize;
S_JET_STATUS mJetStatus;
S_JET_STATUS mPreviousJetStatus;
char mJetFilePath[256];
}; // end class JetPlayer
} // end namespace android
#endif /*JETPLAYER_H_*/
@@ -0,0 +1,55 @@
/*
**
** 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_MEDIAMETADATARETRIEVERINTERFACE_H
#define ANDROID_MEDIAMETADATARETRIEVERINTERFACE_H
#include <utils/RefBase.h>
#include <media/mediametadataretriever.h>
#include <private/media/VideoFrame.h>
namespace android {
// Abstract base class
class MediaMetadataRetrieverBase : public RefBase
{
public:
MediaMetadataRetrieverBase() {}
virtual ~MediaMetadataRetrieverBase() {}
virtual status_t setDataSource(const char *url) = 0;
virtual status_t setDataSource(int fd, int64_t offset, int64_t length) = 0;
virtual VideoFrame* getFrameAtTime(int64_t timeUs, int option) = 0;
virtual MediaAlbumArt* extractAlbumArt() = 0;
virtual const char* extractMetadata(int keyCode) = 0;
};
// MediaMetadataRetrieverInterface
class MediaMetadataRetrieverInterface : public MediaMetadataRetrieverBase
{
public:
MediaMetadataRetrieverInterface() {}
virtual ~MediaMetadataRetrieverInterface() {}
virtual VideoFrame* getFrameAtTime(int64_t timeUs, int option) { return NULL; }
virtual MediaAlbumArt* extractAlbumArt() { return NULL; }
virtual const char* extractMetadata(int keyCode) { return NULL; }
};
}; // namespace android
#endif // ANDROID_MEDIAMETADATARETRIEVERINTERFACE_H
+190
View File
@@ -0,0 +1,190 @@
/*
* Copyright (C) 2007 The Android Open Source Project
* Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
*
* 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_MEDIAPLAYERINTERFACE_H
#define ANDROID_MEDIAPLAYERINTERFACE_H
#ifdef __cplusplus
#include <sys/types.h>
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <utils/String8.h>
#include <utils/RefBase.h>
#include <media/mediaplayer.h>
#include <media/AudioSystem.h>
#include <media/Metadata.h>
namespace android {
class Parcel;
class ISurface;
template<typename T> class SortedVector;
enum player_type {
PV_PLAYER = 1,
SONIVOX_PLAYER = 2,
STAGEFRIGHT_PLAYER = 4,
// Test players are available only in the 'test' and 'eng' builds.
// The shared library with the test player is passed passed as an
// argument to the 'test:' url in the setDataSource call.
TEST_PLAYER = 5,
};
#define DEFAULT_AUDIOSINK_BUFFERCOUNT 4
#define DEFAULT_AUDIOSINK_BUFFERSIZE 1200
#define DEFAULT_AUDIOSINK_SAMPLERATE 44100
// callback mechanism for passing messages to MediaPlayer object
typedef void (*notify_callback_f)(void* cookie, int msg, int ext1, int ext2);
// abstract base class - use MediaPlayerInterface
class MediaPlayerBase : public RefBase
{
public:
// AudioSink: abstraction layer for audio output
class AudioSink : public RefBase {
public:
// Callback returns the number of bytes actually written to the buffer.
typedef size_t (*AudioCallback)(
AudioSink *audioSink, void *buffer, size_t size, void *cookie);
virtual ~AudioSink() {}
virtual bool ready() const = 0; // audio output is open and ready
virtual bool realtime() const = 0; // audio output is real-time output
virtual ssize_t bufferSize() const = 0;
virtual ssize_t frameCount() const = 0;
virtual ssize_t channelCount() const = 0;
virtual ssize_t frameSize() const = 0;
virtual uint32_t latency() const = 0;
virtual float msecsPerFrame() const = 0;
virtual status_t getPosition(uint32_t *position) = 0;
virtual int getSessionId() = 0;
// If no callback is specified, use the "write" API below to submit
// audio data.
virtual status_t open(
uint32_t sampleRate, int channelCount,
int format=AudioSystem::PCM_16_BIT,
int bufferCount=DEFAULT_AUDIOSINK_BUFFERCOUNT,
AudioCallback cb = NULL,
void *cookie = NULL) = 0;
// API to open a routing session for tunneled audio playback
virtual status_t openSession(
int format, int sessionId, uint32_t sampleRate = 44100, int channels = 2) {return 0;};
virtual void start() = 0;
virtual ssize_t write(const void* buffer, size_t size) = 0;
virtual void stop() = 0;
virtual void flush() = 0;
virtual void pause() = 0;
virtual void pauseSession() {return;};
virtual void resumeSession() {return;};
virtual void close() = 0;
virtual void closeSession() {return;};
};
MediaPlayerBase() : mCookie(0), mNotify(0) {}
virtual ~MediaPlayerBase() {}
virtual status_t initCheck() = 0;
virtual bool hardwareOutput() = 0;
virtual status_t setDataSource(
const char *url,
const KeyedVector<String8, String8> *headers = NULL) = 0;
virtual status_t setDataSource(int fd, int64_t offset, int64_t length) = 0;
virtual status_t setVideoSurface(const sp<ISurface>& surface) = 0;
virtual status_t prepare() = 0;
virtual status_t prepareAsync() = 0;
virtual status_t start() = 0;
virtual status_t stop() = 0;
virtual status_t pause() = 0;
virtual bool isPlaying() = 0;
virtual status_t seekTo(int msec) = 0;
virtual status_t getCurrentPosition(int *msec) = 0;
virtual status_t getDuration(int *msec) = 0;
virtual status_t reset() = 0;
virtual status_t setLooping(int loop) = 0;
virtual player_type playerType() = 0;
virtual status_t suspend() { return INVALID_OPERATION; }
virtual status_t resume() { return INVALID_OPERATION; }
virtual void setNotifyCallback(void* cookie, notify_callback_f notifyFunc) {
mCookie = cookie; mNotify = notifyFunc; }
// Invoke a generic method on the player by using opaque parcels
// for the request and reply.
//
// @param request Parcel that is positioned at the start of the
// data sent by the java layer.
// @param[out] reply Parcel to hold the reply data. Cannot be null.
// @return OK if the call was successful.
virtual status_t invoke(const Parcel& request, Parcel *reply) = 0;
// The Client in the MetadataPlayerService calls this method on
// the native player to retrieve all or a subset of metadata.
//
// @param ids SortedList of metadata ID to be fetch. If empty, all
// the known metadata should be returned.
// @param[inout] records Parcel where the player appends its metadata.
// @return OK if the call was successful.
virtual status_t getMetadata(const media::Metadata::Filter& ids,
Parcel *records) {
return INVALID_OPERATION;
};
virtual void sendEvent(int msg, int ext1=0, int ext2=0) { if (mNotify) mNotify(mCookie, msg, ext1, ext2); }
virtual status_t setParameters(const String8& params) = 0;
protected:
void* mCookie;
notify_callback_f mNotify;
};
// Implement this class for media players that use the AudioFlinger software mixer
class MediaPlayerInterface : public MediaPlayerBase
{
public:
virtual ~MediaPlayerInterface() { }
virtual bool hardwareOutput() { return false; }
virtual void setAudioSink(const sp<AudioSink>& audioSink) { mAudioSink = audioSink; }
protected:
sp<AudioSink> mAudioSink;
};
// Implement this class for media players that output directo to hardware
class MediaPlayerHWInterface : public MediaPlayerBase
{
public:
virtual ~MediaPlayerHWInterface() {}
virtual bool hardwareOutput() { return true; }
virtual status_t setVolume(float leftVolume, float rightVolume) = 0;
virtual status_t setAudioStreamType(int streamType) = 0;
};
}; // namespace android
#endif // __cplusplus
#endif // ANDROID_MEDIAPLAYERINTERFACE_H
+327
View File
@@ -0,0 +1,327 @@
/*
**
** Copyright 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_MEDIAPROFILES_H
#define ANDROID_MEDIAPROFILES_H
#include <utils/threads.h>
#include <media/mediarecorder.h>
namespace android {
enum camcorder_quality {
CAMCORDER_QUALITY_LOW = 0,
CAMCORDER_QUALITY_HIGH = 1
};
enum video_decoder {
VIDEO_DECODER_WMV,
};
enum audio_decoder {
AUDIO_DECODER_WMA,
};
class MediaProfiles
{
public:
/**
* Returns the singleton instance for subsequence queries.
* or NULL if error.
*/
static MediaProfiles* getInstance();
/**
* Returns the value for the given param name for the given camera at
* the given quality level, or -1 if error.
*
* Supported param name are:
* duration - the recording duration.
* file.format - output file format. see mediarecorder.h for details
* vid.codec - video encoder. see mediarecorder.h for details.
* aud.codec - audio encoder. see mediarecorder.h for details.
* vid.width - video frame width
* vid.height - video frame height
* vid.fps - video frame rate
* vid.bps - video bit rate
* aud.bps - audio bit rate
* aud.hz - audio sample rate
* aud.ch - number of audio channels
*/
int getCamcorderProfileParamByName(const char *name, int cameraId,
camcorder_quality quality) const;
/**
* Returns the output file formats supported.
*/
Vector<output_format> getOutputFileFormats() const;
/**
* Returns the video encoders supported.
*/
Vector<video_encoder> getVideoEncoders() const;
/**
* Returns the value for the given param name for the given video encoder
* returned from getVideoEncoderByIndex or -1 if error.
*
* Supported param name are:
* enc.vid.width.min - min video frame width
* enc.vid.width.max - max video frame width
* enc.vid.height.min - min video frame height
* enc.vid.height.max - max video frame height
* enc.vid.bps.min - min bit rate in bits per second
* enc.vid.bps.max - max bit rate in bits per second
* enc.vid.fps.min - min frame rate in frames per second
* enc.vid.fps.max - max frame rate in frames per second
*/
int getVideoEncoderParamByName(const char *name, video_encoder codec) const;
/**
* Returns the audio encoders supported.
*/
Vector<audio_encoder> getAudioEncoders() const;
/**
* Returns the value for the given param name for the given audio encoder
* returned from getAudioEncoderByIndex or -1 if error.
*
* Supported param name are:
* enc.aud.ch.min - min number of channels
* enc.aud.ch.max - max number of channels
* enc.aud.bps.min - min bit rate in bits per second
* enc.aud.bps.max - max bit rate in bits per second
* enc.aud.hz.min - min sample rate in samples per second
* enc.aud.hz.max - max sample rate in samples per second
*/
int getAudioEncoderParamByName(const char *name, audio_encoder codec) const;
/**
* Returns the video decoders supported.
*/
Vector<video_decoder> getVideoDecoders() const;
/**
* Returns the audio decoders supported.
*/
Vector<audio_decoder> getAudioDecoders() const;
/**
* Returns the number of image encoding quality levels supported.
*/
Vector<int> getImageEncodingQualityLevels(int cameraId) const;
private:
MediaProfiles& operator=(const MediaProfiles&); // Don't call me
MediaProfiles(const MediaProfiles&); // Don't call me
MediaProfiles() {} // Dummy default constructor
~MediaProfiles(); // Don't delete me
struct VideoCodec {
VideoCodec(video_encoder codec, int bitRate, int frameWidth, int frameHeight, int frameRate)
: mCodec(codec),
mBitRate(bitRate),
mFrameWidth(frameWidth),
mFrameHeight(frameHeight),
mFrameRate(frameRate) {}
~VideoCodec() {}
video_encoder mCodec;
int mBitRate;
int mFrameWidth;
int mFrameHeight;
int mFrameRate;
};
struct AudioCodec {
AudioCodec(audio_encoder codec, int bitRate, int sampleRate, int channels)
: mCodec(codec),
mBitRate(bitRate),
mSampleRate(sampleRate),
mChannels(channels) {}
~AudioCodec() {}
audio_encoder mCodec;
int mBitRate;
int mSampleRate;
int mChannels;
};
struct CamcorderProfile {
CamcorderProfile()
: mCameraId(0),
mFileFormat(OUTPUT_FORMAT_THREE_GPP),
mQuality(CAMCORDER_QUALITY_HIGH),
mDuration(0),
mVideoCodec(0),
mAudioCodec(0) {}
~CamcorderProfile() {
delete mVideoCodec;
delete mAudioCodec;
}
int mCameraId;
output_format mFileFormat;
camcorder_quality mQuality;
int mDuration;
VideoCodec *mVideoCodec;
AudioCodec *mAudioCodec;
};
struct VideoEncoderCap {
// Ugly constructor
VideoEncoderCap(video_encoder codec,
int minBitRate, int maxBitRate,
int minFrameWidth, int maxFrameWidth,
int minFrameHeight, int maxFrameHeight,
int minFrameRate, int maxFrameRate)
: mCodec(codec),
mMinBitRate(minBitRate), mMaxBitRate(maxBitRate),
mMinFrameWidth(minFrameWidth), mMaxFrameWidth(maxFrameWidth),
mMinFrameHeight(minFrameHeight), mMaxFrameHeight(maxFrameHeight),
mMinFrameRate(minFrameRate), mMaxFrameRate(maxFrameRate) {}
~VideoEncoderCap() {}
video_encoder mCodec;
int mMinBitRate, mMaxBitRate;
int mMinFrameWidth, mMaxFrameWidth;
int mMinFrameHeight, mMaxFrameHeight;
int mMinFrameRate, mMaxFrameRate;
};
struct AudioEncoderCap {
// Ugly constructor
AudioEncoderCap(audio_encoder codec,
int minBitRate, int maxBitRate,
int minSampleRate, int maxSampleRate,
int minChannels, int maxChannels)
: mCodec(codec),
mMinBitRate(minBitRate), mMaxBitRate(maxBitRate),
mMinSampleRate(minSampleRate), mMaxSampleRate(maxSampleRate),
mMinChannels(minChannels), mMaxChannels(maxChannels) {}
~AudioEncoderCap() {}
audio_encoder mCodec;
int mMinBitRate, mMaxBitRate;
int mMinSampleRate, mMaxSampleRate;
int mMinChannels, mMaxChannels;
};
struct VideoDecoderCap {
VideoDecoderCap(video_decoder codec): mCodec(codec) {}
~VideoDecoderCap() {}
video_decoder mCodec;
};
struct AudioDecoderCap {
AudioDecoderCap(audio_decoder codec): mCodec(codec) {}
~AudioDecoderCap() {}
audio_decoder mCodec;
};
struct NameToTagMap {
const char* name;
int tag;
};
struct ImageEncodingQualityLevels {
int mCameraId;
Vector<int> mLevels;
};
// Debug
static void logVideoCodec(const VideoCodec& codec);
static void logAudioCodec(const AudioCodec& codec);
static void logVideoEncoderCap(const VideoEncoderCap& cap);
static void logAudioEncoderCap(const AudioEncoderCap& cap);
static void logVideoDecoderCap(const VideoDecoderCap& cap);
static void logAudioDecoderCap(const AudioDecoderCap& cap);
// If the xml configuration file does exist, use the settings
// from the xml
static MediaProfiles* createInstanceFromXmlFile(const char *xml);
static output_format createEncoderOutputFileFormat(const char **atts);
static VideoCodec* createVideoCodec(const char **atts, MediaProfiles *profiles);
static AudioCodec* createAudioCodec(const char **atts, MediaProfiles *profiles);
static AudioDecoderCap* createAudioDecoderCap(const char **atts);
static VideoDecoderCap* createVideoDecoderCap(const char **atts);
static VideoEncoderCap* createVideoEncoderCap(const char **atts);
static AudioEncoderCap* createAudioEncoderCap(const char **atts);
static CamcorderProfile* createCamcorderProfile(int cameraId, const char **atts);
static int getCameraId(const char **atts);
ImageEncodingQualityLevels* findImageEncodingQualityLevels(int cameraId) const;
void addImageEncodingQualityLevel(int cameraId, const char** atts);
// Customized element tag handler for parsing the xml configuration file.
static void startElementHandler(void *userData, const char *name, const char **atts);
// If the xml configuration file does not exist, use hard-coded values
static MediaProfiles* createDefaultInstance();
static CamcorderProfile *createDefaultCamcorderLowProfile();
static CamcorderProfile *createDefaultCamcorderHighProfile();
static void createDefaultCamcorderProfiles(MediaProfiles *profiles);
static void createDefaultVideoEncoders(MediaProfiles *profiles);
static void createDefaultAudioEncoders(MediaProfiles *profiles);
static void createDefaultVideoDecoders(MediaProfiles *profiles);
static void createDefaultAudioDecoders(MediaProfiles *profiles);
static void createDefaultEncoderOutputFileFormats(MediaProfiles *profiles);
static void createDefaultImageEncodingQualityLevels(MediaProfiles *profiles);
static void createDefaultImageDecodingMaxMemory(MediaProfiles *profiles);
static VideoEncoderCap* createDefaultH263VideoEncoderCap();
static VideoEncoderCap* createDefaultH264VideoEncoderCap();
static VideoEncoderCap* createDefaultM4vVideoEncoderCap();
static AudioEncoderCap* createDefaultAmrNBEncoderCap();
static AudioEncoderCap* createDefaultAacEncoderCap();
static int findTagForName(const NameToTagMap *map, size_t nMappings, const char *name);
// Mappings from name (for instance, codec name) to enum value
static const NameToTagMap sVideoEncoderNameMap[];
static const NameToTagMap sAudioEncoderNameMap[];
static const NameToTagMap sFileFormatMap[];
static const NameToTagMap sVideoDecoderNameMap[];
static const NameToTagMap sAudioDecoderNameMap[];
static const NameToTagMap sCamcorderQualityNameMap[];
static bool sIsInitialized;
static MediaProfiles *sInstance;
static Mutex sLock;
int mCurrentCameraId;
Vector<CamcorderProfile*> mCamcorderProfiles;
Vector<AudioEncoderCap*> mAudioEncoders;
Vector<VideoEncoderCap*> mVideoEncoders;
Vector<AudioDecoderCap*> mAudioDecoders;
Vector<VideoDecoderCap*> mVideoDecoders;
Vector<output_format> mEncoderOutputFileFormats;
Vector<ImageEncodingQualityLevels *> mImageEncodingQualityLevels;
};
}; // namespace android
#endif // ANDROID_MEDIAPROFILES_H
+62
View File
@@ -0,0 +1,62 @@
/*
* 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_RECORDER_BASE_H_
#define MEDIA_RECORDER_BASE_H_
#include <media/mediarecorder.h>
namespace android {
class ISurface;
struct MediaRecorderBase {
MediaRecorderBase() {}
virtual ~MediaRecorderBase() {}
virtual status_t init() = 0;
virtual status_t setAudioSource(audio_source as) = 0;
virtual status_t setVideoSource(video_source vs) = 0;
virtual status_t setOutputFormat(output_format of) = 0;
virtual status_t setAudioEncoder(audio_encoder ae) = 0;
virtual status_t setVideoEncoder(video_encoder ve) = 0;
virtual status_t setVideoSize(int width, int height) = 0;
virtual status_t setVideoFrameRate(int frames_per_second) = 0;
virtual status_t setCamera(const sp<ICamera>& camera) = 0;
virtual status_t setPreviewSurface(const sp<ISurface>& surface) = 0;
virtual status_t setOutputFile(const char *path) = 0;
virtual status_t setOutputFile(int fd, int64_t offset, int64_t length) = 0;
virtual status_t setParameters(const String8& params) = 0;
virtual status_t setListener(const sp<IMediaRecorderClient>& listener) = 0;
virtual status_t setCameraParameters(const String8& params) = 0;
virtual status_t prepare() = 0;
virtual status_t start() = 0;
virtual status_t stop() = 0;
virtual status_t close() = 0;
virtual status_t reset() = 0;
virtual status_t getMaxAmplitude(int *max) = 0;
virtual status_t dump(int fd, const Vector<String16>& args) const = 0;
virtual status_t takeLiveSnapshot() {return NO_ERROR;}
private:
MediaRecorderBase(const MediaRecorderBase &);
MediaRecorderBase &operator=(const MediaRecorderBase &);
};
} // namespace android
#endif // MEDIA_RECORDER_BASE_H_
+134
View File
@@ -0,0 +1,134 @@
/*
* 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_MEDIA_METADATA_H__
#define ANDROID_MEDIA_METADATA_H__
#include <sys/types.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>
#include <utils/SortedVector.h>
namespace android {
class Parcel;
namespace media {
// Metadata is a class to build/serialize a set of metadata in a Parcel.
//
// This class should be kept in sync with android/media/Metadata.java.
// It provides all the metadata ids available and methods to build the
// header, add records and adjust the set size header field.
//
// Typical Usage:
// ==============
// Parcel p;
// media::Metadata data(&p);
//
// data.appendHeader();
// data.appendBool(Metadata::kPauseAvailable, true);
// ... more append ...
// data.updateLength();
//
class Metadata {
public:
typedef int32_t Type;
typedef SortedVector<Type> Filter;
static const Type kAny = 0;
// Keep in sync with android/media/Metadata.java
static const Type kTitle = 1; // String
static const Type kComment = 2; // String
static const Type kCopyright = 3; // String
static const Type kAlbum = 4; // String
static const Type kArtist = 5; // String
static const Type kAuthor = 6; // String
static const Type kComposer = 7; // String
static const Type kGenre = 8; // String
static const Type kDate = 9; // Date
static const Type kDuration = 10; // Integer(millisec)
static const Type kCdTrackNum = 11; // Integer 1-based
static const Type kCdTrackMax = 12; // Integer
static const Type kRating = 13; // String
static const Type kAlbumArt = 14; // byte[]
static const Type kVideoFrame = 15; // Bitmap
static const Type kCaption = 16; // TimedText
static const Type kBitRate = 17; // Integer, Aggregate rate of
// all the streams in bps.
static const Type kAudioBitRate = 18; // Integer, bps
static const Type kVideoBitRate = 19; // Integer, bps
static const Type kAudioSampleRate = 20; // Integer, Hz
static const Type kVideoframeRate = 21; // Integer, Hz
// See RFC2046 and RFC4281.
static const Type kMimeType = 22; // String
static const Type kAudioCodec = 23; // String
static const Type kVideoCodec = 24; // String
static const Type kVideoHeight = 25; // Integer
static const Type kVideoWidth = 26; // Integer
static const Type kNumTracks = 27; // Integer
static const Type kDrmCrippled = 28; // Boolean
// Playback capabilities.
static const Type kPauseAvailable = 29; // Boolean
static const Type kSeekBackwardAvailable = 30; // Boolean
static const Type kSeekForwardAvailable = 31; // Boolean
static const Type kSeekAvailable = 32; // Boolean
// @param p[inout] The parcel to append the metadata records
// to. The global metadata header should have been set already.
explicit Metadata(Parcel *p);
~Metadata();
// Rewind the underlying parcel, undoing all the changes.
void resetParcel();
// Append the size and 'META' marker.
bool appendHeader();
// Once all the records have been added, call this to update the
// lenght field in the header.
void updateLength();
// append* are methods to append metadata.
// @param key Is the metadata Id.
// @param val Is the value of the metadata.
// @return true if successful, false otherwise.
// TODO: add more as needed to handle other types.
bool appendBool(Type key, bool val);
bool appendInt32(Type key, int32_t val);
private:
Metadata(const Metadata&);
Metadata& operator=(const Metadata&);
// Checks the key is valid and not already present.
bool checkKey(Type key);
Parcel *mData;
size_t mBegin;
};
} // namespace android::media
} // namespace android
#endif // ANDROID_MEDIA_METADATA_H__
+70
View File
@@ -0,0 +1,70 @@
/*
**
** Copyright 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_PVMEDIARECORDER_H
#define ANDROID_PVMEDIARECORDER_H
#include <media/IMediaRecorderClient.h>
#include <media/MediaRecorderBase.h>
namespace android {
class ISurface;
class ICamera;
class AuthorDriverWrapper;
class PVMediaRecorder : public MediaRecorderBase {
public:
PVMediaRecorder();
virtual ~PVMediaRecorder();
virtual status_t init();
virtual status_t setAudioSource(audio_source as);
virtual status_t setVideoSource(video_source vs);
virtual status_t setOutputFormat(output_format of);
virtual status_t setAudioEncoder(audio_encoder ae);
virtual status_t setVideoEncoder(video_encoder ve);
virtual status_t setVideoSize(int width, int height);
virtual status_t setVideoFrameRate(int frames_per_second);
virtual status_t setCamera(const sp<ICamera>& camera);
virtual status_t setPreviewSurface(const sp<ISurface>& surface);
virtual status_t setOutputFile(const char *path);
virtual status_t setOutputFile(int fd, int64_t offset, int64_t length);
virtual status_t setParameters(const String8& params);
virtual status_t setListener(const sp<IMediaRecorderClient>& listener);
virtual status_t setCameraParameters(const String8& params);
virtual status_t prepare();
virtual status_t start();
virtual status_t stop();
virtual status_t close();
virtual status_t reset();
virtual status_t getMaxAmplitude(int *max);
virtual status_t dump(int fd, const Vector<String16>& args) const;
private:
status_t doStop();
AuthorDriverWrapper* mAuthorDriverWrapper;
PVMediaRecorder(const PVMediaRecorder &);
PVMediaRecorder &operator=(const PVMediaRecorder &);
};
}; // namespace android
#endif // ANDROID_PVMEDIARECORDER_H
+51
View File
@@ -0,0 +1,51 @@
/*
**
** 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_PVMETADATARETRIEVER_H
#define ANDROID_PVMETADATARETRIEVER_H
#include <utils/Errors.h>
#include <media/MediaMetadataRetrieverInterface.h>
#include <private/media/VideoFrame.h>
namespace android {
class MetadataDriver;
class PVMetadataRetriever : public MediaMetadataRetrieverInterface
{
public:
PVMetadataRetriever();
virtual ~PVMetadataRetriever();
virtual status_t setDataSource(const char *url);
virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
virtual status_t setMode(int mode);
virtual status_t getMode(int* mode) const;
virtual VideoFrame* captureFrame();
virtual MediaAlbumArt* extractAlbumArt();
virtual const char* extractMetadata(int keyCode);
private:
mutable Mutex mLock;
MetadataDriver* mMetadataDriver;
char* mDataSourcePath;
};
}; // namespace android
#endif // ANDROID_PVMETADATARETRIEVER_H
+107
View File
@@ -0,0 +1,107 @@
/*
* 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_PVPLAYER_H
#define ANDROID_PVPLAYER_H
#include <utils/Errors.h>
#include <media/MediaPlayerInterface.h>
#include <media/Metadata.h>
#define MAX_OPENCORE_INSTANCES 25
#ifdef MAX_OPENCORE_INSTANCES
#include <cutils/atomic.h>
#endif
class PlayerDriver;
namespace android {
class PVPlayer : public MediaPlayerInterface
{
public:
PVPlayer();
virtual ~PVPlayer();
virtual status_t initCheck();
virtual status_t setDataSource(
const char *url, const KeyedVector<String8, String8> *headers);
virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
virtual status_t setVideoSurface(const sp<ISurface>& surface);
virtual status_t prepare();
virtual status_t prepareAsync();
virtual status_t start();
virtual status_t stop();
virtual status_t pause();
virtual bool isPlaying();
virtual status_t seekTo(int msec);
virtual status_t getCurrentPosition(int *msec);
virtual status_t getDuration(int *msec);
virtual status_t reset();
virtual status_t setLooping(int loop);
virtual player_type playerType() { return PV_PLAYER; }
virtual status_t invoke(const Parcel& request, Parcel *reply);
virtual status_t getMetadata(
const SortedVector<media::Metadata::Type>& ids,
Parcel *records);
virtual status_t suspend();
virtual status_t resume();
virtual status_t setParameters(const String8& params);
// make available to PlayerDriver
void sendEvent(int msg, int ext1=0, int ext2=0) { MediaPlayerBase::sendEvent(msg, ext1, ext2); }
static status_t usePVPlayer(const char *filename);
static status_t usePVPlayer(int fd, int64_t offset, int64_t length);
void setIsResume(bool set) { mIsResume = set; }
bool getIsResume() { return mIsResume; }
void setIsPlaying(bool set) { mIsPlaying = set; }
bool getIsPlaying() { return mIsPlaying; }
bool isNotPaused();
int getCurrentPlayerState();
private:
static void do_nothing(status_t s, void *cookie, bool cancelled) { }
static void run_init(status_t s, void *cookie, bool cancelled);
static void run_set_video_surface(status_t s, void *cookie, bool cancelled);
static void run_set_audio_output(status_t s, void *cookie, bool cancelled);
static void run_prepare(status_t s, void *cookie, bool cancelled);
static void check_for_live_streaming(status_t s, void *cookie, bool cancelled);
PlayerDriver* mPlayerDriver;
char * mDataSourcePath;
bool mIsDataSourceSet;
sp<ISurface> mSurface;
int mSharedFd;
status_t mInit;
int mDuration;
int mPositionWhenSuspend;
bool mIsPlaying;
bool mIsResume;
#ifdef MAX_OPENCORE_INSTANCES
static volatile int32_t sNumInstances;
#endif
};
}; // namespace android
#endif // ANDROID_PVPLAYER_H
+314
View File
@@ -0,0 +1,314 @@
/*
* 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_TONEGENERATOR_H_
#define ANDROID_TONEGENERATOR_H_
#include <utils/RefBase.h>
#include <utils/KeyedVector.h>
#include <utils/threads.h>
#include <media/AudioSystem.h>
#include <media/AudioTrack.h>
namespace android {
class ToneGenerator {
public:
// List of all available tones
// This enum must be kept consistant with constants in ToneGenerator JAVA class
enum tone_type {
// DTMF tones ITU-T Recommendation Q.23
TONE_DTMF_0 = 0, // 0 key: 1336Hz, 941Hz
TONE_DTMF_1, // 1 key: 1209Hz, 697Hz
TONE_DTMF_2, // 2 key: 1336Hz, 697Hz
TONE_DTMF_3, // 3 key: 1477Hz, 697Hz
TONE_DTMF_4, // 4 key: 1209Hz, 770Hz
TONE_DTMF_5, // 5 key: 1336Hz, 770Hz
TONE_DTMF_6, // 6 key: 1477Hz, 770Hz
TONE_DTMF_7, // 7 key: 1209Hz, 852Hz
TONE_DTMF_8, // 8 key: 1336Hz, 852Hz
TONE_DTMF_9, // 9 key: 1477Hz, 852Hz
TONE_DTMF_S, // * key: 1209Hz, 941Hz
TONE_DTMF_P, // # key: 1477Hz, 941Hz
TONE_DTMF_A, // A key: 1633Hz, 697Hz
TONE_DTMF_B, // B key: 1633Hz, 770Hz
TONE_DTMF_C, // C key: 1633Hz, 852Hz
TONE_DTMF_D, // D key: 1633Hz, 941Hz
// Call supervisory tones: 3GPP TS 22.001 (CEPT)
TONE_SUP_DIAL, // Dial tone: CEPT: 425Hz, continuous
FIRST_SUP_TONE = TONE_SUP_DIAL,
TONE_SUP_BUSY, // Busy tone, CEPT: 425Hz, 500ms ON, 500ms OFF...
TONE_SUP_CONGESTION, // Congestion tone CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF...
TONE_SUP_RADIO_ACK, // Radio path acknowlegment, CEPT, ANSI: 425Hz, 200ms ON
TONE_SUP_RADIO_NOTAVAIL, // Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts
TONE_SUP_ERROR, // Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF...
TONE_SUP_CALL_WAITING, // Call Waiting CEPT,JAPAN: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF...
TONE_SUP_RINGTONE, // Ring Tone CEPT, JAPAN: 425Hz, 1s ON, 4s OFF...
LAST_SUP_TONE = TONE_SUP_RINGTONE,
// Proprietary tones: 3GPP TS 31.111
TONE_PROP_BEEP, // General beep: 400Hz+1200Hz, 35ms ON
TONE_PROP_ACK, // Positive Acknowlgement: 1200Hz, 100ms ON, 100ms OFF 2 bursts
TONE_PROP_NACK, // Negative Acknowlgement: 300Hz+400Hz+500Hz, 400ms ON
TONE_PROP_PROMPT, // Prompt tone: 400Hz+1200Hz, 200ms ON
TONE_PROP_BEEP2, // General double beep: 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms on
// Additional call supervisory tones: specified by IS-95 only
TONE_SUP_INTERCEPT, // Intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms.
TONE_SUP_INTERCEPT_ABBREV, // Abbreviated intercept: intercept tone limited to 4 seconds
TONE_SUP_CONGESTION_ABBREV, // Abbreviated congestion: congestion tone limited to 4 seconds
TONE_SUP_CONFIRM, // Confirm tone: a 350 Hz tone added to a 440 Hz tone repeated 3 times in a 100 ms on, 100 ms off cycle.
TONE_SUP_PIP, // Pip tone: four bursts of 480 Hz tone (0.1 s on, 0.1 s off).
// CDMA Tones
TONE_CDMA_DIAL_TONE_LITE,
TONE_CDMA_NETWORK_USA_RINGBACK,
TONE_CDMA_INTERCEPT,
TONE_CDMA_ABBR_INTERCEPT,
TONE_CDMA_REORDER,
TONE_CDMA_ABBR_REORDER,
TONE_CDMA_NETWORK_BUSY,
TONE_CDMA_CONFIRM,
TONE_CDMA_ANSWER,
TONE_CDMA_NETWORK_CALLWAITING,
TONE_CDMA_PIP,
// ISDN
TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL, // ISDN Alert Normal
TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP, // ISDN Intergroup
TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI, // ISDN SP PRI
TONE_CDMA_CALL_SIGNAL_ISDN_PAT3, // ISDN Alert PAT3
TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING, // ISDN Alert PING RING
TONE_CDMA_CALL_SIGNAL_ISDN_PAT5, // ISDN Alert PAT5
TONE_CDMA_CALL_SIGNAL_ISDN_PAT6, // ISDN Alert PAT6
TONE_CDMA_CALL_SIGNAL_ISDN_PAT7, // ISDN Alert PAT7
// ISDN end
// IS54
TONE_CDMA_HIGH_L, // IS54 High Pitch Long
TONE_CDMA_MED_L, // IS54 Med Pitch Long
TONE_CDMA_LOW_L, // IS54 Low Pitch Long
TONE_CDMA_HIGH_SS, // IS54 High Pitch Short Short
TONE_CDMA_MED_SS, // IS54 Medium Pitch Short Short
TONE_CDMA_LOW_SS, // IS54 Low Pitch Short Short
TONE_CDMA_HIGH_SSL, // IS54 High Pitch Short Short Long
TONE_CDMA_MED_SSL, // IS54 Medium Pitch Short Short Long
TONE_CDMA_LOW_SSL, // IS54 Low Pitch Short Short Long
TONE_CDMA_HIGH_SS_2, // IS54 High Pitch Short Short 2
TONE_CDMA_MED_SS_2, // IS54 Med Pitch Short Short 2
TONE_CDMA_LOW_SS_2, // IS54 Low Pitch Short Short 2
TONE_CDMA_HIGH_SLS, // IS54 High Pitch Short Long Short
TONE_CDMA_MED_SLS, // IS54 Med Pitch Short Long Short
TONE_CDMA_LOW_SLS, // IS54 Low Pitch Short Long Short
TONE_CDMA_HIGH_S_X4, // IS54 High Pitch Short Short Short Short
TONE_CDMA_MED_S_X4, // IS54 Med Pitch Short Short Short Short
TONE_CDMA_LOW_S_X4, // IS54 Low Pitch Short Short Short Short
TONE_CDMA_HIGH_PBX_L, // PBX High Pitch Long
TONE_CDMA_MED_PBX_L, // PBX Med Pitch Long
TONE_CDMA_LOW_PBX_L, // PBX Low Pitch Long
TONE_CDMA_HIGH_PBX_SS, // PBX High Short Short
TONE_CDMA_MED_PBX_SS, // PBX Med Short Short
TONE_CDMA_LOW_PBX_SS, // PBX Low Short Short
TONE_CDMA_HIGH_PBX_SSL, // PBX High Short Short Long
TONE_CDMA_MED_PBX_SSL, // PBX Med Short Short Long
TONE_CDMA_LOW_PBX_SSL, // PBX Low Short Short Long
TONE_CDMA_HIGH_PBX_SLS, // PBX High SLS
TONE_CDMA_MED_PBX_SLS, // PBX Med SLS
TONE_CDMA_LOW_PBX_SLS, // PBX Low SLS
TONE_CDMA_HIGH_PBX_S_X4, // PBX High SSSS
TONE_CDMA_MED_PBX_S_X4, // PBX Med SSSS
TONE_CDMA_LOW_PBX_S_X4, // PBX LOW SSSS
//IS54 end
// proprietary
TONE_CDMA_ALERT_NETWORK_LITE,
TONE_CDMA_ALERT_AUTOREDIAL_LITE,
TONE_CDMA_ONE_MIN_BEEP,
TONE_CDMA_KEYPAD_VOLUME_KEY_LITE,
TONE_CDMA_PRESSHOLDKEY_LITE,
TONE_CDMA_ALERT_INCALL_LITE,
TONE_CDMA_EMERGENCY_RINGBACK,
TONE_CDMA_ALERT_CALL_GUARD,
TONE_CDMA_SOFT_ERROR_LITE,
TONE_CDMA_CALLDROP_LITE,
// proprietary end
TONE_CDMA_NETWORK_BUSY_ONE_SHOT,
TONE_CDMA_ABBR_ALERT,
TONE_CDMA_SIGNAL_OFF,
//CDMA end
TONE_CMAS,
NUM_TONES,
NUM_SUP_TONES = LAST_SUP_TONE-FIRST_SUP_TONE+1
};
ToneGenerator(int streamType, float volume, bool threadCanCallJava = false);
~ToneGenerator();
bool startTone(int toneType, int durationMs = -1);
void stopTone();
bool isInited() { return (mState == TONE_IDLE)?false:true;}
private:
enum tone_state {
TONE_IDLE, // ToneGenerator is being initialized or initialization failed
TONE_INIT, // ToneGenerator has been successfully initialized and is not playing
TONE_STARTING, // ToneGenerator is starting playing
TONE_PLAYING, // ToneGenerator is playing
TONE_STOPPING, // ToneGenerator is stoping
TONE_STOPPED, // ToneGenerator is stopped: the AudioTrack will be stopped
TONE_RESTARTING // A start request was received in active state (playing or stopping)
};
// Region specific tones.
// These supervisory tones are different depending on the region (USA/CANADA, JAPAN, rest of the world).
// When a tone in the range [FIRST_SUP_TONE, LAST_SUP_TONE] is requested, the region is determined
// from system property gsm.operator.iso-country and the proper tone descriptor is selected with the
// help of sToneMappingTable[]
enum regional_tone_type {
// ANSI supervisory tones
TONE_ANSI_DIAL = NUM_TONES, // Dial tone: a continuous 350 Hz + 440 Hz tone.
TONE_ANSI_BUSY, // Busy tone on: a 480 Hz + 620 Hz tone repeated in a 500 ms on, 500 ms off cycle.
TONE_ANSI_CONGESTION, // Network congestion (reorder) tone on: a 480 Hz + 620 Hz tone repeated in a 250 ms on, 250 ms off cycle.
TONE_ANSI_CALL_WAITING, // Call waiting tone on: 440 Hz, on for 300 ms, 9,7 s off followed by
// (440 Hz, on for 100 ms off for 100 ms, on for 100 ms, 9,7s off and repeated as necessary).
TONE_ANSI_RINGTONE, // Ring Tone: a 440 Hz + 480 Hz tone repeated in a 2 s on, 4 s off pattern.
// JAPAN Supervisory tones
TONE_JAPAN_DIAL, // Dial tone: 400Hz, continuous
TONE_JAPAN_BUSY, // Busy tone: 400Hz, 500ms ON, 500ms OFF...
TONE_JAPAN_RADIO_ACK, // Radio path acknowlegment: 400Hz, 1s ON, 2s OFF...
NUM_ALTERNATE_TONES
};
enum region {
ANSI,
JAPAN,
CEPT,
NUM_REGIONS
};
static const unsigned char sToneMappingTable[NUM_REGIONS-1][NUM_SUP_TONES];
static const unsigned int TONEGEN_MAX_WAVES = 3; // Maximun number of sine waves in a tone segment
static const unsigned int TONEGEN_MAX_SEGMENTS = 12; // Maximun number of segments in a tone descriptor
static const unsigned int TONEGEN_INF = 0xFFFFFFFF; // Represents infinite time duration
static const float TONEGEN_GAIN = 0.9; // Default gain passed to WaveGenerator().
// ToneDescriptor class contains all parameters needed to generate a tone:
// - The array waveFreq[]:
// 1 for static tone descriptors: contains the frequencies of all individual waves making the multi-tone.
// 2 for active tone descritors: contains the indexes of the WaveGenerator objects in mWaveGens
// The number of sine waves varies from 1 to TONEGEN_MAX_WAVES.
// The first null value indicates that no more waves are needed.
// - The array segments[] is used to generate the tone pulses. A segment is a period of time
// during which the tone is ON or OFF. Segments with even index (starting from 0)
// correspond to tone ON state and segments with odd index to OFF state.
// The data stored in segments[] is the duration of the corresponding period in ms.
// The first segment encountered with a 0 duration indicates that no more segment follows.
// - loopCnt - Number of times to repeat a sequence of seqments after playing this
// - loopIndx - The segment index to go back and play is loopcnt > 0
// - repeatCnt indicates the number of times the sequence described by segments[] array must be repeated.
// When the tone generator encounters the first 0 duration segment, it will compare repeatCnt to mCurCount.
// If mCurCount > repeatCnt, the tone is stopped automatically. Otherwise, tone sequence will be
// restarted from segment repeatSegment.
// - repeatSegment number of the first repeated segment when repeatCnt is not null
class ToneSegment {
public:
unsigned int duration;
unsigned short waveFreq[TONEGEN_MAX_WAVES+1];
unsigned short loopCnt;
unsigned short loopIndx;
};
class ToneDescriptor {
public:
ToneSegment segments[TONEGEN_MAX_SEGMENTS+1];
unsigned long repeatCnt;
unsigned long repeatSegment;
};
static const ToneDescriptor sToneDescriptors[];
bool mThreadCanCallJava;
unsigned int mTotalSmp; // Total number of audio samples played (gives current time)
unsigned int mNextSegSmp; // Position of next segment transition expressed in samples
// NOTE: because mTotalSmp, mNextSegSmp are stored on 32 bit, current design will operate properly
// only if tone duration is less than about 27 Hours(@44100Hz sampling rate). If this time is exceeded,
// no crash will occur but tone sequence will show a glitch.
unsigned int mMaxSmp; // Maximum number of audio samples played (maximun tone duration)
int mDurationMs; // Maximum tone duration in ms
unsigned short mCurSegment; // Current segment index in ToneDescriptor segments[]
unsigned short mCurCount; // Current sequence repeat count
volatile unsigned short mState; // ToneGenerator state (tone_state)
unsigned short mRegion;
const ToneDescriptor *mpToneDesc; // pointer to active tone descriptor
const ToneDescriptor *mpNewToneDesc; // pointer to next active tone descriptor
unsigned short mLoopCounter; // Current tone loopback count
int mSamplingRate; // AudioFlinger Sampling rate
AudioTrack *mpAudioTrack; // Pointer to audio track used for playback
Mutex mLock; // Mutex to control concurent access to ToneGenerator object from audio callback and application API
Mutex mCbkCondLock; // Mutex associated to mWaitCbkCond
Condition mWaitCbkCond; // condition enabling interface to wait for audio callback completion after a change is requested
float mVolume; // Volume applied to audio track
int mStreamType; // Audio stream used for output
unsigned int mProcessSize; // Size of audio blocks generated at a time by audioCallback() (in PCM frames).
bool initAudioTrack();
static void audioCallback(int event, void* user, void *info);
bool prepareWave();
unsigned int numWaves(unsigned int segmentIdx);
void clearWaveGens();
int getToneForRegion(int toneType);
// WaveGenerator generates a single sine wave
class WaveGenerator {
public:
enum gen_command {
WAVEGEN_START, // Start/restart wave from phase 0
WAVEGEN_CONT, // Continue wave from current phase
WAVEGEN_STOP // Stop wave on zero crossing
};
WaveGenerator(unsigned short samplingRate, unsigned short frequency,
float volume);
~WaveGenerator();
void getSamples(short *outBuffer, unsigned int count,
unsigned int command);
private:
static const short GEN_AMP = 32000; // amplitude of generator
static const short S_Q14 = 14; // shift for Q14
static const short S_Q15 = 15; // shift for Q15
short mA1_Q14; // Q14 coefficient
// delay line of full amplitude generator
short mS1, mS2; // delay line S2 oldest
short mS2_0; // saved value for reinitialisation
short mAmplitude_Q15; // Q15 amplitude
};
KeyedVector<unsigned short, WaveGenerator *> mWaveGens; // list of active wave generators.
};
}
; // namespace android
#endif /*ANDROID_TONEGENERATOR_H_*/
+159
View File
@@ -0,0 +1,159 @@
/*
* 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_MEDIA_VISUALIZER_H
#define ANDROID_MEDIA_VISUALIZER_H
#include <media/AudioEffect.h>
#include <media/EffectVisualizerApi.h>
#include <string.h>
/**
* The Visualizer class enables application to retrieve part of the currently playing audio for
* visualization purpose. It is not an audio recording interface and only returns partial and low
* quality audio content. However, to protect privacy of certain audio data (e.g voice mail) the use
* of the visualizer requires the permission android.permission.RECORD_AUDIO.
* The audio session ID passed to the constructor indicates which audio content should be
* visualized:
* - If the session is 0, the audio output mix is visualized
* - If the session is not 0, the audio from a particular MediaPlayer or AudioTrack
* using this audio session is visualized
* Two types of representation of audio content can be captured:
* - Waveform data: consecutive 8-bit (unsigned) mono samples by using the getWaveForm() method
* - Frequency data: 8-bit magnitude FFT by using the getFft() method
*
* The length of the capture can be retrieved or specified by calling respectively
* getCaptureSize() and setCaptureSize() methods. Note that the size of the FFT
* is half of the specified capture size but both sides of the spectrum are returned yielding in a
* number of bytes equal to the capture size. The capture size must be a power of 2 in the range
* returned by getMinCaptureSize() and getMaxCaptureSize().
* In addition to the polling capture mode, a callback mode is also available by installing a
* callback function by use of the setCaptureCallBack() method. The rate at which the callback
* is called as well as the type of data returned is specified.
* Before capturing data, the Visualizer must be enabled by calling the setEnabled() method.
* When data capture is not needed any more, the Visualizer should be disabled.
*/
namespace android {
// ----------------------------------------------------------------------------
class Visualizer: public AudioEffect {
public:
enum callback_flags {
CAPTURE_WAVEFORM = 0x00000001, // capture callback returns a PCM wave form
CAPTURE_FFT = 0x00000002, // apture callback returns a frequency representation
CAPTURE_CALL_JAVA = 0x00000004 // the callback thread can call java
};
/* Constructor.
* See AudioEffect constructor for details on parameters.
*/
Visualizer(int32_t priority = 0,
effect_callback_t cbf = 0,
void* user = 0,
int sessionId = 0);
~Visualizer();
virtual status_t setEnabled(bool enabled);
// maximum capture size in samples
static uint32_t getMaxCaptureSize() { return VISUALIZER_CAPTURE_SIZE_MAX; }
// minimum capture size in samples
static uint32_t getMinCaptureSize() { return VISUALIZER_CAPTURE_SIZE_MIN; }
// maximum capture rate in millihertz
static uint32_t getMaxCaptureRate() { return CAPTURE_RATE_MAX; }
// callback used to return periodic PCM or FFT captures to the application. Either one or both
// types of data are returned (PCM and FFT) according to flags indicated when installing the
// callback. When a type of data is not present, the corresponding size (waveformSize or
// fftSize) is 0.
typedef void (*capture_cbk_t)(void* user,
uint32_t waveformSize,
uint8_t *waveform,
uint32_t fftSize,
uint8_t *fft,
uint32_t samplingrate);
// install a callback to receive periodic captures. The capture rate is specified in milliHertz
// and the capture format is according to flags (see callback_flags).
status_t setCaptureCallBack(capture_cbk_t cbk, void* user, uint32_t flags, uint32_t rate);
// set the capture size capture size must be a power of two in the range
// [VISUALIZER_CAPTURE_SIZE_MAX. VISUALIZER_CAPTURE_SIZE_MIN]
// must be called when the visualizer is not enabled
status_t setCaptureSize(uint32_t size);
uint32_t getCaptureSize() { return mCaptureSize; }
// returns the capture rate indicated when installing the callback
uint32_t getCaptureRate() { return mCaptureRate; }
// returns the sampling rate of the audio being captured
uint32_t getSamplingRate() { return mSampleRate; }
// return a capture in PCM 8 bit unsigned format. The size of the capture is equal to
// getCaptureSize()
status_t getWaveForm(uint8_t *waveform);
// return a capture in FFT 8 bit signed format. The size of the capture is equal to
// getCaptureSize() but the length of the FFT is half of the size (both parts of the spectrum
// are returned
status_t getFft(uint8_t *fft);
private:
static const uint32_t CAPTURE_RATE_MAX = 20000;
static const uint32_t CAPTURE_RATE_DEF = 10000;
static const uint32_t CAPTURE_SIZE_DEF = VISUALIZER_CAPTURE_SIZE_MAX;
/* internal class to handle the callback */
class CaptureThread : public Thread
{
public:
CaptureThread(Visualizer& receiver, uint32_t captureRate, bool bCanCallJava = false);
private:
friend class Visualizer;
virtual bool threadLoop();
virtual status_t readyToRun();
virtual void onFirstRef();
Visualizer& mReceiver;
Mutex mLock;
uint32_t mSleepTimeUs;
};
status_t doFft(uint8_t *fft, uint8_t *waveform);
void periodicCapture();
uint32_t initCaptureSize();
Mutex mLock;
uint32_t mCaptureRate;
uint32_t mCaptureSize;
uint32_t mSampleRate;
capture_cbk_t mCaptureCallBack;
void *mCaptureCbkUser;
sp<CaptureThread> mCaptureThread;
uint32_t mCaptureFlags;
};
}; // namespace android
#endif // ANDROID_MEDIA_VISUALIZER_H
@@ -0,0 +1,87 @@
/*
* 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 MEDIAMETADATARETRIEVER_H
#define MEDIAMETADATARETRIEVER_H
#include <utils/Errors.h> // for status_t
#include <utils/threads.h>
#include <binder/IMemory.h>
#include <media/IMediaMetadataRetriever.h>
namespace android {
class IMediaPlayerService;
class IMediaMetadataRetriever;
// Keep these in synch with the constants defined in MediaMetadataRetriever.java
// class.
enum {
METADATA_KEY_CD_TRACK_NUMBER = 0,
METADATA_KEY_ALBUM = 1,
METADATA_KEY_ARTIST = 2,
METADATA_KEY_AUTHOR = 3,
METADATA_KEY_COMPOSER = 4,
METADATA_KEY_DATE = 5,
METADATA_KEY_GENRE = 6,
METADATA_KEY_TITLE = 7,
METADATA_KEY_YEAR = 8,
METADATA_KEY_DURATION = 9,
METADATA_KEY_NUM_TRACKS = 10,
METADATA_KEY_WRITER = 11,
METADATA_KEY_MIMETYPE = 12,
METADATA_KEY_ALBUMARTIST = 13,
METADATA_KEY_DISC_NUMBER = 14,
METADATA_KEY_COMPILATION = 15,
// Add more here...
};
class MediaMetadataRetriever: public RefBase
{
public:
MediaMetadataRetriever();
~MediaMetadataRetriever();
void disconnect();
status_t setDataSource(const char* dataSourceUrl);
status_t setDataSource(int fd, int64_t offset, int64_t length);
sp<IMemory> getFrameAtTime(int64_t timeUs, int option);
sp<IMemory> extractAlbumArt();
const char* extractMetadata(int keyCode);
private:
static const sp<IMediaPlayerService>& getService();
class DeathNotifier: public IBinder::DeathRecipient
{
public:
DeathNotifier() {}
virtual ~DeathNotifier();
virtual void binderDied(const wp<IBinder>& who);
};
static sp<DeathNotifier> sDeathNotifier;
static Mutex sServiceLock;
static sp<IMediaPlayerService> sService;
Mutex mLock;
sp<IMediaMetadataRetriever> mRetriever;
};
}; // namespace android
#endif // MEDIAMETADATARETRIEVER_H
+222
View File
@@ -0,0 +1,222 @@
/*
* Copyright (C) 2007 The Android Open Source Project
* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* 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_MEDIAPLAYER_H
#define ANDROID_MEDIAPLAYER_H
#include <binder/IMemory.h>
#include <media/IMediaPlayerClient.h>
#include <media/IMediaPlayer.h>
#include <media/IMediaDeathNotifier.h>
#include <utils/KeyedVector.h>
#include <utils/String8.h>
namespace android {
class Surface;
enum media_invoke_type {
MEDIA_INVOKE_REGISTER_BUFFERS = 1,
MEDIA_INVOKE_UNREGISTER_BUFFERS = 2,
MEDIA_INVOKE_QUEUE_BUFFER = 3,
MEDIA_INVOKE_QUERY_BUFFER_FORMAT = 4,
};
enum media_event_type {
MEDIA_NOP = 0, // interface test message
MEDIA_PREPARED = 1,
MEDIA_PLAYBACK_COMPLETE = 2,
MEDIA_BUFFERING_UPDATE = 3,
MEDIA_SEEK_COMPLETE = 4,
MEDIA_SET_VIDEO_SIZE = 5,
MEDIA_ERROR = 100,
MEDIA_INFO = 200,
MEDIA_FORMAT_CHANGED = 1001, // video format changed, shared memory buffers need to be freed and reallocated
MEDIA_BUFFER_READY = 1002, // return buffer to mediaplayer client
};
// Generic error codes for the media player framework. Errors are fatal, the
// playback must abort.
//
// Errors are communicated back to the client using the
// MediaPlayerListener::notify method defined below.
// In this situation, 'notify' is invoked with the following:
// 'msg' is set to MEDIA_ERROR.
// 'ext1' should be a value from the enum media_error_type.
// 'ext2' contains an implementation dependant error code to provide
// more details. Should default to 0 when not used.
//
// The codes are distributed as follow:
// 0xx: Reserved
// 1xx: Android Player errors. Something went wrong inside the MediaPlayer.
// 2xx: Media errors (e.g Codec not supported). There is a problem with the
// media itself.
// 3xx: Runtime errors. Some extraordinary condition arose making the playback
// impossible.
//
enum media_error_type {
// 0xx
MEDIA_ERROR_UNKNOWN = 1,
// 1xx
MEDIA_ERROR_SERVER_DIED = 100,
// 2xx
MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200,
// 3xx
};
// Info and warning codes for the media player framework. These are non fatal,
// the playback is going on but there might be some user visible issues.
//
// Info and warning messages are communicated back to the client using the
// MediaPlayerListener::notify method defined below. In this situation,
// 'notify' is invoked with the following:
// 'msg' is set to MEDIA_INFO.
// 'ext1' should be a value from the enum media_info_type.
// 'ext2' contains an implementation dependant info code to provide
// more details. Should default to 0 when not used.
//
// The codes are distributed as follow:
// 0xx: Reserved
// 7xx: Android Player info/warning (e.g player lagging behind.)
// 8xx: Media info/warning (e.g media badly interleaved.)
//
enum media_info_type {
// 0xx
MEDIA_INFO_UNKNOWN = 1,
// 7xx
// The video is too complex for the decoder: it can't decode frames fast
// enough. Possibly only the audio plays fine at this stage.
MEDIA_INFO_VIDEO_TRACK_LAGGING = 700,
// MediaPlayer is temporarily pausing playback internally in order to
// buffer more data.
MEDIA_INFO_BUFFERING_START = 701,
// MediaPlayer is resuming playback after filling buffers.
MEDIA_INFO_BUFFERING_END = 702,
// 8xx
// Bad interleaving means that a media has been improperly interleaved or not
// interleaved at all, e.g has all the video samples first then all the audio
// ones. Video is playing but a lot of disk seek may be happening.
MEDIA_INFO_BAD_INTERLEAVING = 800,
// The media is not seekable (e.g live stream).
MEDIA_INFO_NOT_SEEKABLE = 801,
// New media metadata is available.
MEDIA_INFO_METADATA_UPDATE = 802,
};
enum media_player_states {
MEDIA_PLAYER_STATE_ERROR = 0,
MEDIA_PLAYER_IDLE = 1 << 0,
MEDIA_PLAYER_INITIALIZED = 1 << 1,
MEDIA_PLAYER_PREPARING = 1 << 2,
MEDIA_PLAYER_PREPARED = 1 << 3,
MEDIA_PLAYER_STARTED = 1 << 4,
MEDIA_PLAYER_PAUSED = 1 << 5,
MEDIA_PLAYER_STOPPED = 1 << 6,
MEDIA_PLAYER_PLAYBACK_COMPLETE = 1 << 7
};
// ----------------------------------------------------------------------------
// ref-counted object for callbacks
class MediaPlayerListener: virtual public RefBase
{
public:
virtual void notify(int msg, int ext1, int ext2) = 0;
};
class MediaPlayer : public BnMediaPlayerClient,
public virtual IMediaDeathNotifier
{
public:
MediaPlayer();
~MediaPlayer();
void died();
void disconnect();
status_t setDataSource(
const char *url,
const KeyedVector<String8, String8> *headers);
status_t setDataSource(int fd, int64_t offset, int64_t length);
status_t setVideoSurface(const sp<Surface>& surface);
status_t setListener(const sp<MediaPlayerListener>& listener);
status_t prepare();
status_t prepareAsync();
status_t start();
status_t stop();
status_t pause();
bool isPlaying();
status_t getVideoWidth(int *w);
status_t getVideoHeight(int *h);
status_t seekTo(int msec);
status_t getCurrentPosition(int *msec);
status_t getDuration(int *msec);
status_t reset();
status_t setAudioStreamType(int type);
status_t setLooping(int loop);
bool isLooping();
status_t setVolume(float leftVolume, float rightVolume);
void notify(int msg, int ext1, int ext2);
static sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
static sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
status_t invoke(const Parcel& request, Parcel *reply);
status_t setMetadataFilter(const Parcel& filter);
status_t getMetadata(bool update_only, bool apply_filter, Parcel *metadata);
status_t suspend();
status_t resume();
status_t setAudioSessionId(int sessionId);
int getAudioSessionId();
status_t setAuxEffectSendLevel(float level);
status_t attachAuxEffect(int effectId);
status_t setVideoSurface(const sp<ISurface>& surface);
status_t setParameters(const String8& params);
private:
void clear_l();
status_t seekTo_l(int msec);
status_t prepareAsync_l();
status_t getDuration_l(int *msec);
status_t setDataSource(const sp<IMediaPlayer>& player);
sp<IMediaPlayer> mPlayer;
thread_id_t mLockThreadId;
Mutex mLock;
Mutex mNotifyLock;
Condition mSignal;
sp<MediaPlayerListener> mListener;
void* mCookie;
media_player_states mCurrentState;
int mDuration;
int mCurrentPosition;
int mSeekPosition;
bool mPrepareSync;
status_t mPrepareStatus;
int mStreamType;
bool mLoop;
float mLeftVolume;
float mRightVolume;
int mVideoWidth;
int mVideoHeight;
int mAudioSessionId;
float mSendLevel;
};
}; // namespace android
#endif // ANDROID_MEDIAPLAYER_H
+224
View File
@@ -0,0 +1,224 @@
/*
** 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_MEDIARECORDER_H
#define ANDROID_MEDIARECORDER_H
#include <utils/Log.h>
#include <utils/threads.h>
#include <utils/List.h>
#include <utils/Errors.h>
#include <media/IMediaRecorderClient.h>
#include <media/IMediaDeathNotifier.h>
namespace android {
class Surface;
class IMediaRecorder;
class ICamera;
typedef void (*media_completion_f)(status_t status, void *cookie);
/* Do not change these values without updating their counterparts
* in media/java/android/media/MediaRecorder.java!
*/
enum audio_source {
AUDIO_SOURCE_DEFAULT = 0,
AUDIO_SOURCE_MIC = 1,
AUDIO_SOURCE_VOICE_UPLINK = 2,
AUDIO_SOURCE_VOICE_DOWNLINK = 3,
AUDIO_SOURCE_VOICE_CALL = 4,
AUDIO_SOURCE_CAMCORDER = 5,
AUDIO_SOURCE_VOICE_RECOGNITION = 6,
AUDIO_SOURCE_VOICE_COMMUNICATION = 7,
AUDIO_SOURCE_FM_RX = 8,
AUDIO_SOURCE_FM_RX_A2DP = 9,
AUDIO_SOURCE_MAX = AUDIO_SOURCE_FM_RX_A2DP,
AUDIO_SOURCE_LIST_END // must be last - used to validate audio source type
};
enum video_source {
VIDEO_SOURCE_DEFAULT = 0,
VIDEO_SOURCE_CAMERA = 1,
VIDEO_SOURCE_LIST_END // must be last - used to validate audio source type
};
//Please update media/java/android/media/MediaRecorder.java if the following is updated.
enum output_format {
OUTPUT_FORMAT_DEFAULT = 0,
OUTPUT_FORMAT_THREE_GPP = 1,
OUTPUT_FORMAT_MPEG_4 = 2,
OUTPUT_FORMAT_AUDIO_ONLY_START = 3, // Used in validating the output format. Should be the
// at the start of the audio only output formats.
/* These are audio only file formats */
OUTPUT_FORMAT_RAW_AMR = 3, //to be backward compatible
OUTPUT_FORMAT_AMR_NB = 3,
OUTPUT_FORMAT_AMR_WB = 4,
OUTPUT_FORMAT_AAC_ADIF = 5,
OUTPUT_FORMAT_AAC_ADTS = 6,
/* Stream over a socket, limited to a single stream */
OUTPUT_FORMAT_RTP_AVP = 7,
/* H.264/AAC data encapsulated in MPEG2/TS */
OUTPUT_FORMAT_MPEG2TS = 8,
OUTPUT_FORMAT_QCP = 9, // QCP file format
OUTPUT_FORMAT_THREE_GPP2 = 10, /*3GPP2*/
OUTPUT_FORMAT_LIST_END // must be last - used to validate format type
};
enum audio_encoder {
AUDIO_ENCODER_DEFAULT = 0,
AUDIO_ENCODER_AMR_NB = 1,
AUDIO_ENCODER_AMR_WB = 2,
AUDIO_ENCODER_AAC = 3,
AUDIO_ENCODER_AAC_PLUS = 4,
AUDIO_ENCODER_EAAC_PLUS = 5,
AUDIO_ENCODER_EVRC = 6,
AUDIO_ENCODER_QCELP = 7,
AUDIO_ENCODER_LIST_END // must be the last - used to validate the audio encoder type
};
enum video_encoder {
VIDEO_ENCODER_DEFAULT = 0,
VIDEO_ENCODER_H263 = 1,
VIDEO_ENCODER_H264 = 2,
VIDEO_ENCODER_MPEG_4_SP = 3,
VIDEO_ENCODER_LIST_END // must be the last - used to validate the video encoder type
};
/*
* The state machine of the media_recorder uses a set of different state names.
* The mapping between the media_recorder and the pvauthorengine is shown below:
*
* mediarecorder pvauthorengine
* ----------------------------------------------------------------
* MEDIA_RECORDER_ERROR ERROR
* MEDIA_RECORDER_IDLE IDLE
* MEDIA_RECORDER_INITIALIZED OPENED
* MEDIA_RECORDER_DATASOURCE_CONFIGURED
* MEDIA_RECORDER_PREPARED INITIALIZED
* MEDIA_RECORDER_RECORDING RECORDING
*/
enum media_recorder_states {
MEDIA_RECORDER_ERROR = 0,
MEDIA_RECORDER_IDLE = 1 << 0,
MEDIA_RECORDER_INITIALIZED = 1 << 1,
MEDIA_RECORDER_DATASOURCE_CONFIGURED = 1 << 2,
MEDIA_RECORDER_PREPARED = 1 << 3,
MEDIA_RECORDER_RECORDING = 1 << 4,
};
// The "msg" code passed to the listener in notify.
enum media_recorder_event_type {
MEDIA_RECORDER_EVENT_ERROR = 1,
MEDIA_RECORDER_EVENT_INFO = 2,
MEDIA_RECORDER_MSG_COMPRESSED_IMAGE = 8
};
enum media_recorder_error_type {
MEDIA_RECORDER_ERROR_UNKNOWN = 1,
MEDIA_RECORDER_ERROR_RESOURCE = 2
};
// The codes are distributed as follow:
// 0xx: Reserved
// 8xx: General info/warning
//
enum media_recorder_info_type {
MEDIA_RECORDER_INFO_UNKNOWN = 1,
MEDIA_RECORDER_INFO_MAX_DURATION_REACHED = 800,
MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED = 801,
MEDIA_RECORDER_INFO_COMPLETION_STATUS = 802,
MEDIA_RECORDER_INFO_PROGRESS_FRAME_STATUS = 803,
MEDIA_RECORDER_INFO_PROGRESS_TIME_STATUS = 804,
MEDIA_RECORDER_UNSUPPORTED_RESOLUTION = 805,
};
// ----------------------------------------------------------------------------
// ref-counted object for callbacks
class MediaRecorderListener: virtual public RefBase
{
public:
virtual void notify(int msg, int ext1, int ext2) = 0;
virtual void postData(int32_t msgType, const sp<IMemory>& dataPtr) = 0;
};
class MediaRecorder : public BnMediaRecorderClient,
public virtual IMediaDeathNotifier
{
public:
MediaRecorder();
~MediaRecorder();
void died();
status_t initCheck();
status_t setCamera(const sp<ICamera>& camera);
status_t setPreviewSurface(const sp<Surface>& surface);
status_t setVideoSource(int vs);
status_t setAudioSource(int as);
status_t setOutputFormat(int of);
status_t setVideoEncoder(int ve);
status_t setAudioEncoder(int ae);
status_t setOutputFile(const char* path);
status_t setOutputFile(int fd, int64_t offset, int64_t length);
status_t setVideoSize(int width, int height);
status_t setVideoFrameRate(int frames_per_second);
status_t setParameters(const String8& params);
status_t setCameraParameters(const String8& params);
status_t setListener(const sp<MediaRecorderListener>& listener);
status_t prepare();
status_t getMaxAmplitude(int* max);
status_t start();
status_t takeLiveSnapshot();
status_t stop();
status_t reset();
status_t init();
status_t close();
status_t release();
void notify(int msg, int ext1, int ext2);
void dataCallback(int32_t msgType, const sp<IMemory>& dataPtr);
private:
void doCleanUp();
status_t doReset();
sp<IMediaRecorder> mMediaRecorder;
sp<MediaRecorderListener> mListener;
media_recorder_states mCurrentState;
bool mIsAudioSourceSet;
bool mIsVideoSourceSet;
bool mIsAudioEncoderSet;
bool mIsVideoEncoderSet;
bool mIsOutputFileSet;
Mutex mLock;
Mutex mNotifyLock;
Mutex mdataCallbackLock;
};
}; // namespace android
#endif // ANDROID_MEDIARECORDER_H
+96
View File
@@ -0,0 +1,96 @@
/*
* 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 MEDIASCANNER_H
#define MEDIASCANNER_H
#include <utils/Log.h>
#include <utils/threads.h>
#include <utils/List.h>
#include <utils/Errors.h>
#include <pthread.h>
namespace android {
class MediaScannerClient;
class StringArray;
struct MediaScanner {
MediaScanner();
virtual ~MediaScanner();
virtual status_t processFile(
const char *path, const char *mimeType,
MediaScannerClient &client) = 0;
typedef bool (*ExceptionCheck)(void* env);
virtual status_t processDirectory(
const char *path, const char *extensions,
MediaScannerClient &client,
ExceptionCheck exceptionCheck, void *exceptionEnv);
void setLocale(const char *locale);
// extracts album art as a block of data
virtual char *extractAlbumArt(int fd) = 0;
protected:
const char *locale() const;
private:
// current locale (like "ja_JP"), created/destroyed with strdup()/free()
char *mLocale;
status_t doProcessDirectory(
char *path, int pathRemaining, const char *extensions,
MediaScannerClient &client, ExceptionCheck exceptionCheck,
void *exceptionEnv);
MediaScanner(const MediaScanner &);
MediaScanner &operator=(const MediaScanner &);
};
class MediaScannerClient
{
public:
MediaScannerClient();
virtual ~MediaScannerClient();
void setLocale(const char* locale);
void beginFile();
bool addStringTag(const char* name, const char* value);
void endFile();
virtual bool scanFile(const char* path, long long lastModified, long long fileSize) = 0;
virtual bool handleStringTag(const char* name, const char* value) = 0;
virtual bool setMimeType(const char* mimeType) = 0;
virtual bool addNoMediaFolder(const char* path) = 0;
protected:
void convertValues(uint32_t encoding);
protected:
// cached name and value strings, for native encoding support.
StringArray* mNames;
StringArray* mValues;
// default encoding based on MediaScanner::mLocale string
uint32_t mLocaleEncoding;
};
}; // namespace android
#endif // MEDIASCANNER_H
@@ -0,0 +1,70 @@
/*
* 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 AMR_WRITER_H_
#define AMR_WRITER_H_
#include <stdio.h>
#include <media/stagefright/MediaWriter.h>
#include <utils/threads.h>
namespace android {
struct MediaSource;
struct MetaData;
struct AMRWriter : public MediaWriter {
AMRWriter(const char *filename);
AMRWriter(int fd);
status_t initCheck() const;
virtual status_t addSource(const sp<MediaSource> &source);
virtual bool reachedEOS();
virtual status_t start(MetaData *params = NULL);
virtual status_t stop();
virtual status_t pause();
protected:
virtual ~AMRWriter();
private:
FILE *mFile;
status_t mInitCheck;
sp<MediaSource> mSource;
bool mStarted;
volatile bool mPaused;
volatile bool mResumed;
volatile bool mDone;
volatile bool mReachedEOS;
pthread_t mThread;
int64_t mEstimatedSizeBytes;
int64_t mEstimatedDurationUs;
static void *ThreadWrapper(void *);
status_t threadFunc();
bool exceedsFileSizeLimit();
bool exceedsFileDurationLimit();
AMRWriter(const AMRWriter &);
AMRWriter &operator=(const AMRWriter &);
};
} // namespace android
#endif // AMR_WRITER_H_
@@ -0,0 +1,118 @@
/*
* 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 AUDIO_PLAYER_H_
#define AUDIO_PLAYER_H_
#include <media/MediaPlayerInterface.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/TimeSource.h>
#include <utils/threads.h>
namespace android {
class MediaSource;
class AudioTrack;
class AwesomePlayer;
class AudioPlayer : public TimeSource {
public:
enum {
REACHED_EOS,
SEEK_COMPLETE
};
AudioPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink,
AwesomePlayer *audioObserver = NULL);
virtual ~AudioPlayer();
// Caller retains ownership of "source".
virtual void setSource(const sp<MediaSource> &source);
// Return time in us.
virtual int64_t getRealTimeUs();
virtual status_t start(bool sourceAlreadyStarted = false);
virtual void pause(bool playPendingSamples = false);
virtual void resume();
// Returns the timestamp of the last buffer played (in us).
virtual int64_t getMediaTimeUs();
// Returns true iff a mapping is established, i.e. the AudioPlayer
// has played at least one frame of audio.
virtual bool getMediaTimeMapping(int64_t *realtime_us, int64_t *mediatime_us);
virtual status_t seekTo(int64_t time_us);
virtual bool isSeeking();
virtual bool reachedEOS(status_t *finalStatus);
private:
sp<MediaSource> mSource;
AudioTrack *mAudioTrack;
MediaBuffer *mInputBuffer;
int mSampleRate;
int64_t mLatencyUs;
size_t mFrameSize;
Mutex mLock;
int64_t mNumFramesPlayed;
int64_t mPositionTimeMediaUs;
int64_t mPositionTimeRealUs;
bool mSeeking;
bool mReachedEOS;
status_t mFinalStatus;
int64_t mSeekTimeUs;
bool mStarted;
bool mSourceStopped;
bool mIsFirstBuffer;
status_t mFirstBufferResult;
MediaBuffer *mFirstBuffer;
sp<MediaPlayerBase::AudioSink> mAudioSink;
AwesomePlayer *mObserver;
bool mPaused;
static void AudioCallback(int event, void *user, void *info);
void AudioCallback(int event, void *info);
static size_t AudioSinkCallback(
MediaPlayerBase::AudioSink *audioSink,
void *data, size_t size, void *me);
size_t fillBuffer(void *data, size_t size);
int64_t getRealTimeUsLocked() const;
void reset();
AudioPlayer(const AudioPlayer &);
AudioPlayer &operator=(const AudioPlayer &);
};
} // namespace android
#endif // AUDIO_PLAYER_H_
@@ -0,0 +1,106 @@
/*
* 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 AUDIO_SOURCE_H_
#define AUDIO_SOURCE_H_
#include <media/AudioSystem.h>
#include <media/stagefright/MediaSource.h>
namespace android {
class AudioRecord;
struct MediaBufferGroup;
struct AudioSource : public MediaSource {
// Note that the "channels" parameter is _not_ the number of channels,
// but a bitmask of AudioSystem::audio_channels constants.
AudioSource(
int inputSource, uint32_t sampleRate,
uint32_t channels = AudioSystem::CHANNEL_IN_MONO);
status_t initCheck() const;
virtual status_t start(MetaData *params = NULL);
virtual status_t stop();
virtual sp<MetaData> getFormat();
// Returns the maximum amplitude since last call.
int16_t getMaxAmplitude();
virtual status_t read(
MediaBuffer **buffer, const ReadOptions *options = NULL);
protected:
virtual ~AudioSource();
private:
enum {
kMaxBufferSize = 4096,
// After the initial mute, we raise the volume linearly
// over kAutoRampDurationUs.
kAutoRampDurationUs = 700000,
// This is the initial mute duration to suppress
// the video recording signal tone
kAutoRampStartUs = 1000000,
};
AudioRecord *mRecord;
status_t mInitCheck;
bool mStarted;
bool mFirstFrame;
bool mCollectStats;
bool mTrackMaxAmplitude;
int64_t mStartTimeUs;
int16_t mMaxAmplitude;
int64_t mPrevSampleTimeUs;
int64_t mTotalLostFrames;
int64_t mPrevLostBytes;
int64_t mInitialReadTimeUs;
MediaBufferGroup *mGroup;
void trackMaxAmplitude(int16_t *data, int nSamples);
// This is used to raise the volume from mute to the
// actual level linearly.
void rampVolume(
int32_t startFrame, int32_t rampDurationFrames,
uint8_t *data, size_t bytes);
AudioSource(const AudioSource &);
AudioSource &operator=(const AudioSource &);
//additions for tunnel source
public:
AudioSource(
int inputSource, const sp<MetaData>& meta );
private:
int32_t mFormat;
String8 mMime;
int32_t mMaxBufferSize;
int32_t mNumChannels;
int64_t bufferDurationUs( ssize_t n );
};
} // namespace android
#endif // AUDIO_SOURCE_H_
@@ -0,0 +1,104 @@
/*
* 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 CAMERA_SOURCE_H_
#define CAMERA_SOURCE_H_
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaSource.h>
#include <utils/List.h>
#include <utils/RefBase.h>
#include <utils/threads.h>
#include <media/IMediaRecorderClient.h>
namespace android {
class ICamera;
class IMemory;
class Camera;
class CameraSource : public MediaSource, public MediaBufferObserver {
public:
static CameraSource *Create();
static CameraSource *CreateFromCamera(const sp<Camera> &camera);
virtual ~CameraSource();
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 void signalBufferReturned(MediaBuffer* buffer);
virtual status_t getBufferInfo(sp<IMemory>& Frame, size_t *alignedSize);
//this function is not virtual.
void setListener(const sp<IMediaRecorderClient>& listener) {
mListener = listener;
}
private:
friend class CameraSourceListener;
sp<Camera> mCamera;
sp<MetaData> mMeta;
Mutex mLock;
Condition mFrameAvailableCondition;
Condition mFrameCompleteCondition;
List<sp<IMemory> > mFramesReceived;
List<sp<IMemory> > mFramesBeingEncoded;
List<int64_t> mFrameTimes;
int64_t mStartTimeUs;
int64_t mFirstFrameTimeUs;
int64_t mLastFrameTimestampUs;
int32_t mNumFramesReceived;
int32_t mNumFramesEncoded;
int32_t mNumFramesDropped;
int32_t mNumGlitches;
bool mFatalErrorBailout;
int64_t mGlitchDurationThresholdUs;
bool mCollectStats;
bool mStarted;
sp<IMediaRecorderClient> mListener;
CameraSource(const sp<Camera> &camera);
void dataCallbackTimestamp(
int64_t timestampUs, int32_t msgType, const sp<IMemory> &data);
void dataCallback(
int32_t msgType, const sp<IMemory> &data);
void errorCallback( );
void releaseQueuedFrames();
void releaseOneRecordingFrame(const sp<IMemory>& frame);
CameraSource(const CameraSource &);
CameraSource &operator=(const CameraSource &);
};
} // namespace android
#endif // CAMERA_SOURCE_H_
@@ -0,0 +1,122 @@
/*
* Copyright (C) 2009 The Android Open Source Project
* Copyright (c) 2010-2011, The Linux Foundation
*
* 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 <OMX_Video.h>
namespace android {
struct ColorConverter {
ColorConverter(OMX_COLOR_FORMATTYPE from, OMX_COLOR_FORMATTYPE to);
~ColorConverter();
bool isValid() const;
void convert(
size_t width, size_t height,
const void *srcBits, size_t srcSkip,
void *dstBits, size_t dstSkip);
private:
OMX_COLOR_FORMATTYPE mSrcFormat, mDstFormat;
uint8_t *mClip;
uint8_t *initClip();
void convertCbYCrY(
size_t width, size_t height,
const void *srcBits, size_t srcSkip,
void *dstBits, size_t dstSkip);
void convertYUV420Planar(
size_t width, size_t height,
const void *srcBits, size_t srcSkip,
void *dstBits, size_t dstSkip);
void convertQCOMYUV420SemiPlanar(
size_t width, size_t height,
const void *srcBits, size_t srcSkip,
void *dstBits, size_t dstSkip);
void convertYUV420SemiPlanar(
size_t width, size_t height,
const void *srcBits, size_t srcSkip,
void *dstBits, size_t dstSkip);
void convertYUV420SemiPlanar32Aligned(
size_t width, size_t height,
const void *srcBits, size_t srcSkip,
void *dstBits, size_t dstSkip,
size_t alignedWidth);
ColorConverter(const ColorConverter &);
ColorConverter &operator=(const ColorConverter &);
};
enum ColorConvertFormat {
RGB565 = 1,
YCbCr420Tile,
YCbCr420SP,
YCbCr420P,
YCrCb420P,
};
enum ColorConvertFlags {
COLOR_CONVERT_ALIGN_NONE = 1,
COLOR_CONVERT_CENTER_OUTPUT = 1<<1,
COLOR_CONVERT_ALIGN_16 = 1<<4,
COLOR_CONVERT_ALIGN_2048 = 1<<11,
COLOR_CONVERT_ALIGN_8192 = 1<<13,
};
struct ColorConvertParams {
size_t width;
size_t height;
size_t cropWidth;
size_t cropHeight;
size_t cropLeft;
size_t cropRight;
size_t cropTop;
size_t cropBottom;
ColorConvertFormat colorFormat;
const void * data;
int fd;
uint64_t flags;
};
typedef int (* ConvertFn)(ColorConvertParams src,
ColorConvertParams dst, uint8_t *adjustedClip);
int convert(ColorConvertParams src, ColorConvertParams dst,
uint8_t *adjustedClip);
} // namespace android
#endif // COLOR_CONVERTER_H_
@@ -0,0 +1,89 @@
/*
* 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 <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <utils/List.h>
#include <utils/RefBase.h>
#include <utils/threads.h>
namespace android {
struct AMessage;
class String8;
class DataSource : public RefBase {
public:
enum Flags {
kWantsPrefetching = 1,
kStreamedFromLocalHost = 2,
kIsCachingDataSource = 4,
};
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;
}
////////////////////////////////////////////////////////////////////////////
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();
protected:
virtual ~DataSource() {}
private:
static Mutex gSnifferMutex;
static List<SnifferFunc> gSniffers;
DataSource(const DataSource &);
DataSource &operator=(const DataSource &);
};
} // namespace android
#endif // DATA_SOURCE_H_
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2010, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EXTENDED_EXTRACTOR_FUNCS_
#define EXTENDED_EXTRACTOR_FUNCS_
#include <media/stagefright/DataSource.h>
namespace android {
class MediaExtractor;
//Prototype for factory function - extended media extractor must export a function with this prototype to
//instantiate MediaExtractor objects.
typedef MediaExtractor* (*MediaExtractorFactory)(const sp<DataSource> &source, const char* mime);
//Function name for extractor factory function. Extended extractor must export a function with this name.
static const char* MEDIA_CREATE_EXTRACTOR = "createExtractor";
//Prototype for function to return sniffers - extended media extractor must export a function with this prototype to
//set a pointer to an array of sniffers and set the count value.
typedef void (*SnifferArrayFunc)(const DataSource::SnifferFunc* snifferArray[], int *count);
//Function name for function to return sniffer array. Extended extractor must export a function with this name.
static const char* MEDIA_SNIFFER_ARRAY = "snifferArray";
} //namespace android
#endif //EXTENDED_EXTRACTOR_FUNCS_
@@ -0,0 +1,126 @@
/*
* Copyright (C) 2011 The Linux Foundation. All rights reserved
*
* 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 EXTENDED_WRITER_H_
#define EXTENDED_WRITER_H_
#include <stdio.h>
#include <media/stagefright/MediaWriter.h>
#include <utils/threads.h>
namespace android {
struct MediaSource;
struct MetaData;
struct ExtendedWriter : public MediaWriter {
ExtendedWriter(const char *filename);
ExtendedWriter(int fd);
status_t initCheck() const;
virtual status_t addSource(const sp<MediaSource> &source);
virtual bool reachedEOS();
virtual status_t start(MetaData *params = NULL);
virtual status_t stop();
virtual status_t pause();
protected:
virtual ~ExtendedWriter();
private:
FILE *mFile;
status_t mInitCheck;
sp<MediaSource> mSource;
bool mStarted;
volatile bool mPaused;
volatile bool mResumed;
volatile bool mDone;
volatile bool mReachedEOS;
pthread_t mThread;
int64_t mEstimatedSizeBytes;
int64_t mEstimatedDurationUs;
int32_t mFormat;
//QCP/EVRC header
struct QCPEVRCHeader
{
/* RIFF Section */
char riff[4];
unsigned int s_riff;
char qlcm[4];
/* Format chunk */
char fmt[4];
unsigned int s_fmt;
char mjr;
char mnr;
unsigned int data1;
/* UNIQUE ID of the codec */
unsigned short data2;
unsigned short data3;
char data4[8];
unsigned short ver;
/* Codec Info */
char name[80];
unsigned short abps;
/* average bits per sec of the codec */
unsigned short bytes_per_pkt;
unsigned short samp_per_block;
unsigned short samp_per_sec;
unsigned short bits_per_samp;
unsigned char vr_num_of_rates;
/* Rate Header fmt info */
unsigned char rvd1[3];
unsigned short vr_bytes_per_pkt[8];
unsigned int rvd2[5];
/* Vrat chunk */
unsigned char vrat[4];
unsigned int s_vrat;
unsigned int v_rate;
unsigned int size_in_pkts;
/* Data chunk */
unsigned char data[4];
unsigned int s_data;
} __attribute__ ((packed));
struct QCPEVRCHeader mHeader;
off_t mOffset; //note off_t
static void *ThreadWrapper(void *);
status_t threadFunc();
bool exceedsFileSizeLimit();
bool exceedsFileDurationLimit();
ExtendedWriter(const ExtendedWriter &);
ExtendedWriter &operator=(const ExtendedWriter &);
status_t writeQCPHeader( );
status_t writeEVRCHeader( );
};
} // namespace android
#endif // AMR_WRITER_H_
@@ -0,0 +1,81 @@
/*
* Copyright (C) 2010 The Android Open Source Project
* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* 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 FM_A2DP_WRITER_H_
#define FM_A2DP_WRITER_H_
#include <stdio.h>
#include <media/stagefright/MediaWriter.h>
#include <utils/threads.h>
#include <media/AudioRecord.h>
#include <utils/List.h>
#include <semaphore.h>
#include <media/mediarecorder.h>
namespace android {
struct MediaSource;
struct MetaData;
struct audioBufferstruct {
public:
audioBufferstruct (void *buff, size_t bufflen)
:audioBuffer(buff), bufferlen(bufflen){}
void *audioBuffer;
size_t bufferlen;
};
struct FMA2DPWriter : public MediaWriter {
FMA2DPWriter();
status_t initCheck() const;
virtual status_t addSource(const sp<MediaSource> &source);
virtual bool reachedEOS();
virtual status_t start(MetaData *params = NULL);
virtual status_t stop();
virtual status_t pause();
virtual status_t allocateBufferPool();
protected:
virtual ~FMA2DPWriter();
private:
List<audioBufferstruct > mFreeQ,mDataQ;
Mutex mFreeQLock,mDataQLock;
sem_t mReaderThreadWakeupsem,mWriterThreadWakeupsem;
pthread_t mReaderThread,mWriterThread;
bool mStarted;
volatile bool mDone;
int32_t mAudioChannels;
int32_t mSampleRate;
int32_t mAudioFormat;
audio_source mAudioSource;
size_t mBufferSize;
static void *ReaderThreadWrapper(void *);
static void *WriterThreadWrapper(void *);
status_t readerthread();
status_t writerthread();
FMA2DPWriter(const FMA2DPWriter &);
FMA2DPWriter &operator=(const FMA2DPWriter &);
};
} // namespace android
#endif // FM_A2DP_WRITER_H_
@@ -0,0 +1,56 @@
/*
* 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 FILE_SOURCE_H_
#define FILE_SOURCE_H_
#include <stdio.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/MediaErrors.h>
#include <utils/threads.h>
namespace android {
class FileSource : public DataSource {
public:
FileSource(const char *filename);
FileSource(int fd, int64_t offset, int64_t length);
virtual status_t initCheck() const;
virtual ssize_t readAt(off64_t offset, void *data, size_t size);
virtual status_t getSize(off64_t *size);
protected:
virtual ~FileSource();
private:
FILE *mFile;
int64_t mOffset;
int64_t mLength;
Mutex mLock;
FileSource(const FileSource &);
FileSource &operator=(const FileSource &);
};
} // namespace android
#endif // FILE_SOURCE_H_
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef HARDWARE_API_H_
#define HARDWARE_API_H_
#include <media/stagefright/OMXPluginBase.h>
#include <media/stagefright/VideoRenderer.h>
#include <surfaceflinger/ISurface.h>
#include <utils/RefBase.h>
#include <OMX_Component.h>
extern android::VideoRenderer *createRenderer(
const android::sp<android::ISurface> &surface,
const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat,
size_t displayWidth, size_t displayHeight,
size_t decodedWidth, size_t decodedHeight,
size_t rotation = 0, size_t flags = 0);
extern android::VideoRenderer *createRendererWithRotation(
const android::sp<android::ISurface> &surface,
const char *componentName,
OMX_COLOR_FORMATTYPE colorFormat,
size_t displayWidth, size_t displayHeight,
size_t decodedWidth, size_t decodedHeight,
int32_t rotationDegrees);
extern android::OMXPluginBase *createOMXPlugin();
#endif // HARDWARE_API_H_
@@ -0,0 +1,58 @@
/*
* 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 JPEG_SOURCE_H_
#define JPEG_SOURCE_H_
#include <media/stagefright/MediaSource.h>
namespace android {
class DataSource;
class MediaBufferGroup;
struct JPEGSource : public MediaSource {
JPEGSource(const sp<DataSource> &source);
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);
protected:
virtual ~JPEGSource();
private:
sp<DataSource> mSource;
MediaBufferGroup *mGroup;
bool mStarted;
off64_t mSize;
int32_t mWidth, mHeight;
off64_t mOffset;
status_t parseJPEG();
JPEGSource(const JPEGSource &);
JPEGSource &operator=(const JPEGSource &);
};
} // namespace android
#endif // JPEG_SOURCE_H_
+289
View File
@@ -0,0 +1,289 @@
/*
* Copyright (C) 2009 The Android Open Source Project
* Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
*
* 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 LPA_PLAYER_H_
#define LPA_PLAYER_H_
#include "AudioPlayer.h"
#include <media/IAudioFlinger.h>
#include <utils/threads.h>
#include <utils/List.h>
#include <utils/Vector.h>
#include <pthread.h>
#include <binder/IServiceManager.h>
#include <linux/unistd.h>
#include <linux/msm_audio.h>
#include <include/TimedEventQueue.h>
// Pause timeout = 3sec
#define LPA_PAUSE_TIMEOUT_USEC 3000000
namespace android {
class LPAPlayer : public AudioPlayer {
public:
enum {
REACHED_EOS,
SEEK_COMPLETE
};
LPAPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink, bool &initCheck,
AwesomePlayer *audioObserver = NULL);
virtual ~LPAPlayer();
// Caller retains ownership of "source".
virtual void setSource(const sp<MediaSource> &source);
// Return time in us.
virtual int64_t getRealTimeUs();
virtual status_t start(bool sourceAlreadyStarted = false);
virtual void pause(bool playPendingSamples = false);
virtual void resume();
// Returns the timestamp of the last buffer played (in us).
virtual int64_t getMediaTimeUs();
// Returns true iff a mapping is established, i.e. the LPAPlayer
// has played at least one frame of audio.
virtual bool getMediaTimeMapping(int64_t *realtime_us, int64_t *mediatime_us);
virtual status_t seekTo(int64_t time_us);
virtual bool isSeeking();
virtual bool reachedEOS(status_t *finalStatus);
void* handle;
static int objectsAlive;
private:
int afd;
int efd;
int sessionId;
uint32_t bytesToWrite;
bool isPaused;
bool mSeeked;
bool a2dpDisconnectPause;
bool a2dpThreadStarted;
volatile bool asyncReset;
bool eventThreadCreated;
//Structure to hold pmem buffer information
class BuffersAllocated {
public:
BuffersAllocated(void *buf1, void *buf2, int32_t nSize, int32_t fd) :
localBuf(buf1), pmemBuf(buf2), pmemBufsize(nSize), pmemFd(fd)
{}
void* localBuf;
void* pmemBuf;
int32_t pmemBufsize;
int32_t pmemFd;
uint32_t bytesToWrite;
};
List<BuffersAllocated> pmemBuffersRequestQueue;
List<BuffersAllocated> pmemBuffersResponseQueue;
List<BuffersAllocated> bufPool;
List<BuffersAllocated> effectsQueue;
void *pmemBufferAlloc(int32_t nSize, int32_t *pmem_fd);
void pmemBufferDeAlloc();
//Declare all the threads
pthread_t eventThread;
pthread_t decoderThread;
pthread_t A2DPThread;
pthread_t EffectsThread;
pthread_t A2DPNotificationThread;
//Kill Thread boolean
bool killDecoderThread;
bool killEventThread;
bool killA2DPThread;
bool killEffectsThread;
bool killA2DPNotificationThread;
//Thread alive boolean
bool decoderThreadAlive;
bool eventThreadAlive;
bool a2dpThreadAlive;
bool effectsThreadAlive;
bool a2dpNotificationThreadAlive;
//Declare the condition Variables and Mutex
pthread_mutex_t pmem_request_mutex;
pthread_mutex_t pmem_response_mutex;
pthread_mutex_t decoder_mutex;
pthread_mutex_t event_mutex;
pthread_mutex_t a2dp_mutex;
pthread_mutex_t effect_mutex;
pthread_mutex_t apply_effect_mutex;
pthread_mutex_t a2dp_notification_mutex;
pthread_cond_t event_cv;
pthread_cond_t decoder_cv;
pthread_cond_t a2dp_cv;
pthread_cond_t effect_cv;
pthread_cond_t event_thread_cv;
pthread_cond_t a2dp_notification_cv;
// make sure Decoder thread has exited
void requestAndWaitForDecoderThreadExit();
// make sure the event thread also exited
void requestAndWaitForEventThreadExit();
// make sure the A2dp thread also exited
void requestAndWaitForA2DPThreadExit();
// make sure the Effects thread also exited
void requestAndWaitForEffectsThreadExit();
// make sure the Effects thread also exited
void requestAndWaitForA2DPNotificationThreadExit();
static void *eventThreadWrapper(void *me);
void eventThreadEntry();
static void *decoderThreadWrapper(void *me);
void decoderThreadEntry();
static void *A2DPThreadWrapper(void *me);
void A2DPThreadEntry();
static void *EffectsThreadWrapper(void *me);
void EffectsThreadEntry();
static void *A2DPNotificationThreadWrapper(void *me);
void A2DPNotificationThreadEntry();
void createThreads();
volatile bool bIsA2DPEnabled, bIsAudioRouted, bEffectConfigChanged;
//Structure to recieve the BT notification from the flinger.
class AudioFlingerLPAdecodeClient: public IBinder::DeathRecipient, public BnAudioFlingerClient {
public:
AudioFlingerLPAdecodeClient(void *obj);
LPAPlayer *pBaseClass;
// DeathRecipient
virtual void binderDied(const wp<IBinder>& who);
// IAudioFlingerClient
// indicate a change in the configuration of an output or input: keeps the cached
// values for output/input parameters upto date in client process
virtual void ioConfigChanged(int event, int ioHandle, void *param2);
friend class LPAPlayer;
};
sp<IAudioFlinger> mAudioFlinger;
// helper function to obtain AudioFlinger service handle
void getAudioFlinger();
void handleA2DPSwitch();
sp<AudioFlingerLPAdecodeClient> AudioFlingerClient;
friend class AudioFlingerLPAdecodeClient;
Mutex AudioFlingerLock;
bool mSourceEmpty;
bool mAudioSinkOpen;
sp<MediaSource> mSource;
MediaBuffer *mInputBuffer;
int32_t numChannels;
int mSampleRate;
int64_t mLatencyUs;
size_t mFrameSize;
Mutex mLock;
Mutex mSeekLock;
Mutex a2dpSwitchLock;
Mutex resumeLock;
int64_t mNumFramesPlayed;
int64_t mPositionTimeMediaUs;
int64_t mPositionTimeRealUs;
bool mSeeking;
bool mInternalSeeking;
bool mReachedEOS;
status_t mFinalStatus;
int64_t mSeekTimeUs;
int64_t timePlayed;
int64_t timeStarted;
bool mStarted;
bool mIsFirstBuffer;
status_t mFirstBufferResult;
MediaBuffer *mFirstBuffer;
TimedEventQueue mQueue;
bool mQueueStarted;
sp<TimedEventQueue::Event> mPauseEvent;
bool mPauseEventPending;
bool mPlaybackSuspended;
bool mIsDriverStarted;
bool mIsAudioRouted;
sp<MediaPlayerBase::AudioSink> mAudioSink;
AwesomePlayer *mObserver;
size_t fillBuffer(void *data, size_t size);
int64_t getRealTimeUsLocked();
void reset();
void onPauseTimeOut();
LPAPlayer(const LPAPlayer &);
LPAPlayer &operator=(const LPAPlayer &);
};
struct TimedEvent : public TimedEventQueue::Event {
TimedEvent(LPAPlayer *player,
void (LPAPlayer::*method)())
: mPlayer(player),
mMethod(method) {
}
protected:
virtual ~TimedEvent() {}
virtual void fire(TimedEventQueue *queue, int64_t /* now_us */) {
(mPlayer->*mMethod)();
}
private:
LPAPlayer *mPlayer;
void (LPAPlayer::*mMethod)();
TimedEvent(const TimedEvent &);
TimedEvent &operator=(const TimedEvent &);
};
} // namespace android
#endif // LPA_PLAYER_H_
@@ -0,0 +1,77 @@
/*
* 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 MPEG2TS_WRITER_H_
#define MPEG2TS_WRITER_H_
#include <media/stagefright/foundation/ABase.h>
#include <media/stagefright/foundation/AHandlerReflector.h>
#include <media/stagefright/foundation/ALooper.h>
#include <media/stagefright/MediaWriter.h>
namespace android {
struct ABuffer;
struct MPEG2TSWriter : public MediaWriter {
MPEG2TSWriter(int fd);
MPEG2TSWriter(const char *filename);
virtual status_t addSource(const sp<MediaSource> &source);
virtual status_t start(MetaData *param = NULL);
virtual status_t stop();
virtual status_t pause();
virtual bool reachedEOS();
virtual status_t dump(int fd, const Vector<String16>& args);
void onMessageReceived(const sp<AMessage> &msg);
protected:
virtual ~MPEG2TSWriter();
private:
enum {
kWhatSourceNotify = 'noti'
};
struct SourceInfo;
FILE *mFile;
sp<ALooper> mLooper;
sp<AHandlerReflector<MPEG2TSWriter> > mReflector;
bool mStarted;
Vector<sp<SourceInfo> > mSources;
size_t mNumSourcesDone;
int64_t mNumTSPacketsWritten;
int64_t mNumTSPacketsBeforeMeta;
void init();
void writeTS();
void writeProgramAssociationTable();
void writeProgramMap();
void writeAccessUnit(int32_t sourceIndex, const sp<ABuffer> &buffer);
DISALLOW_EVIL_CONSTRUCTORS(MPEG2TSWriter);
};
} // namespace android
#endif // MPEG2TS_WRITER_H_
@@ -0,0 +1,164 @@
/*
* 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 MPEG4_WRITER_H_
#define MPEG4_WRITER_H_
#include <stdio.h>
#include <media/stagefright/MediaWriter.h>
#include <utils/List.h>
#include <utils/threads.h>
namespace android {
class MediaBuffer;
class MediaSource;
class MetaData;
class MPEG4Writer : public MediaWriter {
public:
MPEG4Writer(const char *filename);
MPEG4Writer(int fd);
virtual status_t addSource(const sp<MediaSource> &source);
virtual status_t start(MetaData *param = NULL);
virtual status_t stop();
virtual status_t pause();
virtual bool reachedEOS();
virtual status_t dump(int fd, const Vector<String16>& args);
void beginBox(const char *fourcc);
void writeInt8(int8_t x);
void writeInt16(int16_t x);
void writeInt32(int32_t x);
void writeInt64(int64_t x);
void writeCString(const char *s);
void writeFourcc(const char *fourcc);
void write(const void *data, size_t size);
void endBox();
uint32_t interleaveDuration() const { return mInterleaveDurationUs; }
status_t setInterleaveDuration(uint32_t duration);
int32_t getTimeScale() const { return mTimeScale; }
protected:
virtual ~MPEG4Writer();
private:
class Track;
bool mUse4ByteNalLength;
bool mUse32BitOffset;
bool mIsFileSizeLimitExplicitlyRequested;
bool mPaused;
bool mStarted;
off64_t mOffset;
off64_t mMdatOffset;
uint8_t *mMoovBoxBuffer;
off64_t mMoovBoxBufferOffset;
bool mWriteMoovBoxToMemory;
off64_t mFreeBoxOffset;
bool mStreamableFile;
off64_t mEstimatedMoovBoxSize;
uint32_t mInterleaveDurationUs;
int32_t mTimeScale;
int64_t mStartTimestampUs;
int mFd;
Mutex mLock;
List<Track *> mTracks;
List<off64_t> mBoxes;
void setStartTimestampUs(int64_t timeUs);
int64_t getStartTimestampUs(); // Not const
status_t startTracks(MetaData *params);
size_t numTracks();
int64_t estimateMoovBoxSize(int32_t bitRate);
struct Chunk {
Track *mTrack; // Owner
int64_t mTimeStampUs; // Timestamp of the 1st sample
List<MediaBuffer *> mSamples; // Sample data
// Convenient constructor
Chunk(Track *track, int64_t timeUs, List<MediaBuffer *> samples)
: mTrack(track), mTimeStampUs(timeUs), mSamples(samples) {
}
};
struct ChunkInfo {
Track *mTrack; // Owner
List<Chunk> mChunks; // Remaining chunks to be written
};
bool mIsFirstChunk;
volatile bool mDone; // Writer thread is done?
pthread_t mThread; // Thread id for the writer
List<ChunkInfo> mChunkInfos; // Chunk infos
Condition mChunkReadyCondition; // Signal that chunks are available
// Writer thread handling
status_t startWriterThread();
void stopWriterThread();
static void *ThreadWrapper(void *me);
void threadFunc();
// Buffer a single chunk to be written out later.
void bufferChunk(const Chunk& chunk);
// Write all buffered chunks from all tracks
void writeChunks();
// Write a chunk if there is one
status_t writeOneChunk();
// Write the first chunk from the given ChunkInfo.
void writeFirstChunk(ChunkInfo* info);
// Adjust other track media clock (presumably wall clock)
// based on audio track media clock with the drift time.
int64_t mDriftTimeUs;
void setDriftTimeUs(int64_t driftTimeUs);
int64_t getDriftTimeUs();
// Return whether the nal length is 4 bytes or 2 bytes
// Only makes sense for H.264/AVC
bool useNalLengthFour();
void lock();
void unlock();
// Acquire lock before calling these methods
off64_t addSample_l(MediaBuffer *buffer);
off64_t addLengthPrefixedSample_l(MediaBuffer *buffer);
inline size_t write(const void *ptr, size_t size, size_t nmemb, int fd);
bool exceedsFileSizeLimit();
bool use32BitFileOffset() const;
bool exceedsFileDurationLimit();
bool isFileStreamable() const;
void trackProgressStatus(const Track* track, int64_t timeUs, status_t err = OK);
void writeCompositionMatrix(int32_t degrees);
MPEG4Writer(const MPEG4Writer &);
MPEG4Writer &operator=(const MPEG4Writer &);
};
} // namespace android
#endif // MPEG4_WRITER_H_
@@ -0,0 +1,117 @@
/*
* 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.
*/
/*--------------------------------------------------------------------------
Copyright (c) 2010, The Linux Foundation. All rights reserved.
--------------------------------------------------------------------------*/
#ifndef MEDIA_BUFFER_H_
#define MEDIA_BUFFER_H_
#include <pthread.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>
namespace android {
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);
// 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 setData(void *);
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<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;
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_
@@ -0,0 +1,58 @@
/*
* 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_GROUP_H_
#define MEDIA_BUFFER_GROUP_H_
#include <media/stagefright/MediaBuffer.h>
#include <utils/Errors.h>
#include <utils/threads.h>
namespace android {
class MediaBuffer;
class MetaData;
class MediaBufferGroup : public MediaBufferObserver {
public:
MediaBufferGroup();
~MediaBufferGroup();
void add_buffer(MediaBuffer *buffer);
// Blocks until a buffer is available and returns it to the caller,
// the returned buffer will have a reference count of 1.
status_t acquire_buffer(MediaBuffer **buffer);
protected:
virtual void signalBufferReturned(MediaBuffer *buffer);
private:
friend class MediaBuffer;
Mutex mLock;
Condition mCondition;
MediaBuffer *mFirstBuffer, *mLastBuffer;
MediaBufferGroup(const MediaBufferGroup &);
MediaBufferGroup &operator=(const MediaBufferGroup &);
};
} // namespace android
#endif // MEDIA_BUFFER_GROUP_H_
@@ -0,0 +1,20 @@
#ifndef MEDIA_DEBUG_H_
#define MEDIA_DEBUG_H_
#include <cutils/log.h>
#define LITERAL_TO_STRING_INTERNAL(x) #x
#define LITERAL_TO_STRING(x) LITERAL_TO_STRING_INTERNAL(x)
#define CHECK_EQ(x,y) \
LOG_ALWAYS_FATAL_IF( \
(x) != (y), \
__FILE__ ":" LITERAL_TO_STRING(__LINE__) " " #x " != " #y)
#define CHECK(x) \
LOG_ALWAYS_FATAL_IF( \
!(x), \
__FILE__ ":" LITERAL_TO_STRING(__LINE__) " " #x)
#endif // MEDIA_DEBUG_H_
@@ -0,0 +1,65 @@
/*
* 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.
*/
/*
* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*/
#ifndef MEDIA_DEFS_H_
#define MEDIA_DEFS_H_
namespace android {
extern const char *MEDIA_MIMETYPE_IMAGE_JPEG;
extern const char *MEDIA_MIMETYPE_VIDEO_VPX;
extern const char *MEDIA_MIMETYPE_VIDEO_AVC;
extern const char *MEDIA_MIMETYPE_VIDEO_MPEG4;
extern const char *MEDIA_MIMETYPE_VIDEO_H263;
extern const char *MEDIA_MIMETYPE_VIDEO_RAW;
extern const char *MEDIA_MIMETYPE_VIDEO_WMV;
extern const char *MEDIA_MIMETYPE_AUDIO_AMR_NB;
extern const char *MEDIA_MIMETYPE_AUDIO_AMR_WB;
extern const char *MEDIA_MIMETYPE_AUDIO_MPEG;
extern const char *MEDIA_MIMETYPE_AUDIO_AAC;
extern const char *MEDIA_MIMETYPE_AUDIO_QCELP;
extern const char *MEDIA_MIMETYPE_AUDIO_VORBIS;
extern const char *MEDIA_MIMETYPE_AUDIO_G711_ALAW;
extern const char *MEDIA_MIMETYPE_AUDIO_G711_MLAW;
extern const char *MEDIA_MIMETYPE_AUDIO_RAW;
extern const char *MEDIA_MIMETYPE_AUDIO_WMA;
extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG4;
extern const char *MEDIA_MIMETYPE_CONTAINER_WAV;
extern const char *MEDIA_MIMETYPE_CONTAINER_OGG;
extern const char *MEDIA_MIMETYPE_CONTAINER_MATROSKA;
extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG2TS;
extern const char *MEDIA_MIMETYPE_CONTAINER_AVI;
extern const char *MEDIA_MIMETYPE_CONTAINER_QCP;
extern const char *MEDIA_MIMETYPE_CONTAINER_ASF;
extern const char *MEDIA_MIMETYPE_CONTAINER_AAC;
extern const char *MEDIA_MIMETYPE_VIDEO_DIVX; // DIVX 5 & 6
extern const char *MEDIA_MIMETYPE_VIDEO_DIVX311; // DIVX 311
extern const char *MEDIA_MIMETYPE_VIDEO_DIVX4; // DIVX 4
extern const char *MEDIA_MIMETYPE_AUDIO_AC3;
extern const char *MEDIA_MIMETYPE_VIDEO_SPARK;
extern const char *MEDIA_MIMETYPE_VIDEO_VP6;
extern const char *MEDIA_MIMETYPE_AUDIO_EVRC;
extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG2;
extern const char *MEDIA_MIMETYPE_VIDEO_MPEG2;
} // namespace android
#endif // MEDIA_DEFS_H_
@@ -0,0 +1,50 @@
/*
* 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,
//Custom Error for corrupt NAL
ERROR_CORRUPT_NAL = MEDIA_ERROR_BASE - 99,
};
} // namespace android
#endif // MEDIA_ERRORS_H_
@@ -0,0 +1,69 @@
/*
* 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;
class 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;
protected:
MediaExtractor() {}
virtual ~MediaExtractor() {}
private:
MediaExtractor(const MediaExtractor &);
MediaExtractor &operator=(const MediaExtractor &);
};
} // namespace android
#endif // MEDIA_EXTRACTOR_H_
@@ -0,0 +1,136 @@
/*
* 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 <binder/IMemory.h>
namespace android {
class MediaBuffer;
class MetaData;
struct MediaSource : public 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;
virtual status_t getBufferInfo(sp<IMemory>& Frame, size_t *alignedSize);
// 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;
// Option allows encoder to skip some frames until the specified
// time stamp.
// To prevent from being abused, when the skipFrame timestamp is
// found to be more than 1 second later than the current timestamp,
// an error will be returned from read().
void clearSkipFrame();
bool getSkipFrame(int64_t *timeUs) const;
void setSkipFrame(int64_t timeUs);
void setLateBy(int64_t lateness_us);
int64_t getLateBy() const;
private:
enum Options {
// Bit map
kSeekTo_Option = 1,
kSkipFrame_Option = 2,
};
uint32_t mOptions;
int64_t mSeekTimeUs;
SeekMode mSeekMode;
int64_t mLatenessUs;
int64_t mSkipFrameUntilTimeUs;
};
// 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;
}
protected:
virtual ~MediaSource();
private:
MediaSource(const MediaSource &);
MediaSource &operator=(const MediaSource &);
public:
virtual status_t isPaused(){return mIsPaused;}
protected:
bool mIsPaused;
};
} // namespace android
#endif // MEDIA_SOURCE_H_
@@ -0,0 +1,69 @@
/*
* 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 MEDIA_WRITER_H_
#define MEDIA_WRITER_H_
#include <utils/RefBase.h>
#include <media/IMediaRecorderClient.h>
namespace android {
struct MediaSource;
struct MetaData;
struct MediaWriter : public RefBase {
MediaWriter()
: mMaxFileSizeLimitBytes(0),
mMaxFileDurationLimitUs(0) {
}
virtual status_t addSource(const sp<MediaSource> &source) = 0;
virtual bool reachedEOS() = 0;
virtual status_t start(MetaData *params = NULL) = 0;
virtual status_t stop() = 0;
virtual status_t pause() = 0;
virtual void setMaxFileSize(int64_t bytes) { mMaxFileSizeLimitBytes = bytes; }
virtual void setMaxFileDuration(int64_t durationUs) { mMaxFileDurationLimitUs = durationUs; }
virtual void setListener(const sp<IMediaRecorderClient>& listener) {
mListener = listener;
}
virtual status_t dump(int fd, const Vector<String16>& args) {
return OK;
}
protected:
virtual ~MediaWriter() {}
int64_t mMaxFileSizeLimitBytes;
int64_t mMaxFileDurationLimitUs;
sp<IMediaRecorderClient> mListener;
void notify(int msg, int ext1, int ext2) {
if (mListener != NULL) {
mListener->notify(msg, ext1, ext2);
}
}
private:
MediaWriter(const MediaWriter &);
MediaWriter &operator=(const MediaWriter &);
};
} // namespace android
#endif // MEDIA_WRITER_H_
+240
View File
@@ -0,0 +1,240 @@
/*
* Copyright (C) 2009 The Android Open Source Project
* Copyright (C) 2010-2011 The Linux Foundation
*
* 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
kKeyHeight = 'heig', // int32_t
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 (also video frame rate)
kKeyBitRate = 'brte', // int32_t (bps)
kKeyESDS = 'esds', // raw data
kKeyAVCC = 'avcc', // 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)
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)
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
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
kKeyRotationDegree = 'rdge', // int32_t (clockwise, in degree)
kKeyNotRealTime = 'ntrt', // bool (int32_t)
// Ogg files can be tagged to be automatically looping...
kKeyAutoLoop = 'autL', // bool (int32_t)
kKeyValidSamples = 'valD', // int32_t
kKeyEditOffset = 'edof', // bool (int64_t)
kKeyIsUnreadable = 'unre', // bool (int32_t)
kKeyRawCodecSpecificData = 'rcsd', // raw data - added to support mmParser
kKeyDivXVersion = 'DivX', // int32_t
kKeyDivXDrm = 'QDrm', // void *
kKeyWriteCtts = 'ctts', // int32_t (bool)
kKeyIsBFrame = 'bfrm', // int32_t (bool)
kKeyWMAEncodeOpt = 'eopt', // int32_t
kKeyWMABlockAlign = 'blka', // int32_t
kKeyWMAVersion = 'wmav', // int32_t
kKeyWMAAdvEncOpt1 = 'ade1', // int16_t
kKeyWMAAdvEncOpt2 = 'ade2', // int32_t
kKeyWMAFormatTag = 'fmtt', // int64_t
kKeyWMABitspersample = 'bsps', // int64_t
kKeyWMAVirPktSize = 'vpks', // int64_t
kKeyIsDRM = 'idrm', // int32_t (bool)
kKeyWMVProfile = 'wmvp', //int32_t
// 3D Video Flag
kKey3D = '3Dvf', // bool (int32_t)
kKeyHFR = 'hfr ', // int32_t
kKeyLatitude = 'lati', // int32_t
kKeyLongitude = 'logi', // int32_t
kKeyAacCodecSpecificData = 'acsd' ,
// for AAC specific type ADTS or ADIF
kkeyAacFormatAdif = 'adif', // bool (int32_t)
kkeyAacFormatLtp = 'ltp',
};
enum {
kTypeESDS = 'esds',
kTypeAVCC = 'avcc',
};
enum {
kTypeDivXVer_3_11,
kTypeDivXVer_4,
kTypeDivXVer_5,
kTypeDivXVer_6,
};
enum {
kTypeWMVSimple,
kTypeWMVAdvance,
};
enum {
kTypeWMA,
kTypeWMAPro,
kTypeWMALossLess,
};
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 ',
};
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 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 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;
}
};
KeyedVector<uint32_t, typed_data> mItems;
// MetaData &operator=(const MetaData &);
};
} // namespace android
#endif // META_DATA_H_
@@ -0,0 +1,49 @@
/*--------------------------------------------------------------------------
Copyright (c) 2011, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of The Linux Foundation nor
the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------*/
#include <ui/egl/android_natives.h>
#include <private/ui/android_natives_priv.h>
#include <ui/android_native_buffer.h>
#include <utils/RefBase.h>
#define PRIV_FLAGS_USES_PMEM 0x00000002
namespace android {
class NativeBuffer
: public EGLNativeBase<
android_native_buffer_t,
NativeBuffer,
RefBase>
{
public:
android_native_buffer_t* getNativeBuffer() const;
NativeBuffer(int width, int height, int format, int fd, int size, int offset, int base);
~NativeBuffer();
};
}
@@ -0,0 +1,45 @@
/*
* 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_
+352
View File
@@ -0,0 +1,352 @@
/*
* 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.
*/
/*--------------------------------------------------------------------------
Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
--------------------------------------------------------------------------*/
#ifndef OMX_CODEC_H_
#define OMX_CODEC_H_
#include <media/IOMX.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/NativeBuffer.h>
#include <utils/threads.h>
namespace android {
class MemoryDealer;
struct OMXCodecObserver;
struct CodecProfileLevel;
struct OMXCodec : public MediaSource,
public MediaBufferObserver {
#define CREATION_FLAGS_MAX (1U<<31)
enum CreationFlags {
kPreferSoftwareCodecs = 1,
kIgnoreCodecSpecificData = 2,
// The client wants to access the output buffer's video
// data for example for thumbnail extraction.
kClientNeedsFramebuffer = 4,
//Qualcomm specific, use higher values
kEnableGPUComposition = CREATION_FLAGS_MAX,
kEnableThumbnailMode = CREATION_FLAGS_MAX>>1,
kForce3DTopBottom = CREATION_FLAGS_MAX>>2,
kForce3DLeftRight = CREATION_FLAGS_MAX>>3,
kForce3DRightLeft = CREATION_FLAGS_MAX>>4,
kForce3DBottomTop = CREATION_FLAGS_MAX>>5,
kLocalFileMode = CREATION_FLAGS_MAX>>6,
};
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);
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();
void on_message(const omx_message &msg);
void registerBuffers(const sp<IMemoryHeap> &mem);
// from MediaBufferObserver
virtual void signalBufferReturned(MediaBuffer *buffer);
protected:
virtual ~OMXCodec();
private:
// Make sure mLock is accessible to OMXCodecObserver
friend class OMXCodecObserver;
enum State {
DEAD,
LOADED,
LOADED_TO_IDLE,
IDLE_TO_EXECUTING,
EXECUTING,
EXECUTING_TO_IDLE,
IDLE_TO_LOADED,
RECONFIGURING,
PAUSING,
FLUSHING,
PAUSED,
ERROR
};
enum {
kPortIndexBoth = -1,
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,
kStoreMetaDataInInputVideoBuffers = 16384,
kDoesNotRequireMemcpyOnOutputPort = 32768,
kBFrameFlagInExtensions = 65536,
kRequiresEOSMessage = 131072,
kRequiresWMAProComponent = 262144,
};
struct BufferInfo {
IOMX::buffer_id mBuffer;
bool mOwnedByComponent;
sp<IMemory> mMem;
size_t mSize;
void *mData;
MediaBuffer *mMediaBuffer;
sp<NativeBuffer> mNativeBuffer;
};
struct CodecSpecificData {
size_t mSize;
uint8_t mData[1];
};
sp<IOMX> mOMX;
bool mOMXLivesLocally;
IOMX::node_id mNode;
uint32_t mQuirks;
bool mIsEncoder;
char *mMIME;
char *mComponentName;
sp<MetaData> mOutputFormat;
sp<MediaSource> mSource;
Vector<CodecSpecificData *> mCodecSpecificData;
size_t mCodecSpecificDataIndex;
sp<IMemoryHeap> mPmemInfo;
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;
int64_t mSkipTimeUs;
bool mGPUComposition;
bool mThumbnailMode;
uint32_t mForce3D;
MediaBuffer *mLeftOverBuffer;
Mutex mLock;
Condition mAsyncCompletion;
State mStateBeforeError;
bool mPaused;
// A list of indices into mPortStatus[kPortIndexOutput] filled with data.
List<size_t> mFilledBuffers;
Condition mBufferFilled;
bool mInterlaceFormatDetected;
bool m3DVideoDetected;
bool mSendEOS;
bool mSPSParsed;
bool bInvalidState;
OMXCodec(const sp<IOMX> &omx, IOMX::node_id node, uint32_t quirks,
bool isEncoder, const char *mime, const char *componentName,
const sp<MediaSource> &source);
void addCodecSpecificData(const void *data, size_t size);
void clearCodecSpecificData();
void setComponentRole();
void setAMRFormat(bool isWAMR, int32_t bitRate);
void setAACFormat(int32_t numChannels, int32_t sampleRate, int32_t bitRate);
void setEVRCFormat( int32_t sampleRate, int32_t numChannels, int32_t bitRate);
void setQCELPFormat( int32_t sampleRate, int32_t numChannels, int32_t bitRate);
void setAC3Format(int32_t numChannels, int32_t sampleRate);
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 setupMPEG2EncoderParameters(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 freeBuffersOnPort(
OMX_U32 portIndex, bool onlyThoseWeOwn = false);
void drainInputBuffer(IOMX::buffer_id buffer);
void fillOutputBuffer(IOMX::buffer_id buffer);
void drainInputBuffer(BufferInfo *info);
void fillOutputBuffer(BufferInfo *info);
void drainInputBuffers();
void fillOutputBuffers();
// 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);
void 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);
void dumpPortStatus(OMX_U32 portIndex);
status_t configureCodec(const sp<MetaData> &meta, uint32_t flags);
static uint32_t getComponentQuirks(
const char *componentName, bool isEncoder);
static void findMatchingCodecs(
const char *mime,
bool createEncoder, const char *matchComponentName,
uint32_t flags,
Vector<String8> *matchingCodecs);
void parseFlags(uint32_t flags);
status_t processExtraDataBlocksOfBuffer(MediaBuffer *aBuffer, OMX_U32 flags);
status_t processSEIData();
OMXCodec(const OMXCodec &);
OMXCodec &operator=(const OMXCodec &);
status_t sendEOSToOMXComponent( );
status_t setWMAFormat(const sp<MetaData> &inputFormat);
status_t freeBuffersOnOutPortIfAllAreWithUs();
};
struct CodecProfileLevel {
OMX_U32 mProfile;
OMX_U32 mLevel;
};
struct CodecCapabilities {
String8 mComponentName;
Vector<CodecProfileLevel> mProfileLevels;
};
// 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.
// 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,
Vector<CodecCapabilities> *results);
} // namespace android
#endif // OMX_CODEC_H_
@@ -0,0 +1,61 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OMX_PLUGIN_BASE_H_
#define OMX_PLUGIN_BASE_H_
#include <sys/types.h>
#include <OMX_Component.h>
#include <utils/String8.h>
#include <utils/Vector.h>
namespace android {
struct OMXComponentBase;
struct OMXPluginBase {
OMXPluginBase() {}
virtual ~OMXPluginBase() {}
virtual OMX_ERRORTYPE makeComponentInstance(
const char *name,
const OMX_CALLBACKTYPE *callbacks,
OMX_PTR appData,
OMX_COMPONENTTYPE **component) = 0;
virtual OMX_ERRORTYPE destroyComponentInstance(
OMX_COMPONENTTYPE *component) = 0;
virtual OMX_ERRORTYPE enumerateComponents(
OMX_STRING name,
size_t size,
OMX_U32 index) = 0;
virtual OMX_ERRORTYPE getRolesOfComponent(
const char *name,
Vector<String8> *roles) = 0;
private:
OMXPluginBase(const OMXPluginBase &);
OMXPluginBase &operator=(const OMXPluginBase &);
};
} // namespace android
#endif // OMX_PLUGIN_BASE_H_
@@ -0,0 +1,61 @@
/*
* 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 SHOUTCAST_SOURCE_H_
#define SHOUTCAST_SOURCE_H_
#include <sys/types.h>
#include <media/stagefright/MediaSource.h>
namespace android {
class HTTPStream;
class MediaBufferGroup;
class ShoutcastSource : public MediaSource {
public:
// Assumes ownership of "http".
ShoutcastSource(HTTPStream *http);
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);
protected:
virtual ~ShoutcastSource();
private:
HTTPStream *mHttp;
size_t mMetaDataOffset;
size_t mBytesUntilMetaData;
MediaBufferGroup *mGroup;
bool mStarted;
ShoutcastSource(const ShoutcastSource &);
ShoutcastSource &operator= (const ShoutcastSource &);
};
} // namespace android
#endif // SHOUTCAST_SOURCE_H_
@@ -0,0 +1,46 @@
/*
* 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 STAGEFRIGHT_MEDIA_SCANNER_H_
#define STAGEFRIGHT_MEDIA_SCANNER_H_
#include <media/mediascanner.h>
namespace android {
struct MediaMetadataRetriever;
struct StagefrightMediaScanner : public MediaScanner {
StagefrightMediaScanner();
virtual ~StagefrightMediaScanner();
virtual status_t processFile(
const char *path, const char *mimeType,
MediaScannerClient &client);
virtual char *extractAlbumArt(int fd);
private:
sp<MediaMetadataRetriever> mRetriever;
StagefrightMediaScanner(const StagefrightMediaScanner &);
StagefrightMediaScanner &operator=(const StagefrightMediaScanner &);
};
} // namespace android
#endif // STAGEFRIGHT_MEDIA_SCANNER_H_
@@ -0,0 +1,51 @@
/*
* 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 TIME_SOURCE_H_
#define TIME_SOURCE_H_
#include <stdint.h>
namespace android {
class TimeSource {
public:
TimeSource() {}
virtual ~TimeSource() {}
virtual int64_t getRealTimeUs() = 0;
private:
TimeSource(const TimeSource &);
TimeSource &operator=(const TimeSource &);
};
class SystemTimeSource : public TimeSource {
public:
SystemTimeSource();
virtual int64_t getRealTimeUs();
private:
static int64_t GetSystemTimeUs();
int64_t mStartTimeUs;
};
} // namespace android
#endif // TIME_SOURCE_H_
+184
View File
@@ -0,0 +1,184 @@
/*
* Copyright (C) 2009 The Android Open Source Project
* Copyright (C) 2011 The Linux Foundation
*
* 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 UTILS_H_
#define UTILS_H_
#include <stdint.h>
#include <utils/Errors.h>
namespace android {
//Define non-standard colorformats
static const int OMX_QCOM_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00;
static const int QOMX_COLOR_FormatYVU420PackedSemiPlanar32m4ka = 0x7FA30C01;
static const int QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka = 0x7FA30C03;
//Flags that are XORed with colorformats
static const int QOMX_INTERLACE_FLAG = 0x49283654;
static const int QOMX_3D_LEFT_RIGHT_VIDEO_FLAG = 0x23784238;
static const int QOMX_3D_RIGHT_LEFT_VIDEO_FLAG = 0x23784239;
static const int QOMX_3D_TOP_BOTTOM_VIDEO_FLAG = 0x4678239b;
static const int QOMX_3D_BOTTOM_TOP_VIDEO_FLAG = 0x4678239c;
//Compression formats
static const int QOMX_VIDEO_CodingDivx = 0x7FA30C02;
static const int QOMX_VIDEO_CodingSpark = 0x7FA30C03;
static const int QOMX_VIDEO_CodingVp = 0x7FA30C04;
/*
* Checks if the colorformat is a 3D colorformat.
* Puts QOMX_3D_TOP_BOTTOM_VIDEO_FLAG
* or QOMX_3D_LEFT_RIGHT_VIDEO_FLAG in format if top-bottom
* or left-right respectively.
* Otherwise puts 0.
*/
#define GET_3D_FORMAT(colorFormat, format) \
do { \
switch (colorFormat) { \
case OMX_COLOR_FormatYUV420Planar: \
case OMX_COLOR_FormatCbYCrY: \
case OMX_QCOM_COLOR_FormatYVU420SemiPlanar: \
case OMX_COLOR_FormatYUV420SemiPlanar: \
case QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka: \
case (OMX_QCOM_COLOR_FormatYVU420SemiPlanar ^ QOMX_INTERLACE_FLAG): \
case (QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka ^ QOMX_INTERLACE_FLAG): \
case (OMX_COLOR_FormatYUV420SemiPlanar ^ QOMX_INTERLACE_FLAG): \
format = 0; \
break; \
case (OMX_COLOR_FormatYUV420SemiPlanar ^ QOMX_3D_LEFT_RIGHT_VIDEO_FLAG): \
case (OMX_QCOM_COLOR_FormatYVU420SemiPlanar ^ QOMX_3D_LEFT_RIGHT_VIDEO_FLAG): \
case (QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka ^ QOMX_3D_LEFT_RIGHT_VIDEO_FLAG): \
format = QOMX_3D_LEFT_RIGHT_VIDEO_FLAG; \
break; \
case (OMX_COLOR_FormatYUV420SemiPlanar ^ QOMX_3D_RIGHT_LEFT_VIDEO_FLAG): \
case (OMX_QCOM_COLOR_FormatYVU420SemiPlanar ^ QOMX_3D_RIGHT_LEFT_VIDEO_FLAG): \
case (QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka ^ QOMX_3D_RIGHT_LEFT_VIDEO_FLAG): \
format = QOMX_3D_RIGHT_LEFT_VIDEO_FLAG; \
break; \
case (QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka ^ QOMX_3D_TOP_BOTTOM_VIDEO_FLAG): \
case (OMX_COLOR_FormatYUV420SemiPlanar ^ QOMX_3D_TOP_BOTTOM_VIDEO_FLAG): \
case (OMX_QCOM_COLOR_FormatYVU420SemiPlanar ^ QOMX_3D_TOP_BOTTOM_VIDEO_FLAG): \
format = QOMX_3D_TOP_BOTTOM_VIDEO_FLAG; \
break; \
case (QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka ^ QOMX_3D_BOTTOM_TOP_VIDEO_FLAG): \
case (OMX_COLOR_FormatYUV420SemiPlanar ^ QOMX_3D_BOTTOM_TOP_VIDEO_FLAG): \
case (OMX_QCOM_COLOR_FormatYVU420SemiPlanar ^ QOMX_3D_BOTTOM_TOP_VIDEO_FLAG): \
format = QOMX_3D_BOTTOM_TOP_VIDEO_FLAG; \
break; \
default: \
format = 0; \
} \
} while(0)
/*
* Checks if the colorformat is an interlaced colorformat.
* Puts QOMX_INTERLACE_FLAG if so, else puts 0
* Otherwise returns 0.
*/
#define GET_INTERLACE_FORMAT(colorFormat, format) \
do { \
switch (colorFormat) { \
case OMX_COLOR_FormatYUV420Planar: \
case OMX_COLOR_FormatCbYCrY: \
case OMX_QCOM_COLOR_FormatYVU420SemiPlanar: \
case OMX_COLOR_FormatYUV420SemiPlanar: \
case QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka: \
case (OMX_COLOR_FormatYUV420SemiPlanar ^ QOMX_3D_LEFT_RIGHT_VIDEO_FLAG): \
case (OMX_QCOM_COLOR_FormatYVU420SemiPlanar ^ QOMX_3D_LEFT_RIGHT_VIDEO_FLAG): \
case (QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka ^ QOMX_3D_LEFT_RIGHT_VIDEO_FLAG): \
case (QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka ^ QOMX_3D_TOP_BOTTOM_VIDEO_FLAG): \
case (OMX_COLOR_FormatYUV420SemiPlanar ^ QOMX_3D_TOP_BOTTOM_VIDEO_FLAG): \
case (OMX_QCOM_COLOR_FormatYVU420SemiPlanar ^ QOMX_3D_TOP_BOTTOM_VIDEO_FLAG): \
format = 0; \
break; \
break; \
case (OMX_QCOM_COLOR_FormatYVU420SemiPlanar ^ QOMX_INTERLACE_FLAG): \
case (QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka ^ QOMX_INTERLACE_FLAG): \
case (OMX_COLOR_FormatYUV420SemiPlanar ^ QOMX_INTERLACE_FLAG): \
format = QOMX_INTERLACE_FLAG; \
break; \
break; \
default: \
format = 0; \
} \
} while(0)
/*
* From a colorformat that is composed of the real colorformat XOR some modifier flag,
* extract the real colorformat.
*
* Puts the base color format in format. If passed in colorformat was invalid, puts 0
* in format.
*
* temp1 and temp2 are temporary 32bit variables used by this macro.
*
* Returns the real colorformat if passed in colorformat is valid, returns 0 otherwise.
*/
#define GET_BASE_COLOR_FORMAT(colorFormat, format, temp1, temp2) \
do { \
/* Risky declaring inside a macro, mangling the */ \
/* variable name so no one else uses the samename*/ \
GET_INTERLACE_FORMAT(colorFormat, (temp1)); \
GET_3D_FORMAT(colorFormat, (temp2)); \
/* Since foo XOR 0 = foo, we can blindly xor with*/ \
/* the interlace flags regardless of if they're */ \
/* set or not. We'll just end up only xoring out*/ \
/* flags that we actually set */ \
format = (colorFormat) ^ (temp1) ^ (temp2); \
switch (format) { \
case OMX_COLOR_FormatYUV420Planar: \
case OMX_COLOR_FormatCbYCrY: \
case OMX_QCOM_COLOR_FormatYVU420SemiPlanar: \
case OMX_COLOR_FormatYUV420SemiPlanar: \
case QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka: \
break; \
default: \
format = 0; \
} \
} while(0)
#define FOURCC(c1, c2, c3, c4) \
(c1 << 24 | c2 << 16 | c3 << 8 | c4)
uint16_t U16_AT(const uint8_t *ptr);
uint32_t U32_AT(const uint8_t *ptr);
uint64_t U64_AT(const uint8_t *ptr);
uint16_t U16LE_AT(const uint8_t *ptr);
uint32_t U32LE_AT(const uint8_t *ptr);
uint64_t U64LE_AT(const uint8_t *ptr);
uint64_t ntoh64(uint64_t x);
uint64_t hton64(uint64_t x);
typedef struct {
uint8_t mProfile;
uint8_t mLevel;
int32_t mHeightInMBs;
int32_t mWidthInMBs;
int32_t mNumRefFrames;
int32_t mInterlaced;
} SpsInfo;
status_t
parseSps(uint8_t naluSize,const uint8_t *encodedBytes, SpsInfo *info);
} // namespace android
#endif // UTILS_H_
@@ -0,0 +1,41 @@
/*
* 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 VIDEO_RENDERER_H_
#define VIDEO_RENDERER_H_
#include <sys/types.h>
namespace android {
class VideoRenderer {
public:
virtual ~VideoRenderer() {}
virtual void render(
const void *data, size_t size, void *platformPrivate) = 0;
protected:
VideoRenderer() {}
VideoRenderer(const VideoRenderer &);
VideoRenderer &operator=(const VideoRenderer &);
};
} // namespace android
#endif // VIDEO_RENDERER_H_
@@ -0,0 +1,51 @@
/*
* 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 A_ATOMIZER_H_
#define A_ATOMIZER_H_
#include <stdint.h>
#include <media/stagefright/foundation/ABase.h>
#include <media/stagefright/foundation/AString.h>
#include <utils/List.h>
#include <utils/Vector.h>
#include <utils/threads.h>
namespace android {
struct AAtomizer {
static const char *Atomize(const char *name);
private:
static AAtomizer gAtomizer;
Mutex mLock;
Vector<List<AString> > mAtoms;
AAtomizer();
const char *atomize(const char *name);
static uint32_t Hash(const char *s);
DISALLOW_EVIL_CONSTRUCTORS(AAtomizer);
};
} // namespace android
#endif // A_ATOMIZER_H_
@@ -0,0 +1,25 @@
/*
* 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 A_BASE_H_
#define A_BASE_H_
#define DISALLOW_EVIL_CONSTRUCTORS(name) \
name(const name &); \
name &operator=(const name &)
#endif // A_BASE_H_
@@ -0,0 +1,53 @@
/*
* 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 A_BIT_READER_H_
#define A_BIT_READER_H_
#include <media/stagefright/foundation/ABase.h>
#include <sys/types.h>
#include <stdint.h>
namespace android {
struct ABitReader {
ABitReader(const uint8_t *data, size_t size);
uint32_t getBits(size_t n);
void skipBits(size_t n);
size_t numBitsLeft() const;
const uint8_t *data() const;
private:
const uint8_t *mData;
size_t mSize;
uint32_t mReservoir; // left-aligned bits
size_t mNumBitsLeft;
void fillReservoir();
void putBits(uint32_t x, size_t n);
DISALLOW_EVIL_CONSTRUCTORS(ABitReader);
};
} // namespace android
#endif // A_BIT_READER_H_
@@ -0,0 +1,71 @@
/*
* 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 A_BUFFER_H_
#define A_BUFFER_H_
#include <sys/types.h>
#include <stdint.h>
#include <media/stagefright/foundation/ABase.h>
#include <utils/RefBase.h>
namespace android {
struct AMessage;
struct ABuffer : public RefBase {
ABuffer(size_t capacity);
ABuffer(void *data, size_t capacity);
void setFarewellMessage(const sp<AMessage> msg);
uint8_t *base() { return (uint8_t *)mData; }
uint8_t *data() { return (uint8_t *)mData + mRangeOffset; }
size_t capacity() const { return mCapacity; }
size_t size() const { return mRangeLength; }
size_t offset() const { return mRangeOffset; }
void setRange(size_t offset, size_t size);
void setInt32Data(int32_t data) { mInt32Data = data; }
int32_t int32Data() const { return mInt32Data; }
sp<AMessage> meta();
protected:
virtual ~ABuffer();
private:
sp<AMessage> mFarewell;
sp<AMessage> mMeta;
void *mData;
size_t mCapacity;
size_t mRangeOffset;
size_t mRangeLength;
int32_t mInt32Data;
bool mOwnsData;
DISALLOW_EVIL_CONSTRUCTORS(ABuffer);
};
} // namespace android
#endif // A_BUFFER_H_
@@ -0,0 +1,80 @@
/*
* 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 A_DEBUG_H_
#define A_DEBUG_H_
#include <string.h>
#include <media/stagefright/foundation/ABase.h>
#include <media/stagefright/foundation/AString.h>
#include <utils/Log.h>
namespace android {
#define LITERAL_TO_STRING_INTERNAL(x) #x
#define LITERAL_TO_STRING(x) LITERAL_TO_STRING_INTERNAL(x)
#define CHECK(condition) \
LOG_ALWAYS_FATAL_IF( \
!(condition), \
__FILE__ ":" LITERAL_TO_STRING(__LINE__) \
" CHECK(" #condition ") failed.")
#define MAKE_COMPARATOR(suffix,op) \
template<class A, class B> \
AString Compare_##suffix(const A &a, const B &b) { \
AString res; \
if (!(a op b)) { \
res.append(a); \
res.append(" vs. "); \
res.append(b); \
} \
return res; \
}
MAKE_COMPARATOR(EQ,==)
MAKE_COMPARATOR(NE,!=)
MAKE_COMPARATOR(LE,<=)
MAKE_COMPARATOR(GE,>=)
MAKE_COMPARATOR(LT,<)
MAKE_COMPARATOR(GT,>)
#define CHECK_OP(x,y,suffix,op) \
do { \
AString ___res = Compare_##suffix(x, y); \
if (!___res.empty()) { \
LOG_ALWAYS_FATAL( \
__FILE__ ":" LITERAL_TO_STRING(__LINE__) \
" CHECK_" #suffix "( " #x "," #y ") failed: %s", \
___res.c_str()); \
} \
} while (false)
#define CHECK_EQ(x,y) CHECK_OP(x,y,EQ,==)
#define CHECK_NE(x,y) CHECK_OP(x,y,NE,!=)
#define CHECK_LE(x,y) CHECK_OP(x,y,LE,<=)
#define CHECK_LT(x,y) CHECK_OP(x,y,LT,<)
#define CHECK_GE(x,y) CHECK_OP(x,y,GE,>=)
#define CHECK_GT(x,y) CHECK_OP(x,y,GT,>)
#define TRESPASS() LOG_ALWAYS_FATAL("Should not be here.")
} // namespace android
#endif // A_DEBUG_H_
@@ -0,0 +1,56 @@
/*
* 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 A_HANDLER_H_
#define A_HANDLER_H_
#include <media/stagefright/foundation/ALooper.h>
#include <utils/RefBase.h>
namespace android {
struct AMessage;
struct AHandler : public RefBase {
AHandler()
: mID(0) {
}
ALooper::handler_id id() const {
return mID;
}
sp<ALooper> looper();
protected:
virtual void onMessageReceived(const sp<AMessage> &msg) = 0;
private:
friend struct ALooperRoster;
ALooper::handler_id mID;
void setID(ALooper::handler_id id) {
mID = id;
}
DISALLOW_EVIL_CONSTRUCTORS(AHandler);
};
} // namespace android
#endif // A_HANDLER_H_
@@ -0,0 +1,32 @@
#ifndef A_HANDLER_REFLECTOR_H_
#define A_HANDLER_REFLECTOR_H_
#include <media/stagefright/foundation/AHandler.h>
namespace android {
template<class T>
struct AHandlerReflector : public AHandler {
AHandlerReflector(T *target)
: mTarget(target) {
}
protected:
virtual void onMessageReceived(const sp<AMessage> &msg) {
sp<T> target = mTarget.promote();
if (target != NULL) {
target->onMessageReceived(msg);
}
}
private:
wp<T> mTarget;
AHandlerReflector(const AHandlerReflector<T> &);
AHandlerReflector<T> &operator=(const AHandlerReflector<T> &);
};
} // namespace android
#endif // A_HANDLER_REFLECTOR_H_
@@ -0,0 +1,86 @@
/*
* 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 A_LOOPER_H_
#define A_LOOPER_H_
#include <media/stagefright/foundation/ABase.h>
#include <media/stagefright/foundation/AString.h>
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <utils/List.h>
#include <utils/RefBase.h>
#include <utils/threads.h>
namespace android {
struct AHandler;
struct AMessage;
struct ALooper : public RefBase {
typedef int32_t event_id;
typedef int32_t handler_id;
ALooper();
// Takes effect in a subsequent call to start().
void setName(const char *name);
handler_id registerHandler(const sp<AHandler> &handler);
void unregisterHandler(handler_id handlerID);
status_t start(
bool runOnCallingThread = false,
bool canCallJava = false,
int32_t priority = PRIORITY_DEFAULT
);
status_t stop();
static int64_t GetNowUs();
protected:
virtual ~ALooper();
private:
friend struct ALooperRoster;
struct Event {
int64_t mWhenUs;
sp<AMessage> mMessage;
};
Mutex mLock;
Condition mQueueChangedCondition;
AString mName;
List<Event> mEventQueue;
struct LooperThread;
sp<LooperThread> mThread;
bool mRunningLocally;
void post(const sp<AMessage> &msg, int64_t delayUs);
bool loop();
DISALLOW_EVIL_CONSTRUCTORS(ALooper);
};
} // namespace android
#endif // A_LOOPER_H_
@@ -0,0 +1,54 @@
/*
* 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 A_LOOPER_ROSTER_H_
#define A_LOOPER_ROSTER_H_
#include <media/stagefright/foundation/ALooper.h>
#include <utils/KeyedVector.h>
namespace android {
struct ALooperRoster {
ALooperRoster();
ALooper::handler_id registerHandler(
const sp<ALooper> looper, const sp<AHandler> &handler);
void unregisterHandler(ALooper::handler_id handlerID);
void postMessage(const sp<AMessage> &msg, int64_t delayUs = 0);
void deliverMessage(const sp<AMessage> &msg);
sp<ALooper> findLooper(ALooper::handler_id handlerID);
private:
struct HandlerInfo {
wp<ALooper> mLooper;
wp<AHandler> mHandler;
};
Mutex mLock;
KeyedVector<ALooper::handler_id, HandlerInfo> mHandlers;
ALooper::handler_id mNextHandlerID;
DISALLOW_EVIL_CONSTRUCTORS(ALooperRoster);
};
} // namespace android
#endif // A_LOOPER_ROSTER_H_
@@ -0,0 +1,115 @@
/*
* 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 A_MESSAGE_H_
#define A_MESSAGE_H_
#include <media/stagefright/foundation/ABase.h>
#include <media/stagefright/foundation/ALooper.h>
#include <utils/KeyedVector.h>
#include <utils/RefBase.h>
namespace android {
struct AString;
struct AMessage : public RefBase {
AMessage(uint32_t what = 0, ALooper::handler_id target = 0);
void setWhat(uint32_t what);
uint32_t what() const;
void setTarget(ALooper::handler_id target);
ALooper::handler_id target() const;
void setInt32(const char *name, int32_t value);
void setInt64(const char *name, int64_t value);
void setSize(const char *name, size_t value);
void setFloat(const char *name, float value);
void setDouble(const char *name, double value);
void setPointer(const char *name, void *value);
void setString(const char *name, const char *s, ssize_t len = -1);
void setObject(const char *name, const sp<RefBase> &obj);
void setMessage(const char *name, const sp<AMessage> &obj);
bool findInt32(const char *name, int32_t *value) const;
bool findInt64(const char *name, int64_t *value) const;
bool findSize(const char *name, size_t *value) const;
bool findFloat(const char *name, float *value) const;
bool findDouble(const char *name, double *value) const;
bool findPointer(const char *name, void **value) const;
bool findString(const char *name, AString *value) const;
bool findObject(const char *name, sp<RefBase> *obj) const;
bool findMessage(const char *name, sp<AMessage> *obj) const;
void post(int64_t delayUs = 0);
sp<AMessage> dup() const;
AString debugString(int32_t indent = 0) const;
protected:
virtual ~AMessage();
private:
enum Type {
kTypeInt32,
kTypeInt64,
kTypeSize,
kTypeFloat,
kTypeDouble,
kTypePointer,
kTypeString,
kTypeObject,
kTypeMessage,
};
uint32_t mWhat;
ALooper::handler_id mTarget;
struct Item {
union {
int32_t int32Value;
int64_t int64Value;
size_t sizeValue;
float floatValue;
double doubleValue;
void *ptrValue;
RefBase *refValue;
AString *stringValue;
} u;
const char *mName;
Type mType;
};
enum {
kMaxNumItems = 16
};
Item mItems[kMaxNumItems];
size_t mNumItems;
void clear();
Item *allocateItem(const char *name);
void freeItem(Item *item);
const Item *findItem(const char *name, Type type) const;
DISALLOW_EVIL_CONSTRUCTORS(AMessage);
};
} // namespace android
#endif // A_MESSAGE_H_
@@ -0,0 +1,94 @@
/*
* 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 A_STRING_H_
#define A_STRING_H_
#include <sys/types.h>
namespace android {
struct AString {
AString();
AString(const char *s);
AString(const char *s, size_t size);
AString(const AString &from);
AString(const AString &from, size_t offset, size_t n);
~AString();
AString &operator=(const AString &from);
void setTo(const char *s);
void setTo(const char *s, size_t size);
void setTo(const AString &from, size_t offset, size_t n);
size_t size() const;
const char *c_str() const;
bool empty() const;
void clear();
void trim();
void erase(size_t start, size_t n);
void append(char c) { append(&c, 1); }
void append(const char *s);
void append(const char *s, size_t size);
void append(const AString &from);
void append(const AString &from, size_t offset, size_t n);
void append(int x);
void append(unsigned x);
void append(long x);
void append(unsigned long x);
void append(long long x);
void append(unsigned long long x);
void append(float x);
void append(double x);
void append(void *x);
void insert(const AString &from, size_t insertionPos);
void insert(const char *from, size_t size, size_t insertionPos);
ssize_t find(const char *substring, size_t start = 0) const;
size_t hash() const;
bool operator==(const AString &other) const;
bool operator<(const AString &other) const;
bool operator>(const AString &other) const;
int compare(const AString &other) const;
bool startsWith(const char *prefix) const;
void tolower();
private:
static const char *kEmptyString;
char *mData;
size_t mSize;
size_t mAllocSize;
void makeMutable();
};
AString StringPrintf(const char *format, ...);
} // namespace android
#endif // A_STRING_H_
@@ -0,0 +1,33 @@
/*
* 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 BASE_64_H_
#define BASE_64_H_
#include <utils/RefBase.h>
namespace android {
struct ABuffer;
struct AString;
sp<ABuffer> decodeBase64(const AString &s);
void encodeBase64(const void *data, size_t size, AString *out);
} // namespace android
#endif // BASE_64_H_
@@ -0,0 +1,29 @@
/*
* 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 HEXDUMP_H_
#define HEXDUMP_H_
#include <sys/types.h>
namespace android {
void hexdump(const void *_data, size_t size);
} // namespace android
#endif // HEXDUMP_H_
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,596 @@
/* ------------------------------------------------------------------
* 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_Component.h - OpenMax IL version 1.1.2
* The OMX_Component header file contains the definitions used to define
* the public interface of a component. This header file is intended to
* be used by both the application and the component.
*/
#ifndef OMX_Component_h
#define OMX_Component_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_Audio.h>
#include <OMX_Video.h>
#include <OMX_Image.h>
#include <OMX_Other.h>
/** @ingroup comp */
typedef enum OMX_PORTDOMAINTYPE {
OMX_PortDomainAudio,
OMX_PortDomainVideo,
OMX_PortDomainImage,
OMX_PortDomainOther,
OMX_PortDomainKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_PortDomainVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_PortDomainMax = 0x7ffffff
} OMX_PORTDOMAINTYPE;
/** @ingroup comp */
typedef struct OMX_PARAM_PORTDEFINITIONTYPE {
OMX_U32 nSize; /**< Size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_U32 nPortIndex; /**< Port number the structure applies to */
OMX_DIRTYPE eDir; /**< Direction (input or output) of this port */
OMX_U32 nBufferCountActual; /**< The actual number of buffers allocated on this port */
OMX_U32 nBufferCountMin; /**< The minimum number of buffers this port requires */
OMX_U32 nBufferSize; /**< Size, in bytes, for buffers to be used for this channel */
OMX_BOOL bEnabled; /**< Ports default to enabled and are enabled/disabled by
OMX_CommandPortEnable/OMX_CommandPortDisable.
When disabled a port is unpopulated. A disabled port
is not populated with buffers on a transition to IDLE. */
OMX_BOOL bPopulated; /**< Port is populated with all of its buffers as indicated by
nBufferCountActual. A disabled port is always unpopulated.
An enabled port is populated on a transition to OMX_StateIdle
and unpopulated on a transition to loaded. */
OMX_PORTDOMAINTYPE eDomain; /**< Domain of the port. Determines the contents of metadata below. */
union {
OMX_AUDIO_PORTDEFINITIONTYPE audio;
OMX_VIDEO_PORTDEFINITIONTYPE video;
OMX_IMAGE_PORTDEFINITIONTYPE image;
OMX_OTHER_PORTDEFINITIONTYPE other;
} format;
OMX_BOOL bBuffersContiguous;
OMX_U32 nBufferAlignment;
} OMX_PARAM_PORTDEFINITIONTYPE;
/** @ingroup comp */
typedef struct OMX_PARAM_U32TYPE {
OMX_U32 nSize; /**< Size of this structure, in Bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_U32 nPortIndex; /**< port that this structure applies to */
OMX_U32 nU32; /**< U32 value */
} OMX_PARAM_U32TYPE;
/** @ingroup rpm */
typedef enum OMX_SUSPENSIONPOLICYTYPE {
OMX_SuspensionDisabled, /**< No suspension; v1.0 behavior */
OMX_SuspensionEnabled, /**< Suspension allowed */
OMX_SuspensionPolicyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_SuspensionPolicyStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_SuspensionPolicyMax = 0x7fffffff
} OMX_SUSPENSIONPOLICYTYPE;
/** @ingroup rpm */
typedef struct OMX_PARAM_SUSPENSIONPOLICYTYPE {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_SUSPENSIONPOLICYTYPE ePolicy;
} OMX_PARAM_SUSPENSIONPOLICYTYPE;
/** @ingroup rpm */
typedef enum OMX_SUSPENSIONTYPE {
OMX_NotSuspended, /**< component is not suspended */
OMX_Suspended, /**< component is suspended */
OMX_SuspensionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_SuspensionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_SuspendMax = 0x7FFFFFFF
} OMX_SUSPENSIONTYPE;
/** @ingroup rpm */
typedef struct OMX_PARAM_SUSPENSIONTYPE {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_SUSPENSIONTYPE eType;
} OMX_PARAM_SUSPENSIONTYPE ;
typedef struct OMX_CONFIG_BOOLEANTYPE {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_BOOL bEnabled;
} OMX_CONFIG_BOOLEANTYPE;
/* Parameter specifying the content uri to use. */
/** @ingroup cp */
typedef struct OMX_PARAM_CONTENTURITYPE
{
OMX_U32 nSize; /**< size of the structure in bytes, including
actual URI name */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_U8 contentURI[1]; /**< The URI name */
} OMX_PARAM_CONTENTURITYPE;
/* Parameter specifying the pipe to use. */
/** @ingroup cp */
typedef struct OMX_PARAM_CONTENTPIPETYPE
{
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_HANDLETYPE hPipe; /**< The pipe handle*/
} OMX_PARAM_CONTENTPIPETYPE;
/** @ingroup rpm */
typedef struct OMX_RESOURCECONCEALMENTTYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_BOOL bResourceConcealmentForbidden; /**< disallow the use of resource concealment
methods (like degrading algorithm quality to
lower resource consumption or functional bypass)
on a component as a resolution to resource conflicts. */
} OMX_RESOURCECONCEALMENTTYPE;
/** @ingroup metadata */
typedef enum OMX_METADATACHARSETTYPE {
OMX_MetadataCharsetUnknown = 0,
OMX_MetadataCharsetASCII,
OMX_MetadataCharsetBinary,
OMX_MetadataCharsetCodePage1252,
OMX_MetadataCharsetUTF8,
OMX_MetadataCharsetJavaConformantUTF8,
OMX_MetadataCharsetUTF7,
OMX_MetadataCharsetImapUTF7,
OMX_MetadataCharsetUTF16LE,
OMX_MetadataCharsetUTF16BE,
OMX_MetadataCharsetGB12345,
OMX_MetadataCharsetHZGB2312,
OMX_MetadataCharsetGB2312,
OMX_MetadataCharsetGB18030,
OMX_MetadataCharsetGBK,
OMX_MetadataCharsetBig5,
OMX_MetadataCharsetISO88591,
OMX_MetadataCharsetISO88592,
OMX_MetadataCharsetISO88593,
OMX_MetadataCharsetISO88594,
OMX_MetadataCharsetISO88595,
OMX_MetadataCharsetISO88596,
OMX_MetadataCharsetISO88597,
OMX_MetadataCharsetISO88598,
OMX_MetadataCharsetISO88599,
OMX_MetadataCharsetISO885910,
OMX_MetadataCharsetISO885913,
OMX_MetadataCharsetISO885914,
OMX_MetadataCharsetISO885915,
OMX_MetadataCharsetShiftJIS,
OMX_MetadataCharsetISO2022JP,
OMX_MetadataCharsetISO2022JP1,
OMX_MetadataCharsetISOEUCJP,
OMX_MetadataCharsetSMS7Bit,
OMX_MetadataCharsetKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_MetadataCharsetVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_MetadataCharsetTypeMax= 0x7FFFFFFF
} OMX_METADATACHARSETTYPE;
/** @ingroup metadata */
typedef enum OMX_METADATASCOPETYPE
{
OMX_MetadataScopeAllLevels,
OMX_MetadataScopeTopLevel,
OMX_MetadataScopePortLevel,
OMX_MetadataScopeNodeLevel,
OMX_MetadataScopeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_MetadataScopeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_MetadataScopeTypeMax = 0x7fffffff
} OMX_METADATASCOPETYPE;
/** @ingroup metadata */
typedef enum OMX_METADATASEARCHMODETYPE
{
OMX_MetadataSearchValueSizeByIndex,
OMX_MetadataSearchItemByIndex,
OMX_MetadataSearchNextItemByKey,
OMX_MetadataSearchKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_MetadataSearchVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_MetadataSearchTypeMax = 0x7fffffff
} OMX_METADATASEARCHMODETYPE;
/** @ingroup metadata */
typedef struct OMX_CONFIG_METADATAITEMCOUNTTYPE
{
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_METADATASCOPETYPE eScopeMode;
OMX_U32 nScopeSpecifier;
OMX_U32 nMetadataItemCount;
} OMX_CONFIG_METADATAITEMCOUNTTYPE;
/** @ingroup metadata */
typedef struct OMX_CONFIG_METADATAITEMTYPE
{
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_METADATASCOPETYPE eScopeMode;
OMX_U32 nScopeSpecifier;
OMX_U32 nMetadataItemIndex;
OMX_METADATASEARCHMODETYPE eSearchMode;
OMX_METADATACHARSETTYPE eKeyCharset;
OMX_U8 nKeySizeUsed;
OMX_U8 nKey[128];
OMX_METADATACHARSETTYPE eValueCharset;
OMX_STRING sLanguageCountry;
OMX_U32 nValueMaxSize;
OMX_U32 nValueSizeUsed;
OMX_U8 nValue[1];
} OMX_CONFIG_METADATAITEMTYPE;
/* @ingroup metadata */
typedef struct OMX_CONFIG_CONTAINERNODECOUNTTYPE
{
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_BOOL bAllKeys;
OMX_U32 nParentNodeID;
OMX_U32 nNumNodes;
} OMX_CONFIG_CONTAINERNODECOUNTTYPE;
/** @ingroup metadata */
typedef struct OMX_CONFIG_CONTAINERNODEIDTYPE
{
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_BOOL bAllKeys;
OMX_U32 nParentNodeID;
OMX_U32 nNodeIndex;
OMX_U32 nNodeID;
OMX_STRING cNodeName;
OMX_BOOL bIsLeafType;
} OMX_CONFIG_CONTAINERNODEIDTYPE;
/** @ingroup metadata */
typedef struct OMX_PARAM_METADATAFILTERTYPE
{
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_BOOL bAllKeys; /* if true then this structure refers to all keys and
* the three key fields below are ignored */
OMX_METADATACHARSETTYPE eKeyCharset;
OMX_U32 nKeySizeUsed;
OMX_U8 nKey [128];
OMX_U32 nLanguageCountrySizeUsed;
OMX_U8 nLanguageCountry[128];
OMX_BOOL bEnabled; /* if true then key is part of filter (e.g.
* retained for query later). If false then
* key is not part of filter */
} OMX_PARAM_METADATAFILTERTYPE;
/** The OMX_HANDLETYPE structure defines the component handle. The component
* handle is used to access all of the component's public methods and also
* contains pointers to the component's private data area. The component
* handle is initialized by the OMX core (with help from the component)
* during the process of loading the component. After the component is
* successfully loaded, the application can safely access any of the
* component's public functions (although some may return an error because
* the state is inappropriate for the access).
*
* @ingroup comp
*/
typedef struct OMX_COMPONENTTYPE
{
/** The size of this structure, in bytes. It is the responsibility
of the allocator of this structure to fill in this value. Since
this structure is allocated by the GetHandle function, this
function will fill in this value. */
OMX_U32 nSize;
/** nVersion is the version of the OMX specification that the structure
is built against. It is the responsibility of the creator of this
structure to initialize this value and every user of this structure
should verify that it knows how to use the exact version of
this structure found herein. */
OMX_VERSIONTYPE nVersion;
/** pComponentPrivate is a pointer to the component private data area.
This member is allocated and initialized by the component when the
component is first loaded. The application should not access this
data area. */
OMX_PTR pComponentPrivate;
/** pApplicationPrivate is a pointer that is a parameter to the
OMX_GetHandle method, and contains an application private value
provided by the IL client. This application private data is
returned to the IL Client by OMX in all callbacks */
OMX_PTR pApplicationPrivate;
/** refer to OMX_GetComponentVersion in OMX_core.h or the OMX IL
specification for details on the GetComponentVersion method.
*/
OMX_ERRORTYPE (*GetComponentVersion)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_OUT OMX_STRING pComponentName,
OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
OMX_OUT OMX_UUIDTYPE* pComponentUUID);
/** refer to OMX_SendCommand in OMX_core.h or the OMX IL
specification for details on the SendCommand method.
*/
OMX_ERRORTYPE (*SendCommand)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_COMMANDTYPE Cmd,
OMX_IN OMX_U32 nParam1,
OMX_IN OMX_PTR pCmdData);
/** refer to OMX_GetParameter in OMX_core.h or the OMX IL
specification for details on the GetParameter method.
*/
OMX_ERRORTYPE (*GetParameter)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_INOUT OMX_PTR pComponentParameterStructure);
/** refer to OMX_SetParameter in OMX_core.h or the OMX IL
specification for details on the SetParameter method.
*/
OMX_ERRORTYPE (*SetParameter)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentParameterStructure);
/** refer to OMX_GetConfig in OMX_core.h or the OMX IL
specification for details on the GetConfig method.
*/
OMX_ERRORTYPE (*GetConfig)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_INOUT OMX_PTR pComponentConfigStructure);
/** refer to OMX_SetConfig in OMX_core.h or the OMX IL
specification for details on the SetConfig method.
*/
OMX_ERRORTYPE (*SetConfig)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentConfigStructure);
/** refer to OMX_GetExtensionIndex in OMX_core.h or the OMX IL
specification for details on the GetExtensionIndex method.
*/
OMX_ERRORTYPE (*GetExtensionIndex)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_STRING cParameterName,
OMX_OUT OMX_INDEXTYPE* pIndexType);
/** refer to OMX_GetState in OMX_core.h or the OMX IL
specification for details on the GetState method.
*/
OMX_ERRORTYPE (*GetState)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_OUT OMX_STATETYPE* pState);
/** The ComponentTunnelRequest method will interact with another OMX
component to determine if tunneling is possible and to setup the
tunneling. The return codes for this method can be used to
determine if tunneling is not possible, or if tunneling is not
supported.
Base profile components (i.e. non-interop) do not support this
method and should return OMX_ErrorNotImplemented
The interop profile component MUST support tunneling to another
interop profile component with a compatible port parameters.
A component may also support proprietary communication.
If proprietary communication is supported the negotiation of
proprietary communication is done outside of OMX in a vendor
specific way. It is only required that the proper result be
returned and the details of how the setup is done is left
to the component implementation.
When this method is invoked when nPort in an output port, the
component will:
1. Populate the pTunnelSetup structure with the output port's
requirements and constraints for the tunnel.
When this method is invoked when nPort in an input port, the
component will:
1. Query the necessary parameters from the output port to
determine if the ports are compatible for tunneling
2. If the ports are compatible, the component should store
the tunnel step provided by the output port
3. Determine which port (either input or output) is the buffer
supplier, and call OMX_SetParameter on the output port to
indicate this selection.
The component will return from this call within 5 msec.
@param [in] hComp
Handle of the component to be accessed. This is the component
handle returned by the call to the OMX_GetHandle method.
@param [in] nPort
nPort is used to select the port on the component to be used
for tunneling.
@param [in] hTunneledComp
Handle of the component to tunnel with. This is the component
handle returned by the call to the OMX_GetHandle method. When
this parameter is 0x0 the component should setup the port for
communication with the application / IL Client.
@param [in] nPortOutput
nPortOutput is used indicate the port the component should
tunnel with.
@param [in] pTunnelSetup
Pointer to the tunnel setup structure. When nPort is an output port
the component should populate the fields of this structure. When
When nPort is an input port the component should review the setup
provided by the component with the output port.
@return OMX_ERRORTYPE
If the command successfully executes, the return code will be
OMX_ErrorNone. Otherwise the appropriate OMX error will be returned.
@ingroup tun
*/
OMX_ERRORTYPE (*ComponentTunnelRequest)(
OMX_IN OMX_HANDLETYPE hComp,
OMX_IN OMX_U32 nPort,
OMX_IN OMX_HANDLETYPE hTunneledComp,
OMX_IN OMX_U32 nTunneledPort,
OMX_INOUT OMX_TUNNELSETUPTYPE* pTunnelSetup);
/** refer to OMX_UseBuffer in OMX_core.h or the OMX IL
specification for details on the UseBuffer method.
@ingroup buf
*/
OMX_ERRORTYPE (*UseBuffer)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
OMX_IN OMX_U32 nPortIndex,
OMX_IN OMX_PTR pAppPrivate,
OMX_IN OMX_U32 nSizeBytes,
OMX_IN OMX_U8* pBuffer);
/** refer to OMX_AllocateBuffer in OMX_core.h or the OMX IL
specification for details on the AllocateBuffer method.
@ingroup buf
*/
OMX_ERRORTYPE (*AllocateBuffer)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_INOUT OMX_BUFFERHEADERTYPE** ppBuffer,
OMX_IN OMX_U32 nPortIndex,
OMX_IN OMX_PTR pAppPrivate,
OMX_IN OMX_U32 nSizeBytes);
/** refer to OMX_FreeBuffer in OMX_core.h or the OMX IL
specification for details on the FreeBuffer method.
@ingroup buf
*/
OMX_ERRORTYPE (*FreeBuffer)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_U32 nPortIndex,
OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
/** refer to OMX_EmptyThisBuffer in OMX_core.h or the OMX IL
specification for details on the EmptyThisBuffer method.
@ingroup buf
*/
OMX_ERRORTYPE (*EmptyThisBuffer)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
/** refer to OMX_FillThisBuffer in OMX_core.h or the OMX IL
specification for details on the FillThisBuffer method.
@ingroup buf
*/
OMX_ERRORTYPE (*FillThisBuffer)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
/** The SetCallbacks method is used by the core to specify the callback
structure from the application to the component. This is a blocking
call. The component will return from this call within 5 msec.
@param [in] hComponent
Handle of the component to be accessed. This is the component
handle returned by the call to the GetHandle function.
@param [in] pCallbacks
pointer to an OMX_CALLBACKTYPE structure used to provide the
callback information to the component
@param [in] pAppData
pointer to an application defined value. It is anticipated that
the application will pass a pointer to a data structure or a "this
pointer" in this area to allow the callback (in the application)
to determine the context of the call
@return OMX_ERRORTYPE
If the command successfully executes, the return code will be
OMX_ErrorNone. Otherwise the appropriate OMX error will be returned.
*/
OMX_ERRORTYPE (*SetCallbacks)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_CALLBACKTYPE* pCallbacks,
OMX_IN OMX_PTR pAppData);
/** ComponentDeInit method is used to deinitialize the component
providing a means to free any resources allocated at component
initialization. NOTE: After this call the component handle is
not valid for further use.
@param [in] hComponent
Handle of the component to be accessed. This is the component
handle returned by the call to the GetHandle function.
@return OMX_ERRORTYPE
If the command successfully executes, the return code will be
OMX_ErrorNone. Otherwise the appropriate OMX error will be returned.
*/
OMX_ERRORTYPE (*ComponentDeInit)(
OMX_IN OMX_HANDLETYPE hComponent);
/** @ingroup buf */
OMX_ERRORTYPE (*UseEGLImage)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
OMX_IN OMX_U32 nPortIndex,
OMX_IN OMX_PTR pAppPrivate,
OMX_IN void* eglImage);
OMX_ERRORTYPE (*ComponentRoleEnum)(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_OUT OMX_U8 *cRole,
OMX_IN OMX_U32 nIndex);
} OMX_COMPONENTTYPE;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/* File EOF */
@@ -0,0 +1,212 @@
/* ------------------------------------------------------------------
* 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_ContentPipe.h - OpenMax IL version 1.1.2
* The OMX_ContentPipe header file contains the definitions used to define
* the public interface for content piples. This header file is intended to
* be used by the component.
*/
#ifndef OMX_CONTENTPIPE_H
#define OMX_CONTENTPIPE_H
#ifndef KD_EACCES
/* OpenKODE error codes. CPResult values may be zero (indicating success
or one of the following values) */
#define KD_EACCES (1)
#define KD_EADDRINUSE (2)
#define KD_EAGAIN (5)
#define KD_EBADF (7)
#define KD_EBUSY (8)
#define KD_ECONNREFUSED (9)
#define KD_ECONNRESET (10)
#define KD_EDEADLK (11)
#define KD_EDESTADDRREQ (12)
#define KD_ERANGE (35)
#define KD_EEXIST (13)
#define KD_EFBIG (14)
#define KD_EHOSTUNREACH (15)
#define KD_EINVAL (17)
#define KD_EIO (18)
#define KD_EISCONN (20)
#define KD_EISDIR (21)
#define KD_EMFILE (22)
#define KD_ENAMETOOLONG (23)
#define KD_ENOENT (24)
#define KD_ENOMEM (25)
#define KD_ENOSPC (26)
#define KD_ENOSYS (27)
#define KD_ENOTCONN (28)
#define KD_EPERM (33)
#define KD_ETIMEDOUT (36)
#define KD_EILSEQ (19)
#endif
/** Map types from OMX standard types only here so interface is as generic as possible. */
typedef OMX_U32 CPresult;
typedef char * CPstring;
typedef void * CPhandle;
typedef OMX_U32 CPuint;
typedef OMX_S32 CPint;
typedef char CPbyte;
typedef OMX_BOOL CPbool;
/** enumeration of origin types used in the CP_PIPETYPE's Seek function
* @ingroup cp
*/
typedef enum CP_ORIGINTYPE {
CP_OriginBegin,
CP_OriginCur,
CP_OriginEnd,
CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
CP_OriginVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
CP_OriginMax = 0X7FFFFFFF
} CP_ORIGINTYPE;
/** enumeration of contact access types used in the CP_PIPETYPE's Open function
* @ingroup cp
*/
typedef enum CP_ACCESSTYPE {
CP_AccessRead,
CP_AccessWrite,
CP_AccessReadWrite ,
CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
CP_AccessVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
CP_AccessMax = 0X7FFFFFFF
} CP_ACCESSTYPE;
/** enumeration of results returned by the CP_PIPETYPE's CheckAvailableBytes function
* @ingroup cp
*/
typedef enum CP_CHECKBYTESRESULTTYPE
{
CP_CheckBytesOk, /**< There are at least the request number
of bytes available */
CP_CheckBytesNotReady, /**< The pipe is still retrieving bytes
and presently lacks sufficient bytes.
Client will be called when they are
sufficient bytes are available. */
CP_CheckBytesInsufficientBytes , /**< The pipe has retrieved all bytes
but those available are less than those
requested */
CP_CheckBytesAtEndOfStream, /**< The pipe has reached the end of stream
and no more bytes are available. */
CP_CheckBytesOutOfBuffers, /**< All read/write buffers are currently in use. */
CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
CP_CheckBytesVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
CP_CheckBytesMax = 0X7FFFFFFF
} CP_CHECKBYTESRESULTTYPE;
/** enumeration of content pipe events sent to the client callback.
* @ingroup cp
*/
typedef enum CP_EVENTTYPE{
CP_BytesAvailable, /** bytes requested in a CheckAvailableBytes call are now available*/
CP_Overflow, /** enumeration of content pipe events sent to the client callback*/
CP_PipeDisconnected , /** enumeration of content pipe events sent to the client callback*/
CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
CP_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
CP_EventMax = 0X7FFFFFFF
} CP_EVENTTYPE;
/** content pipe definition
* @ingroup cp
*/
typedef struct CP_PIPETYPE
{
/** Open a content stream for reading or writing. */
CPresult (*Open)( CPhandle* hContent, CPstring szURI, CP_ACCESSTYPE eAccess );
/** Close a content stream. */
CPresult (*Close)( CPhandle hContent );
/** Create a content source and open it for writing. */
CPresult (*Create)( CPhandle *hContent, CPstring szURI );
/** Check the that specified number of bytes are available for reading or writing (depending on access type).*/
CPresult (*CheckAvailableBytes)( CPhandle hContent, CPuint nBytesRequested, CP_CHECKBYTESRESULTTYPE *eResult );
/** Seek to certain position in the content relative to the specified origin. */
CPresult (*SetPosition)( CPhandle hContent, CPint nOffset, CP_ORIGINTYPE eOrigin);
/** Retrieve the current position relative to the start of the content. */
CPresult (*GetPosition)( CPhandle hContent, CPuint *pPosition);
/** Retrieve data of the specified size from the content stream (advance content pointer by size of data).
Note: pipe client provides pointer. This function is appropriate for small high frequency reads. */
CPresult (*Read)( CPhandle hContent, CPbyte *pData, CPuint nSize);
/** Retrieve a buffer allocated by the pipe that contains the requested number of bytes.
Buffer contains the next block of bytes, as specified by nSize, of the content. nSize also
returns the size of the block actually read. Content pointer advances the by the returned size.
Note: pipe provides pointer. This function is appropriate for large reads. The client must call
ReleaseReadBuffer when done with buffer.
In some cases the requested block may not reside in contiguous memory within the
pipe implementation. For instance if the pipe leverages a circular buffer then the requested
block may straddle the boundary of the circular buffer. By default a pipe implementation
performs a copy in this case to provide the block to the pipe client in one contiguous buffer.
If, however, the client sets bForbidCopy, then the pipe returns only those bytes preceding the memory
boundary. Here the client may retrieve the data in segments over successive calls. */
CPresult (*ReadBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint *nSize, CPbool bForbidCopy);
/** Release a buffer obtained by ReadBuffer back to the pipe. */
CPresult (*ReleaseReadBuffer)(CPhandle hContent, CPbyte *pBuffer);
/** Write data of the specified size to the content (advance content pointer by size of data).
Note: pipe client provides pointer. This function is appropriate for small high frequency writes. */
CPresult (*Write)( CPhandle hContent, CPbyte *data, CPuint nSize);
/** Retrieve a buffer allocated by the pipe used to write data to the content.
Client will fill buffer with output data. Note: pipe provides pointer. This function is appropriate
for large writes. The client must call WriteBuffer when done it has filled the buffer with data.*/
CPresult (*GetWriteBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint nSize);
/** Deliver a buffer obtained via GetWriteBuffer to the pipe. Pipe will write the
the contents of the buffer to content and advance content pointer by the size of the buffer */
CPresult (*WriteBuffer)( CPhandle hContent, CPbyte *pBuffer, CPuint nFilledSize);
/** Register a per-handle client callback with the content pipe. */
CPresult (*RegisterCallback)( CPhandle hContent, CPresult (*ClientCallback)(CP_EVENTTYPE eEvent, CPuint iParam));
} CP_PIPETYPE;
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,937 @@
/* ------------------------------------------------------------------
* 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 */
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 */
@@ -0,0 +1,345 @@
/* ------------------------------------------------------------------
* 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_Image.h - OpenMax IL version 1.1.2
* The structures needed by Image components to exchange parameters and
* configuration data with the components.
*/
#ifndef OMX_Image_h
#define OMX_Image_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_IVCommon.h>
/** @defgroup imaging OpenMAX IL Imaging Domain
* @ingroup iv
* Structures for OpenMAX IL Imaging domain
* @{
*/
/**
* Enumeration used to define the possible image compression coding.
*/
typedef enum OMX_IMAGE_CODINGTYPE {
OMX_IMAGE_CodingUnused, /**< Value when format is N/A */
OMX_IMAGE_CodingAutoDetect, /**< Auto detection of image format */
OMX_IMAGE_CodingJPEG, /**< JPEG/JFIF image format */
OMX_IMAGE_CodingJPEG2K, /**< JPEG 2000 image format */
OMX_IMAGE_CodingEXIF, /**< EXIF image format */
OMX_IMAGE_CodingTIFF, /**< TIFF image format */
OMX_IMAGE_CodingGIF, /**< Graphics image format */
OMX_IMAGE_CodingPNG, /**< PNG image format */
OMX_IMAGE_CodingLZW, /**< LZW image format */
OMX_IMAGE_CodingBMP, /**< Windows Bitmap format */
OMX_IMAGE_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_IMAGE_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_IMAGE_CodingMax = 0x7FFFFFFF
} OMX_IMAGE_CODINGTYPE;
/**
* Data structure used to define an image path. The number of image paths
* for input and output will vary by type of the image component.
*
* Input (aka Source) : Zero Inputs, one Output,
* Splitter : One Input, 2 or more Outputs,
* Processing Element : One Input, one output,
* Mixer : 2 or more inputs, one output,
* Output (aka Sink) : One Input, zero outputs.
*
* The PortDefinition structure is used to define all of the parameters
* necessary for the compliant component to setup an input or an output
* image path. If additional vendor specific data is required, it should
* be transmitted to the component using the CustomCommand function.
* Compliant components will prepopulate this structure with optimal
* values during the OMX_GetParameter() command.
*
* STRUCT MEMBERS:
* cMIMEType : MIME type of data for the port
* pNativeRender : Platform specific reference for a display if a
* sync, otherwise this field is 0
* nFrameWidth : Width of frame to be used on port if
* uncompressed format is used. Use 0 for
* unknown, don't care or variable
* nFrameHeight : Height of frame to be used on port if
* uncompressed format is used. Use 0 for
* unknown, don't care or variable
* nStride : Number of bytes per span of an image (i.e.
* indicates the number of bytes to get from
* span N to span N+1, where negative stride
* indicates the image is bottom up
* nSliceHeight : Height used when encoding in slices
* bFlagErrorConcealment : Turns on error concealment if it is supported by
* the OMX component
* eCompressionFormat : Compression format used in this instance of
* the component. When OMX_IMAGE_CodingUnused is
* specified, eColorFormat is valid
* eColorFormat : Decompressed format used by this component
* pNativeWindow : Platform specific reference for a window object if a
* display sink , otherwise this field is 0x0.
*/
typedef struct OMX_IMAGE_PORTDEFINITIONTYPE {
OMX_STRING cMIMEType;
OMX_NATIVE_DEVICETYPE pNativeRender;
OMX_U32 nFrameWidth;
OMX_U32 nFrameHeight;
OMX_S32 nStride;
OMX_U32 nSliceHeight;
OMX_BOOL bFlagErrorConcealment;
OMX_IMAGE_CODINGTYPE eCompressionFormat;
OMX_COLOR_FORMATTYPE eColorFormat;
OMX_NATIVE_WINDOWTYPE pNativeWindow;
} OMX_IMAGE_PORTDEFINITIONTYPE;
/**
* Port format parameter. This structure is used to enumerate the various
* data input/output format supported by the port.
*
* STRUCT MEMBERS:
* nSize : Size of the structure in bytes
* nVersion : OMX specification version information
* nPortIndex : Indicates which port to set
* nIndex : Indicates the enumeration index for the format from
* 0x0 to N-1
* eCompressionFormat : Compression format used in this instance of the
* component. When OMX_IMAGE_CodingUnused is specified,
* eColorFormat is valid
* eColorFormat : Decompressed format used by this component
*/
typedef struct OMX_IMAGE_PARAM_PORTFORMATTYPE {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_U32 nPortIndex;
OMX_U32 nIndex;
OMX_IMAGE_CODINGTYPE eCompressionFormat;
OMX_COLOR_FORMATTYPE eColorFormat;
} OMX_IMAGE_PARAM_PORTFORMATTYPE;
/**
* Flash control type
*
* ENUMS
* Torch : Flash forced constantly on
*/
typedef enum OMX_IMAGE_FLASHCONTROLTYPE {
OMX_IMAGE_FlashControlOn = 0,
OMX_IMAGE_FlashControlOff,
OMX_IMAGE_FlashControlAuto,
OMX_IMAGE_FlashControlRedEyeReduction,
OMX_IMAGE_FlashControlFillin,
OMX_IMAGE_FlashControlTorch,
OMX_IMAGE_FlashControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_IMAGE_FlashControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_IMAGE_FlashControlMax = 0x7FFFFFFF
} OMX_IMAGE_FLASHCONTROLTYPE;
/**
* Flash control configuration
*
* STRUCT MEMBERS:
* nSize : Size of the structure in bytes
* nVersion : OMX specification version information
* nPortIndex : Port that this structure applies to
* eFlashControl : Flash control type
*/
typedef struct OMX_IMAGE_PARAM_FLASHCONTROLTYPE {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_U32 nPortIndex;
OMX_IMAGE_FLASHCONTROLTYPE eFlashControl;
} OMX_IMAGE_PARAM_FLASHCONTROLTYPE;
/**
* Focus control type
*/
typedef enum OMX_IMAGE_FOCUSCONTROLTYPE {
OMX_IMAGE_FocusControlOn = 0,
OMX_IMAGE_FocusControlOff,
OMX_IMAGE_FocusControlAuto,
OMX_IMAGE_FocusControlAutoLock,
OMX_IMAGE_FocusControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_IMAGE_FocusControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_IMAGE_FocusControlMax = 0x7FFFFFFF
} OMX_IMAGE_FOCUSCONTROLTYPE;
/**
* Focus control configuration
*
* STRUCT MEMBERS:
* nSize : Size of the structure in bytes
* nVersion : OMX specification version information
* nPortIndex : Port that this structure applies to
* eFocusControl : Focus control
* nFocusSteps : Focus can take on values from 0 mm to infinity.
* Interest is only in number of steps over this range.
* nFocusStepIndex : Current focus step index
*/
typedef struct OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_U32 nPortIndex;
OMX_IMAGE_FOCUSCONTROLTYPE eFocusControl;
OMX_U32 nFocusSteps;
OMX_U32 nFocusStepIndex;
} OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE;
/**
* Q Factor for JPEG compression, which controls the tradeoff between image
* quality and size. Q Factor provides a more simple means of controlling
* JPEG compression quality, without directly programming Quantization
* tables for chroma and luma
*
* STRUCT MEMBERS:
* nSize : Size of the structure in bytes
* nVersion : OMX specification version information
* nPortIndex : Port that this structure applies to
* nQFactor : JPEG Q factor value in the range of 1-100. A factor of 1
* produces the smallest, worst quality images, and a factor
* of 100 produces the largest, best quality images. A
* typical default is 75 for small good quality images
*/
typedef struct OMX_IMAGE_PARAM_QFACTORTYPE {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_U32 nPortIndex;
OMX_U32 nQFactor;
} OMX_IMAGE_PARAM_QFACTORTYPE;
/**
* Quantization table type
*/
typedef enum OMX_IMAGE_QUANTIZATIONTABLETYPE {
OMX_IMAGE_QuantizationTableLuma = 0,
OMX_IMAGE_QuantizationTableChroma,
OMX_IMAGE_QuantizationTableChromaCb,
OMX_IMAGE_QuantizationTableChromaCr,
OMX_IMAGE_QuantizationTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_IMAGE_QuantizationTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_IMAGE_QuantizationTableMax = 0x7FFFFFFF
} OMX_IMAGE_QUANTIZATIONTABLETYPE;
/**
* JPEG quantization tables are used to determine DCT compression for
* YUV data, as an alternative to specifying Q factor, providing exact
* control of compression
*
* STRUCT MEMBERS:
* nSize : Size of the structure in bytes
* nVersion : OMX specification version information
* nPortIndex : Port that this structure applies to
* eQuantizationTable : Quantization table type
* nQuantizationMatrix[64] : JPEG quantization table of coefficients stored
* in increasing columns then by rows of data (i.e.
* row 1, ... row 8). Quantization values are in
* the range 0-255 and stored in linear order
* (i.e. the component will zig-zag the
* quantization table data if required internally)
*/
typedef struct OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_U32 nPortIndex;
OMX_IMAGE_QUANTIZATIONTABLETYPE eQuantizationTable;
OMX_U8 nQuantizationMatrix[64];
} OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE;
/**
* Huffman table type, the same Huffman table is applied for chroma and
* luma component
*/
typedef enum OMX_IMAGE_HUFFMANTABLETYPE {
OMX_IMAGE_HuffmanTableAC = 0,
OMX_IMAGE_HuffmanTableDC,
OMX_IMAGE_HuffmanTableACLuma,
OMX_IMAGE_HuffmanTableACChroma,
OMX_IMAGE_HuffmanTableDCLuma,
OMX_IMAGE_HuffmanTableDCChroma,
OMX_IMAGE_HuffmanTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_IMAGE_HuffmanTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_IMAGE_HuffmanTableMax = 0x7FFFFFFF
} OMX_IMAGE_HUFFMANTABLETYPE;
/**
* JPEG Huffman table
*
* STRUCT MEMBERS:
* nSize : Size of the structure in bytes
* nVersion : OMX specification version information
* nPortIndex : Port that this structure applies to
* eHuffmanTable : Huffman table type
* nNumberOfHuffmanCodeOfLength[16] : 0-16, number of Huffman codes of each
* possible length
* nHuffmanTable[256] : 0-255, the size used for AC and DC
* HuffmanTable are 16 and 162
*/
typedef struct OMX_IMAGE_PARAM_HUFFMANTTABLETYPE {
OMX_U32 nSize;
OMX_VERSIONTYPE nVersion;
OMX_U32 nPortIndex;
OMX_IMAGE_HUFFMANTABLETYPE eHuffmanTable;
OMX_U8 nNumberOfHuffmanCodeOfLength[16];
OMX_U8 nHuffmanTable[256];
}OMX_IMAGE_PARAM_HUFFMANTTABLETYPE;
/** @} */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/* File EOF */
@@ -0,0 +1,275 @@
/* ------------------------------------------------------------------
* 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 */
@@ -0,0 +1,354 @@
/* ------------------------------------------------------------------
* 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_Other.h - OpenMax IL version 1.1.2
* The structures needed by Other components to exchange
* parameters and configuration data with the components.
*/
#ifndef OMX_Other_h
#define OMX_Other_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>
/**
* Enumeration of possible data types which match to multiple domains or no
* domain at all. For types which are vendor specific, a value above
* OMX_OTHER_VENDORTSTART should be used.
*/
typedef enum OMX_OTHER_FORMATTYPE {
OMX_OTHER_FormatTime = 0, /**< Transmission of various timestamps, elapsed time,
time deltas, etc */
OMX_OTHER_FormatPower, /**< Perhaps used for enabling/disabling power
management, setting clocks? */
OMX_OTHER_FormatStats, /**< Could be things such as frame rate, frames
dropped, etc */
OMX_OTHER_FormatBinary, /**< Arbitrary binary data */
OMX_OTHER_FormatVendorReserved = 1000, /**< Starting value for vendor specific
formats */
OMX_OTHER_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_OTHER_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_OTHER_FormatMax = 0x7FFFFFFF
} OMX_OTHER_FORMATTYPE;
/**
* Enumeration of seek modes.
*/
typedef enum OMX_TIME_SEEKMODETYPE {
OMX_TIME_SeekModeFast = 0, /**< Prefer seeking to an approximation
* of the requested seek position over
* the actual seek position if it
* results in a faster seek. */
OMX_TIME_SeekModeAccurate, /**< Prefer seeking to the actual seek
* position over an approximation
* of the requested seek position even
* if it results in a slower seek. */
OMX_TIME_SeekModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_TIME_SeekModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_TIME_SeekModeMax = 0x7FFFFFFF
} OMX_TIME_SEEKMODETYPE;
/* Structure representing the seekmode of the component */
typedef struct OMX_TIME_CONFIG_SEEKMODETYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_TIME_SEEKMODETYPE eType; /**< The seek mode */
} OMX_TIME_CONFIG_SEEKMODETYPE;
/** Structure representing a time stamp used with the following configs
* on the Clock Component (CC):
*
* OMX_IndexConfigTimeCurrentWallTime: query of the CCs current wall
* time
* OMX_IndexConfigTimeCurrentMediaTime: query of the CCs current media
* time
* OMX_IndexConfigTimeCurrentAudioReference and
* OMX_IndexConfigTimeCurrentVideoReference: audio/video reference
* clock sending SC its reference time
* OMX_IndexConfigTimeClientStartTime: a Clock Component client sends
* this structure to the Clock Component via a SetConfig on its
* client port when it receives a buffer with
* OMX_BUFFERFLAG_STARTTIME set. It must use the timestamp
* specified by that buffer for nStartTimestamp.
*
* Its also used with the following config on components in general:
*
* OMX_IndexConfigTimePosition: IL client querying component position
* (GetConfig) or commanding a component to seek to the given location
* (SetConfig)
*/
typedef struct OMX_TIME_CONFIG_TIMESTAMPTYPE {
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_TICKS nTimestamp; /**< timestamp .*/
} OMX_TIME_CONFIG_TIMESTAMPTYPE;
/** Enumeration of possible reference clocks to the media time. */
typedef enum OMX_TIME_UPDATETYPE {
OMX_TIME_UpdateRequestFulfillment, /**< Update is the fulfillment of a media time request. */
OMX_TIME_UpdateScaleChanged, /**< Update was generated because the scale chagned. */
OMX_TIME_UpdateClockStateChanged, /**< Update was generated because the clock state changed. */
OMX_TIME_UpdateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_TIME_UpdateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_TIME_UpdateMax = 0x7FFFFFFF
} OMX_TIME_UPDATETYPE;
/** Enumeration of possible reference clocks to the media time. */
typedef enum OMX_TIME_REFCLOCKTYPE {
OMX_TIME_RefClockNone, /**< Use no references. */
OMX_TIME_RefClockAudio, /**< Use references sent through OMX_IndexConfigTimeCurrentAudioReference */
OMX_TIME_RefClockVideo, /**< Use references sent through OMX_IndexConfigTimeCurrentVideoReference */
OMX_TIME_RefClockKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_TIME_RefClockVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_TIME_RefClockMax = 0x7FFFFFFF
} OMX_TIME_REFCLOCKTYPE;
/** Enumeration of clock states. */
typedef enum OMX_TIME_CLOCKSTATE {
OMX_TIME_ClockStateRunning, /**< Clock running. */
OMX_TIME_ClockStateWaitingForStartTime, /**< Clock waiting until the
* prescribed clients emit their
* start time. */
OMX_TIME_ClockStateStopped, /**< Clock stopped. */
OMX_TIME_ClockStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
OMX_TIME_ClockStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
OMX_TIME_ClockStateMax = 0x7FFFFFFF
} OMX_TIME_CLOCKSTATE;
/** Structure representing a media time request to the clock component.
*
* A client component sends this structure to the Clock Component via a SetConfig
* on its client port to specify a media timestamp the Clock Component
* should emit. The Clock Component should fulfill the request by sending a
* OMX_TIME_MEDIATIMETYPE when its media clock matches the requested
* timestamp.
*
* The client may require a media time request be fulfilled slightly
* earlier than the media time specified. In this case the client specifies
* an offset which is equal to the difference between wall time corresponding
* to the requested media time and the wall time when it will be
* fulfilled.
*
* A client component may uses these requests and the OMX_TIME_MEDIATIMETYPE to
* time events according to timestamps. If a client must perform an operation O at
* a time T (e.g. deliver a video frame at its corresponding timestamp), it makes a
* media time request at T (perhaps specifying an offset to ensure the request fulfillment
* is a little early). When the clock component passes the resulting OMX_TIME_MEDIATIMETYPE
* structure back to the client component, the client may perform operation O (perhaps having
* to wait a slight amount more time itself as specified by the return values).
*/
typedef struct OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE {
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_PTR pClientPrivate; /**< Client private data to disabiguate this media time
* from others (e.g. the number of the frame to deliver).
* Duplicated in the media time structure that fulfills
* this request. A value of zero is reserved for time scale
* updates. */
OMX_TICKS nMediaTimestamp; /**< Media timestamp requested.*/
OMX_TICKS nOffset; /**< Amount of wall clock time by which this
* request should be fulfilled early */
} OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE;
/**< Structure sent from the clock component client either when fulfilling
* a media time request or when the time scale has changed.
*
* In the former case the Clock Component fills this structure and times its emission
* to a client component (via the client port) according to the corresponding media
* time request sent by the client. The Clock Component should time the emission to occur
* when the requested timestamp matches the Clock Component's media time but also the
* prescribed offset early.
*
* Upon scale changes the clock component clears the nClientPrivate data, sends the current
* media time and sets the nScale to the new scale via the client port. It emits a
* OMX_TIME_MEDIATIMETYPE to all clients independent of any requests. This allows clients to
* alter processing to accomodate scaling. For instance a video component might skip inter-frames
* in the case of extreme fastforward. Likewise an audio component might add or remove samples
* from an audio frame to scale audio data.
*
* It is expected that some clock components may not be able to fulfill requests
* at exactly the prescribed time. This is acceptable so long as the request is
* fulfilled at least as early as described and not later. This structure provides
* fields the client may use to wait for the remaining time.
*
* The client may use either the nOffset or nWallTimeAtMedia fields to determine the
* wall time until the nMediaTimestamp actually occurs. In the latter case the
* client can get a more accurate value for offset by getting the current wall
* from the cloc component and subtracting it from nWallTimeAtMedia.
*/
typedef struct OMX_TIME_MEDIATIMETYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_U32 nClientPrivate; /**< Client private data to disabiguate this media time
* from others. Copied from the media time request.
* A value of zero is reserved for time scale updates. */
OMX_TIME_UPDATETYPE eUpdateType; /**< Reason for the update */
OMX_TICKS nMediaTimestamp; /**< Media time requested. If no media time was
* requested then this is the current media time. */
OMX_TICKS nOffset; /**< Amount of wall clock time by which this
* request was actually fulfilled early */
OMX_TICKS nWallTimeAtMediaTime; /**< Wall time corresponding to nMediaTimeStamp.
* A client may compare this value to current
* media time obtained from the Clock Component to determine
* the wall time until the media timestamp is really
* current. */
OMX_S32 xScale; /**< Current media time scale in Q16 format. */
OMX_TIME_CLOCKSTATE eState; /* Seeking Change. Added 7/12.*/
/**< State of the media time. */
} OMX_TIME_MEDIATIMETYPE;
/** Structure representing the current media time scale factor. Applicable only to clock
* component, other components see scale changes via OMX_TIME_MEDIATIMETYPE buffers sent via
* the clock component client ports. Upon recieving this config the clock component changes
* the rate by which the media time increases or decreases effectively implementing trick modes.
*/
typedef struct OMX_TIME_CONFIG_SCALETYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_S32 xScale; /**< This is a value in Q16 format which is used for
* scaling the media time */
} OMX_TIME_CONFIG_SCALETYPE;
/** Bits used to identify a clock port. Used in OMX_TIME_CONFIG_CLOCKSTATETYPEs nWaitMask field */
#define OMX_CLOCKPORT0 0x00000001
#define OMX_CLOCKPORT1 0x00000002
#define OMX_CLOCKPORT2 0x00000004
#define OMX_CLOCKPORT3 0x00000008
#define OMX_CLOCKPORT4 0x00000010
#define OMX_CLOCKPORT5 0x00000020
#define OMX_CLOCKPORT6 0x00000040
#define OMX_CLOCKPORT7 0x00000080
/** Structure representing the current mode of the media clock.
* IL Client uses this config to change or query the mode of the
* media clock of the clock component. Applicable only to clock
* component.
*
* On a SetConfig if eState is OMX_TIME_ClockStateRunning media time
* starts immediately at the prescribed start time. If
* OMX_TIME_ClockStateWaitingForStartTime the Clock Component ignores
* the given nStartTime and waits for all clients specified in the
* nWaitMask to send starttimes (via
* OMX_IndexConfigTimeClientStartTime). The Clock Component then starts
* the media clock using the earliest start time supplied. */
typedef struct OMX_TIME_CONFIG_CLOCKSTATETYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version
* information */
OMX_TIME_CLOCKSTATE eState; /**< State of the media time. */
OMX_TICKS nStartTime; /**< Start time of the media time. */
OMX_TICKS nOffset; /**< Time to offset the media time by
* (e.g. preroll). Media time will be
* reported to be nOffset ticks earlier.
*/
OMX_U32 nWaitMask; /**< Mask of OMX_CLOCKPORT values. */
} OMX_TIME_CONFIG_CLOCKSTATETYPE;
/** Structure representing the reference clock currently being used to
* compute media time. IL client uses this config to change or query the
* clock component's active reference clock */
typedef struct OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_TIME_REFCLOCKTYPE eClock; /**< Reference clock used to compute media time */
} OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE;
/** Descriptor for setting specifics of power type.
* Note: this structure is listed for backwards compatibility. */
typedef struct OMX_OTHER_CONFIG_POWERTYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_BOOL bEnablePM; /**< Flag to enable Power Management */
} OMX_OTHER_CONFIG_POWERTYPE;
/** Descriptor for setting specifics of stats type.
* Note: this structure is listed for backwards compatibility. */
typedef struct OMX_OTHER_CONFIG_STATSTYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
/* what goes here */
} OMX_OTHER_CONFIG_STATSTYPE;
/**
* The PortDefinition structure is used to define all of the parameters
* necessary for the compliant component to setup an input or an output other
* path.
*/
typedef struct OMX_OTHER_PORTDEFINITIONTYPE {
OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */
} OMX_OTHER_PORTDEFINITIONTYPE;
/** Port format parameter. This structure is used to enumerate
* the various data input/output format supported by the port.
*/
typedef struct OMX_OTHER_PARAM_PORTFORMATTYPE {
OMX_U32 nSize; /**< size of the structure in bytes */
OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
OMX_U32 nPortIndex; /**< Indicates which port to set */
OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */
OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */
} OMX_OTHER_PARAM_PORTFORMATTYPE;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/* File EOF */
@@ -0,0 +1,365 @@
/* ------------------------------------------------------------------
* 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 */
File diff suppressed because it is too large Load Diff
+24
View File
@@ -0,0 +1,24 @@
/*
* 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 THREAD_INIT_H
#define THREAD_INIT_H
bool InitializeForThread();
void UninitializeForThread();
#endif /* THREAD_INIT_H*/