summaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
Diffstat (limited to 'include/media')
-rw-r--r--include/media/AudioRecord.h235
-rw-r--r--include/media/AudioSystem.h122
-rw-r--r--include/media/AudioTrack.h277
-rw-r--r--include/media/IAudioFlinger.h124
-rw-r--r--include/media/IAudioRecord.h68
-rw-r--r--include/media/IAudioTrack.h84
-rw-r--r--include/media/IMediaPlayer.h65
-rw-r--r--include/media/IMediaPlayerClient.h48
-rw-r--r--include/media/IMediaPlayerService.h54
-rw-r--r--include/media/MediaPlayerInterface.h156
-rw-r--r--include/media/PVPlayer.h75
-rw-r--r--include/media/ToneGenerator.h175
-rw-r--r--include/media/mediametadataretriever.h101
-rw-r--r--include/media/mediaplayer.h138
-rw-r--r--include/media/mediarecorder.h120
-rw-r--r--include/media/mediascanner.h63
-rw-r--r--include/media/thread_init.h25
17 files changed, 1930 insertions, 0 deletions
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
new file mode 100644
index 0000000..008569f
--- /dev/null
+++ b/include/media/AudioRecord.h
@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AUDIORECORD_H_
+#define AUDIORECORD_H_
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <media/IAudioFlinger.h>
+#include <media/IAudioRecord.h>
+#include <media/AudioTrack.h>
+
+#include <utils/RefBase.h>
+#include <utils/Errors.h>
+#include <utils/IInterface.h>
+#include <utils/IMemory.h>
+#include <utils/threads.h>
+
+
+namespace android {
+
+// ----------------------------------------------------------------------------
+
+class AudioRecord
+{
+public:
+
+ enum stream_type {
+ DEFAULT_INPUT =-1,
+ MIC_INPUT = 0,
+ NUM_STREAM_TYPES
+ };
+
+ static const int DEFAULT_SAMPLE_RATE = 8000;
+
+ /* Create Buffer on the stack and pass it to obtainBuffer()
+ * and releaseBuffer().
+ */
+
+ class Buffer
+ {
+ public:
+ enum {
+ MUTE = 0x00000001
+ };
+ uint32_t flags;
+ int channelCount;
+ int format;
+ size_t frameCount;
+ size_t size;
+ union {
+ void* raw;
+ short* i16;
+ int8_t* i8;
+ };
+ };
+
+ /* These are static methods to control the system-wide AudioFlinger
+ * only privileged processes can have access to them
+ */
+
+// static status_t setMasterMute(bool mute);
+
+ /* Returns AudioFlinger's frame count. AudioRecord's buffers will
+ * be created with this size.
+ */
+ static size_t frameCount();
+
+ /* As a convenience, if a callback is supplied, a handler thread
+ * is automatically created with the appropriate priority. This thread
+ * invokes the callback when a new buffer becomes availlable.
+ */
+ typedef bool (*callback_t)(void* user, const Buffer& info);
+
+ /* Constructs an uninitialized AudioRecord. No connection with
+ * AudioFlinger takes place.
+ */
+ AudioRecord();
+
+ /* Creates an AudioRecord track and registers it with AudioFlinger.
+ * Once created, the track needs to be started before it can be used.
+ * Unspecified values are set to the audio hardware's current
+ * values.
+ */
+
+ AudioRecord(int streamType = 0,
+ uint32_t sampleRate = 0,
+ int format = 0,
+ int channelCount = 0,
+ int bufferCount = 0,
+ uint32_t flags = 0,
+ callback_t cbf = 0, void* user = 0);
+
+
+ /* Terminates the AudioRecord and unregisters it from AudioFlinger.
+ * Also destroys all resources assotiated with the AudioRecord.
+ */
+ ~AudioRecord();
+
+
+ /* Initialize an uninitialized AudioRecord. */
+ status_t set(int streamType = 0,
+ uint32_t sampleRate = 0,
+ int format = 0,
+ int channelCount = 0,
+ int bufferCount = 0,
+ uint32_t flags = 0,
+ callback_t cbf = 0, void* user = 0);
+
+
+ /* Result of constructing the AudioRecord. This must be checked
+ * before using any AudioRecord API (except for set()), using
+ * an uninitialized AudioRecord prduces undefined results.
+ */
+ status_t initCheck() const;
+
+ /* Returns this track's latency in nanoseconds or framecount.
+ * This only includes the latency due to the fill buffer size.
+ * In particular, the hardware or driver latencies are not accounted.
+ */
+ nsecs_t latency() const;
+
+ /* getters, see constructor */
+
+ uint32_t sampleRate() const;
+ int format() const;
+ int channelCount() const;
+ int bufferCount() const;
+
+
+ /* After it's created the track is not active. Call start() to
+ * make it active. If set, the callback will start being called.
+ */
+ status_t start();
+
+ /* Stop a track. If set, the callback will cease being called and
+ * obtainBuffer returns STOPPED. Note that obtainBuffer() still works
+ * and will fill up buffers until the pool is exhausted.
+ */
+ status_t stop();
+ bool stopped() const;
+
+ /* get sample rate for this track
+ */
+ uint32_t getSampleRate();
+
+ /* obtains a buffer of "frameCount" frames. The buffer must be
+ * filled entirely. If the track is stopped, obtainBuffer() returns
+ * STOPPED instead of NO_ERROR as long as there are buffers availlable,
+ * at which point NO_MORE_BUFFERS is returned.
+ * Buffers will be returned until the pool (buffercount())
+ * is exhausted, at which point obtainBuffer() will either block
+ * or return WOULD_BLOCK depending on the value of the "blocking"
+ * parameter.
+ */
+
+ enum {
+ NO_MORE_BUFFERS = 0x80000001,
+ STOPPED = 1
+ };
+
+ status_t obtainBuffer(Buffer* audioBuffer, bool blocking);
+ void releaseBuffer(Buffer* audioBuffer);
+
+
+ /* As a convenience we provide a read() interface to the audio buffer.
+ * This is implemented on top of lockBuffer/unlockBuffer.
+ */
+ ssize_t read(void* buffer, size_t size);
+
+private:
+ /* copying audio tracks is not allowed */
+ AudioRecord(const AudioRecord& other);
+ AudioRecord& operator = (const AudioRecord& other);
+
+ /* a small internal class to handle the callback */
+ class ClientRecordThread : public Thread
+ {
+ public:
+ ClientRecordThread(AudioRecord& receiver);
+ private:
+ friend class AudioRecord;
+ virtual bool threadLoop();
+ virtual status_t readyToRun() { return NO_ERROR; }
+ virtual void onFirstRef() {}
+ AudioRecord& mReceiver;
+ };
+
+ bool processAudioBuffer(const sp<ClientRecordThread>& thread);
+
+ sp<IAudioFlinger> mAudioFlinger;
+ sp<IAudioRecord> mAudioRecord;
+ sp<IMemory> mCblkMemory;
+ sp<ClientRecordThread> mClientRecordThread;
+ Mutex mRecordThreadLock;
+
+ uint32_t mSampleRate;
+ size_t mFrameCount;
+
+ audio_track_cblk_t* mCblk;
+ uint8_t mFormat;
+ uint8_t mBufferCount;
+ uint8_t mChannelCount : 4;
+ uint8_t mReserved : 3;
+ status_t mStatus;
+ nsecs_t mLatency;
+
+ volatile int32_t mActive;
+
+ callback_t mCbf;
+ void* mUserData;
+
+ AudioRecord::Buffer mAudioBuffer;
+ size_t mPosition;
+
+ uint32_t mReservedFBC[4];
+};
+
+}; // namespace android
+
+#endif /*AUDIORECORD_H_*/
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
new file mode 100644
index 0000000..9fcbea5
--- /dev/null
+++ b/include/media/AudioSystem.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIOSYSTEM_H_
+#define ANDROID_AUDIOSYSTEM_H_
+
+#include <utils/RefBase.h>
+#include <utils/threads.h>
+#include <media/IAudioFlinger.h>
+
+namespace android {
+
+typedef void (*audio_error_callback)(status_t err);
+
+class AudioSystem
+{
+public:
+
+ enum audio_format {
+ DEFAULT = 0,
+ PCM_16_BIT,
+ PCM_8_BIT,
+ INVALID_FORMAT
+ };
+
+ enum audio_mode {
+ MODE_INVALID = -2,
+ MODE_CURRENT = -1,
+ MODE_NORMAL = 0,
+ MODE_RINGTONE,
+ MODE_IN_CALL,
+ NUM_MODES // not a valid entry, denotes end-of-list
+ };
+
+ enum audio_routes {
+ ROUTE_EARPIECE = (1 << 0),
+ ROUTE_SPEAKER = (1 << 1),
+ ROUTE_BLUETOOTH = (1 << 2),
+ ROUTE_HEADSET = (1 << 3),
+ ROUTE_ALL = (ROUTE_EARPIECE | ROUTE_SPEAKER | ROUTE_BLUETOOTH | ROUTE_HEADSET)
+ };
+
+ /* These are static methods to control the system-wide AudioFlinger
+ * only privileged processes can have access to them
+ */
+
+ // routing helper functions
+ static status_t speakerphone(bool state);
+ static status_t isSpeakerphoneOn(bool* state);
+ static status_t bluetoothSco(bool state);
+ static status_t isBluetoothScoOn(bool* state);
+ static status_t muteMicrophone(bool state);
+ static status_t isMicrophoneMuted(bool *state);
+
+ static status_t setMasterVolume(float value);
+ static status_t setMasterMute(bool mute);
+ static status_t getMasterVolume(float* volume);
+ static status_t getMasterMute(bool* mute);
+
+ static status_t setStreamVolume(int stream, float value);
+ static status_t setStreamMute(int stream, bool mute);
+ static status_t getStreamVolume(int stream, float* volume);
+ static status_t getStreamMute(int stream, bool* mute);
+
+ static status_t setMode(int mode);
+ static status_t getMode(int* mode);
+
+ static status_t setRouting(int mode, uint32_t routes, uint32_t mask);
+ static status_t getRouting(int mode, uint32_t* routes);
+
+ static status_t isMusicActive(bool *state);
+
+ // Temporary interface, do not use
+ // TODO: Replace with a more generic key:value get/set mechanism
+ static status_t setParameter(const char* key, const char* value);
+
+ static void setErrorCallback(audio_error_callback cb);
+
+ // helper function to obtain AudioFlinger service handle
+ static const sp<IAudioFlinger>& get_audio_flinger();
+
+ static float linearToLog(int volume);
+ static int logToLinear(float volume);
+
+ // ----------------------------------------------------------------------------
+
+private:
+
+ class DeathNotifier: public IBinder::DeathRecipient
+ {
+ public:
+ DeathNotifier() {
+ }
+
+ virtual void binderDied(const wp<IBinder>& who);
+ };
+
+ static sp<DeathNotifier> gDeathNotifier;
+
+ friend class DeathNotifier;
+
+ static Mutex gLock;
+ static sp<IAudioFlinger> gAudioFlinger;
+ static audio_error_callback gAudioErrorCallback;
+};
+
+}; // namespace android
+
+#endif /*ANDROID_AUDIOSYSTEM_H_*/
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
new file mode 100644
index 0000000..a89d7ff
--- /dev/null
+++ b/include/media/AudioTrack.h
@@ -0,0 +1,277 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIOTRACK_H
+#define ANDROID_AUDIOTRACK_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <media/IAudioFlinger.h>
+#include <media/IAudioTrack.h>
+#include <media/AudioSystem.h>
+
+#include <utils/RefBase.h>
+#include <utils/Errors.h>
+#include <utils/IInterface.h>
+#include <utils/IMemory.h>
+#include <utils/threads.h>
+
+
+namespace android {
+
+// ----------------------------------------------------------------------------
+
+class audio_track_cblk_t;
+
+// ----------------------------------------------------------------------------
+
+class AudioTrack
+{
+public:
+
+ enum stream_type {
+ DEFAULT =-1,
+ VOICE_CALL = 0,
+ SYSTEM = 1,
+ RING = 2,
+ MUSIC = 3,
+ ALARM = 4,
+ NUM_STREAM_TYPES
+ };
+
+ enum channel_index {
+ MONO = 0,
+ LEFT = 0,
+ RIGHT = 1
+ };
+
+ /* Create Buffer on the stack and pass it to obtainBuffer()
+ * and releaseBuffer().
+ */
+
+ class Buffer
+ {
+ public:
+ enum {
+ MUTE = 0x00000001
+ };
+ uint32_t flags;
+ int channelCount;
+ int format;
+ size_t frameCount;
+ size_t size;
+ union {
+ void* raw;
+ short* i16;
+ int8_t* i8;
+ };
+ };
+
+ /* Returns AudioFlinger's frame count. AudioTrack's buffers will
+ * be created with this size.
+ */
+ static size_t frameCount();
+
+ /* As a convenience, if a callback is supplied, a handler thread
+ * is automatically created with the appropriate priority. This thread
+ * invokes the callback when a new buffer becomes availlable.
+ */
+ typedef void (*callback_t)(void* user, const Buffer& info);
+
+ /* Constructs an uninitialized AudioTrack. No connection with
+ * AudioFlinger takes place.
+ */
+ AudioTrack();
+
+ /* Creates an audio track and registers it with AudioFlinger.
+ * Once created, the track needs to be started before it can be used.
+ * Unspecified values are set to the audio hardware's current
+ * values.
+ */
+
+ AudioTrack( int streamType,
+ uint32_t sampleRate = 0,
+ int format = 0,
+ int channelCount = 0,
+ int bufferCount = 0,
+ uint32_t flags = 0,
+ callback_t cbf = 0, void* user = 0);
+
+
+ /* Terminates the AudioTrack and unregisters it from AudioFlinger.
+ * Also destroys all resources assotiated with the AudioTrack.
+ */
+ ~AudioTrack();
+
+
+ /* Initialize an uninitialized AudioTrack. */
+ status_t set(int streamType =-1,
+ uint32_t sampleRate = 0,
+ int format = 0,
+ int channelCount = 0,
+ int bufferCount = 0,
+ uint32_t flags = 0,
+ callback_t cbf = 0, void* user = 0);
+
+
+ /* Result of constructing the AudioTrack. This must be checked
+ * before using any AudioTrack API (except for set()), using
+ * an uninitialized AudoiTrack prduces undefined results.
+ */
+ status_t initCheck() const;
+
+ /* Returns this track's latency in nanoseconds or framecount.
+ * This only includes the latency due to the fill buffer size.
+ * In particular, the hardware or driver latencies are not accounted.
+ */
+ nsecs_t latency() const;
+
+ /* getters, see constructor */
+
+ int streamType() const;
+ uint32_t sampleRate() const;
+ int format() const;
+ int channelCount() const;
+ int bufferCount() const;
+
+
+ /* After it's created the track is not active. Call start() to
+ * make it active. If set, the callback will start being called.
+ */
+ void start();
+
+ /* Stop a track. If set, the callback will cease being called and
+ * obtainBuffer returns STOPPED. Note that obtainBuffer() still works
+ * and will fill up buffers until the pool is exhausted.
+ */
+ void stop();
+ bool stopped() const;
+
+ /* flush a stopped track. All pending buffers are discarded.
+ * This function has no effect if the track is not stoped.
+ */
+ void flush();
+
+ /* Pause a track. If set, the callback will cease being called and
+ * obtainBuffer returns STOPPED. Note that obtainBuffer() still works
+ * and will fill up buffers until the pool is exhausted.
+ */
+ void pause();
+
+ /* mute or unmutes this track.
+ * While mutted, the callback, if set, is still called.
+ */
+ void mute(bool);
+ bool muted() const;
+
+
+ /* set volume for this track, mostly used for games' sound effects
+ */
+ void setVolume(float left, float right);
+ void getVolume(float* left, float* right);
+
+ /* set sample rate for this track, mostly used for games' sound effects
+ */
+ void setSampleRate(int sampleRate);
+ uint32_t getSampleRate();
+
+ /* obtains a buffer of "frameCount" frames. The buffer must be
+ * filled entirely. If the track is stopped, obtainBuffer() returns
+ * STOPPED instead of NO_ERROR as long as there are buffers availlable,
+ * at which point NO_MORE_BUFFERS is returned.
+ * Buffers will be returned until the pool (buffercount())
+ * is exhausted, at which point obtainBuffer() will either block
+ * or return WOULD_BLOCK depending on the value of the "blocking"
+ * parameter.
+ */
+
+ enum {
+ NO_MORE_BUFFERS = 0x80000001,
+ STOPPED = 1
+ };
+
+ status_t obtainBuffer(Buffer* audioBuffer, bool blocking);
+ void releaseBuffer(Buffer* audioBuffer);
+
+
+ /* As a convenience we provide a write() interface to the audio buffer.
+ * This is implemented on top of lockBuffer/unlockBuffer. For best
+ * performance
+ *
+ */
+ ssize_t write(const void* buffer, size_t size);
+
+ /*
+ * Dumps the state of an audio track.
+ */
+ status_t dump(int fd, const Vector<String16>& args) const;
+
+private:
+ /* copying audio tracks is not allowed */
+ AudioTrack(const AudioTrack& other);
+ AudioTrack& operator = (const AudioTrack& other);
+
+ /* a small internal class to handle the callback */
+ class AudioTrackThread : public Thread
+ {
+ public:
+ AudioTrackThread(AudioTrack& receiver);
+ private:
+ friend class AudioTrack;
+ virtual bool threadLoop();
+ virtual status_t readyToRun();
+ virtual void onFirstRef();
+ AudioTrack& mReceiver;
+ Mutex mLock;
+ };
+
+ bool processAudioBuffer(const sp<AudioTrackThread>& thread);
+
+ sp<IAudioFlinger> mAudioFlinger;
+ sp<IAudioTrack> mAudioTrack;
+ sp<IMemory> mCblkMemory;
+ sp<AudioTrackThread> mAudioTrackThread;
+
+ float mVolume[2];
+ uint32_t mSampleRate;
+ size_t mFrameCount;
+
+ audio_track_cblk_t* mCblk;
+ uint8_t mStreamType;
+ uint8_t mFormat;
+ uint8_t mBufferCount;
+ uint8_t mChannelCount : 4;
+ uint8_t mMuted : 1;
+ uint8_t mReserved : 2;
+ status_t mStatus;
+ nsecs_t mLatency;
+
+ volatile int32_t mActive;
+
+ callback_t mCbf;
+ void* mUserData;
+
+ AudioTrack::Buffer mAudioBuffer;
+ size_t mPosition;
+
+ uint32_t mReservedFBC[4];
+};
+
+
+}; // namespace android
+
+#endif // ANDROID_AUDIOTRACK_H
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
new file mode 100644
index 0000000..fa8e121
--- /dev/null
+++ b/include/media/IAudioFlinger.h
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_IAUDIOFLINGER_H
+#define ANDROID_IAUDIOFLINGER_H
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <utils/RefBase.h>
+#include <utils/Errors.h>
+#include <utils/IInterface.h>
+#include <media/IAudioTrack.h>
+#include <media/IAudioRecord.h>
+
+
+namespace android {
+
+// ----------------------------------------------------------------------------
+
+class IAudioFlinger : public IInterface
+{
+public:
+ DECLARE_META_INTERFACE(AudioFlinger);
+
+ /* create an audio track and registers it with AudioFlinger.
+ * return null if the track cannot be created.
+ */
+ virtual sp<IAudioTrack> createTrack(
+ pid_t pid,
+ int streamType,
+ uint32_t sampleRate,
+ int format,
+ int channelCount,
+ int bufferCount,
+ uint32_t flags) = 0;
+
+ virtual sp<IAudioRecord> openRecord(
+ pid_t pid,
+ int streamType,
+ uint32_t sampleRate,
+ int format,
+ int channelCount,
+ int bufferCount,
+ uint32_t flags) = 0;
+
+ /* query the audio hardware state. This state never changes,
+ * and therefore can be cached.
+ */
+ virtual uint32_t sampleRate() const = 0;
+ virtual int channelCount() const = 0;
+ virtual int format() const = 0;
+ virtual size_t frameCount() const = 0;
+
+ /* set/get the audio hardware state. This will probably be used by
+ * the preference panel, mostly.
+ */
+ virtual status_t setMasterVolume(float value) = 0;
+ virtual status_t setMasterMute(bool muted) = 0;
+
+ virtual float masterVolume() const = 0;
+ virtual bool masterMute() const = 0;
+
+ /* set/get stream type state. This will probably be used by
+ * the preference panel, mostly.
+ */
+ virtual status_t setStreamVolume(int stream, float value) = 0;
+ virtual status_t setStreamMute(int stream, bool muted) = 0;
+
+ virtual float streamVolume(int stream) const = 0;
+ virtual bool streamMute(int stream) const = 0;
+
+ // set/get audio routing
+ virtual status_t setRouting(int mode, uint32_t routes, uint32_t mask) = 0;
+ virtual uint32_t getRouting(int mode) const = 0;
+
+ // set/get audio mode
+ virtual status_t setMode(int mode) = 0;
+ virtual int getMode() const = 0;
+
+ // mic mute/state
+ virtual status_t setMicMute(bool state) = 0;
+ virtual bool getMicMute() const = 0;
+
+ // is a music stream active?
+ virtual bool isMusicActive() const = 0;
+
+ // pass a generic configuration parameter to libaudio
+ // Temporary interface, do not use
+ // TODO: Replace with a more generic key:value get/set mechanism
+ virtual status_t setParameter(const char* key, const char* value) = 0;
+};
+
+
+// ----------------------------------------------------------------------------
+
+class BnAudioFlinger : public BnInterface<IAudioFlinger>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+// ----------------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // ANDROID_IAUDIOFLINGER_H
diff --git a/include/media/IAudioRecord.h b/include/media/IAudioRecord.h
new file mode 100644
index 0000000..9d45d2d
--- /dev/null
+++ b/include/media/IAudioRecord.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IAUDIORECORD_H_
+#define IAUDIORECORD_H_
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/RefBase.h>
+#include <utils/Errors.h>
+#include <utils/IInterface.h>
+#include <utils/IMemory.h>
+
+
+namespace android {
+
+// ----------------------------------------------------------------------------
+
+class IAudioRecord : public IInterface
+{
+public:
+ DECLARE_META_INTERFACE(AudioRecord);
+
+ /* After it's created the track is not active. Call start() to
+ * make it active. If set, the callback will start being called.
+ */
+ virtual status_t start() = 0;
+
+ /* Stop a track. If set, the callback will cease being called and
+ * obtainBuffer will return an error. Buffers that are already released
+ * will be processed, unless flush() is called.
+ */
+ virtual void stop() = 0;
+
+ /* get this tracks control block */
+ virtual sp<IMemory> getCblk() const = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnAudioRecord : public BnInterface<IAudioRecord>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+// ----------------------------------------------------------------------------
+
+}; // namespace android
+
+#endif /*IAUDIORECORD_H_*/
diff --git a/include/media/IAudioTrack.h b/include/media/IAudioTrack.h
new file mode 100644
index 0000000..12f2111
--- /dev/null
+++ b/include/media/IAudioTrack.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_IAUDIOTRACK_H
+#define ANDROID_IAUDIOTRACK_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/RefBase.h>
+#include <utils/Errors.h>
+#include <utils/IInterface.h>
+#include <utils/IMemory.h>
+
+
+namespace android {
+
+// ----------------------------------------------------------------------------
+
+class IAudioTrack : public IInterface
+{
+public:
+ DECLARE_META_INTERFACE(AudioTrack);
+
+ /* After it's created the track is not active. Call start() to
+ * make it active. If set, the callback will start being called.
+ */
+ virtual status_t start() = 0;
+
+ /* Stop a track. If set, the callback will cease being called and
+ * obtainBuffer will return an error. Buffers that are already released
+ * will be processed, unless flush() is called.
+ */
+ virtual void stop() = 0;
+
+ /* flush a stopped track. All pending buffers are discarded.
+ * This function has no effect if the track is not stoped.
+ */
+ virtual void flush() = 0;
+
+ /* mute or unmutes this track.
+ * While mutted, the callback, if set, is still called.
+ */
+ virtual void mute(bool) = 0;
+
+ /* Pause a track. If set, the callback will cease being called and
+ * obtainBuffer will return an error. Buffers that are already released
+ * will be processed, unless flush() is called.
+ */
+ virtual void pause() = 0;
+
+ /* get this tracks control block */
+ virtual sp<IMemory> getCblk() const = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnAudioTrack : public BnInterface<IAudioTrack>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+// ----------------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // ANDROID_IAUDIOTRACK_H
diff --git a/include/media/IMediaPlayer.h b/include/media/IMediaPlayer.h
new file mode 100644
index 0000000..43abf77
--- /dev/null
+++ b/include/media/IMediaPlayer.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_IMEDIAPLAYER_H
+#define ANDROID_IMEDIAPLAYER_H
+
+#include <utils/RefBase.h>
+#include <utils/IInterface.h>
+#include <utils/Parcel.h>
+
+namespace android {
+
+class ISurface;
+
+class IMediaPlayer: public IInterface
+{
+public:
+ DECLARE_META_INTERFACE(MediaPlayer);
+
+ virtual void disconnect() = 0;
+
+ virtual status_t setVideoSurface(const sp<ISurface>& surface) = 0;
+ virtual status_t prepareAsync() = 0;
+ virtual status_t start() = 0;
+ virtual status_t stop() = 0;
+ virtual status_t pause() = 0;
+ virtual status_t isPlaying(bool* state) = 0;
+ virtual status_t getVideoSize(int* w, int* h) = 0;
+ virtual status_t seekTo(int msec) = 0;
+ virtual status_t getCurrentPosition(int* msec) = 0;
+ virtual status_t getDuration(int* msec) = 0;
+ virtual status_t reset() = 0;
+ virtual status_t setAudioStreamType(int type) = 0;
+ virtual status_t setLooping(int loop) = 0;
+ virtual status_t setVolume(float leftVolume, float rightVolume) = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnMediaPlayer: public BnInterface<IMediaPlayer>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif // ANDROID_IMEDIAPLAYER_H
+
diff --git a/include/media/IMediaPlayerClient.h b/include/media/IMediaPlayerClient.h
new file mode 100644
index 0000000..5d32811
--- /dev/null
+++ b/include/media/IMediaPlayerClient.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_IMEDIAPLAYERCLIENT_H
+#define ANDROID_IMEDIAPLAYERCLIENT_H
+
+#include <utils/RefBase.h>
+#include <utils/IInterface.h>
+#include <utils/Parcel.h>
+
+namespace android {
+
+class IMediaPlayerClient: public IInterface
+{
+public:
+ DECLARE_META_INTERFACE(MediaPlayerClient);
+
+ virtual void notify(int msg, int ext1, int ext2) = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnMediaPlayerClient: public BnInterface<IMediaPlayerClient>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif // ANDROID_IMEDIAPLAYERCLIENT_H
+
diff --git a/include/media/IMediaPlayerService.h b/include/media/IMediaPlayerService.h
new file mode 100644
index 0000000..63c7a00
--- /dev/null
+++ b/include/media/IMediaPlayerService.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_IMEDIAPLAYERSERVICE_H
+#define ANDROID_IMEDIAPLAYERSERVICE_H
+
+#include <utils/RefBase.h>
+#include <utils/IInterface.h>
+#include <utils/Parcel.h>
+
+#include <media/IMediaPlayerClient.h>
+#include <media/IMediaPlayer.h>
+
+namespace android {
+
+class IMediaPlayerService: public IInterface
+{
+public:
+ DECLARE_META_INTERFACE(MediaPlayerService);
+
+ virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client, const char* url) = 0;
+ virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client, int fd, int64_t offset, int64_t length) = 0;
+ virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels) = 0;
+ virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels) = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnMediaPlayerService: public BnInterface<IMediaPlayerService>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif // ANDROID_IMEDIAPLAYERSERVICE_H
+
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
new file mode 100644
index 0000000..275e789
--- /dev/null
+++ b/include/media/MediaPlayerInterface.h
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_MEDIAPLAYERINTERFACE_H
+#define ANDROID_MEDIAPLAYERINTERFACE_H
+
+#include <pthread.h>
+#include <signal.h>
+
+#ifdef __cplusplus
+
+#include <ui/ISurface.h>
+#include <utils/RefBase.h>
+
+#include <media/mediaplayer.h>
+
+namespace android {
+
+enum player_type {
+ PV_PLAYER = 1,
+ SONIVOX_PLAYER = 2,
+ VORBIS_PLAYER = 3
+};
+
+#define DEFAULT_AUDIOSINK_BUFFERCOUNT 4
+
+// callback mechanism for passing messages to MediaPlayer object
+typedef void (*notify_callback_f)(void* cookie, int msg, int ext1, int ext2);
+
+// abstract base class - use MediaPlayerInterface
+class MediaPlayerBase : public RefBase
+{
+public:
+
+ // AudioSink: abstraction layer for audio output
+ class AudioSink : public RefBase {
+ public:
+ virtual ~AudioSink() {}
+ virtual bool ready() const = 0; // audio output is open and ready
+ virtual bool realtime() const = 0; // audio output is real-time output
+ virtual ssize_t bufferSize() const = 0;
+ virtual ssize_t frameCount() const = 0;
+ virtual ssize_t channelCount() const = 0;
+ virtual ssize_t frameSize() const = 0;
+ virtual uint32_t latency() const = 0;
+ virtual float msecsPerFrame() const = 0;
+ virtual status_t open(uint32_t sampleRate, int channelCount, int bufferCount=DEFAULT_AUDIOSINK_BUFFERCOUNT) = 0;
+ virtual void start() = 0;
+ virtual ssize_t write(const void* buffer, size_t size) = 0;
+ virtual void stop() = 0;
+ virtual void flush() = 0;
+ virtual void pause() = 0;
+ virtual void close() = 0;
+ };
+
+ MediaPlayerBase() : mCookie(0), mNotify(0) {}
+ virtual ~MediaPlayerBase() {}
+ virtual status_t initCheck() = 0;
+ virtual bool hardwareOutput() = 0;
+ virtual status_t setSigBusHandlerStructTLSKey(pthread_key_t key) { return 0; }
+ virtual status_t setDataSource(const char *url) = 0;
+ virtual status_t setDataSource(int fd, int64_t offset, int64_t length) = 0;
+ virtual status_t setVideoSurface(const sp<ISurface>& surface) = 0;
+ virtual status_t prepare() = 0;
+ virtual status_t prepareAsync() = 0;
+ virtual status_t start() = 0;
+ virtual status_t stop() = 0;
+ virtual status_t pause() = 0;
+ virtual bool isPlaying() = 0;
+ virtual status_t getVideoWidth(int *w) {return 0;}
+ virtual status_t getVideoHeight(int *h) {return 0;}
+ virtual status_t seekTo(int msec) = 0;
+ virtual status_t getCurrentPosition(int *msec) = 0;
+ virtual status_t getDuration(int *msec) = 0;
+ virtual status_t reset() = 0;
+ virtual status_t setLooping(int loop) = 0;
+ virtual player_type playerType() = 0;
+ virtual void setNotifyCallback(void* cookie, notify_callback_f notifyFunc) {
+ mCookie = cookie; mNotify = notifyFunc; }
+
+protected:
+ virtual void sendEvent(int msg, int ext1=0, int ext2=0) { if (mNotify) mNotify(mCookie, msg, ext1, ext2); }
+
+ void* mCookie;
+ notify_callback_f mNotify;
+};
+
+// Implement this class for media players that use the AudioFlinger software mixer
+class MediaPlayerInterface : public MediaPlayerBase
+{
+public:
+ virtual ~MediaPlayerInterface() { }
+ virtual bool hardwareOutput() { return false; }
+ virtual void setAudioSink(const sp<AudioSink>& audioSink) { mAudioSink = audioSink; }
+protected:
+ sp<AudioSink> mAudioSink;
+};
+
+// Implement this class for media players that output directo to hardware
+class MediaPlayerHWInterface : public MediaPlayerBase
+{
+public:
+ virtual ~MediaPlayerHWInterface() {}
+ virtual bool hardwareOutput() { return true; }
+ virtual status_t setVolume(float leftVolume, float rightVolume) = 0;
+ virtual status_t setAudioStreamType(int streamType) = 0;
+};
+
+}; // namespace android
+
+#endif // __cplusplus
+
+// A thread can set the thread local variable identified by the pthread_key_t
+// that was passed to the player using the setSigBusHandlerStructTLSKey()
+// method to the address of the following structure.
+// If 'handlesigbus' is non-NULL, the function it points to will be called,
+// and if it returns 0, the signal will be assumed to have been handled,
+// and no other action will be taken. If it returns non-zero, the old SIGBUS
+// handler will be called.
+// If 'handlesigbus is NULL, then sigbusvar must be non NULL. The system's
+// SIGBUS handler will map an accessible page filled with zeroes at the
+// location that caused the original fault, set the variable pointed to by
+// sigbusvar to a non-zero value, and exit (which causes the operation to
+// be retried, which should now succeed).
+// If base and len are non zero, which is strongly recommended, they will
+// be used as additional constraints on the signal handler. That is, when
+// specified, the fault address must be in the range specified by base and
+// len in order for handlesigbus() to be called or sigbusvar to be set.
+// If the fault address is outside of the range, the old SIGBUS handler
+// will be called.
+struct mediasigbushandler {
+ int (*handlesigbus)(siginfo_t *, struct mediasigbushandler *);
+ int *sigbusvar;
+ char *base;
+ int len;
+ // these next two are free for application use
+ struct mediasigbushandler *next;
+ void *data;
+};
+
+
+#endif // ANDROID_MEDIAPLAYERINTERFACE_H
+
diff --git a/include/media/PVPlayer.h b/include/media/PVPlayer.h
new file mode 100644
index 0000000..8164d8c
--- /dev/null
+++ b/include/media/PVPlayer.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_PVPLAYER_H
+#define ANDROID_PVPLAYER_H
+
+#include <utils/Errors.h>
+#include <media/MediaPlayerInterface.h>
+
+class PlayerDriver;
+
+namespace android {
+
+class PVPlayer : public MediaPlayerInterface
+{
+public:
+ PVPlayer();
+ virtual ~PVPlayer();
+
+ virtual status_t initCheck();
+ virtual status_t setSigBusHandlerStructTLSKey(pthread_key_t key);
+ virtual status_t setDataSource(const char *url);
+ virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
+ virtual status_t setVideoSurface(const sp<ISurface>& surface);
+ virtual status_t prepare();
+ virtual status_t prepareAsync();
+ virtual status_t start();
+ virtual status_t stop();
+ virtual status_t pause();
+ virtual bool isPlaying();
+ virtual status_t getVideoWidth(int *w);
+ virtual status_t getVideoHeight(int *h);
+ virtual status_t seekTo(int msec);
+ virtual status_t getCurrentPosition(int *msec);
+ virtual status_t getDuration(int *msec);
+ virtual status_t reset();
+ virtual status_t setLooping(int loop);
+ virtual player_type playerType() { return PV_PLAYER; }
+
+ // make available to PlayerDriver
+ void sendEvent(int msg, int ext1=0, int ext2=0) { MediaPlayerBase::sendEvent(msg, ext1, ext2); }
+
+private:
+ static void do_nothing(status_t s, void *cookie) { }
+ static void run_init(status_t s, void *cookie);
+ static void run_set_video_surface(status_t s, void *cookie);
+ static void run_set_audio_output(status_t s, void *cookie);
+ static void run_prepare(status_t s, void *cookie);
+
+ PlayerDriver* mPlayerDriver;
+ char * mDataSourcePath;
+ bool mIsDataSourceSet;
+ sp<ISurface> mSurface;
+ void * mMemBase;
+ off_t mMemSize;
+ status_t mInit;
+ int mDuration;
+};
+
+}; // namespace android
+
+#endif // ANDROID_PVPLAYER_H
diff --git a/include/media/ToneGenerator.h b/include/media/ToneGenerator.h
new file mode 100644
index 0000000..bc27d35
--- /dev/null
+++ b/include/media/ToneGenerator.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_TONEGENERATOR_H_
+#define ANDROID_TONEGENERATOR_H_
+
+#include <utils/RefBase.h>
+#include <utils/Vector.h>
+#include <utils/threads.h>
+#include <media/AudioSystem.h>
+#include <media/AudioTrack.h>
+
+namespace android {
+
+class ToneGenerator {
+public:
+
+ // List of all available tones
+ // This enum must be kept consistant with constants in ToneGenerator JAVA class
+ enum tone_type {
+ // DTMF tones ITU-T Recommendation Q.23
+ TONE_DTMF_0 = 0, // 0 key: 1336Hz, 941Hz
+ TONE_DTMF_1, // 1 key: 1209Hz, 697Hz
+ TONE_DTMF_2, // 2 key: 1336Hz, 697Hz
+ TONE_DTMF_3, // 3 key: 1477Hz, 697Hz
+ TONE_DTMF_4, // 4 key: 1209Hz, 770Hz
+ TONE_DTMF_5, // 5 key: 1336Hz, 770Hz
+ TONE_DTMF_6, // 6 key: 1477Hz, 770Hz
+ TONE_DTMF_7, // 7 key: 1209Hz, 852Hz
+ TONE_DTMF_8, // 8 key: 1336Hz, 852Hz
+ TONE_DTMF_9, // 9 key: 1477Hz, 852Hz
+ TONE_DTMF_S, // * key: 1209Hz, 941Hz
+ TONE_DTMF_P, // # key: 1477Hz, 941Hz
+ TONE_DTMF_A, // A key: 1633Hz, 697Hz
+ TONE_DTMF_B, // B key: 1633Hz, 770Hz
+ TONE_DTMF_C, // C key: 1633Hz, 852Hz
+ TONE_DTMF_D, // D key: 1633Hz, 941Hz
+ // Call supervisory tones: 3GPP TS 22.001 (CEPT)
+ TONE_SUP_DIAL, // Dial tone: 425Hz, continuous
+ TONE_SUP_BUSY, // Busy tone: 425Hz, 500ms ON, 500ms OFF...
+ TONE_SUP_CONGESTION, // Congestion tone: 425Hz, 200ms ON, 200ms OFF...
+ TONE_SUP_RADIO_ACK, // Radio path acknowlegment: 425Hz, 200ms ON
+ TONE_SUP_RADIO_NOTAVAIL, // Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts
+ TONE_SUP_ERROR, // Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF...
+ TONE_SUP_CALL_WAITING, // Call Waiting: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF...
+ TONE_SUP_RINGTONE, // Ring Tone: 425Hz, 1s ON, 4s OFF...
+ // Proprietary tones: 3GPP TS 31.111
+ TONE_PROP_BEEP, // General beep: 400Hz+1200Hz, 35ms ON
+ TONE_PROP_ACK, // Positive Acknowlgement: 1200Hz, 100ms ON, 100ms OFF 2 bursts
+ TONE_PROP_NACK, // Negative Acknowlgement: 300Hz+400Hz+500Hz, 400ms ON
+ TONE_PROP_PROMPT, // Prompt tone: 400Hz+1200Hz, 200ms ON
+ TONE_PROP_BEEP2, // General double beep: 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms on
+ NUM_TONES
+ };
+
+ ToneGenerator(int streamType, float volume);
+ ~ToneGenerator();
+
+ bool startTone(int toneType);
+ void stopTone();
+
+ bool isInited() { return (mState == TONE_IDLE)?false:true;}
+
+private:
+
+ enum tone_state {
+ TONE_IDLE, // ToneGenerator is being initialized or initialization failed
+ TONE_INIT, // ToneGenerator has been successfully initialized and is not playing
+ TONE_STARTING, // ToneGenerator is starting playing
+ TONE_PLAYING, // ToneGenerator is playing
+ TONE_STOPPING, // ToneGenerator is stoping
+ TONE_RESTARTING //
+ };
+
+ static const unsigned int NUM_PCM_BUFFERS = 2; // number of pcm buffers of audio track
+
+ static const unsigned int TONEGEN_MAX_WAVES = 3;
+ static const unsigned int TONEGEN_MAX_SEGMENTS = 4; // Maximun number of elenemts in
+ static const unsigned int TONEGEN_INF = 0xFFFFFFFF; // Represents infinite time duration
+ static const float TONEGEN_GAIN = 0.9; // Default gain passed to WaveGenerator().
+
+ // ToneDescriptor class contains all parameters needed to generate a tone:
+ // - The array waveFreq[] contains the frequencies of all individual waves making the multi-tone.
+ // The number of sine waves varies from 1 to TONEGEN_MAX_WAVES.
+ // The first null value indicates that no more waves are needed.
+ // - The array segments[] is used to generate the tone pulses. A segment is a period of time
+ // during which the tone is ON or OFF. Segments with even index (starting from 0)
+ // correspond to tone ON state and segments with odd index to OFF state.
+ // The data stored in segments[] is the duration of the corresponding period in ms.
+ // The first segment encountered with a 0 duration indicates that no more segment follows.
+ // - repeatCnt indicates the number of times the sequence described by segments[] array must be repeated.
+ // When the tone generator encounters the first 0 duration segment, it will compare repeatCnt to mCurCount.
+ // If mCurCount > repeatCnt, the tone is stopped automatically.
+
+ class ToneDescriptor {
+ public:
+ unsigned short waveFreq[TONEGEN_MAX_WAVES+1];
+ unsigned long segments[TONEGEN_MAX_SEGMENTS+1];
+ unsigned long repeatCnt;
+ };
+
+ static const ToneDescriptor toneDescriptors[NUM_TONES];
+
+ unsigned int mTotalSmp; // Total number of audio samples played (gives current time)
+ unsigned int mNextSegSmp; // Position of next segment transition expressed in samples
+ // NOTE: because mTotalSmp, mNextSegSmp are stored on 32 bit, current design will operate properly
+ // only if tone duration is less than about 27 Hours(@44100Hz sampling rate). If this time is exceeded,
+ // no crash will occur but tone sequence will show a glitch.
+
+ unsigned short mCurSegment; // Current segment index in ToneDescriptor segments[]
+ unsigned short mCurCount; // Current sequence repeat count
+ volatile unsigned short mState; // ToneGenerator state (tone_state)
+ const ToneDescriptor *mpToneDesc; // pointer to active tone descriptor
+ const ToneDescriptor *mpNewToneDesc; // pointer to next active tone descriptor
+
+ unsigned int mSamplingRate; // Sampling rate
+ AudioTrack *mpAudioTrack; // Pointer to audio track used for playback
+ Mutex mLock; // Mutex to control concurent access to ToneGenerator object from audio callback and application API
+ Mutex mCbkCondLock; // Mutex associated to mWaitCbkCond
+ Condition mWaitCbkCond; // condition enabling interface to wait for audio callback completion after a change is requested
+ float mVolume; // Volume applied to audio track
+
+ static void audioCallback(void* user, const AudioTrack::Buffer& info);
+ bool prepareWave();
+ unsigned int numWaves();
+ void clearWaveGens();
+
+ // WaveGenerator generates a single sine wave
+ class WaveGenerator {
+ public:
+ enum gen_command {
+ WAVEGEN_START, // Start/restart wave from phase 0
+ WAVEGEN_CONT, // Continue wave from current phase
+ WAVEGEN_STOP // Stop wave on zero crossing
+ };
+
+ WaveGenerator(unsigned short samplingRate, unsigned short frequency,
+ float volume);
+ ~WaveGenerator();
+
+ void getSamples(short *outBuffer, unsigned int count,
+ unsigned int command);
+
+ private:
+ static const short GEN_AMP = 32000; // amplitude of generator
+ static const short S_Q14 = 14; // shift for Q14
+ static const short S_Q15 = 15; // shift for Q15
+
+ short mA1_Q14; // Q14 coefficient
+ // delay line of full amplitude generator
+ short mS1, mS2; // delay line S2 oldest
+ short mS2_0; // saved value for reinitialisation
+ short mAmplitude_Q15; // Q15 amplitude
+ };
+
+ Vector<WaveGenerator *> mWaveGens; // list of active wave generators.
+};
+
+}
+; // namespace android
+
+#endif /*ANDROID_TONEGENERATOR_H_*/
diff --git a/include/media/mediametadataretriever.h b/include/media/mediametadataretriever.h
new file mode 100644
index 0000000..586dda1c
--- /dev/null
+++ b/include/media/mediametadataretriever.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef MEDIAMETADATARETRIEVER_H
+#define MEDIAMETADATARETRIEVER_H
+
+#include <graphics/SkBitmap.h> // for SkBitmap
+
+namespace android {
+
+// Keep these in synch with the constants defined in MediaMetadataRetriever.java
+// class.
+enum {
+ METADATA_KEY_CD_TRACK_NUMBER = 0,
+ METADATA_KEY_ALBUM = 1,
+ METADATA_KEY_ARTIST = 2,
+ METADATA_KEY_AUTHOR = 3,
+ METADATA_KEY_COMPOSER = 4,
+ METADATA_KEY_DATE = 5,
+ METADATA_KEY_GENRE = 6,
+ METADATA_KEY_TITLE = 7,
+ METADATA_KEY_YEAR = 8,
+ METADATA_KEY_DURATION = 9,
+ METADATA_KEY_NUM_TRACKS = 10,
+ METADATA_KEY_IS_DRM_CRIPPLED = 11,
+ METADATA_KEY_CODEC = 12,
+ // Add more here...
+};
+
+// A utility class that holds the size and actual data in album art.
+class MediaAlbumArt {
+public:
+ MediaAlbumArt(): length(0), data(NULL) {}
+ MediaAlbumArt(const MediaAlbumArt& copy) {
+ // Don't be caught by uninitialized variables!!
+ length = 0;
+ data = NULL;
+ setData(copy.length, copy.data);
+ }
+ MediaAlbumArt(const char* url);
+ ~MediaAlbumArt() { clearData(); }
+
+ void clearData();
+ status_t setData(unsigned int len, const char* buf);
+ char *getData() const { return copyData(length, data); }
+ unsigned int getLength() const { return length; }
+
+private:
+ // Disable copy assignment operator!
+ MediaAlbumArt& operator=(const MediaAlbumArt& rhs);
+ static char* copyData(unsigned int len, const char* buf);
+
+ unsigned int length; // Number of bytes in data.
+ char *data; // Actual binary data.
+};
+
+class MediaMetadataRetrieverImpl
+{
+public:
+ virtual ~MediaMetadataRetrieverImpl() {};
+ virtual status_t setDataSource(const char* dataSourceUrl) = 0;
+ virtual SkBitmap *captureFrame() = 0;
+ virtual const char* extractMetadata(int keyCode) = 0;
+ virtual MediaAlbumArt* extractAlbumArt() = 0;
+ virtual void setMode(int mode) = 0;
+};
+
+class MediaMetadataRetriever
+{
+public:
+ static status_t setDataSource(const char* dataSourceUrl);
+ static SkBitmap *captureFrame();
+ static const char* extractMetadata(int keyCode);
+ static MediaAlbumArt* extractAlbumArt();
+ static void setMode(int mode);
+ static void release();
+ static void create();
+
+private:
+ MediaMetadataRetriever() {}
+ static MediaMetadataRetrieverImpl *mRetriever;
+ static void *mLibHandler;
+};
+
+}; // namespace android
+
+#endif // MEDIAMETADATARETRIEVER_H
diff --git a/include/media/mediaplayer.h b/include/media/mediaplayer.h
new file mode 100644
index 0000000..aadfc32
--- /dev/null
+++ b/include/media/mediaplayer.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_MEDIAPLAYER_H
+#define ANDROID_MEDIAPLAYER_H
+
+#include <ui/Surface.h>
+#include <media/AudioTrack.h>
+#include <media/IMediaPlayerClient.h>
+#include <media/IMediaPlayer.h>
+#include <media/IMediaPlayerService.h>
+
+namespace android {
+
+enum media_event_type {
+ MEDIA_NOP = 0, // interface test message
+ MEDIA_PREPARED = 1,
+ MEDIA_PLAYBACK_COMPLETE = 2,
+ MEDIA_BUFFERING_UPDATE = 3,
+ MEDIA_SEEK_COMPLETE = 4,
+ MEDIA_ERROR = 100,
+};
+
+typedef int media_error_type;
+const media_error_type MEDIA_ERROR_UNKNOWN = 1;
+const media_error_type MEDIA_ERROR_SERVER_DIED = 100;
+
+enum media_player_states {
+ MEDIA_PLAYER_STATE_ERROR = 0,
+ MEDIA_PLAYER_IDLE = 1 << 0,
+ MEDIA_PLAYER_INITIALIZED = 1 << 1,
+ MEDIA_PLAYER_PREPARING = 1 << 2,
+ MEDIA_PLAYER_PREPARED = 1 << 3,
+ MEDIA_PLAYER_STARTED = 1 << 4,
+ MEDIA_PLAYER_PAUSED = 1 << 5,
+ MEDIA_PLAYER_STOPPED = 1 << 6,
+ MEDIA_PLAYER_PLAYBACK_COMPLETE = 1 << 7
+};
+
+// ----------------------------------------------------------------------------
+// ref-counted object for callbacks
+class MediaPlayerListener: public RefBase
+{
+public:
+ virtual void notify(int msg, int ext1, int ext2) = 0;
+};
+
+class MediaPlayer : public BnMediaPlayerClient, public IBinder::DeathRecipient
+{
+public:
+ MediaPlayer();
+ ~MediaPlayer();
+
+ void disconnect();
+ status_t setDataSource(const char *url);
+ status_t setDataSource(int fd, int64_t offset, int64_t length);
+ status_t setVideoSurface(const sp<Surface>& surface);
+ status_t setListener(const sp<MediaPlayerListener>& listener);
+ status_t prepare();
+ status_t prepareAsync();
+ status_t start();
+ status_t stop();
+ status_t pause();
+ bool isPlaying();
+ status_t getVideoWidth(int *w);
+ status_t getVideoHeight(int *h);
+ status_t seekTo(int msec);
+ status_t getCurrentPosition(int *msec);
+ status_t getDuration(int *msec);
+ status_t reset();
+ status_t setAudioStreamType(int type);
+ status_t setLooping(int loop);
+ status_t setVolume(float leftVolume, float rightVolume);
+ void notify(int msg, int ext1, int ext2);
+ static sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels);
+ static sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels);
+
+private:
+ void clear_l();
+ status_t seekTo_l(int msec);
+ status_t prepareAsync_l();
+ status_t getDuration_l(int *msec);
+ status_t setDataSource(const sp<IMediaPlayer>& player);
+
+ static const sp<IMediaPlayerService>& getMediaPlayerService();
+ virtual void binderDied(const wp<IBinder>& who);
+
+ class DeathNotifier: public IBinder::DeathRecipient
+ {
+ public:
+ DeathNotifier() {}
+ virtual ~DeathNotifier();
+
+ virtual void binderDied(const wp<IBinder>& who);
+ };
+
+ static sp<DeathNotifier> mDeathNotifier;
+
+ sp<IMediaPlayer> mPlayer;
+ Mutex mLock;
+ Mutex mNotifyLock;
+ Condition mSignal;
+ sp<MediaPlayerListener> mListener;
+ void* mCookie;
+ media_player_states mCurrentState;
+ int mDuration;
+ int mCurrentPosition;
+ int mSeekPosition;
+ bool mPrepareSync;
+ status_t mPrepareStatus;
+ int mStreamType;
+ bool mLoop;
+ float mLeftVolume;
+ float mRightVolume;
+
+ friend class DeathNotifier;
+
+ static Mutex mServiceLock;
+ static sp<IMediaPlayerService> mMediaPlayerService;
+};
+
+}; // namespace android
+
+#endif // ANDROID_MEDIAPLAYER_H
+
diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h
new file mode 100644
index 0000000..f247424
--- /dev/null
+++ b/include/media/mediarecorder.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MEDIARECORDER_H
+#define MEDIARECORDER_H
+
+#include <utils.h>
+#include <ui/SurfaceComposerClient.h>
+
+namespace android {
+
+class AuthorDriverWrapper;
+
+typedef void (*media_completion_f)(status_t status, void *cookie);
+
+/* Do not change these values without updating their counterparts
+ * in java/android/android/media/MediaRecorder.java!
+ */
+enum audio_source {
+ AUDIO_SOURCE_DEFAULT = 0,
+ AUDIO_SOURCE_MIC = 1,
+};
+
+enum video_source {
+ VIDEO_SOURCE_DEFAULT = 0,
+ VIDEO_SOURCE_CAMERA = 1,
+};
+
+enum output_format {
+ OUTPUT_FORMAT_DEFAULT = 0,
+ OUTPUT_FORMAT_THREE_GPP = 1,
+ OUTPUT_FORMAT_MPEG_4 = 2,
+};
+
+enum audio_encoder {
+ AUDIO_ENCODER_DEFAULT = 0,
+ AUDIO_ENCODER_AMR_NB = 1,
+};
+
+enum video_encoder {
+ VIDEO_ENCODER_DEFAULT = 0,
+ VIDEO_ENCODER_H263 = 1,
+ VIDEO_ENCODER_H264 = 2,
+ VIDEO_ENCODER_MPEG_4_SP = 3,
+};
+
+/*
+ * The state machine of the media_recorder uses a set of different state names.
+ * The mapping between the media_recorder and the pvauthorengine is shown below:
+ *
+ * mediarecorder pvauthorengine
+ * ----------------------------------------------------------------
+ * MEDIA_RECORDER_ERROR ERROR
+ * MEDIA_RECORDER_IDLE IDLE
+ * MEDIA_RECORDER_INITIALIZED OPENED
+ * MEDIA_RECORDER_PREPARING
+ * MEDIA_RECORDER_PREPARED INITIALIZED
+ * MEDIA_RECORDER_RECORDING RECORDING
+ */
+enum media_recorder_states {
+ MEDIA_RECORDER_ERROR = 0,
+ MEDIA_RECORDER_IDLE = 1 << 0,
+ MEDIA_RECORDER_INITIALIZED = 1 << 1,
+ MEDIA_RECORDER_PREPARING = 1 << 2,
+ MEDIA_RECORDER_PREPARED = 1 << 3,
+ MEDIA_RECORDER_RECORDING = 1 << 4,
+};
+
+class MediaRecorder
+{
+public:
+ MediaRecorder();
+ ~MediaRecorder();
+
+ status_t init();
+
+ status_t setAudioSource(audio_source as);
+ status_t setVideoSource(video_source vs);
+ status_t setOutputFormat(output_format of);
+ status_t setAudioEncoder(audio_encoder ae);
+ status_t setVideoEncoder(video_encoder ve);
+ status_t setVideoSize(int width, int height);
+ status_t setVideoFrameRate(int frames_per_second);
+ status_t setPreviewSurface(const sp<Surface>& surface);
+
+ status_t setOutputFile(const char *path);
+ // XXX metadata setup
+
+ status_t prepare();
+ status_t start();
+ status_t stop();
+ status_t reset();
+ status_t getIfOutputFormatSpecified();
+
+ status_t getMaxAmplitude(int *max);
+
+private:
+ AuthorDriverWrapper *mAuthorDriverWrapper;
+ bool mOutputFormatSpecified;
+ media_recorder_states mCurrentState;
+
+};
+
+}; // namespace android
+
+#endif // MEDIAPLAYER_H
+
diff --git a/include/media/mediascanner.h b/include/media/mediascanner.h
new file mode 100644
index 0000000..5d0122d
--- /dev/null
+++ b/include/media/mediascanner.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MEDIASCANNER_H
+#define MEDIASCANNER_H
+
+#include <utils.h>
+#include <pthread.h>
+
+namespace android {
+
+class MediaScannerClient;
+
+class MediaScanner
+{
+public:
+ MediaScanner();
+ ~MediaScanner();
+
+ typedef bool (*ExceptionCheck)(void* env);
+
+ status_t processFile(const char *path, const char *mimeType, MediaScannerClient& client);
+ status_t processDirectory(const char *path, const char* extensions,
+ MediaScannerClient& client, ExceptionCheck exceptionCheck, void* exceptionEnv);
+
+ // extracts album art as a block of data
+ char* extractAlbumArt(int fd);
+
+ static void uninitializeForThread();
+
+private:
+ status_t doProcessDirectory(char *path, int pathRemaining, const char* extensions,
+ MediaScannerClient& client, ExceptionCheck exceptionCheck, void* exceptionEnv);
+ void initializeForThread();
+};
+
+
+class MediaScannerClient
+{
+public:
+ virtual ~MediaScannerClient() {}
+ virtual bool scanFile(const char* path, long long lastModified, long long fileSize) = 0;
+ virtual bool handleStringTag(const char* name, const char* value) = 0;
+ virtual bool setMimeType(const char* mimeType) = 0;
+};
+
+}; // namespace android
+
+#endif // MEDIASCANNER_H
+
diff --git a/include/media/thread_init.h b/include/media/thread_init.h
new file mode 100644
index 0000000..2c0c1f1
--- /dev/null
+++ b/include/media/thread_init.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef THREAD_INIT_H
+#define THREAD_INIT_H
+
+bool InitializeForThread();
+void UninitializeForThread();
+void keydestructor(void*);
+
+#endif /* THREAD_INIT_H*/
+