diff options
Diffstat (limited to 'include')
111 files changed, 0 insertions, 14177 deletions
diff --git a/include/android_runtime/ActivityManager.h b/include/android_runtime/ActivityManager.h deleted file mode 100644 index 451a004..0000000 --- a/include/android_runtime/ActivityManager.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ActivityManager_H -#define ActivityManager_H - -#include <utils/String16.h> - -namespace android { - -// Perform a ContentProvider.openFile() call for the given URI. -// -// Returns the native file descriptor for the opened stream, < 0 on error. -extern int openContentProviderFile(const String16& uri); - -} - -#endif diff --git a/include/camera/Camera.h b/include/camera/Camera.h deleted file mode 100644 index 3fedea0..0000000 --- a/include/camera/Camera.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_HARDWARE_CAMERA_H -#define ANDROID_HARDWARE_CAMERA_H - -#include <utils/Timers.h> -#include <gui/ISurfaceTexture.h> -#include <system/camera.h> -#include <camera/ICameraClient.h> -#include <camera/ICameraRecordingProxy.h> -#include <camera/ICameraRecordingProxyListener.h> - -namespace android { - -struct CameraInfo { - /** - * The direction that the camera faces to. It should be CAMERA_FACING_BACK - * or CAMERA_FACING_FRONT. - */ - int facing; - - /** - * The orientation of the camera image. The value is the angle that the - * camera image needs to be rotated clockwise so it shows correctly on the - * display in its natural orientation. It should be 0, 90, 180, or 270. - * - * For example, suppose a device has a naturally tall screen. The - * back-facing camera sensor is mounted in landscape. You are looking at - * the screen. If the top side of the camera sensor is aligned with the - * right edge of the screen in natural orientation, the value should be - * 90. If the top side of a front-facing camera sensor is aligned with the - * right of the screen, the value should be 270. - */ - int orientation; -}; - -class ICameraService; -class ICamera; -class Surface; -class Mutex; -class String8; - -// ref-counted object for callbacks -class CameraListener: virtual public RefBase -{ -public: - virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) = 0; - virtual void postData(int32_t msgType, const sp<IMemory>& dataPtr, - camera_frame_metadata_t *metadata) = 0; - virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) = 0; -}; - -class Camera : public BnCameraClient, public IBinder::DeathRecipient -{ -public: - // construct a camera client from an existing remote - static sp<Camera> create(const sp<ICamera>& camera); - static int32_t getNumberOfCameras(); - static status_t getCameraInfo(int cameraId, - struct CameraInfo* cameraInfo); - static sp<Camera> connect(int cameraId, bool force, bool keep); - virtual ~Camera(); - void init(); - - status_t reconnect(); - void disconnect(); - status_t lock(); - status_t unlock(); - - status_t getStatus() { return mStatus; } - - // pass the buffered Surface to the camera service - status_t setPreviewDisplay(const sp<Surface>& surface); - - // pass the buffered ISurfaceTexture to the camera service - status_t setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture); - - // start preview mode, must call setPreviewDisplay first - status_t startPreview(); - - // stop preview mode - void stopPreview(); - - // get preview state - bool previewEnabled(); - - // start recording mode, must call setPreviewDisplay first - status_t startRecording(); - - // stop recording mode - void stopRecording(); - - // get recording state - bool recordingEnabled(); - - // release a recording frame - void releaseRecordingFrame(const sp<IMemory>& mem); - - // autoFocus - status returned from callback - status_t autoFocus(); - - // cancel auto focus - status_t cancelAutoFocus(); - - // take a picture - picture returned from callback - status_t takePicture(int msgType); - - // set preview/capture parameters - key/value pairs - status_t setParameters(const String8& params); - - // get preview/capture parameters - key/value pairs - String8 getParameters() const; - - // send command to camera driver - status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2); - - // tell camera hal to store meta data or real YUV in video buffers. - status_t storeMetaDataInBuffers(bool enabled); - - void setListener(const sp<CameraListener>& listener); - void setRecordingProxyListener(const sp<ICameraRecordingProxyListener>& listener); - void setPreviewCallbackFlags(int preview_callback_flag); - - sp<ICameraRecordingProxy> getRecordingProxy(); - - // ICameraClient interface - virtual void notifyCallback(int32_t msgType, int32_t ext, int32_t ext2); - virtual void dataCallback(int32_t msgType, const sp<IMemory>& dataPtr, - camera_frame_metadata_t *metadata); - virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr); - - sp<ICamera> remote(); - - class RecordingProxy : public BnCameraRecordingProxy - { - public: - RecordingProxy(const sp<Camera>& camera); - - // ICameraRecordingProxy interface - virtual status_t startRecording(const sp<ICameraRecordingProxyListener>& listener); - virtual void stopRecording(); - virtual void releaseRecordingFrame(const sp<IMemory>& mem); - - private: - sp<Camera> mCamera; - }; - -private: - Camera(); - Camera(const Camera&); - Camera& operator=(const Camera); - virtual void binderDied(const wp<IBinder>& who); - - class DeathNotifier: public IBinder::DeathRecipient - { - public: - DeathNotifier() { - } - - virtual void binderDied(const wp<IBinder>& who); - }; - - static sp<DeathNotifier> mDeathNotifier; - - // helper function to obtain camera service handle - static const sp<ICameraService>& getCameraService(); - - sp<ICamera> mCamera; - status_t mStatus; - - sp<CameraListener> mListener; - sp<ICameraRecordingProxyListener> mRecordingProxyListener; - - friend class DeathNotifier; - - static Mutex mLock; - static sp<ICameraService> mCameraService; -}; - -}; // namespace android - -#endif diff --git a/include/camera/ICamera.h b/include/camera/ICamera.h deleted file mode 100644 index 3d18837..0000000 --- a/include/camera/ICamera.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_HARDWARE_ICAMERA_H -#define ANDROID_HARDWARE_ICAMERA_H - -#include <utils/RefBase.h> -#include <binder/IInterface.h> -#include <binder/Parcel.h> -#include <binder/IMemory.h> -#include <utils/String8.h> -#include <camera/Camera.h> - -namespace android { - -class ICameraClient; -class ISurfaceTexture; -class Surface; - -class ICamera: public IInterface -{ -public: - DECLARE_META_INTERFACE(Camera); - - virtual void disconnect() = 0; - - // connect new client with existing camera remote - virtual status_t connect(const sp<ICameraClient>& client) = 0; - - // prevent other processes from using this ICamera interface - virtual status_t lock() = 0; - - // allow other processes to use this ICamera interface - virtual status_t unlock() = 0; - - // pass the buffered Surface to the camera service - virtual status_t setPreviewDisplay(const sp<Surface>& surface) = 0; - - // pass the buffered ISurfaceTexture to the camera service - virtual status_t setPreviewTexture( - const sp<ISurfaceTexture>& surfaceTexture) = 0; - - // set the preview callback flag to affect how the received frames from - // preview are handled. - virtual void setPreviewCallbackFlag(int flag) = 0; - - // start preview mode, must call setPreviewDisplay first - virtual status_t startPreview() = 0; - - // stop preview mode - virtual void stopPreview() = 0; - - // get preview state - virtual bool previewEnabled() = 0; - - // start recording mode - virtual status_t startRecording() = 0; - - // stop recording mode - virtual void stopRecording() = 0; - - // get recording state - virtual bool recordingEnabled() = 0; - - // release a recording frame - virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0; - - // auto focus - virtual status_t autoFocus() = 0; - - // cancel auto focus - virtual status_t cancelAutoFocus() = 0; - - /* - * take a picture. - * @param msgType the message type an application selectively turn on/off - * on a photo-by-photo basis. The supported message types are: - * CAMERA_MSG_SHUTTER, CAMERA_MSG_RAW_IMAGE, CAMERA_MSG_COMPRESSED_IMAGE, - * and CAMERA_MSG_POSTVIEW_FRAME. Any other message types will be ignored. - */ - virtual status_t takePicture(int msgType) = 0; - - // set preview/capture parameters - key/value pairs - virtual status_t setParameters(const String8& params) = 0; - - // get preview/capture parameters - key/value pairs - virtual String8 getParameters() const = 0; - - // send command to camera driver - virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0; - - // tell the camera hal to store meta data or real YUV data in video buffers. - virtual status_t storeMetaDataInBuffers(bool enabled) = 0; -}; - -// ---------------------------------------------------------------------------- - -class BnCamera: public BnInterface<ICamera> -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -}; // namespace android - -#endif diff --git a/include/camera/ICameraClient.h b/include/camera/ICameraClient.h deleted file mode 100644 index b30aa7a..0000000 --- a/include/camera/ICameraClient.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_HARDWARE_ICAMERA_APP_H -#define ANDROID_HARDWARE_ICAMERA_APP_H - -#include <utils/RefBase.h> -#include <binder/IInterface.h> -#include <binder/Parcel.h> -#include <binder/IMemory.h> -#include <utils/Timers.h> -#include <system/camera.h> - -namespace android { - -class ICameraClient: public IInterface -{ -public: - DECLARE_META_INTERFACE(CameraClient); - - virtual void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2) = 0; - virtual void dataCallback(int32_t msgType, const sp<IMemory>& data, - camera_frame_metadata_t *metadata) = 0; - virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& data) = 0; -}; - -// ---------------------------------------------------------------------------- - -class BnCameraClient: public BnInterface<ICameraClient> -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -}; // namespace android - -#endif diff --git a/include/camera/ICameraRecordingProxy.h b/include/camera/ICameraRecordingProxy.h deleted file mode 100644 index 2aac284..0000000 --- a/include/camera/ICameraRecordingProxy.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_H -#define ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_H - -#include <binder/IInterface.h> -#include <utils/RefBase.h> - -namespace android { - -class ICameraRecordingProxyListener; -class IMemory; -class Parcel; - -/* - * The purpose of ICameraRecordingProxy and ICameraRecordingProxyListener is to - * allow applications using the camera during recording. - * - * Camera service allows only one client at a time. Since camcorder application - * needs to own the camera to do things like zoom, the media recorder cannot - * access the camera directly during recording. So ICameraRecordingProxy is a - * proxy of ICamera, which allows the media recorder to start/stop the recording - * and release recording frames. ICameraRecordingProxyListener is an interface - * that allows the recorder to receive video frames during recording. - * - * ICameraRecordingProxy - * startRecording() - * stopRecording() - * releaseRecordingFrame() - * - * ICameraRecordingProxyListener - * dataCallbackTimestamp() - - * The camcorder app opens the camera and starts the preview. The app passes - * ICamera and ICameraRecordingProxy to the media recorder by - * MediaRecorder::setCamera(). The recorder uses ICamera to setup the camera in - * MediaRecorder::start(). After setup, the recorder disconnects from camera - * service. The recorder calls ICameraRecordingProxy::startRecording() and - * passes a ICameraRecordingProxyListener to the app. The app connects back to - * camera service and starts the recording. The app owns the camera and can do - * things like zoom. The media recorder receives the video frames from the - * listener and releases them by ICameraRecordingProxy::releaseRecordingFrame. - * The recorder calls ICameraRecordingProxy::stopRecording() to stop the - * recording. - * - * The call sequences are as follows: - * 1. The app: Camera.unlock(). - * 2. The app: MediaRecorder.setCamera(). - * 3. Start recording - * (1) The app: MediaRecorder.start(). - * (2) The recorder: ICamera.unlock() and ICamera.disconnect(). - * (3) The recorder: ICameraRecordingProxy.startRecording(). - * (4) The app: ICamera.reconnect(). - * (5) The app: ICamera.startRecording(). - * 4. During recording - * (1) The recorder: receive frames from ICameraRecordingProxyListener.dataCallbackTimestamp() - * (2) The recorder: release frames by ICameraRecordingProxy.releaseRecordingFrame(). - * 5. Stop recording - * (1) The app: MediaRecorder.stop() - * (2) The recorder: ICameraRecordingProxy.stopRecording(). - * (3) The app: ICamera.stopRecording(). - */ - -class ICameraRecordingProxy: public IInterface -{ -public: - DECLARE_META_INTERFACE(CameraRecordingProxy); - - virtual status_t startRecording(const sp<ICameraRecordingProxyListener>& listener) = 0; - virtual void stopRecording() = 0; - virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0; -}; - -// ---------------------------------------------------------------------------- - -class BnCameraRecordingProxy: public BnInterface<ICameraRecordingProxy> -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -}; // namespace android - -#endif diff --git a/include/camera/ICameraRecordingProxyListener.h b/include/camera/ICameraRecordingProxyListener.h deleted file mode 100644 index b6c0624..0000000 --- a/include/camera/ICameraRecordingProxyListener.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_LISTENER_H -#define ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_LISTENER_H - -#include <binder/IInterface.h> -#include <stdint.h> -#include <utils/RefBase.h> -#include <utils/Timers.h> - -namespace android { - -class Parcel; -class IMemory; - -class ICameraRecordingProxyListener: public IInterface -{ -public: - DECLARE_META_INTERFACE(CameraRecordingProxyListener); - - virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, - const sp<IMemory>& data) = 0; -}; - -// ---------------------------------------------------------------------------- - -class BnCameraRecordingProxyListener: public BnInterface<ICameraRecordingProxyListener> -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -}; // namespace android - -#endif diff --git a/include/camera/ICameraService.h b/include/camera/ICameraService.h deleted file mode 100644 index 97e3169..0000000 --- a/include/camera/ICameraService.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_HARDWARE_ICAMERASERVICE_H -#define ANDROID_HARDWARE_ICAMERASERVICE_H - -#include <utils/RefBase.h> -#include <binder/IInterface.h> -#include <binder/Parcel.h> - -#include <camera/ICameraClient.h> -#include <camera/ICamera.h> - -namespace android { - -class ICameraService : public IInterface -{ -public: - enum { - GET_NUMBER_OF_CAMERAS = IBinder::FIRST_CALL_TRANSACTION, - GET_CAMERA_INFO, - CONNECT - }; - -public: - DECLARE_META_INTERFACE(CameraService); - - virtual int32_t getNumberOfCameras() = 0; - virtual status_t getCameraInfo(int cameraId, - struct CameraInfo* cameraInfo) = 0; - virtual sp<ICamera> connect(const sp<ICameraClient>& cameraClient, - int cameraId, bool force, bool keep) = 0; -}; - -// ---------------------------------------------------------------------------- - -class BnCameraService: public BnInterface<ICameraService> -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -}; // namespace android - -#endif diff --git a/include/common_time/ICommonClock.h b/include/common_time/ICommonClock.h deleted file mode 100644 index d7073f1..0000000 --- a/include/common_time/ICommonClock.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_ICOMMONCLOCK_H -#define ANDROID_ICOMMONCLOCK_H - -#include <stdint.h> -#include <linux/socket.h> - -#include <binder/IInterface.h> -#include <binder/IServiceManager.h> - -namespace android { - -class ICommonClockListener : public IInterface { - public: - DECLARE_META_INTERFACE(CommonClockListener); - - virtual void onTimelineChanged(uint64_t timelineID) = 0; -}; - -class BnCommonClockListener : public BnInterface<ICommonClockListener> { - public: - virtual status_t onTransact(uint32_t code, const Parcel& data, - Parcel* reply, uint32_t flags = 0); -}; - -class ICommonClock : public IInterface { - public: - DECLARE_META_INTERFACE(CommonClock); - - // Name of the ICommonClock service registered with the service manager. - static const String16 kServiceName; - - // a reserved invalid timeline ID - static const uint64_t kInvalidTimelineID; - - // a reserved invalid error estimate - static const int32_t kErrorEstimateUnknown; - - enum State { - // the device just came up and is trying to discover the master - STATE_INITIAL, - - // the device is a client of a master - STATE_CLIENT, - - // the device is acting as master - STATE_MASTER, - - // the device has lost contact with its master and needs to participate - // in the election of a new master - STATE_RONIN, - - // the device is waiting for announcement of the newly elected master - STATE_WAIT_FOR_ELECTION, - }; - - virtual status_t isCommonTimeValid(bool* valid, uint32_t* timelineID) = 0; - virtual status_t commonTimeToLocalTime(int64_t commonTime, - int64_t* localTime) = 0; - virtual status_t localTimeToCommonTime(int64_t localTime, - int64_t* commonTime) = 0; - virtual status_t getCommonTime(int64_t* commonTime) = 0; - virtual status_t getCommonFreq(uint64_t* freq) = 0; - virtual status_t getLocalTime(int64_t* localTime) = 0; - virtual status_t getLocalFreq(uint64_t* freq) = 0; - virtual status_t getEstimatedError(int32_t* estimate) = 0; - virtual status_t getTimelineID(uint64_t* id) = 0; - virtual status_t getState(State* state) = 0; - virtual status_t getMasterAddr(struct sockaddr_storage* addr) = 0; - - virtual status_t registerListener( - const sp<ICommonClockListener>& listener) = 0; - virtual status_t unregisterListener( - const sp<ICommonClockListener>& listener) = 0; - - // Simple helper to make it easier to connect to the CommonClock service. - static inline sp<ICommonClock> getInstance() { - sp<IBinder> binder = defaultServiceManager()->checkService( - ICommonClock::kServiceName); - sp<ICommonClock> clk = interface_cast<ICommonClock>(binder); - return clk; - } -}; - -class BnCommonClock : public BnInterface<ICommonClock> { - public: - virtual status_t onTransact(uint32_t code, const Parcel& data, - Parcel* reply, uint32_t flags = 0); -}; - -}; // namespace android - -#endif // ANDROID_ICOMMONCLOCK_H diff --git a/include/common_time/ICommonTimeConfig.h b/include/common_time/ICommonTimeConfig.h deleted file mode 100644 index 497b666..0000000 --- a/include/common_time/ICommonTimeConfig.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_ICOMMONTIMECONFIG_H -#define ANDROID_ICOMMONTIMECONFIG_H - -#include <stdint.h> -#include <linux/socket.h> - -#include <binder/IInterface.h> -#include <binder/IServiceManager.h> - -namespace android { - -class String16; - -class ICommonTimeConfig : public IInterface { - public: - DECLARE_META_INTERFACE(CommonTimeConfig); - - // Name of the ICommonTimeConfig service registered with the service - // manager. - static const String16 kServiceName; - - virtual status_t getMasterElectionPriority(uint8_t *priority) = 0; - virtual status_t setMasterElectionPriority(uint8_t priority) = 0; - virtual status_t getMasterElectionEndpoint(struct sockaddr_storage *addr) = 0; - virtual status_t setMasterElectionEndpoint(const struct sockaddr_storage *addr) = 0; - virtual status_t getMasterElectionGroupId(uint64_t *id) = 0; - virtual status_t setMasterElectionGroupId(uint64_t id) = 0; - virtual status_t getInterfaceBinding(String16& ifaceName) = 0; - virtual status_t setInterfaceBinding(const String16& ifaceName) = 0; - virtual status_t getMasterAnnounceInterval(int *interval) = 0; - virtual status_t setMasterAnnounceInterval(int interval) = 0; - virtual status_t getClientSyncInterval(int *interval) = 0; - virtual status_t setClientSyncInterval(int interval) = 0; - virtual status_t getPanicThreshold(int *threshold) = 0; - virtual status_t setPanicThreshold(int threshold) = 0; - virtual status_t getAutoDisable(bool *autoDisable) = 0; - virtual status_t setAutoDisable(bool autoDisable) = 0; - virtual status_t forceNetworklessMasterMode() = 0; - - // Simple helper to make it easier to connect to the CommonTimeConfig service. - static inline sp<ICommonTimeConfig> getInstance() { - sp<IBinder> binder = defaultServiceManager()->checkService( - ICommonTimeConfig::kServiceName); - sp<ICommonTimeConfig> clk = interface_cast<ICommonTimeConfig>(binder); - return clk; - } -}; - -class BnCommonTimeConfig : public BnInterface<ICommonTimeConfig> { - public: - virtual status_t onTransact(uint32_t code, const Parcel& data, - Parcel* reply, uint32_t flags = 0); -}; - -}; // namespace android - -#endif // ANDROID_ICOMMONTIMECONFIG_H diff --git a/include/common_time/cc_helper.h b/include/common_time/cc_helper.h deleted file mode 100644 index 8c4d5c0..0000000 --- a/include/common_time/cc_helper.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __CC_HELPER_H__ -#define __CC_HELPER_H__ - -#include <stdint.h> -#include <common_time/ICommonClock.h> -#include <utils/threads.h> - -namespace android { - -// CCHelper is a simple wrapper class to help with centralizing access to the -// Common Clock service and implementing lifetime managment, as well as to -// implement a simple policy of making a basic attempt to reconnect to the -// common clock service when things go wrong. -// -// On platforms which run the native common_time service in auto-disable mode, -// the service will go into networkless mode whenever it has no active clients. -// It tracks active clients using registered CommonClockListeners (the callback -// interface for onTimelineChanged) since this provides a convienent death -// handler notification for when the service's clients die unexpectedly. This -// means that users of the common time service should really always have a -// CommonClockListener, unless they know that the time service is not running in -// auto disabled mode, or that there is at least one other registered listener -// active in the system. The CCHelper makes this a little easier by sharing a -// ref counted ICommonClock interface across all clients and automatically -// registering and unregistering a listener whenever there are CCHelper -// instances active in the process. -class CCHelper { - public: - CCHelper(); - ~CCHelper(); - - status_t isCommonTimeValid(bool* valid, uint32_t* timelineID); - status_t commonTimeToLocalTime(int64_t commonTime, int64_t* localTime); - status_t localTimeToCommonTime(int64_t localTime, int64_t* commonTime); - status_t getCommonTime(int64_t* commonTime); - status_t getCommonFreq(uint64_t* freq); - status_t getLocalTime(int64_t* localTime); - status_t getLocalFreq(uint64_t* freq); - - private: - class CommonClockListener : public BnCommonClockListener { - public: - void onTimelineChanged(uint64_t timelineID); - }; - - static bool verifyClock_l(); - - static Mutex lock_; - static sp<ICommonClock> common_clock_; - static sp<ICommonClockListener> common_clock_listener_; - static uint32_t ref_count_; -}; - - -} // namespace android -#endif // __CC_HELPER_H__ diff --git a/include/common_time/local_clock.h b/include/common_time/local_clock.h deleted file mode 100644 index 384c3de..0000000 --- a/include/common_time/local_clock.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef __LOCAL_CLOCK_H__ -#define __LOCAL_CLOCK_H__ - -#include <stdint.h> - -#include <hardware/local_time_hal.h> -#include <utils/Errors.h> -#include <utils/threads.h> - -namespace android { - -class LocalClock { - public: - LocalClock(); - - bool initCheck(); - - int64_t getLocalTime(); - uint64_t getLocalFreq(); - status_t setLocalSlew(int16_t rate); - int32_t getDebugLog(struct local_time_debug_event* records, - int max_records); - - private: - static Mutex dev_lock_; - static local_time_hw_device_t* dev_; -}; - -} // namespace android -#endif // __LOCAL_CLOCK_H__ diff --git a/include/drm/DrmConstraints.h b/include/drm/DrmConstraints.h deleted file mode 100644 index a9ec942..0000000 --- a/include/drm/DrmConstraints.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DRM_CONSTRAINTS_H__ -#define __DRM_CONSTRAINTS_H__ - -#include "drm_framework_common.h" - -namespace android { - -/** - * This is an utility class which contains the constraints information. - * - * As a result of DrmManagerClient::getConstraints(const String8*, const int) - * an instance of DrmConstraints would be returned. - * - */ -class DrmConstraints { -public: - /** - * The following variables are replica of android.drm.DrmStore.ConstraintsColumns - * Any changes should also be incorporated with Java Layer as well - */ - /** - * The max repeat count - */ - static const String8 MAX_REPEAT_COUNT; - /** - * The remaining repeat count - */ - static const String8 REMAINING_REPEAT_COUNT; - - /** - * The time before which the protected file can not be played/viewed - */ - static const String8 LICENSE_START_TIME; - - /** - * The time after which the protected file can not be played/viewed - */ - static const String8 LICENSE_EXPIRY_TIME; - - /** - * The available time for license - */ - static const String8 LICENSE_AVAILABLE_TIME; - - /** - * The data stream for extended metadata - */ - static const String8 EXTENDED_METADATA; - -public: - /** - * Iterator for key - */ - class KeyIterator { - friend class DrmConstraints; - private: - KeyIterator(DrmConstraints* drmConstraints) - : mDrmConstraints(drmConstraints), mIndex(0) {} - - public: - KeyIterator(const KeyIterator& keyIterator); - KeyIterator& operator=(const KeyIterator& keyIterator); - virtual ~KeyIterator() {} - - public: - bool hasNext(); - const String8& next(); - - private: - DrmConstraints* mDrmConstraints; - unsigned int mIndex; - }; - - /** - * Iterator for constraints - */ - class Iterator { - friend class DrmConstraints; - private: - Iterator(DrmConstraints* drmConstraints) - : mDrmConstraints(drmConstraints), mIndex(0) {} - - public: - Iterator(const Iterator& iterator); - Iterator& operator=(const Iterator& iterator); - virtual ~Iterator() {} - - public: - bool hasNext(); - String8 next(); - - private: - DrmConstraints* mDrmConstraints; - unsigned int mIndex; - }; - -public: - DrmConstraints() {} - virtual ~DrmConstraints() { - DrmConstraints::KeyIterator keyIt = this->keyIterator(); - - while (keyIt.hasNext()) { - String8 key = keyIt.next(); - const char* value = this->getAsByteArray(&key); - if (NULL != value) { - delete[] value; - value = NULL; - } - } - mConstraintMap.clear(); - } -public: - /** - * Returns the number of constraints contained in this instance - * - * @return Number of constraints - */ - int getCount(void) const; - - /** - * Adds constraint information as <key, value> pair to this instance - * - * @param[in] key Key to add - * @param[in] value Value to add - * @return Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t put(const String8* key, const char* value); - - /** - * Retrieves the value of given key - * - * @param key Key whose value to be retrieved - * @return The value - */ - String8 get(const String8& key) const; - - /** - * Retrieves the value as byte array of given key - * @param key Key whose value to be retrieved as byte array - * @return The byte array value - */ - const char* getAsByteArray(const String8* key) const; - - /** - * Returns KeyIterator object to walk through the keys associated with this instance - * - * @return KeyIterator object - */ - KeyIterator keyIterator(); - - /** - * Returns Iterator object to walk through the values associated with this instance - * - * @return Iterator object - */ - Iterator iterator(); -private: - const char* getValue(const String8* key) const; -private: - typedef KeyedVector<String8, const char*> DrmConstraintsMap; - DrmConstraintsMap mConstraintMap; -}; - -}; - -#endif /* __DRM_CONSTRAINTS_H__ */ - diff --git a/include/drm/DrmConvertedStatus.h b/include/drm/DrmConvertedStatus.h deleted file mode 100644 index 679e48d..0000000 --- a/include/drm/DrmConvertedStatus.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DRM_CONVERTED_STATUS_H__ -#define __DRM_CONVERTED_STATUS_H__ - -#include "drm_framework_common.h" - -namespace android { - -/** - * This is an utility class which wraps the status of the conversion, the converted - * data/checksum data and the offset. Offset is going to be used in the case of close - * session where the agent will inform where the header and body signature should be added - * - * As a result of DrmManagerClient::convertData(int, const DrmBuffer*) and - * DrmManagerClient::closeConvertSession(int) an instance of DrmConvertedStatus - * would be returned. - * - */ -class DrmConvertedStatus { -public: - // Should be in sync with DrmConvertedStatus.java - static const int STATUS_OK = 1; - static const int STATUS_INPUTDATA_ERROR = 2; - static const int STATUS_ERROR = 3; - -public: - /** - * Constructor for DrmConvertedStatus - * - * @param[in] _statusCode Status of the conversion - * @param[in] _convertedData Converted data/checksum data - * @param[in] _offset Offset value - */ - DrmConvertedStatus(int _statusCode, const DrmBuffer* _convertedData, int _offset); - - /** - * Destructor for DrmConvertedStatus - */ - virtual ~DrmConvertedStatus() { - - } - -public: - int statusCode; - const DrmBuffer* convertedData; - int offset; -}; - -}; - -#endif /* __DRM_CONVERTED_STATUS_H__ */ - diff --git a/include/drm/DrmInfo.h b/include/drm/DrmInfo.h deleted file mode 100644 index 7b48541..0000000 --- a/include/drm/DrmInfo.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DRM_INFO_H__ -#define __DRM_INFO_H__ - -#include "drm_framework_common.h" - -namespace android { - -/** - * This is an utility class in which necessary information required to transact - * between device and online DRM server is described. DRM Framework achieves - * server registration, license acquisition and any other server related transaction - * by passing an instance of this class to DrmManagerClient::processDrmInfo(const DrmInfo*). - * - * The Caller can retrieve the DrmInfo instance by using - * DrmManagerClient::acquireDrmInfo(const DrmInfoRequest*) by passing DrmInfoRequest instance. - * - */ -class DrmInfo { -public: - /** - * Constructor for DrmInfo - * - * @param[in] infoType Type of information - * @param[in] drmBuffer Trigger data - * @param[in] mimeType MIME type - */ - DrmInfo(int infoType, const DrmBuffer& drmBuffer, const String8& mimeType); - - /** - * Destructor for DrmInfo - */ - virtual ~DrmInfo() {} - -public: - /** - * Iterator for key - */ - class KeyIterator { - friend class DrmInfo; - - private: - KeyIterator(const DrmInfo* drmInfo) - : mDrmInfo(const_cast <DrmInfo*> (drmInfo)), mIndex(0) {} - - public: - KeyIterator(const KeyIterator& keyIterator); - KeyIterator& operator=(const KeyIterator& keyIterator); - virtual ~KeyIterator() {} - - public: - bool hasNext(); - const String8& next(); - - private: - DrmInfo* mDrmInfo; - unsigned int mIndex; - }; - - /** - * Iterator - */ - class Iterator { - friend class DrmInfo; - - private: - Iterator(const DrmInfo* drmInfo) - : mDrmInfo(const_cast <DrmInfo*> (drmInfo)), mIndex(0) {} - - public: - Iterator(const Iterator& iterator); - Iterator& operator=(const Iterator& iterator); - virtual ~Iterator() {} - - public: - bool hasNext(); - String8& next(); - - private: - DrmInfo* mDrmInfo; - unsigned int mIndex; - }; - -public: - /** - * Returns information type associated with this instance - * - * @return Information type - */ - int getInfoType(void) const; - - /** - * Returns MIME type associated with this instance - * - * @return MIME type - */ - String8 getMimeType(void) const; - - /** - * Returns the trigger data associated with this instance - * - * @return Trigger data - */ - const DrmBuffer& getData(void) const; - - /** - * Returns the number of attributes contained in this instance - * - * @return Number of attributes - */ - int getCount(void) const; - - /** - * Adds optional information as <key, value> pair to this instance - * - * @param[in] key Key to add - * @param[in] value Value to add - * @return Returns the error code - */ - status_t put(const String8& key, const String8& value); - - /** - * Retrieves the value of given key - * - * @param key Key whose value to be retrieved - * @return The value - */ - String8 get(const String8& key) const; - - /** - * Returns KeyIterator object to walk through the keys associated with this instance - * - * @return KeyIterator object - */ - KeyIterator keyIterator() const; - - /** - * Returns Iterator object to walk through the values associated with this instance - * - * @return Iterator object - */ - Iterator iterator() const; - - /** - * Returns index of the given key - * - * @return index - */ - int indexOfKey(const String8& key) const; - -protected: - int mInfoType; - DrmBuffer mData; - String8 mMimeType; - KeyedVector<String8, String8> mAttributes; -}; - -}; - -#endif /* __DRM_INFO_H__ */ - diff --git a/include/drm/DrmInfoEvent.h b/include/drm/DrmInfoEvent.h deleted file mode 100644 index dfca228..0000000 --- a/include/drm/DrmInfoEvent.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DRM_INFO_EVENT_H__ -#define __DRM_INFO_EVENT_H__ - -namespace android { - -class String8; - -/** - * This is an entity class which would be passed to caller in - * DrmManagerClient::OnInfoListener::onInfo(const DrmInfoEvent&). - */ -class DrmInfoEvent { -public: - /** - * The following constant values should be in sync with DrmInfoEvent.java - */ - //! TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT, when registration has been - //! already done by another account ID. - static const int TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT = 1; - //! TYPE_REMOVE_RIGHTS, when the rights needs to be removed completely. - static const int TYPE_REMOVE_RIGHTS = 2; - //! TYPE_RIGHTS_INSTALLED, when the rights are downloaded and installed ok. - static const int TYPE_RIGHTS_INSTALLED = 3; - //! TYPE_WAIT_FOR_RIGHTS, rights object is on it's way to phone, - //! wait before calling checkRights again - static const int TYPE_WAIT_FOR_RIGHTS = 4; - //! TYPE_ACCOUNT_ALREADY_REGISTERED, when registration has been - //! already done for the given account. - static const int TYPE_ACCOUNT_ALREADY_REGISTERED = 5; - //! TYPE_RIGHTS_REMOVED, when the rights has been removed. - static const int TYPE_RIGHTS_REMOVED = 6; - - /** - * The following constant values should be in sync with DrmErrorEvent.java - */ - //! TYPE_RIGHTS_NOT_INSTALLED, when something went wrong installing the rights - static const int TYPE_RIGHTS_NOT_INSTALLED = 2001; - //! TYPE_RIGHTS_RENEWAL_NOT_ALLOWED, when the server rejects renewal of rights - static const int TYPE_RIGHTS_RENEWAL_NOT_ALLOWED = 2002; - //! TYPE_NOT_SUPPORTED, when answer from server can not be handled by the native agent - static const int TYPE_NOT_SUPPORTED = 2003; - //! TYPE_OUT_OF_MEMORY, when memory allocation fail during renewal. - //! Can in the future perhaps be used to trigger garbage collector - static const int TYPE_OUT_OF_MEMORY = 2004; - //! TYPE_NO_INTERNET_CONNECTION, when the Internet connection is missing and no attempt - //! can be made to renew rights - static const int TYPE_NO_INTERNET_CONNECTION = 2005; - //! TYPE_PROCESS_DRM_INFO_FAILED, when failed to process DrmInfo. - static const int TYPE_PROCESS_DRM_INFO_FAILED = 2006; - //! TYPE_REMOVE_ALL_RIGHTS_FAILED, when failed to remove all the rights objects - //! associated with all DRM schemes. - static const int TYPE_REMOVE_ALL_RIGHTS_FAILED = 2007; - //! TYPE_ACQUIRE_DRM_INFO_FAILED, when failed to acquire DrmInfo. - static const int TYPE_ACQUIRE_DRM_INFO_FAILED = 2008; - -public: - /** - * Constructor for DrmInfoEvent - * - * @param[in] uniqueId Unique session identifier - * @param[in] infoType Type of information - * @param[in] message Message description - */ - DrmInfoEvent(int uniqueId, int infoType, const String8 message); - - /** - * Destructor for DrmInfoEvent - */ - virtual ~DrmInfoEvent() {} - -public: - /** - * Returns the Unique Id associated with this instance - * - * @return Unique Id - */ - int getUniqueId() const; - - /** - * Returns the Type of information associated with this object - * - * @return Type of information - */ - int getType() const; - - /** - * Returns the message description associated with this object - * - * @return Message description - */ - const String8 getMessage() const; - -private: - int mUniqueId; - int mInfoType; - const String8 mMessage; -}; - -}; - -#endif /* __DRM_INFO_EVENT_H__ */ - diff --git a/include/drm/DrmInfoRequest.h b/include/drm/DrmInfoRequest.h deleted file mode 100644 index 3e48ecc..0000000 --- a/include/drm/DrmInfoRequest.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DRM_INFO_REQUEST_H__ -#define __DRM_INFO_REQUEST_H__ - -#include "drm_framework_common.h" - -namespace android { - -/** - * This is an utility class used to pass required parameters to get - * the necessary information to communicate with online DRM server - * - * An instance of this class is passed to - * DrmManagerClient::acquireDrmInfo(const DrmInfoRequest*) to get the - * instance of DrmInfo. - * - */ -class DrmInfoRequest { -public: - // Changes in following constants should be in sync with DrmInfoRequest.java - static const int TYPE_REGISTRATION_INFO = 1; - static const int TYPE_UNREGISTRATION_INFO = 2; - static const int TYPE_RIGHTS_ACQUISITION_INFO = 3; - static const int TYPE_RIGHTS_ACQUISITION_PROGRESS_INFO = 4; - - /** - * Key to pass the unique id for the account or the user - */ - static const String8 ACCOUNT_ID; - /** - * Key to pass the subscription id - */ - static const String8 SUBSCRIPTION_ID; - -public: - /** - * Constructor for DrmInfoRequest - * - * @param[in] infoType Type of information - * @param[in] mimeType MIME type - */ - DrmInfoRequest(int infoType, const String8& mimeType); - - /** - * Destructor for DrmInfoRequest - */ - virtual ~DrmInfoRequest() {} - -public: - /** - * Iterator for key - */ - class KeyIterator { - friend class DrmInfoRequest; - - private: - KeyIterator(const DrmInfoRequest* drmInfoRequest) - : mDrmInfoRequest(const_cast <DrmInfoRequest*> (drmInfoRequest)), mIndex(0) {} - - public: - KeyIterator(const KeyIterator& keyIterator); - KeyIterator& operator=(const KeyIterator& keyIterator); - virtual ~KeyIterator() {} - - public: - bool hasNext(); - const String8& next(); - - private: - DrmInfoRequest* mDrmInfoRequest; - unsigned int mIndex; - }; - - /** - * Iterator - */ - class Iterator { - friend class DrmInfoRequest; - - private: - Iterator(const DrmInfoRequest* drmInfoRequest) - : mDrmInfoRequest(const_cast <DrmInfoRequest*> (drmInfoRequest)), mIndex(0) {} - - public: - Iterator(const Iterator& iterator); - Iterator& operator=(const Iterator& iterator); - virtual ~Iterator() {} - - public: - bool hasNext(); - String8& next(); - - private: - DrmInfoRequest* mDrmInfoRequest; - unsigned int mIndex; - }; - -public: - /** - * Returns information type associated with this instance - * - * @return Information type - */ - int getInfoType(void) const; - - /** - * Returns MIME type associated with this instance - * - * @return MIME type - */ - String8 getMimeType(void) const; - - /** - * Returns the number of entries in DrmRequestInfoMap - * - * @return Number of entries - */ - int getCount(void) const; - - /** - * Adds optional information as <key, value> pair to this instance - * - * @param[in] key Key to add - * @param[in] value Value to add - * @return Returns the error code - */ - status_t put(const String8& key, const String8& value); - - /** - * Retrieves the value of given key - * - * @param key Key whose value to be retrieved - * @return The value - */ - String8 get(const String8& key) const; - - /** - * Returns KeyIterator object to walk through the keys associated with this instance - * - * @return KeyIterator object - */ - KeyIterator keyIterator() const; - - /** - * Returns Iterator object to walk through the values associated with this instance - * - * @return Iterator object - */ - Iterator iterator() const; - -private: - int mInfoType; - String8 mMimeType; - - typedef KeyedVector<String8, String8> DrmRequestInfoMap; - DrmRequestInfoMap mRequestInformationMap; -}; - -}; - -#endif /* __DRM_INFO_REQUEST_H__ */ - diff --git a/include/drm/DrmInfoStatus.h b/include/drm/DrmInfoStatus.h deleted file mode 100644 index 88c0f40..0000000 --- a/include/drm/DrmInfoStatus.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DRM_INFO_STATUS_H__ -#define __DRM_INFO_STATUS_H__ - -#include "drm_framework_common.h" - -namespace android { - -/** - * This is an utility class which wraps the result of communication between device - * and online DRM server. - * - * As a result of DrmManagerClient::processDrmInfo(const DrmInfo*) an instance of - * DrmInfoStatus would be returned. This class holds DrmBuffer which could be - * used to instantiate DrmRights in license acquisition. - * - */ -class DrmInfoStatus { -public: - // Should be in sync with DrmInfoStatus.java - static const int STATUS_OK = 1; - static const int STATUS_ERROR = 2; - -public: - /** - * Constructor for DrmInfoStatus - * - * @param[in] _statusCode Status of the communication - * @param[in] _infoType Type of the DRM information processed - * @param[in] _drmBuffer Rights information - * @param[in] _mimeType MIME type - */ - DrmInfoStatus(int _statusCode, int _infoType, const DrmBuffer* _drmBuffer, const String8& _mimeType); - - /** - * Destructor for DrmInfoStatus - */ - virtual ~DrmInfoStatus() { - - } - -public: - int statusCode; - int infoType; - const DrmBuffer* drmBuffer; - String8 mimeType; -}; - -}; - -#endif /* __DRM_INFO_STATUS_H__ */ - diff --git a/include/drm/DrmManagerClient.h b/include/drm/DrmManagerClient.h deleted file mode 100644 index c47bbfb..0000000 --- a/include/drm/DrmManagerClient.h +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DRM_MANAGER_CLIENT_H__ -#define __DRM_MANAGER_CLIENT_H__ - -#include <utils/threads.h> -#include <binder/IInterface.h> -#include "drm_framework_common.h" - -namespace android { - -class DrmInfo; -class DrmRights; -class DrmMetadata; -class DrmInfoEvent; -class DrmInfoStatus; -class DrmInfoRequest; -class DrmSupportInfo; -class DrmConstraints; -class DrmConvertedStatus; -class DrmManagerClientImpl; - -/** - * The Native application will instantiate this class and access DRM Framework - * services through this class. - * - */ -class DrmManagerClient { -public: - DrmManagerClient(); - - virtual ~DrmManagerClient(); - -public: - class OnInfoListener: virtual public RefBase { - - public: - virtual ~OnInfoListener() {} - - public: - virtual void onInfo(const DrmInfoEvent& event) = 0; - }; - -/** - * APIs which will be used by native modules (e.g. StageFright) - * - */ -public: - /** - * Open the decrypt session to decrypt the given protected content - * - * @param[in] fd File descriptor of the protected content to be decrypted - * @param[in] offset Start position of the content - * @param[in] length The length of the protected content - * @param[in] mime Mime type of the protected content if it is not NULL or empty - * @return - * Handle for the decryption session - */ - sp<DecryptHandle> openDecryptSession(int fd, off64_t offset, off64_t length, const char* mime); - - /** - * Open the decrypt session to decrypt the given protected content - * - * @param[in] uri Path of the protected content to be decrypted - * @param[in] mime Mime type of the protected content if it is not NULL or empty - * @return - * Handle for the decryption session - */ - sp<DecryptHandle> openDecryptSession(const char* uri, const char* mime); - - /** - * Close the decrypt session for the given handle - * - * @param[in] decryptHandle Handle for the decryption session - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t closeDecryptSession(sp<DecryptHandle> &decryptHandle); - - /** - * Consumes the rights for a content. - * If the reserve parameter is true the rights is reserved until the same - * application calls this api again with the reserve parameter set to false. - * - * @param[in] decryptHandle Handle for the decryption session - * @param[in] action Action to perform. (Action::DEFAULT, Action::PLAY, etc) - * @param[in] reserve True if the rights should be reserved. - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure. - * In case license has been expired, DRM_ERROR_LICENSE_EXPIRED will be returned. - */ - status_t consumeRights(sp<DecryptHandle> &decryptHandle, int action, bool reserve); - - /** - * Informs the DRM engine about the playback actions performed on the DRM files. - * - * @param[in] decryptHandle Handle for the decryption session - * @param[in] playbackStatus Playback action (Playback::START, Playback::STOP, Playback::PAUSE) - * @param[in] position Position in the file (in milliseconds) where the start occurs. - * Only valid together with Playback::START. - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t setPlaybackStatus( - sp<DecryptHandle> &decryptHandle, int playbackStatus, int64_t position); - - /** - * Initialize decryption for the given unit of the protected content - * - * @param[in] decryptHandle Handle for the decryption session - * @param[in] decryptUnitId ID which specifies decryption unit, such as track ID - * @param[in] headerInfo Information for initializing decryption of this decrypUnit - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t initializeDecryptUnit( - sp<DecryptHandle> &decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo); - - /** - * Decrypt the protected content buffers for the given unit - * This method will be called any number of times, based on number of - * encrypted streams received from application. - * - * @param[in] decryptHandle Handle for the decryption session - * @param[in] decryptUnitId ID which specifies decryption unit, such as track ID - * @param[in] encBuffer Encrypted data block - * @param[out] decBuffer Decrypted data block - * @param[in] IV Optional buffer - * @return status_t - * Returns the error code for this API - * DRM_NO_ERROR for success, and one of DRM_ERROR_UNKNOWN, DRM_ERROR_LICENSE_EXPIRED - * DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED, - * DRM_ERROR_DECRYPT for failure. - */ - status_t decrypt( - sp<DecryptHandle> &decryptHandle, int decryptUnitId, - const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV = NULL); - - /** - * Finalize decryption for the given unit of the protected content - * - * @param[in] decryptHandle Handle for the decryption session - * @param[in] decryptUnitId ID which specifies decryption unit, such as track ID - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t finalizeDecryptUnit( - sp<DecryptHandle> &decryptHandle, int decryptUnitId); - - /** - * Reads the specified number of bytes from an open DRM file. - * - * @param[in] decryptHandle Handle for the decryption session - * @param[out] buffer Reference to the buffer that should receive the read data. - * @param[in] numBytes Number of bytes to read. - * @param[in] offset Offset with which to update the file position. - * - * @return Number of bytes read. Returns -1 for Failure. - */ - ssize_t pread(sp<DecryptHandle> &decryptHandle, - void* buffer, ssize_t numBytes, off64_t offset); - - /** - * Validates whether an action on the DRM content is allowed or not. - * - * @param[in] path Path of the protected content - * @param[in] action Action to validate. (Action::DEFAULT, Action::PLAY, etc) - * @param[in] description Detailed description of the action - * @return true if the action is allowed. - */ - bool validateAction(const String8& path, int action, const ActionDescription& description); - -/** - * APIs which are just the underlying implementation for the Java API - * - */ -public: - /** - * Register a callback to be invoked when the caller required to - * receive necessary information - * - * @param[in] infoListener Listener - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t setOnInfoListener(const sp<DrmManagerClient::OnInfoListener>& infoListener); - - /** - * Get constraint information associated with input content - * - * @param[in] path Path of the protected content - * @param[in] action Actions defined such as, - * Action::DEFAULT, Action::PLAY, etc - * @return DrmConstraints - * key-value pairs of constraint are embedded in it - * @note - * In case of error, return NULL - */ - DrmConstraints* getConstraints(const String8* path, const int action); - - /** - * Get metadata information associated with input content - * - * @param[in] path Path of the protected content - * @return DrmMetadata - * key-value pairs of metadata - * @note - * In case of error, return NULL - */ - DrmMetadata* getMetadata(const String8* path); - - /** - * Check whether the given mimetype or path can be handled - * - * @param[in] path Path of the content needs to be handled - * @param[in] mimetype Mimetype of the content needs to be handled - * @return - * True if DrmManager can handle given path or mime type. - */ - bool canHandle(const String8& path, const String8& mimeType); - - /** - * Executes given drm information based on its type - * - * @param[in] drmInfo Information needs to be processed - * @return DrmInfoStatus - * instance as a result of processing given input - */ - DrmInfoStatus* processDrmInfo(const DrmInfo* drmInfo); - - /** - * Retrieves necessary information for registration, unregistration or rights - * acquisition information. - * - * @param[in] drmInfoRequest Request information to retrieve drmInfo - * @return DrmInfo - * instance as a result of processing given input - */ - DrmInfo* acquireDrmInfo(const DrmInfoRequest* drmInfoRequest); - - /** - * Save DRM rights to specified rights path - * and make association with content path - * - * @param[in] drmRights DrmRights to be saved - * @param[in] rightsPath File path where rights to be saved - * @param[in] contentPath File path where content was saved - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t saveRights( - const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath); - - /** - * Retrieves the mime type embedded inside the original content - * - * @param[in] path the path of the protected content - * @return String8 - * Returns mime-type of the original content, such as "video/mpeg" - */ - String8 getOriginalMimeType(const String8& path); - - /** - * Retrieves the type of the protected object (content, rights, etc..) - * by using specified path or mimetype. At least one parameter should be non null - * to retrieve DRM object type - * - * @param[in] path Path of the content or null. - * @param[in] mimeType Mime type of the content or null. - * @return type of the DRM content, - * such as DrmObjectType::CONTENT, DrmObjectType::RIGHTS_OBJECT - */ - int getDrmObjectType(const String8& path, const String8& mimeType); - - /** - * Check whether the given content has valid rights or not - * - * @param[in] path Path of the protected content - * @param[in] action Action to perform - * @return the status of the rights for the protected content, - * such as RightsStatus::RIGHTS_VALID, RightsStatus::RIGHTS_EXPIRED, etc. - */ - int checkRightsStatus(const String8& path, int action); - - /** - * Removes the rights associated with the given protected content - * - * @param[in] path Path of the protected content - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t removeRights(const String8& path); - - /** - * Removes all the rights information of each plug-in associated with - * DRM framework. Will be used in master reset - * - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t removeAllRights(); - - /** - * This API is for Forward Lock DRM. - * Each time the application tries to download a new DRM file - * which needs to be converted, then the application has to - * begin with calling this API. - * - * @param[in] convertId Handle for the convert session - * @param[in] mimeType Description/MIME type of the input data packet - * @return Return handle for the convert session - */ - int openConvertSession(const String8& mimeType); - - /** - * Passes the input data which need to be converted. The resultant - * converted data and the status is returned in the DrmConvertedInfo - * object. This method will be called each time there are new block - * of data received by the application. - * - * @param[in] convertId Handle for the convert session - * @param[in] inputData Input Data which need to be converted - * @return Return object contains the status of the data conversion, - * the output converted data and offset. In this case the - * application will ignore the offset information. - */ - DrmConvertedStatus* convertData(int convertId, const DrmBuffer* inputData); - - /** - * When there is no more data which need to be converted or when an - * error occurs that time the application has to inform the Drm agent - * via this API. Upon successful conversion of the complete data, - * the agent will inform that where the header and body signature - * should be added. This signature appending is needed to integrity - * protect the converted file. - * - * @param[in] convertId Handle for the convert session - * @return Return object contains the status of the data conversion, - * the header and body signature data. It also informs - * the application on which offset these signature data - * should be appended. - */ - DrmConvertedStatus* closeConvertSession(int convertId); - - /** - * Retrieves all DrmSupportInfo instance that native DRM framework can handle. - * This interface is meant to be used by JNI layer - * - * @param[out] length Number of elements in drmSupportInfoArray - * @param[out] drmSupportInfoArray Array contains all DrmSupportInfo - * that native DRM framework can handle - * @return status_t - * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t getAllSupportInfo(int* length, DrmSupportInfo** drmSupportInfoArray); - -private: - int mUniqueId; - sp<DrmManagerClientImpl> mDrmManagerClientImpl; -}; - -}; - -#endif /* __DRM_MANAGER_CLIENT_H__ */ - diff --git a/include/drm/DrmMetadata.h b/include/drm/DrmMetadata.h deleted file mode 100644 index 2c7538a..0000000 --- a/include/drm/DrmMetadata.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DRM_METADATA_H__ -#define __DRM_METADATA_H__ - -#include "drm_framework_common.h" - -namespace android { - -/** - * This is an utility class which contains the constraints information. - * - * As a result of DrmManagerClient::getMetadata(const String8*) - * an instance of DrmMetadata would be returned. - */ -class DrmMetadata { -public: - /** - * Iterator for key - */ - class KeyIterator { - friend class DrmMetadata; - private: - KeyIterator(DrmMetadata* drmMetadata) : mDrmMetadata(drmMetadata), mIndex(0) {} - - public: - KeyIterator(const KeyIterator& keyIterator); - KeyIterator& operator=(const KeyIterator& keyIterator); - virtual ~KeyIterator() {} - - public: - bool hasNext(); - const String8& next(); - - private: - DrmMetadata* mDrmMetadata; - unsigned int mIndex; - }; - - /** - * Iterator for constraints - */ - class Iterator { - friend class DrmMetadata; - private: - Iterator(DrmMetadata* drmMetadata) : mDrmMetadata(drmMetadata), mIndex(0) {} - - public: - Iterator(const Iterator& iterator); - Iterator& operator=(const Iterator& iterator); - virtual ~Iterator() {} - - public: - bool hasNext(); - String8 next(); - - private: - DrmMetadata* mDrmMetadata; - unsigned int mIndex; - }; - -public: - DrmMetadata() {} - virtual ~DrmMetadata() { - DrmMetadata::KeyIterator keyIt = this->keyIterator(); - - while (keyIt.hasNext()) { - String8 key = keyIt.next(); - const char* value = this->getAsByteArray(&key); - if (NULL != value) { - delete[] value; - value = NULL; - } - } - mMetadataMap.clear(); - } - -public: - int getCount(void) const; - status_t put(const String8* key, const char* value); - String8 get(const String8& key) const; - const char* getAsByteArray(const String8* key) const; - KeyIterator keyIterator(); - Iterator iterator(); - -private: - const char* getValue(const String8* key) const; - -private: - typedef KeyedVector<String8, const char*> DrmMetadataMap; - DrmMetadataMap mMetadataMap; -}; - -}; - -#endif /* __DRM_METADATA_H__ */ - diff --git a/include/drm/DrmRights.h b/include/drm/DrmRights.h deleted file mode 100644 index 11f8f78..0000000 --- a/include/drm/DrmRights.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DRM_RIGHTS_H__ -#define __DRM_RIGHTS_H__ - -#include "drm_framework_common.h" - -namespace android { - -/** - * This is an utility class which wraps the license information which was - * retrieved from the online DRM server. - * - * Caller can instantiate DrmRights by invoking DrmRights(const DrmBuffer&, String) - * constructor by using the result of DrmManagerClient::ProcessDrmInfo(const DrmInfo*) API. - * Caller can also instantiate DrmRights using the file path which contains rights information. - * - */ -class DrmRights { -public: - /** - * Constructor for DrmRights - * - * @param[in] rightsFilePath Path of the file containing rights data - * @param[in] mimeType MIME type - * @param[in] accountId Account Id of the user - * @param[in] subscriptionId Subscription Id of the user - */ - DrmRights( - const String8& rightsFilePath, const String8& mimeType, - const String8& accountId = String8("_NO_USER"), - const String8& subscriptionId = String8("")); - - /** - * Constructor for DrmRights - * - * @param[in] rightsData Rights data - * @param[in] mimeType MIME type - * @param[in] accountId Account Id of the user - * @param[in] subscriptionId Subscription Id of the user - */ - DrmRights( - const DrmBuffer& rightsData, const String8& mimeType, - const String8& accountId = String8("_NO_USER"), - const String8& subscriptionId = String8("")); - - /** - * Destructor for DrmRights - */ - virtual ~DrmRights(); - -public: - /** - * Returns the rights data associated with this instance - * - * @return Rights data - */ - const DrmBuffer& getData(void) const; - - /** - * Returns MIME type associated with this instance - * - * @return MIME type - */ - String8 getMimeType(void) const; - - /** - * Returns the account-id associated with this instance - * - * @return Account Id - */ - String8 getAccountId(void) const; - - /** - * Returns the subscription-id associated with this object - * - * @return Subscription Id - */ - String8 getSubscriptionId(void) const; - -private: - DrmBuffer mData; - String8 mMimeType; - String8 mAccountId; - String8 mSubscriptionId; - char* mRightsFromFile; -}; - -}; - -#endif /* __DRM_RIGHTS_H__ */ - diff --git a/include/drm/DrmSupportInfo.h b/include/drm/DrmSupportInfo.h deleted file mode 100644 index bf12b0b..0000000 --- a/include/drm/DrmSupportInfo.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DRM_SUPPORT_INFO_H__ -#define __DRM_SUPPORT_INFO_H__ - -#include "drm_framework_common.h" - -namespace android { - -/** - * This is an utility class which wraps the capability of each plug-in, - * such as mimetype's and file suffixes it could handle. - * - * Plug-in developer could return the capability of the plugin by passing - * DrmSupportInfo instance. - * - */ -class DrmSupportInfo { -public: - /** - * Iterator for mMimeTypeVector - */ - class MimeTypeIterator { - friend class DrmSupportInfo; - private: - MimeTypeIterator(DrmSupportInfo* drmSupportInfo) - : mDrmSupportInfo(drmSupportInfo), mIndex(0) {} - public: - MimeTypeIterator(const MimeTypeIterator& iterator); - MimeTypeIterator& operator=(const MimeTypeIterator& iterator); - virtual ~MimeTypeIterator() {} - - public: - bool hasNext(); - String8& next(); - - private: - DrmSupportInfo* mDrmSupportInfo; - unsigned int mIndex; - }; - - /** - * Iterator for mFileSuffixVector - */ - class FileSuffixIterator { - friend class DrmSupportInfo; - - private: - FileSuffixIterator(DrmSupportInfo* drmSupportInfo) - : mDrmSupportInfo(drmSupportInfo), mIndex(0) {} - public: - FileSuffixIterator(const FileSuffixIterator& iterator); - FileSuffixIterator& operator=(const FileSuffixIterator& iterator); - virtual ~FileSuffixIterator() {} - - public: - bool hasNext(); - String8& next(); - - private: - DrmSupportInfo* mDrmSupportInfo; - unsigned int mIndex; - }; - -public: - /** - * Constructor for DrmSupportInfo - */ - DrmSupportInfo(); - - /** - * Copy constructor for DrmSupportInfo - */ - DrmSupportInfo(const DrmSupportInfo& drmSupportInfo); - - /** - * Destructor for DrmSupportInfo - */ - virtual ~DrmSupportInfo() {} - - DrmSupportInfo& operator=(const DrmSupportInfo& drmSupportInfo); - bool operator<(const DrmSupportInfo& drmSupportInfo) const; - bool operator==(const DrmSupportInfo& drmSupportInfo) const; - - /** - * Returns FileSuffixIterator object to walk through file suffix values - * associated with this instance - * - * @return FileSuffixIterator object - */ - FileSuffixIterator getFileSuffixIterator(); - - /** - * Returns MimeTypeIterator object to walk through mimetype values - * associated with this instance - * - * @return MimeTypeIterator object - */ - MimeTypeIterator getMimeTypeIterator(); - -public: - /** - * Returns the number of mimetypes supported. - * - * @return Number of mimetypes supported - */ - int getMimeTypeCount(void) const; - - /** - * Returns the number of file types supported. - * - * @return Number of file types supported - */ - int getFileSuffixCount(void) const; - - /** - * Adds the mimetype to the list of supported mimetypes - * - * @param[in] mimeType mimetype to be added - * @return Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t addMimeType(const String8& mimeType); - - /** - * Adds the filesuffix to the list of supported file types - * - * @param[in] filesuffix file suffix to be added - * @return Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t addFileSuffix(const String8& fileSuffix); - - /** - * Set the unique description about the plugin - * - * @param[in] description Unique description - * @return Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure - */ - status_t setDescription(const String8& description); - - /** - * Returns the unique description associated with the plugin - * - * @return Unique description - */ - String8 getDescription() const; - - /** - * Returns whether given mimetype is supported or not - * - * @param[in] mimeType MIME type - * @return - * true - if mime-type is supported - * false - if mime-type is not supported - */ - bool isSupportedMimeType(const String8& mimeType) const; - - /** - * Returns whether given file type is supported or not - * - * @param[in] fileType File type - * @return - * true if file type is supported - * false if file type is not supported - */ - bool isSupportedFileSuffix(const String8& fileType) const; - -private: - Vector<String8> mMimeTypeVector; - Vector<String8> mFileSuffixVector; - - String8 mDescription; -}; - -}; - -#endif /* __DRM_SUPPORT_INFO_H__ */ - diff --git a/include/drm/drm_framework_common.h b/include/drm/drm_framework_common.h deleted file mode 100644 index 637409c..0000000 --- a/include/drm/drm_framework_common.h +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DRM_FRAMEWORK_COMMON_H__ -#define __DRM_FRAMEWORK_COMMON_H__ - -#include <utils/Vector.h> -#include <utils/KeyedVector.h> -#include <utils/RefBase.h> -#include <utils/String8.h> -#include <utils/Errors.h> - -#define INVALID_VALUE -1 - -namespace android { - -/** - * Error code for DRM Frameowrk - */ -enum { - // The following constant values should be in sync with - // media/stagefright/MediaErrors.h - ERROR_BASE = -2000, - - DRM_ERROR_UNKNOWN = ERROR_BASE, - DRM_ERROR_NO_LICENSE = ERROR_BASE - 1, - DRM_ERROR_LICENSE_EXPIRED = ERROR_BASE - 2, - DRM_ERROR_SESSION_NOT_OPENED = ERROR_BASE - 3, - DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED = ERROR_BASE - 4, - DRM_ERROR_DECRYPT = ERROR_BASE - 5, - DRM_ERROR_CANNOT_HANDLE = ERROR_BASE - 6, - DRM_ERROR_TAMPER_DETECTED = ERROR_BASE - 7, - DRM_ERROR_NO_PERMISSION = ERROR_BASE - 8, - - DRM_NO_ERROR = NO_ERROR -}; - -/** - * copy control settings used in DecryptHandle::copyControlVector - */ -enum DrmCopyControl { - DRM_COPY_CONTROL_BASE = 1000, - // the key used to set the value for HDCP - // if the associated value is 1, then HDCP is required - // otherwise, HDCP is not required - DRM_COPY_CONTROL_HDCP = DRM_COPY_CONTROL_BASE -}; - -/** - * Defines DRM Buffer - */ -class DrmBuffer { -public: - char* data; - int length; - - DrmBuffer() : - data(NULL), - length(0) { - } - - DrmBuffer(char* dataBytes, int dataLength) : - data(dataBytes), - length(dataLength) { - } - -}; - -/** - * Defines detailed description of the action - */ -class ActionDescription { -public: - ActionDescription(int _outputType, int _configuration) : - outputType(_outputType), - configuration(_configuration) { - } - -public: - int outputType; /* BLUETOOTH , HDMI*/ - int configuration; /* RESOLUTION_720_480 , RECORDABLE etc.*/ -}; - -/** - * Defines constants related to DRM types - */ -class DrmObjectType { -private: - DrmObjectType(); - -public: - /** - * Field specifies the unknown type - */ - static const int UNKNOWN = 0x00; - /** - * Field specifies the protected content type - */ - static const int CONTENT = 0x01; - /** - * Field specifies the rights information - */ - static const int RIGHTS_OBJECT = 0x02; - /** - * Field specifies the trigger information - */ - static const int TRIGGER_OBJECT = 0x03; -}; - -/** - * Defines constants related to play back - */ -class Playback { -private: - Playback(); - -public: - /** - * Constant field signifies playback start - */ - static const int START = 0x00; - /** - * Constant field signifies playback stop - */ - static const int STOP = 0x01; - /** - * Constant field signifies playback paused - */ - static const int PAUSE = 0x02; - /** - * Constant field signifies playback resumed - */ - static const int RESUME = 0x03; -}; - -/** - * Defines actions that can be performed on protected content - */ -class Action { -private: - Action(); - -public: - /** - * Constant field signifies that the default action - */ - static const int DEFAULT = 0x00; - /** - * Constant field signifies that the content can be played - */ - static const int PLAY = 0x01; - /** - * Constant field signifies that the content can be set as ring tone - */ - static const int RINGTONE = 0x02; - /** - * Constant field signifies that the content can be transfered - */ - static const int TRANSFER = 0x03; - /** - * Constant field signifies that the content can be set as output - */ - static const int OUTPUT = 0x04; - /** - * Constant field signifies that preview is allowed - */ - static const int PREVIEW = 0x05; - /** - * Constant field signifies that the content can be executed - */ - static const int EXECUTE = 0x06; - /** - * Constant field signifies that the content can displayed - */ - static const int DISPLAY = 0x07; -}; - -/** - * Defines constants related to status of the rights - */ -class RightsStatus { -private: - RightsStatus(); - -public: - /** - * Constant field signifies that the rights are valid - */ - static const int RIGHTS_VALID = 0x00; - /** - * Constant field signifies that the rights are invalid - */ - static const int RIGHTS_INVALID = 0x01; - /** - * Constant field signifies that the rights are expired for the content - */ - static const int RIGHTS_EXPIRED = 0x02; - /** - * Constant field signifies that the rights are not acquired for the content - */ - static const int RIGHTS_NOT_ACQUIRED = 0x03; -}; - -/** - * Defines API set for decryption - */ -class DecryptApiType { -private: - DecryptApiType(); - -public: - /** - * Decrypt API set for non encrypted content - */ - static const int NON_ENCRYPTED = 0x00; - /** - * Decrypt API set for ES based DRM - */ - static const int ELEMENTARY_STREAM_BASED = 0x01; - /** - * POSIX based Decrypt API set for container based DRM - */ - static const int CONTAINER_BASED = 0x02; - /** - * Decrypt API for Widevine streams - */ - static const int WV_BASED = 0x3; -}; - -/** - * Defines decryption information - */ -class DecryptInfo { -public: - /** - * size of memory to be allocated to get the decrypted content. - */ - int decryptBufferLength; - /** - * reserved for future purpose - */ -}; - -/** - * Defines decryption handle - */ -class DecryptHandle : public RefBase { -public: - /** - * Decryption session Handle - */ - int decryptId; - /** - * Mimetype of the content to be used to select the media extractor - * For e.g., "video/mpeg" or "audio/mp3" - */ - String8 mimeType; - /** - * Defines which decryption pattern should be used to decrypt the given content - * DrmFramework provides two different set of decryption APIs. - * 1. Decrypt APIs for elementary stream based DRM - * (file format is not encrypted but ES is encrypted) - * e.g., Marlin DRM (MP4 file format), WM-DRM (asf file format) - * - * DecryptApiType::ELEMENTARY_STREAM_BASED - * Decryption API set for ES based DRM - * initializeDecryptUnit(), decrypt(), and finalizeDecryptUnit() - * 2. Decrypt APIs for container based DRM (file format itself is encrypted) - * e.g., OMA DRM (dcf file format) - * - * DecryptApiType::CONTAINER_BASED - * POSIX based Decryption API set for container based DRM - * pread() - */ - int decryptApiType; - /** - * Defines the status of the rights like - * RIGHTS_VALID, RIGHTS_INVALID, RIGHTS_EXPIRED or RIGHTS_NOT_ACQUIRED - */ - int status; - /** - * Information required to decrypt content - * e.g. size of memory to be allocated to get the decrypted content. - */ - DecryptInfo* decryptInfo; - /** - * Defines a vector for the copy control settings sent from the DRM plugin - * to the player - */ - KeyedVector<DrmCopyControl, int> copyControlVector; - - /** - * Defines a vector for any extra data the DRM plugin wants to send - * to the native code - */ - KeyedVector<String8, String8> extendedData; - -public: - DecryptHandle(): - decryptId(INVALID_VALUE), - mimeType(""), - decryptApiType(INVALID_VALUE), - status(INVALID_VALUE), - decryptInfo(NULL) { - - } - - ~DecryptHandle() { - delete decryptInfo; decryptInfo = NULL; - } - - bool operator<(const DecryptHandle& handle) const { - return (decryptId < handle.decryptId); - } - - bool operator==(const DecryptHandle& handle) const { - return (decryptId == handle.decryptId); - } -}; - -}; - -#endif /* __DRM_FRAMEWORK_COMMON_H__ */ - diff --git a/include/media/AudioEffect.h b/include/media/AudioEffect.h deleted file mode 100644 index 02dfc1b..0000000 --- a/include/media/AudioEffect.h +++ /dev/null @@ -1,459 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_AUDIOEFFECT_H -#define ANDROID_AUDIOEFFECT_H - -#include <stdint.h> -#include <sys/types.h> - -#include <media/IAudioFlinger.h> -#include <media/IAudioPolicyService.h> -#include <media/IEffect.h> -#include <media/IEffectClient.h> -#include <hardware/audio_effect.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 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(const effect_uuid_t *uuid, - effect_descriptor_t *descriptor) /*const*/; - - - /* - * Returns a list of descriptors corresponding to the pre processings enabled by default - * on an AudioRecord with the supplied audio session ID. - * - * Parameters: - * audioSession: audio session ID. - * descriptors: address where the effect descriptors should be returned. - * count: as input, the maximum number of descriptor than should be returned - * as output, the number of descriptor returned if status is NO_ERROR or the actual - * number of enabled pre processings if status is NO_MEMORY - * - * Returned status (from utils/Errors.h) can be: - * NO_ERROR successful operation. - * NO_MEMORY the number of descriptor to return is more than the maximum number - * indicated by count. - * PERMISSION_DENIED could not get AudioFlinger interface - * NO_INIT effect library failed to initialize - * BAD_VALUE invalid audio session or descriptor pointers - * - * Returned value - * *descriptor updated with descriptors of pre processings enabled by default - * *count number of descriptors returned if returned status is N_ERROR. - * total number of pre processing enabled by default if returned status is - * NO_MEMORY. This happens if the count passed as input is less than the number - * of descriptors to return - */ - static status_t queryDefaultPreProcessing(int audioSession, - effect_descriptor_t *descriptors, - uint32_t *count); - - /* - * 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. - * io: HAL audio output or input 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 = NULL, - void* user = NULL, - int sessionId = 0, - audio_io_handle_t io = 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 = NULL, - void* user = NULL, - int sessionId = 0, - audio_io_handle_t io = 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 = NULL, - void* user = NULL, - int sessionId = 0, - audio_io_handle_t io = 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 audio_effect.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 audio_effect.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 audio_effect.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 audio_effect.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 audio_effect.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: - bool 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 - Mutex mLock; // Mutex for mEnabled access - -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 diff --git a/include/media/AudioParameter.h b/include/media/AudioParameter.h deleted file mode 100644 index 79d5d82..0000000 --- a/include/media/AudioParameter.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2008-2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_AUDIOPARAMETER_H_ -#define ANDROID_AUDIOPARAMETER_H_ - -#include <utils/Errors.h> -#include <utils/KeyedVector.h> -#include <utils/String8.h> - -namespace android { - -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 audio_devices_t - // keySamplingRate: to change sampling rate routing, value is an int - // keyFormat: to change audio format, value is an int in audio_format_t - // keyChannels: to change audio channel configuration, value is an int in audio_channels_t - // keyFrameCount: to change audio output frame count, value is an int - // keyInputSource: to change audio input source, value is an int in audio_source_t - // (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_AUDIOPARAMETER_H_*/ diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h deleted file mode 100644 index 5bfb65b..0000000 --- a/include/media/AudioRecord.h +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef AUDIORECORD_H_ -#define AUDIORECORD_H_ - -#include <stdint.h> -#include <sys/types.h> - -#include <media/IAudioFlinger.h> -#include <media/IAudioRecord.h> - -#include <utils/RefBase.h> -#include <utils/Errors.h> -#include <binder/IInterface.h> -#include <binder/IMemory.h> -#include <utils/threads.h> - -#include <system/audio.h> - -namespace android { - -class audio_track_cblk_t; - -// ---------------------------------------------------------------------------- - -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; - audio_format_t 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, - audio_format_t 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 AUDIO_FORMAT_PCM_16_BIT for signed - * 16 bits per sample). - * channelMask: Channel mask: see audio_channels_t. - * 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. - */ - - // FIXME consider removing this alias and replacing it by audio_in_acoustics_t - // or removing the parameter entirely if it is unused - enum record_flags { - RECORD_AGC_ENABLE = AUDIO_IN_ACOUSTICS_AGC_ENABLE, - RECORD_NS_ENABLE = AUDIO_IN_ACOUSTICS_NS_ENABLE, - RECORD_IIR_ENABLE = AUDIO_IN_ACOUSTICS_TX_IIR_ENABLE, - }; - - AudioRecord(audio_source_t inputSource, - uint32_t sampleRate = 0, - audio_format_t format = AUDIO_FORMAT_DEFAULT, - uint32_t channelMask = AUDIO_CHANNEL_IN_MONO, - int frameCount = 0, - record_flags flags = (record_flags) 0, - callback_t cbf = NULL, - void* user = NULL, - 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(audio_source_t inputSource = AUDIO_SOURCE_DEFAULT, - uint32_t sampleRate = 0, - audio_format_t format = AUDIO_FORMAT_DEFAULT, - uint32_t channelMask = AUDIO_CHANNEL_IN_MONO, - int frameCount = 0, - record_flags flags = (record_flags) 0, - callback_t cbf = NULL, - void* user = NULL, - 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 */ - - audio_format_t format() const; - int channelCount() const; - int channels() const; - uint32_t frameCount() const; - size_t frameSize() const; - audio_source_t 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() const; - - /* 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) const; - - - /* 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) const; - - - /* 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) const; - - /* 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() const; - - /* returns the audio session ID associated to this AudioRecord. - * - * Parameters: - * none. - * - * Returned value: - * AudioRecord session ID. - */ - int getSessionId() const; - - /* 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 available, - * 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 obtainBuffer/releaseBuffer. - */ - 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() const; - -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(); - virtual void onFirstRef() {} - AudioRecord& mReceiver; - }; - - bool processAudioBuffer(const sp<ClientRecordThread>& thread); - status_t openRecord_l(uint32_t sampleRate, - audio_format_t format, - uint32_t channelMask, - int frameCount, - audio_io_handle_t input); - audio_io_handle_t getInput_l(); - status_t restoreRecord_l(audio_track_cblk_t*& cblk); - - sp<IAudioRecord> mAudioRecord; - sp<IMemory> mCblkMemory; - sp<ClientRecordThread> mClientRecordThread; - status_t mReadyToRun; - mutable Mutex mLock; - Condition mCondition; - - uint32_t mFrameCount; - - audio_track_cblk_t* mCblk; - audio_format_t mFormat; - uint8_t mChannelCount; - audio_source_t mInputSource; - 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; - record_flags mFlags; - uint32_t mChannelMask; - audio_io_handle_t mInput; - int mSessionId; - int mPreviousPriority; // before start() - int mPreviousSchedulingGroup; -}; - -}; // namespace android - -#endif /*AUDIORECORD_H_*/ diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h deleted file mode 100644 index cc0a594..0000000 --- a/include/media/AudioSystem.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_AUDIOSYSTEM_H_ -#define ANDROID_AUDIOSYSTEM_H_ - -#include <utils/RefBase.h> -#include <utils/threads.h> -#include <media/IAudioFlinger.h> - -#include <system/audio.h> -#include <system/audio_policy.h> - -/* XXX: Should be include by all the users instead */ -#include <media/AudioParameter.h> - -namespace android { - -typedef void (*audio_error_callback)(status_t err); - -class IAudioPolicyService; -class String8; - -class AudioSystem -{ -public: - - /* 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(audio_stream_type_t stream, float value, - audio_io_handle_t output); - static status_t getStreamVolume(audio_stream_type_t stream, float* volume, - audio_io_handle_t output); - - // mute/unmute stream - static status_t setStreamMute(audio_stream_type_t stream, bool mute); - static status_t getStreamMute(audio_stream_type_t stream, bool* mute); - - // set audio mode in audio hardware - static status_t setMode(audio_mode_t mode); - - // returns true in *state if tracks are active on the specified stream or has been active - // in the past inPastMs milliseconds - static status_t isStreamActive(audio_stream_type_t stream, bool *state, uint32_t inPastMs = 0); - - // 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, audio_stream_type_t stream = AUDIO_STREAM_DEFAULT); - static status_t getOutputFrameCount(int* frameCount, audio_stream_type_t stream = AUDIO_STREAM_DEFAULT); - static status_t getOutputLatency(uint32_t* latency, audio_stream_type_t stream = AUDIO_STREAM_DEFAULT); - - // DEPRECATED - static status_t getOutputSamplingRate(int* samplingRate, int stream = AUDIO_STREAM_DEFAULT); - - // DEPRECATED - static status_t getOutputFrameCount(int* frameCount, int stream = AUDIO_STREAM_DEFAULT); - - static bool routedToA2dpOutput(audio_stream_type_t streamType); - - static status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount, - size_t* buffSize); - - static status_t setVoiceVolume(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 specified 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, audio_stream_type_t stream = AUDIO_STREAM_DEFAULT); - - static unsigned int getInputFramesLost(audio_io_handle_t ioHandle); - - static int newAudioSessionId(); - static void acquireAudioSessionId(int audioSession); - static void releaseAudioSessionId(int audioSession); - - // 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, - NUM_CONFIG_EVENTS - }; - - // audio output descriptor used to cache output configurations in client process to avoid frequent calls - // through IAudioFlinger - class OutputDescriptor { - public: - OutputDescriptor() - : samplingRate(0), format(AUDIO_FORMAT_DEFAULT), 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_t device, audio_policy_dev_state_t state, const char *device_address); - static audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, const char *device_address); - static status_t setPhoneState(audio_mode_t state); - static status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); - static audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage); - static audio_io_handle_t getOutput(audio_stream_type_t stream, - uint32_t samplingRate = 0, - audio_format_t format = AUDIO_FORMAT_DEFAULT, - uint32_t channels = AUDIO_CHANNEL_OUT_STEREO, - audio_policy_output_flags_t flags = AUDIO_POLICY_OUTPUT_FLAG_NONE); - static status_t startOutput(audio_io_handle_t output, - audio_stream_type_t stream, - int session = 0); - static status_t stopOutput(audio_io_handle_t output, - audio_stream_type_t stream, - int session = 0); - static void releaseOutput(audio_io_handle_t output); - static audio_io_handle_t getInput(audio_source_t inputSource, - uint32_t samplingRate = 0, - audio_format_t format = AUDIO_FORMAT_DEFAULT, - uint32_t channels = AUDIO_CHANNEL_IN_MONO, - audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0, - int sessionId = 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(audio_stream_type_t stream, - int indexMin, - int indexMax); - static status_t setStreamVolumeIndex(audio_stream_type_t stream, - int index, - audio_devices_t device); - static status_t getStreamVolumeIndex(audio_stream_type_t stream, - int *index, - audio_devices_t device); - - static uint32_t getStrategyForStream(audio_stream_type_t stream); - static audio_devices_t getDevicesForStream(audio_stream_type_t stream); - - static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc); - static status_t registerEffect(effect_descriptor_t *desc, - audio_io_handle_t io, - uint32_t strategy, - int session, - int id); - static status_t unregisterEffect(int id); - static status_t setEffectEnabled(int id, bool enabled); - - // clear stream to output mapping cache (gStreamOutputMap) - // and output configuration cache (gOutputs) - static void clearAudioConfigCache(); - - static const sp<IAudioPolicyService>& get_audio_policy_service(); - - // ---------------------------------------------------------------------------- - -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 up-to-date in client process - virtual void ioConfigChanged(int event, audio_io_handle_t ioHandle, const 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 audio_format_t gPrevInFormat; - static int gPrevInChannelCount; - - static sp<IAudioPolicyService> gAudioPolicyService; - - // mapping between stream types and outputs - static DefaultKeyedVector<audio_stream_type_t, audio_io_handle_t> gStreamOutputMap; - // list of output descriptors containing cached parameters - // (sampling rate, framecount, channel count...) - static DefaultKeyedVector<audio_io_handle_t, OutputDescriptor *> gOutputs; -}; - -}; // namespace android - -#endif /*ANDROID_AUDIOSYSTEM_H_*/ diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h deleted file mode 100644 index 7d5d772..0000000 --- a/include/media/AudioTrack.h +++ /dev/null @@ -1,553 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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 : virtual public RefBase -{ -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. - }; - - /* Client should declare Buffer on the stack and pass address to obtainBuffer() - * and releaseBuffer(). See also callback_t for EVENT_MORE_DATA. - */ - - class Buffer - { - public: - enum { - MUTE = 0x00000001 - }; - uint32_t flags; // 0 or MUTE - audio_format_t format; // but AUDIO_FORMAT_PCM_8_BIT -> AUDIO_FORMAT_PCM_16_BIT - // accessed directly by WebKit ANP callback - int channelCount; // will be removed in the future, do not use - - size_t frameCount; // number of sample frames corresponding to size; - // on input it is the number of frames desired, - // on output is the number of frames actually filled - - size_t size; // input/output in byte units - union { - void* raw; - short* i16; // signed 16-bit - int8_t* i8; // unsigned 8-bit, offset by 0x80 - }; - }; - - - /* 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 available or various conditions occur. - * 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 fewer bytes are - * written. - * - EVENT_UNDERRUN: unused. - * - EVENT_LOOP_END: pointer to an int indicating the number of loops remaining. - * - EVENT_MARKER: pointer to an uint32_t containing the marker position in frames. - * - EVENT_NEW_POS: pointer to an uint32_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, - audio_stream_type_t streamType = AUDIO_STREAM_DEFAULT, - 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. AUDIO_STREAM_MUSIC). - * sampleRate: Track sampling rate in Hz. - * format: Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed - * 16 bits per sample). - * channelMask: Channel mask: see audio_channels_t. - * frameCount: Minimum size of track PCM buffer in frames. This defines the - * latency of the track. The actual size selected by the AudioTrack could be - * larger if the requested size is not compatible with current audio HAL - * latency. - * flags: Reserved for future use. - * cbf: Callback function. If not null, this function is called periodically - * to request new PCM data. - * user: Context for use by the callback receiver. - * notificationFrames: The callback function is called each time notificationFrames PCM - * frames have been consumed from track input buffer. - * sessionId: Specific session ID, or zero to use default. - */ - - AudioTrack( audio_stream_type_t streamType, - uint32_t sampleRate = 0, - audio_format_t format = AUDIO_FORMAT_DEFAULT, - int channelMask = 0, - int frameCount = 0, - audio_policy_output_flags_t flags = AUDIO_POLICY_OUTPUT_FLAG_NONE, - callback_t cbf = NULL, - void* user = NULL, - int notificationFrames = 0, - int sessionId = 0); - - // DEPRECATED - explicit AudioTrack( int streamType, - uint32_t sampleRate = 0, - int format = AUDIO_FORMAT_DEFAULT, - int channelMask = 0, - int frameCount = 0, - uint32_t flags = (uint32_t) AUDIO_POLICY_OUTPUT_FLAG_NONE, - 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 in memory before the AudioTrack is started. - * The write() and flush() methods are not supported in this case. - * It is recommended to pass a callback function to be notified of playback end by an - * EVENT_UNDERRUN event. - */ - - AudioTrack( audio_stream_type_t streamType, - uint32_t sampleRate = 0, - audio_format_t format = AUDIO_FORMAT_DEFAULT, - int channelMask = 0, - const sp<IMemory>& sharedBuffer = 0, - audio_policy_output_flags_t flags = AUDIO_POLICY_OUTPUT_FLAG_NONE, - callback_t cbf = NULL, - void* user = NULL, - int notificationFrames = 0, - int sessionId = 0); - - /* Terminates the AudioTrack and unregisters it from AudioFlinger. - * Also destroys all resources associated with the AudioTrack. - */ - ~AudioTrack(); - - - /* Initialize an uninitialized AudioTrack. - * Returned status (from utils/Errors.h) can be: - * - NO_ERROR: successful initialization - * - INVALID_OPERATION: AudioTrack is already initialized - * - BAD_VALUE: invalid parameter (channels, format, sampleRate...) - * - NO_INIT: audio server or audio hardware not initialized - * */ - status_t set(audio_stream_type_t streamType = AUDIO_STREAM_DEFAULT, - uint32_t sampleRate = 0, - audio_format_t format = AUDIO_FORMAT_DEFAULT, - int channelMask = 0, - int frameCount = 0, - audio_policy_output_flags_t flags = AUDIO_POLICY_OUTPUT_FLAG_NONE, - callback_t cbf = NULL, - void* user = NULL, - int notificationFrames = 0, - const sp<IMemory>& sharedBuffer = 0, - bool threadCanCallJava = false, - int sessionId = 0); - - - /* Result of constructing the AudioTrack. This must be checked - * before using any AudioTrack API (except for set()), because using - * an uninitialized AudioTrack produces undefined results. - * See set() method above for possible return codes. - */ - status_t initCheck() const; - - /* Returns this track's estimated 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 constructors and set() */ - - audio_stream_type_t streamType() const; - audio_format_t format() const; - int channelCount() const; - uint32_t frameCount() const; - - /* Return channelCount * (bit depth per channel / 8). - * channelCount is determined from channelMask, and bit depth comes from format. - */ - size_t 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 stopped. - */ - 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 unmute this track. - * While muted, 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 >= 0.0 and <= 1.0. - */ - status_t setVolume(float left, float right); - void getVolume(float* left, float* right) const; - - /* Set the send level for this track. An auxiliary effect should be attached - * to the track with attachEffect(). Level must be >= 0.0 and <= 1.0. - */ - status_t setAuxEffectSendLevel(float level); - void getAuxEffectSendLevel(float* level) const; - - /* Set sample rate for this track, mostly used for games' sound effects - */ - status_t setSampleRate(int sampleRate); - uint32_t getSampleRate() const; - - /* 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); - - /* 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) const; - - - /* 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) const; - - /* 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 session ID associated with this track. - * - * Parameters: - * none. - * - * Returned value: - * AudioTrack session ID. - */ - int getSessionId() const; - - /* Attach track auxiliary output to specified effect. Use 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, and then released with releaseBuffer(). - * If the track is stopped, obtainBuffer() returns - * STOPPED instead of NO_ERROR as long as there are buffers available, - * 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. - * - * Interpretation of waitCount: - * +n limits wait time to n * WAIT_PERIOD_MS, - * -1 causes an (almost) infinite wait time, - * 0 non-blocking. - */ - - enum { - NO_MORE_BUFFERS = 0x80000001, // same name in AudioFlinger.h, ok to be different value - STOPPED = 1 - }; - - status_t obtainBuffer(Buffer* audioBuffer, int32_t waitCount); - - /* Release a filled buffer of "frameCount" frames for AudioFlinger to process. */ - void releaseBuffer(Buffer* audioBuffer); - - /* As a convenience we provide a write() interface to the audio buffer. - * This is implemented on top of obtainBuffer/releaseBuffer. For best - * performance use callbacks. Returns actual number of bytes written >= 0, - * or one of the following negative status codes: - * INVALID_OPERATION AudioTrack is configured for shared buffer mode - * BAD_VALUE size is invalid - * STOPPED AudioTrack was stopped during the write - * NO_MORE_BUFFERS when obtainBuffer() returns same - * or any other error code returned by IAudioTrack::start() or restoreTrack_l(). - */ - 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; - -protected: - /* 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; - }; - - // body of AudioTrackThread::threadLoop() - bool processAudioBuffer(const sp<AudioTrackThread>& thread); - - status_t createTrack_l(audio_stream_type_t streamType, - uint32_t sampleRate, - audio_format_t format, - uint32_t channelMask, - int frameCount, - audio_policy_output_flags_t flags, - const sp<IMemory>& sharedBuffer, - audio_io_handle_t output); - void flush_l(); - status_t setLoop_l(uint32_t loopStart, uint32_t loopEnd, int loopCount); - audio_io_handle_t getOutput_l(); - status_t restoreTrack_l(audio_track_cblk_t*& cblk, bool fromStart); - bool stopped_l() const { return !mActive; } - - sp<IAudioTrack> mAudioTrack; - sp<IMemory> mCblkMemory; - sp<AudioTrackThread> mAudioTrackThread; - - float mVolume[2]; - float mSendLevel; - uint32_t mFrameCount; - - audio_track_cblk_t* mCblk; - audio_format_t mFormat; - audio_stream_type_t mStreamType; - uint8_t mChannelCount; - uint8_t mMuted; - uint8_t mReserved; - uint32_t mChannelMask; - status_t mStatus; - uint32_t mLatency; - - bool mActive; // protected by mLock - - callback_t mCbf; // callback handler for events, or NULL - 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; - bool mFlushed; // FIXME will be made obsolete by making flush() synchronous - audio_policy_output_flags_t mFlags; - int mSessionId; - int mAuxEffectId; - mutable Mutex mLock; - status_t mRestoreStatus; - bool mIsTimed; - int mPreviousPriority; // before start() - int mPreviousSchedulingGroup; -}; - -class TimedAudioTrack : public AudioTrack -{ -public: - TimedAudioTrack(); - - /* allocate a shared memory buffer that can be passed to queueTimedBuffer */ - status_t allocateTimedBuffer(size_t size, sp<IMemory>* buffer); - - /* queue a buffer obtained via allocateTimedBuffer for playback at the - given timestamp. PTS units a microseconds on the media time timeline. - The media time transform (set with setMediaTimeTransform) set by the - audio producer will handle converting from media time to local time - (perhaps going through the common time timeline in the case of - synchronized multiroom audio case) */ - status_t queueTimedBuffer(const sp<IMemory>& buffer, int64_t pts); - - /* define a transform between media time and either common time or - local time */ - enum TargetTimeline {LOCAL_TIME, COMMON_TIME}; - status_t setMediaTimeTransform(const LinearTransform& xform, - TargetTimeline target); -}; - -}; // namespace android - -#endif // ANDROID_AUDIOTRACK_H diff --git a/include/media/EffectsFactoryApi.h b/include/media/EffectsFactoryApi.h deleted file mode 100644 index 65c26f4..0000000 --- a/include/media/EffectsFactoryApi.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_EFFECTSFACTORYAPI_H_ -#define ANDROID_EFFECTSFACTORYAPI_H_ - -#include <errno.h> -#include <stdint.h> -#include <sys/types.h> -#include <hardware/audio_effect.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 handle 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: -// pHandle: address where to return the effect handle. -// -// Output: -// returned value: 0 successful operation. -// -ENODEV factory failed to initialize -// -EINVAL invalid pEffectUuid or pHandle -// -ENOENT no effect with this uuid found -// *pHandle: updated with the effect handle. -// -//////////////////////////////////////////////////////////////////////////////// -int EffectCreate(const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle); - -//////////////////////////////////////////////////////////////////////////////// -// -// 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: -// handle: handle on the effect interface to be released. -// -// Output: -// returned value: 0 successful operation. -// -ENODEV factory failed to initialize -// -EINVAL invalid interface handle -// -//////////////////////////////////////////////////////////////////////////////// -int EffectRelease(effect_handle_t 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(const 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(const effect_uuid_t *pEffectUuid); - -#if __cplusplus -} // extern "C" -#endif - - -#endif /*ANDROID_EFFECTSFACTORYAPI_H_*/ diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h deleted file mode 100644 index 8239b0e..0000000 --- a/include/media/IAudioFlinger.h +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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 <system/audio.h> -#include <system/audio_policy.h> -#include <hardware/audio_effect.h> -#include <media/IEffect.h> -#include <media/IEffectClient.h> -#include <utils/String8.h> - -namespace android { - -// ---------------------------------------------------------------------------- - -class IAudioFlinger : public IInterface -{ -public: - DECLARE_META_INTERFACE(AudioFlinger); - - // or-able bits shared by createTrack and openRecord, but not all combinations make sense - enum { - TRACK_DEFAULT = 0, // client requests a default AudioTrack - TRACK_TIMED = 1, // client requests a TimedAudioTrack - TRACK_FAST = 2, // client requests a fast AudioTrack - }; - typedef uint32_t track_flags_t; - - /* create an audio track and registers it with AudioFlinger. - * return null if the track cannot be created. - */ - virtual sp<IAudioTrack> createTrack( - pid_t pid, - audio_stream_type_t streamType, - uint32_t sampleRate, - audio_format_t format, - uint32_t channelMask, - int frameCount, - track_flags_t flags, - const sp<IMemory>& sharedBuffer, - audio_io_handle_t output, - int *sessionId, - status_t *status) = 0; - - virtual sp<IAudioRecord> openRecord( - pid_t pid, - audio_io_handle_t input, - uint32_t sampleRate, - audio_format_t format, - uint32_t channelMask, - int frameCount, - track_flags_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(audio_io_handle_t output) const = 0; - virtual int channelCount(audio_io_handle_t output) const = 0; - virtual audio_format_t format(audio_io_handle_t output) const = 0; - virtual size_t frameCount(audio_io_handle_t output) const = 0; - - // return estimated latency in milliseconds - virtual uint32_t latency(audio_io_handle_t 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(audio_stream_type_t stream, float value, - audio_io_handle_t output) = 0; - virtual status_t setStreamMute(audio_stream_type_t stream, bool muted) = 0; - - virtual float streamVolume(audio_stream_type_t stream, - audio_io_handle_t output) const = 0; - virtual bool streamMute(audio_stream_type_t stream) const = 0; - - // set audio mode - virtual status_t setMode(audio_mode_t mode) = 0; - - // mic mute/state - virtual status_t setMicMute(bool state) = 0; - virtual bool getMicMute() const = 0; - - virtual status_t setParameters(audio_io_handle_t ioHandle, - const String8& keyValuePairs) = 0; - virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const = 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, audio_format_t format, int channelCount) const = 0; - - virtual audio_io_handle_t openOutput(uint32_t *pDevices, - uint32_t *pSamplingRate, - audio_format_t *pFormat, - uint32_t *pChannels, - uint32_t *pLatencyMs, - audio_policy_output_flags_t flags) = 0; - virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1, - audio_io_handle_t output2) = 0; - virtual status_t closeOutput(audio_io_handle_t output) = 0; - virtual status_t suspendOutput(audio_io_handle_t output) = 0; - virtual status_t restoreOutput(audio_io_handle_t output) = 0; - - virtual audio_io_handle_t openInput(uint32_t *pDevices, - uint32_t *pSamplingRate, - audio_format_t *pFormat, - uint32_t *pChannels, - audio_in_acoustics_t acoustics) = 0; - virtual status_t closeInput(audio_io_handle_t input) = 0; - - virtual status_t setStreamOutput(audio_stream_type_t stream, audio_io_handle_t output) = 0; - - virtual status_t setVoiceVolume(float volume) = 0; - - virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, - audio_io_handle_t output) const = 0; - - virtual unsigned int getInputFramesLost(audio_io_handle_t ioHandle) const = 0; - - virtual int newAudioSessionId() = 0; - - virtual void acquireAudioSessionId(int audioSession) = 0; - virtual void releaseAudioSessionId(int audioSession) = 0; - - virtual status_t queryNumberEffects(uint32_t *numEffects) const = 0; - - virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const = 0; - - virtual status_t getEffectDescriptor(const effect_uuid_t *pEffectUUID, - effect_descriptor_t *pDescriptor) const = 0; - - virtual sp<IEffect> createEffect(pid_t pid, - effect_descriptor_t *pDesc, - const sp<IEffectClient>& client, - int32_t priority, - audio_io_handle_t output, - int sessionId, - status_t *status, - int *id, - int *enabled) = 0; - - virtual status_t moveEffects(int session, audio_io_handle_t srcOutput, - audio_io_handle_t dstOutput) = 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 diff --git a/include/media/IAudioFlingerClient.h b/include/media/IAudioFlingerClient.h deleted file mode 100644 index 75a9971..0000000 --- a/include/media/IAudioFlingerClient.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_IAUDIOFLINGERCLIENT_H -#define ANDROID_IAUDIOFLINGERCLIENT_H - - -#include <utils/RefBase.h> -#include <binder/IInterface.h> -#include <utils/KeyedVector.h> -#include <system/audio.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, audio_io_handle_t ioHandle, const 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 diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h deleted file mode 100644 index 04c927a..0000000 --- a/include/media/IAudioPolicyService.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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> - -#include <system/audio_policy.h> - -namespace android { - -// ---------------------------------------------------------------------------- - -class IAudioPolicyService : public IInterface -{ -public: - DECLARE_META_INTERFACE(AudioPolicyService); - - // - // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions) - // - virtual status_t setDeviceConnectionState(audio_devices_t device, - audio_policy_dev_state_t state, - const char *device_address) = 0; - virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, - const char *device_address) = 0; - virtual status_t setPhoneState(audio_mode_t state) = 0; - virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) = 0; - virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) = 0; - virtual audio_io_handle_t getOutput(audio_stream_type_t stream, - uint32_t samplingRate = 0, - audio_format_t format = AUDIO_FORMAT_DEFAULT, - uint32_t channels = 0, - audio_policy_output_flags_t flags = AUDIO_POLICY_OUTPUT_FLAG_NONE) = 0; - virtual status_t startOutput(audio_io_handle_t output, - audio_stream_type_t stream, - int session = 0) = 0; - virtual status_t stopOutput(audio_io_handle_t output, - audio_stream_type_t stream, - int session = 0) = 0; - virtual void releaseOutput(audio_io_handle_t output) = 0; - virtual audio_io_handle_t getInput(audio_source_t inputSource, - uint32_t samplingRate = 0, - audio_format_t format = AUDIO_FORMAT_DEFAULT, - uint32_t channels = 0, - audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0, - int audioSession = 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(audio_stream_type_t stream, - int indexMin, - int indexMax) = 0; - virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, - int index, - audio_devices_t device) = 0; - virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, - int *index, - audio_devices_t device) = 0; - virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0; - virtual audio_devices_t getDevicesForStream(audio_stream_type_t 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 io, - uint32_t strategy, - int session, - int id) = 0; - virtual status_t unregisterEffect(int id) = 0; - virtual status_t setEffectEnabled(int id, bool enabled) = 0; - virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0; - virtual status_t queryDefaultPreProcessing(int audioSession, - effect_descriptor_t *descriptors, - uint32_t *count) = 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 diff --git a/include/media/IAudioRecord.h b/include/media/IAudioRecord.h deleted file mode 100644 index 089be3b..0000000 --- a/include/media/IAudioRecord.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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. - * tid identifies the client callback thread, or 0 if not needed. - */ - virtual status_t start(pid_t tid) = 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_*/ diff --git a/include/media/IAudioTrack.h b/include/media/IAudioTrack.h deleted file mode 100644 index 577b095..0000000 --- a/include/media/IAudioTrack.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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> -#include <utils/LinearTransform.h> - -namespace android { - -// ---------------------------------------------------------------------------- - -class IAudioTrack : public IInterface -{ -public: - DECLARE_META_INTERFACE(AudioTrack); - - /* Get this track's control block */ - virtual sp<IMemory> getCblk() const = 0; - - /* After it's created the track is not active. Call start() to - * make it active. If set, the callback will start being called. - * tid identifies the client callback thread, or 0 if not needed. - */ - virtual status_t start(pid_t tid) = 0; - - /* Stop a track. If set, the callback will cease being called and - * obtainBuffer will return an error. Buffers that are already released - * will continue to be processed, unless/until flush() is called. - */ - virtual void stop() = 0; - - /* Flush a stopped or paused track. All pending/released buffers are discarded. - * This function has no effect if the track is not stopped or paused. - */ - virtual void flush() = 0; - - /* Mute or unmute this track. - * While muted, 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 continue to be processed, unless/until 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; - - - /* Allocate a shared memory buffer suitable for holding timed audio - samples */ - virtual status_t allocateTimedBuffer(size_t size, - sp<IMemory>* buffer) = 0; - - /* Queue a buffer obtained via allocateTimedBuffer for playback at the given - timestamp */ - virtual status_t queueTimedBuffer(const sp<IMemory>& buffer, - int64_t pts) = 0; - - /* Define the linear transform that will be applied to the timestamps - given to queueTimedBuffer (which are expressed in media time). - Target specifies whether this transform converts media time to local time - or Tungsten time. The values for target are defined in AudioTrack.h */ - virtual status_t setMediaTimeTransform(const LinearTransform& xform, - int target) = 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 diff --git a/include/media/ICrypto.h b/include/media/ICrypto.h deleted file mode 100644 index 916abe0..0000000 --- a/include/media/ICrypto.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <binder/IInterface.h> -#include <media/stagefright/foundation/ABase.h> - -#ifndef ANDROID_ICRYPTO_H_ - -#define ANDROID_ICRYPTO_H_ - -namespace android { - -struct ICrypto : public IInterface { - DECLARE_META_INTERFACE(Crypto); - - virtual status_t initialize() = 0; - virtual status_t terminate() = 0; - - virtual status_t setEntitlementKey( - const void *key, size_t keyLength) = 0; - - virtual status_t setEntitlementControlMessage( - const void *msg, size_t msgLength) = 0; - - // "dstData" is in media_server's address space (but inaccessible). - virtual ssize_t decryptVideo( - const void *iv, size_t ivLength, - const void *srcData, size_t srcDataSize, - void *dstData, size_t dstDataOffset) = 0; - - // "dstData" is in the calling process' address space. - virtual ssize_t decryptAudio( - const void *iv, size_t ivLength, - const void *srcData, size_t srcDataSize, - void *dstData, size_t dstDataSize) = 0; - -private: - DISALLOW_EVIL_CONSTRUCTORS(ICrypto); -}; - -struct BnCrypto : public BnInterface<ICrypto> { - virtual status_t onTransact( - uint32_t code, const Parcel &data, Parcel *reply, - uint32_t flags = 0); -}; - -} // namespace android - -#endif // ANDROID_ICRYPTO_H_ - diff --git a/include/media/IEffect.h b/include/media/IEffect.h deleted file mode 100644 index ff04869..0000000 --- a/include/media/IEffect.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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 diff --git a/include/media/IEffectClient.h b/include/media/IEffectClient.h deleted file mode 100644 index 2f78c98..0000000 --- a/include/media/IEffectClient.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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 diff --git a/include/media/IMediaDeathNotifier.h b/include/media/IMediaDeathNotifier.h deleted file mode 100644 index bb3d0d8..0000000 --- a/include/media/IMediaDeathNotifier.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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 diff --git a/include/media/IMediaMetadataRetriever.h b/include/media/IMediaMetadataRetriever.h deleted file mode 100644 index 6dbb2d7..0000000 --- a/include/media/IMediaMetadataRetriever.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -** -** Copyright (C) 2008 The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -#ifndef ANDROID_IMEDIAMETADATARETRIEVER_H -#define ANDROID_IMEDIAMETADATARETRIEVER_H - -#include <binder/IInterface.h> -#include <binder/Parcel.h> -#include <binder/IMemory.h> -#include <utils/KeyedVector.h> -#include <utils/RefBase.h> - -namespace android { - -class IMediaMetadataRetriever: public IInterface -{ -public: - DECLARE_META_INTERFACE(MediaMetadataRetriever); - virtual void disconnect() = 0; - - virtual status_t setDataSource( - const char *srcUrl, - const KeyedVector<String8, String8> *headers = NULL) = 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 diff --git a/include/media/IMediaPlayer.h b/include/media/IMediaPlayer.h deleted file mode 100644 index 00facc5..0000000 --- a/include/media/IMediaPlayer.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_IMEDIAPLAYER_H -#define ANDROID_IMEDIAPLAYER_H - -#include <utils/RefBase.h> -#include <binder/IInterface.h> -#include <binder/Parcel.h> -#include <utils/KeyedVector.h> -#include <system/audio.h> - -// Fwd decl to make sure everyone agrees that the scope of struct sockaddr_in is -// global, and not in android:: -struct sockaddr_in; - -namespace android { - -class Parcel; -class Surface; -class IStreamSource; -class ISurfaceTexture; - -class IMediaPlayer: public IInterface -{ -public: - DECLARE_META_INTERFACE(MediaPlayer); - - virtual void disconnect() = 0; - - virtual status_t setDataSource(const char *url, - const KeyedVector<String8, String8>* headers) = 0; - virtual status_t setDataSource(int fd, int64_t offset, int64_t length) = 0; - virtual status_t setDataSource(const sp<IStreamSource>& source) = 0; - virtual status_t setVideoSurfaceTexture( - const sp<ISurfaceTexture>& surfaceTexture) = 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(audio_stream_type_t type) = 0; - virtual status_t setLooping(int loop) = 0; - virtual status_t setVolume(float leftVolume, float rightVolume) = 0; - virtual status_t setAuxEffectSendLevel(float level) = 0; - virtual status_t attachAuxEffect(int effectId) = 0; - virtual status_t setParameter(int key, const Parcel& request) = 0; - virtual status_t getParameter(int key, Parcel* reply) = 0; - virtual status_t setRetransmitEndpoint(const struct sockaddr_in* endpoint) = 0; - virtual status_t setNextPlayer(const sp<IMediaPlayer>& next) = 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; -}; - -// ---------------------------------------------------------------------------- - -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 diff --git a/include/media/IMediaPlayerClient.h b/include/media/IMediaPlayerClient.h deleted file mode 100644 index 8f1843e..0000000 --- a/include/media/IMediaPlayerClient.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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, const Parcel *obj) = 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 diff --git a/include/media/IMediaPlayerService.h b/include/media/IMediaPlayerService.h deleted file mode 100644 index 76c45a0..0000000 --- a/include/media/IMediaPlayerService.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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 <system/audio.h> - -#include <media/IMediaPlayerClient.h> -#include <media/IMediaPlayer.h> -#include <media/IMediaMetadataRetriever.h> - -namespace android { - -struct ICrypto; -class IMediaRecorder; -class IOMX; -struct IStreamSource; - -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, int audioSessionId = 0) = 0; - - virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0; - virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0; - virtual sp<IOMX> getOMX() = 0; - virtual sp<ICrypto> makeCrypto() = 0; - - // codecs and audio devices usage tracking for the battery app - enum BatteryDataBits { - // tracking audio codec - kBatteryDataTrackAudio = 0x1, - // tracking video codec - kBatteryDataTrackVideo = 0x2, - // codec is started, otherwise codec is paused - kBatteryDataCodecStarted = 0x4, - // tracking decoder (for media player), - // otherwise tracking encoder (for media recorder) - kBatteryDataTrackDecoder = 0x8, - // start to play an audio on an audio device - kBatteryDataAudioFlingerStart = 0x10, - // stop/pause the audio playback - kBatteryDataAudioFlingerStop = 0x20, - // audio is rounted to speaker - kBatteryDataSpeakerOn = 0x40, - // audio is rounted to devices other than speaker - kBatteryDataOtherAudioDeviceOn = 0x80, - }; - - virtual void addBatteryData(uint32_t params) = 0; - virtual status_t pullBatteryData(Parcel* reply) = 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 diff --git a/include/media/IMediaRecorder.h b/include/media/IMediaRecorder.h deleted file mode 100644 index ec84e25..0000000 --- a/include/media/IMediaRecorder.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - ** - ** 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 Surface; -class ICamera; -class ICameraRecordingProxy; -class IMediaRecorderClient; -class ISurfaceTexture; - -class IMediaRecorder: public IInterface -{ -public: - DECLARE_META_INTERFACE(MediaRecorder); - - virtual status_t setCamera(const sp<ICamera>& camera, - const sp<ICameraRecordingProxy>& proxy) = 0; - virtual status_t setPreviewSurface(const sp<Surface>& 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 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 sp<ISurfaceTexture> querySurfaceMediaSource() = 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 diff --git a/include/media/IMediaRecorderClient.h b/include/media/IMediaRecorderClient.h deleted file mode 100644 index e7d0229..0000000 --- a/include/media/IMediaRecorderClient.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_IMEDIARECORDERCLIENT_H -#define ANDROID_IMEDIARECORDERCLIENT_H - -#include <utils/RefBase.h> -#include <binder/IInterface.h> -#include <binder/Parcel.h> - -namespace android { - -class IMediaRecorderClient: public IInterface -{ -public: - DECLARE_META_INTERFACE(MediaRecorderClient); - - virtual void notify(int msg, int ext1, int ext2) = 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 diff --git a/include/media/IOMX.h b/include/media/IOMX.h deleted file mode 100644 index be1b2fc..0000000 --- a/include/media/IOMX.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_IOMX_H_ - -#define ANDROID_IOMX_H_ - -#include <binder/IInterface.h> -#include <ui/GraphicBuffer.h> -#include <utils/List.h> -#include <utils/String8.h> - -#include <OMX_Core.h> -#include <OMX_Video.h> - -namespace android { - -class IMemory; -class IOMXObserver; -class IOMXRenderer; -class Surface; - -class IOMX : public IInterface { -public: - DECLARE_META_INTERFACE(OMX); - - typedef void *buffer_id; - typedef void *node_id; - - // Given a node_id and the calling process' pid, returns true iff - // the implementation of the OMX interface lives in the same - // process. - virtual bool livesLocally(node_id node, pid_t pid) = 0; - - struct ComponentInfo { - String8 mName; - List<String8> mRoles; - }; - virtual status_t listNodes(List<ComponentInfo> *list) = 0; - - virtual status_t allocateNode( - const char *name, const sp<IOMXObserver> &observer, - node_id *node) = 0; - - virtual status_t freeNode(node_id node) = 0; - - virtual status_t sendCommand( - node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param) = 0; - - virtual status_t getParameter( - node_id node, OMX_INDEXTYPE index, - void *params, size_t size) = 0; - - virtual status_t setParameter( - node_id node, OMX_INDEXTYPE index, - const void *params, size_t size) = 0; - - virtual status_t getConfig( - node_id node, OMX_INDEXTYPE index, - void *params, size_t size) = 0; - - virtual status_t setConfig( - node_id node, OMX_INDEXTYPE index, - const void *params, size_t size) = 0; - - virtual status_t getState( - node_id node, OMX_STATETYPE* state) = 0; - - virtual status_t storeMetaDataInBuffers( - node_id node, OMX_U32 port_index, OMX_BOOL enable) = 0; - - virtual status_t enableGraphicBuffers( - node_id node, OMX_U32 port_index, OMX_BOOL enable) = 0; - - virtual status_t getGraphicBufferUsage( - node_id node, OMX_U32 port_index, OMX_U32* usage) = 0; - - virtual status_t useBuffer( - node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, - buffer_id *buffer) = 0; - - virtual status_t useGraphicBuffer( - node_id node, OMX_U32 port_index, - const sp<GraphicBuffer> &graphicBuffer, buffer_id *buffer) = 0; - - // This API clearly only makes sense if the caller lives in the - // same process as the callee, i.e. is the media_server, as the - // returned "buffer_data" pointer is just that, a pointer into local - // address space. - virtual status_t allocateBuffer( - node_id node, OMX_U32 port_index, size_t size, - buffer_id *buffer, void **buffer_data) = 0; - - virtual status_t allocateBufferWithBackup( - node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, - buffer_id *buffer) = 0; - - virtual status_t freeBuffer( - node_id node, OMX_U32 port_index, buffer_id buffer) = 0; - - virtual status_t fillBuffer(node_id node, buffer_id buffer) = 0; - - virtual status_t emptyBuffer( - node_id node, - buffer_id buffer, - OMX_U32 range_offset, OMX_U32 range_length, - OMX_U32 flags, OMX_TICKS timestamp) = 0; - - virtual status_t getExtensionIndex( - node_id node, - const char *parameter_name, - OMX_INDEXTYPE *index) = 0; -}; - -struct omx_message { - enum { - EVENT, - EMPTY_BUFFER_DONE, - FILL_BUFFER_DONE, - - } type; - - IOMX::node_id node; - - union { - // if type == EVENT - struct { - OMX_EVENTTYPE event; - OMX_U32 data1; - OMX_U32 data2; - } event_data; - - // if type == EMPTY_BUFFER_DONE - struct { - IOMX::buffer_id buffer; - } buffer_data; - - // if type == FILL_BUFFER_DONE - struct { - IOMX::buffer_id buffer; - OMX_U32 range_offset; - OMX_U32 range_length; - OMX_U32 flags; - OMX_TICKS timestamp; - OMX_PTR platform_private; - OMX_PTR data_ptr; - } extended_buffer_data; - - } u; -}; - -class IOMXObserver : public IInterface { -public: - DECLARE_META_INTERFACE(OMXObserver); - - virtual void onMessage(const omx_message &msg) = 0; -}; - -//////////////////////////////////////////////////////////////////////////////// - -class BnOMX : public BnInterface<IOMX> { -public: - virtual status_t onTransact( - uint32_t code, const Parcel &data, Parcel *reply, - uint32_t flags = 0); -}; - -class BnOMXObserver : public BnInterface<IOMXObserver> { -public: - virtual status_t onTransact( - uint32_t code, const Parcel &data, Parcel *reply, - uint32_t flags = 0); -}; - -struct CodecProfileLevel { - OMX_U32 mProfile; - OMX_U32 mLevel; -}; - -} // namespace android - -#endif // ANDROID_IOMX_H_ diff --git a/include/media/IStreamSource.h b/include/media/IStreamSource.h deleted file mode 100644 index 19646b0..0000000 --- a/include/media/IStreamSource.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_ISTREAMSOURCE_H_ - -#define ANDROID_ISTREAMSOURCE_H_ - -#include <binder/IInterface.h> - -namespace android { - -struct AMessage; -struct IMemory; -struct IStreamListener; - -struct IStreamSource : public IInterface { - DECLARE_META_INTERFACE(StreamSource); - - virtual void setListener(const sp<IStreamListener> &listener) = 0; - virtual void setBuffers(const Vector<sp<IMemory> > &buffers) = 0; - - virtual void onBufferAvailable(size_t index) = 0; -}; - -struct IStreamListener : public IInterface { - DECLARE_META_INTERFACE(StreamListener); - - enum Command { - EOS, - DISCONTINUITY, - }; - - virtual void queueBuffer(size_t index, size_t size) = 0; - - // When signalling a discontinuity you can optionally - // specify an int64_t PTS timestamp in "msg". - // If present, rendering of data following the discontinuity - // will be suppressed until media time reaches this timestamp. - static const char *const kKeyResumeAtPTS; - - // When signalling a discontinuity you can optionally - // specify the type(s) of discontinuity, i.e. if the - // audio format has changed, the video format has changed, - // time has jumped or any combination thereof. - // To do so, include a non-zero int32_t value - // under the key "kKeyDiscontinuityMask" when issuing the DISCONTINUITY - // command. - // If there is a change in audio/video format, The new logical stream - // must start with proper codec initialization - // information for playback to continue, i.e. SPS and PPS in the case - // of AVC video etc. - // If this key is not present, only a time discontinuity is assumed. - // The value should be a bitmask of values from - // ATSParser::DiscontinuityType. - static const char *const kKeyDiscontinuityMask; - - virtual void issueCommand( - Command cmd, bool synchronous, const sp<AMessage> &msg = NULL) = 0; -}; - -//////////////////////////////////////////////////////////////////////////////// - -struct BnStreamSource : public BnInterface<IStreamSource> { - virtual status_t onTransact( - uint32_t code, const Parcel &data, Parcel *reply, - uint32_t flags = 0); -}; - -struct BnStreamListener : public BnInterface<IStreamListener> { - virtual status_t onTransact( - uint32_t code, const Parcel &data, Parcel *reply, - uint32_t flags = 0); -}; - -} // namespace android - -#endif // ANDROID_ISTREAMSOURCE_H_ diff --git a/include/media/JetPlayer.h b/include/media/JetPlayer.h deleted file mode 100644 index 0616bf0..0000000 --- a/include/media/JetPlayer.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef JETPLAYER_H_ -#define JETPLAYER_H_ - -#include <utils/threads.h> - -#include <libsonivox/jet.h> -#include <libsonivox/eas_types.h> -#include <media/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(void *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: - int render(); - void fireUpdateOnStatusChange(); - void fireEventsFromJetQueue(); - - JetPlayer() {} // no default constructor - void dump(); - void dumpJetStatus(S_JET_STATUS* pJetStatus); - - jetevent_callback mEventCallback; - - void* 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[PATH_MAX]; - - class JetPlayerThread : public Thread { - public: - JetPlayerThread(JetPlayer *player) : mPlayer(player) { - } - - protected: - virtual ~JetPlayerThread() {} - - private: - JetPlayer *mPlayer; - - bool threadLoop() { - int result; - result = mPlayer->render(); - return false; - } - - JetPlayerThread(const JetPlayerThread &); - JetPlayerThread &operator=(const JetPlayerThread &); - }; - - sp<JetPlayerThread> mThread; - -}; // end class JetPlayer - -} // end namespace android - - - -#endif /*JETPLAYER_H_*/ diff --git a/include/media/MediaMetadataRetrieverInterface.h b/include/media/MediaMetadataRetrieverInterface.h deleted file mode 100644 index ecc3b65..0000000 --- a/include/media/MediaMetadataRetrieverInterface.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -** -** Copyright (C) 2008 The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -#ifndef ANDROID_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, - const KeyedVector<String8, String8> *headers = NULL) = 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 diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h deleted file mode 100644 index d4aa233..0000000 --- a/include/media/MediaPlayerInterface.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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> - -// Fwd decl to make sure everyone agrees that the scope of struct sockaddr_in is -// global, and not in android:: -struct sockaddr_in; - -namespace android { - -class Parcel; -class Surface; -class ISurfaceTexture; - -template<typename T> class SortedVector; - -enum player_type { - PV_PLAYER = 1, - SONIVOX_PLAYER = 2, - STAGEFRIGHT_PLAYER = 3, - NU_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, - - AAH_RX_PLAYER = 100, - AAH_TX_PLAYER = 101, -}; - - -#define DEFAULT_AUDIOSINK_BUFFERCOUNT 4 -#define DEFAULT_AUDIOSINK_BUFFERSIZE 1200 -#define DEFAULT_AUDIOSINK_SAMPLERATE 44100 - -// when the channel mask isn't known, use the channel count to derive a mask in AudioSink::open() -#define CHANNEL_MASK_USE_CHANNEL_ORDER 0 - -// callback mechanism for passing messages to MediaPlayer object -typedef void (*notify_callback_f)(void* cookie, - int msg, int ext1, int ext2, const Parcel *obj); - -// 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, audio_channel_mask_t channelMask, - audio_format_t format=AUDIO_FORMAT_PCM_16_BIT, - int bufferCount=DEFAULT_AUDIOSINK_BUFFERCOUNT, - AudioCallback cb = NULL, - void *cookie = NULL) = 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 close() = 0; - - virtual status_t setPlaybackRatePermille(int32_t rate) { return INVALID_OPERATION; } - virtual bool needsTrailingPadding() { return true; } - }; - - MediaPlayerBase() : mCookie(0), mNotify(0) {} - virtual ~MediaPlayerBase() {} - virtual status_t initCheck() = 0; - virtual bool hardwareOutput() = 0; - - virtual status_t setUID(uid_t uid) { - return INVALID_OPERATION; - } - - 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 setDataSource(const sp<IStreamSource> &source) { - return INVALID_OPERATION; - } - - // pass the buffered ISurfaceTexture to the media player service - virtual status_t setVideoSurfaceTexture( - const sp<ISurfaceTexture>& surfaceTexture) = 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 setParameter(int key, const Parcel &request) = 0; - virtual status_t getParameter(int key, Parcel *reply) = 0; - - // Right now, only the AAX TX player supports this functionality. For now, - // provide a default implementation which indicates a lack of support for - // this functionality to make life easier for all of the other media player - // maintainers out there. - virtual status_t setRetransmitEndpoint(const struct sockaddr_in* endpoint) { - return INVALID_OPERATION; - } - - // 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; - }; - - void setNotifyCallback( - void* cookie, notify_callback_f notifyFunc) { - Mutex::Autolock autoLock(mNotifyLock); - mCookie = cookie; mNotify = notifyFunc; - } - - void sendEvent(int msg, int ext1=0, int ext2=0, - const Parcel *obj=NULL) { - Mutex::Autolock autoLock(mNotifyLock); - if (mNotify) mNotify(mCookie, msg, ext1, ext2, obj); - } - - virtual status_t dump(int fd, const Vector<String16> &args) const { - return INVALID_OPERATION; - } - -private: - friend class MediaPlayerService; - - Mutex mNotifyLock; - 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 audio directly 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(audio_stream_type_t streamType) = 0; -}; - -}; // namespace android - -#endif // __cplusplus - - -#endif // ANDROID_MEDIAPLAYERINTERFACE_H diff --git a/include/media/MediaProfiles.h b/include/media/MediaProfiles.h deleted file mode 100644 index 9fc962c..0000000 --- a/include/media/MediaProfiles.h +++ /dev/null @@ -1,518 +0,0 @@ -/* - ** - ** 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_LIST_START = 0, - CAMCORDER_QUALITY_LOW = 0, - CAMCORDER_QUALITY_HIGH = 1, - CAMCORDER_QUALITY_QCIF = 2, - CAMCORDER_QUALITY_CIF = 3, - CAMCORDER_QUALITY_480P = 4, - CAMCORDER_QUALITY_720P = 5, - CAMCORDER_QUALITY_1080P = 6, - CAMCORDER_QUALITY_QVGA = 7, - CAMCORDER_QUALITY_LIST_END = 7, - - CAMCORDER_QUALITY_TIME_LAPSE_LIST_START = 1000, - CAMCORDER_QUALITY_TIME_LAPSE_LOW = 1000, - CAMCORDER_QUALITY_TIME_LAPSE_HIGH = 1001, - CAMCORDER_QUALITY_TIME_LAPSE_QCIF = 1002, - CAMCORDER_QUALITY_TIME_LAPSE_CIF = 1003, - CAMCORDER_QUALITY_TIME_LAPSE_480P = 1004, - CAMCORDER_QUALITY_TIME_LAPSE_720P = 1005, - CAMCORDER_QUALITY_TIME_LAPSE_1080P = 1006, - CAMCORDER_QUALITY_TIME_LAPSE_QVGA = 1007, - CAMCORDER_QUALITY_TIME_LAPSE_LIST_END = 1007, -}; - -/** - * Set CIF as default maximum import and export resolution of video editor. - * The maximum import and export resolutions are platform specific, - * which should be defined in media_profiles.xml. - * Set default maximum prefetch YUV frames to 6, which means video editor can - * queue up to 6 YUV frames in the video encoder source. - * This value is used to limit the amount of memory used by video editor - * engine when the encoder consumes YUV frames at a lower speed - * than video editor engine produces. - */ -enum videoeditor_capability { - VIDEOEDITOR_DEFAULT_MAX_INPUT_FRAME_WIDTH = 352, - VIDEOEDITOR_DEFUALT_MAX_INPUT_FRAME_HEIGHT = 288, - VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH = 352, - VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT = 288, - VIDEOEDITOR_DEFAULT_MAX_PREFETCH_YUV_FRAMES = 6 -}; - -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 true if a profile for the given camera at the given quality exists, - * or false if not. - */ - bool hasCamcorderProfile(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 value for the given param name for the video editor cap - * param or -1 if error. - * Supported param name are: - * videoeditor.input.width.max - max input video frame width - * videoeditor.input.height.max - max input video frame height - * videoeditor.output.width.max - max output video frame width - * videoeditor.output.height.max - max output video frame height - * maxPrefetchYUVFrames - max prefetch YUV frames in video editor engine. This value is used - * to limit the memory consumption. - */ - int getVideoEditorCapParamByName(const char *name) const; - - /** - * Returns the value for the given param name for the video editor export codec format - * param or -1 if error. - * Supported param name are: - * videoeditor.export.profile - export video profile - * videoeditor.export.level - export video level - * Supported param codec are: - * 1 for h263 - * 2 for h264 - * 3 for mpeg4 - */ - int getVideoEditorExportParamByName(const char *name, int 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; - - /** - * Returns the start time offset (in ms) for the given camera Id. - * If the given camera Id does not exist, -1 will be returned. - */ - int getStartTimeOffsetMs(int cameraId) const; - -private: - enum { - // Camcorder profiles (high/low) and timelapse profiles (high/low) - kNumRequiredProfiles = 4, - }; - - MediaProfiles& operator=(const MediaProfiles&); // Don't call me - MediaProfiles(const MediaProfiles&); // Don't call me - MediaProfiles() { mVideoEditorCap = NULL; } // 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(const VideoCodec& copy) { - mCodec = copy.mCodec; - mBitRate = copy.mBitRate; - mFrameWidth = copy.mFrameWidth; - mFrameHeight = copy.mFrameHeight; - mFrameRate = copy.mFrameRate; - } - - ~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(const AudioCodec& copy) { - mCodec = copy.mCodec; - mBitRate = copy.mBitRate; - mSampleRate = copy.mSampleRate; - mChannels = copy.mChannels; - } - - ~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(const CamcorderProfile& copy) { - mCameraId = copy.mCameraId; - mFileFormat = copy.mFileFormat; - mQuality = copy.mQuality; - mDuration = copy.mDuration; - mVideoCodec = new VideoCodec(*copy.mVideoCodec); - mAudioCodec = new AudioCodec(*copy.mAudioCodec); - } - - ~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; - }; - struct ExportVideoProfile { - ExportVideoProfile(int codec, int profile, int level) - :mCodec(codec),mProfile(profile),mLevel(level) {} - ~ExportVideoProfile() {} - int mCodec; - int mProfile; - int mLevel; - }; - struct VideoEditorCap { - VideoEditorCap(int inFrameWidth, int inFrameHeight, - int outFrameWidth, int outFrameHeight, int frames) - : mMaxInputFrameWidth(inFrameWidth), - mMaxInputFrameHeight(inFrameHeight), - mMaxOutputFrameWidth(outFrameWidth), - mMaxOutputFrameHeight(outFrameHeight), - mMaxPrefetchYUVFrames(frames) {} - - ~VideoEditorCap() {} - - int mMaxInputFrameWidth; - int mMaxInputFrameHeight; - int mMaxOutputFrameWidth; - int mMaxOutputFrameHeight; - int mMaxPrefetchYUVFrames; - }; - - int getCamcorderProfileIndex(int cameraId, camcorder_quality quality) const; - void initRequiredProfileRefs(const Vector<int>& cameraIds); - int getRequiredProfileRefIndex(int cameraId); - - // 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); - static void logVideoEditorCap(const VideoEditorCap& 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 VideoEditorCap* createVideoEditorCap( - const char **atts, MediaProfiles *profiles); - static ExportVideoProfile* createExportVideoProfile(const char **atts); - - static CamcorderProfile* createCamcorderProfile( - int cameraId, const char **atts, Vector<int>& cameraIds); - - static int getCameraId(const char **atts); - - void addStartTimeOffset(int cameraId, 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 *createDefaultCamcorderQcifProfile(camcorder_quality quality); - static CamcorderProfile *createDefaultCamcorderCifProfile(camcorder_quality quality); - static void createDefaultCamcorderLowProfiles( - MediaProfiles::CamcorderProfile **lowProfile, - MediaProfiles::CamcorderProfile **lowSpecificProfile); - static void createDefaultCamcorderHighProfiles( - MediaProfiles::CamcorderProfile **highProfile, - MediaProfiles::CamcorderProfile **highSpecificProfile); - - static CamcorderProfile *createDefaultCamcorderTimeLapseQcifProfile(camcorder_quality quality); - static CamcorderProfile *createDefaultCamcorderTimeLapse480pProfile(camcorder_quality quality); - static void createDefaultCamcorderTimeLapseLowProfiles( - MediaProfiles::CamcorderProfile **lowTimeLapseProfile, - MediaProfiles::CamcorderProfile **lowSpecificTimeLapseProfile); - static void createDefaultCamcorderTimeLapseHighProfiles( - MediaProfiles::CamcorderProfile **highTimeLapseProfile, - MediaProfiles::CamcorderProfile **highSpecificTimeLapseProfile); - - 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 void createDefaultVideoEditorCap(MediaProfiles *profiles); - static void createDefaultExportVideoProfiles(MediaProfiles *profiles); - - static VideoEncoderCap* createDefaultH263VideoEncoderCap(); - static VideoEncoderCap* createDefaultM4vVideoEncoderCap(); - static AudioEncoderCap* createDefaultAmrNBEncoderCap(); - - static int findTagForName(const NameToTagMap *map, size_t nMappings, const char *name); - - /** - * Check on existing profiles with the following criteria: - * 1. Low quality profile must have the lowest video - * resolution product (width x height) - * 2. High quality profile must have the highest video - * resolution product (width x height) - * - * and add required low/high quality camcorder/timelapse - * profiles if they are not found. This allows to remove - * duplicate profile definitions in the media_profiles.xml - * file. - */ - void checkAndAddRequiredProfilesIfNecessary(); - - - // 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; - KeyedVector<int, int> mStartTimeOffsets; - - typedef struct { - bool mHasRefProfile; // Refers to an existing profile - int mRefProfileIndex; // Reference profile index - int mResolutionProduct; // width x height - } RequiredProfileRefInfo; // Required low and high profiles - - typedef struct { - RequiredProfileRefInfo mRefs[kNumRequiredProfiles]; - int mCameraId; - } RequiredProfiles; - - RequiredProfiles *mRequiredProfileRefs; - Vector<int> mCameraIds; - VideoEditorCap* mVideoEditorCap; - Vector<ExportVideoProfile*> mVideoEditorExportProfiles; -}; - -}; // namespace android - -#endif // ANDROID_MEDIAPROFILES_H diff --git a/include/media/MediaRecorderBase.h b/include/media/MediaRecorderBase.h deleted file mode 100644 index ef799f5..0000000 --- a/include/media/MediaRecorderBase.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MEDIA_RECORDER_BASE_H_ - -#define MEDIA_RECORDER_BASE_H_ - -#include <media/mediarecorder.h> - -#include <system/audio.h> - -namespace android { - -class ICameraRecordingProxy; -class Surface; -class ISurfaceTexture; - -struct MediaRecorderBase { - MediaRecorderBase() {} - virtual ~MediaRecorderBase() {} - - virtual status_t init() = 0; - virtual status_t setAudioSource(audio_source_t 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, - const sp<ICameraRecordingProxy>& proxy) = 0; - virtual status_t setPreviewSurface(const sp<Surface>& 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 setOutputFileAuxiliary(int fd) {return INVALID_OPERATION;} - virtual status_t setParameters(const String8& params) = 0; - virtual status_t setListener(const sp<IMediaRecorderClient>& listener) = 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 sp<ISurfaceTexture> querySurfaceMediaSource() const = 0; - -private: - MediaRecorderBase(const MediaRecorderBase &); - MediaRecorderBase &operator=(const MediaRecorderBase &); -}; - -} // namespace android - -#endif // MEDIA_RECORDER_BASE_H_ diff --git a/include/media/MemoryLeakTrackUtil.h b/include/media/MemoryLeakTrackUtil.h deleted file mode 100644 index d2618aa..0000000 --- a/include/media/MemoryLeakTrackUtil.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2011, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef MEMORY_LEAK_TRACK_UTIL_H -#define MEMORY_LEAK_TRACK_UTIL_H - -namespace android { -/* - * Dump the memory address of the calling process to the given fd. - */ -extern void dumpMemoryAddresses(int fd); - -}; - -#endif // MEMORY_LEAK_TRACK_UTIL_H diff --git a/include/media/Metadata.h b/include/media/Metadata.h deleted file mode 100644 index 07567eb..0000000 --- a/include/media/Metadata.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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; - - // Playback capabilities. - static const Type kPauseAvailable = 1; // Boolean - static const Type kSeekBackwardAvailable = 2; // Boolean - static const Type kSeekForwardAvailable = 3; // Boolean - static const Type kSeekAvailable = 4; // Boolean - - // Keep in sync with android/media/Metadata.java - static const Type kTitle = 5; // String - static const Type kComment = 6; // String - static const Type kCopyright = 7; // String - static const Type kAlbum = 8; // String - static const Type kArtist = 9; // String - static const Type kAuthor = 10; // String - static const Type kComposer = 11; // String - static const Type kGenre = 12; // String - static const Type kDate = 13; // Date - static const Type kDuration = 14; // Integer(millisec) - static const Type kCdTrackNum = 15; // Integer 1-based - static const Type kCdTrackMax = 16; // Integer - static const Type kRating = 17; // String - static const Type kAlbumArt = 18; // byte[] - static const Type kVideoFrame = 19; // Bitmap - - static const Type kBitRate = 20; // Integer, Aggregate rate of - // all the streams in bps. - - static const Type kAudioBitRate = 21; // Integer, bps - static const Type kVideoBitRate = 22; // Integer, bps - static const Type kAudioSampleRate = 23; // Integer, Hz - static const Type kVideoframeRate = 24; // Integer, Hz - - // See RFC2046 and RFC4281. - static const Type kMimeType = 25; // String - static const Type kAudioCodec = 26; // String - static const Type kVideoCodec = 27; // String - - static const Type kVideoHeight = 28; // Integer - static const Type kVideoWidth = 29; // Integer - static const Type kNumTracks = 30; // Integer - static const Type kDrmCrippled = 31; // 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__ diff --git a/include/media/ToneGenerator.h b/include/media/ToneGenerator.h deleted file mode 100644 index df0c97e..0000000 --- a/include/media/ToneGenerator.h +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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 - NUM_TONES, - NUM_SUP_TONES = LAST_SUP_TONE-FIRST_SUP_TONE+1 - }; - - ToneGenerator(audio_stream_type_t streamType, float volume, bool threadCanCallJava = false); - ~ToneGenerator(); - - bool startTone(tone_type 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 - audio_stream_type_t 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(); - tone_type getToneForRegion(tone_type 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_*/ diff --git a/include/media/Visualizer.h b/include/media/Visualizer.h deleted file mode 100644 index 60fa15b..0000000 --- a/include/media/Visualizer.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_MEDIA_VISUALIZER_H -#define ANDROID_MEDIA_VISUALIZER_H - -#include <media/AudioEffect.h> -#include <audio_effects/effect_visualizer.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 = NULL, - void* user = NULL, - 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 mCaptureLock; - 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 diff --git a/include/media/mediametadataretriever.h b/include/media/mediametadataretriever.h deleted file mode 100644 index 534afce..0000000 --- a/include/media/mediametadataretriever.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef 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, - METADATA_KEY_HAS_AUDIO = 16, - METADATA_KEY_HAS_VIDEO = 17, - METADATA_KEY_VIDEO_WIDTH = 18, - METADATA_KEY_VIDEO_HEIGHT = 19, - METADATA_KEY_BITRATE = 20, - METADATA_KEY_TIMED_TEXT_LANGUAGES = 21, - METADATA_KEY_IS_DRM = 22, - METADATA_KEY_LOCATION = 23, - - // Add more here... -}; - -class MediaMetadataRetriever: public RefBase -{ -public: - MediaMetadataRetriever(); - ~MediaMetadataRetriever(); - void disconnect(); - - status_t setDataSource( - const char *dataSourceUrl, - const KeyedVector<String8, String8> *headers = NULL); - - 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 diff --git a/include/media/mediaplayer.h b/include/media/mediaplayer.h deleted file mode 100644 index a68ab4e..0000000 --- a/include/media/mediaplayer.h +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_MEDIAPLAYER_H -#define ANDROID_MEDIAPLAYER_H - -#include <arpa/inet.h> - -#include <binder/IMemory.h> -#include <media/IMediaPlayerClient.h> -#include <media/IMediaPlayer.h> -#include <media/IMediaDeathNotifier.h> -#include <media/IStreamSource.h> - -#include <utils/KeyedVector.h> -#include <utils/String8.h> - -class ANativeWindow; - -namespace android { - -class Surface; -class ISurfaceTexture; - -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_TIMED_TEXT = 99, - MEDIA_ERROR = 100, - MEDIA_INFO = 200, -}; - -// 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, - // The player was started because it was used as the next player for another - // player, which just completed playback - MEDIA_INFO_STARTED_AS_NEXT = 2, - // 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, - // Bandwidth in recent past - MEDIA_INFO_NETWORK_BANDWIDTH = 703, - - // 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, - - //9xx - MEDIA_INFO_TIMED_TEXT_ERROR = 900, -}; - - - -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 -}; - -// Keep KEY_PARAMETER_* in sync with MediaPlayer.java. -// The same enum space is used for both set and get, in case there are future keys that -// can be both set and get. But as of now, all parameters are either set only or get only. -enum media_parameter_keys { - // Streaming/buffering parameters - KEY_PARAMETER_CACHE_STAT_COLLECT_FREQ_MS = 1100, // set only - - // Return a Parcel containing a single int, which is the channel count of the - // audio track, or zero for error (e.g. no audio track) or unknown. - KEY_PARAMETER_AUDIO_CHANNEL_COUNT = 1200, // get only - - // Playback rate expressed in permille (1000 is normal speed), saved as int32_t, with negative - // values used for rewinding or reverse playback. - KEY_PARAMETER_PLAYBACK_RATE_PERMILLE = 1300, // set only -}; - -// Keep INVOKE_ID_* in sync with MediaPlayer.java. -enum media_player_invoke_ids { - INVOKE_ID_GET_TRACK_INFO = 1, - INVOKE_ID_ADD_EXTERNAL_SOURCE = 2, - INVOKE_ID_ADD_EXTERNAL_SOURCE_FD = 3, - INVOKE_ID_SELECT_TRACK = 4, - INVOKE_ID_UNSELECT_TRACK = 5, -}; - -// Keep MEDIA_TRACK_TYPE_* in sync with MediaPlayer.java. -enum media_track_type { - MEDIA_TRACK_TYPE_UNKNOWN = 0, - MEDIA_TRACK_TYPE_VIDEO = 1, - MEDIA_TRACK_TYPE_AUDIO = 2, - MEDIA_TRACK_TYPE_TIMEDTEXT = 3, -}; - -// ---------------------------------------------------------------------------- -// ref-counted object for callbacks -class MediaPlayerListener: virtual public RefBase -{ -public: - virtual void notify(int msg, int ext1, int ext2, const Parcel *obj) = 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 setDataSource(const sp<IStreamSource> &source); - status_t setVideoSurfaceTexture( - const sp<ISurfaceTexture>& surfaceTexture); - 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(audio_stream_type_t type); - status_t setLooping(int loop); - bool isLooping(); - status_t setVolume(float leftVolume, float rightVolume); - void notify(int msg, int ext1, int ext2, const Parcel *obj = NULL); - static sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat); - static sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* 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 setAudioSessionId(int sessionId); - int getAudioSessionId(); - status_t setAuxEffectSendLevel(float level); - status_t attachAuxEffect(int effectId); - status_t setParameter(int key, const Parcel& request); - status_t getParameter(int key, Parcel* reply); - status_t setRetransmitEndpoint(const char* addrString, uint16_t port); - status_t setNextMediaPlayer(const sp<MediaPlayer>& player); - -private: - void clear_l(); - status_t seekTo_l(int msec); - status_t prepareAsync_l(); - status_t getDuration_l(int *msec); - status_t attachNewPlayer(const sp<IMediaPlayer>& player); - status_t reset_l(); - status_t doSetRetransmitEndpoint(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; - audio_stream_type_t mStreamType; - bool mLoop; - float mLeftVolume; - float mRightVolume; - int mVideoWidth; - int mVideoHeight; - int mAudioSessionId; - float mSendLevel; - struct sockaddr_in mRetransmitEndpoint; - bool mRetransmitEndpointValid; -}; - -}; // namespace android - -#endif // ANDROID_MEDIAPLAYER_H diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h deleted file mode 100644 index 30db642..0000000 --- a/include/media/mediarecorder.h +++ /dev/null @@ -1,257 +0,0 @@ -/* - ** Copyright (C) 2008 The Android Open Source Project - ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** - ** http://www.apache.org/licenses/LICENSE-2.0 - ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ** See the License for the specific language governing permissions and - ** - ** limitations under the License. - */ - -#ifndef ANDROID_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; -class ICameraRecordingProxy; -class ISurfaceTexture; -class SurfaceTextureClient; - -typedef void (*media_completion_f)(status_t status, void *cookie); - -enum video_source { - VIDEO_SOURCE_DEFAULT = 0, - VIDEO_SOURCE_CAMERA = 1, - VIDEO_SOURCE_GRALLOC_BUFFER = 2, - - 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_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_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. - */ -enum media_recorder_states { - // Error state. - MEDIA_RECORDER_ERROR = 0, - - // Recorder was just created. - MEDIA_RECORDER_IDLE = 1 << 0, - - // Recorder has been initialized. - MEDIA_RECORDER_INITIALIZED = 1 << 1, - - // Configuration of the recorder has been completed. - MEDIA_RECORDER_DATASOURCE_CONFIGURED = 1 << 2, - - // Recorder is ready to start. - MEDIA_RECORDER_PREPARED = 1 << 3, - - // Recording is in progress. - MEDIA_RECORDER_RECORDING = 1 << 4, -}; - -// The "msg" code passed to the listener in notify. -enum media_recorder_event_type { - MEDIA_RECORDER_EVENT_LIST_START = 1, - MEDIA_RECORDER_EVENT_ERROR = 1, - MEDIA_RECORDER_EVENT_INFO = 2, - MEDIA_RECORDER_EVENT_LIST_END = 99, - - // Track related event types - MEDIA_RECORDER_TRACK_EVENT_LIST_START = 100, - MEDIA_RECORDER_TRACK_EVENT_ERROR = 100, - MEDIA_RECORDER_TRACK_EVENT_INFO = 101, - MEDIA_RECORDER_TRACK_EVENT_LIST_END = 1000, -}; - -/* - * The (part of) "what" code passed to the listener in notify. - * When the error or info type is track specific, the what has - * the following layout: - * the left-most 16-bit is meant for error or info type. - * the right-most 4-bit is meant for track id. - * the rest is reserved. - * - * | track id | reserved | error or info type | - * 31 28 16 0 - * - */ -enum media_recorder_error_type { - MEDIA_RECORDER_ERROR_UNKNOWN = 1, - - // Track related error type - MEDIA_RECORDER_TRACK_ERROR_LIST_START = 100, - MEDIA_RECORDER_TRACK_ERROR_GENERAL = 100, - MEDIA_RECORDER_ERROR_VIDEO_NO_SYNC_FRAME = 200, - MEDIA_RECORDER_TRACK_ERROR_LIST_END = 1000, -}; - -// 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, - - // All track related informtional events start here - MEDIA_RECORDER_TRACK_INFO_LIST_START = 1000, - MEDIA_RECORDER_TRACK_INFO_COMPLETION_STATUS = 1000, - MEDIA_RECORDER_TRACK_INFO_PROGRESS_IN_TIME = 1001, - MEDIA_RECORDER_TRACK_INFO_TYPE = 1002, - MEDIA_RECORDER_TRACK_INFO_DURATION_MS = 1003, - - // The time to measure the max chunk duration - MEDIA_RECORDER_TRACK_INFO_MAX_CHUNK_DUR_MS = 1004, - - MEDIA_RECORDER_TRACK_INFO_ENCODED_FRAMES = 1005, - - // The time to measure how well the audio and video - // track data is interleaved. - MEDIA_RECORDER_TRACK_INTER_CHUNK_TIME_MS = 1006, - - // The time to measure system response. Note that - // the delay does not include the intentional delay - // we use to eliminate the recording sound. - MEDIA_RECORDER_TRACK_INFO_INITIAL_DELAY_MS = 1007, - - // The time used to compensate for initial A/V sync. - MEDIA_RECORDER_TRACK_INFO_START_OFFSET_MS = 1008, - - // Total number of bytes of the media data. - MEDIA_RECORDER_TRACK_INFO_DATA_KBYTES = 1009, - - MEDIA_RECORDER_TRACK_INFO_LIST_END = 2000, -}; - -// ---------------------------------------------------------------------------- -// ref-counted object for callbacks -class MediaRecorderListener: virtual public RefBase -{ -public: - virtual void notify(int msg, int ext1, int ext2) = 0; -}; - -class MediaRecorder : public BnMediaRecorderClient, - public virtual IMediaDeathNotifier -{ -public: - MediaRecorder(); - ~MediaRecorder(); - - void died(); - status_t initCheck(); - status_t setCamera(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy); - 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 setListener(const sp<MediaRecorderListener>& listener); - status_t prepare(); - status_t getMaxAmplitude(int* max); - status_t start(); - status_t stop(); - status_t reset(); - status_t init(); - status_t close(); - status_t release(); - void notify(int msg, int ext1, int ext2); - sp<ISurfaceTexture> querySurfaceMediaSourceFromMediaServer(); - -private: - void doCleanUp(); - status_t doReset(); - - sp<IMediaRecorder> mMediaRecorder; - sp<MediaRecorderListener> mListener; - - // Reference toISurfaceTexture - // for encoding GL Frames. That is useful only when the - // video source is set to VIDEO_SOURCE_GRALLOC_BUFFER - sp<ISurfaceTexture> mSurfaceMediaSource; - - media_recorder_states mCurrentState; - bool mIsAudioSourceSet; - bool mIsVideoSourceSet; - bool mIsAudioEncoderSet; - bool mIsVideoEncoderSet; - bool mIsOutputFileSet; - Mutex mLock; - Mutex mNotifyLock; -}; - -}; // namespace android - -#endif // ANDROID_MEDIARECORDER_H diff --git a/include/media/mediascanner.h b/include/media/mediascanner.h deleted file mode 100644 index a73403b..0000000 --- a/include/media/mediascanner.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MEDIASCANNER_H -#define MEDIASCANNER_H - -#include <utils/Log.h> -#include <utils/threads.h> -#include <utils/List.h> -#include <utils/Errors.h> -#include <pthread.h> - -struct dirent; - -namespace android { - -class MediaScannerClient; -class StringArray; - -enum MediaScanResult { - // This file or directory was scanned successfully. - MEDIA_SCAN_RESULT_OK, - // This file or directory was skipped because it was not found, could - // not be opened, was of an unsupported type, or was malfored in some way. - MEDIA_SCAN_RESULT_SKIPPED, - // The scan should be aborted due to a fatal error such as out of memory - // or an exception. - MEDIA_SCAN_RESULT_ERROR, -}; - -struct MediaScanner { - MediaScanner(); - virtual ~MediaScanner(); - - virtual MediaScanResult processFile( - const char *path, const char *mimeType, MediaScannerClient &client) = 0; - - virtual MediaScanResult processDirectory( - const char *path, MediaScannerClient &client); - - 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; - char *mSkipList; - int *mSkipIndex; - - MediaScanResult doProcessDirectory( - char *path, int pathRemaining, MediaScannerClient &client, bool noMedia); - MediaScanResult doProcessDirectoryEntry( - char *path, int pathRemaining, MediaScannerClient &client, bool noMedia, - struct dirent* entry, char* fileSpot); - void loadSkipList(); - bool shouldSkipDirectory(char *path); - - - MediaScanner(const MediaScanner &); - MediaScanner &operator=(const MediaScanner &); -}; - -class MediaScannerClient -{ -public: - MediaScannerClient(); - virtual ~MediaScannerClient(); - void setLocale(const char* locale); - void beginFile(); - status_t addStringTag(const char* name, const char* value); - void endFile(); - - virtual status_t scanFile(const char* path, long long lastModified, - long long fileSize, bool isDirectory, bool noMedia) = 0; - virtual status_t handleStringTag(const char* name, const char* value) = 0; - virtual status_t setMimeType(const char* mimeType) = 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 diff --git a/include/media/stagefright/AACWriter.h b/include/media/stagefright/AACWriter.h deleted file mode 100644 index 49397ee..0000000 --- a/include/media/stagefright/AACWriter.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef AAC_WRITER_H_ -#define AAC_WRITER_H_ - -#include <media/stagefright/MediaWriter.h> -#include <utils/threads.h> - -namespace android { - -struct MediaSource; -struct MetaData; - -struct AACWriter : public MediaWriter { - AACWriter(const char *filename); - AACWriter(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() { return reset(); } - virtual status_t pause(); - -protected: - virtual ~AACWriter(); - -private: - enum { - kAdtsHeaderLength = 7, // # of bytes for the adts header - kSamplesPerFrame = 1024, // # of samples in a frame - }; - - int mFd; - 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 mChannelCount; - int32_t mSampleRate; - int32_t mFrameDurationUs; - - static void *ThreadWrapper(void *); - status_t threadFunc(); - bool exceedsFileSizeLimit(); - bool exceedsFileDurationLimit(); - status_t writeAdtsHeader(uint32_t frameLength); - status_t reset(); - - DISALLOW_EVIL_CONSTRUCTORS(AACWriter); -}; - -} // namespace android - -#endif // AAC_WRITER_H_ diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h deleted file mode 100644 index 7d7af63..0000000 --- a/include/media/stagefright/ACodec.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef A_CODEC_H_ - -#define A_CODEC_H_ - -#include <stdint.h> -#include <android/native_window.h> -#include <media/IOMX.h> -#include <media/stagefright/foundation/AHierarchicalStateMachine.h> -#include <OMX_Audio.h> - -namespace android { - -struct ABuffer; -struct MemoryDealer; - -struct ACodec : public AHierarchicalStateMachine { - enum { - kWhatFillThisBuffer = 'fill', - kWhatDrainThisBuffer = 'drai', - kWhatEOS = 'eos ', - kWhatShutdownCompleted = 'scom', - kWhatFlushCompleted = 'fcom', - kWhatOutputFormatChanged = 'outC', - kWhatError = 'erro', - kWhatComponentAllocated = 'cAll', - kWhatComponentConfigured = 'cCon', - kWhatBuffersAllocated = 'allc', - }; - - ACodec(); - - void setNotificationMessage(const sp<AMessage> &msg); - void initiateSetup(const sp<AMessage> &msg); - void signalFlush(); - void signalResume(); - void initiateShutdown(bool keepComponentAllocated = false); - - void initiateAllocateComponent(const sp<AMessage> &msg); - void initiateConfigureComponent(const sp<AMessage> &msg); - void initiateStart(); - -protected: - virtual ~ACodec(); - -private: - struct BaseState; - struct UninitializedState; - struct LoadedState; - struct LoadedToIdleState; - struct IdleToExecutingState; - struct ExecutingState; - struct OutputPortSettingsChangedState; - struct ExecutingToIdleState; - struct IdleToLoadedState; - struct FlushingState; - - enum { - kWhatSetup = 'setu', - kWhatOMXMessage = 'omx ', - kWhatInputBufferFilled = 'inpF', - kWhatOutputBufferDrained = 'outD', - kWhatShutdown = 'shut', - kWhatFlush = 'flus', - kWhatResume = 'resm', - kWhatDrainDeferredMessages = 'drai', - kWhatAllocateComponent = 'allo', - kWhatConfigureComponent = 'conf', - kWhatStart = 'star', - }; - - enum { - kPortIndexInput = 0, - kPortIndexOutput = 1 - }; - - enum { - kFlagIsSecure = 1, - }; - - struct BufferInfo { - enum Status { - OWNED_BY_US, - OWNED_BY_COMPONENT, - OWNED_BY_UPSTREAM, - OWNED_BY_DOWNSTREAM, - OWNED_BY_NATIVE_WINDOW, - }; - - IOMX::buffer_id mBufferID; - Status mStatus; - - sp<ABuffer> mData; - sp<GraphicBuffer> mGraphicBuffer; - }; - - sp<AMessage> mNotify; - - sp<UninitializedState> mUninitializedState; - sp<LoadedState> mLoadedState; - sp<LoadedToIdleState> mLoadedToIdleState; - sp<IdleToExecutingState> mIdleToExecutingState; - sp<ExecutingState> mExecutingState; - sp<OutputPortSettingsChangedState> mOutputPortSettingsChangedState; - sp<ExecutingToIdleState> mExecutingToIdleState; - sp<IdleToLoadedState> mIdleToLoadedState; - sp<FlushingState> mFlushingState; - - AString mComponentName; - uint32_t mFlags; - uint32_t mQuirks; - sp<IOMX> mOMX; - IOMX::node_id mNode; - sp<MemoryDealer> mDealer[2]; - - sp<ANativeWindow> mNativeWindow; - - Vector<BufferInfo> mBuffers[2]; - bool mPortEOS[2]; - status_t mInputEOSResult; - - List<sp<AMessage> > mDeferredQueue; - - bool mSentFormat; - bool mIsEncoder; - - bool mShutdownInProgress; - - // If "mKeepComponentAllocated" we only transition back to Loaded state - // and do not release the component instance. - bool mKeepComponentAllocated; - - status_t allocateBuffersOnPort(OMX_U32 portIndex); - status_t freeBuffersOnPort(OMX_U32 portIndex); - status_t freeBuffer(OMX_U32 portIndex, size_t i); - - status_t allocateOutputBuffersFromNativeWindow(); - status_t cancelBufferToNativeWindow(BufferInfo *info); - status_t freeOutputBuffersNotOwnedByComponent(); - BufferInfo *dequeueBufferFromNativeWindow(); - - BufferInfo *findBufferByID( - uint32_t portIndex, IOMX::buffer_id bufferID, - ssize_t *index = NULL); - - status_t setComponentRole(bool isEncoder, const char *mime); - status_t configureCodec(const char *mime, const sp<AMessage> &msg); - - status_t setVideoPortFormatType( - OMX_U32 portIndex, - OMX_VIDEO_CODINGTYPE compressionFormat, - OMX_COLOR_FORMATTYPE colorFormat); - - status_t setSupportedOutputFormat(); - - status_t setupVideoDecoder( - const char *mime, int32_t width, int32_t height); - - status_t setupVideoEncoder( - const char *mime, const sp<AMessage> &msg); - - status_t setVideoFormatOnPort( - OMX_U32 portIndex, - int32_t width, int32_t height, - OMX_VIDEO_CODINGTYPE compressionFormat); - - status_t setupAACCodec( - bool encoder, - int32_t numChannels, int32_t sampleRate, int32_t bitRate, - bool isADTS); - - status_t selectAudioPortFormat( - OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE desiredFormat); - - status_t setupAMRCodec(bool encoder, bool isWAMR, int32_t bitRate); - status_t setupG711Codec(bool encoder, int32_t numChannels); - - status_t setupRawAudioFormat( - OMX_U32 portIndex, int32_t sampleRate, int32_t numChannels); - - status_t setMinBufferSize(OMX_U32 portIndex, size_t size); - - status_t setupMPEG4EncoderParameters(const sp<AMessage> &msg); - status_t setupH263EncoderParameters(const sp<AMessage> &msg); - status_t setupAVCEncoderParameters(const sp<AMessage> &msg); - - status_t verifySupportForProfileAndLevel(int32_t profile, int32_t level); - status_t configureBitrate(int32_t bitrate); - status_t setupErrorCorrectionParameters(); - - status_t initNativeWindow(); - - // Returns true iff all buffers on the given port have status OWNED_BY_US. - bool allYourBuffersAreBelongToUs(OMX_U32 portIndex); - - bool allYourBuffersAreBelongToUs(); - - size_t countBuffersOwnedByComponent(OMX_U32 portIndex) const; - - void deferMessage(const sp<AMessage> &msg); - void processDeferredMessages(); - - void sendFormatChange(); - - void signalError( - OMX_ERRORTYPE error = OMX_ErrorUndefined, - status_t internalError = UNKNOWN_ERROR); - - DISALLOW_EVIL_CONSTRUCTORS(ACodec); -}; - -} // namespace android - -#endif // A_CODEC_H_ diff --git a/include/media/stagefright/AMRWriter.h b/include/media/stagefright/AMRWriter.h deleted file mode 100644 index 392f968..0000000 --- a/include/media/stagefright/AMRWriter.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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() { return reset(); } - virtual status_t pause(); - -protected: - virtual ~AMRWriter(); - -private: - int mFd; - 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(); - status_t reset(); - - AMRWriter(const AMRWriter &); - AMRWriter &operator=(const AMRWriter &); -}; - -} // namespace android - -#endif // AMR_WRITER_H_ diff --git a/include/media/stagefright/AudioPlayer.h b/include/media/stagefright/AudioPlayer.h deleted file mode 100644 index 70c47ae..0000000 --- a/include/media/stagefright/AudioPlayer.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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". - void setSource(const sp<MediaSource> &source); - - // Return time in us. - virtual int64_t getRealTimeUs(); - - status_t start(bool sourceAlreadyStarted = false); - - void pause(bool playPendingSamples = false); - void resume(); - - // Returns the timestamp of the last buffer played (in us). - int64_t getMediaTimeUs(); - - // Returns true iff a mapping is established, i.e. the AudioPlayer - // has played at least one frame of audio. - bool getMediaTimeMapping(int64_t *realtime_us, int64_t *mediatime_us); - - status_t seekTo(int64_t time_us); - - bool isSeeking(); - bool reachedEOS(status_t *finalStatus); - - status_t setPlaybackRatePermille(int32_t ratePermille); - -private: - friend class VideoEditorAudioPlayer; - 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 mIsFirstBuffer; - status_t mFirstBufferResult; - MediaBuffer *mFirstBuffer; - - sp<MediaPlayerBase::AudioSink> mAudioSink; - AwesomePlayer *mObserver; - - 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(); - - uint32_t getNumFramesPendingPlayout() const; - - AudioPlayer(const AudioPlayer &); - AudioPlayer &operator=(const AudioPlayer &); -}; - -} // namespace android - -#endif // AUDIO_PLAYER_H_ diff --git a/include/media/stagefright/AudioSource.h b/include/media/stagefright/AudioSource.h deleted file mode 100644 index f5466e8..0000000 --- a/include/media/stagefright/AudioSource.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef AUDIO_SOURCE_H_ - -#define AUDIO_SOURCE_H_ - -#include <media/AudioRecord.h> -#include <media/AudioSystem.h> -#include <media/stagefright/MediaSource.h> -#include <media/stagefright/MediaBuffer.h> -#include <utils/List.h> - -#include <system/audio.h> - -namespace android { - -class AudioRecord; - -struct AudioSource : public MediaSource, public MediaBufferObserver { - // Note that the "channels" parameter is _not_ the number of channels, - // but a bitmask of audio_channels_t constants. - AudioSource( - audio_source_t inputSource, uint32_t sampleRate, - uint32_t channels = AUDIO_CHANNEL_IN_MONO); - - status_t initCheck() const; - - virtual status_t start(MetaData *params = NULL); - virtual status_t stop() { return reset(); } - virtual sp<MetaData> getFormat(); - - // Returns the maximum amplitude since last call. - int16_t getMaxAmplitude(); - - virtual status_t read( - MediaBuffer **buffer, const ReadOptions *options = NULL); - - status_t dataCallbackTimestamp(const AudioRecord::Buffer& buffer, int64_t timeUs); - virtual void signalBufferReturned(MediaBuffer *buffer); - -protected: - virtual ~AudioSource(); - -private: - enum { - kMaxBufferSize = 2048, - - // After the initial mute, we raise the volume linearly - // over kAutoRampDurationUs. - kAutoRampDurationUs = 300000, - - // This is the initial mute duration to suppress - // the video recording signal tone - kAutoRampStartUs = 0, - }; - - Mutex mLock; - Condition mFrameAvailableCondition; - Condition mFrameEncodingCompletionCondition; - - AudioRecord *mRecord; - status_t mInitCheck; - bool mStarted; - int32_t mSampleRate; - - bool mTrackMaxAmplitude; - int64_t mStartTimeUs; - int16_t mMaxAmplitude; - int64_t mPrevSampleTimeUs; - int64_t mInitialReadTimeUs; - int64_t mNumFramesReceived; - int64_t mNumClientOwnedBuffers; - - List<MediaBuffer * > mBuffersReceived; - - 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); - - void queueInputBuffer_l(MediaBuffer *buffer, int64_t timeUs); - void releaseQueuedFrames_l(); - void waitOutstandingEncodingFrames_l(); - status_t reset(); - - AudioSource(const AudioSource &); - AudioSource &operator=(const AudioSource &); -}; - -} // namespace android - -#endif // AUDIO_SOURCE_H_ diff --git a/include/media/stagefright/CameraSource.h b/include/media/stagefright/CameraSource.h deleted file mode 100644 index 5a35358..0000000 --- a/include/media/stagefright/CameraSource.h +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef CAMERA_SOURCE_H_ - -#define CAMERA_SOURCE_H_ - -#include <media/stagefright/MediaBuffer.h> -#include <media/stagefright/MediaSource.h> -#include <camera/ICamera.h> -#include <camera/ICameraRecordingProxyListener.h> -#include <camera/CameraParameters.h> -#include <utils/List.h> -#include <utils/RefBase.h> - -namespace android { - -class IMemory; -class Camera; -class Surface; - -class CameraSource : public MediaSource, public MediaBufferObserver { -public: - /** - * Factory method to create a new CameraSource using the current - * settings (such as video size, frame rate, color format, etc) - * from the default camera. - * - * @return NULL on error. - */ - static CameraSource *Create(); - - /** - * Factory method to create a new CameraSource. - * - * @param camera the video input frame data source. If it is NULL, - * we will try to connect to the camera with the given - * cameraId. - * - * @param cameraId the id of the camera that the source will connect - * to if camera is NULL; otherwise ignored. - * - * @param videoSize the dimension (in pixels) of the video frame - * @param frameRate the target frames per second - * @param surface the preview surface for display where preview - * frames are sent to - * @param storeMetaDataInVideoBuffers true to request the camera - * source to store meta data in video buffers; false to - * request the camera source to store real YUV frame data - * in the video buffers. The camera source may not support - * storing meta data in video buffers, if so, a request - * to do that will NOT be honored. To find out whether - * meta data is actually being stored in video buffers - * during recording, call isMetaDataStoredInVideoBuffers(). - * - * @return NULL on error. - */ - static CameraSource *CreateFromCamera(const sp<ICamera> &camera, - const sp<ICameraRecordingProxy> &proxy, - int32_t cameraId, - Size videoSize, - int32_t frameRate, - const sp<Surface>& surface, - bool storeMetaDataInVideoBuffers = false); - - virtual ~CameraSource(); - - virtual status_t start(MetaData *params = NULL); - virtual status_t stop() { return reset(); } - virtual status_t read( - MediaBuffer **buffer, const ReadOptions *options = NULL); - - /** - * Check whether a CameraSource object is properly initialized. - * Must call this method before stop(). - * @return OK if initialization has successfully completed. - */ - virtual status_t initCheck() const; - - /** - * Returns the MetaData associated with the CameraSource, - * including: - * kKeyColorFormat: YUV color format of the video frames - * kKeyWidth, kKeyHeight: dimension (in pixels) of the video frames - * kKeySampleRate: frame rate in frames per second - * kKeyMIMEType: always fixed to be MEDIA_MIMETYPE_VIDEO_RAW - */ - virtual sp<MetaData> getFormat(); - - /** - * Tell whether this camera source stores meta data or real YUV - * frame data in video buffers. - * - * @return true if meta data is stored in the video - * buffers; false if real YUV data is stored in - * the video buffers. - */ - bool isMetaDataStoredInVideoBuffers() const; - - virtual void signalBufferReturned(MediaBuffer* buffer); - -protected: - class ProxyListener: public BnCameraRecordingProxyListener { - public: - ProxyListener(const sp<CameraSource>& source); - virtual void dataCallbackTimestamp(int64_t timestampUs, int32_t msgType, - const sp<IMemory> &data); - - private: - sp<CameraSource> mSource; - }; - - // isBinderAlive needs linkToDeath to work. - class DeathNotifier: public IBinder::DeathRecipient { - public: - DeathNotifier() {} - virtual void binderDied(const wp<IBinder>& who); - }; - - enum CameraFlags { - FLAGS_SET_CAMERA = 1L << 0, - FLAGS_HOT_CAMERA = 1L << 1, - }; - - int32_t mCameraFlags; - Size mVideoSize; - int32_t mVideoFrameRate; - int32_t mColorFormat; - status_t mInitCheck; - - sp<Camera> mCamera; - sp<ICameraRecordingProxy> mCameraRecordingProxy; - sp<DeathNotifier> mDeathNotifier; - sp<Surface> mSurface; - sp<MetaData> mMeta; - - int64_t mStartTimeUs; - int32_t mNumFramesReceived; - int64_t mLastFrameTimestampUs; - bool mStarted; - int32_t mNumFramesEncoded; - - // Time between capture of two frames. - int64_t mTimeBetweenFrameCaptureUs; - - CameraSource(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy, - int32_t cameraId, - Size videoSize, int32_t frameRate, - const sp<Surface>& surface, - bool storeMetaDataInVideoBuffers); - - virtual void startCameraRecording(); - virtual void releaseRecordingFrame(const sp<IMemory>& frame); - - // Returns true if need to skip the current frame. - // Called from dataCallbackTimestamp. - virtual bool skipCurrentFrame(int64_t timestampUs) {return false;} - - // Callback called when still camera raw data is available. - virtual void dataCallback(int32_t msgType, const sp<IMemory> &data) {} - - virtual void dataCallbackTimestamp(int64_t timestampUs, int32_t msgType, - const sp<IMemory> &data); - -private: - friend class CameraSourceListener; - - Mutex mLock; - Condition mFrameAvailableCondition; - Condition mFrameCompleteCondition; - List<sp<IMemory> > mFramesReceived; - List<sp<IMemory> > mFramesBeingEncoded; - List<int64_t> mFrameTimes; - - int64_t mFirstFrameTimeUs; - int32_t mNumFramesDropped; - int32_t mNumGlitches; - int64_t mGlitchDurationThresholdUs; - bool mCollectStats; - bool mIsMetaDataStoredInVideoBuffers; - - void releaseQueuedFrames(); - void releaseOneRecordingFrame(const sp<IMemory>& frame); - - - status_t init(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy, - int32_t cameraId, Size videoSize, int32_t frameRate, - bool storeMetaDataInVideoBuffers); - - status_t initWithCameraAccess( - const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy, - int32_t cameraId, Size videoSize, int32_t frameRate, - bool storeMetaDataInVideoBuffers); - - status_t isCameraAvailable(const sp<ICamera>& camera, - const sp<ICameraRecordingProxy>& proxy, - int32_t cameraId); - status_t isCameraColorFormatSupported(const CameraParameters& params); - status_t configureCamera(CameraParameters* params, - int32_t width, int32_t height, - int32_t frameRate); - - status_t checkVideoSize(const CameraParameters& params, - int32_t width, int32_t height); - - status_t checkFrameRate(const CameraParameters& params, - int32_t frameRate); - - void stopCameraRecording(); - void releaseCamera(); - status_t reset(); - - CameraSource(const CameraSource &); - CameraSource &operator=(const CameraSource &); -}; - -} // namespace android - -#endif // CAMERA_SOURCE_H_ diff --git a/include/media/stagefright/CameraSourceTimeLapse.h b/include/media/stagefright/CameraSourceTimeLapse.h deleted file mode 100644 index 0936da2..0000000 --- a/include/media/stagefright/CameraSourceTimeLapse.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef CAMERA_SOURCE_TIME_LAPSE_H_ - -#define CAMERA_SOURCE_TIME_LAPSE_H_ - -#include <pthread.h> - -#include <utils/RefBase.h> -#include <utils/threads.h> - -namespace android { - -class ICamera; -class IMemory; -class Camera; - -class CameraSourceTimeLapse : public CameraSource { -public: - static CameraSourceTimeLapse *CreateFromCamera( - const sp<ICamera> &camera, - const sp<ICameraRecordingProxy> &proxy, - int32_t cameraId, - Size videoSize, - int32_t videoFrameRate, - const sp<Surface>& surface, - int64_t timeBetweenTimeLapseFrameCaptureUs); - - virtual ~CameraSourceTimeLapse(); - - // If the frame capture interval is large, read will block for a long time. - // Due to the way the mediaRecorder framework works, a stop() call from - // mediaRecorder waits until the read returns, causing a long wait for - // stop() to return. To avoid this, we can make read() return a copy of the - // last read frame with the same time stamp frequently. This keeps the - // read() call from blocking too long. Calling this function quickly - // captures another frame, keeps its copy, and enables this mode of read() - // returning quickly. - void startQuickReadReturns(); - -private: - // size of the encoded video. - int32_t mVideoWidth; - int32_t mVideoHeight; - - // Time between two frames in final video (1/frameRate) - int64_t mTimeBetweenTimeLapseVideoFramesUs; - - // Real timestamp of the last encoded time lapse frame - int64_t mLastTimeLapseFrameRealTimestampUs; - - // Variable set in dataCallbackTimestamp() to help skipCurrentFrame() - // to know if current frame needs to be skipped. - bool mSkipCurrentFrame; - - // Lock for accessing mCameraIdle - Mutex mCameraIdleLock; - - // Condition variable to wait on if camera is is not yet idle. Once the - // camera gets idle, this variable will be signalled. - Condition mCameraIdleCondition; - - // True if camera is in preview mode and ready for takePicture(). - // False after a call to takePicture() but before the final compressed - // data callback has been called and preview has been restarted. - volatile bool mCameraIdle; - - // True if stop() is waiting for camera to get idle, i.e. for the last - // takePicture() to complete. This is needed so that dataCallbackTimestamp() - // can return immediately. - volatile bool mStopWaitingForIdleCamera; - - // Lock for accessing quick stop variables. - Mutex mQuickStopLock; - - // mQuickStop is set to true if we use quick read() returns, otherwise it is set - // to false. Once in this mode read() return a copy of the last read frame - // with the same time stamp. See startQuickReadReturns(). - volatile bool mQuickStop; - - // Forces the next frame passed to dataCallbackTimestamp() to be read - // as a time lapse frame. Used by startQuickReadReturns() so that the next - // frame wakes up any blocking read. - volatile bool mForceRead; - - // Stores a copy of the MediaBuffer read in the last read() call after - // mQuickStop was true. - MediaBuffer* mLastReadBufferCopy; - - // Status code for last read. - status_t mLastReadStatus; - - CameraSourceTimeLapse( - const sp<ICamera> &camera, - const sp<ICameraRecordingProxy> &proxy, - int32_t cameraId, - Size videoSize, - int32_t videoFrameRate, - const sp<Surface>& surface, - int64_t timeBetweenTimeLapseFrameCaptureUs); - - // Wrapper over CameraSource::signalBufferReturned() to implement quick stop. - // It only handles the case when mLastReadBufferCopy is signalled. Otherwise - // it calls the base class' function. - virtual void signalBufferReturned(MediaBuffer* buffer); - - // Wrapper over CameraSource::read() to implement quick stop. - virtual status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL); - - // mSkipCurrentFrame is set to true in dataCallbackTimestamp() if the current - // frame needs to be skipped and this function just returns the value of mSkipCurrentFrame. - virtual bool skipCurrentFrame(int64_t timestampUs); - - // In the video camera case calls skipFrameAndModifyTimeStamp() to modify - // timestamp and set mSkipCurrentFrame. - // Then it calls the base CameraSource::dataCallbackTimestamp() - virtual void dataCallbackTimestamp(int64_t timestampUs, int32_t msgType, - const sp<IMemory> &data); - - // Convenience function to fill mLastReadBufferCopy from the just read - // buffer. - void fillLastReadBufferCopy(MediaBuffer& sourceBuffer); - - // If the passed in size (width x height) is a supported video/preview size, - // the function sets the camera's video/preview size to it and returns true. - // Otherwise returns false. - bool trySettingVideoSize(int32_t width, int32_t height); - - // When video camera is used for time lapse capture, returns true - // until enough time has passed for the next time lapse frame. When - // the frame needs to be encoded, it returns false and also modifies - // the time stamp to be one frame time ahead of the last encoded - // frame's time stamp. - bool skipFrameAndModifyTimeStamp(int64_t *timestampUs); - - // Wrapper to enter threadTimeLapseEntry() - static void *ThreadTimeLapseWrapper(void *me); - - // Creates a copy of source_data into a new memory of final type MemoryBase. - sp<IMemory> createIMemoryCopy(const sp<IMemory> &source_data); - - CameraSourceTimeLapse(const CameraSourceTimeLapse &); - CameraSourceTimeLapse &operator=(const CameraSourceTimeLapse &); -}; - -} // namespace android - -#endif // CAMERA_SOURCE_TIME_LAPSE_H_ diff --git a/include/media/stagefright/ColorConverter.h b/include/media/stagefright/ColorConverter.h deleted file mode 100644 index 85ba920..0000000 --- a/include/media/stagefright/ColorConverter.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef COLOR_CONVERTER_H_ - -#define COLOR_CONVERTER_H_ - -#include <sys/types.h> - -#include <stdint.h> -#include <utils/Errors.h> - -#include <OMX_Video.h> - -namespace android { - -struct ColorConverter { - ColorConverter(OMX_COLOR_FORMATTYPE from, OMX_COLOR_FORMATTYPE to); - ~ColorConverter(); - - bool isValid() const; - - status_t convert( - const void *srcBits, - size_t srcWidth, size_t srcHeight, - size_t srcCropLeft, size_t srcCropTop, - size_t srcCropRight, size_t srcCropBottom, - void *dstBits, - size_t dstWidth, size_t dstHeight, - size_t dstCropLeft, size_t dstCropTop, - size_t dstCropRight, size_t dstCropBottom); - -private: - struct BitmapParams { - BitmapParams( - void *bits, - size_t width, size_t height, - size_t cropLeft, size_t cropTop, - size_t cropRight, size_t cropBottom); - - size_t cropWidth() const; - size_t cropHeight() const; - - void *mBits; - size_t mWidth, mHeight; - size_t mCropLeft, mCropTop, mCropRight, mCropBottom; - }; - - OMX_COLOR_FORMATTYPE mSrcFormat, mDstFormat; - uint8_t *mClip; - - uint8_t *initClip(); - - status_t convertCbYCrY( - const BitmapParams &src, const BitmapParams &dst); - - status_t convertYUV420Planar( - const BitmapParams &src, const BitmapParams &dst); - - status_t convertQCOMYUV420SemiPlanar( - const BitmapParams &src, const BitmapParams &dst); - - status_t convertYUV420SemiPlanar( - const BitmapParams &src, const BitmapParams &dst); - - status_t convertTIYUV420PackedSemiPlanar( - const BitmapParams &src, const BitmapParams &dst); - - ColorConverter(const ColorConverter &); - ColorConverter &operator=(const ColorConverter &); -}; - -} // namespace android - -#endif // COLOR_CONVERTER_H_ diff --git a/include/media/stagefright/DataSource.h b/include/media/stagefright/DataSource.h deleted file mode 100644 index 00d583e..0000000 --- a/include/media/stagefright/DataSource.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DATA_SOURCE_H_ - -#define DATA_SOURCE_H_ - -#include <sys/types.h> - -#include <media/stagefright/MediaErrors.h> -#include <utils/Errors.h> -#include <utils/KeyedVector.h> -#include <utils/List.h> -#include <utils/RefBase.h> -#include <utils/threads.h> -#include <drm/DrmManagerClient.h> - -namespace android { - -struct AMessage; -class String8; - -class DataSource : public RefBase { -public: - enum Flags { - kWantsPrefetching = 1, - kStreamedFromLocalHost = 2, - kIsCachingDataSource = 4, - kIsHTTPBasedSource = 8, - }; - - static sp<DataSource> CreateFromURI( - const char *uri, - const KeyedVector<String8, String8> *headers = NULL); - - DataSource() {} - - virtual status_t initCheck() const = 0; - - virtual ssize_t readAt(off64_t offset, void *data, size_t size) = 0; - - // Convenience methods: - bool getUInt16(off64_t offset, uint16_t *x); - - // May return ERROR_UNSUPPORTED. - virtual status_t getSize(off64_t *size); - - virtual uint32_t flags() { - return 0; - } - - virtual status_t reconnectAtOffset(off64_t offset) { - return ERROR_UNSUPPORTED; - } - - //////////////////////////////////////////////////////////////////////////// - - bool sniff(String8 *mimeType, float *confidence, sp<AMessage> *meta); - - // The sniffer can optionally fill in "meta" with an AMessage containing - // a dictionary of values that helps the corresponding extractor initialize - // its state without duplicating effort already exerted by the sniffer. - typedef bool (*SnifferFunc)( - const sp<DataSource> &source, String8 *mimeType, - float *confidence, sp<AMessage> *meta); - - static void RegisterSniffer(SnifferFunc func); - static void RegisterDefaultSniffers(); - - // for DRM - virtual sp<DecryptHandle> DrmInitialization(const char *mime = NULL) { - return NULL; - } - virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client) {}; - - virtual String8 getUri() { - return String8(); - } - - virtual String8 getMIMEType() const; - -protected: - virtual ~DataSource() {} - -private: - static Mutex gSnifferMutex; - static List<SnifferFunc> gSniffers; - - DataSource(const DataSource &); - DataSource &operator=(const DataSource &); -}; - -} // namespace android - -#endif // DATA_SOURCE_H_ diff --git a/include/media/stagefright/FileSource.h b/include/media/stagefright/FileSource.h deleted file mode 100644 index d994cb3..0000000 --- a/include/media/stagefright/FileSource.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FILE_SOURCE_H_ - -#define FILE_SOURCE_H_ - -#include <stdio.h> - -#include <media/stagefright/DataSource.h> -#include <media/stagefright/MediaErrors.h> -#include <utils/threads.h> -#include <drm/DrmManagerClient.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); - - virtual sp<DecryptHandle> DrmInitialization(const char *mime); - - virtual void getDrmInfo(sp<DecryptHandle> &handle, DrmManagerClient **client); - -protected: - virtual ~FileSource(); - -private: - int mFd; - int64_t mOffset; - int64_t mLength; - Mutex mLock; - - /*for DRM*/ - sp<DecryptHandle> mDecryptHandle; - DrmManagerClient *mDrmManagerClient; - int64_t mDrmBufOffset; - int64_t mDrmBufSize; - unsigned char *mDrmBuf; - - ssize_t readAtDRM(off64_t offset, void *data, size_t size); - - FileSource(const FileSource &); - FileSource &operator=(const FileSource &); -}; - -} // namespace android - -#endif // FILE_SOURCE_H_ - diff --git a/include/media/stagefright/JPEGSource.h b/include/media/stagefright/JPEGSource.h deleted file mode 100644 index 1b7e91b..0000000 --- a/include/media/stagefright/JPEGSource.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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_ - diff --git a/include/media/stagefright/MPEG2TSWriter.h b/include/media/stagefright/MPEG2TSWriter.h deleted file mode 100644 index a7c9ecf..0000000 --- a/include/media/stagefright/MPEG2TSWriter.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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); - - MPEG2TSWriter( - void *cookie, - ssize_t (*write)(void *cookie, const void *data, size_t size)); - - virtual status_t addSource(const sp<MediaSource> &source); - virtual status_t start(MetaData *param = NULL); - virtual status_t stop() { return reset(); } - 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; - - void *mWriteCookie; - ssize_t (*mWriteFunc)(void *cookie, const void *data, size_t size); - - 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); - - ssize_t internalWrite(const void *data, size_t size); - status_t reset(); - - DISALLOW_EVIL_CONSTRUCTORS(MPEG2TSWriter); -}; - -} // namespace android - -#endif // MPEG2TS_WRITER_H_ diff --git a/include/media/stagefright/MPEG4Writer.h b/include/media/stagefright/MPEG4Writer.h deleted file mode 100644 index 0409b30..0000000 --- a/include/media/stagefright/MPEG4Writer.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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() { return reset(); } - 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; } - - status_t setGeoData(int latitudex10000, int longitudex10000); - void setStartTimeOffsetMs(int ms) { mStartTimeOffsetMs = ms; } - int32_t getStartTimeOffsetMs() const { return mStartTimeOffsetMs; } - -protected: - virtual ~MPEG4Writer(); - -private: - class Track; - - int mFd; - status_t mInitCheck; - bool mUse4ByteNalLength; - bool mUse32BitOffset; - bool mIsFileSizeLimitExplicitlyRequested; - bool mPaused; - bool mStarted; // Writer thread + track threads started successfully - bool mWriterThreadStarted; // Only writer thread started successfully - off64_t mOffset; - off_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 mLatitudex10000; - int mLongitudex10000; - bool mAreGeoTagsAvailable; - int32_t mStartTimeOffsetMs; - - 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(): mTrack(NULL), mTimeStampUs(0) {} - - 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 - - // Previous chunk timestamp that has been written - int64_t mPrevChunkTimestampUs; - - // Max time interval between neighboring chunks - int64_t mMaxInterChunkDurUs; - - }; - - 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 writeAllChunks(); - - // Retrieve the proper chunk to write if there is one - // Return true if a chunk is found; otherwise, return false. - bool findChunkToWrite(Chunk *chunk); - - // Actually write the given chunk to the file. - void writeChunkToFile(Chunk* chunk); - - // 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); - bool exceedsFileSizeLimit(); - bool use32BitFileOffset() const; - bool exceedsFileDurationLimit(); - bool isFileStreamable() const; - void trackProgressStatus(size_t trackId, int64_t timeUs, status_t err = OK); - void writeCompositionMatrix(int32_t degrees); - void writeMvhdBox(int64_t durationUs); - void writeMoovBox(int64_t durationUs); - void writeFtypBox(MetaData *param); - void writeUdtaBox(); - void writeGeoDataBox(); - void writeLatitude(int degreex10000); - void writeLongitude(int degreex10000); - void sendSessionSummary(); - void release(); - status_t reset(); - - MPEG4Writer(const MPEG4Writer &); - MPEG4Writer &operator=(const MPEG4Writer &); -}; - -} // namespace android - -#endif // MPEG4_WRITER_H_ diff --git a/include/media/stagefright/MediaBuffer.h b/include/media/stagefright/MediaBuffer.h deleted file mode 100644 index 3d79596..0000000 --- a/include/media/stagefright/MediaBuffer.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MEDIA_BUFFER_H_ - -#define MEDIA_BUFFER_H_ - -#include <pthread.h> - -#include <utils/Errors.h> -#include <utils/RefBase.h> - -namespace android { - -struct ABuffer; -class GraphicBuffer; -class MediaBuffer; -class MediaBufferObserver; -class MetaData; - -class MediaBufferObserver { -public: - MediaBufferObserver() {} - virtual ~MediaBufferObserver() {} - - virtual void signalBufferReturned(MediaBuffer *buffer) = 0; - -private: - MediaBufferObserver(const MediaBufferObserver &); - MediaBufferObserver &operator=(const MediaBufferObserver &); -}; - -class MediaBuffer { -public: - // The underlying data remains the responsibility of the caller! - MediaBuffer(void *data, size_t size); - - MediaBuffer(size_t size); - - MediaBuffer(const sp<GraphicBuffer>& graphicBuffer); - - MediaBuffer(const sp<ABuffer> &buffer); - - // Decrements the reference count and returns the buffer to its - // associated MediaBufferGroup if the reference count drops to 0. - void release(); - - // Increments the reference count. - void add_ref(); - - void *data() const; - size_t size() const; - - size_t range_offset() const; - size_t range_length() const; - - void set_range(size_t offset, size_t length); - - sp<GraphicBuffer> graphicBuffer() const; - - sp<MetaData> meta_data(); - - // Clears meta data and resets the range to the full extent. - void reset(); - - void setObserver(MediaBufferObserver *group); - - // Returns a clone of this MediaBuffer increasing its reference count. - // The clone references the same data but has its own range and - // MetaData. - MediaBuffer *clone(); - - int refcount() const; - -protected: - virtual ~MediaBuffer(); - -private: - friend class MediaBufferGroup; - friend class OMXDecoder; - - // For use by OMXDecoder, reference count must be 1, drop reference - // count to 0 without signalling the observer. - void claim(); - - MediaBufferObserver *mObserver; - MediaBuffer *mNextBuffer; - int mRefCount; - - void *mData; - size_t mSize, mRangeOffset, mRangeLength; - sp<GraphicBuffer> mGraphicBuffer; - sp<ABuffer> mBuffer; - - bool mOwnsData; - - sp<MetaData> mMetaData; - - MediaBuffer *mOriginal; - - void setNextBuffer(MediaBuffer *buffer); - MediaBuffer *nextBuffer(); - - MediaBuffer(const MediaBuffer &); - MediaBuffer &operator=(const MediaBuffer &); -}; - -} // namespace android - -#endif // MEDIA_BUFFER_H_ diff --git a/include/media/stagefright/MediaBufferGroup.h b/include/media/stagefright/MediaBufferGroup.h deleted file mode 100644 index 0488292..0000000 --- a/include/media/stagefright/MediaBufferGroup.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MEDIA_BUFFER_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_ diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h deleted file mode 100644 index 0fc88e1..0000000 --- a/include/media/stagefright/MediaCodec.h +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MEDIA_CODEC_H_ - -#define MEDIA_CODEC_H_ - -#include <gui/ISurfaceTexture.h> -#include <media/stagefright/foundation/AHandler.h> -#include <utils/Vector.h> - -namespace android { - -struct ABuffer; -struct ACodec; -struct AMessage; -struct ICrypto; -struct SoftwareRenderer; -struct SurfaceTextureClient; - -struct MediaCodec : public AHandler { - enum ConfigureFlags { - CONFIGURE_FLAG_ENCODE = 1, - CONFIGURE_FLAG_SECURE = 2, - }; - - enum BufferFlags { - BUFFER_FLAG_SYNCFRAME = 1, - BUFFER_FLAG_CODECCONFIG = 2, - BUFFER_FLAG_EOS = 4, - BUFFER_FLAG_ENCRYPTED = 8, - }; - - static sp<MediaCodec> CreateByType( - const sp<ALooper> &looper, const char *mime, bool encoder); - - static sp<MediaCodec> CreateByComponentName( - const sp<ALooper> &looper, const char *name); - - status_t configure( - const sp<AMessage> &format, - const sp<SurfaceTextureClient> &nativeWindow, - uint32_t flags); - - status_t start(); - - // Returns to a state in which the component remains allocated but - // unconfigured. - status_t stop(); - - // Client MUST call release before releasing final reference to this - // object. - status_t release(); - - status_t flush(); - - status_t queueInputBuffer( - size_t index, - size_t offset, - size_t size, - int64_t presentationTimeUs, - uint32_t flags); - - status_t dequeueInputBuffer(size_t *index, int64_t timeoutUs = 0ll); - - status_t dequeueOutputBuffer( - size_t *index, - size_t *offset, - size_t *size, - int64_t *presentationTimeUs, - uint32_t *flags, - int64_t timeoutUs = 0ll); - - status_t renderOutputBufferAndRelease(size_t index); - status_t releaseOutputBuffer(size_t index); - - status_t getOutputFormat(sp<AMessage> *format) const; - - status_t getInputBuffers(Vector<sp<ABuffer> > *buffers) const; - status_t getOutputBuffers(Vector<sp<ABuffer> > *buffers) const; - -protected: - virtual ~MediaCodec(); - virtual void onMessageReceived(const sp<AMessage> &msg); - -private: - enum State { - UNINITIALIZED, - INITIALIZING, - INITIALIZED, - CONFIGURING, - CONFIGURED, - STARTING, - STARTED, - FLUSHING, - STOPPING, - RELEASING, - }; - - enum { - kPortIndexInput = 0, - kPortIndexOutput = 1, - }; - - enum { - kWhatInit = 'init', - kWhatConfigure = 'conf', - kWhatStart = 'strt', - kWhatStop = 'stop', - kWhatRelease = 'rele', - kWhatDequeueInputBuffer = 'deqI', - kWhatQueueInputBuffer = 'queI', - kWhatDequeueOutputBuffer = 'deqO', - kWhatReleaseOutputBuffer = 'relO', - kWhatGetBuffers = 'getB', - kWhatFlush = 'flus', - kWhatGetOutputFormat = 'getO', - kWhatDequeueInputTimedOut = 'dITO', - kWhatDequeueOutputTimedOut = 'dOTO', - kWhatCodecNotify = 'codc', - }; - - enum { - kFlagIsSoftwareCodec = 1, - kFlagOutputFormatChanged = 2, - kFlagOutputBuffersChanged = 4, - kFlagStickyError = 8, - kFlagDequeueInputPending = 16, - kFlagDequeueOutputPending = 32, - kFlagIsSecure = 64, - }; - - struct BufferInfo { - void *mBufferID; - sp<ABuffer> mData; - sp<ABuffer> mEncryptedData; - sp<AMessage> mNotify; - bool mOwnedByClient; - }; - - State mState; - sp<ALooper> mLooper; - sp<ALooper> mCodecLooper; - sp<ACodec> mCodec; - uint32_t mReplyID; - uint32_t mFlags; - sp<SurfaceTextureClient> mNativeWindow; - SoftwareRenderer *mSoftRenderer; - sp<AMessage> mOutputFormat; - - List<size_t> mAvailPortBuffers[2]; - Vector<BufferInfo> mPortBuffers[2]; - - int32_t mDequeueInputTimeoutGeneration; - uint32_t mDequeueInputReplyID; - - int32_t mDequeueOutputTimeoutGeneration; - uint32_t mDequeueOutputReplyID; - - sp<ICrypto> mCrypto; - - MediaCodec(const sp<ALooper> &looper); - - static status_t PostAndAwaitResponse( - const sp<AMessage> &msg, sp<AMessage> *response); - - status_t init(const char *name, bool nameIsType, bool encoder); - - void setState(State newState); - void returnBuffersToCodec(); - void returnBuffersToCodecOnPort(int32_t portIndex); - size_t updateBuffers(int32_t portIndex, const sp<AMessage> &msg); - status_t onQueueInputBuffer(const sp<AMessage> &msg); - status_t onReleaseOutputBuffer(const sp<AMessage> &msg); - ssize_t dequeuePortBuffer(int32_t portIndex); - - bool handleDequeueInputBuffer(uint32_t replyID, bool newRequest = false); - bool handleDequeueOutputBuffer(uint32_t replyID, bool newRequest = false); - void cancelPendingDequeueOperations(); - - DISALLOW_EVIL_CONSTRUCTORS(MediaCodec); -}; - -} // namespace android - -#endif // MEDIA_CODEC_H_ diff --git a/include/media/stagefright/MediaCodecList.h b/include/media/stagefright/MediaCodecList.h deleted file mode 100644 index 14dc1b8..0000000 --- a/include/media/stagefright/MediaCodecList.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MEDIA_CODEC_LIST_H_ - -#define MEDIA_CODEC_LIST_H_ - -#include <media/stagefright/foundation/ABase.h> -#include <media/stagefright/foundation/AString.h> - -#include <sys/types.h> -#include <utils/Errors.h> -#include <utils/KeyedVector.h> -#include <utils/Vector.h> - -namespace android { - -struct MediaCodecList { - static const MediaCodecList *getInstance(); - - ssize_t findCodecByType( - const char *type, bool encoder, size_t startIndex = 0) const; - - ssize_t findCodecByName(const char *name) const; - - const char *getCodecName(size_t index) const; - bool codecHasQuirk(size_t index, const char *quirkName) const; - -private: - enum Section { - SECTION_TOPLEVEL, - SECTION_DECODERS, - SECTION_DECODER, - SECTION_ENCODERS, - SECTION_ENCODER, - }; - - struct CodecInfo { - AString mName; - bool mIsEncoder; - uint32_t mTypes; - uint32_t mQuirks; - }; - - static MediaCodecList *sCodecList; - - status_t mInitCheck; - Section mCurrentSection; - int32_t mDepth; - - Vector<CodecInfo> mCodecInfos; - KeyedVector<AString, size_t> mCodecQuirks; - KeyedVector<AString, size_t> mTypes; - - MediaCodecList(); - ~MediaCodecList(); - - status_t initCheck() const; - void parseXMLFile(FILE *file); - - static void StartElementHandlerWrapper( - void *me, const char *name, const char **attrs); - - static void EndElementHandlerWrapper(void *me, const char *name); - - void startElementHandler(const char *name, const char **attrs); - void endElementHandler(const char *name); - - status_t addMediaCodecFromAttributes(bool encoder, const char **attrs); - void addMediaCodec(bool encoder, const char *name, const char *type = NULL); - - status_t addQuirk(const char **attrs); - status_t addTypeFromAttributes(const char **attrs); - void addType(const char *name); - - DISALLOW_EVIL_CONSTRUCTORS(MediaCodecList); -}; - -} // namespace android - -#endif // MEDIA_CODEC_LIST_H_ - diff --git a/include/media/stagefright/MediaDefs.h b/include/media/stagefright/MediaDefs.h deleted file mode 100644 index 457d5d7..0000000 --- a/include/media/stagefright/MediaDefs.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MEDIA_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_MPEG2; -extern const char *MEDIA_MIMETYPE_VIDEO_RAW; - -extern const char *MEDIA_MIMETYPE_AUDIO_AMR_NB; -extern const char *MEDIA_MIMETYPE_AUDIO_AMR_WB; -extern const char *MEDIA_MIMETYPE_AUDIO_MPEG; // layer III -extern const char *MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_I; -extern const char *MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II; -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_FLAC; -extern const char *MEDIA_MIMETYPE_AUDIO_AAC_ADTS; - -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_MPEG2PS; - -extern const char *MEDIA_MIMETYPE_CONTAINER_WVM; - -extern const char *MEDIA_MIMETYPE_TEXT_3GPP; -extern const char *MEDIA_MIMETYPE_TEXT_SUBRIP; - -} // namespace android - -#endif // MEDIA_DEFS_H_ diff --git a/include/media/stagefright/MediaErrors.h b/include/media/stagefright/MediaErrors.h deleted file mode 100644 index dd3bf28..0000000 --- a/include/media/stagefright/MediaErrors.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MEDIA_ERRORS_H_ - -#define MEDIA_ERRORS_H_ - -#include <utils/Errors.h> - -namespace android { - -enum { - MEDIA_ERROR_BASE = -1000, - - ERROR_ALREADY_CONNECTED = MEDIA_ERROR_BASE, - ERROR_NOT_CONNECTED = MEDIA_ERROR_BASE - 1, - ERROR_UNKNOWN_HOST = MEDIA_ERROR_BASE - 2, - ERROR_CANNOT_CONNECT = MEDIA_ERROR_BASE - 3, - ERROR_IO = MEDIA_ERROR_BASE - 4, - ERROR_CONNECTION_LOST = MEDIA_ERROR_BASE - 5, - ERROR_MALFORMED = MEDIA_ERROR_BASE - 7, - ERROR_OUT_OF_RANGE = MEDIA_ERROR_BASE - 8, - ERROR_BUFFER_TOO_SMALL = MEDIA_ERROR_BASE - 9, - ERROR_UNSUPPORTED = MEDIA_ERROR_BASE - 10, - ERROR_END_OF_STREAM = MEDIA_ERROR_BASE - 11, - - // Not technically an error. - INFO_FORMAT_CHANGED = MEDIA_ERROR_BASE - 12, - INFO_DISCONTINUITY = MEDIA_ERROR_BASE - 13, - INFO_OUTPUT_BUFFERS_CHANGED = MEDIA_ERROR_BASE - 14, - - // The following constant values should be in sync with - // drm/drm_framework_common.h - DRM_ERROR_BASE = -2000, - - ERROR_DRM_UNKNOWN = DRM_ERROR_BASE, - ERROR_DRM_NO_LICENSE = DRM_ERROR_BASE - 1, - ERROR_DRM_LICENSE_EXPIRED = DRM_ERROR_BASE - 2, - ERROR_DRM_SESSION_NOT_OPENED = DRM_ERROR_BASE - 3, - ERROR_DRM_DECRYPT_UNIT_NOT_INITIALIZED = DRM_ERROR_BASE - 4, - ERROR_DRM_DECRYPT = DRM_ERROR_BASE - 5, - ERROR_DRM_CANNOT_HANDLE = DRM_ERROR_BASE - 6, - ERROR_DRM_TAMPER_DETECTED = DRM_ERROR_BASE - 7, - - // Heartbeat Error Codes - HEARTBEAT_ERROR_BASE = -3000, - - ERROR_HEARTBEAT_AUTHENTICATION_FAILURE = HEARTBEAT_ERROR_BASE, - ERROR_HEARTBEAT_NO_ACTIVE_PURCHASE_AGREEMENT = HEARTBEAT_ERROR_BASE - 1, - ERROR_HEARTBEAT_CONCURRENT_PLAYBACK = HEARTBEAT_ERROR_BASE - 2, - ERROR_HEARTBEAT_UNUSUAL_ACTIVITY = HEARTBEAT_ERROR_BASE - 3, - ERROR_HEARTBEAT_STREAMING_UNAVAILABLE = HEARTBEAT_ERROR_BASE - 4, - ERROR_HEARTBEAT_CANNOT_ACTIVATE_RENTAL = HEARTBEAT_ERROR_BASE - 5, - ERROR_HEARTBEAT_TERMINATE_REQUESTED = HEARTBEAT_ERROR_BASE - 6, -}; - -} // namespace android - -#endif // MEDIA_ERRORS_H_ diff --git a/include/media/stagefright/MediaExtractor.h b/include/media/stagefright/MediaExtractor.h deleted file mode 100644 index 94090ee..0000000 --- a/include/media/stagefright/MediaExtractor.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MEDIA_EXTRACTOR_H_ - -#define MEDIA_EXTRACTOR_H_ - -#include <utils/RefBase.h> - -namespace android { - -class DataSource; -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; - - // for DRM - void setDrmFlag(bool flag) { - mIsDrm = flag; - }; - bool getDrmFlag() { - return mIsDrm; - } - virtual char* getDrmTrackInfo(size_t trackID, int *len) { - return NULL; - } - -protected: - MediaExtractor() {} - virtual ~MediaExtractor() {} - -private: - bool mIsDrm; - - MediaExtractor(const MediaExtractor &); - MediaExtractor &operator=(const MediaExtractor &); -}; - -} // namespace android - -#endif // MEDIA_EXTRACTOR_H_ diff --git a/include/media/stagefright/MediaSource.h b/include/media/stagefright/MediaSource.h deleted file mode 100644 index 3818e63..0000000 --- a/include/media/stagefright/MediaSource.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MEDIA_SOURCE_H_ - -#define MEDIA_SOURCE_H_ - -#include <sys/types.h> - -#include <media/stagefright/MediaErrors.h> -#include <utils/RefBase.h> -#include <utils/Vector.h> - -namespace android { - -class MediaBuffer; -class MetaData; - -struct MediaSource : public virtual RefBase { - MediaSource(); - - // To be called before any other methods on this object, except - // getFormat(). - virtual status_t start(MetaData *params = NULL) = 0; - - // Any blocking read call returns immediately with a result of NO_INIT. - // It is an error to call any methods other than start after this call - // returns. Any buffers the object may be holding onto at the time of - // the stop() call are released. - // Also, it is imperative that any buffers output by this object and - // held onto by callers be released before a call to stop() !!! - virtual status_t stop() = 0; - - // Returns the format of the data output by this media source. - virtual sp<MetaData> getFormat() = 0; - - struct ReadOptions; - - // Returns a new buffer of data. Call blocks until a - // buffer is available, an error is encountered of the end of the stream - // is reached. - // End of stream is signalled by a result of ERROR_END_OF_STREAM. - // A result of INFO_FORMAT_CHANGED indicates that the format of this - // MediaSource has changed mid-stream, the client can continue reading - // but should be prepared for buffers of the new configuration. - virtual status_t read( - MediaBuffer **buffer, const ReadOptions *options = NULL) = 0; - - // Options that modify read() behaviour. The default is to - // a) not request a seek - // b) not be late, i.e. lateness_us = 0 - struct ReadOptions { - enum SeekMode { - SEEK_PREVIOUS_SYNC, - SEEK_NEXT_SYNC, - SEEK_CLOSEST_SYNC, - SEEK_CLOSEST, - }; - - ReadOptions(); - - // Reset everything back to defaults. - void reset(); - - void setSeekTo(int64_t time_us, SeekMode mode = SEEK_CLOSEST_SYNC); - void clearSeekTo(); - bool getSeekTo(int64_t *time_us, SeekMode *mode) const; - - void setLateBy(int64_t lateness_us); - int64_t getLateBy() const; - - private: - enum Options { - kSeekTo_Option = 1, - }; - - uint32_t mOptions; - int64_t mSeekTimeUs; - SeekMode mSeekMode; - int64_t mLatenessUs; - }; - - // Causes this source to suspend pulling data from its upstream source - // until a subsequent read-with-seek. Currently only supported by - // OMXCodec. - virtual status_t pause() { - return ERROR_UNSUPPORTED; - } - - // The consumer of this media source requests that the given buffers - // are to be returned exclusively in response to read calls. - // This will be called after a successful start() and before the - // first read() call. - // Callee assumes ownership of the buffers if no error is returned. - virtual status_t setBuffers(const Vector<MediaBuffer *> &buffers) { - return ERROR_UNSUPPORTED; - } - -protected: - virtual ~MediaSource(); - -private: - MediaSource(const MediaSource &); - MediaSource &operator=(const MediaSource &); -}; - -} // namespace android - -#endif // MEDIA_SOURCE_H_ diff --git a/include/media/stagefright/MediaWriter.h b/include/media/stagefright/MediaWriter.h deleted file mode 100644 index 5cc8dcf..0000000 --- a/include/media/stagefright/MediaWriter.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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_ diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h deleted file mode 100644 index 639446e..0000000 --- a/include/media/stagefright/MetaData.h +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef META_DATA_H_ - -#define META_DATA_H_ - -#include <sys/types.h> - -#include <stdint.h> - -#include <utils/RefBase.h> -#include <utils/KeyedVector.h> -#include <utils/String8.h> - -namespace android { - -// The following keys map to int32_t data unless indicated otherwise. -enum { - kKeyMIMEType = 'mime', // cstring - kKeyWidth = 'widt', // int32_t, image pixel - kKeyHeight = 'heig', // int32_t, image pixel - kKeyDisplayWidth = 'dWid', // int32_t, display/presentation - kKeyDisplayHeight = 'dHgt', // int32_t, display/presentation - - // a rectangle, if absent assumed to be (0, 0, width - 1, height - 1) - kKeyCropRect = 'crop', - - kKeyRotation = 'rotA', // int32_t (angle in degrees) - kKeyIFramesInterval = 'ifiv', // int32_t - kKeyStride = 'strd', // int32_t - kKeySliceHeight = 'slht', // int32_t - kKeyChannelCount = '#chn', // int32_t - kKeyChannelMask = 'chnm', // int32_t - kKeySampleRate = 'srte', // int32_t (audio sampling rate Hz) - kKeyFrameRate = 'frmR', // int32_t (video frame rate fps) - kKeyBitRate = 'brte', // int32_t (bps) - kKeyESDS = 'esds', // raw data - kKeyAVCC = 'avcc', // raw data - kKeyD263 = 'd263', // raw data - kKeyVorbisInfo = 'vinf', // raw data - kKeyVorbisBooks = 'vboo', // raw data - kKeyWantsNALFragments = 'NALf', - kKeyIsSyncFrame = 'sync', // int32_t (bool) - kKeyIsCodecConfig = 'conf', // int32_t (bool) - kKeyTime = 'time', // int64_t (usecs) - kKeyDecodingTime = 'decT', // int64_t (decoding timestamp in usecs) - kKeyNTPTime = 'ntpT', // uint64_t (ntp-timestamp) - kKeyTargetTime = 'tarT', // int64_t (usecs) - kKeyDriftTime = 'dftT', // int64_t (usecs) - kKeyAnchorTime = 'ancT', // int64_t (usecs) - kKeyDuration = 'dura', // int64_t (usecs) - kKeyColorFormat = 'colf', - kKeyPlatformPrivate = 'priv', // pointer - kKeyDecoderComponent = 'decC', // cstring - kKeyBufferID = 'bfID', - kKeyMaxInputSize = 'inpS', - kKeyThumbnailTime = 'thbT', // int64_t (usecs) - kKeyTrackID = 'trID', - kKeyIsDRM = 'idrm', // int32_t (bool) - kKeyEncoderDelay = 'encd', // int32_t (frames) - kKeyEncoderPadding = 'encp', // int32_t (frames) - - kKeyAlbum = 'albu', // cstring - kKeyArtist = 'arti', // cstring - kKeyAlbumArtist = 'aart', // cstring - kKeyComposer = 'comp', // cstring - kKeyGenre = 'genr', // cstring - kKeyTitle = 'titl', // cstring - kKeyYear = 'year', // cstring - kKeyAlbumArt = 'albA', // compressed image data - kKeyAlbumArtMIME = 'alAM', // cstring - kKeyAuthor = 'auth', // cstring - kKeyCDTrackNumber = 'cdtr', // cstring - kKeyDiscNumber = 'dnum', // cstring - kKeyDate = 'date', // cstring - kKeyWriter = 'writ', // cstring - kKeyCompilation = 'cpil', // cstring - kKeyLocation = 'loc ', // cstring - kKeyTimeScale = 'tmsl', // int32_t - - // video profile and level - kKeyVideoProfile = 'vprf', // int32_t - kKeyVideoLevel = 'vlev', // int32_t - - // Set this key to enable authoring files in 64-bit offset - kKey64BitFileOffset = 'fobt', // int32_t (bool) - kKey2ByteNalLength = '2NAL', // int32_t (bool) - - // Identify the file output format for authoring - // Please see <media/mediarecorder.h> for the supported - // file output formats. - kKeyFileType = 'ftyp', // int32_t - - // Track authoring progress status - // kKeyTrackTimeStatus is used to track progress in elapsed time - kKeyTrackTimeStatus = 'tktm', // int64_t - - kKeyNotRealTime = 'ntrt', // bool (int32_t) - - // Ogg files can be tagged to be automatically looping... - kKeyAutoLoop = 'autL', // bool (int32_t) - - kKeyValidSamples = 'valD', // int32_t - - kKeyIsUnreadable = 'unre', // bool (int32_t) - - // An indication that a video buffer has been rendered. - kKeyRendered = 'rend', // bool (int32_t) - - // The language code for this media - kKeyMediaLanguage = 'lang', // cstring - - // To store the timed text format data - kKeyTextFormatData = 'text', // raw data - - kKeyRequiresSecureBuffers = 'secu', // bool (int32_t) - - kKeyScrambling = 'scrm', // int32_t - kKeyEMM = 'emm ', // raw data - kKeyECM = 'ecm ', // raw data - - kKeyIsADTS = 'adts', // bool (int32_t) -}; - -enum { - kTypeESDS = 'esds', - kTypeAVCC = 'avcc', - kTypeD263 = 'd263', -}; - -class MetaData : public RefBase { -public: - MetaData(); - MetaData(const MetaData &from); - - enum Type { - TYPE_NONE = 'none', - TYPE_C_STRING = 'cstr', - TYPE_INT32 = 'in32', - TYPE_INT64 = 'in64', - TYPE_FLOAT = 'floa', - TYPE_POINTER = 'ptr ', - TYPE_RECT = 'rect', - }; - - void clear(); - bool remove(uint32_t key); - - bool setCString(uint32_t key, const char *value); - bool setInt32(uint32_t key, int32_t value); - bool setInt64(uint32_t key, int64_t value); - bool setFloat(uint32_t key, float value); - bool setPointer(uint32_t key, void *value); - - bool setRect( - uint32_t key, - int32_t left, int32_t top, - int32_t right, int32_t bottom); - - bool findCString(uint32_t key, const char **value); - bool findInt32(uint32_t key, int32_t *value); - bool findInt64(uint32_t key, int64_t *value); - bool findFloat(uint32_t key, float *value); - bool findPointer(uint32_t key, void **value); - - bool findRect( - uint32_t key, - int32_t *left, int32_t *top, - int32_t *right, int32_t *bottom); - - bool setData(uint32_t key, uint32_t type, const void *data, size_t size); - - bool findData(uint32_t key, uint32_t *type, - const void **data, size_t *size) const; - - void dumpToLog() 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; - String8 asString() const; - - private: - uint32_t mType; - size_t mSize; - - union { - void *ext_data; - float reservoir; - } u; - - bool usesReservoir() const { - return mSize <= sizeof(u.reservoir); - } - - void allocateStorage(size_t size); - void freeStorage(); - - void *storage() { - return usesReservoir() ? &u.reservoir : u.ext_data; - } - - const void *storage() const { - return usesReservoir() ? &u.reservoir : u.ext_data; - } - }; - - struct Rect { - int32_t mLeft, mTop, mRight, mBottom; - }; - - KeyedVector<uint32_t, typed_data> mItems; - - // MetaData &operator=(const MetaData &); -}; - -} // namespace android - -#endif // META_DATA_H_ diff --git a/include/media/stagefright/NativeWindowWrapper.h b/include/media/stagefright/NativeWindowWrapper.h deleted file mode 100644 index 97cc0ce..0000000 --- a/include/media/stagefright/NativeWindowWrapper.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NATIVE_WINDOW_WRAPPER_H_ - -#define NATIVE_WINDOW_WRAPPER_H_ - -#include <gui/SurfaceTextureClient.h> - -namespace android { - -// SurfaceTextureClient derives from ANativeWindow which derives from multiple -// base classes, in order to carry it in AMessages, we'll temporarily wrap it -// into a NativeWindowWrapper. - -struct NativeWindowWrapper : RefBase { - NativeWindowWrapper( - const sp<SurfaceTextureClient> &surfaceTextureClient) : - mSurfaceTextureClient(surfaceTextureClient) { } - - sp<ANativeWindow> getNativeWindow() const { - return mSurfaceTextureClient; - } - - sp<SurfaceTextureClient> getSurfaceTextureClient() const { - return mSurfaceTextureClient; - } - -private: - const sp<SurfaceTextureClient> mSurfaceTextureClient; - - DISALLOW_EVIL_CONSTRUCTORS(NativeWindowWrapper); -}; - -} // namespace android - -#endif // NATIVE_WINDOW_WRAPPER_H_ diff --git a/include/media/stagefright/NuMediaExtractor.h b/include/media/stagefright/NuMediaExtractor.h deleted file mode 100644 index 07c7be5..0000000 --- a/include/media/stagefright/NuMediaExtractor.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NU_MEDIA_EXTRACTOR_H_ -#define NU_MEDIA_EXTRACTOR_H_ - -#include <media/stagefright/foundation/ABase.h> -#include <utils/Errors.h> -#include <utils/RefBase.h> -#include <utils/Vector.h> - -namespace android { - -struct ABuffer; -struct AMessage; -struct MediaBuffer; -struct MediaExtractor; -struct MediaSource; - -struct NuMediaExtractor : public RefBase { - enum SampleFlags { - SAMPLE_FLAG_SYNC = 1, - SAMPLE_FLAG_ENCRYPTED = 2, - }; - - NuMediaExtractor(); - - status_t setDataSource(const char *path); - - size_t countTracks() const; - status_t getTrackFormat(size_t index, sp<AMessage> *format) const; - - status_t selectTrack(size_t index); - - status_t seekTo(int64_t timeUs); - - status_t advance(); - status_t readSampleData(const sp<ABuffer> &buffer); - status_t getSampleTrackIndex(size_t *trackIndex); - status_t getSampleTime(int64_t *sampleTimeUs); - status_t getSampleFlags(uint32_t *sampleFlags); - -protected: - virtual ~NuMediaExtractor(); - -private: - enum TrackFlags { - kIsVorbis = 1, - }; - - struct TrackInfo { - sp<MediaSource> mSource; - size_t mTrackIndex; - status_t mFinalResult; - MediaBuffer *mSample; - int64_t mSampleTimeUs; - uint32_t mSampleFlags; - - uint32_t mTrackFlags; // bitmask of "TrackFlags" - }; - - sp<MediaExtractor> mImpl; - - Vector<TrackInfo> mSelectedTracks; - - ssize_t fetchTrackSamples(int64_t seekTimeUs = -1ll); - void releaseTrackSamples(); - - DISALLOW_EVIL_CONSTRUCTORS(NuMediaExtractor); -}; - -} // namespace android - -#endif // NU_MEDIA_EXTRACTOR_H_ - diff --git a/include/media/stagefright/OMXClient.h b/include/media/stagefright/OMXClient.h deleted file mode 100644 index 2f14d06..0000000 --- a/include/media/stagefright/OMXClient.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OMX_CLIENT_H_ - -#define OMX_CLIENT_H_ - -#include <media/IOMX.h> - -namespace android { - -class OMXClient { -public: - OMXClient(); - - status_t connect(); - void disconnect(); - - sp<IOMX> interface() { - return mOMX; - } - -private: - sp<IOMX> mOMX; - - OMXClient(const OMXClient &); - OMXClient &operator=(const OMXClient &); -}; - -} // namespace android - -#endif // OMX_CLIENT_H_ diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h deleted file mode 100644 index 7d51dee..0000000 --- a/include/media/stagefright/OMXCodec.h +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OMX_CODEC_H_ - -#define OMX_CODEC_H_ - -#include <android/native_window.h> -#include <media/IOMX.h> -#include <media/stagefright/MediaBuffer.h> -#include <media/stagefright/MediaSource.h> -#include <utils/threads.h> - -namespace android { - -struct MediaCodecList; -class MemoryDealer; -struct OMXCodecObserver; -struct CodecProfileLevel; -class SkipCutBuffer; - -struct OMXCodec : public MediaSource, - public MediaBufferObserver { - enum CreationFlags { - kPreferSoftwareCodecs = 1, - kIgnoreCodecSpecificData = 2, - - // The client wants to access the output buffer's video - // data for example for thumbnail extraction. - kClientNeedsFramebuffer = 4, - - // Request for software or hardware codecs. If request - // can not be fullfilled, Create() returns NULL. - kSoftwareCodecsOnly = 8, - kHardwareCodecsOnly = 16, - - // Store meta data in video buffers - kStoreMetaDataInVideoBuffers = 32, - - // Only submit one input buffer at one time. - kOnlySubmitOneInputBufferAtOneTime = 64, - - // Enable GRALLOC_USAGE_PROTECTED for output buffers from native window - kEnableGrallocUsageProtected = 128, - - // Secure decoding mode - kUseSecureInputBuffers = 256, - }; - static sp<MediaSource> Create( - const sp<IOMX> &omx, - const sp<MetaData> &meta, bool createEncoder, - const sp<MediaSource> &source, - const char *matchComponentName = NULL, - uint32_t flags = 0, - const sp<ANativeWindow> &nativeWindow = NULL); - - static void setComponentRole( - const sp<IOMX> &omx, IOMX::node_id node, bool isEncoder, - const char *mime); - - virtual status_t start(MetaData *params = NULL); - virtual status_t stop(); - - virtual sp<MetaData> getFormat(); - - virtual status_t read( - MediaBuffer **buffer, const ReadOptions *options = NULL); - - virtual status_t pause(); - - // from MediaBufferObserver - virtual void signalBufferReturned(MediaBuffer *buffer); - - 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, - }; - - // for use by ACodec - static void findMatchingCodecs( - const char *mime, - bool createEncoder, const char *matchComponentName, - uint32_t flags, - Vector<String8> *matchingCodecs, - Vector<uint32_t> *matchingCodecQuirks = NULL); - - static uint32_t getComponentQuirks( - const MediaCodecList *list, size_t index); - - static bool findCodecQuirks(const char *componentName, uint32_t *quirks); - -protected: - virtual ~OMXCodec(); - -private: - - // Make sure mLock is accessible to OMXCodecObserver - friend class OMXCodecObserver; - - // Call this with mLock hold - void on_message(const omx_message &msg); - - enum State { - DEAD, - LOADED, - LOADED_TO_IDLE, - IDLE_TO_EXECUTING, - EXECUTING, - EXECUTING_TO_IDLE, - IDLE_TO_LOADED, - RECONFIGURING, - ERROR - }; - - enum { - kPortIndexInput = 0, - kPortIndexOutput = 1 - }; - - enum PortStatus { - ENABLED, - DISABLING, - DISABLED, - ENABLING, - SHUTTING_DOWN, - }; - - enum BufferStatus { - OWNED_BY_US, - OWNED_BY_COMPONENT, - OWNED_BY_NATIVE_WINDOW, - OWNED_BY_CLIENT, - }; - - struct BufferInfo { - IOMX::buffer_id mBuffer; - BufferStatus mStatus; - sp<IMemory> mMem; - size_t mSize; - void *mData; - MediaBuffer *mMediaBuffer; - }; - - struct CodecSpecificData { - size_t mSize; - uint8_t mData[1]; - }; - - sp<IOMX> mOMX; - bool mOMXLivesLocally; - IOMX::node_id mNode; - uint32_t mQuirks; - - // Flags specified in the creation of the codec. - uint32_t mFlags; - - bool mIsEncoder; - bool mIsVideo; - char *mMIME; - char *mComponentName; - sp<MetaData> mOutputFormat; - sp<MediaSource> mSource; - Vector<CodecSpecificData *> mCodecSpecificData; - size_t mCodecSpecificDataIndex; - - sp<MemoryDealer> mDealer[2]; - - State mState; - Vector<BufferInfo> mPortBuffers[2]; - PortStatus mPortStatus[2]; - bool mInitialBufferSubmit; - bool mSignalledEOS; - status_t mFinalStatus; - bool mNoMoreOutputData; - bool mOutputPortSettingsHaveChanged; - int64_t mSeekTimeUs; - ReadOptions::SeekMode mSeekMode; - int64_t mTargetTimeUs; - bool mOutputPortSettingsChangedPending; - SkipCutBuffer *mSkipCutBuffer; - - MediaBuffer *mLeftOverBuffer; - - Mutex mLock; - Condition mAsyncCompletion; - - bool mPaused; - - sp<ANativeWindow> mNativeWindow; - - // The index in each of the mPortBuffers arrays of the buffer that will be - // submitted to OMX next. This only applies when using buffers from a - // native window. - size_t mNextNativeBufferIndex[2]; - - // A list of indices into mPortStatus[kPortIndexOutput] filled with data. - List<size_t> mFilledBuffers; - Condition mBufferFilled; - - // Used to record the decoding time for an output picture from - // a video encoder. - List<int64_t> mDecodingTimeList; - - OMXCodec(const sp<IOMX> &omx, IOMX::node_id node, - uint32_t quirks, uint32_t flags, - bool isEncoder, const char *mime, const char *componentName, - const sp<MediaSource> &source, - const sp<ANativeWindow> &nativeWindow); - - void addCodecSpecificData(const void *data, size_t size); - void clearCodecSpecificData(); - - void setComponentRole(); - - void setAMRFormat(bool isWAMR, int32_t bitRate); - - status_t setAACFormat( - int32_t numChannels, int32_t sampleRate, int32_t bitRate, - bool isADTS); - - void setG711Format(int32_t numChannels); - - status_t setVideoPortFormatType( - OMX_U32 portIndex, - OMX_VIDEO_CODINGTYPE compressionFormat, - OMX_COLOR_FORMATTYPE colorFormat); - - void setVideoInputFormat( - const char *mime, const sp<MetaData>& meta); - - status_t setupBitRate(int32_t bitRate); - status_t setupErrorCorrectionParameters(); - status_t setupH263EncoderParameters(const sp<MetaData>& meta); - status_t setupMPEG4EncoderParameters(const sp<MetaData>& meta); - status_t setupAVCEncoderParameters(const sp<MetaData>& meta); - status_t findTargetColorFormat( - const sp<MetaData>& meta, OMX_COLOR_FORMATTYPE *colorFormat); - - status_t isColorFormatSupported( - OMX_COLOR_FORMATTYPE colorFormat, int portIndex); - - // If profile/level is set in the meta data, its value in the meta - // data will be used; otherwise, the default value will be used. - status_t getVideoProfileLevel(const sp<MetaData>& meta, - const CodecProfileLevel& defaultProfileLevel, - CodecProfileLevel& profileLevel); - - status_t setVideoOutputFormat( - const char *mime, OMX_U32 width, OMX_U32 height); - - void setImageOutputFormat( - OMX_COLOR_FORMATTYPE format, OMX_U32 width, OMX_U32 height); - - void setJPEGInputFormat( - OMX_U32 width, OMX_U32 height, OMX_U32 compressedSize); - - void setMinBufferSize(OMX_U32 portIndex, OMX_U32 size); - - void setRawAudioFormat( - OMX_U32 portIndex, int32_t sampleRate, int32_t numChannels); - - status_t allocateBuffers(); - status_t allocateBuffersOnPort(OMX_U32 portIndex); - status_t allocateOutputBuffersFromNativeWindow(); - - status_t queueBufferToNativeWindow(BufferInfo *info); - status_t cancelBufferToNativeWindow(BufferInfo *info); - BufferInfo* dequeueBufferFromNativeWindow(); - status_t pushBlankBuffersToNativeWindow(); - - status_t freeBuffersOnPort( - OMX_U32 portIndex, bool onlyThoseWeOwn = false); - - status_t freeBuffer(OMX_U32 portIndex, size_t bufIndex); - - bool drainInputBuffer(IOMX::buffer_id buffer); - void fillOutputBuffer(IOMX::buffer_id buffer); - bool drainInputBuffer(BufferInfo *info); - void fillOutputBuffer(BufferInfo *info); - - void drainInputBuffers(); - void fillOutputBuffers(); - - bool drainAnyInputBuffer(); - BufferInfo *findInputBufferByDataPointer(void *ptr); - BufferInfo *findEmptyInputBuffer(); - - // Returns true iff a flush was initiated and a completion event is - // upcoming, false otherwise (A flush was not necessary as we own all - // the buffers on that port). - // This method will ONLY ever return false for a component with quirk - // "kRequiresFlushCompleteEmulation". - bool flushPortAsync(OMX_U32 portIndex); - - void disablePortAsync(OMX_U32 portIndex); - status_t enablePortAsync(OMX_U32 portIndex); - - static size_t countBuffersWeOwn(const Vector<BufferInfo> &buffers); - static bool isIntermediateState(State state); - - void onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2); - void onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data); - void onStateChange(OMX_STATETYPE newState); - void onPortSettingsChanged(OMX_U32 portIndex); - - void setState(State newState); - - status_t init(); - void initOutputFormat(const sp<MetaData> &inputFormat); - status_t initNativeWindow(); - - void initNativeWindowCrop(); - - void dumpPortStatus(OMX_U32 portIndex); - - status_t configureCodec(const sp<MetaData> &meta); - - void restorePatchedDataPointer(BufferInfo *info); - - status_t applyRotation(); - status_t waitForBufferFilled_l(); - - int64_t getDecodingTimeUs(); - - status_t parseAVCCodecSpecificData( - const void *data, size_t size, - unsigned *profile, unsigned *level); - - OMXCodec(const OMXCodec &); - OMXCodec &operator=(const OMXCodec &); -}; - -struct CodecCapabilities { - String8 mComponentName; - Vector<CodecProfileLevel> mProfileLevels; - Vector<OMX_U32> mColorFormats; -}; - -// Return a vector of componentNames with supported profile/level pairs -// supporting the given mime type, if queryDecoders==true, returns components -// that decode content of the given type, otherwise returns components -// that encode content of the given type. -// profile and level indications only make sense for h.263, mpeg4 and avc -// video. -// If hwCodecOnly==true, only returns hardware-based components, software and -// hardware otherwise. -// The profile/level values correspond to -// OMX_VIDEO_H263PROFILETYPE, OMX_VIDEO_MPEG4PROFILETYPE, -// OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263LEVELTYPE, OMX_VIDEO_MPEG4LEVELTYPE -// and OMX_VIDEO_AVCLEVELTYPE respectively. - -status_t QueryCodecs( - const sp<IOMX> &omx, - const char *mimeType, bool queryDecoders, bool hwCodecOnly, - Vector<CodecCapabilities> *results); - -status_t QueryCodecs( - const sp<IOMX> &omx, - const char *mimeType, bool queryDecoders, - Vector<CodecCapabilities> *results); - - -} // namespace android - -#endif // OMX_CODEC_H_ diff --git a/include/media/stagefright/SkipCutBuffer.h b/include/media/stagefright/SkipCutBuffer.h deleted file mode 100644 index 5c7cd47..0000000 --- a/include/media/stagefright/SkipCutBuffer.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SKIP_CUT_BUFFER_H_ - -#define SKIP_CUT_BUFFER_H_ - -#include <media/stagefright/MediaBuffer.h> - -namespace android { - -/** - * utility class to cut the start and end off a stream of data in MediaBuffers - * - */ -class SkipCutBuffer { - public: - // 'skip' is the number of bytes to skip from the beginning - // 'cut' is the number of bytes to cut from the end - // 'output_size' is the size in bytes of the MediaBuffers that will be used - SkipCutBuffer(int32_t skip, int32_t cut, int32_t output_size); - virtual ~SkipCutBuffer(); - - // Submit one MediaBuffer for skipping and cutting. This may consume all or - // some of the data in the buffer, or it may add data to it. - // After this, the caller should continue processing the buffer as usual. - void submit(MediaBuffer *buffer); - void clear(); - size_t size(); // how many bytes are currently stored in the buffer - - private: - void write(const char *src, size_t num); - size_t read(char *dst, size_t num); - int32_t mFrontPadding; - int32_t mBackPadding; - int32_t mWriteHead; - int32_t mReadHead; - int32_t mCapacity; - char* mCutBuffer; - DISALLOW_EVIL_CONSTRUCTORS(SkipCutBuffer); -}; - -} // namespace android - -#endif // OMX_CODEC_H_ diff --git a/include/media/stagefright/StagefrightMediaScanner.h b/include/media/stagefright/StagefrightMediaScanner.h deleted file mode 100644 index 6510a59..0000000 --- a/include/media/stagefright/StagefrightMediaScanner.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef STAGEFRIGHT_MEDIA_SCANNER_H_ - -#define STAGEFRIGHT_MEDIA_SCANNER_H_ - -#include <media/mediascanner.h> - -namespace android { - -struct StagefrightMediaScanner : public MediaScanner { - StagefrightMediaScanner(); - virtual ~StagefrightMediaScanner(); - - virtual MediaScanResult processFile( - const char *path, const char *mimeType, - MediaScannerClient &client); - - virtual char *extractAlbumArt(int fd); - -private: - StagefrightMediaScanner(const StagefrightMediaScanner &); - StagefrightMediaScanner &operator=(const StagefrightMediaScanner &); - - MediaScanResult processFileInternal( - const char *path, const char *mimeType, - MediaScannerClient &client); -}; - -} // namespace android - -#endif // STAGEFRIGHT_MEDIA_SCANNER_H_ diff --git a/include/media/stagefright/SurfaceMediaSource.h b/include/media/stagefright/SurfaceMediaSource.h deleted file mode 100644 index 936b057..0000000 --- a/include/media/stagefright/SurfaceMediaSource.h +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_GUI_SURFACEMEDIASOURCE_H -#define ANDROID_GUI_SURFACEMEDIASOURCE_H - -#include <gui/ISurfaceTexture.h> - -#include <utils/threads.h> -#include <utils/Vector.h> -#include <media/stagefright/MediaSource.h> -#include <media/stagefright/MediaBuffer.h> - -namespace android { -// ---------------------------------------------------------------------------- - -class IGraphicBufferAlloc; -class String8; -class GraphicBuffer; - -class SurfaceMediaSource : public BnSurfaceTexture, public MediaSource, - public MediaBufferObserver { -public: - enum { MIN_UNDEQUEUED_BUFFERS = 4 }; - enum { - MIN_ASYNC_BUFFER_SLOTS = MIN_UNDEQUEUED_BUFFERS + 1, - MIN_SYNC_BUFFER_SLOTS = MIN_UNDEQUEUED_BUFFERS - }; - enum { NUM_BUFFER_SLOTS = 32 }; - enum { NO_CONNECTED_API = 0 }; - - struct FrameAvailableListener : public virtual RefBase { - // onFrameAvailable() is called from queueBuffer() is the FIFO is - // empty. You can use SurfaceMediaSource::getQueuedCount() to - // figure out if there are more frames waiting. - // This is called without any lock held can be called concurrently by - // multiple threads. - virtual void onFrameAvailable() = 0; - }; - - SurfaceMediaSource(uint32_t bufW, uint32_t bufH); - - virtual ~SurfaceMediaSource(); - - - // For the MediaSource interface for use by StageFrightRecorder: - virtual status_t start(MetaData *params = NULL); - virtual status_t stop() { return reset(); } - virtual status_t read( - MediaBuffer **buffer, const ReadOptions *options = NULL); - virtual sp<MetaData> getFormat(); - - // Pass the metadata over to the buffer, call when you have the lock - void passMetadataBufferLocked(MediaBuffer **buffer); - bool checkBufferMatchesSlot(int slot, MediaBuffer *buffer); - - // Get / Set the frame rate used for encoding. Default fps = 30 - status_t setFrameRate(int32_t fps) ; - int32_t getFrameRate( ) const; - - // The call for the StageFrightRecorder to tell us that - // it is done using the MediaBuffer data so that its state - // can be set to FREE for dequeuing - virtual void signalBufferReturned(MediaBuffer* buffer); - // end of MediaSource interface - - uint32_t getBufferCount( ) const { return mBufferCount;} - - - // setBufferCount updates the number of available buffer slots. After - // calling this all buffer slots are both unallocated and owned by the - // SurfaceMediaSource object (i.e. they are not owned by the client). - virtual status_t setBufferCount(int bufferCount); - - virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf); - - // dequeueBuffer gets the next buffer slot index for the client to use. If a - // buffer slot is available then that slot index is written to the location - // pointed to by the buf argument and a status of OK is returned. If no - // slot is available then a status of -EBUSY is returned and buf is - // unmodified. - virtual status_t dequeueBuffer(int *buf, uint32_t w, uint32_t h, - uint32_t format, uint32_t usage); - - // queueBuffer returns a filled buffer to the SurfaceMediaSource. In addition, a - // timestamp must be provided for the buffer. The timestamp is in - // nanoseconds, and must be monotonically increasing. Its other semantics - // (zero point, etc) are client-dependent and should be documented by the - // client. - virtual status_t queueBuffer(int buf, int64_t timestamp, - uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform); - virtual void cancelBuffer(int buf); - - // onFrameReceivedLocked informs the buffer consumers (StageFrightRecorder) - // or listeners that a frame has been received - // The buffer is not made available for dequeueing immediately. We need to - // wait to hear from StageFrightRecorder to set the buffer FREE - // Make sure this is called when the mutex is locked - virtual status_t onFrameReceivedLocked(); - - virtual status_t setScalingMode(int mode) { return OK; } // no op for encoding - virtual int query(int what, int* value); - - // Just confirming to the ISurfaceTexture interface as of now - virtual status_t setCrop(const Rect& reg) { return OK; } - virtual status_t setTransform(uint32_t transform) {return OK;} - - // setSynchronousMode set whether dequeueBuffer is synchronous or - // asynchronous. In synchronous mode, dequeueBuffer blocks until - // a buffer is available, the currently bound buffer can be dequeued and - // queued buffers will be retired in order. - // The default mode is synchronous. - // TODO: Clarify the minute differences bet sycn /async - // modes (S.Encoder vis-a-vis SurfaceTexture) - virtual status_t setSynchronousMode(bool enabled); - - // connect attempts to connect a client API to the SurfaceMediaSource. This - // must be called before any other ISurfaceTexture methods are called except - // for getAllocator. - // - // This method will fail if the connect was previously called on the - // SurfaceMediaSource and no corresponding disconnect call was made. - virtual status_t connect(int api, - uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform); - - // disconnect attempts to disconnect a client API from the SurfaceMediaSource. - // Calling this method will cause any subsequent calls to other - // ISurfaceTexture methods to fail except for getAllocator and connect. - // Successfully calling connect after this will allow the other methods to - // succeed again. - // - // This method will fail if the the SurfaceMediaSource is not currently - // connected to the specified client API. - virtual status_t disconnect(int api); - - // getqueuedCount returns the number of queued frames waiting in the - // FIFO. In asynchronous mode, this always returns 0 or 1 since - // frames are not accumulating in the FIFO. - size_t getQueuedCount() const; - - // setBufferCountServer set the buffer count. If the client has requested - // a buffer count using setBufferCount, the server-buffer count will - // take effect once the client sets the count back to zero. - status_t setBufferCountServer(int bufferCount); - - // getTimestamp retrieves the timestamp associated with the image - // set by the most recent call to read() - // - // The timestamp is in nanoseconds, and is monotonically increasing. Its - // other semantics (zero point, etc) are source-dependent and should be - // documented by the source. - int64_t getTimestamp(); - - // setFrameAvailableListener sets the listener object that will be notified - // when a new frame becomes available. - void setFrameAvailableListener(const sp<FrameAvailableListener>& listener); - - // getCurrentBuffer returns the buffer associated with the current image. - sp<GraphicBuffer> getCurrentBuffer() const; - - // dump our state in a String - void dump(String8& result) const; - void dump(String8& result, const char* prefix, char* buffer, - size_t SIZE) const; - - // isMetaDataStoredInVideoBuffers tells the encoder whether we will - // pass metadata through the buffers. Currently, it is force set to true - bool isMetaDataStoredInVideoBuffers() const; - -protected: - - // freeAllBuffersLocked frees the resources (both GraphicBuffer and EGLImage) for - // all slots. - void freeAllBuffersLocked(); - static bool isExternalFormat(uint32_t format); - -private: - - status_t setBufferCountServerLocked(int bufferCount); - - enum { INVALID_BUFFER_SLOT = -1 }; - - struct BufferSlot { - - BufferSlot() - : mBufferState(BufferSlot::FREE), - mRequestBufferCalled(false), - mTimestamp(0) { - } - - // mGraphicBuffer points to the buffer allocated for this slot or is - // NULL if no buffer has been allocated. - sp<GraphicBuffer> mGraphicBuffer; - - // BufferState represents the different states in which a buffer slot - // can be. - enum BufferState { - // FREE indicates that the buffer is not currently being used and - // will not be used in the future until it gets dequeued and - // subseqently queued by the client. - FREE = 0, - - // DEQUEUED indicates that the buffer has been dequeued by the - // client, but has not yet been queued or canceled. The buffer is - // considered 'owned' by the client, and the server should not use - // it for anything. - // - // Note that when in synchronous-mode (mSynchronousMode == true), - // the buffer that's currently attached to the texture may be - // dequeued by the client. That means that the current buffer can - // be in either the DEQUEUED or QUEUED state. In asynchronous mode, - // however, the current buffer is always in the QUEUED state. - DEQUEUED = 1, - - // QUEUED indicates that the buffer has been queued by the client, - // and has not since been made available for the client to dequeue. - // Attaching the buffer to the texture does NOT transition the - // buffer away from the QUEUED state. However, in Synchronous mode - // the current buffer may be dequeued by the client under some - // circumstances. See the note about the current buffer in the - // documentation for DEQUEUED. - QUEUED = 2, - }; - - // mBufferState is the current state of this buffer slot. - BufferState mBufferState; - - // mRequestBufferCalled is used for validating that the client did - // call requestBuffer() when told to do so. Technically this is not - // needed but useful for debugging and catching client bugs. - bool mRequestBufferCalled; - - // mTimestamp is the current timestamp for this buffer slot. This gets - // to set by queueBuffer each time this slot is queued. - int64_t mTimestamp; - }; - - // mSlots is the array of buffer slots that must be mirrored on the client - // side. This allows buffer ownership to be transferred between the client - // and server without sending a GraphicBuffer over binder. The entire array - // is initialized to NULL at construction time, and buffers are allocated - // for a slot when requestBuffer is called with that slot's index. - BufferSlot mSlots[NUM_BUFFER_SLOTS]; - - // mDefaultWidth holds the default width of allocated buffers. It is used - // in requestBuffers() if a width and height of zero is specified. - uint32_t mDefaultWidth; - - // mDefaultHeight holds the default height of allocated buffers. It is used - // in requestBuffers() if a width and height of zero is specified. - uint32_t mDefaultHeight; - - // mPixelFormat holds the pixel format of allocated buffers. It is used - // in requestBuffers() if a format of zero is specified. - uint32_t mPixelFormat; - - // mBufferCount is the number of buffer slots that the client and server - // must maintain. It defaults to MIN_ASYNC_BUFFER_SLOTS and can be changed - // by calling setBufferCount or setBufferCountServer - int mBufferCount; - - // mClientBufferCount is the number of buffer slots requested by the - // client. The default is zero, which means the client doesn't care how - // many buffers there are - int mClientBufferCount; - - // mServerBufferCount buffer count requested by the server-side - int mServerBufferCount; - - // mCurrentSlot is the buffer slot index of the buffer that is currently - // being used by buffer consumer - // (e.g. StageFrightRecorder in the case of SurfaceMediaSource or GLTexture - // in the case of SurfaceTexture). - // It is initialized to INVALID_BUFFER_SLOT, - // indicating that no buffer slot is currently bound to the texture. Note, - // however, that a value of INVALID_BUFFER_SLOT does not necessarily mean - // that no buffer is bound to the texture. A call to setBufferCount will - // reset mCurrentTexture to INVALID_BUFFER_SLOT. - int mCurrentSlot; - - - // mCurrentBuf is the graphic buffer of the current slot to be used by - // buffer consumer. It's possible that this buffer is not associated - // with any buffer slot, so we must track it separately in order to - // properly use IGraphicBufferAlloc::freeAllGraphicBuffersExcept. - sp<GraphicBuffer> mCurrentBuf; - - - // mCurrentTimestamp is the timestamp for the current texture. It - // gets set to mLastQueuedTimestamp each time updateTexImage is called. - int64_t mCurrentTimestamp; - - // mGraphicBufferAlloc is the connection to SurfaceFlinger that is used to - // allocate new GraphicBuffer objects. - sp<IGraphicBufferAlloc> mGraphicBufferAlloc; - - // mFrameAvailableListener is the listener object that will be called when a - // new frame becomes available. If it is not NULL it will be called from - // queueBuffer. - sp<FrameAvailableListener> mFrameAvailableListener; - - // mSynchronousMode whether we're in synchronous mode or not - bool mSynchronousMode; - - // mConnectedApi indicates the API that is currently connected to this - // SurfaceTexture. It defaults to NO_CONNECTED_API (= 0), and gets updated - // by the connect and disconnect methods. - int mConnectedApi; - - // mDequeueCondition condition used for dequeueBuffer in synchronous mode - mutable Condition mDequeueCondition; - - - // mQueue is a FIFO of queued buffers used in synchronous mode - typedef Vector<int> Fifo; - Fifo mQueue; - - // mMutex is the mutex used to prevent concurrent access to the member - // variables of SurfaceMediaSource objects. It must be locked whenever the - // member variables are accessed. - mutable Mutex mMutex; - - ////////////////////////// For MediaSource - // Set to a default of 30 fps if not specified by the client side - int32_t mFrameRate; - - // mStopped is a flag to check if the recording is going on - bool mStopped; - - // mNumFramesReceived indicates the number of frames recieved from - // the client side - int mNumFramesReceived; - // mNumFramesEncoded indicates the number of frames passed on to the - // encoder - int mNumFramesEncoded; - - // mFirstFrameTimestamp is the timestamp of the first received frame. - // It is used to offset the output timestamps so recording starts at time 0. - int64_t mFirstFrameTimestamp; - // mStartTimeNs is the start time passed into the source at start, used to - // offset timestamps. - int64_t mStartTimeNs; - - // mFrameAvailableCondition condition used to indicate whether there - // is a frame available for dequeuing - Condition mFrameAvailableCondition; - Condition mFrameCompleteCondition; - - status_t reset(); - - // Avoid copying and equating and default constructor - DISALLOW_IMPLICIT_CONSTRUCTORS(SurfaceMediaSource); -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_SURFACEMEDIASOURCE_H diff --git a/include/media/stagefright/TimeSource.h b/include/media/stagefright/TimeSource.h deleted file mode 100644 index 443673d..0000000 --- a/include/media/stagefright/TimeSource.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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_ diff --git a/include/media/stagefright/Utils.h b/include/media/stagefright/Utils.h deleted file mode 100644 index 498b525..0000000 --- a/include/media/stagefright/Utils.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef UTILS_H_ - -#define UTILS_H_ - -#include <stdint.h> - -namespace android { - -#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); - -} // namespace android - -#endif // UTILS_H_ diff --git a/include/media/stagefright/VideoSourceDownSampler.h b/include/media/stagefright/VideoSourceDownSampler.h deleted file mode 100644 index 439918c..0000000 --- a/include/media/stagefright/VideoSourceDownSampler.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// VideoSourceDownSampler implements the MediaSource interface, -// downsampling frames provided from a real video source. - -#ifndef VIDEO_SOURCE_DOWN_SAMPLER_H_ - -#define VIDEO_SOURCE_DOWN_SAMPLER_H_ - -#include <media/stagefright/MediaSource.h> -#include <utils/RefBase.h> - -namespace android { - -class IMemory; -class MediaBuffer; -class MetaData; - -class VideoSourceDownSampler : public MediaSource { -public: - virtual ~VideoSourceDownSampler(); - - // Constructor: - // videoSource: The real video source which provides the original frames. - // width, height: The desired width, height. These should be less than or equal - // to those of the real video source. We then downsample the original frames to - // this size. - VideoSourceDownSampler(const sp<MediaSource> &videoSource, - int32_t width, int32_t height); - - // MediaSource interface - 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(); - -private: - // Reference to the real video source. - sp<MediaSource> mRealVideoSource; - - // Size of frames to be provided by this source. - int32_t mWidth; - int32_t mHeight; - - // Size of frames provided by the real source. - int32_t mRealSourceWidth; - int32_t mRealSourceHeight; - - // Down sampling paramters. - int32_t mDownSampleOffsetX; - int32_t mDownSampleOffsetY; - int32_t mDownSampleSkipX; - int32_t mDownSampleSkipY; - - // True if we need to crop the still video image to get the video frame. - bool mNeedDownSampling; - - // Meta data. This is a copy of the real source except for the width and - // height parameters. - sp<MetaData> mMeta; - - // Computes the offset, skip parameters for downsampling the original frame - // to the desired size. - void computeDownSamplingParameters(); - - // Downsamples the frame in sourceBuffer to size (mWidth x mHeight). A new - // buffer is created which stores the downsampled image. - void downSampleYUVImage(const MediaBuffer &sourceBuffer, MediaBuffer **buffer) const; - - // Disallow these. - VideoSourceDownSampler(const VideoSourceDownSampler &); - VideoSourceDownSampler &operator=(const VideoSourceDownSampler &); -}; - -} // namespace android - -#endif // VIDEO_SOURCE_DOWN_SAMPLER_H_ diff --git a/include/media/stagefright/YUVCanvas.h b/include/media/stagefright/YUVCanvas.h deleted file mode 100644 index ff70923..0000000 --- a/include/media/stagefright/YUVCanvas.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// YUVCanvas holds a reference to a YUVImage on which it can do various -// drawing operations. It provides various utility functions for filling, -// cropping, etc. - - -#ifndef YUV_CANVAS_H_ - -#define YUV_CANVAS_H_ - -#include <stdint.h> - -namespace android { - -class YUVImage; -class Rect; - -class YUVCanvas { -public: - - // Constructor takes in reference to a yuvImage on which it can do - // various drawing opreations. - YUVCanvas(YUVImage &yuvImage); - ~YUVCanvas(); - - // Fills the entire image with the given YUV values. - void FillYUV(uint8_t yValue, uint8_t uValue, uint8_t vValue); - - // Fills the rectangular region [startX,endX]x[startY,endY] with the given YUV values. - void FillYUVRectangle(const Rect& rect, - uint8_t yValue, uint8_t uValue, uint8_t vValue); - - // Copies the region [startX,endX]x[startY,endY] from srcImage into the - // canvas' target image (mYUVImage) starting at - // (destinationStartX,destinationStartY). - // Note that undefined behavior may occur if srcImage is same as the canvas' - // target image. - void CopyImageRect( - const Rect& srcRect, - int32_t destStartX, int32_t destStartY, - const YUVImage &srcImage); - - // Downsamples the srcImage into the canvas' target image (mYUVImage) - // The downsampling copies pixels from the source image starting at - // (srcOffsetX, srcOffsetY) to the target image, starting at (0, 0). - // For each X increment in the target image, skipX pixels are skipped - // in the source image. - // Similarly for each Y increment in the target image, skipY pixels - // are skipped in the source image. - void downsample( - int32_t srcOffsetX, int32_t srcOffsetY, - int32_t skipX, int32_t skipY, - const YUVImage &srcImage); - -private: - YUVImage& mYUVImage; - - YUVCanvas(const YUVCanvas &); - YUVCanvas &operator=(const YUVCanvas &); -}; - -} // namespace android - -#endif // YUV_CANVAS_H_ diff --git a/include/media/stagefright/YUVImage.h b/include/media/stagefright/YUVImage.h deleted file mode 100644 index 4e98618..0000000 --- a/include/media/stagefright/YUVImage.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// A container class to hold YUV data and provide various utilities, -// e.g. to set/get pixel values. -// Supported formats: -// - YUV420 Planar -// - YUV420 Semi Planar -// -// Currently does not support variable strides. -// -// Implementation: Two simple abstractions are done to simplify access -// to YUV channels for different formats: -// - initializeYUVPointers() sets up pointers (mYdata, mUdata, mVdata) to -// point to the right start locations of the different channel data depending -// on the format. -// - getOffsets() returns the correct offset for the different channels -// depending on the format. -// Location of any pixel's YUV channels can then be easily computed using these. -// - -#ifndef YUV_IMAGE_H_ - -#define YUV_IMAGE_H_ - -#include <stdint.h> -#include <cstring> - -namespace android { - -class Rect; - -class YUVImage { -public: - // Supported YUV formats - enum YUVFormat { - YUV420Planar, - YUV420SemiPlanar - }; - - // Constructs an image with the given size, format. Also allocates and owns - // the required memory. - YUVImage(YUVFormat yuvFormat, int32_t width, int32_t height); - - // Constructs an image with the given size, format. The memory is provided - // by the caller and we don't own it. - YUVImage(YUVFormat yuvFormat, int32_t width, int32_t height, uint8_t *buffer); - - // Destructor to delete the memory if it owns it. - ~YUVImage(); - - // Returns the size of the buffer required to store the YUV data for the given - // format and geometry. Useful when the caller wants to allocate the requisite - // memory. - static size_t bufferSize(YUVFormat yuvFormat, int32_t width, int32_t height); - - int32_t width() const {return mWidth;} - int32_t height() const {return mHeight;} - - // Returns true if pixel is the range [0, width-1] x [0, height-1] - // and false otherwise. - bool validPixel(int32_t x, int32_t y) const; - - // Get the pixel YUV value at pixel (x,y). - // Note that the range of x is [0, width-1] and the range of y is [0, height-1]. - // Returns true if get was successful and false otherwise. - bool getPixelValue(int32_t x, int32_t y, - uint8_t *yPtr, uint8_t *uPtr, uint8_t *vPtr) const; - - // Set the pixel YUV value at pixel (x,y). - // Note that the range of x is [0, width-1] and the range of y is [0, height-1]. - // Returns true if set was successful and false otherwise. - bool setPixelValue(int32_t x, int32_t y, - uint8_t yValue, uint8_t uValue, uint8_t vValue); - - // Uses memcpy to copy an entire row of data - static void fastCopyRectangle420Planar( - const Rect& srcRect, - int32_t destStartX, int32_t destStartY, - const YUVImage &srcImage, YUVImage &destImage); - - // Uses memcpy to copy an entire row of data - static void fastCopyRectangle420SemiPlanar( - const Rect& srcRect, - int32_t destStartX, int32_t destStartY, - const YUVImage &srcImage, YUVImage &destImage); - - // Tries to use memcopy to copy entire rows of data. - // Returns false if fast copy is not possible for the passed image formats. - static bool fastCopyRectangle( - const Rect& srcRect, - int32_t destStartX, int32_t destStartY, - const YUVImage &srcImage, YUVImage &destImage); - - // Convert the given YUV value to RGB. - void yuv2rgb(uint8_t yValue, uint8_t uValue, uint8_t vValue, - uint8_t *r, uint8_t *g, uint8_t *b) const; - - // Write the image to a human readable PPM file. - // Returns true if write was succesful and false otherwise. - bool writeToPPM(const char *filename) const; - -private: - // YUV Format of the image. - YUVFormat mYUVFormat; - - int32_t mWidth; - int32_t mHeight; - - // Pointer to the memory buffer. - uint8_t *mBuffer; - - // Boolean telling whether we own the memory buffer. - bool mOwnBuffer; - - // Pointer to start of the Y data plane. - uint8_t *mYdata; - - // Pointer to start of the U data plane. Note that in case of interleaved formats like - // YUV420 semiplanar, mUdata points to the start of the U data in the UV plane. - uint8_t *mUdata; - - // Pointer to start of the V data plane. Note that in case of interleaved formats like - // YUV420 semiplanar, mVdata points to the start of the V data in the UV plane. - uint8_t *mVdata; - - // Initialize the pointers mYdata, mUdata, mVdata to point to the right locations for - // the given format and geometry. - // Returns true if initialize was succesful and false otherwise. - bool initializeYUVPointers(); - - // For the given pixel location, this returns the offset of the location of y, u and v - // data from the corresponding base pointers -- mYdata, mUdata, mVdata. - // Note that the range of x is [0, width-1] and the range of y is [0, height-1]. - // Returns true if getting offsets was succesful and false otherwise. - bool getOffsets(int32_t x, int32_t y, - int32_t *yOffset, int32_t *uOffset, int32_t *vOffset) const; - - // Returns the offset increments incurred in going from one data row to the next data row - // for the YUV channels. Note that this corresponds to data rows and not pixel rows. - // E.g. depending on formats, U/V channels may have only one data row corresponding - // to two pixel rows. - bool getOffsetIncrementsPerDataRow( - int32_t *yDataOffsetIncrement, - int32_t *uDataOffsetIncrement, - int32_t *vDataOffsetIncrement) const; - - // Given the offset return the address of the corresponding channel's data. - uint8_t* getYAddress(int32_t offset) const; - uint8_t* getUAddress(int32_t offset) const; - uint8_t* getVAddress(int32_t offset) const; - - // Given the pixel location, returns the address of the corresponding channel's data. - // Note that the range of x is [0, width-1] and the range of y is [0, height-1]. - bool getYUVAddresses(int32_t x, int32_t y, - uint8_t **yAddr, uint8_t **uAddr, uint8_t **vAddr) const; - - // Disallow implicit casting and copying. - YUVImage(const YUVImage &); - YUVImage &operator=(const YUVImage &); -}; - -} // namespace android - -#endif // YUV_IMAGE_H_ diff --git a/include/media/stagefright/foundation/AAtomizer.h b/include/media/stagefright/foundation/AAtomizer.h deleted file mode 100644 index 5f3a678..0000000 --- a/include/media/stagefright/foundation/AAtomizer.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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_ diff --git a/include/media/stagefright/foundation/ABase.h b/include/media/stagefright/foundation/ABase.h deleted file mode 100644 index 9eceea3..0000000 --- a/include/media/stagefright/foundation/ABase.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef A_BASE_H_ - -#define A_BASE_H_ - -#define DISALLOW_EVIL_CONSTRUCTORS(name) \ - name(const name &); \ - name &operator=(const name &) - -#endif // A_BASE_H_ diff --git a/include/media/stagefright/foundation/ABitReader.h b/include/media/stagefright/foundation/ABitReader.h deleted file mode 100644 index 5510b12..0000000 --- a/include/media/stagefright/foundation/ABitReader.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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); - - void putBits(uint32_t x, 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(); - - DISALLOW_EVIL_CONSTRUCTORS(ABitReader); -}; - -} // namespace android - -#endif // A_BIT_READER_H_ diff --git a/include/media/stagefright/foundation/ABuffer.h b/include/media/stagefright/foundation/ABuffer.h deleted file mode 100644 index 28f0aed..0000000 --- a/include/media/stagefright/foundation/ABuffer.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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_ diff --git a/include/media/stagefright/foundation/ADebug.h b/include/media/stagefright/foundation/ADebug.h deleted file mode 100644 index 450dcfe..0000000 --- a/include/media/stagefright/foundation/ADebug.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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), \ - "%s", \ - __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()) { \ - AString ___full = \ - __FILE__ ":" LITERAL_TO_STRING(__LINE__) \ - " CHECK_" #suffix "( " #x "," #y ") failed: "; \ - ___full.append(___res); \ - \ - LOG_ALWAYS_FATAL("%s", ___full.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( \ - __FILE__ ":" LITERAL_TO_STRING(__LINE__) \ - " Should not be here."); - -} // namespace android - -#endif // A_DEBUG_H_ - diff --git a/include/media/stagefright/foundation/AHandler.h b/include/media/stagefright/foundation/AHandler.h deleted file mode 100644 index b008b54..0000000 --- a/include/media/stagefright/foundation/AHandler.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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_ diff --git a/include/media/stagefright/foundation/AHandlerReflector.h b/include/media/stagefright/foundation/AHandlerReflector.h deleted file mode 100644 index 9d201b5..0000000 --- a/include/media/stagefright/foundation/AHandlerReflector.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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_ diff --git a/include/media/stagefright/foundation/AHierarchicalStateMachine.h b/include/media/stagefright/foundation/AHierarchicalStateMachine.h deleted file mode 100644 index d2e6b28..0000000 --- a/include/media/stagefright/foundation/AHierarchicalStateMachine.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef A_HIERARCHICAL_STATE_MACHINE_H_ - -#define A_HIERARCHICAL_STATE_MACHINE_H_ - -#include <media/stagefright/foundation/AHandler.h> - -namespace android { - -struct AState : public RefBase { - AState(const sp<AState> &parentState = NULL); - - sp<AState> parentState(); - -protected: - virtual ~AState(); - - virtual void stateEntered(); - virtual void stateExited(); - - virtual bool onMessageReceived(const sp<AMessage> &msg) = 0; - -private: - friend struct AHierarchicalStateMachine; - - sp<AState> mParentState; - - DISALLOW_EVIL_CONSTRUCTORS(AState); -}; - -struct AHierarchicalStateMachine : public AHandler { - AHierarchicalStateMachine(); - -protected: - virtual ~AHierarchicalStateMachine(); - - virtual void onMessageReceived(const sp<AMessage> &msg); - - // Only to be called in response to a message. - void changeState(const sp<AState> &state); - -private: - sp<AState> mState; - - DISALLOW_EVIL_CONSTRUCTORS(AHierarchicalStateMachine); -}; - -} // namespace android - -#endif // A_HIERARCHICAL_STATE_MACHINE_H_ diff --git a/include/media/stagefright/foundation/ALooper.h b/include/media/stagefright/foundation/ALooper.h deleted file mode 100644 index 70e0c5e..0000000 --- a/include/media/stagefright/foundation/ALooper.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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_ diff --git a/include/media/stagefright/foundation/ALooperRoster.h b/include/media/stagefright/foundation/ALooperRoster.h deleted file mode 100644 index 2e5fd73..0000000 --- a/include/media/stagefright/foundation/ALooperRoster.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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); - - status_t postMessage(const sp<AMessage> &msg, int64_t delayUs = 0); - void deliverMessage(const sp<AMessage> &msg); - - status_t postAndAwaitResponse( - const sp<AMessage> &msg, sp<AMessage> *response); - - void postReply(uint32_t replyID, const sp<AMessage> &reply); - - 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; - uint32_t mNextReplyID; - Condition mRepliesCondition; - - KeyedVector<uint32_t, sp<AMessage> > mReplies; - - status_t postMessage_l(const sp<AMessage> &msg, int64_t delayUs); - - DISALLOW_EVIL_CONSTRUCTORS(ALooperRoster); -}; - -} // namespace android - -#endif // A_LOOPER_ROSTER_H_ diff --git a/include/media/stagefright/foundation/AMessage.h b/include/media/stagefright/foundation/AMessage.h deleted file mode 100644 index e5416e4..0000000 --- a/include/media/stagefright/foundation/AMessage.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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 ABuffer; -struct AString; -struct Parcel; - -struct AMessage : public RefBase { - AMessage(uint32_t what = 0, ALooper::handler_id target = 0); - - static sp<AMessage> FromParcel(const Parcel &parcel); - void writeToParcel(Parcel *parcel) const; - - void setWhat(uint32_t what); - uint32_t what() const; - - void setTarget(ALooper::handler_id target); - ALooper::handler_id target() const; - - void clear(); - - 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 setBuffer(const char *name, const sp<ABuffer> &buffer); - void setMessage(const char *name, const sp<AMessage> &obj); - - void setRect( - const char *name, - int32_t left, int32_t top, int32_t right, int32_t bottom); - - 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 findBuffer(const char *name, sp<ABuffer> *buffer) const; - bool findMessage(const char *name, sp<AMessage> *obj) const; - - bool findRect( - const char *name, - int32_t *left, int32_t *top, int32_t *right, int32_t *bottom) const; - - void post(int64_t delayUs = 0); - - // Posts the message to its target and waits for a response (or error) - // before returning. - status_t postAndAwaitResponse(sp<AMessage> *response); - - // If this returns true, the sender of this message is synchronously - // awaiting a response, the "replyID" can be used to send the response - // via "postReply" below. - bool senderAwaitsResponse(uint32_t *replyID) const; - - void postReply(uint32_t replyID); - - // Performs a deep-copy of "this", contained messages are in turn "dup'ed". - // Warning: RefBase items, i.e. "objects" are _not_ copied but only have - // their refcount incremented. - sp<AMessage> dup() const; - - AString debugString(int32_t indent = 0) const; - - enum Type { - kTypeInt32, - kTypeInt64, - kTypeSize, - kTypeFloat, - kTypeDouble, - kTypePointer, - kTypeString, - kTypeObject, - kTypeMessage, - kTypeRect, - kTypeBuffer, - }; - - size_t countEntries() const; - const char *getEntryNameAt(size_t index, Type *type) const; - -protected: - virtual ~AMessage(); - -private: - uint32_t mWhat; - ALooper::handler_id mTarget; - - struct Rect { - int32_t mLeft, mTop, mRight, mBottom; - }; - - struct Item { - union { - int32_t int32Value; - int64_t int64Value; - size_t sizeValue; - float floatValue; - double doubleValue; - void *ptrValue; - RefBase *refValue; - AString *stringValue; - Rect rectValue; - } u; - const char *mName; - Type mType; - }; - - enum { - kMaxNumItems = 32 - }; - Item mItems[kMaxNumItems]; - size_t mNumItems; - - Item *allocateItem(const char *name); - void freeItem(Item *item); - const Item *findItem(const char *name, Type type) const; - - void setObjectInternal( - const char *name, const sp<RefBase> &obj, Type type); - - DISALLOW_EVIL_CONSTRUCTORS(AMessage); -}; - -} // namespace android - -#endif // A_MESSAGE_H_ diff --git a/include/media/stagefright/foundation/AString.h b/include/media/stagefright/foundation/AString.h deleted file mode 100644 index 0f8f1e1..0000000 --- a/include/media/stagefright/foundation/AString.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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; - bool endsWith(const char *suffix) 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_ - diff --git a/include/media/stagefright/foundation/base64.h b/include/media/stagefright/foundation/base64.h deleted file mode 100644 index e340b89..0000000 --- a/include/media/stagefright/foundation/base64.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef 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_ diff --git a/include/media/stagefright/foundation/hexdump.h b/include/media/stagefright/foundation/hexdump.h deleted file mode 100644 index f6083a9..0000000 --- a/include/media/stagefright/foundation/hexdump.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef HEXDUMP_H_ - -#define HEXDUMP_H_ - -#include <sys/types.h> - -namespace android { - -void hexdump(const void *_data, size_t size); - -} // namespace android - -#endif // HEXDUMP_H_ diff --git a/include/media/stagefright/timedtext/TimedTextDriver.h b/include/media/stagefright/timedtext/TimedTextDriver.h deleted file mode 100644 index b9752df..0000000 --- a/include/media/stagefright/timedtext/TimedTextDriver.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TIMED_TEXT_DRIVER_H_ -#define TIMED_TEXT_DRIVER_H_ - -#include <media/stagefright/foundation/ABase.h> // for DISALLOW_* macro -#include <utils/Errors.h> // for status_t -#include <utils/RefBase.h> -#include <utils/threads.h> - -namespace android { - -class ALooper; -class MediaPlayerBase; -class MediaSource; -class Parcel; -class TimedTextPlayer; -class TimedTextSource; - -class TimedTextDriver { -public: - TimedTextDriver(const wp<MediaPlayerBase> &listener); - - ~TimedTextDriver(); - - status_t start(); - status_t pause(); - status_t selectTrack(int32_t index); - status_t unselectTrack(int32_t index); - - status_t seekToAsync(int64_t timeUs); - - status_t addInBandTextSource(const sp<MediaSource>& source); - status_t addOutOfBandTextSource(const char *uri, const char *mimeType); - // Caller owns the file desriptor and caller is responsible for closing it. - status_t addOutOfBandTextSource( - int fd, off64_t offset, size_t length, const char *mimeType); - - void getTrackInfo(Parcel *parcel); - -private: - Mutex mLock; - - enum State { - UNINITIALIZED, - PLAYING, - PAUSED, - }; - - sp<ALooper> mLooper; - sp<TimedTextPlayer> mPlayer; - wp<MediaPlayerBase> mListener; - - // Variables to be guarded by mLock. - State mState; - int32_t mCurrentTrackIndex; - Vector<sp<TimedTextSource> > mTextSourceVector; - // -- End of variables to be guarded by mLock - - status_t selectTrack_l(int32_t index); - - DISALLOW_EVIL_CONSTRUCTORS(TimedTextDriver); -}; - -} // namespace android - -#endif // TIMED_TEXT_DRIVER_H_ diff --git a/include/private/media/AudioEffectShared.h b/include/private/media/AudioEffectShared.h deleted file mode 100644 index a3a99a4..0000000 --- a/include/private/media/AudioEffectShared.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_EFFECTCBASESHARED_H -#define ANDROID_EFFECTCBASESHARED_H - -#include <stdint.h> -#include <sys/types.h> - -#include <utils/threads.h> - -namespace android { - -// ---------------------------------------------------------------------------- - -// Size of buffer used to exchange parameters between application and mediaserver processes. -#define EFFECT_PARAM_BUFFER_SIZE 1024 - - -// Shared memory area used to exchange parameters between application and mediaserver -// process. -struct effect_param_cblk_t -{ - Mutex lock; - volatile uint32_t clientIndex; // Current read/write index for application - volatile uint32_t serverIndex; // Current read/write index for mediaserver - uint8_t* buffer; // start of parameter buffer - - effect_param_cblk_t() - : lock(Mutex::SHARED), clientIndex(0), serverIndex(0) {} -}; - - -// ---------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_EFFECTCBASESHARED_H diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h deleted file mode 100644 index af2db93..0000000 --- a/include/private/media/AudioTrackShared.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_AUDIO_TRACK_SHARED_H -#define ANDROID_AUDIO_TRACK_SHARED_H - -#include <stdint.h> -#include <sys/types.h> - -#include <utils/threads.h> - -namespace android { - -// ---------------------------------------------------------------------------- - -// Maximum cumulated timeout milliseconds before restarting audioflinger thread -#define MAX_STARTUP_TIMEOUT_MS 3000 // Longer timeout period at startup to cope with A2DP init time -#define MAX_RUN_TIMEOUT_MS 1000 -#define WAIT_PERIOD_MS 10 -#define RESTORE_TIMEOUT_MS 5000 // Maximum waiting time for a track to be restored - -#define CBLK_UNDERRUN_MSK 0x0001 -#define CBLK_UNDERRUN_ON 0x0001 // underrun (out) or overrrun (in) indication -#define CBLK_UNDERRUN_OFF 0x0000 // no underrun -#define CBLK_DIRECTION_MSK 0x0002 -#define CBLK_DIRECTION_OUT 0x0002 // this cblk is for an AudioTrack -#define CBLK_DIRECTION_IN 0x0000 // this cblk is for an AudioRecord -#define CBLK_FORCEREADY_MSK 0x0004 -#define CBLK_FORCEREADY_ON 0x0004 // track is considered ready immediately by AudioFlinger -#define CBLK_FORCEREADY_OFF 0x0000 // track is ready when buffer full -#define CBLK_INVALID_MSK 0x0008 -#define CBLK_INVALID_ON 0x0008 // track buffer is invalidated by AudioFlinger: -#define CBLK_INVALID_OFF 0x0000 // must be re-created -#define CBLK_DISABLED_MSK 0x0010 -#define CBLK_DISABLED_ON 0x0010 // track disabled by AudioFlinger due to underrun: -#define CBLK_DISABLED_OFF 0x0000 // must be re-started -#define CBLK_RESTORING_MSK 0x0020 -#define CBLK_RESTORING_ON 0x0020 // track is being restored after invalidation -#define CBLK_RESTORING_OFF 0x0000 // by AudioFlinger -#define CBLK_RESTORED_MSK 0x0040 -#define CBLK_RESTORED_ON 0x0040 // track has been restored after invalidation -#define CBLK_RESTORED_OFF 0x0040 // by AudioFlinger - -// Important: do not add any virtual methods, including ~ -struct audio_track_cblk_t -{ - - // The data members are grouped so that members accessed frequently and in the same context - // are in the same line of data cache. - Mutex lock; // sizeof(int) - Condition cv; // sizeof(int) - - // next 4 are offsets within "buffers" - volatile uint32_t user; - volatile uint32_t server; - uint32_t userBase; - uint32_t serverBase; - - // if there is a shared buffer, "buffers" is the value of pointer() for the shared - // buffer, otherwise "buffers" points immediately after the control block - void* buffers; - uint32_t frameCount; - - // Cache line boundary - - uint32_t loopStart; - uint32_t loopEnd; // read-only for server, read/write for client - int loopCount; // read/write for client - - // Channel volumes are fixed point U4.12, so 0x1000 means 1.0. - // Left channel is in [0:15], right channel is in [16:31]. - // Always read and write the combined pair atomically. - // For AudioTrack only, not used by AudioRecord. -private: - uint32_t mVolumeLR; -public: - - uint32_t sampleRate; - - // NOTE: audio_track_cblk_t::frameSize is not equal to AudioTrack::frameSize() for - // 8 bit PCM data: in this case, mCblk->frameSize is based on a sample size of - // 16 bit because data is converted to 16 bit before being stored in buffer - - // read-only for client, server writes once at initialization and is then read-only - uint8_t frameSize; // would normally be size_t, but 8 bits is plenty - - // never used - uint8_t pad1; - - // used by client only - uint16_t bufferTimeoutMs; // Maximum cumulated timeout before restarting audioflinger - - uint16_t waitTimeMs; // Cumulated wait time, used by client only -private: - // client write-only, server read-only - uint16_t mSendLevel; // Fixed point U4.12 so 0x1000 means 1.0 -public: - volatile int32_t flags; - - // Cache line boundary (32 bytes) - - // Since the control block is always located in shared memory, this constructor - // is only used for placement new(). It is never used for regular new() or stack. - audio_track_cblk_t(); - uint32_t stepUser(uint32_t frameCount); // called by client only, where - // client includes regular AudioTrack and AudioFlinger::PlaybackThread::OutputTrack - bool stepServer(uint32_t frameCount); // called by server only - void* buffer(uint32_t offset) const; - uint32_t framesAvailable(); - uint32_t framesAvailable_l(); - uint32_t framesReady(); // called by server only - bool tryLock(); - - // No barriers on the following operations, so the ordering of loads/stores - // with respect to other parameters is UNPREDICTABLE. That's considered safe. - - // for AudioTrack client only, caller must limit to 0.0 <= sendLevel <= 1.0 - void setSendLevel(float sendLevel) { - mSendLevel = uint16_t(sendLevel * 0x1000); - } - - // for AudioFlinger only; the return value must be validated by the caller - uint16_t getSendLevel_U4_12() const { - return mSendLevel; - } - - // for AudioTrack client only, caller must limit to 0 <= volumeLR <= 0x10001000 - void setVolumeLR(uint32_t volumeLR) { - mVolumeLR = volumeLR; - } - - // for AudioFlinger only; the return value must be validated by the caller - uint32_t getVolumeLR() const { - return mVolumeLR; - } - -}; - - -// ---------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_AUDIO_TRACK_SHARED_H diff --git a/include/private/media/VideoFrame.h b/include/private/media/VideoFrame.h deleted file mode 100644 index 0ecc348..0000000 --- a/include/private/media/VideoFrame.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -** -** Copyright (C) 2008 The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -#ifndef ANDROID_VIDEO_FRAME_H -#define ANDROID_VIDEO_FRAME_H - -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <utils/Log.h> - -namespace android { - -// A simple buffer to hold binary data -class MediaAlbumArt -{ -public: - MediaAlbumArt(): mSize(0), mData(0) {} - - explicit MediaAlbumArt(const char* url) { - mSize = 0; - mData = NULL; - FILE *in = fopen(url, "r"); - if (!in) { - return; - } - fseek(in, 0, SEEK_END); - mSize = ftell(in); // Allocating buffer of size equals to the external file size. - if (mSize == 0 || (mData = new uint8_t[mSize]) == NULL) { - fclose(in); - if (mSize != 0) { - mSize = 0; - } - return; - } - rewind(in); - if (fread(mData, 1, mSize, in) != mSize) { // Read failed. - delete[] mData; - mData = NULL; - mSize = 0; - return; - } - fclose(in); - } - - MediaAlbumArt(const MediaAlbumArt& copy) { - mSize = copy.mSize; - mData = NULL; // initialize it first - if (mSize > 0 && copy.mData != NULL) { - mData = new uint8_t[copy.mSize]; - if (mData != NULL) { - memcpy(mData, copy.mData, mSize); - } else { - mSize = 0; - } - } - } - - ~MediaAlbumArt() { - if (mData != 0) { - delete[] mData; - } - } - - // Intentional public access modifier: - // We have to know the internal structure in order to share it between - // processes? - uint32_t mSize; // Number of bytes in mData - uint8_t* mData; // Actual binary data -}; - -// Represents a color converted (RGB-based) video frame -// with bitmap pixels stored in FrameBuffer -class VideoFrame -{ -public: - VideoFrame(): mWidth(0), mHeight(0), mDisplayWidth(0), mDisplayHeight(0), mSize(0), mData(0) {} - - VideoFrame(const VideoFrame& copy) { - mWidth = copy.mWidth; - mHeight = copy.mHeight; - mDisplayWidth = copy.mDisplayWidth; - mDisplayHeight = copy.mDisplayHeight; - mSize = copy.mSize; - mData = NULL; // initialize it first - if (mSize > 0 && copy.mData != NULL) { - mData = new uint8_t[mSize]; - if (mData != NULL) { - memcpy(mData, copy.mData, mSize); - } else { - mSize = 0; - } - } - } - - ~VideoFrame() { - if (mData != 0) { - delete[] mData; - } - } - - // Intentional public access modifier: - uint32_t mWidth; - uint32_t mHeight; - uint32_t mDisplayWidth; - uint32_t mDisplayHeight; - uint32_t mSize; // Number of bytes in mData - uint8_t* mData; // Actual binary data - int32_t mRotationAngle; // rotation angle, clockwise -}; - -}; // namespace android - -#endif // ANDROID_VIDEO_FRAME_H |