summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/binder/IBinder.h2
-rw-r--r--include/binder/IPCThreadState.h10
-rw-r--r--include/media/AudioSystem.h17
-rw-r--r--include/media/IAudioFlinger.h5
-rw-r--r--include/media/IMediaDeathNotifier.h61
-rw-r--r--include/media/IOMX.h18
-rw-r--r--include/media/MediaPlayerInterface.h3
-rw-r--r--include/media/MediaRecorderBase.h59
-rw-r--r--include/media/PVMediaRecorder.h50
-rw-r--r--include/media/mediametadataretriever.h1
-rw-r--r--include/media/mediaplayer.h28
-rw-r--r--include/media/mediarecorder.h5
-rw-r--r--include/media/mediascanner.h47
-rw-r--r--include/media/stagefright/AMRExtractor.h54
-rw-r--r--include/media/stagefright/AMRWriter.h64
-rw-r--r--include/media/stagefright/AudioPlayer.h11
-rw-r--r--include/media/stagefright/AudioSource.h19
-rw-r--r--include/media/stagefright/CachingDataSource.h6
-rw-r--r--include/media/stagefright/CameraSource.h29
-rw-r--r--include/media/stagefright/ColorConverter.h67
-rw-r--r--include/media/stagefright/DataSource.h14
-rw-r--r--include/media/stagefright/ESDS.h64
-rw-r--r--include/media/stagefright/FileSource.h13
-rw-r--r--include/media/stagefright/HTTPDataSource.h22
-rw-r--r--include/media/stagefright/HTTPStream.h74
-rw-r--r--include/media/stagefright/HardwareAPI.h3
-rw-r--r--include/media/stagefright/MP3Extractor.h55
-rw-r--r--include/media/stagefright/MPEG4Extractor.h68
-rw-r--r--include/media/stagefright/MPEG4Writer.h14
-rw-r--r--include/media/stagefright/MediaDefs.h1
-rw-r--r--include/media/stagefright/MediaErrors.h3
-rw-r--r--include/media/stagefright/MediaExtractor.h14
-rw-r--r--include/media/stagefright/MediaPlayerImpl.h130
-rw-r--r--include/media/stagefright/MediaSource.h3
-rw-r--r--include/media/stagefright/MediaWriter.h45
-rw-r--r--include/media/stagefright/MetaData.h38
-rw-r--r--include/media/stagefright/OMXCodec.h29
-rw-r--r--include/media/stagefright/OMXPluginBase.h61
-rw-r--r--include/media/stagefright/SampleTable.h109
-rw-r--r--include/media/stagefright/ShoutcastSource.h4
-rw-r--r--include/media/stagefright/SoftwareRenderer.h66
-rw-r--r--include/media/stagefright/StagefrightMediaScanner.h (renamed from include/media/stagefright/MmapSource.h)36
-rw-r--r--include/media/stagefright/TimedEventQueue.h106
-rw-r--r--include/media/stagefright/stagefright_string.h54
-rw-r--r--include/ui/Camera.h2
-rw-r--r--include/ui/CameraParameters.h16
-rw-r--r--include/ui/ISurface.h7
-rw-r--r--include/utils/ResourceTypes.h13
-rw-r--r--include/utils/String16.h5
-rw-r--r--include/utils/String8.h8
-rw-r--r--include/utils/threads.h18
51 files changed, 703 insertions, 948 deletions
diff --git a/include/binder/IBinder.h b/include/binder/IBinder.h
index 884b5c1..749a977 100644
--- a/include/binder/IBinder.h
+++ b/include/binder/IBinder.h
@@ -52,7 +52,7 @@ public:
DUMP_TRANSACTION = B_PACK_CHARS('_','D','M','P'),
INTERFACE_TRANSACTION = B_PACK_CHARS('_', 'N', 'T', 'F'),
- // Corresponds to tfOneWay -- an asynchronous call.
+ // Corresponds to TF_ONE_WAY -- an asynchronous call.
FLAG_ONEWAY = 0x00000001
};
diff --git a/include/binder/IPCThreadState.h b/include/binder/IPCThreadState.h
index 78306b2..3ab985d 100644
--- a/include/binder/IPCThreadState.h
+++ b/include/binder/IPCThreadState.h
@@ -68,6 +68,13 @@ public:
static void shutdown();
+ // Call this to disable switching threads to background scheduling when
+ // receiving incoming IPC calls. This is specifically here for the
+ // Android system process, since it expects to have background apps calling
+ // in to it but doesn't want to acquire locks in its services while in
+ // the background.
+ static void disableBackgroundScheduling(bool disable);
+
private:
IPCThreadState();
~IPCThreadState();
@@ -93,9 +100,10 @@ private:
void* cookie);
const sp<ProcessState> mProcess;
+ const pid_t mMyThreadId;
Vector<BBinder*> mPendingStrongDerefs;
Vector<RefBase::weakref_type*> mPendingWeakDerefs;
-
+
Parcel mIn;
Parcel mOut;
status_t mLastError;
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index c87007c..42bb4df 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -194,8 +194,8 @@ public:
// set audio mode in audio hardware (see AudioSystem::audio_mode)
static status_t setMode(int mode);
- // returns true if tracks are active on AudioSystem::MUSIC stream
- static status_t isMusicActive(bool *state);
+ // returns true in *state if tracks are active on the specified stream
+ static status_t isStreamActive(int stream, bool *state);
// set/get audio hardware parameters. The function accepts a list of parameters
// key value pairs in the form: key1=value1;key2=value2;...
@@ -222,6 +222,17 @@ public:
static status_t setVoiceVolume(float volume);
+ // return the number of audio frames written by AudioFlinger to audio HAL and
+ // audio dsp to DAC since the output on which the specificed stream is playing
+ // has exited standby.
+ // returned status (from utils/Errors.h) can be:
+ // - NO_ERROR: successful operation, halFrames and dspFrames point to valid data
+ // - INVALID_OPERATION: Not supported on current hardware platform
+ // - BAD_VALUE: invalid parameter
+ // NOTE: this feature is not supported on all hardware platforms and it is
+ // necessary to check returned status before using the returned values.
+ static status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int stream = DEFAULT);
+
//
// AudioPolicyService interface
//
@@ -244,6 +255,8 @@ public:
DEVICE_OUT_WIRED_HEADPHONE | DEVICE_OUT_BLUETOOTH_SCO | DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
DEVICE_OUT_BLUETOOTH_SCO_CARKIT | DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | DEVICE_OUT_AUX_DIGITAL | DEVICE_OUT_DEFAULT),
+ DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
+ DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER),
// input devices
DEVICE_IN_COMMUNICATION = 0x10000,
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index a46c727..bddd23e 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -97,8 +97,8 @@ public:
virtual status_t setMicMute(bool state) = 0;
virtual bool getMicMute() const = 0;
- // is a music stream active?
- virtual bool isMusicActive() const = 0;
+ // is any track active on this stream?
+ virtual bool isStreamActive(int stream) const = 0;
virtual status_t setParameters(int ioHandle, const String8& keyValuePairs) = 0;
virtual String8 getParameters(int ioHandle, const String8& keys) = 0;
@@ -130,6 +130,7 @@ public:
virtual status_t setStreamOutput(uint32_t stream, int output) = 0;
virtual status_t setVoiceVolume(float volume) = 0;
+ virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) = 0;
};
diff --git a/include/media/IMediaDeathNotifier.h b/include/media/IMediaDeathNotifier.h
new file mode 100644
index 0000000..bb3d0d8
--- /dev/null
+++ b/include/media/IMediaDeathNotifier.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_IMEDIADEATHNOTIFIER_H
+#define ANDROID_IMEDIADEATHNOTIFIER_H
+
+#include <utils/threads.h>
+#include <media/IMediaPlayerService.h>
+#include <utils/SortedVector.h>
+
+namespace android {
+
+class IMediaDeathNotifier: virtual public RefBase
+{
+public:
+ IMediaDeathNotifier() { addObitRecipient(this); }
+ virtual ~IMediaDeathNotifier() { removeObitRecipient(this); }
+
+ virtual void died() = 0;
+ static const sp<IMediaPlayerService>& getMediaPlayerService();
+
+private:
+ IMediaDeathNotifier &operator=(const IMediaDeathNotifier &);
+ IMediaDeathNotifier(const IMediaDeathNotifier &);
+
+ static void addObitRecipient(const wp<IMediaDeathNotifier>& recipient);
+ static void removeObitRecipient(const wp<IMediaDeathNotifier>& recipient);
+
+ class DeathNotifier: public IBinder::DeathRecipient
+ {
+ public:
+ DeathNotifier() {}
+ virtual ~DeathNotifier();
+
+ virtual void binderDied(const wp<IBinder>& who);
+ };
+
+ friend class DeathNotifier;
+
+ static Mutex sServiceLock;
+ static sp<IMediaPlayerService> sMediaPlayerService;
+ static sp<DeathNotifier> sDeathNotifier;
+ static SortedVector< wp<IMediaDeathNotifier> > sObitRecipients;
+};
+
+}; // namespace android
+
+#endif // ANDROID_IMEDIADEATHNOTIFIER_H
diff --git a/include/media/IOMX.h b/include/media/IOMX.h
index 6f3ba1c..2f61cbe 100644
--- a/include/media/IOMX.h
+++ b/include/media/IOMX.h
@@ -42,7 +42,16 @@ public:
typedef void *buffer_id;
typedef void *node_id;
- virtual status_t listNodes(List<String8> *list) = 0;
+ // Given the calling process' pid, returns true iff
+ // the implementation of the OMX interface lives in the same
+ // process.
+ virtual bool livesLocally(pid_t pid) = 0;
+
+ struct ComponentInfo {
+ String8 mName;
+ List<String8> mRoles;
+ };
+ virtual status_t listNodes(List<ComponentInfo> *list) = 0;
virtual status_t allocateNode(
const char *name, const sp<IOMXObserver> &observer,
@@ -73,9 +82,13 @@ public:
node_id node, OMX_U32 port_index, const sp<IMemory> &params,
buffer_id *buffer) = 0;
+ // This API clearly only makes sense if the caller lives in the
+ // same process as the callee, i.e. is the media_server, as the
+ // returned "buffer_data" pointer is just that, a pointer into local
+ // address space.
virtual status_t allocateBuffer(
node_id node, OMX_U32 port_index, size_t size,
- buffer_id *buffer) = 0;
+ buffer_id *buffer, void **buffer_data) = 0;
virtual status_t allocateBufferWithBackup(
node_id node, OMX_U32 port_index, const sp<IMemory> &params,
@@ -153,6 +166,7 @@ struct omx_message {
OMX_U32 flags;
OMX_TICKS timestamp;
OMX_PTR platform_private;
+ OMX_PTR data_ptr;
} extended_buffer_data;
} u;
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
index f723cfd..588c51a 100644
--- a/include/media/MediaPlayerInterface.h
+++ b/include/media/MediaPlayerInterface.h
@@ -72,6 +72,7 @@ public:
virtual ssize_t frameSize() const = 0;
virtual uint32_t latency() const = 0;
virtual float msecsPerFrame() const = 0;
+ virtual status_t getPosition(uint32_t *position) = 0;
// If no callback is specified, use the "write" API below to submit
// audio data. Otherwise return a full buffer of audio data on each
@@ -133,9 +134,9 @@ public:
return INVALID_OPERATION;
};
-protected:
virtual void sendEvent(int msg, int ext1=0, int ext2=0) { if (mNotify) mNotify(mCookie, msg, ext1, ext2); }
+protected:
void* mCookie;
notify_callback_f mNotify;
};
diff --git a/include/media/MediaRecorderBase.h b/include/media/MediaRecorderBase.h
new file mode 100644
index 0000000..5b787a7
--- /dev/null
+++ b/include/media/MediaRecorderBase.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MEDIA_RECORDER_BASE_H_
+
+#define MEDIA_RECORDER_BASE_H_
+
+#include <media/mediarecorder.h>
+
+namespace android {
+
+class ISurface;
+
+struct MediaRecorderBase {
+ MediaRecorderBase() {}
+ virtual ~MediaRecorderBase() {}
+
+ virtual status_t init() = 0;
+ virtual status_t setAudioSource(audio_source as) = 0;
+ virtual status_t setVideoSource(video_source vs) = 0;
+ virtual status_t setOutputFormat(output_format of) = 0;
+ virtual status_t setAudioEncoder(audio_encoder ae) = 0;
+ virtual status_t setVideoEncoder(video_encoder ve) = 0;
+ virtual status_t setVideoSize(int width, int height) = 0;
+ virtual status_t setVideoFrameRate(int frames_per_second) = 0;
+ virtual status_t setCamera(const sp<ICamera>& camera) = 0;
+ virtual status_t setPreviewSurface(const sp<ISurface>& surface) = 0;
+ virtual status_t setOutputFile(const char *path) = 0;
+ virtual status_t setOutputFile(int fd, int64_t offset, int64_t length) = 0;
+ virtual status_t setParameters(const String8& params) = 0;
+ virtual status_t setListener(const sp<IMediaPlayerClient>& listener) = 0;
+ virtual status_t prepare() = 0;
+ virtual status_t start() = 0;
+ virtual status_t stop() = 0;
+ virtual status_t close() = 0;
+ virtual status_t reset() = 0;
+ virtual status_t getMaxAmplitude(int *max) = 0;
+
+private:
+ MediaRecorderBase(const MediaRecorderBase &);
+ MediaRecorderBase &operator=(const MediaRecorderBase &);
+};
+
+} // namespace android
+
+#endif // MEDIA_RECORDER_BASE_H_
diff --git a/include/media/PVMediaRecorder.h b/include/media/PVMediaRecorder.h
index 0c71932..4f17c1a 100644
--- a/include/media/PVMediaRecorder.h
+++ b/include/media/PVMediaRecorder.h
@@ -18,8 +18,8 @@
#ifndef ANDROID_PVMEDIARECORDER_H
#define ANDROID_PVMEDIARECORDER_H
-#include <media/mediarecorder.h>
#include <media/IMediaPlayerClient.h>
+#include <media/MediaRecorderBase.h>
namespace android {
@@ -27,37 +27,39 @@ class ISurface;
class ICamera;
class AuthorDriverWrapper;
-class PVMediaRecorder
-{
+class PVMediaRecorder : public MediaRecorderBase {
public:
PVMediaRecorder();
- ~PVMediaRecorder();
+ virtual ~PVMediaRecorder();
- 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 setCamera(const sp<ICamera>& camera);
- status_t setPreviewSurface(const sp<ISurface>& surface);
- status_t setOutputFile(const char *path);
- status_t setOutputFile(int fd, int64_t offset, int64_t length);
- status_t setParameters(const String8& params);
- status_t setListener(const sp<IMediaPlayerClient>& listener);
- status_t prepare();
- status_t start();
- status_t stop();
- status_t close();
- status_t reset();
- status_t getMaxAmplitude(int *max);
+ virtual status_t init();
+ virtual status_t setAudioSource(audio_source as);
+ virtual status_t setVideoSource(video_source vs);
+ virtual status_t setOutputFormat(output_format of);
+ virtual status_t setAudioEncoder(audio_encoder ae);
+ virtual status_t setVideoEncoder(video_encoder ve);
+ virtual status_t setVideoSize(int width, int height);
+ virtual status_t setVideoFrameRate(int frames_per_second);
+ virtual status_t setCamera(const sp<ICamera>& camera);
+ virtual status_t setPreviewSurface(const sp<ISurface>& surface);
+ virtual status_t setOutputFile(const char *path);
+ virtual status_t setOutputFile(int fd, int64_t offset, int64_t length);
+ virtual status_t setParameters(const String8& params);
+ virtual status_t setListener(const sp<IMediaPlayerClient>& listener);
+ virtual status_t prepare();
+ virtual status_t start();
+ virtual status_t stop();
+ virtual status_t close();
+ virtual status_t reset();
+ virtual status_t getMaxAmplitude(int *max);
private:
status_t doStop();
AuthorDriverWrapper* mAuthorDriverWrapper;
+
+ PVMediaRecorder(const PVMediaRecorder &);
+ PVMediaRecorder &operator=(const PVMediaRecorder &);
};
}; // namespace android
diff --git a/include/media/mediametadataretriever.h b/include/media/mediametadataretriever.h
index cfc205c..113c452 100644
--- a/include/media/mediametadataretriever.h
+++ b/include/media/mediametadataretriever.h
@@ -53,6 +53,7 @@ enum {
METADATA_KEY_VIDEO_HEIGHT = 19,
METADATA_KEY_VIDEO_WIDTH = 20,
METADATA_KEY_WRITER = 21,
+ METADATA_KEY_MIMETYPE = 22,
// Add more here...
};
diff --git a/include/media/mediaplayer.h b/include/media/mediaplayer.h
index 7132b18..87d23f6 100644
--- a/include/media/mediaplayer.h
+++ b/include/media/mediaplayer.h
@@ -21,8 +21,7 @@
#include <ui/Surface.h>
#include <media/IMediaPlayerClient.h>
#include <media/IMediaPlayer.h>
-#include <media/IMediaPlayerService.h>
-#include <utils/SortedVector.h>
+#include <media/IMediaDeathNotifier.h>
namespace android {
@@ -123,12 +122,13 @@ public:
virtual void notify(int msg, int ext1, int ext2) = 0;
};
-class MediaPlayer : public BnMediaPlayerClient
+class MediaPlayer : public BnMediaPlayerClient,
+ public virtual IMediaDeathNotifier
{
public:
MediaPlayer();
~MediaPlayer();
- void onFirstRef();
+ void died();
void disconnect();
status_t setDataSource(const char *url);
status_t setDataSource(int fd, int64_t offset, int64_t length);
@@ -164,19 +164,6 @@ private:
status_t getDuration_l(int *msec);
status_t setDataSource(const sp<IMediaPlayer>& player);
- static const sp<IMediaPlayerService>& getMediaPlayerService();
- static void addObitRecipient(const wp<MediaPlayer>& recipient);
- static void removeObitRecipient(const wp<MediaPlayer>& recipient);
-
- class DeathNotifier: public IBinder::DeathRecipient
- {
- public:
- DeathNotifier() {}
- virtual ~DeathNotifier();
-
- virtual void binderDied(const wp<IBinder>& who);
- };
-
sp<IMediaPlayer> mPlayer;
thread_id_t mLockThreadId;
Mutex mLock;
@@ -196,13 +183,6 @@ private:
float mRightVolume;
int mVideoWidth;
int mVideoHeight;
-
- friend class DeathNotifier;
-
- static Mutex sServiceLock;
- static sp<IMediaPlayerService> sMediaPlayerService;
- static sp<DeathNotifier> sDeathNotifier;
- static SortedVector< wp<MediaPlayer> > sObitRecipients;
};
}; // namespace android
diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h
index 8c7392b..9ea6c7b 100644
--- a/include/media/mediarecorder.h
+++ b/include/media/mediarecorder.h
@@ -23,6 +23,7 @@
#include <utils/List.h>
#include <utils/Errors.h>
#include <media/IMediaPlayerClient.h>
+#include <media/IMediaDeathNotifier.h>
namespace android {
@@ -145,12 +146,14 @@ public:
virtual void notify(int msg, int ext1, int ext2) = 0;
};
-class MediaRecorder : public BnMediaPlayerClient
+class MediaRecorder : public BnMediaPlayerClient,
+ public virtual IMediaDeathNotifier
{
public:
MediaRecorder();
~MediaRecorder();
+ void died();
status_t initCheck();
status_t setCamera(const sp<ICamera>& camera);
status_t setPreviewSurface(const sp<Surface>& surface);
diff --git a/include/media/mediascanner.h b/include/media/mediascanner.h
index cd0b86e..0d397ac 100644
--- a/include/media/mediascanner.h
+++ b/include/media/mediascanner.h
@@ -28,33 +28,40 @@ namespace android {
class MediaScannerClient;
class StringArray;
-class MediaScanner
-{
-public:
+struct MediaScanner {
MediaScanner();
- ~MediaScanner();
-
+ virtual ~MediaScanner();
+
+ virtual status_t processFile(
+ const char *path, const char *mimeType,
+ MediaScannerClient &client) = 0;
+
typedef bool (*ExceptionCheck)(void* env);
+ virtual status_t processDirectory(
+ const char *path, const char *extensions,
+ MediaScannerClient &client,
+ ExceptionCheck exceptionCheck, void *exceptionEnv);
+
+ void setLocale(const char *locale);
- 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);
- void setLocale(const char* locale);
-
// extracts album art as a block of data
- char* extractAlbumArt(int fd);
-
- static void uninitializeForThread();
+ virtual char *extractAlbumArt(int fd) = 0;
+
+protected:
+ const char *locale() const;
private:
- status_t doProcessDirectory(char *path, int pathRemaining, const char* extensions,
- MediaScannerClient& client, ExceptionCheck exceptionCheck, void* exceptionEnv);
- void initializeForThread();
-
// current locale (like "ja_JP"), created/destroyed with strdup()/free()
- char* mLocale;
-};
+ char *mLocale;
+ status_t doProcessDirectory(
+ char *path, int pathRemaining, const char *extensions,
+ MediaScannerClient &client, ExceptionCheck exceptionCheck,
+ void *exceptionEnv);
+
+ MediaScanner(const MediaScanner &);
+ MediaScanner &operator=(const MediaScanner &);
+};
class MediaScannerClient
{
@@ -78,7 +85,7 @@ protected:
// cached name and value strings, for native encoding support.
StringArray* mNames;
StringArray* mValues;
-
+
// default encoding based on MediaScanner::mLocale string
uint32_t mLocaleEncoding;
};
diff --git a/include/media/stagefright/AMRExtractor.h b/include/media/stagefright/AMRExtractor.h
deleted file mode 100644
index c8710d3..0000000
--- a/include/media/stagefright/AMRExtractor.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef AMR_EXTRACTOR_H_
-
-#define AMR_EXTRACTOR_H_
-
-#include <media/stagefright/MediaExtractor.h>
-
-namespace android {
-
-class String8;
-
-class AMRExtractor : public MediaExtractor {
-public:
- AMRExtractor(const sp<DataSource> &source);
-
- virtual size_t countTracks();
- virtual sp<MediaSource> getTrack(size_t index);
- virtual sp<MetaData> getTrackMetaData(size_t index);
-
- static sp<MetaData> makeAMRFormat(bool isWide);
-
-protected:
- virtual ~AMRExtractor();
-
-private:
- sp<DataSource> mDataSource;
- status_t mInitCheck;
- bool mIsWide;
-
- AMRExtractor(const AMRExtractor &);
- AMRExtractor &operator=(const AMRExtractor &);
-};
-
-bool SniffAMR(
- const sp<DataSource> &source, String8 *mimeType, float *confidence);
-
-} // namespace android
-
-#endif // AMR_EXTRACTOR_H_
diff --git a/include/media/stagefright/AMRWriter.h b/include/media/stagefright/AMRWriter.h
new file mode 100644
index 0000000..372909a
--- /dev/null
+++ b/include/media/stagefright/AMRWriter.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AMR_WRITER_H_
+
+#define AMR_WRITER_H_
+
+#include <stdio.h>
+
+#include <media/stagefright/MediaWriter.h>
+#include <utils/threads.h>
+
+namespace android {
+
+struct MediaSource;
+
+struct AMRWriter : public MediaWriter {
+ AMRWriter(const char *filename);
+ AMRWriter(int fd);
+
+ status_t initCheck() const;
+
+ virtual status_t addSource(const sp<MediaSource> &source);
+ virtual bool reachedEOS();
+ virtual status_t start();
+ virtual void stop();
+
+protected:
+ virtual ~AMRWriter();
+
+private:
+ Mutex mLock;
+
+ FILE *mFile;
+ status_t mInitCheck;
+ sp<MediaSource> mSource;
+ bool mStarted;
+ volatile bool mDone;
+ bool mReachedEOS;
+ pthread_t mThread;
+
+ static void *ThreadWrapper(void *);
+ void threadFunc();
+
+ AMRWriter(const AMRWriter &);
+ AMRWriter &operator=(const AMRWriter &);
+};
+
+} // namespace android
+
+#endif // AMR_WRITER_H_
diff --git a/include/media/stagefright/AudioPlayer.h b/include/media/stagefright/AudioPlayer.h
index 960eda3..71344e6 100644
--- a/include/media/stagefright/AudioPlayer.h
+++ b/include/media/stagefright/AudioPlayer.h
@@ -30,12 +30,20 @@ class AudioTrack;
class AudioPlayer : public TimeSource {
public:
+ enum {
+ REACHED_EOS,
+ SEEK_COMPLETE
+ };
+
AudioPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink);
virtual ~AudioPlayer();
// Caller retains ownership of "source".
void setSource(const sp<MediaSource> &source);
+ void setListenerCallback(
+ void (*notify)(void *cookie, int what), void *cookie);
+
// Return time in us.
virtual int64_t getRealTimeUs();
@@ -76,6 +84,9 @@ private:
bool mStarted;
+ void (*mListenerCallback)(void *cookie, int what);
+ void *mListenerCookie;
+
sp<MediaPlayerBase::AudioSink> mAudioSink;
static void AudioCallback(int event, void *user, void *info);
diff --git a/include/media/stagefright/AudioSource.h b/include/media/stagefright/AudioSource.h
index e129958..eb00140 100644
--- a/include/media/stagefright/AudioSource.h
+++ b/include/media/stagefright/AudioSource.h
@@ -18,16 +18,20 @@
#define AUDIO_SOURCE_H_
+#include <media/AudioSystem.h>
#include <media/stagefright/MediaSource.h>
namespace android {
class AudioRecord;
+struct MediaBufferGroup;
-class AudioSource {
-public:
- AudioSource(int inputSource);
- virtual ~AudioSource();
+struct AudioSource : public MediaSource {
+ // Note that the "channels" parameter is _not_ the number of channels,
+ // but a bitmask of AudioSystem::audio_channels constants.
+ AudioSource(
+ int inputSource, uint32_t sampleRate,
+ uint32_t channels = AudioSystem::CHANNEL_IN_MONO);
status_t initCheck() const;
@@ -38,9 +42,16 @@ public:
virtual status_t read(
MediaBuffer **buffer, const ReadOptions *options = NULL);
+protected:
+ virtual ~AudioSource();
+
private:
+ enum { kMaxBufferSize = 8192 };
+
AudioRecord *mRecord;
status_t mInitCheck;
+ bool mStarted;
+ MediaBufferGroup *mGroup;
AudioSource(const AudioSource &);
AudioSource &operator=(const AudioSource &);
diff --git a/include/media/stagefright/CachingDataSource.h b/include/media/stagefright/CachingDataSource.h
index e35e19e..30b7ad9 100644
--- a/include/media/stagefright/CachingDataSource.h
+++ b/include/media/stagefright/CachingDataSource.h
@@ -29,9 +29,11 @@ public:
CachingDataSource(
const sp<DataSource> &source, size_t pageSize, int numPages);
- status_t InitCheck() const;
+ virtual status_t initCheck() const;
- virtual ssize_t read_at(off_t offset, void *data, size_t size);
+ virtual ssize_t readAt(off_t offset, void *data, size_t size);
+
+ virtual uint32_t flags();
protected:
virtual ~CachingDataSource();
diff --git a/include/media/stagefright/CameraSource.h b/include/media/stagefright/CameraSource.h
index 7042e1a..ea435de 100644
--- a/include/media/stagefright/CameraSource.h
+++ b/include/media/stagefright/CameraSource.h
@@ -27,16 +27,19 @@
namespace android {
class ICamera;
-class ICameraClient;
class IMemory;
+class ISurface;
+class Camera;
-class CameraSource : public MediaSource,
- public MediaBufferObserver {
+class CameraSource : public MediaSource {
public:
static CameraSource *Create();
+ static CameraSource *CreateFromICamera(const sp<ICamera> &icamera);
virtual ~CameraSource();
+ void setPreviewSurface(const sp<ISurface> &surface);
+
virtual status_t start(MetaData *params = NULL);
virtual status_t stop();
@@ -45,24 +48,26 @@ public:
virtual status_t read(
MediaBuffer **buffer, const ReadOptions *options = NULL);
- virtual void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2);
- virtual void dataCallback(int32_t msgType, const sp<IMemory>& data);
-
- virtual void signalBufferReturned(MediaBuffer *buffer);
-
private:
- CameraSource(const sp<ICamera> &camera, const sp<ICameraClient> &client);
+ friend class CameraSourceListener;
- sp<ICamera> mCamera;
- sp<ICameraClient> mCameraClient;
+ sp<Camera> mCamera;
+ sp<ISurface> mPreviewSurface;
Mutex mLock;
Condition mFrameAvailableCondition;
List<sp<IMemory> > mFrames;
+ List<int64_t> mFrameTimes;
- int mNumFrames;
+ int mWidth, mHeight;
+ int64_t mFirstFrameTimeUs;
+ int32_t mNumFrames;
bool mStarted;
+ CameraSource(const sp<Camera> &camera);
+
+ void dataCallback(int32_t msgType, const sp<IMemory> &data);
+
CameraSource(const CameraSource &);
CameraSource &operator=(const CameraSource &);
};
diff --git a/include/media/stagefright/ColorConverter.h b/include/media/stagefright/ColorConverter.h
new file mode 100644
index 0000000..1e341b9
--- /dev/null
+++ b/include/media/stagefright/ColorConverter.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COLOR_CONVERTER_H_
+
+#define COLOR_CONVERTER_H_
+
+#include <sys/types.h>
+
+#include <stdint.h>
+
+#include <OMX_Video.h>
+
+namespace android {
+
+struct ColorConverter {
+ ColorConverter(OMX_COLOR_FORMATTYPE from, OMX_COLOR_FORMATTYPE to);
+ ~ColorConverter();
+
+ bool isValid() const;
+
+ void convert(
+ size_t width, size_t height,
+ const void *srcBits, size_t srcSkip,
+ void *dstBits, size_t dstSkip);
+
+private:
+ OMX_COLOR_FORMATTYPE mSrcFormat, mDstFormat;
+ uint8_t *mClip;
+
+ uint8_t *initClip();
+
+ void convertCbYCrY(
+ size_t width, size_t height,
+ const void *srcBits, size_t srcSkip,
+ void *dstBits, size_t dstSkip);
+
+ void convertYUV420Planar(
+ size_t width, size_t height,
+ const void *srcBits, size_t srcSkip,
+ void *dstBits, size_t dstSkip);
+
+ void convertQCOMYUV420SemiPlanar(
+ size_t width, size_t height,
+ const void *srcBits, size_t srcSkip,
+ void *dstBits, size_t dstSkip);
+
+ ColorConverter(const ColorConverter &);
+ ColorConverter &operator=(const ColorConverter &);
+};
+
+} // namespace android
+
+#endif // COLOR_CONVERTER_H_
diff --git a/include/media/stagefright/DataSource.h b/include/media/stagefright/DataSource.h
index f46f0af..0c0ace0 100644
--- a/include/media/stagefright/DataSource.h
+++ b/include/media/stagefright/DataSource.h
@@ -31,9 +31,17 @@ class String8;
class DataSource : public RefBase {
public:
+ enum Flags {
+ kWantsPrefetching = 1,
+ };
+
+ static sp<DataSource> CreateFromURI(const char *uri);
+
DataSource() {}
- virtual ssize_t read_at(off_t offset, void *data, size_t size) = 0;
+ virtual status_t initCheck() const = 0;
+
+ virtual ssize_t readAt(off_t offset, void *data, size_t size) = 0;
// Convenience methods:
bool getUInt16(off_t offset, uint16_t *x);
@@ -41,6 +49,10 @@ public:
// May return ERROR_UNSUPPORTED.
virtual status_t getSize(off_t *size);
+ virtual uint32_t flags() {
+ return 0;
+ }
+
////////////////////////////////////////////////////////////////////////////
bool sniff(String8 *mimeType, float *confidence);
diff --git a/include/media/stagefright/ESDS.h b/include/media/stagefright/ESDS.h
deleted file mode 100644
index 01bcd18..0000000
--- a/include/media/stagefright/ESDS.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ESDS_H_
-
-#define ESDS_H_
-
-#include <stdint.h>
-
-#include <media/stagefright/MediaErrors.h>
-
-namespace android {
-
-class ESDS {
-public:
- ESDS(const void *data, size_t size);
- ~ESDS();
-
- status_t InitCheck() const;
-
- status_t getCodecSpecificInfo(const void **data, size_t *size) const;
-
-private:
- enum {
- kTag_ESDescriptor = 0x03,
- kTag_DecoderConfigDescriptor = 0x04,
- kTag_DecoderSpecificInfo = 0x05
- };
-
- uint8_t *mData;
- size_t mSize;
-
- status_t mInitCheck;
-
- size_t mDecoderSpecificOffset;
- size_t mDecoderSpecificLength;
-
- status_t skipDescriptorHeader(
- size_t offset, size_t size,
- uint8_t *tag, size_t *data_offset, size_t *data_size) const;
-
- status_t parse();
- status_t parseESDescriptor(size_t offset, size_t size);
- status_t parseDecoderConfigDescriptor(size_t offset, size_t size);
-
- ESDS(const ESDS &);
- ESDS &operator=(const ESDS &);
-};
-
-} // namespace android
-#endif // ESDS_H_
diff --git a/include/media/stagefright/FileSource.h b/include/media/stagefright/FileSource.h
index ccbe0ef..8a215ea 100644
--- a/include/media/stagefright/FileSource.h
+++ b/include/media/stagefright/FileSource.h
@@ -29,14 +29,21 @@ namespace android {
class FileSource : public DataSource {
public:
FileSource(const char *filename);
- virtual ~FileSource();
+ FileSource(int fd, int64_t offset, int64_t length);
+
+ virtual status_t initCheck() const;
- status_t InitCheck() const;
+ virtual ssize_t readAt(off_t offset, void *data, size_t size);
- virtual ssize_t read_at(off_t offset, void *data, size_t size);
+ virtual status_t getSize(off_t *size);
+
+protected:
+ virtual ~FileSource();
private:
FILE *mFile;
+ int64_t mOffset;
+ int64_t mLength;
Mutex mLock;
FileSource(const FileSource &);
diff --git a/include/media/stagefright/HTTPDataSource.h b/include/media/stagefright/HTTPDataSource.h
index 0587c7c..42444dc 100644
--- a/include/media/stagefright/HTTPDataSource.h
+++ b/include/media/stagefright/HTTPDataSource.h
@@ -19,28 +19,33 @@
#define HTTP_DATASOURCE_H_
#include <media/stagefright/DataSource.h>
-#include <media/stagefright/HTTPStream.h>
namespace android {
+class HTTPStream;
+
class HTTPDataSource : public DataSource {
public:
HTTPDataSource(const char *host, int port, const char *path);
HTTPDataSource(const char *uri);
- virtual ~HTTPDataSource();
+ virtual status_t initCheck() const;
+
+ virtual ssize_t readAt(off_t offset, void *data, size_t size);
- // XXXandih
- status_t InitCheck() const { return OK; }
+ virtual uint32_t flags() {
+ return kWantsPrefetching;
+ }
- virtual ssize_t read_at(off_t offset, void *data, size_t size);
+protected:
+ virtual ~HTTPDataSource();
private:
enum {
kBufferSize = 64 * 1024
};
- HTTPStream mHttp;
+ HTTPStream *mHttp;
char *mHost;
int mPort;
char *mPath;
@@ -48,6 +53,11 @@ private:
void *mBuffer;
size_t mBufferLength;
off_t mBufferOffset;
+ bool mFirstRequest;
+
+ status_t mInitCheck;
+
+ ssize_t sendRangeRequest(size_t offset);
HTTPDataSource(const HTTPDataSource &);
HTTPDataSource &operator=(const HTTPDataSource &);
diff --git a/include/media/stagefright/HTTPStream.h b/include/media/stagefright/HTTPStream.h
deleted file mode 100644
index 72e796c..0000000
--- a/include/media/stagefright/HTTPStream.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef HTTP_STREAM_H_
-
-#define HTTP_STREAM_H_
-
-#include <sys/types.h>
-
-#include <media/stagefright/MediaErrors.h>
-#include <media/stagefright/stagefright_string.h>
-#include <utils/KeyedVector.h>
-
-namespace android {
-
-class HTTPStream {
-public:
- HTTPStream();
- ~HTTPStream();
-
- status_t connect(const char *server, int port = 80);
- status_t disconnect();
-
- status_t send(const char *data, size_t size);
-
- // Assumes data is a '\0' terminated string.
- status_t send(const char *data);
-
- // Receive up to "size" bytes of data.
- ssize_t receive(void *data, size_t size);
-
- status_t receive_header(int *http_status);
-
- // The header key used to retrieve the status line.
- static const char *kStatusKey;
-
- bool find_header_value(
- const string &key, string *value) const;
-
-private:
- enum State {
- READY,
- CONNECTED
- };
-
- State mState;
- int mSocket;
-
- KeyedVector<string, string> mHeaders;
-
- // Receive a line of data terminated by CRLF, line will be '\0' terminated
- // _excluding_ the termianting CRLF.
- status_t receive_line(char *line, size_t size);
-
- HTTPStream(const HTTPStream &);
- HTTPStream &operator=(const HTTPStream &);
-};
-
-} // namespace android
-
-#endif // HTTP_STREAM_H_
diff --git a/include/media/stagefright/HardwareAPI.h b/include/media/stagefright/HardwareAPI.h
index 7e1f08d..b7daddc 100644
--- a/include/media/stagefright/HardwareAPI.h
+++ b/include/media/stagefright/HardwareAPI.h
@@ -18,6 +18,7 @@
#define HARDWARE_API_H_
+#include <media/stagefright/OMXPluginBase.h>
#include <media/stagefright/VideoRenderer.h>
#include <ui/ISurface.h>
#include <utils/RefBase.h>
@@ -31,5 +32,7 @@ extern android::VideoRenderer *createRenderer(
size_t displayWidth, size_t displayHeight,
size_t decodedWidth, size_t decodedHeight);
+extern android::OMXPluginBase *createOMXPlugin();
+
#endif // HARDWARE_API_H_
diff --git a/include/media/stagefright/MP3Extractor.h b/include/media/stagefright/MP3Extractor.h
deleted file mode 100644
index 11ba01d..0000000
--- a/include/media/stagefright/MP3Extractor.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef MP3_EXTRACTOR_H_
-
-#define MP3_EXTRACTOR_H_
-
-#include <media/stagefright/MediaExtractor.h>
-
-namespace android {
-
-class DataSource;
-class String8;
-
-class MP3Extractor : public MediaExtractor {
-public:
- // Extractor assumes ownership of "source".
- MP3Extractor(const sp<DataSource> &source);
-
- virtual size_t countTracks();
- virtual sp<MediaSource> getTrack(size_t index);
- virtual sp<MetaData> getTrackMetaData(size_t index);
-
-protected:
- virtual ~MP3Extractor();
-
-private:
- sp<DataSource> mDataSource;
- off_t mFirstFramePos;
- sp<MetaData> mMeta;
- uint32_t mFixedHeader;
-
- MP3Extractor(const MP3Extractor &);
- MP3Extractor &operator=(const MP3Extractor &);
-};
-
-bool SniffMP3(
- const sp<DataSource> &source, String8 *mimeType, float *confidence);
-
-} // namespace android
-
-#endif // MP3_EXTRACTOR_H_
diff --git a/include/media/stagefright/MPEG4Extractor.h b/include/media/stagefright/MPEG4Extractor.h
deleted file mode 100644
index 932e30f..0000000
--- a/include/media/stagefright/MPEG4Extractor.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef MPEG4_EXTRACTOR_H_
-
-#define MPEG4_EXTRACTOR_H_
-
-#include <media/stagefright/MediaExtractor.h>
-
-namespace android {
-
-class DataSource;
-class SampleTable;
-class String8;
-
-class MPEG4Extractor : public MediaExtractor {
-public:
- // Extractor assumes ownership of "source".
- MPEG4Extractor(const sp<DataSource> &source);
-
- size_t countTracks();
- sp<MediaSource> getTrack(size_t index);
- sp<MetaData> getTrackMetaData(size_t index);
-
-protected:
- virtual ~MPEG4Extractor();
-
-private:
- struct Track {
- Track *next;
- sp<MetaData> meta;
- uint32_t timescale;
- sp<SampleTable> sampleTable;
- };
-
- sp<DataSource> mDataSource;
- bool mHaveMetadata;
-
- Track *mFirstTrack, *mLastTrack;
-
- uint32_t mHandlerType;
-
- status_t readMetaData();
- status_t parseChunk(off_t *offset, int depth);
-
- MPEG4Extractor(const MPEG4Extractor &);
- MPEG4Extractor &operator=(const MPEG4Extractor &);
-};
-
-bool SniffMPEG4(
- const sp<DataSource> &source, String8 *mimeType, float *confidence);
-
-} // namespace android
-
-#endif // MPEG4_EXTRACTOR_H_
diff --git a/include/media/stagefright/MPEG4Writer.h b/include/media/stagefright/MPEG4Writer.h
index 6b0399f..6b93f19 100644
--- a/include/media/stagefright/MPEG4Writer.h
+++ b/include/media/stagefright/MPEG4Writer.h
@@ -20,8 +20,8 @@
#include <stdio.h>
+#include <media/stagefright/MediaWriter.h>
#include <utils/List.h>
-#include <utils/RefBase.h>
#include <utils/threads.h>
namespace android {
@@ -30,14 +30,15 @@ class MediaBuffer;
class MediaSource;
class MetaData;
-class MPEG4Writer : public RefBase {
+class MPEG4Writer : public MediaWriter {
public:
MPEG4Writer(const char *filename);
+ MPEG4Writer(int fd);
- void addSource(const sp<MediaSource> &source);
- status_t start();
- bool reachedEOS();
- void stop();
+ virtual status_t addSource(const sp<MediaSource> &source);
+ virtual status_t start();
+ virtual bool reachedEOS();
+ virtual void stop();
void beginBox(const char *fourcc);
void writeInt8(int8_t x);
@@ -65,6 +66,7 @@ private:
List<off_t> mBoxes;
off_t addSample(MediaBuffer *buffer);
+ off_t addLengthPrefixedSample(MediaBuffer *buffer);
MPEG4Writer(const MPEG4Writer &);
MPEG4Writer &operator=(const MPEG4Writer &);
diff --git a/include/media/stagefright/MediaDefs.h b/include/media/stagefright/MediaDefs.h
index feb66e3..1efeb92 100644
--- a/include/media/stagefright/MediaDefs.h
+++ b/include/media/stagefright/MediaDefs.h
@@ -34,6 +34,7 @@ extern const char *MEDIA_MIMETYPE_AUDIO_AAC;
extern const char *MEDIA_MIMETYPE_AUDIO_RAW;
extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG4;
+extern const char *MEDIA_MIMETYPE_CONTAINER_WAV;
} // namespace android
diff --git a/include/media/stagefright/MediaErrors.h b/include/media/stagefright/MediaErrors.h
index 2bb0ed6..73d0f77 100644
--- a/include/media/stagefright/MediaErrors.h
+++ b/include/media/stagefright/MediaErrors.h
@@ -36,6 +36,9 @@ enum {
ERROR_BUFFER_TOO_SMALL = MEDIA_ERROR_BASE - 9,
ERROR_UNSUPPORTED = MEDIA_ERROR_BASE - 10,
ERROR_END_OF_STREAM = MEDIA_ERROR_BASE - 11,
+
+ // Not technically an error.
+ INFO_FORMAT_CHANGED = MEDIA_ERROR_BASE - 12,
};
} // namespace android
diff --git a/include/media/stagefright/MediaExtractor.h b/include/media/stagefright/MediaExtractor.h
index 67e45bd..4bc996e 100644
--- a/include/media/stagefright/MediaExtractor.h
+++ b/include/media/stagefright/MediaExtractor.h
@@ -31,9 +31,21 @@ public:
static sp<MediaExtractor> Create(
const sp<DataSource> &source, const char *mime = NULL);
+ static sp<MediaExtractor> CreateFromURI(
+ const char *uri, const char *mime = NULL);
+
virtual size_t countTracks() = 0;
virtual sp<MediaSource> getTrack(size_t index) = 0;
- virtual sp<MetaData> getTrackMetaData(size_t index) = 0;
+
+ enum GetTrackMetaDataFlags {
+ kIncludeExtensiveMetaData = 1
+ };
+ virtual sp<MetaData> getTrackMetaData(
+ size_t index, uint32_t flags = 0) = 0;
+
+ // Return container specific meta-data. The default implementation
+ // returns an empty metadata object.
+ virtual sp<MetaData> getMetaData();
protected:
MediaExtractor() {}
diff --git a/include/media/stagefright/MediaPlayerImpl.h b/include/media/stagefright/MediaPlayerImpl.h
deleted file mode 100644
index 7adf836..0000000
--- a/include/media/stagefright/MediaPlayerImpl.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef MEDIA_PLAYER_IMPL_H_
-
-#define MEDIA_PLAYER_IMPL_H_
-
-#include <pthread.h>
-
-#include <media/MediaPlayerInterface.h>
-#include <media/stagefright/OMXClient.h>
-#include <utils/RefBase.h>
-#include <utils/threads.h>
-
-namespace android {
-
-class AudioPlayer;
-class IOMXRenderer;
-class ISurface;
-class MediaExtractor;
-class MediaBuffer;
-class MediaSource;
-class MemoryHeapPmem;
-class MetaData;
-class Surface;
-class TimeSource;
-
-class MediaPlayerImpl {
-public:
- MediaPlayerImpl(const char *uri);
-
- status_t initCheck() const;
-
- // Assumes ownership of "fd".
- MediaPlayerImpl(int fd, int64_t offset, int64_t length);
-
- ~MediaPlayerImpl();
-
- void play();
- void pause();
- bool isPlaying() const;
-
- void setSurface(const sp<Surface> &surface);
- void setISurface(const sp<ISurface> &isurface);
-
- void setAudioSink(const sp<MediaPlayerBase::AudioSink> &audioSink);
-
- int32_t getWidth() const { return mVideoWidth; }
- int32_t getHeight() const { return mVideoHeight; }
-
- int64_t getDuration();
- int64_t getPosition();
- status_t seekTo(int64_t time);
-
-private:
- status_t mInitCheck;
-
- OMXClient mClient;
-
- sp<MediaExtractor> mExtractor;
-
- TimeSource *mTimeSource;
-
- sp<MediaSource> mAudioSource;
- sp<MediaSource> mAudioDecoder;
- AudioPlayer *mAudioPlayer;
-
- sp<MediaSource> mVideoSource;
- sp<MediaSource> mVideoDecoder;
- int32_t mVideoWidth, mVideoHeight;
- int64_t mVideoPosition;
-
- int64_t mDuration;
-
- bool mPlaying;
- bool mPaused;
-
- int64_t mTimeSourceDeltaUs;
-
- sp<Surface> mSurface;
- sp<ISurface> mISurface;
- sp<IOMXRenderer> mVideoRenderer;
-
- sp<MediaPlayerBase::AudioSink> mAudioSink;
-
- Mutex mLock;
- pthread_t mVideoThread;
-
- bool mSeeking;
- int64_t mSeekTimeUs;
-
- void init();
-
- static void *VideoWrapper(void *me);
- void videoEntry();
-
- void setAudioSource(const sp<MediaSource> &source);
- void setVideoSource(const sp<MediaSource> &source);
-
- MediaSource *makeShoutcastSource(const char *path);
-
- void displayOrDiscardFrame(
- MediaBuffer **lastBuffer, MediaBuffer *buffer, int64_t pts_us);
-
- void populateISurface();
- void depopulateISurface();
- void sendFrameToISurface(MediaBuffer *buffer);
-
- void stop();
-
- MediaPlayerImpl(const MediaPlayerImpl &);
- MediaPlayerImpl &operator=(const MediaPlayerImpl &);
-};
-
-} // namespace android
-
-#endif // MEDIA_PLAYER_IMPL_H_
diff --git a/include/media/stagefright/MediaSource.h b/include/media/stagefright/MediaSource.h
index d1fa114..96d57e7 100644
--- a/include/media/stagefright/MediaSource.h
+++ b/include/media/stagefright/MediaSource.h
@@ -51,6 +51,9 @@ struct MediaSource : public RefBase {
// buffer is available, an error is encountered of the end of the stream
// is reached.
// End of stream is signalled by a result of ERROR_END_OF_STREAM.
+ // A result of INFO_FORMAT_CHANGED indicates that the format of this
+ // MediaSource has changed mid-stream, the client can continue reading
+ // but should be prepared for buffers of the new configuration.
virtual status_t read(
MediaBuffer **buffer, const ReadOptions *options = NULL) = 0;
diff --git a/include/media/stagefright/MediaWriter.h b/include/media/stagefright/MediaWriter.h
new file mode 100644
index 0000000..b8232c6
--- /dev/null
+++ b/include/media/stagefright/MediaWriter.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MEDIA_WRITER_H_
+
+#define MEDIA_WRITER_H_
+
+#include <utils/RefBase.h>
+
+namespace android {
+
+struct MediaSource;
+
+struct MediaWriter : public RefBase {
+ MediaWriter() {}
+
+ virtual status_t addSource(const sp<MediaSource> &source) = 0;
+ virtual bool reachedEOS() = 0;
+ virtual status_t start() = 0;
+ virtual void stop() = 0;
+
+protected:
+ virtual ~MediaWriter() {}
+
+private:
+ MediaWriter(const MediaWriter &);
+ MediaWriter &operator=(const MediaWriter &);
+};
+
+} // namespace android
+
+#endif // MEDIA_WRITER_H_
diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h
index abb45a9..3b21468 100644
--- a/include/media/stagefright/MetaData.h
+++ b/include/media/stagefright/MetaData.h
@@ -27,25 +27,40 @@
namespace android {
+// The following keys map to int32_t data unless indicated otherwise.
enum {
- kKeyMIMEType = 'mime',
+ kKeyMIMEType = 'mime', // cstring
kKeyWidth = 'widt',
kKeyHeight = 'heig',
kKeyChannelCount = '#chn',
kKeySampleRate = 'srte',
- kKeyBitRate = 'brte',
- kKeyESDS = 'esds',
- kKeyAVCC = 'avcc',
- kKeyTimeUnits = '#tim',
- kKeyTimeScale = 'scal',
+ kKeyBitRate = 'brte', // int32_t (bps)
+ kKeyESDS = 'esds', // raw data
+ kKeyAVCC = 'avcc', // raw data
kKeyWantsNALFragments = 'NALf',
- kKeyIsSyncFrame = 'sync',
- kKeyDuration = 'dura',
+ kKeyIsSyncFrame = 'sync', // int32_t (bool)
+ kKeyIsCodecConfig = 'conf', // int32_t (bool)
+ kKeyTime = 'time', // int64_t (usecs)
+ kKeyDuration = 'dura', // int64_t (usecs)
kKeyColorFormat = 'colf',
- kKeyPlatformPrivate = 'priv',
- kKeyDecoderComponent = 'decC',
+ kKeyPlatformPrivate = 'priv', // pointer
+ kKeyDecoderComponent = 'decC', // cstring
kKeyBufferID = 'bfID',
kKeyMaxInputSize = 'inpS',
+ kKeyThumbnailTime = 'thbT', // int64_t (usecs)
+
+ kKeyAlbum = 'albu', // cstring
+ kKeyArtist = 'arti', // cstring
+ kKeyComposer = 'comp', // cstring
+ kKeyGenre = 'genr', // cstring
+ kKeyTitle = 'titl', // cstring
+ kKeyYear = 'year', // cstring
+ kKeyAlbumArt = 'albA', // compressed image data
+ kKeyAlbumArtMIME = 'alAM', // cstring
+ kKeyAuthor = 'auth', // cstring
+ kKeyCDTrackNumber = 'cdtr', // cstring
+ kKeyDate = 'date', // cstring
+ kKeyWriter = 'writ', // cstring
};
enum {
@@ -62,6 +77,7 @@ public:
TYPE_NONE = 'none',
TYPE_C_STRING = 'cstr',
TYPE_INT32 = 'in32',
+ TYPE_INT64 = 'in64',
TYPE_FLOAT = 'floa',
TYPE_POINTER = 'ptr ',
};
@@ -71,11 +87,13 @@ public:
bool setCString(uint32_t key, const char *value);
bool setInt32(uint32_t key, int32_t value);
+ bool setInt64(uint32_t key, int64_t value);
bool setFloat(uint32_t key, float value);
bool setPointer(uint32_t key, void *value);
bool findCString(uint32_t key, const char **value);
bool findInt32(uint32_t key, int32_t *value);
+ bool findInt64(uint32_t key, int64_t *value);
bool findFloat(uint32_t key, float *value);
bool findPointer(uint32_t key, void **value);
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index 3f3dcf9..82dd2b5 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -30,11 +30,15 @@ struct OMXCodecObserver;
struct OMXCodec : public MediaSource,
public MediaBufferObserver {
- static sp<OMXCodec> Create(
+ enum CreationFlags {
+ kPreferSoftwareCodecs = 1,
+ };
+ static sp<MediaSource> Create(
const sp<IOMX> &omx,
const sp<MetaData> &meta, bool createEncoder,
const sp<MediaSource> &source,
- const char *matchComponentName = NULL);
+ const char *matchComponentName = NULL,
+ uint32_t flags = 0);
static void setComponentRole(
const sp<IOMX> &omx, IOMX::node_id node, bool isEncoder,
@@ -90,13 +94,15 @@ private:
kRequiresFlushCompleteEmulation = 16,
kRequiresAllocateBufferOnOutputPorts = 32,
kRequiresFlushBeforeShutdown = 64,
- kOutputDimensionsAre16Aligned = 128,
+ kDefersOutputBufferAllocation = 128,
};
struct BufferInfo {
IOMX::buffer_id mBuffer;
bool mOwnedByComponent;
sp<IMemory> mMem;
+ size_t mSize;
+ void *mData;
MediaBuffer *mMediaBuffer;
};
@@ -106,8 +112,8 @@ private:
};
sp<IOMX> mOMX;
+ bool mOMXLivesLocally;
IOMX::node_id mNode;
- sp<OMXCodecObserver> mObserver;
uint32_t mQuirks;
bool mIsEncoder;
char *mMIME;
@@ -125,6 +131,7 @@ private:
bool mInitialBufferSubmit;
bool mSignalledEOS;
bool mNoMoreOutputData;
+ bool mOutputPortSettingsHaveChanged;
int64_t mSeekTimeUs;
Mutex mLock;
@@ -143,8 +150,7 @@ private:
void setComponentRole();
- void setAMRFormat();
- void setAMRWBFormat();
+ void setAMRFormat(bool isWAMR);
void setAACFormat(int32_t numChannels, int32_t sampleRate);
status_t setVideoPortFormatType(
@@ -155,6 +161,9 @@ private:
void setVideoInputFormat(
const char *mime, OMX_U32 width, OMX_U32 height);
+ status_t setupMPEG4EncoderParameters();
+ status_t setupAVCEncoderParameters();
+
void setVideoOutputFormat(
const char *mime, OMX_U32 width, OMX_U32 height);
@@ -208,6 +217,14 @@ private:
void dumpPortStatus(OMX_U32 portIndex);
+ static uint32_t getComponentQuirks(const char *componentName);
+
+ static void findMatchingCodecs(
+ const char *mime,
+ bool createEncoder, const char *matchComponentName,
+ uint32_t flags,
+ Vector<String8> *matchingCodecs);
+
OMXCodec(const OMXCodec &);
OMXCodec &operator=(const OMXCodec &);
};
diff --git a/include/media/stagefright/OMXPluginBase.h b/include/media/stagefright/OMXPluginBase.h
new file mode 100644
index 0000000..2fd8e12
--- /dev/null
+++ b/include/media/stagefright/OMXPluginBase.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMX_PLUGIN_BASE_H_
+
+#define OMX_PLUGIN_BASE_H_
+
+#include <sys/types.h>
+
+#include <OMX_Component.h>
+
+#include <utils/String8.h>
+#include <utils/Vector.h>
+
+namespace android {
+
+struct OMXComponentBase;
+
+struct OMXPluginBase {
+ OMXPluginBase() {}
+ virtual ~OMXPluginBase() {}
+
+ virtual OMX_ERRORTYPE makeComponentInstance(
+ const char *name,
+ const OMX_CALLBACKTYPE *callbacks,
+ OMX_PTR appData,
+ OMX_COMPONENTTYPE **component) = 0;
+
+ virtual OMX_ERRORTYPE destroyComponentInstance(
+ OMX_COMPONENTTYPE *component) = 0;
+
+ virtual OMX_ERRORTYPE enumerateComponents(
+ OMX_STRING name,
+ size_t size,
+ OMX_U32 index) = 0;
+
+ virtual OMX_ERRORTYPE getRolesOfComponent(
+ const char *name,
+ Vector<String8> *roles) = 0;
+
+private:
+ OMXPluginBase(const OMXPluginBase &);
+ OMXPluginBase &operator=(const OMXPluginBase &);
+};
+
+} // namespace android
+
+#endif // OMX_PLUGIN_BASE_H_
diff --git a/include/media/stagefright/SampleTable.h b/include/media/stagefright/SampleTable.h
deleted file mode 100644
index 808d142..0000000
--- a/include/media/stagefright/SampleTable.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SAMPLE_TABLE_H_
-
-#define SAMPLE_TABLE_H_
-
-#include <sys/types.h>
-#include <stdint.h>
-
-#include <media/stagefright/MediaErrors.h>
-#include <utils/RefBase.h>
-#include <utils/threads.h>
-
-namespace android {
-
-class DataSource;
-
-class SampleTable : public RefBase {
-public:
- SampleTable(const sp<DataSource> &source);
-
- // type can be 'stco' or 'co64'.
- status_t setChunkOffsetParams(
- uint32_t type, off_t data_offset, off_t data_size);
-
- status_t setSampleToChunkParams(off_t data_offset, off_t data_size);
-
- // type can be 'stsz' or 'stz2'.
- status_t setSampleSizeParams(
- uint32_t type, off_t data_offset, off_t data_size);
-
- status_t setTimeToSampleParams(off_t data_offset, off_t data_size);
-
- status_t setSyncSampleParams(off_t data_offset, off_t data_size);
-
- ////////////////////////////////////////////////////////////////////////////
-
- uint32_t countChunkOffsets() const;
- status_t getChunkOffset(uint32_t chunk_index, off_t *offset);
-
- status_t getChunkForSample(
- uint32_t sample_index, uint32_t *chunk_index,
- uint32_t *chunk_relative_sample_index, uint32_t *desc_index);
-
- uint32_t countSamples() const;
- status_t getSampleSize(uint32_t sample_index, size_t *sample_size);
-
- status_t getSampleOffsetAndSize(
- uint32_t sample_index, off_t *offset, size_t *size);
-
- status_t getMaxSampleSize(size_t *size);
-
- status_t getDecodingTime(uint32_t sample_index, uint32_t *time);
-
- enum {
- kSyncSample_Flag = 1
- };
- status_t findClosestSample(
- uint32_t req_time, uint32_t *sample_index, uint32_t flags);
-
- status_t findClosestSyncSample(
- uint32_t start_sample_index, uint32_t *sample_index);
-
-protected:
- ~SampleTable();
-
-private:
- sp<DataSource> mDataSource;
- Mutex mLock;
-
- off_t mChunkOffsetOffset;
- uint32_t mChunkOffsetType;
- uint32_t mNumChunkOffsets;
-
- off_t mSampleToChunkOffset;
- uint32_t mNumSampleToChunkOffsets;
-
- off_t mSampleSizeOffset;
- uint32_t mSampleSizeFieldSize;
- uint32_t mDefaultSampleSize;
- uint32_t mNumSampleSizes;
-
- uint32_t mTimeToSampleCount;
- uint32_t *mTimeToSample;
-
- off_t mSyncSampleOffset;
- uint32_t mNumSyncSamples;
-
- SampleTable(const SampleTable &);
- SampleTable &operator=(const SampleTable &);
-};
-
-} // namespace android
-
-#endif // SAMPLE_TABLE_H_
diff --git a/include/media/stagefright/ShoutcastSource.h b/include/media/stagefright/ShoutcastSource.h
index 352857a..bc67156 100644
--- a/include/media/stagefright/ShoutcastSource.h
+++ b/include/media/stagefright/ShoutcastSource.h
@@ -31,7 +31,6 @@ class ShoutcastSource : public MediaSource {
public:
// Assumes ownership of "http".
ShoutcastSource(HTTPStream *http);
- virtual ~ShoutcastSource();
virtual status_t start(MetaData *params = NULL);
virtual status_t stop();
@@ -41,6 +40,9 @@ public:
virtual status_t read(
MediaBuffer **buffer, const ReadOptions *options = NULL);
+protected:
+ virtual ~ShoutcastSource();
+
private:
HTTPStream *mHttp;
size_t mMetaDataOffset;
diff --git a/include/media/stagefright/SoftwareRenderer.h b/include/media/stagefright/SoftwareRenderer.h
deleted file mode 100644
index 1545493..0000000
--- a/include/media/stagefright/SoftwareRenderer.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SOFTWARE_RENDERER_H_
-
-#define SOFTWARE_RENDERER_H_
-
-#include <OMX_Video.h>
-#include <media/stagefright/VideoRenderer.h>
-#include <utils/RefBase.h>
-
-namespace android {
-
-class ISurface;
-class MemoryHeapBase;
-
-class SoftwareRenderer : public VideoRenderer {
-public:
- SoftwareRenderer(
- OMX_COLOR_FORMATTYPE colorFormat,
- const sp<ISurface> &surface,
- size_t displayWidth, size_t displayHeight,
- size_t decodedWidth, size_t decodedHeight);
-
- virtual ~SoftwareRenderer();
-
- virtual void render(
- const void *data, size_t size, void *platformPrivate);
-
-private:
- uint8_t *initClip();
-
- void renderCbYCrY(const void *data, size_t size);
- void renderYUV420Planar(const void *data, size_t size);
- void renderQCOMYUV420SemiPlanar(const void *data, size_t size);
-
- OMX_COLOR_FORMATTYPE mColorFormat;
- sp<ISurface> mISurface;
- size_t mDisplayWidth, mDisplayHeight;
- size_t mDecodedWidth, mDecodedHeight;
- size_t mFrameSize;
- sp<MemoryHeapBase> mMemoryHeap;
- int mIndex;
-
- uint8_t *mClip;
-
- SoftwareRenderer(const SoftwareRenderer &);
- SoftwareRenderer &operator=(const SoftwareRenderer &);
-};
-
-} // namespace android
-
-#endif // SOFTWARE_RENDERER_H_
diff --git a/include/media/stagefright/MmapSource.h b/include/media/stagefright/StagefrightMediaScanner.h
index a8bd57f..af125dc 100644
--- a/include/media/stagefright/MmapSource.h
+++ b/include/media/stagefright/StagefrightMediaScanner.h
@@ -14,39 +14,33 @@
* limitations under the License.
*/
-#ifndef MMAP_SOURCE_H_
+#ifndef STAGEFRIGHT_MEDIA_SCANNER_H_
-#define MMAP_SOURCE_H_
+#define STAGEFRIGHT_MEDIA_SCANNER_H_
-#include <media/stagefright/DataSource.h>
-#include <media/stagefright/MediaErrors.h>
+#include <media/mediascanner.h>
namespace android {
-class MmapSource : public DataSource {
-public:
- MmapSource(const char *filename);
+struct StagefrightMetadataRetriever;
- // Assumes ownership of "fd".
- MmapSource(int fd, int64_t offset, int64_t length);
+struct StagefrightMediaScanner : public MediaScanner {
+ StagefrightMediaScanner();
+ virtual ~StagefrightMediaScanner();
- virtual ~MmapSource();
+ virtual status_t processFile(
+ const char *path, const char *mimeType,
+ MediaScannerClient &client);
- status_t InitCheck() const;
-
- virtual ssize_t read_at(off_t offset, void *data, size_t size);
- virtual status_t getSize(off_t *size);
+ virtual char *extractAlbumArt(int fd);
private:
- int mFd;
- void *mBase;
- size_t mSize;
+ sp<StagefrightMetadataRetriever> mRetriever;
- MmapSource(const MmapSource &);
- MmapSource &operator=(const MmapSource &);
+ StagefrightMediaScanner(const StagefrightMediaScanner &);
+ StagefrightMediaScanner &operator=(const StagefrightMediaScanner &);
};
} // namespace android
-#endif // MMAP_SOURCE_H_
-
+#endif // STAGEFRIGHT_MEDIA_SCANNER_H_
diff --git a/include/media/stagefright/TimedEventQueue.h b/include/media/stagefright/TimedEventQueue.h
deleted file mode 100644
index a264421..0000000
--- a/include/media/stagefright/TimedEventQueue.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef TIMED_EVENT_QUEUE_H_
-
-#define TIMED_EVENT_QUEUE_H_
-
-#include <pthread.h>
-
-#include <utils/List.h>
-#include <utils/RefBase.h>
-#include <utils/threads.h>
-
-namespace android {
-
-struct TimedEventQueue {
-
- struct Event : public RefBase {
- Event() {}
- virtual ~Event() {}
-
- protected:
- virtual void fire(TimedEventQueue *queue, int64_t now_us) = 0;
-
- private:
- friend class TimedEventQueue;
-
- Event(const Event &);
- Event &operator=(const Event &);
- };
-
- TimedEventQueue();
- ~TimedEventQueue();
-
- // Start executing the event loop.
- void start();
-
- // Stop executing the event loop, if flush is false, any pending
- // events are discarded, otherwise the queue will stop (and this call
- // return) once all pending events have been handled.
- void stop(bool flush = false);
-
- // Posts an event to the front of the queue (after all events that
- // have previously been posted to the front but before timed events).
- void postEvent(const sp<Event> &event);
-
- void postEventToBack(const sp<Event> &event);
-
- // It is an error to post an event with a negative delay.
- void postEventWithDelay(const sp<Event> &event, int64_t delay_us);
-
- // If the event is to be posted at a time that has already passed,
- // it will fire as soon as possible.
- void postTimedEvent(const sp<Event> &event, int64_t realtime_us);
-
- // Returns true iff event is currently in the queue and has been
- // successfully cancelled. In this case the event will have been
- // removed from the queue and won't fire.
- bool cancelEvent(const sp<Event> &event);
-
- static int64_t getRealTimeUs();
-
-private:
- struct QueueItem {
- sp<Event> event;
- int64_t realtime_us;
- };
-
- struct StopEvent : public TimedEventQueue::Event {
- virtual void fire(TimedEventQueue *queue, int64_t now_us) {
- queue->mStopped = true;
- }
- };
-
- pthread_t mThread;
- List<QueueItem> mQueue;
- Mutex mLock;
- Condition mQueueNotEmptyCondition;
- Condition mQueueHeadChangedCondition;
-
- bool mRunning;
- bool mStopped;
-
- static void *ThreadWrapper(void *me);
- void threadEntry();
-
- TimedEventQueue(const TimedEventQueue &);
- TimedEventQueue &operator=(const TimedEventQueue &);
-};
-
-} // namespace android
-
-#endif // TIMED_EVENT_QUEUE_H_
diff --git a/include/media/stagefright/stagefright_string.h b/include/media/stagefright/stagefright_string.h
deleted file mode 100644
index 1ed4c86..0000000
--- a/include/media/stagefright/stagefright_string.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef STAGEFRIGHT_STRING_H_
-
-#define STAGEFRIGHT_STRING_H_
-
-#include <utils/String8.h>
-
-namespace android {
-
-class string {
-public:
- typedef size_t size_type;
- static size_type npos;
-
- string();
- string(const char *s);
- string(const char *s, size_t length);
- string(const string &from, size_type start, size_type length = npos);
-
- const char *c_str() const;
- size_type size() const;
-
- void clear();
- void erase(size_type from, size_type length);
-
- size_type find(char c) const;
-
- bool operator<(const string &other) const;
- bool operator==(const string &other) const;
-
- string &operator+=(char c);
-
-private:
- String8 mString;
-};
-
-} // namespace android
-
-#endif // STAGEFRIGHT_STRING_H_
diff --git a/include/ui/Camera.h b/include/ui/Camera.h
index 5219772..c506fb8 100644
--- a/include/ui/Camera.h
+++ b/include/ui/Camera.h
@@ -82,6 +82,7 @@ enum {
enum {
CAMERA_CMD_START_SMOOTH_ZOOM = 1,
CAMERA_CMD_STOP_SMOOTH_ZOOM = 2,
+ CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3,
};
// camera fatal errors
@@ -209,4 +210,3 @@ private:
}; // namespace android
#endif
-
diff --git a/include/ui/CameraParameters.h b/include/ui/CameraParameters.h
index 9e4e140..cae0676 100644
--- a/include/ui/CameraParameters.h
+++ b/include/ui/CameraParameters.h
@@ -29,12 +29,6 @@ public:
CameraParameters(const String8 &params) { unflatten(params); }
~CameraParameters();
- enum {
- CAMERA_ORIENTATION_UNKNOWN = 0,
- CAMERA_ORIENTATION_PORTRAIT = 1,
- CAMERA_ORIENTATION_LANDSCAPE = 2,
- };
-
String8 flatten() const;
void unflatten(const String8 &params);
@@ -63,9 +57,6 @@ public:
void setPictureFormat(const char *format);
const char *getPictureFormat() const;
- int getOrientation() const;
- void setOrientation(int orientation);
-
void dump() const;
status_t dump(int fd, const Vector<String16>& args) const;
@@ -109,9 +100,10 @@ public:
// The height (in pixels) of EXIF thumbnail in Jpeg picture.
// Example value: "384". Read/write.
static const char KEY_JPEG_THUMBNAIL_HEIGHT[];
- // Supported EXIF thumbnail sizes (width x height).
- // Example value: "512x384,320x240". Read only.
- static const char KEY_SUPPORTED_THUMBNAIL_SIZES[];
+ // Supported EXIF thumbnail sizes (width x height). 0x0 means not thumbnail
+ // in EXIF.
+ // Example value: "512x384,320x240,0x0". Read only.
+ static const char KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[];
// The quality of the EXIF thumbnail in Jpeg picture. The range is 1 to 100,
// with 100 being the best.
// Example value: "90". Read/write.
diff --git a/include/ui/ISurface.h b/include/ui/ISurface.h
index 2ca0026..c7f181c 100644
--- a/include/ui/ISurface.h
+++ b/include/ui/ISurface.h
@@ -55,8 +55,11 @@ public:
class BufferHeap {
public:
enum {
- /* rotate source image 90 degrees */
+ /* rotate source image */
+ ROT_0 = 0,
ROT_90 = HAL_TRANSFORM_ROT_90,
+ ROT_180 = HAL_TRANSFORM_ROT_180,
+ ROT_270 = HAL_TRANSFORM_ROT_270,
};
BufferHeap();
@@ -86,7 +89,7 @@ public:
virtual void unregisterBuffers() = 0;
virtual sp<OverlayRef> createOverlay(
- uint32_t w, uint32_t h, int32_t format) = 0;
+ uint32_t w, uint32_t h, int32_t format, int32_t orientation) = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h
index 49145e8..6090f60 100644
--- a/include/utils/ResourceTypes.h
+++ b/include/utils/ResourceTypes.h
@@ -393,7 +393,10 @@ struct ResStringPool_header
enum {
// If set, the string index is sorted by the string values (based
// on strcmp16()).
- SORTED_FLAG = 1<<0
+ SORTED_FLAG = 1<<0,
+
+ // String pool is encoded in UTF-8
+ UTF8_FLAG = 1<<8
};
uint32_t flags;
@@ -451,14 +454,20 @@ public:
size_t size() const;
+#ifndef HAVE_ANDROID_OS
+ bool isUTF8() const;
+#endif
+
private:
status_t mError;
void* mOwnedData;
const ResStringPool_header* mHeader;
size_t mSize;
+ mutable Mutex mDecodeLock;
const uint32_t* mEntries;
const uint32_t* mEntryStyles;
- const char16_t* mStrings;
+ const void* mStrings;
+ char16_t** mCache;
uint32_t mStringPoolSize; // number of uint16_t
const uint32_t* mStyles;
uint32_t mStylePoolSize; // number of uint32_t
diff --git a/include/utils/String16.h b/include/utils/String16.h
index a2d22ee..07a0c11 100644
--- a/include/utils/String16.h
+++ b/include/utils/String16.h
@@ -49,12 +49,17 @@ int strzcmp16(const char16_t *s1, size_t n1, const char16_t *s2, size_t n2);
// Version of strzcmp16 for comparing strings in different endianness.
int strzcmp16_h_n(const char16_t *s1H, size_t n1, const char16_t *s2N, size_t n2);
+// Convert UTF-8 to UTF-16 including surrogate pairs
+void utf8_to_utf16(const uint8_t *src, size_t srcLen, char16_t* dst, const size_t dstLen);
+
}
// ---------------------------------------------------------------------------
namespace android {
+// ---------------------------------------------------------------------------
+
class String8;
class TextOutput;
diff --git a/include/utils/String8.h b/include/utils/String8.h
index ecc5774..c4b18a4 100644
--- a/include/utils/String8.h
+++ b/include/utils/String8.h
@@ -60,6 +60,11 @@ size_t utf32_length(const char *src, size_t src_len);
/*
* Returns the UTF-8 length of "src".
*/
+size_t utf8_length_from_utf16(const char16_t *src, size_t src_len);
+
+/*
+ * Returns the UTF-8 length of "src".
+ */
size_t utf8_length_from_utf32(const char32_t *src, size_t src_len);
/*
@@ -120,6 +125,9 @@ size_t utf8_to_utf32(const char* src, size_t src_len,
size_t utf32_to_utf8(const char32_t* src, size_t src_len,
char* dst, size_t dst_len);
+size_t utf16_to_utf8(const char16_t* src, size_t src_len,
+ char* dst, size_t dst_len);
+
}
// ---------------------------------------------------------------------------
diff --git a/include/utils/threads.h b/include/utils/threads.h
index 0fc533f..130d83c 100644
--- a/include/utils/threads.h
+++ b/include/utils/threads.h
@@ -124,6 +124,24 @@ typedef int (*android_create_thread_fn)(android_thread_func_t entryFunction,
extern void androidSetCreateThreadFunc(android_create_thread_fn func);
+// ------------------------------------------------------------------
+// Extra functions working with raw pids.
+
+// Get pid for the current thread.
+extern pid_t androidGetTid();
+
+// Change the scheduling group of a particular thread. The group
+// should be one of the ANDROID_TGROUP constants. Returns BAD_VALUE if
+// grp is out of range, else another non-zero value with errno set if
+// the operation failed.
+extern int androidSetThreadSchedulingGroup(pid_t tid, int grp);
+
+// Change the priority AND scheduling group of a particular thread. The priority
+// should be one of the ANDROID_PRIORITY constants. Returns INVALID_OPERATION
+// if the priority set failed, else another value if just the group set failed;
+// in either case errno is set.
+extern int androidSetThreadPriority(pid_t tid, int prio);
+
#ifdef __cplusplus
}
#endif