summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/camera/CameraParameters.h3
-rw-r--r--include/camera/ICameraService.h26
-rw-r--r--include/camera/ICameraServiceListener.h26
-rw-r--r--include/camera/IProCameraCallbacks.h71
-rw-r--r--include/camera/IProCameraUser.h100
-rw-r--r--include/camera/ProCamera.h319
-rw-r--r--include/camera/camera2/ICameraDeviceUser.h7
-rw-r--r--include/camera/camera2/OutputConfiguration.h51
-rw-r--r--include/media/AudioRecord.h10
-rw-r--r--include/media/AudioResamplerPublic.h13
-rw-r--r--include/media/AudioSystem.h10
-rw-r--r--include/media/AudioTrack.h90
-rw-r--r--include/media/EffectsFactoryApi.h2
-rw-r--r--include/media/IAudioFlinger.h3
-rw-r--r--include/media/IAudioPolicyService.h3
-rw-r--r--include/media/IMediaPlayer.h1
-rw-r--r--include/media/IMediaPlayerService.h3
-rw-r--r--include/media/IMediaRecorder.h1
-rw-r--r--include/media/IOMX.h1
-rw-r--r--include/media/MediaPlayerInterface.h15
-rw-r--r--include/media/MediaRecorderBase.h1
-rw-r--r--include/media/SingleStateQueue.h106
-rw-r--r--include/media/StringArray.h2
-rw-r--r--include/media/mediaplayer.h2
-rw-r--r--include/media/mediarecorder.h1
-rw-r--r--include/media/nbaio/NBAIO.h6
-rw-r--r--include/media/nbaio/NBLog.h2
-rw-r--r--include/media/stagefright/AACWriter.h1
-rw-r--r--include/media/stagefright/ACodec.h3
-rw-r--r--include/media/stagefright/AMRWriter.h1
-rw-r--r--include/media/stagefright/BufferProducerWrapper.h1
-rw-r--r--include/media/stagefright/MPEG2TSWriter.h1
-rw-r--r--include/media/stagefright/MPEG4Writer.h13
-rw-r--r--include/media/stagefright/MediaClock.h77
-rw-r--r--include/media/stagefright/MediaCodec.h13
-rw-r--r--include/media/stagefright/MediaCodecSource.h3
-rw-r--r--include/media/stagefright/MediaFilter.h167
-rw-r--r--include/media/stagefright/MediaMuxer.h3
-rw-r--r--include/media/stagefright/ProcessInfo.h40
-rw-r--r--include/media/stagefright/ProcessInfoInterface.h (renamed from include/media/nbaio/roundup.h)26
-rw-r--r--include/media/stagefright/RenderScriptWrapper.h42
-rw-r--r--include/media/stagefright/foundation/ABase.h2
-rw-r--r--include/media/stagefright/foundation/AHandler.h24
-rw-r--r--include/media/stagefright/foundation/ALooper.h29
-rw-r--r--include/media/stagefright/foundation/ALooperRoster.h14
-rw-r--r--include/media/stagefright/foundation/AMessage.h58
-rw-r--r--include/ndk/NdkMediaCodec.h3
-rw-r--r--include/ndk/NdkMediaExtractor.h6
-rw-r--r--include/private/media/AudioTrackShared.h94
-rw-r--r--include/private/media/StaticAudioTrackState.h39
-rw-r--r--include/radio/IRadio.h70
-rw-r--r--include/radio/IRadioClient.h50
-rw-r--r--include/radio/IRadioService.h59
-rw-r--r--include/radio/Radio.h88
-rw-r--r--include/radio/RadioCallback.h38
55 files changed, 1168 insertions, 672 deletions
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index c6074fc..ba33ffe 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -108,6 +108,9 @@ public:
*/
void getSupportedPreviewFormats(Vector<int>& formats) const;
+ // Returns true if no keys are present
+ bool isEmpty() const;
+
// Parameter keys to communicate between camera application and driver.
// The access (read/write, read only, or write only) is viewed from the
// perspective of applications, not driver.
diff --git a/include/camera/ICameraService.h b/include/camera/ICameraService.h
index f7f06bb..c8d3d19 100644
--- a/include/camera/ICameraService.h
+++ b/include/camera/ICameraService.h
@@ -25,8 +25,6 @@ namespace android {
class ICamera;
class ICameraClient;
-class IProCameraUser;
-class IProCameraCallbacks;
class ICameraServiceListener;
class ICameraDeviceUser;
class ICameraDeviceCallbacks;
@@ -44,7 +42,6 @@ public:
GET_NUMBER_OF_CAMERAS = IBinder::FIRST_CALL_TRANSACTION,
GET_CAMERA_INFO,
CONNECT,
- CONNECT_PRO,
CONNECT_DEVICE,
ADD_LISTENER,
REMOVE_LISTENER,
@@ -53,6 +50,7 @@ public:
GET_LEGACY_PARAMETERS,
SUPPORTS_CAMERA_API,
CONNECT_LEGACY,
+ SET_TORCH_MODE,
};
enum {
@@ -104,13 +102,6 @@ public:
/*out*/
sp<ICamera>& device) = 0;
- virtual status_t connectPro(const sp<IProCameraCallbacks>& cameraCb,
- int cameraId,
- const String16& clientPackageName,
- int clientUid,
- /*out*/
- sp<IProCameraUser>& device) = 0;
-
virtual status_t connectDevice(
const sp<ICameraDeviceCallbacks>& cameraCb,
int cameraId,
@@ -142,6 +133,21 @@ public:
int clientUid,
/*out*/
sp<ICamera>& device) = 0;
+
+ /**
+ * Turn on or off a camera's torch mode. Torch mode will be turned off by
+ * camera service if the lastest client binder that turns it on dies.
+ *
+ * return values:
+ * 0: on a successful operation.
+ * -ENOSYS: the camera device doesn't support this operation. It it returned
+ * if and only if android.flash.into.available is false.
+ * -EBUSY: the camera device is opened.
+ * -EINVAL: camera_id is invalid or clientBinder is NULL when enabling a
+ * torch mode.
+ */
+ virtual status_t setTorchMode(const String16& cameraId, bool enabled,
+ const sp<IBinder>& clientBinder) = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/camera/ICameraServiceListener.h b/include/camera/ICameraServiceListener.h
index 0a0e43a..709ff31 100644
--- a/include/camera/ICameraServiceListener.h
+++ b/include/camera/ICameraServiceListener.h
@@ -66,9 +66,35 @@ public:
STATUS_UNKNOWN = 0xFFFFFFFF,
};
+ /**
+ * The torch mode status of a camera.
+ *
+ * Initial status will be transmitted with onTorchStatusChanged immediately
+ * after this listener is added to the service listener list.
+ *
+ * The enums should be set to values matching
+ * include/hardware/camera_common.h
+ */
+ enum TorchStatus {
+ // The camera's torch mode has become not available to use via
+ // setTorchMode().
+ TORCH_STATUS_NOT_AVAILABLE = TORCH_MODE_STATUS_NOT_AVAILABLE,
+ // The camera's torch mode is off and available to be turned on via
+ // setTorchMode().
+ TORCH_STATUS_AVAILABLE_OFF = TORCH_MODE_STATUS_AVAILABLE_OFF,
+ // The camera's torch mode is on and available to be turned off via
+ // setTorchMode().
+ TORCH_STATUS_AVAILABLE_ON = TORCH_MODE_STATUS_AVAILABLE_ON,
+
+ // Use to initialize variables only
+ TORCH_STATUS_UNKNOWN = 0xFFFFFFFF,
+ };
+
DECLARE_META_INTERFACE(CameraServiceListener);
virtual void onStatusChanged(Status status, int32_t cameraId) = 0;
+
+ virtual void onTorchStatusChanged(TorchStatus status, const String16& cameraId) = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/camera/IProCameraCallbacks.h b/include/camera/IProCameraCallbacks.h
deleted file mode 100644
index e8abb89..0000000
--- a/include/camera/IProCameraCallbacks.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2013 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_IPROCAMERA_CALLBACKS_H
-#define ANDROID_HARDWARE_IPROCAMERA_CALLBACKS_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>
-
-struct camera_metadata;
-
-namespace android {
-
-class IProCameraCallbacks : public IInterface
-{
- /**
- * Keep up-to-date with IProCameraCallbacks.aidl in frameworks/base
- */
-public:
- DECLARE_META_INTERFACE(ProCameraCallbacks);
-
- virtual void notifyCallback(int32_t msgType,
- int32_t ext1,
- int32_t ext2) = 0;
-
- enum LockStatus {
- LOCK_ACQUIRED,
- LOCK_RELEASED,
- LOCK_STOLEN,
- };
-
- virtual void onLockStatusChanged(LockStatus newLockStatus) = 0;
-
- /** Missing by design: implementation is client-side in ProCamera.cpp **/
- // virtual void onBufferReceived(int streamId,
- // const CpuConsumer::LockedBufer& buf);
- virtual void onResultReceived(int32_t requestId,
- camera_metadata* result) = 0;
-};
-
-// ----------------------------------------------------------------------------
-
-class BnProCameraCallbacks : public BnInterface<IProCameraCallbacks>
-{
-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/IProCameraUser.h b/include/camera/IProCameraUser.h
deleted file mode 100644
index 2ccc4d2..0000000
--- a/include/camera/IProCameraUser.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2013 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_IPROCAMERAUSER_H
-#define ANDROID_HARDWARE_IPROCAMERAUSER_H
-
-#include <utils/RefBase.h>
-#include <binder/IInterface.h>
-#include <binder/Parcel.h>
-#include <binder/IMemory.h>
-#include <utils/String8.h>
-#include <camera/IProCameraCallbacks.h>
-
-struct camera_metadata;
-
-namespace android {
-
-class IProCameraUserClient;
-class IGraphicBufferProducer;
-class Surface;
-
-class IProCameraUser: public IInterface
-{
- /**
- * Keep up-to-date with IProCameraUser.aidl in frameworks/base
- */
-public:
- DECLARE_META_INTERFACE(ProCameraUser);
-
- virtual void disconnect() = 0;
-
- // connect to the service, given a callbacks listener
- virtual status_t connect(const sp<IProCameraCallbacks>& callbacks)
- = 0;
-
- /**
- * Locking
- **/
- virtual status_t exclusiveTryLock() = 0;
- virtual status_t exclusiveLock() = 0;
- virtual status_t exclusiveUnlock() = 0;
-
- virtual bool hasExclusiveLock() = 0;
-
- /**
- * Request Handling
- **/
-
- // Note that the callee gets a copy of the metadata.
- virtual int submitRequest(struct camera_metadata* metadata,
- bool streaming = false) = 0;
- virtual status_t cancelRequest(int requestId) = 0;
-
- virtual status_t deleteStream(int streamId) = 0;
- virtual status_t createStream(
- int width, int height, int format,
- const sp<IGraphicBufferProducer>& bufferProducer,
- /*out*/
- int* streamId) = 0;
-
- // Create a request object from a template.
- virtual status_t createDefaultRequest(int templateId,
- /*out*/
- camera_metadata** request)
- = 0;
-
- // Get static camera metadata
- virtual status_t getCameraInfo(int cameraId,
- /*out*/
- camera_metadata** info) = 0;
-
-};
-
-// ----------------------------------------------------------------------------
-
-class BnProCameraUser: public BnInterface<IProCameraUser>
-{
-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/ProCamera.h b/include/camera/ProCamera.h
deleted file mode 100644
index e9b687a..0000000
--- a/include/camera/ProCamera.h
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright (C) 2013 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_PRO_CAMERA_H
-#define ANDROID_HARDWARE_PRO_CAMERA_H
-
-#include <utils/Timers.h>
-#include <utils/KeyedVector.h>
-#include <gui/IGraphicBufferProducer.h>
-#include <system/camera.h>
-#include <camera/IProCameraCallbacks.h>
-#include <camera/IProCameraUser.h>
-#include <camera/Camera.h>
-#include <camera/CameraMetadata.h>
-#include <camera/ICameraService.h>
-#include <gui/CpuConsumer.h>
-
-#include <gui/Surface.h>
-
-#include <utils/Condition.h>
-#include <utils/Mutex.h>
-
-#include <camera/CameraBase.h>
-
-struct camera_metadata;
-
-namespace android {
-
-// All callbacks on this class are concurrent
-// (they come from separate threads)
-class ProCameraListener : virtual public RefBase
-{
-public:
- virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) = 0;
-
- // Lock has been acquired. Write operations now available.
- virtual void onLockAcquired() = 0;
- // Lock has been released with exclusiveUnlock.
- virtual void onLockReleased() = 0;
- // Lock has been stolen by another client.
- virtual void onLockStolen() = 0;
-
- // Lock free.
- virtual void onTriggerNotify(int32_t msgType, int32_t ext1, int32_t ext2)
- = 0;
- // onFrameAvailable and OnResultReceived can come in with any order,
- // use android.sensor.timestamp and LockedBuffer.timestamp to correlate them
-
- /**
- * A new metadata buffer has been received.
- * -- Ownership of request passes on to the callee, free with
- * free_camera_metadata.
- */
- virtual void onResultReceived(int32_t frameId, camera_metadata* result) = 0;
-
- // TODO: make onFrameAvailable pure virtual
-
- // A new frame buffer has been received for this stream.
- // -- This callback only fires for createStreamCpu streams
- // -- A buffer may be obtained by calling cpuConsumer->lockNextBuffer
- // -- Use buf.timestamp to correlate with result's android.sensor.timestamp
- // -- The buffer should be accessed with CpuConsumer::lockNextBuffer
- // and CpuConsumer::unlockBuffer
- virtual void onFrameAvailable(int /*streamId*/,
- const sp<CpuConsumer>& /*cpuConsumer*/) {
- }
-
-};
-
-class ProCamera;
-
-template <>
-struct CameraTraits<ProCamera>
-{
- typedef ProCameraListener TCamListener;
- typedef IProCameraUser TCamUser;
- typedef IProCameraCallbacks TCamCallbacks;
- typedef status_t (ICameraService::*TCamConnectService)(const sp<IProCameraCallbacks>&,
- int, const String16&, int,
- /*out*/
- sp<IProCameraUser>&);
- static TCamConnectService fnConnectService;
-};
-
-
-class ProCamera :
- public CameraBase<ProCamera>,
- public BnProCameraCallbacks
-{
-public:
- /**
- * Connect a shared camera. By default access is restricted to read only
- * (Lock free) operations. To be able to submit custom requests a lock needs
- * to be acquired with exclusive[Try]Lock.
- */
- static sp<ProCamera> connect(int cameraId);
- virtual ~ProCamera();
-
- /**
- * Exclusive Locks:
- * - We may request exclusive access to a camera if no other
- * clients are using the camera. This works as a traditional
- * client, writing/reading any camera state.
- * - An application opening the camera (a regular 'Camera') will
- * always steal away the exclusive lock from a ProCamera,
- * this will call onLockReleased.
- * - onLockAcquired will be called again once it is possible
- * to again exclusively lock the camera.
- *
- */
-
- /**
- * All exclusiveLock/unlock functions are asynchronous. The remote endpoint
- * shall not block while waiting to acquire the lock. Instead the lock
- * notifications will come in asynchronously on the listener.
- */
-
- /**
- * Attempt to acquire the lock instantly (non-blocking)
- * - If this succeeds, you do not need to wait for onLockAcquired
- * but the event will still be fired
- *
- * Returns -EBUSY if already locked. 0 on success.
- */
- status_t exclusiveTryLock();
- // always returns 0. wait for onLockAcquired before lock is acquired.
- status_t exclusiveLock();
- // release a lock if we have one, or cancel the lock request.
- status_t exclusiveUnlock();
-
- // exclusive lock = do whatever we want. no lock = read only.
- bool hasExclusiveLock();
-
- /**
- * < 0 error, >= 0 the request ID. streaming to have the request repeat
- * until cancelled.
- * The request queue is flushed when a lock is released or stolen
- * if not locked will return PERMISSION_DENIED
- */
- int submitRequest(const struct camera_metadata* metadata,
- bool streaming = false);
- // if not locked will return PERMISSION_DENIED, BAD_VALUE if requestId bad
- status_t cancelRequest(int requestId);
-
- /**
- * Ask for a stream to be enabled.
- * Lock free. Service maintains counter of streams.
- */
- status_t requestStream(int streamId);
-// TODO: remove requestStream, its useless.
-
- /**
- * Delete a stream.
- * Lock free.
- *
- * NOTE: As a side effect this cancels ALL streaming requests.
- *
- * Errors: BAD_VALUE if unknown stream ID.
- * PERMISSION_DENIED if the stream wasn't yours
- */
- status_t deleteStream(int streamId);
-
- /**
- * Create a new HW stream, whose sink will be the window.
- * Lock free. Service maintains counter of streams.
- * Errors: -EBUSY if too many streams created
- */
- status_t createStream(int width, int height, int format,
- const sp<Surface>& surface,
- /*out*/
- int* streamId);
-
- /**
- * Create a new HW stream, whose sink will be the SurfaceTexture.
- * Lock free. Service maintains counter of streams.
- * Errors: -EBUSY if too many streams created
- */
- status_t createStream(int width, int height, int format,
- const sp<IGraphicBufferProducer>& bufferProducer,
- /*out*/
- int* streamId);
- status_t createStreamCpu(int width, int height, int format,
- int heapCount,
- /*out*/
- sp<CpuConsumer>* cpuConsumer,
- int* streamId);
- status_t createStreamCpu(int width, int height, int format,
- int heapCount,
- bool synchronousMode,
- /*out*/
- sp<CpuConsumer>* cpuConsumer,
- int* streamId);
-
- // Create a request object from a template.
- status_t createDefaultRequest(int templateId,
- /*out*/
- camera_metadata** request) const;
-
- // Get static camera metadata
- camera_metadata* getCameraInfo(int cameraId);
-
- // Blocks until a frame is available (CPU streams only)
- // - Obtain the frame data by calling CpuConsumer::lockNextBuffer
- // - Release the frame data after use with CpuConsumer::unlockBuffer
- // Return value:
- // - >0 - number of frames available to be locked
- // - <0 - error (refer to error codes)
- // Error codes:
- // -ETIMEDOUT if it took too long to get a frame
- int waitForFrameBuffer(int streamId);
-
- // Blocks until a metadata result is available
- // - Obtain the metadata by calling consumeFrameMetadata()
- // Error codes:
- // -ETIMEDOUT if it took too long to get a frame
- status_t waitForFrameMetadata();
-
- // Get the latest metadata. This is destructive.
- // - Calling this repeatedly will produce empty metadata objects.
- // - Use waitForFrameMetadata to sync until new data is available.
- CameraMetadata consumeFrameMetadata();
-
- // Convenience method to drop frame buffers (CPU streams only)
- // Return values:
- // >=0 - number of frames dropped (up to count)
- // <0 - error code
- // Error codes:
- // BAD_VALUE - invalid streamId or count passed
- int dropFrameBuffer(int streamId, int count);
-
-protected:
- ////////////////////////////////////////////////////////
- // IProCameraCallbacks implementation
- ////////////////////////////////////////////////////////
- virtual void notifyCallback(int32_t msgType,
- int32_t ext,
- int32_t ext2);
-
- virtual void onLockStatusChanged(
- IProCameraCallbacks::LockStatus newLockStatus);
-
- virtual void onResultReceived(int32_t requestId,
- camera_metadata* result);
-private:
- ProCamera(int cameraId);
-
- class ProFrameListener : public CpuConsumer::FrameAvailableListener {
- public:
- ProFrameListener(wp<ProCamera> camera, int streamID) {
- mCamera = camera;
- mStreamId = streamID;
- }
-
- protected:
- virtual void onFrameAvailable(const BufferItem& /* item */) {
- sp<ProCamera> c = mCamera.promote();
- if (c.get() != NULL) {
- c->onFrameAvailable(mStreamId);
- }
- }
-
- private:
- wp<ProCamera> mCamera;
- int mStreamId;
- };
- friend class ProFrameListener;
-
- struct StreamInfo
- {
- StreamInfo(int streamId) {
- this->streamID = streamId;
- cpuStream = false;
- frameReady = 0;
- }
-
- StreamInfo() {
- streamID = -1;
- cpuStream = false;
- }
-
- int streamID;
- bool cpuStream;
- sp<CpuConsumer> cpuConsumer;
- bool synchronousMode;
- sp<ProFrameListener> frameAvailableListener;
- sp<Surface> stc;
- int frameReady;
- };
-
- Condition mWaitCondition;
- Mutex mWaitMutex;
- static const nsecs_t mWaitTimeout = 1000000000; // 1sec
- KeyedVector<int, StreamInfo> mStreams;
- bool mMetadataReady;
- CameraMetadata mLatestMetadata;
-
- void onFrameAvailable(int streamId);
-
- StreamInfo& getStreamInfo(int streamId);
-
- friend class CameraBase;
-};
-
-}; // namespace android
-
-#endif
diff --git a/include/camera/camera2/ICameraDeviceUser.h b/include/camera/camera2/ICameraDeviceUser.h
index 35488bb..e9f1f5a 100644
--- a/include/camera/camera2/ICameraDeviceUser.h
+++ b/include/camera/camera2/ICameraDeviceUser.h
@@ -27,9 +27,9 @@ namespace android {
class ICameraDeviceUserClient;
class IGraphicBufferProducer;
-class Surface;
class CaptureRequest;
class CameraMetadata;
+class OutputConfiguration;
enum {
NO_IN_FLIGHT_REPEATING_FRAMES = -1,
@@ -100,9 +100,8 @@ public:
virtual status_t endConfigure() = 0;
virtual status_t deleteStream(int streamId) = 0;
- virtual status_t createStream(
- int width, int height, int format,
- const sp<IGraphicBufferProducer>& bufferProducer) = 0;
+
+ virtual status_t createStream(const OutputConfiguration& outputConfiguration) = 0;
// Create a request object from a template.
virtual status_t createDefaultRequest(int templateId,
diff --git a/include/camera/camera2/OutputConfiguration.h b/include/camera/camera2/OutputConfiguration.h
new file mode 100644
index 0000000..e6b679f
--- /dev/null
+++ b/include/camera/camera2/OutputConfiguration.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2015 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_CAMERA2_OUTPUTCONFIGURATION_H
+#define ANDROID_HARDWARE_CAMERA2_OUTPUTCONFIGURATION_H
+
+#include <utils/RefBase.h>
+#include <gui/IGraphicBufferProducer.h>
+
+namespace android {
+
+class Surface;
+
+class OutputConfiguration : public virtual RefBase {
+public:
+
+ static const int INVALID_ROTATION;
+ sp<IGraphicBufferProducer> getGraphicBufferProducer() const;
+ int getRotation() const;
+
+ /**
+ * Keep impl up-to-date with OutputConfiguration.java in frameworks/base
+ */
+ status_t writeToParcel(Parcel& parcel) const;
+ // getGraphicBufferProducer will be NULL if error occurred
+ // getRotation will be INVALID_ROTATION if error occurred
+ OutputConfiguration(const Parcel& parcel);
+
+private:
+ sp<IGraphicBufferProducer> mGbp;
+ int mRotation;
+
+ // helper function
+ static String16 readMaybeEmptyString16(const Parcel& parcel);
+};
+}; // namespace android
+
+#endif
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index f70d981..8e0b8f8 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -88,8 +88,8 @@ public:
* 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 fewer bytes are
- * consumed.
+ * more bytes than indicated by 'size' field and update 'size' if
+ * fewer bytes are consumed.
* - EVENT_OVERRUN: unused.
* - EVENT_MARKER: pointer to const uint32_t containing the marker position in frames.
* - EVENT_NEW_POS: pointer to const uint32_t containing the new position in frames.
@@ -106,6 +106,7 @@ public:
* - BAD_VALUE: unsupported configuration
* frameCount is guaranteed to be non-zero if status is NO_ERROR,
* and is undefined otherwise.
+ * FIXME This API assumes a route, and so should be deprecated.
*/
static status_t getMinFrameCount(size_t* frameCount,
@@ -416,6 +417,7 @@ private:
void pause(); // suspend thread from execution at next loop boundary
void resume(); // allow thread to execute, if not requested to exit
+ void wake(); // wake to handle changed notification conditions.
private:
void pauseInternal(nsecs_t ns = 0LL);
@@ -430,7 +432,9 @@ private:
bool mPaused; // whether thread is requested to pause at next loop entry
bool mPausedInt; // whether thread internally requests pause
nsecs_t mPausedNs; // if mPausedInt then associated timeout, otherwise ignored
- bool mIgnoreNextPausedInt; // whether to ignore next mPausedInt request
+ bool mIgnoreNextPausedInt; // skip any internal pause and go immediately
+ // to processAudioBuffer() as state may have changed
+ // since pause time calculated.
};
// body of AudioRecordThread::threadLoop()
diff --git a/include/media/AudioResamplerPublic.h b/include/media/AudioResamplerPublic.h
index 97847a0..b705efa 100644
--- a/include/media/AudioResamplerPublic.h
+++ b/include/media/AudioResamplerPublic.h
@@ -26,4 +26,17 @@
// TODO: replace with an API
#define AUDIO_RESAMPLER_DOWN_RATIO_MAX 256
+// Returns the source frames needed to resample to destination frames. This is not a precise
+// value and depends on the resampler (and possibly how it handles rounding internally).
+// Nevertheless, this should be an upper bound on the requirements of the resampler.
+// If srcSampleRate and dstSampleRate are equal, then it returns destination frames, which
+// may not be true if the resampler is asynchronous.
+static inline size_t sourceFramesNeeded(
+ uint32_t srcSampleRate, size_t dstFramesRequired, uint32_t dstSampleRate) {
+ // +1 for rounding - always do this even if matched ratio (resampler may use phases not ratio)
+ // +1 for additional sample needed for interpolation
+ return srcSampleRate == dstSampleRate ? dstFramesRequired :
+ size_t((uint64_t)dstFramesRequired * srcSampleRate / dstSampleRate + 1 + 1);
+}
+
#endif // ANDROID_AUDIO_RESAMPLER_PUBLIC_H
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index 843a354..ad5d6ed 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -98,10 +98,13 @@ public:
// Returned samplingRate and frameCount output values are guaranteed
// to be non-zero if status == NO_ERROR
+ // FIXME This API assumes a route, and so should be deprecated.
static status_t getOutputSamplingRate(uint32_t* samplingRate,
audio_stream_type_t stream);
+ // FIXME This API assumes a route, and so should be deprecated.
static status_t getOutputFrameCount(size_t* frameCount,
audio_stream_type_t stream);
+ // FIXME This API assumes a route, and so should be deprecated.
static status_t getOutputLatency(uint32_t* latency,
audio_stream_type_t stream);
static status_t getSamplingRate(audio_io_handle_t output,
@@ -110,19 +113,20 @@ public:
// audio_stream->get_buffer_size()/audio_stream_out_frame_size()
static status_t getFrameCount(audio_io_handle_t output,
size_t* frameCount);
- // returns the audio output stream latency in ms. Corresponds to
+ // returns the audio output latency in ms. Corresponds to
// audio_stream_out->get_latency()
static status_t getLatency(audio_io_handle_t output,
uint32_t* latency);
// return status NO_ERROR implies *buffSize > 0
+ // FIXME This API assumes a route, and so should deprecated.
static status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
audio_channel_mask_t channelMask, 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 specified output I/O handle has exited standby.
+ // audio dsp to DAC since the specified output 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
@@ -201,7 +205,7 @@ public:
// 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);
+ const char *device_address, const char *device_name);
static audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
const char *device_address);
static status_t setPhoneState(audio_mode_t state);
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index fd51b8f..3de0774 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -63,7 +63,7 @@ public:
// See AudioTimestamp for the information included with event.
};
- /* Client should declare Buffer on the stack and pass address to obtainBuffer()
+ /* Client should declare a Buffer and pass the address to obtainBuffer()
* and releaseBuffer(). See also callback_t for EVENT_MORE_DATA.
*/
@@ -72,16 +72,20 @@ public:
public:
// FIXME use m prefix
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
- // (currently ignored, but will make the primary field in future)
+ // on input to obtainBuffer() it is the number of frames desired,
+ // on output from obtainBuffer() it is the number of available
+ // [empty slots for] frames to be filled
+ // on input to releaseBuffer() it is currently ignored
size_t size; // input/output in bytes == frameCount * frameSize
- // on input it is unused
- // on output is the number of bytes actually filled
- // FIXME this is redundant with respect to frameCount,
- // and TRANSFER_OBTAIN mode is broken for 8-bit data
- // since we don't define the frame format
+ // on input to obtainBuffer() it is ignored
+ // on output from obtainBuffer() it is the number of available
+ // [empty slots for] bytes to be filled,
+ // which is frameCount * frameSize
+ // on input to releaseBuffer() it is the number of bytes to
+ // release
+ // FIXME This is redundant with respect to frameCount. Consider
+ // removing size and making frameCount the primary field.
union {
void* raw;
@@ -154,9 +158,9 @@ public:
* streamType: Select the type of audio stream this track is attached to
* (e.g. AUDIO_STREAM_MUSIC).
* sampleRate: Data source sampling rate in Hz.
- * format: Audio format. For mixed tracks, any PCM format supported by server is OK
- * or AUDIO_FORMAT_PCM_8_BIT which is handled on client side. For direct
- * and offloaded tracks, the possible format(s) depends on the output sink.
+ * format: Audio format. For mixed tracks, any PCM format supported by server is OK.
+ * For direct and offloaded tracks, the possible format(s) depends on the
+ * output sink.
* channelMask: Channel mask, such that audio_is_output_channel(channelMask) is true.
* frameCount: Minimum size of track PCM buffer in frames. This defines the
* application's contribution to the
@@ -193,7 +197,6 @@ public:
/* Creates an audio track and registers it with AudioFlinger.
* With this constructor, the track is configured for static buffer mode.
- * The format must not be 8-bit linear PCM.
* Data to be rendered is passed in a shared memory buffer
* identified by the argument sharedBuffer, which must be non-0.
* The memory should be initialized to the desired data before calling start().
@@ -487,10 +490,18 @@ public:
*/
status_t attachAuxEffect(int effectId);
- /* Obtains a buffer of up to "audioBuffer->frameCount" empty slots for frames.
+ /* Public API for TRANSFER_OBTAIN mode.
+ * Obtains a buffer of up to "audioBuffer->frameCount" empty slots for frames.
* After filling these slots with data, the caller should release them with releaseBuffer().
* If the track buffer is not full, obtainBuffer() returns as many contiguous
* [empty slots for] frames as are available immediately.
+ *
+ * If nonContig is non-NULL, it is an output parameter that will be set to the number of
+ * additional non-contiguous frames that are predicted to be available immediately,
+ * if the client were to release the first frames and then call obtainBuffer() again.
+ * This value is only a prediction, and needs to be confirmed.
+ * It will be set to zero for an error return.
+ *
* If the track buffer is full and track is stopped, obtainBuffer() returns WOULD_BLOCK
* regardless of the value of waitCount.
* If the track buffer is full and track is not stopped, obtainBuffer() blocks with a
@@ -499,7 +510,6 @@ public:
* is exhausted, at which point obtainBuffer() will either block
* or return WOULD_BLOCK depending on the value of the "waitCount"
* parameter.
- * Each sample is 16-bit signed PCM.
*
* obtainBuffer() and releaseBuffer() are deprecated for direct use by applications,
* which should use write() or callback EVENT_MORE_DATA instead.
@@ -511,24 +521,29 @@ public:
*
* Buffer fields
* On entry:
- * frameCount number of frames requested
+ * frameCount number of [empty slots for] frames requested
+ * size ignored
+ * raw ignored
* After error return:
* frameCount 0
* size 0
* raw undefined
* After successful return:
- * frameCount actual number of frames available, <= number requested
+ * frameCount actual number of [empty slots for] frames available, <= number requested
* size actual number of bytes available
* raw pointer to the buffer
*/
-
/* FIXME Deprecated public API for TRANSFER_OBTAIN mode */
- status_t obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
+ status_t obtainBuffer(Buffer* audioBuffer, int32_t waitCount,
+ size_t *nonContig = NULL)
__attribute__((__deprecated__));
private:
/* If nonContig is non-NULL, it is an output parameter that will be set to the number of
- * additional non-contiguous frames that are available immediately.
+ * additional non-contiguous frames that are predicted to be available immediately,
+ * if the client were to release the first frames and then call obtainBuffer() again.
+ * This value is only a prediction, and needs to be confirmed.
+ * It will be set to zero for an error return.
* FIXME We could pass an array of Buffers instead of only one Buffer to obtainBuffer(),
* in case the requested amount of frames is in two or more non-contiguous regions.
* FIXME requested and elapsed are both relative times. Consider changing to absolute time.
@@ -537,9 +552,17 @@ private:
struct timespec *elapsed = NULL, size_t *nonContig = NULL);
public:
- /* Release a filled buffer of "audioBuffer->frameCount" frames for AudioFlinger to process. */
+ /* Public API for TRANSFER_OBTAIN mode.
+ * Release a filled buffer of frames for AudioFlinger to process.
+ *
+ * Buffer fields:
+ * frameCount currently ignored but recommend to set to actual number of frames filled
+ * size actual number of bytes filled, must be multiple of frameSize
+ * raw ignored
+ *
+ */
// FIXME make private when obtainBuffer() for TRANSFER_OBTAIN is removed
- void releaseBuffer(Buffer* audioBuffer);
+ void releaseBuffer(const Buffer* audioBuffer);
/* As a convenience we provide a write() interface to the audio buffer.
* Input parameter 'size' is in byte units.
@@ -614,6 +637,7 @@ protected:
void pause(); // suspend thread from execution at next loop boundary
void resume(); // allow thread to execute, if not requested to exit
+ void wake(); // wake to handle changed notification conditions.
private:
void pauseInternal(nsecs_t ns = 0LL);
@@ -628,7 +652,9 @@ protected:
bool mPaused; // whether thread is requested to pause at next loop entry
bool mPausedInt; // whether thread internally requests pause
nsecs_t mPausedNs; // if mPausedInt then associated timeout, otherwise ignored
- bool mIgnoreNextPausedInt; // whether to ignore next mPausedInt request
+ bool mIgnoreNextPausedInt; // skip any internal pause and go immediately
+ // to processAudioBuffer() as state may have changed
+ // since pause time calculated.
};
// body of AudioTrackThread::threadLoop()
@@ -680,7 +706,7 @@ protected:
float mVolume[2];
float mSendLevel;
- mutable uint32_t mSampleRate; // mutable because getSampleRate() can update it.
+ mutable uint32_t mSampleRate; // mutable because getSampleRate() can update it
size_t mFrameCount; // corresponds to current IAudioTrack, value is
// reported back by AudioFlinger to the client
size_t mReqFrameCount; // frame count to request the first or next time
@@ -698,10 +724,7 @@ protected:
const audio_offload_info_t* mOffloadInfo;
audio_attributes_t mAttributes;
- // mFrameSize is equal to mFrameSizeAF for non-PCM or 16-bit PCM data. For 8-bit PCM data, it's
- // twice as large as mFrameSize because data is expanded to 16-bit before it's stored in buffer.
- size_t mFrameSize; // app-level frame size
- size_t mFrameSizeAF; // AudioFlinger frame size
+ size_t mFrameSize; // frame size in bytes
status_t mStatus;
@@ -732,13 +755,20 @@ protected:
bool mRefreshRemaining; // processAudioBuffer() should refresh
// mRemainingFrames and mRetryOnPartialBuffer
+ // used for static track cbf and restoration
+ int32_t mLoopCount; // last setLoop loopCount; zero means disabled
+ uint32_t mLoopStart; // last setLoop loopStart
+ uint32_t mLoopEnd; // last setLoop loopEnd
+ int32_t mLoopCountNotified; // the last loopCount notified by callback.
+ // mLoopCountNotified counts down, matching
+ // the remaining loop count for static track
+ // playback.
+
// These are private to processAudioBuffer(), and are not protected by a lock
uint32_t mRemainingFrames; // number of frames to request in obtainBuffer()
bool mRetryOnPartialBuffer; // sleep and retry after partial obtainBuffer()
uint32_t mObservedSequence; // last observed value of mSequence
- uint32_t mLoopPeriod; // in frames, zero means looping is disabled
-
uint32_t mMarkerPosition; // in wrapping (overflow) frame units
bool mMarkerReached;
uint32_t mNewPosition; // in frames
diff --git a/include/media/EffectsFactoryApi.h b/include/media/EffectsFactoryApi.h
index b1ed7b0..64a3212 100644
--- a/include/media/EffectsFactoryApi.h
+++ b/include/media/EffectsFactoryApi.h
@@ -171,6 +171,8 @@ int EffectGetDescriptor(const effect_uuid_t *pEffectUuid, effect_descriptor_t *p
////////////////////////////////////////////////////////////////////////////////
int EffectIsNullUuid(const effect_uuid_t *pEffectUuid);
+int EffectDumpEffects(int fd);
+
#if __cplusplus
} // extern "C"
#endif
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index 31a14f0..f927a80 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -94,6 +94,8 @@ public:
sp<IMemory>& buffers, // return value 0 means it follows cblk
status_t *status) = 0;
+ // FIXME Surprisingly, sampleRate/format/frameCount/latency don't work for input handles
+
/* query the audio hardware state. This state never changes,
* and therefore can be cached.
*/
@@ -142,6 +144,7 @@ public:
virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0;
// retrieve the audio recording buffer size
+ // FIXME This API assumes a route, and so should be deprecated.
virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
audio_channel_mask_t channelMask) const = 0;
diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h
index c98c475..fecc6f1 100644
--- a/include/media/IAudioPolicyService.h
+++ b/include/media/IAudioPolicyService.h
@@ -44,7 +44,8 @@ public:
//
virtual status_t setDeviceConnectionState(audio_devices_t device,
audio_policy_dev_state_t state,
- const char *device_address) = 0;
+ const char *device_address,
+ const char *device_name) = 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;
diff --git a/include/media/IMediaPlayer.h b/include/media/IMediaPlayer.h
index db62cd5..4153c25 100644
--- a/include/media/IMediaPlayer.h
+++ b/include/media/IMediaPlayer.h
@@ -56,6 +56,7 @@ public:
virtual status_t stop() = 0;
virtual status_t pause() = 0;
virtual status_t isPlaying(bool* state) = 0;
+ virtual status_t setPlaybackRate(float rate) = 0;
virtual status_t seekTo(int msec) = 0;
virtual status_t getCurrentPosition(int* msec) = 0;
virtual status_t getDuration(int* msec) = 0;
diff --git a/include/media/IMediaPlayerService.h b/include/media/IMediaPlayerService.h
index 67b599a..49a3d61 100644
--- a/include/media/IMediaPlayerService.h
+++ b/include/media/IMediaPlayerService.h
@@ -49,7 +49,8 @@ public:
virtual sp<IMediaRecorder> createMediaRecorder() = 0;
virtual sp<IMediaMetadataRetriever> createMetadataRetriever() = 0;
- virtual sp<IMediaPlayer> create(const sp<IMediaPlayerClient>& client, int audioSessionId = 0) = 0;
+ virtual sp<IMediaPlayer> create(const sp<IMediaPlayerClient>& client, int audioSessionId = 0)
+ = 0;
virtual sp<IOMX> getOMX() = 0;
virtual sp<ICrypto> makeCrypto() = 0;
diff --git a/include/media/IMediaRecorder.h b/include/media/IMediaRecorder.h
index 3e67550..509c06b 100644
--- a/include/media/IMediaRecorder.h
+++ b/include/media/IMediaRecorder.h
@@ -41,7 +41,6 @@ public:
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;
diff --git a/include/media/IOMX.h b/include/media/IOMX.h
index 627f23b..6def65b 100644
--- a/include/media/IOMX.h
+++ b/include/media/IOMX.h
@@ -147,6 +147,7 @@ public:
INTERNAL_OPTION_SUSPEND, // data is a bool
INTERNAL_OPTION_REPEAT_PREVIOUS_FRAME_DELAY, // data is an int64_t
INTERNAL_OPTION_MAX_TIMESTAMP_GAP, // data is int64_t
+ INTERNAL_OPTION_MAX_FPS, // data is float
INTERNAL_OPTION_START_TIME, // data is an int64_t
INTERNAL_OPTION_TIME_LAPSE, // data is an int64_t[2]
};
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
index 4a6bf28..d6fe390 100644
--- a/include/media/MediaPlayerInterface.h
+++ b/include/media/MediaPlayerInterface.h
@@ -113,7 +113,19 @@ public:
const audio_offload_info_t *offloadInfo = NULL) = 0;
virtual status_t start() = 0;
- virtual ssize_t write(const void* buffer, size_t size) = 0;
+
+ /* Input parameter |size| is in byte units stored in |buffer|.
+ * Data is copied over and actual number of bytes written (>= 0)
+ * is returned, or no data is copied and a negative status code
+ * is returned (even when |blocking| is true).
+ * When |blocking| is false, AudioSink will immediately return after
+ * part of or full |buffer| is copied over.
+ * When |blocking| is true, AudioSink will wait to copy the entire
+ * buffer, unless an error occurs or the copy operation is
+ * prematurely stopped.
+ */
+ virtual ssize_t write(const void* buffer, size_t size, bool blocking = true) = 0;
+
virtual void stop() = 0;
virtual void flush() = 0;
virtual void pause() = 0;
@@ -156,6 +168,7 @@ public:
virtual status_t stop() = 0;
virtual status_t pause() = 0;
virtual bool isPlaying() = 0;
+ virtual status_t setPlaybackRate(float rate) { return INVALID_OPERATION; }
virtual status_t seekTo(int msec) = 0;
virtual status_t getCurrentPosition(int *msec) = 0;
virtual status_t getDuration(int *msec) = 0;
diff --git a/include/media/MediaRecorderBase.h b/include/media/MediaRecorderBase.h
index d7ac302..f55063e 100644
--- a/include/media/MediaRecorderBase.h
+++ b/include/media/MediaRecorderBase.h
@@ -43,7 +43,6 @@ struct MediaRecorderBase {
virtual status_t setCamera(const sp<ICamera>& camera,
const sp<ICameraRecordingProxy>& proxy) = 0;
virtual status_t setPreviewSurface(const sp<IGraphicBufferProducer>& 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;
diff --git a/include/media/SingleStateQueue.h b/include/media/SingleStateQueue.h
index 04c5fd0..d423962 100644
--- a/include/media/SingleStateQueue.h
+++ b/include/media/SingleStateQueue.h
@@ -21,6 +21,7 @@
// Non-blocking single-reader / single-writer multi-word atomic load / store
#include <stdint.h>
+#include <cutils/atomic.h>
namespace android {
@@ -31,6 +32,12 @@ public:
class Mutator;
class Observer;
+ enum SSQ_STATUS {
+ SSQ_PENDING, /* = 0 */
+ SSQ_READ,
+ SSQ_DONE,
+ };
+
struct Shared {
// needs to be part of a union so don't define constructor or destructor
@@ -41,28 +48,56 @@ private:
void init() { mAck = 0; mSequence = 0; }
volatile int32_t mAck;
-#if 0
- int mPad[7];
- // cache line boundary
-#endif
volatile int32_t mSequence;
T mValue;
};
class Mutator {
public:
- Mutator(Shared *shared);
- /*virtual*/ ~Mutator() { }
+ Mutator(Shared *shared)
+ : mSequence(0), mShared(shared)
+ {
+ // exactly one of Mutator and Observer must initialize, currently it is Observer
+ // shared->init();
+ }
// push new value onto state queue, overwriting previous value;
// returns a sequence number which can be used with ack()
- int32_t push(const T& value);
-
- // return true if most recent push has been observed
- bool ack();
+ int32_t push(const T& value)
+ {
+ Shared *shared = mShared;
+ int32_t sequence = mSequence;
+ sequence++;
+ android_atomic_acquire_store(sequence, &shared->mSequence);
+ shared->mValue = value;
+ sequence++;
+ android_atomic_release_store(sequence, &shared->mSequence);
+ mSequence = sequence;
+ // consider signalling a futex here, if we know that observer is waiting
+ return sequence;
+ }
+
+ // returns the status of the last state push. This may be a stale value.
+ //
+ // SSQ_PENDING, or 0, means it has not been observed
+ // SSQ_READ means it has been read
+ // SSQ_DONE means it has been acted upon, after Observer::done() is called
+ enum SSQ_STATUS ack() const
+ {
+ // in the case of SSQ_DONE, prevent any subtle data-races of subsequent reads
+ // being performed (out-of-order) before the ack read, should the caller be
+ // depending on sequentiality of reads.
+ const int32_t ack = android_atomic_acquire_load(&mShared->mAck);
+ return ack - mSequence & ~1 ? SSQ_PENDING /* seq differ */ :
+ ack & 1 ? SSQ_DONE : SSQ_READ;
+ }
// return true if a push with specified sequence number or later has been observed
- bool ack(int32_t sequence);
+ bool ack(int32_t sequence) const
+ {
+ // this relies on 2's complement rollover to detect an ancient sequence number
+ return mShared->mAck - sequence >= 0;
+ }
private:
int32_t mSequence;
@@ -71,11 +106,54 @@ private:
class Observer {
public:
- Observer(Shared *shared);
- /*virtual*/ ~Observer() { }
+ Observer(Shared *shared)
+ : mSequence(0), mSeed(1), mShared(shared)
+ {
+ // exactly one of Mutator and Observer must initialize, currently it is Observer
+ shared->init();
+ }
// return true if value has changed
- bool poll(T& value);
+ bool poll(T& value)
+ {
+ Shared *shared = mShared;
+ int32_t before = shared->mSequence;
+ if (before == mSequence) {
+ return false;
+ }
+ for (int tries = 0; ; ) {
+ const int MAX_TRIES = 5;
+ if (before & 1) {
+ if (++tries >= MAX_TRIES) {
+ return false;
+ }
+ before = shared->mSequence;
+ } else {
+ android_memory_barrier();
+ T temp = shared->mValue;
+ int32_t after = android_atomic_release_load(&shared->mSequence);
+ if (after == before) {
+ value = temp;
+ shared->mAck = before;
+ mSequence = before; // mSequence is even after poll success
+ return true;
+ }
+ if (++tries >= MAX_TRIES) {
+ return false;
+ }
+ before = after;
+ }
+ }
+ }
+
+ // (optional) used to indicate to the Mutator that the state that has been polled
+ // has also been acted upon.
+ void done()
+ {
+ const int32_t ack = mShared->mAck + 1;
+ // ensure all previous writes have been performed.
+ android_atomic_release_store(ack, &mShared->mAck); // mSequence is odd after "done"
+ }
private:
int32_t mSequence;
diff --git a/include/media/StringArray.h b/include/media/StringArray.h
index ae47085..48d98bf 100644
--- a/include/media/StringArray.h
+++ b/include/media/StringArray.h
@@ -16,7 +16,7 @@
//
// Sortable array of strings. STL-ish, but STL-free.
-//
+//
#ifndef _LIBS_MEDIA_STRING_ARRAY_H
#define _LIBS_MEDIA_STRING_ARRAY_H
diff --git a/include/media/mediaplayer.h b/include/media/mediaplayer.h
index 5830933..808e893 100644
--- a/include/media/mediaplayer.h
+++ b/include/media/mediaplayer.h
@@ -220,6 +220,7 @@ public:
status_t stop();
status_t pause();
bool isPlaying();
+ status_t setPlaybackRate(float rate);
status_t getVideoWidth(int *w);
status_t getVideoHeight(int *h);
status_t seekTo(int msec);
@@ -274,6 +275,7 @@ private:
int mVideoWidth;
int mVideoHeight;
int mAudioSessionId;
+ float mPlaybackRate;
float mSendLevel;
struct sockaddr_in mRetransmitEndpoint;
bool mRetransmitEndpointValid;
diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h
index b0a62a7..74a6469 100644
--- a/include/media/mediarecorder.h
+++ b/include/media/mediarecorder.h
@@ -221,7 +221,6 @@ public:
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);
diff --git a/include/media/nbaio/NBAIO.h b/include/media/nbaio/NBAIO.h
index d422576..d9bbc8d 100644
--- a/include/media/nbaio/NBAIO.h
+++ b/include/media/nbaio/NBAIO.h
@@ -231,7 +231,8 @@ public:
virtual status_t getTimestamp(AudioTimestamp& timestamp) { return INVALID_OPERATION; }
protected:
- NBAIO_Sink(const NBAIO_Format& format = Format_Invalid) : NBAIO_Port(format), mFramesWritten(0) { }
+ NBAIO_Sink(const NBAIO_Format& format = Format_Invalid) : NBAIO_Port(format), mFramesWritten(0)
+ { }
virtual ~NBAIO_Sink() { }
// Implementations are free to ignore these if they don't need them
@@ -322,7 +323,8 @@ public:
virtual void onTimestamp(const AudioTimestamp& timestamp) { }
protected:
- NBAIO_Source(const NBAIO_Format& format = Format_Invalid) : NBAIO_Port(format), mFramesRead(0) { }
+ NBAIO_Source(const NBAIO_Format& format = Format_Invalid) : NBAIO_Port(format), mFramesRead(0)
+ { }
virtual ~NBAIO_Source() { }
// Implementations are free to ignore these if they don't need them
diff --git a/include/media/nbaio/NBLog.h b/include/media/nbaio/NBLog.h
index bcbbc04..1297b51 100644
--- a/include/media/nbaio/NBLog.h
+++ b/include/media/nbaio/NBLog.h
@@ -21,7 +21,7 @@
#include <binder/IMemory.h>
#include <utils/Mutex.h>
-#include <media/nbaio/roundup.h>
+#include <audio_utils/roundup.h>
namespace android {
diff --git a/include/media/stagefright/AACWriter.h b/include/media/stagefright/AACWriter.h
index d22707a..86417a5 100644
--- a/include/media/stagefright/AACWriter.h
+++ b/include/media/stagefright/AACWriter.h
@@ -27,7 +27,6 @@ struct MediaSource;
struct MetaData;
struct AACWriter : public MediaWriter {
- AACWriter(const char *filename);
AACWriter(int fd);
status_t initCheck() const;
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h
index cd2bd27..c1483f3 100644
--- a/include/media/stagefright/ACodec.h
+++ b/include/media/stagefright/ACodec.h
@@ -214,6 +214,7 @@ private:
int64_t mRepeatFrameDelayUs;
int64_t mMaxPtsGapUs;
+ float mMaxFps;
int64_t mTimePerFrameUs;
int64_t mTimePerCaptureUs;
@@ -298,6 +299,8 @@ private:
status_t setupRawAudioFormat(
OMX_U32 portIndex, int32_t sampleRate, int32_t numChannels);
+ status_t setPriority(int32_t priority);
+
status_t setMinBufferSize(OMX_U32 portIndex, size_t size);
status_t setupMPEG4EncoderParameters(const sp<AMessage> &msg);
diff --git a/include/media/stagefright/AMRWriter.h b/include/media/stagefright/AMRWriter.h
index 392f968..bac878b 100644
--- a/include/media/stagefright/AMRWriter.h
+++ b/include/media/stagefright/AMRWriter.h
@@ -29,7 +29,6 @@ struct MediaSource;
struct MetaData;
struct AMRWriter : public MediaWriter {
- AMRWriter(const char *filename);
AMRWriter(int fd);
status_t initCheck() const;
diff --git a/include/media/stagefright/BufferProducerWrapper.h b/include/media/stagefright/BufferProducerWrapper.h
index d8acf30..4caa2c6 100644
--- a/include/media/stagefright/BufferProducerWrapper.h
+++ b/include/media/stagefright/BufferProducerWrapper.h
@@ -19,6 +19,7 @@
#define BUFFER_PRODUCER_WRAPPER_H_
#include <gui/IGraphicBufferProducer.h>
+#include <media/stagefright/foundation/ABase.h>
namespace android {
diff --git a/include/media/stagefright/MPEG2TSWriter.h b/include/media/stagefright/MPEG2TSWriter.h
index 2e2922e..3d7960b 100644
--- a/include/media/stagefright/MPEG2TSWriter.h
+++ b/include/media/stagefright/MPEG2TSWriter.h
@@ -29,7 +29,6 @@ struct ABuffer;
struct MPEG2TSWriter : public MediaWriter {
MPEG2TSWriter(int fd);
- MPEG2TSWriter(const char *filename);
MPEG2TSWriter(
void *cookie,
diff --git a/include/media/stagefright/MPEG4Writer.h b/include/media/stagefright/MPEG4Writer.h
index 26ce5f9..a195fe8 100644
--- a/include/media/stagefright/MPEG4Writer.h
+++ b/include/media/stagefright/MPEG4Writer.h
@@ -26,13 +26,13 @@
namespace android {
+class AMessage;
class MediaBuffer;
class MediaSource;
class MetaData;
class MPEG4Writer : public MediaWriter {
public:
- MPEG4Writer(const char *filename);
MPEG4Writer(int fd);
// Limitations
@@ -49,6 +49,7 @@ public:
virtual status_t dump(int fd, const Vector<String16>& args);
void beginBox(const char *fourcc);
+ void beginBox(uint32_t id);
void writeInt8(int8_t x);
void writeInt16(int16_t x);
void writeInt32(int32_t x);
@@ -63,6 +64,7 @@ public:
int32_t getTimeScale() const { return mTimeScale; }
status_t setGeoData(int latitudex10000, int longitudex10000);
+ status_t setCaptureRate(float captureFps);
virtual void setStartTimeOffsetMs(int ms) { mStartTimeOffsetMs = ms; }
virtual int32_t getStartTimeOffsetMs() const { return mStartTimeOffsetMs; }
@@ -89,6 +91,7 @@ private:
off64_t mFreeBoxOffset;
bool mStreamableFile;
off64_t mEstimatedMoovBoxSize;
+ off64_t mMoovExtraSize;
uint32_t mInterleaveDurationUs;
int32_t mTimeScale;
int64_t mStartTimestampUs;
@@ -103,6 +106,8 @@ private:
List<off64_t> mBoxes;
+ sp<AMessage> mMetaKeys;
+
void setStartTimestampUs(int64_t timeUs);
int64_t getStartTimestampUs(); // Not const
status_t startTracks(MetaData *params);
@@ -196,6 +201,12 @@ private:
void writeGeoDataBox();
void writeLatitude(int degreex10000);
void writeLongitude(int degreex10000);
+
+ void addDeviceMeta();
+ void writeHdlr();
+ void writeKeys();
+ void writeIlst();
+ void writeMetaBox();
void sendSessionSummary();
void release();
status_t reset();
diff --git a/include/media/stagefright/MediaClock.h b/include/media/stagefright/MediaClock.h
new file mode 100644
index 0000000..660764f
--- /dev/null
+++ b/include/media/stagefright/MediaClock.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2015 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_CLOCK_H_
+
+#define MEDIA_CLOCK_H_
+
+#include <media/stagefright/foundation/ABase.h>
+#include <utils/Mutex.h>
+#include <utils/RefBase.h>
+
+namespace android {
+
+struct AMessage;
+
+struct MediaClock : public RefBase {
+ MediaClock();
+
+ void setStartingTimeMedia(int64_t startingTimeMediaUs);
+
+ void clearAnchor();
+ // It's required to use timestamp of just rendered frame as
+ // anchor time in paused state.
+ void updateAnchor(
+ int64_t anchorTimeMediaUs,
+ int64_t anchorTimeRealUs,
+ int64_t maxTimeMediaUs = INT64_MAX);
+
+ void updateMaxTimeMedia(int64_t maxTimeMediaUs);
+
+ void setPlaybackRate(float rate);
+
+ // query media time corresponding to real time |realUs|, and save the
+ // result in |outMediaUs|.
+ status_t getMediaTime(int64_t realUs,
+ int64_t *outMediaUs,
+ bool allowPastMaxTime = false);
+ // query real time corresponding to media time |targetMediaUs|.
+ // The result is saved in |outRealUs|.
+ status_t getRealTimeFor(int64_t targetMediaUs, int64_t *outRealUs);
+
+protected:
+ virtual ~MediaClock();
+
+private:
+ status_t getMediaTime_l(int64_t realUs,
+ int64_t *outMediaUs,
+ bool allowPastMaxTime);
+
+ Mutex mLock;
+
+ int64_t mAnchorTimeMediaUs;
+ int64_t mAnchorTimeRealUs;
+ int64_t mMaxTimeMediaUs;
+ int64_t mStartingTimeMediaUs;
+
+ float mPlaybackRate;
+
+ DISALLOW_EVIL_CONSTRUCTORS(MediaClock);
+};
+
+} // namespace android
+
+#endif // MEDIA_CLOCK_H_
diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h
index d448097..8241e19 100644
--- a/include/media/stagefright/MediaCodec.h
+++ b/include/media/stagefright/MediaCodec.h
@@ -27,6 +27,7 @@ namespace android {
struct ABuffer;
struct AMessage;
+struct AReplyToken;
struct AString;
struct CodecBase;
struct ICrypto;
@@ -222,7 +223,7 @@ private:
sp<ALooper> mCodecLooper;
sp<CodecBase> mCodec;
AString mComponentName;
- uint32_t mReplyID;
+ sp<AReplyToken> mReplyID;
uint32_t mFlags;
status_t mStickyError;
sp<Surface> mNativeWindow;
@@ -249,10 +250,10 @@ private:
Vector<BufferInfo> mPortBuffers[2];
int32_t mDequeueInputTimeoutGeneration;
- uint32_t mDequeueInputReplyID;
+ sp<AReplyToken> mDequeueInputReplyID;
int32_t mDequeueOutputTimeoutGeneration;
- uint32_t mDequeueOutputReplyID;
+ sp<AReplyToken> mDequeueOutputReplyID;
sp<ICrypto> mCrypto;
@@ -267,7 +268,7 @@ private:
static status_t PostAndAwaitResponse(
const sp<AMessage> &msg, sp<AMessage> *response);
- static void PostReplyWithError(int32_t replyID, int32_t err);
+ static void PostReplyWithError(const sp<AReplyToken> &replyID, int32_t err);
status_t init(const AString &name, bool nameIsType, bool encoder);
@@ -283,8 +284,8 @@ private:
size_t portIndex, size_t index,
sp<ABuffer> *buffer, sp<AMessage> *format);
- bool handleDequeueInputBuffer(uint32_t replyID, bool newRequest = false);
- bool handleDequeueOutputBuffer(uint32_t replyID, bool newRequest = false);
+ bool handleDequeueInputBuffer(const sp<AReplyToken> &replyID, bool newRequest = false);
+ bool handleDequeueOutputBuffer(const sp<AReplyToken> &replyID, bool newRequest = false);
void cancelPendingDequeueOperations();
void extractCSD(const sp<AMessage> &format);
diff --git a/include/media/stagefright/MediaCodecSource.h b/include/media/stagefright/MediaCodecSource.h
index 0970b2b..7b8f59d 100644
--- a/include/media/stagefright/MediaCodecSource.h
+++ b/include/media/stagefright/MediaCodecSource.h
@@ -25,6 +25,7 @@ namespace android {
class ALooper;
class AMessage;
+struct AReplyToken;
class IGraphicBufferProducer;
class MediaCodec;
class MetaData;
@@ -99,7 +100,7 @@ private:
sp<Puller> mPuller;
sp<MediaCodec> mEncoder;
uint32_t mFlags;
- List<uint32_t> mStopReplyIDQueue;
+ List<sp<AReplyToken>> mStopReplyIDQueue;
bool mIsVideo;
bool mStarted;
bool mStopping;
diff --git a/include/media/stagefright/MediaFilter.h b/include/media/stagefright/MediaFilter.h
new file mode 100644
index 0000000..7b3f700
--- /dev/null
+++ b/include/media/stagefright/MediaFilter.h
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MEDIA_FILTER_H_
+#define MEDIA_FILTER_H_
+
+#include <media/stagefright/CodecBase.h>
+
+namespace android {
+
+struct ABuffer;
+struct GraphicBufferListener;
+struct MemoryDealer;
+struct SimpleFilter;
+
+struct MediaFilter : public CodecBase {
+ MediaFilter();
+
+ virtual void setNotificationMessage(const sp<AMessage> &msg);
+
+ virtual void initiateAllocateComponent(const sp<AMessage> &msg);
+ virtual void initiateConfigureComponent(const sp<AMessage> &msg);
+ virtual void initiateCreateInputSurface();
+ virtual void initiateStart();
+ virtual void initiateShutdown(bool keepComponentAllocated = false);
+
+ virtual void signalFlush();
+ virtual void signalResume();
+
+ virtual void signalRequestIDRFrame();
+ virtual void signalSetParameters(const sp<AMessage> &msg);
+ virtual void signalEndOfInputStream();
+
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+
+ struct PortDescription : public CodecBase::PortDescription {
+ virtual size_t countBuffers();
+ virtual IOMX::buffer_id bufferIDAt(size_t index) const;
+ virtual sp<ABuffer> bufferAt(size_t index) const;
+
+ protected:
+ PortDescription();
+
+ private:
+ friend struct MediaFilter;
+
+ Vector<IOMX::buffer_id> mBufferIDs;
+ Vector<sp<ABuffer> > mBuffers;
+
+ void addBuffer(IOMX::buffer_id id, const sp<ABuffer> &buffer);
+
+ DISALLOW_EVIL_CONSTRUCTORS(PortDescription);
+ };
+
+protected:
+ virtual ~MediaFilter();
+
+private:
+ struct BufferInfo {
+ enum Status {
+ OWNED_BY_US,
+ OWNED_BY_UPSTREAM,
+ };
+
+ IOMX::buffer_id mBufferID;
+ int32_t mGeneration;
+ int32_t mOutputFlags;
+ Status mStatus;
+
+ sp<ABuffer> mData;
+ };
+
+ enum State {
+ UNINITIALIZED,
+ INITIALIZED,
+ CONFIGURED,
+ STARTED,
+ };
+
+ enum {
+ kWhatInputBufferFilled = 'inpF',
+ kWhatOutputBufferDrained = 'outD',
+ kWhatShutdown = 'shut',
+ kWhatFlush = 'flus',
+ kWhatResume = 'resm',
+ kWhatAllocateComponent = 'allo',
+ kWhatConfigureComponent = 'conf',
+ kWhatCreateInputSurface = 'cisf',
+ kWhatSignalEndOfInputStream = 'eois',
+ kWhatStart = 'star',
+ kWhatSetParameters = 'setP',
+ kWhatProcessBuffers = 'proc',
+ };
+
+ enum {
+ kPortIndexInput = 0,
+ kPortIndexOutput = 1
+ };
+
+ // member variables
+ AString mComponentName;
+ State mState;
+ status_t mInputEOSResult;
+ int32_t mWidth, mHeight;
+ int32_t mStride, mSliceHeight;
+ int32_t mColorFormatIn, mColorFormatOut;
+ size_t mMaxInputSize, mMaxOutputSize;
+ int32_t mGeneration;
+ sp<AMessage> mNotify;
+ sp<AMessage> mInputFormat;
+ sp<AMessage> mOutputFormat;
+
+ sp<MemoryDealer> mDealer[2];
+ Vector<BufferInfo> mBuffers[2];
+ Vector<BufferInfo*> mAvailableInputBuffers;
+ Vector<BufferInfo*> mAvailableOutputBuffers;
+ bool mPortEOS[2];
+
+ sp<SimpleFilter> mFilter;
+ sp<GraphicBufferListener> mGraphicBufferListener;
+
+ // helper functions
+ void signalProcessBuffers();
+ void signalError(status_t error);
+
+ status_t allocateBuffersOnPort(OMX_U32 portIndex);
+ BufferInfo *findBufferByID(
+ uint32_t portIndex, IOMX::buffer_id bufferID,
+ ssize_t *index = NULL);
+ void postFillThisBuffer(BufferInfo *info);
+ void postDrainThisBuffer(BufferInfo *info);
+ void postEOS();
+ void sendFormatChange();
+ void requestFillEmptyInput();
+ void processBuffers();
+
+ void onAllocateComponent(const sp<AMessage> &msg);
+ void onConfigureComponent(const sp<AMessage> &msg);
+ void onStart();
+ void onInputBufferFilled(const sp<AMessage> &msg);
+ void onOutputBufferDrained(const sp<AMessage> &msg);
+ void onShutdown(const sp<AMessage> &msg);
+ void onFlush();
+ void onSetParameters(const sp<AMessage> &msg);
+ void onCreateInputSurface();
+ void onInputFrameAvailable();
+ void onSignalEndOfInputStream();
+
+ DISALLOW_EVIL_CONSTRUCTORS(MediaFilter);
+};
+
+} // namespace android
+
+#endif // MEDIA_FILTER_H_
diff --git a/include/media/stagefright/MediaMuxer.h b/include/media/stagefright/MediaMuxer.h
index 9da98d9..e6538d1 100644
--- a/include/media/stagefright/MediaMuxer.h
+++ b/include/media/stagefright/MediaMuxer.h
@@ -50,9 +50,6 @@ public:
OUTPUT_FORMAT_LIST_END // must be last - used to validate format type
};
- // Construct the muxer with the output file path.
- MediaMuxer(const char *path, OutputFormat format);
-
// Construct the muxer with the file descriptor. Note that the MediaMuxer
// will close this file at stop().
MediaMuxer(int fd, OutputFormat format);
diff --git a/include/media/stagefright/ProcessInfo.h b/include/media/stagefright/ProcessInfo.h
new file mode 100644
index 0000000..ec0cdff
--- /dev/null
+++ b/include/media/stagefright/ProcessInfo.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 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 PROCESS_INFO_H_
+
+#define PROCESS_INFO_H_
+
+#include <media/stagefright/foundation/ABase.h>
+#include <media/stagefright/ProcessInfoInterface.h>
+
+namespace android {
+
+struct ProcessInfo : public ProcessInfoInterface {
+ ProcessInfo();
+
+ virtual bool getPriority(int pid, int* priority);
+
+protected:
+ virtual ~ProcessInfo();
+
+private:
+ DISALLOW_EVIL_CONSTRUCTORS(ProcessInfo);
+};
+
+} // namespace android
+
+#endif // PROCESS_INFO_H_
diff --git a/include/media/nbaio/roundup.h b/include/media/stagefright/ProcessInfoInterface.h
index 4c3cc25..222f92d 100644
--- a/include/media/nbaio/roundup.h
+++ b/include/media/stagefright/ProcessInfoInterface.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2015 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.
@@ -14,18 +14,20 @@
* limitations under the License.
*/
-#ifndef ROUNDUP_H
-#define ROUNDUP_H
+#ifndef PROCESS_INFO_INTERFACE_H_
+#define PROCESS_INFO_INTERFACE_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <utils/RefBase.h>
-// Round up to the next highest power of 2
-unsigned roundup(unsigned v);
+namespace android {
-#ifdef __cplusplus
-}
-#endif
+struct ProcessInfoInterface : public RefBase {
+ virtual bool getPriority(int pid, int* priority) = 0;
-#endif // ROUNDUP_H
+protected:
+ virtual ~ProcessInfoInterface() {}
+};
+
+} // namespace android
+
+#endif // PROCESS_INFO_INTERFACE_H_
diff --git a/include/media/stagefright/RenderScriptWrapper.h b/include/media/stagefright/RenderScriptWrapper.h
new file mode 100644
index 0000000..b42649e
--- /dev/null
+++ b/include/media/stagefright/RenderScriptWrapper.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RENDERSCRIPT_WRAPPER_H_
+#define RENDERSCRIPT_WRAPPER_H_
+
+#include <RenderScript.h>
+
+namespace android {
+
+struct RenderScriptWrapper : public RefBase {
+public:
+ struct RSFilterCallback : public RefBase {
+ public:
+ // called by RSFilter to process each input buffer
+ virtual status_t processBuffers(
+ RSC::Allocation* inBuffer,
+ RSC::Allocation* outBuffer) = 0;
+
+ virtual status_t handleSetParameters(const sp<AMessage> &msg) = 0;
+ };
+
+ sp<RSFilterCallback> mCallback;
+ RSC::sp<RSC::RS> mContext;
+};
+
+} // namespace android
+
+#endif // RENDERSCRIPT_WRAPPER_H_
diff --git a/include/media/stagefright/foundation/ABase.h b/include/media/stagefright/foundation/ABase.h
index 72e3d87..ef1e010 100644
--- a/include/media/stagefright/foundation/ABase.h
+++ b/include/media/stagefright/foundation/ABase.h
@@ -18,7 +18,9 @@
#define A_BASE_H_
+#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
+#endif
#define DISALLOW_EVIL_CONSTRUCTORS(name) \
name(const name &); \
diff --git a/include/media/stagefright/foundation/AHandler.h b/include/media/stagefright/foundation/AHandler.h
index 41ade77..fe02a86 100644
--- a/include/media/stagefright/foundation/AHandler.h
+++ b/include/media/stagefright/foundation/AHandler.h
@@ -29,6 +29,7 @@ struct AMessage;
struct AHandler : public RefBase {
AHandler()
: mID(0),
+ mVerboseStats(false),
mMessageCounter(0) {
}
@@ -36,23 +37,40 @@ struct AHandler : public RefBase {
return mID;
}
- sp<ALooper> looper();
+ sp<ALooper> looper() const {
+ return mLooper.promote();
+ }
+
+ wp<ALooper> getLooper() const {
+ return mLooper;
+ }
+
+ wp<AHandler> getHandler() const {
+ // allow getting a weak reference to a const handler
+ return const_cast<AHandler *>(this);
+ }
protected:
virtual void onMessageReceived(const sp<AMessage> &msg) = 0;
private:
- friend struct ALooperRoster;
+ friend struct AMessage; // deliverMessage()
+ friend struct ALooperRoster; // setID()
ALooper::handler_id mID;
+ wp<ALooper> mLooper;
- void setID(ALooper::handler_id id) {
+ inline void setID(ALooper::handler_id id, wp<ALooper> looper) {
mID = id;
+ mLooper = looper;
}
+ bool mVerboseStats;
uint32_t mMessageCounter;
KeyedVector<uint32_t, uint32_t> mMessages;
+ void deliverMessage(const sp<AMessage> &msg);
+
DISALLOW_EVIL_CONSTRUCTORS(AHandler);
};
diff --git a/include/media/stagefright/foundation/ALooper.h b/include/media/stagefright/foundation/ALooper.h
index 70e0c5e..09c469b 100644
--- a/include/media/stagefright/foundation/ALooper.h
+++ b/include/media/stagefright/foundation/ALooper.h
@@ -30,6 +30,7 @@ namespace android {
struct AHandler;
struct AMessage;
+struct AReplyToken;
struct ALooper : public RefBase {
typedef int32_t event_id;
@@ -53,11 +54,15 @@ struct ALooper : public RefBase {
static int64_t GetNowUs();
+ const char *getName() const {
+ return mName.c_str();
+ }
+
protected:
virtual ~ALooper();
private:
- friend struct ALooperRoster;
+ friend struct AMessage; // post()
struct Event {
int64_t mWhenUs;
@@ -75,12 +80,32 @@ private:
sp<LooperThread> mThread;
bool mRunningLocally;
+ // use a separate lock for reply handling, as it is always on another thread
+ // use a central lock, however, to avoid creating a mutex for each reply
+ Mutex mRepliesLock;
+ Condition mRepliesCondition;
+
+ // START --- methods used only by AMessage
+
+ // posts a message on this looper with the given timeout
void post(const sp<AMessage> &msg, int64_t delayUs);
+
+ // creates a reply token to be used with this looper
+ sp<AReplyToken> createReplyToken();
+ // waits for a response for the reply token. If status is OK, the response
+ // is stored into the supplied variable. Otherwise, it is unchanged.
+ status_t awaitResponse(const sp<AReplyToken> &replyToken, sp<AMessage> *response);
+ // posts a reply for a reply token. If the reply could be successfully posted,
+ // it returns OK. Otherwise, it returns an error value.
+ status_t postReply(const sp<AReplyToken> &replyToken, const sp<AMessage> &msg);
+
+ // END --- methods used only by AMessage
+
bool loop();
DISALLOW_EVIL_CONSTRUCTORS(ALooper);
};
-} // namespace android
+} // namespace android
#endif // A_LOOPER_H_
diff --git a/include/media/stagefright/foundation/ALooperRoster.h b/include/media/stagefright/foundation/ALooperRoster.h
index a0be8eb..9912455 100644
--- a/include/media/stagefright/foundation/ALooperRoster.h
+++ b/include/media/stagefright/foundation/ALooperRoster.h
@@ -33,16 +33,6 @@ struct ALooperRoster {
void unregisterHandler(ALooper::handler_id handlerID);
void unregisterStaleHandlers();
- 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);
-
void dump(int fd, const Vector<String16>& args);
private:
@@ -54,10 +44,6 @@ private:
Mutex mLock;
KeyedVector<ALooper::handler_id, HandlerInfo> mHandlers;
ALooper::handler_id mNextHandlerID;
- uint32_t mNextReplyID;
- Condition mRepliesCondition;
-
- KeyedVector<uint32_t, sp<AMessage> > mReplies;
DISALLOW_EVIL_CONSTRUCTORS(ALooperRoster);
};
diff --git a/include/media/stagefright/foundation/AMessage.h b/include/media/stagefright/foundation/AMessage.h
index a9e235b..4c6bd21 100644
--- a/include/media/stagefright/foundation/AMessage.h
+++ b/include/media/stagefright/foundation/AMessage.h
@@ -26,11 +26,41 @@
namespace android {
struct ABuffer;
+struct AHandler;
struct AString;
struct Parcel;
+struct AReplyToken : public RefBase {
+ AReplyToken(const sp<ALooper> &looper)
+ : mLooper(looper),
+ mReplied(false) {
+ }
+
+private:
+ friend struct AMessage;
+ friend struct ALooper;
+ wp<ALooper> mLooper;
+ sp<AMessage> mReply;
+ bool mReplied;
+
+ sp<ALooper> getLooper() const {
+ return mLooper.promote();
+ }
+ // if reply is not set, returns false; otherwise, it retrieves the reply and returns true
+ bool retrieveReply(sp<AMessage> *reply) {
+ if (mReplied) {
+ *reply = mReply;
+ mReply.clear();
+ }
+ return mReplied;
+ }
+ // sets the reply for this token. returns OK or error
+ status_t setReply(const sp<AMessage> &reply);
+};
+
struct AMessage : public RefBase {
- AMessage(uint32_t what = 0, ALooper::handler_id target = 0);
+ AMessage();
+ AMessage(uint32_t what, const sp<const AHandler> &handler);
static sp<AMessage> FromParcel(const Parcel &parcel);
void writeToParcel(Parcel *parcel) const;
@@ -38,8 +68,7 @@ struct AMessage : public RefBase {
void setWhat(uint32_t what);
uint32_t what() const;
- void setTarget(ALooper::handler_id target);
- ALooper::handler_id target() const;
+ void setTarget(const sp<const AHandler> &handler);
void clear();
@@ -76,18 +105,22 @@ struct AMessage : public RefBase {
const char *name,
int32_t *left, int32_t *top, int32_t *right, int32_t *bottom) const;
- void post(int64_t delayUs = 0);
+ status_t 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;
+ // awaiting a response and the reply token is consumed from the message
+ // and stored into replyID. The reply token must be used to send the response
+ // using "postReply" below.
+ bool senderAwaitsResponse(sp<AReplyToken> *replyID);
- void postReply(uint32_t replyID);
+ // Posts the message as a response to a reply token. A reply token can
+ // only be used once. Returns OK if the response could be posted; otherwise,
+ // an error.
+ status_t postReply(const sp<AReplyToken> &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
@@ -117,9 +150,16 @@ protected:
virtual ~AMessage();
private:
+ friend struct ALooper; // deliver()
+
uint32_t mWhat;
+
+ // used only for debugging
ALooper::handler_id mTarget;
+ wp<AHandler> mHandler;
+ wp<ALooper> mLooper;
+
struct Rect {
int32_t mLeft, mTop, mRight, mBottom;
};
@@ -157,6 +197,8 @@ private:
size_t findItemIndex(const char *name, size_t len) const;
+ void deliver();
+
DISALLOW_EVIL_CONSTRUCTORS(AMessage);
};
diff --git a/include/ndk/NdkMediaCodec.h b/include/ndk/NdkMediaCodec.h
index c07f4c9..4f6a1ef 100644
--- a/include/ndk/NdkMediaCodec.h
+++ b/include/ndk/NdkMediaCodec.h
@@ -142,7 +142,8 @@ media_status_t AMediaCodec_queueSecureInputBuffer(AMediaCodec*,
/**
* Get the index of the next available buffer of processed data.
*/
-ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec*, AMediaCodecBufferInfo *info, int64_t timeoutUs);
+ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec*, AMediaCodecBufferInfo *info,
+ int64_t timeoutUs);
AMediaFormat* AMediaCodec_getOutputFormat(AMediaCodec*);
/**
diff --git a/include/ndk/NdkMediaExtractor.h b/include/ndk/NdkMediaExtractor.h
index 7a4e702..7324d31 100644
--- a/include/ndk/NdkMediaExtractor.h
+++ b/include/ndk/NdkMediaExtractor.h
@@ -55,12 +55,14 @@ media_status_t AMediaExtractor_delete(AMediaExtractor*);
/**
* Set the file descriptor from which the extractor will read.
*/
-media_status_t AMediaExtractor_setDataSourceFd(AMediaExtractor*, int fd, off64_t offset, off64_t length);
+media_status_t AMediaExtractor_setDataSourceFd(AMediaExtractor*, int fd, off64_t offset,
+ off64_t length);
/**
* Set the URI from which the extractor will read.
*/
-media_status_t AMediaExtractor_setDataSource(AMediaExtractor*, const char *location); // TODO support headers
+media_status_t AMediaExtractor_setDataSource(AMediaExtractor*, const char *location);
+ // TODO support headers
/**
* Return the number of tracks in the previously specified media file
diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h
index 31dff36..5644428 100644
--- a/include/private/media/AudioTrackShared.h
+++ b/include/private/media/AudioTrackShared.h
@@ -24,9 +24,8 @@
#include <utils/threads.h>
#include <utils/Log.h>
#include <utils/RefBase.h>
-#include <media/nbaio/roundup.h>
+#include <audio_utils/roundup.h>
#include <media/SingleStateQueue.h>
-#include <private/media/StaticAudioTrackState.h>
namespace android {
@@ -54,22 +53,64 @@ namespace android {
struct AudioTrackSharedStreaming {
// similar to NBAIO MonoPipe
// in continuously incrementing frame units, take modulo buffer size, which must be a power of 2
- volatile int32_t mFront; // read by server
- volatile int32_t mRear; // write by client
+ volatile int32_t mFront; // read by consumer (output: server, input: client)
+ volatile int32_t mRear; // written by producer (output: client, input: server)
volatile int32_t mFlush; // incremented by client to indicate a request to flush;
// server notices and discards all data between mFront and mRear
volatile uint32_t mUnderrunFrames; // server increments for each unavailable but desired frame
};
+// Represents a single state of an AudioTrack that was created in static mode (shared memory buffer
+// supplied by the client). This state needs to be communicated from the client to server. As this
+// state is too large to be updated atomically without a mutex, and mutexes aren't allowed here, the
+// state is wrapped by a SingleStateQueue.
+struct StaticAudioTrackState {
+ // Do not define constructors, destructors, or virtual methods as this is part of a
+ // union in shared memory and they will not get called properly.
+
+ // These fields should both be size_t, but since they are located in shared memory we
+ // force to 32-bit. The client and server may have different typedefs for size_t.
+
+ // The state has a sequence counter to indicate whether changes are made to loop or position.
+ // The sequence counter also currently indicates whether loop or position is first depending
+ // on which is greater; it jumps by max(mLoopSequence, mPositionSequence) + 1.
+
+ uint32_t mLoopStart;
+ uint32_t mLoopEnd;
+ int32_t mLoopCount;
+ uint32_t mLoopSequence; // a sequence counter to indicate changes to loop
+ uint32_t mPosition;
+ uint32_t mPositionSequence; // a sequence counter to indicate changes to position
+};
+
typedef SingleStateQueue<StaticAudioTrackState> StaticAudioTrackSingleStateQueue;
+struct StaticAudioTrackPosLoop {
+ // Do not define constructors, destructors, or virtual methods as this is part of a
+ // union in shared memory and will not get called properly.
+
+ // These fields should both be size_t, but since they are located in shared memory we
+ // force to 32-bit. The client and server may have different typedefs for size_t.
+
+ // This struct information is stored in a single state queue to communicate the
+ // static AudioTrack server state to the client while data is consumed.
+ // It is smaller than StaticAudioTrackState to prevent unnecessary information from
+ // being sent.
+
+ uint32_t mBufferPosition;
+ int32_t mLoopCount;
+};
+
+typedef SingleStateQueue<StaticAudioTrackPosLoop> StaticAudioTrackPosLoopQueue;
+
struct AudioTrackSharedStatic {
+ // client requests to the server for loop or position changes.
StaticAudioTrackSingleStateQueue::Shared
mSingleStateQueue;
- // This field should be a size_t, but since it is located in shared memory we
- // force to 32-bit. The client and server may have different typedefs for size_t.
- uint32_t mBufferPosition; // updated asynchronously by server,
- // "for entertainment purposes only"
+ // position info updated asynchronously by server and read by client,
+ // "for entertainment purposes only"
+ StaticAudioTrackPosLoopQueue::Shared
+ mPosLoopQueue;
};
// ----------------------------------------------------------------------------
@@ -96,7 +137,8 @@ struct audio_track_cblk_t
uint32_t mServer; // Number of filled frames consumed by server (mIsOut),
// or filled frames provided by server (!mIsOut).
// It is updated asynchronously by server without a barrier.
- // The value should be used "for entertainment purposes only",
+ // The value should be used
+ // "for entertainment purposes only",
// which means don't make important decisions based on it.
uint32_t mPad1; // unused
@@ -313,8 +355,28 @@ public:
virtual void flush();
#define MIN_LOOP 16 // minimum length of each loop iteration in frames
+
+ // setLoop(), setBufferPosition(), and setBufferPositionAndLoop() set the
+ // static buffer position and looping parameters. These commands are not
+ // synchronous (they do not wait or block); instead they take effect at the
+ // next buffer data read from the server side. However, the client side
+ // getters will read a cached version of the position and loop variables
+ // until the setting takes effect.
+ //
+ // setBufferPositionAndLoop() is equivalent to calling, in order, setLoop() and
+ // setBufferPosition().
+ //
+ // The functions should not be relied upon to do parameter or state checking.
+ // That is done at the AudioTrack level.
+
void setLoop(size_t loopStart, size_t loopEnd, int loopCount);
+ void setBufferPosition(size_t position);
+ void setBufferPositionAndLoop(size_t position, size_t loopStart, size_t loopEnd,
+ int loopCount);
size_t getBufferPosition();
+ // getBufferPositionAndLoopCount() provides the proper snapshot of
+ // position and loopCount together.
+ void getBufferPositionAndLoopCount(size_t *position, int *loopCount);
virtual size_t getMisalignment() {
return 0;
@@ -326,7 +388,9 @@ public:
private:
StaticAudioTrackSingleStateQueue::Mutator mMutator;
- size_t mBufferPosition; // so that getBufferPosition() appears to be synchronous
+ StaticAudioTrackPosLoopQueue::Observer mPosLoopObserver;
+ StaticAudioTrackState mState; // last communicated state to server
+ StaticAudioTrackPosLoop mPosLoop; // snapshot of position and loop.
};
// ----------------------------------------------------------------------------
@@ -447,10 +511,13 @@ public:
virtual uint32_t getUnderrunFrames() const { return 0; }
private:
+ status_t updateStateWithLoop(StaticAudioTrackState *localState,
+ const StaticAudioTrackState &update) const;
+ status_t updateStateWithPosition(StaticAudioTrackState *localState,
+ const StaticAudioTrackState &update) const;
ssize_t pollPosition(); // poll for state queue update, and return current position
StaticAudioTrackSingleStateQueue::Observer mObserver;
- size_t mPosition; // server's current play position in frames, relative to 0
-
+ StaticAudioTrackPosLoopQueue::Mutator mPosLoopMutator;
size_t mFramesReadySafe; // Assuming size_t read/writes are atomic on 32 / 64 bit
// processors, this is a thread-safe version of
// mFramesReady.
@@ -459,7 +526,8 @@ private:
// can cause a track to appear to have a large number
// of frames. INT64_MAX means an infinite loop.
bool mFramesReadyIsCalledByMultipleThreads;
- StaticAudioTrackState mState;
+ StaticAudioTrackState mState; // Server side state. Any updates from client must be
+ // passed by the mObserver SingleStateQueue.
};
// Proxy used by AudioFlinger for servicing AudioRecord
diff --git a/include/private/media/StaticAudioTrackState.h b/include/private/media/StaticAudioTrackState.h
deleted file mode 100644
index d483061..0000000
--- a/include/private/media/StaticAudioTrackState.h
+++ /dev/null
@@ -1,39 +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 STATIC_AUDIO_TRACK_STATE_H
-#define STATIC_AUDIO_TRACK_STATE_H
-
-namespace android {
-
-// Represents a single state of an AudioTrack that was created in static mode (shared memory buffer
-// supplied by the client). This state needs to be communicated from the client to server. As this
-// state is too large to be updated atomically without a mutex, and mutexes aren't allowed here, the
-// state is wrapped by a SingleStateQueue.
-struct StaticAudioTrackState {
- // do not define constructors, destructors, or virtual methods
-
- // These fields should both be size_t, but since they are located in shared memory we
- // force to 32-bit. The client and server may have different typedefs for size_t.
- uint32_t mLoopStart;
- uint32_t mLoopEnd;
-
- int mLoopCount;
-};
-
-} // namespace android
-
-#endif // STATIC_AUDIO_TRACK_STATE_H
diff --git a/include/radio/IRadio.h b/include/radio/IRadio.h
new file mode 100644
index 0000000..1877f8f
--- /dev/null
+++ b/include/radio/IRadio.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2015 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_IRADIO_H
+#define ANDROID_HARDWARE_IRADIO_H
+
+#include <utils/RefBase.h>
+#include <binder/IInterface.h>
+#include <binder/IMemory.h>
+#include <binder/Parcel.h>
+#include <system/radio.h>
+
+namespace android {
+
+class IRadio : public IInterface
+{
+public:
+
+ DECLARE_META_INTERFACE(Radio);
+
+ virtual void detach() = 0;
+
+ virtual status_t setConfiguration(const struct radio_band_config *config) = 0;
+
+ virtual status_t getConfiguration(struct radio_band_config *config) = 0;
+
+ virtual status_t setMute(bool mute) = 0;
+
+ virtual status_t getMute(bool *mute) = 0;
+
+ virtual status_t step(radio_direction_t direction, bool skipSubChannel) = 0;
+
+ virtual status_t scan(radio_direction_t direction, bool skipSubChannel) = 0;
+
+ virtual status_t tune(unsigned int channel, unsigned int subChannel) = 0;
+
+ virtual status_t cancel() = 0;
+
+ virtual status_t getProgramInformation(struct radio_program_info *info) = 0;
+
+ virtual status_t hasControl(bool *hasControl) = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnRadio: public BnInterface<IRadio>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif //ANDROID_HARDWARE_IRADIO_H
diff --git a/include/radio/IRadioClient.h b/include/radio/IRadioClient.h
new file mode 100644
index 0000000..9062ad6
--- /dev/null
+++ b/include/radio/IRadioClient.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2015 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_IRADIO_CLIENT_H
+#define ANDROID_HARDWARE_IRADIO_CLIENT_H
+
+#include <utils/RefBase.h>
+#include <binder/IInterface.h>
+#include <binder/IMemory.h>
+#include <binder/Parcel.h>
+
+namespace android {
+
+class IRadioClient : public IInterface
+{
+public:
+
+ DECLARE_META_INTERFACE(RadioClient);
+
+ virtual void onEvent(const sp<IMemory>& eventMemory) = 0;
+
+};
+
+// ----------------------------------------------------------------------------
+
+class BnRadioClient : public BnInterface<IRadioClient>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif //ANDROID_HARDWARE_IRADIO_CLIENT_H
diff --git a/include/radio/IRadioService.h b/include/radio/IRadioService.h
new file mode 100644
index 0000000..a946dd5
--- /dev/null
+++ b/include/radio/IRadioService.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2015 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_IRADIO_SERVICE_H
+#define ANDROID_HARDWARE_IRADIO_SERVICE_H
+
+#include <utils/RefBase.h>
+#include <binder/IInterface.h>
+#include <binder/Parcel.h>
+#include <system/radio.h>
+
+namespace android {
+
+class IRadio;
+class IRadioClient;
+
+class IRadioService : public IInterface
+{
+public:
+
+ DECLARE_META_INTERFACE(RadioService);
+
+ virtual status_t listModules(struct radio_properties *properties,
+ uint32_t *numModules) = 0;
+
+ virtual status_t attach(const radio_handle_t handle,
+ const sp<IRadioClient>& client,
+ const struct radio_band_config *config,
+ bool withAudio,
+ sp<IRadio>& radio) = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnRadioService: public BnInterface<IRadioService>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif //ANDROID_HARDWARE_IRADIO_SERVICE_H
diff --git a/include/radio/Radio.h b/include/radio/Radio.h
new file mode 100644
index 0000000..302bf16
--- /dev/null
+++ b/include/radio/Radio.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2015 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_RADIO_H
+#define ANDROID_HARDWARE_RADIO_H
+
+#include <binder/IBinder.h>
+#include <utils/threads.h>
+#include <radio/RadioCallback.h>
+#include <radio/IRadio.h>
+#include <radio/IRadioService.h>
+#include <radio/IRadioClient.h>
+#include <system/radio.h>
+
+namespace android {
+
+class MemoryDealer;
+
+class Radio : public BnRadioClient,
+ public IBinder::DeathRecipient
+{
+public:
+
+ virtual ~Radio();
+
+ static status_t listModules(struct radio_properties *properties,
+ uint32_t *numModules);
+ static sp<Radio> attach(radio_handle_t handle,
+ const struct radio_band_config *config,
+ bool withAudio,
+ const sp<RadioCallback>& callback);
+
+
+ void detach();
+
+ status_t setConfiguration(const struct radio_band_config *config);
+
+ status_t getConfiguration(struct radio_band_config *config);
+
+ status_t setMute(bool mute);
+
+ status_t getMute(bool *mute);
+
+ status_t step(radio_direction_t direction, bool skipSubChannel);
+
+ status_t scan(radio_direction_t direction, bool skipSubChannel);
+
+ status_t tune(unsigned int channel, unsigned int subChannel);
+
+ status_t cancel();
+
+ status_t getProgramInformation(struct radio_program_info *info);
+
+ status_t hasControl(bool *hasControl);
+
+ // BpRadioClient
+ virtual void onEvent(const sp<IMemory>& eventMemory);
+
+ //IBinder::DeathRecipient
+ virtual void binderDied(const wp<IBinder>& who);
+
+private:
+ Radio(radio_handle_t handle,
+ const sp<RadioCallback>&);
+ static const sp<IRadioService>& getRadioService();
+
+ Mutex mLock;
+ sp<IRadio> mIRadio;
+ const radio_handle_t mHandle;
+ sp<RadioCallback> mCallback;
+};
+
+}; // namespace android
+
+#endif //ANDROID_HARDWARE_RADIO_H
diff --git a/include/radio/RadioCallback.h b/include/radio/RadioCallback.h
new file mode 100644
index 0000000..4a7f1a6
--- /dev/null
+++ b/include/radio/RadioCallback.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2015 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_RADIO_CALLBACK_H
+#define ANDROID_HARDWARE_RADIO_CALLBACK_H
+
+#include <utils/RefBase.h>
+#include <system/radio.h>
+
+namespace android {
+
+class RadioCallback : public RefBase
+{
+public:
+
+ RadioCallback() {}
+ virtual ~RadioCallback() {}
+
+ virtual void onEvent(struct radio_event *event) = 0;
+
+};
+
+}; // namespace android
+
+#endif //ANDROID_HARDWARE_RADIO_CALLBACK_H