summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/camera/camera2/CaptureRequest.h1
-rw-r--r--include/camera/camera2/ICameraDeviceUser.h13
-rw-r--r--include/media/AudioRecord.h15
-rw-r--r--include/media/AudioResamplerPublic.h19
-rw-r--r--include/media/AudioTrack.h20
-rw-r--r--include/media/ICrypto.h8
-rw-r--r--include/media/IMediaCodecList.h4
-rw-r--r--include/media/MediaCodecInfo.h4
-rw-r--r--include/media/mediametadataretriever.h1
-rw-r--r--include/media/stagefright/ACodec.h1
-rw-r--r--include/media/stagefright/MediaClock.h1
-rw-r--r--include/media/stagefright/MediaCodec.h46
-rw-r--r--include/media/stagefright/MediaCodecList.h15
-rw-r--r--include/media/stagefright/MetaData.h3
-rw-r--r--include/private/media/AudioTrackShared.h36
15 files changed, 180 insertions, 7 deletions
diff --git a/include/camera/camera2/CaptureRequest.h b/include/camera/camera2/CaptureRequest.h
index e56d61f..eeab217 100644
--- a/include/camera/camera2/CaptureRequest.h
+++ b/include/camera/camera2/CaptureRequest.h
@@ -30,6 +30,7 @@ public:
CameraMetadata mMetadata;
Vector<sp<Surface> > mSurfaceList;
+ bool mIsReprocess;
/**
* Keep impl up-to-date with CaptureRequest.java in frameworks/base
diff --git a/include/camera/camera2/ICameraDeviceUser.h b/include/camera/camera2/ICameraDeviceUser.h
index e9f1f5a..c850924 100644
--- a/include/camera/camera2/ICameraDeviceUser.h
+++ b/include/camera/camera2/ICameraDeviceUser.h
@@ -103,6 +103,19 @@ public:
virtual status_t createStream(const OutputConfiguration& outputConfiguration) = 0;
+ /**
+ * Create an input stream of width, height, and format (one of
+ * HAL_PIXEL_FORMAT_*)
+ *
+ * Return stream ID if it's a non-negative value. status_t if it's a
+ * negative value.
+ */
+ virtual status_t createInputStream(int width, int height, int format) = 0;
+
+ // get the buffer producer of the input stream
+ virtual status_t getInputBufferProducer(
+ sp<IGraphicBufferProducer> *producer) = 0;
+
// Create a request object from a template.
virtual status_t createDefaultRequest(int templateId,
/*out*/
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index 7be2c3e..dbe2788 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -335,6 +335,13 @@ public:
* After draining these frames of data, the caller should release them with releaseBuffer().
* If the track buffer is not empty, obtainBuffer() returns as many contiguous
* full frames as are available immediately.
+ *
+ * If nonContig is non-NULL, it is an output parameter that will be set to the number of
+ * additional non-contiguous frames that are predicted to be available immediately,
+ * if the client were to release the first frames and then call obtainBuffer() again.
+ * This value is only a prediction, and needs to be confirmed.
+ * It will be set to zero for an error return.
+ *
* If the track buffer is empty and track is stopped, obtainBuffer() returns WOULD_BLOCK
* regardless of the value of waitCount.
* If the track buffer is empty and track is not stopped, obtainBuffer() blocks with a
@@ -364,11 +371,15 @@ public:
* raw pointer to the buffer
*/
- status_t obtainBuffer(Buffer* audioBuffer, int32_t waitCount);
+ status_t obtainBuffer(Buffer* audioBuffer, int32_t waitCount,
+ size_t *nonContig = NULL);
private:
/* If nonContig is non-NULL, it is an output parameter that will be set to the number of
- * additional non-contiguous frames that are available immediately.
+ * additional non-contiguous frames that are predicted to be available immediately,
+ * if the client were to release the first frames and then call obtainBuffer() again.
+ * This value is only a prediction, and needs to be confirmed.
+ * It will be set to zero for an error return.
* FIXME We could pass an array of Buffers instead of only one Buffer to obtainBuffer(),
* in case the requested amount of frames is in two or more non-contiguous regions.
* FIXME requested and elapsed are both relative times. Consider changing to absolute time.
diff --git a/include/media/AudioResamplerPublic.h b/include/media/AudioResamplerPublic.h
index 0634741..07d946d 100644
--- a/include/media/AudioResamplerPublic.h
+++ b/include/media/AudioResamplerPublic.h
@@ -34,6 +34,16 @@
// an int32_t of the phase increments, making the resulting sample rate inexact.
#define AUDIO_RESAMPLER_UP_RATIO_MAX 65536
+#define AUDIO_TIMESTRETCH_SPEED_MIN 0.5f
+#define AUDIO_TIMESTRETCH_SPEED_MAX 2.0f
+#define AUDIO_TIMESTRETCH_SPEED_NORMAL 1.0f
+
+#define AUDIO_TIMESTRETCH_PITCH_MIN 0.5f
+#define AUDIO_TIMESTRETCH_PITCH_MAX 2.0f
+#define AUDIO_TIMESTRETCH_PITCH_NORMAL 1.0f
+
+// TODO: Consider putting these inlines into a class scope
+
// Returns the source frames needed to resample to destination frames. This is not a precise
// value and depends on the resampler (and possibly how it handles rounding internally).
// Nevertheless, this should be an upper bound on the requirements of the resampler.
@@ -58,4 +68,13 @@ static inline size_t destinationFramesPossible(size_t srcFrames, uint32_t srcSam
return dstFrames > 2 ? dstFrames - 2 : 0;
}
+static inline size_t sourceFramesNeededWithTimestretch(
+ uint32_t srcSampleRate, size_t dstFramesRequired, uint32_t dstSampleRate,
+ float speed) {
+ // required is the number of input frames the resampler needs
+ size_t required = sourceFramesNeeded(srcSampleRate, dstFramesRequired, dstSampleRate);
+ // to deliver this, the time stretcher requires:
+ return required * (double)speed + 1 + 1; // accounting for rounding dependencies
+}
+
#endif // ANDROID_AUDIO_RESAMPLER_PUBLIC_H
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index e7e0703..a06197f 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -359,6 +359,21 @@ public:
/* Return current source sample rate in Hz */
uint32_t getSampleRate() const;
+ /* Set source playback rate for timestretch
+ * 1.0 is normal speed: < 1.0 is slower, > 1.0 is faster
+ * 1.0 is normal pitch: < 1.0 is lower pitch, > 1.0 is higher pitch
+ *
+ * AUDIO_TIMESTRETCH_SPEED_MIN <= speed <= AUDIO_TIMESTRETCH_SPEED_MAX
+ * AUDIO_TIMESTRETCH_PITCH_MIN <= pitch <= AUDIO_TIMESTRETCH_PITCH_MAX
+ *
+ * Speed increases the playback rate of media, but does not alter pitch.
+ * Pitch increases the "tonal frequency" of media, but does not affect the playback rate.
+ */
+ status_t setPlaybackRate(float speed, float pitch);
+
+ /* Return current playback rate */
+ void getPlaybackRate(float *speed, float *pitch) const;
+
/* Enables looping and sets the start and end points of looping.
* Only supported for static buffer mode.
*
@@ -719,6 +734,9 @@ protected:
// increment mPosition by the delta of mServer, and return new value of mPosition
uint32_t updateAndGetPosition_l();
+ // check sample rate and speed is compatible with AudioTrack
+ bool isSampleRateSpeedAllowed_l(uint32_t sampleRate, float speed) const;
+
// Next 4 fields may be changed if IAudioTrack is re-created, but always != 0
sp<IAudioTrack> mAudioTrack;
sp<IMemory> mCblkMemory;
@@ -730,6 +748,8 @@ protected:
float mVolume[2];
float mSendLevel;
mutable uint32_t mSampleRate; // mutable because getSampleRate() can update it
+ float mSpeed; // timestretch: 1.0f for normal speed.
+ float mPitch; // timestretch: 1.0f for normal pitch.
size_t mFrameCount; // corresponds to current IAudioTrack, value is
// reported back by AudioFlinger to the client
size_t mReqFrameCount; // frame count to request the first or next time
diff --git a/include/media/ICrypto.h b/include/media/ICrypto.h
index 07742ca..aa04dbe 100644
--- a/include/media/ICrypto.h
+++ b/include/media/ICrypto.h
@@ -25,6 +25,7 @@
namespace android {
struct AString;
+struct IMemory;
struct ICrypto : public IInterface {
DECLARE_META_INTERFACE(Crypto);
@@ -43,12 +44,14 @@ struct ICrypto : public IInterface {
virtual void notifyResolution(uint32_t width, uint32_t height) = 0;
+ virtual status_t setMediaDrmSession(const Vector<uint8_t> &sessionId) = 0;
+
virtual ssize_t decrypt(
bool secure,
const uint8_t key[16],
const uint8_t iv[16],
CryptoPlugin::Mode mode,
- const void *srcPtr,
+ const sp<IMemory> &sharedBuffer, size_t offset,
const CryptoPlugin::SubSample *subSamples, size_t numSubSamples,
void *dstPtr,
AString *errorDetailMsg) = 0;
@@ -61,6 +64,9 @@ struct BnCrypto : public BnInterface<ICrypto> {
virtual status_t onTransact(
uint32_t code, const Parcel &data, Parcel *reply,
uint32_t flags = 0);
+private:
+ void readVector(const Parcel &data, Vector<uint8_t> &vector) const;
+ void writeVector(Parcel *reply, Vector<uint8_t> const &vector) const;
};
} // namespace android
diff --git a/include/media/IMediaCodecList.h b/include/media/IMediaCodecList.h
index e93ea8b..12b52d7 100644
--- a/include/media/IMediaCodecList.h
+++ b/include/media/IMediaCodecList.h
@@ -21,6 +21,8 @@
#include <binder/IInterface.h>
#include <binder/Parcel.h>
+#include <media/stagefright/foundation/AMessage.h>
+
namespace android {
struct MediaCodecInfo;
@@ -33,6 +35,8 @@ public:
virtual size_t countCodecs() const = 0;
virtual sp<MediaCodecInfo> getCodecInfo(size_t index) const = 0;
+ virtual const sp<AMessage> getGlobalSettings() const = 0;
+
virtual ssize_t findCodecByType(
const char *type, bool encoder, size_t startIndex = 0) const = 0;
diff --git a/include/media/MediaCodecInfo.h b/include/media/MediaCodecInfo.h
index cd56adb..895a13a 100644
--- a/include/media/MediaCodecInfo.h
+++ b/include/media/MediaCodecInfo.h
@@ -35,6 +35,8 @@ struct AMessage;
struct Parcel;
struct CodecCapabilities;
+typedef KeyedVector<AString, AString> CodecSettings;
+
struct MediaCodecInfo : public RefBase {
struct ProfileLevel {
uint32_t mProfile;
@@ -104,6 +106,7 @@ private:
MediaCodecInfo(AString name, bool encoder, const char *mime);
void addQuirk(const char *name);
status_t addMime(const char *mime);
+ status_t updateMime(const char *mime);
status_t initializeCapabilities(const CodecCapabilities &caps);
void addDetail(const AString &key, const AString &value);
void addFeature(const AString &key, int32_t value);
@@ -114,6 +117,7 @@ private:
DISALLOW_EVIL_CONSTRUCTORS(MediaCodecInfo);
friend class MediaCodecList;
+ friend class MediaCodecListOverridesTest;
};
} // namespace android
diff --git a/include/media/mediametadataretriever.h b/include/media/mediametadataretriever.h
index b35cf32..7191965 100644
--- a/include/media/mediametadataretriever.h
+++ b/include/media/mediametadataretriever.h
@@ -57,6 +57,7 @@ enum {
METADATA_KEY_IS_DRM = 22,
METADATA_KEY_LOCATION = 23,
METADATA_KEY_VIDEO_ROTATION = 24,
+ METADATA_KEY_CAPTURE_FRAMERATE = 25,
// Add more here...
};
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h
index c1483f3..a8d0fcb 100644
--- a/include/media/stagefright/ACodec.h
+++ b/include/media/stagefright/ACodec.h
@@ -300,6 +300,7 @@ private:
OMX_U32 portIndex, int32_t sampleRate, int32_t numChannels);
status_t setPriority(int32_t priority);
+ status_t setOperatingRate(float rateFloat, bool isVideo);
status_t setMinBufferSize(OMX_U32 portIndex, size_t size);
diff --git a/include/media/stagefright/MediaClock.h b/include/media/stagefright/MediaClock.h
index e9c09a1..dd1a809 100644
--- a/include/media/stagefright/MediaClock.h
+++ b/include/media/stagefright/MediaClock.h
@@ -42,6 +42,7 @@ struct MediaClock : public RefBase {
void updateMaxTimeMedia(int64_t maxTimeMediaUs);
void setPlaybackRate(float rate);
+ float getPlaybackRate() const;
// query media time corresponding to real time |realUs|, and save the
// result in |outMediaUs|.
diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h
index d055341..d98fa1a 100644
--- a/include/media/stagefright/MediaCodec.h
+++ b/include/media/stagefright/MediaCodec.h
@@ -20,6 +20,7 @@
#include <gui/IGraphicBufferProducer.h>
#include <media/hardware/CryptoAPI.h>
+#include <media/MediaResource.h>
#include <media/stagefright/foundation/AHandler.h>
#include <utils/Vector.h>
@@ -30,8 +31,12 @@ struct AMessage;
struct AReplyToken;
struct AString;
struct CodecBase;
-struct ICrypto;
struct IBatteryStats;
+struct ICrypto;
+struct IMemory;
+struct MemoryDealer;
+class IResourceManagerClient;
+class IResourceManagerService;
struct SoftwareRenderer;
struct Surface;
@@ -127,6 +132,8 @@ struct MediaCodec : public AHandler {
status_t getOutputFormat(sp<AMessage> *format) const;
status_t getInputFormat(sp<AMessage> *format) const;
+ status_t getWidevineLegacyBuffers(Vector<sp<ABuffer> > *buffers) const;
+
status_t getInputBuffers(Vector<sp<ABuffer> > *buffers) const;
status_t getOutputBuffers(Vector<sp<ABuffer> > *buffers) const;
@@ -214,11 +221,36 @@ private:
uint32_t mBufferID;
sp<ABuffer> mData;
sp<ABuffer> mEncryptedData;
+ sp<IMemory> mSharedEncryptedBuffer;
sp<AMessage> mNotify;
sp<AMessage> mFormat;
bool mOwnedByClient;
};
+ struct ResourceManagerServiceProxy : public IBinder::DeathRecipient {
+ ResourceManagerServiceProxy();
+ ~ResourceManagerServiceProxy();
+
+ void init();
+
+ // implements DeathRecipient
+ virtual void binderDied(const wp<IBinder>& /*who*/);
+
+ void addResource(
+ int pid,
+ int64_t clientId,
+ const sp<IResourceManagerClient> client,
+ const Vector<MediaResource> &resources);
+
+ void removeResource(int64_t clientId);
+
+ bool reclaimResource(int callingPid, const Vector<MediaResource> &resources);
+
+ private:
+ Mutex mLock;
+ sp<IResourceManagerService> mService;
+ };
+
State mState;
sp<ALooper> mLooper;
sp<ALooper> mCodecLooper;
@@ -232,15 +264,24 @@ private:
sp<AMessage> mOutputFormat;
sp<AMessage> mInputFormat;
sp<AMessage> mCallback;
+ sp<MemoryDealer> mDealer;
+
+ sp<IResourceManagerClient> mResourceManagerClient;
+ sp<ResourceManagerServiceProxy> mResourceManagerService;
bool mBatteryStatNotified;
bool mIsVideo;
+ int32_t mVideoWidth;
+ int32_t mVideoHeight;
// initial create parameters
AString mInitName;
bool mInitNameIsType;
bool mInitIsEncoder;
+ // configure parameter
+ sp<AMessage> mConfigureMsg;
+
// Used only to synchronize asynchronous getBufferAndFormat
// across all the other (synchronous) buffer state change
// operations, such as de/queueIn/OutputBuffer, start and
@@ -308,6 +349,9 @@ private:
void updateBatteryStat();
bool isExecuting() const;
+ uint64_t getGraphicBufferSize();
+ void addResource(const char *type, uint64_t value);
+
/* called to get the last codec error when the sticky flag is set.
* if no such codec error is found, returns UNKNOWN_ERROR.
*/
diff --git a/include/media/stagefright/MediaCodecList.h b/include/media/stagefright/MediaCodecList.h
index c2bbe4d..9d1d675 100644
--- a/include/media/stagefright/MediaCodecList.h
+++ b/include/media/stagefright/MediaCodecList.h
@@ -48,9 +48,14 @@ struct MediaCodecList : public BnMediaCodecList {
return mCodecInfos.itemAt(index);
}
+ virtual const sp<AMessage> getGlobalSettings() const;
+
// to be used by MediaPlayerService alone
static sp<IMediaCodecList> getLocalInstance();
+ // only to be used in getLocalInstance
+ void updateDetailsForMultipleCodecs(const KeyedVector<AString, CodecSettings>& updates);
+
private:
class BinderDeathObserver : public IBinder::DeathRecipient {
void binderDied(const wp<IBinder> &the_late_who __unused);
@@ -60,6 +65,7 @@ private:
enum Section {
SECTION_TOPLEVEL,
+ SECTION_SETTINGS,
SECTION_DECODERS,
SECTION_DECODER,
SECTION_DECODER_TYPE,
@@ -74,10 +80,14 @@ private:
status_t mInitCheck;
Section mCurrentSection;
+ bool mUpdate;
Vector<Section> mPastSections;
int32_t mDepth;
AString mHrefBase;
+ sp<AMessage> mGlobalSettings;
+ KeyedVector<AString, CodecSettings> mOverrides;
+
Vector<sp<MediaCodecInfo> > mCodecInfos;
sp<MediaCodecInfo> mCurrentInfo;
sp<IOMX> mOMX;
@@ -87,7 +97,7 @@ private:
status_t initCheck() const;
void parseXMLFile(const char *path);
- void parseTopLevelXMLFile(const char *path);
+ void parseTopLevelXMLFile(const char *path, bool ignore_errors = false);
static void StartElementHandlerWrapper(
void *me, const char *name, const char **attrs);
@@ -98,9 +108,12 @@ private:
void endElementHandler(const char *name);
status_t includeXMLFile(const char **attrs);
+ status_t addSettingFromAttributes(const char **attrs);
status_t addMediaCodecFromAttributes(bool encoder, const char **attrs);
void addMediaCodec(bool encoder, const char *name, const char *type = NULL);
+ void setCurrentCodecInfo(bool encoder, const char *name, const char *type);
+
status_t addQuirk(const char **attrs);
status_t addTypeFromAttributes(const char **attrs);
status_t addLimit(const char **attrs);
diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h
index 087d016..8bdebf6 100644
--- a/include/media/stagefright/MetaData.h
+++ b/include/media/stagefright/MetaData.h
@@ -75,6 +75,8 @@ enum {
kKeyDecoderComponent = 'decC', // cstring
kKeyBufferID = 'bfID',
kKeyMaxInputSize = 'inpS',
+ kKeyMaxWidth = 'maxW',
+ kKeyMaxHeight = 'maxH',
kKeyThumbnailTime = 'thbT', // int64_t (usecs)
kKeyTrackID = 'trID',
kKeyIsDRM = 'idrm', // int32_t (bool)
@@ -98,6 +100,7 @@ enum {
kKeyCompilation = 'cpil', // cstring
kKeyLocation = 'loc ', // cstring
kKeyTimeScale = 'tmsl', // int32_t
+ kKeyCaptureFramerate = 'capF', // float (capture fps)
// video profile and level
kKeyVideoProfile = 'vprf', // int32_t
diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h
index 5644428..6cc2e2b 100644
--- a/include/private/media/AudioTrackShared.h
+++ b/include/private/media/AudioTrackShared.h
@@ -25,6 +25,7 @@
#include <utils/Log.h>
#include <utils/RefBase.h>
#include <audio_utils/roundup.h>
+#include <media/AudioResamplerPublic.h>
#include <media/SingleStateQueue.h>
namespace android {
@@ -113,6 +114,14 @@ struct AudioTrackSharedStatic {
mPosLoopQueue;
};
+
+struct AudioTrackPlaybackRate {
+ float mSpeed;
+ float mPitch;
+};
+
+typedef SingleStateQueue<AudioTrackPlaybackRate> AudioTrackPlaybackRateQueue;
+
// ----------------------------------------------------------------------------
// Important: do not add any virtual methods, including ~
@@ -159,6 +168,8 @@ private:
uint32_t mSampleRate; // AudioTrack only: client's requested sample rate in Hz
// or 0 == default. Write-only client, read-only server.
+ AudioTrackPlaybackRateQueue::Shared mPlaybackRateQueue;
+
// client write-only, server read-only
uint16_t mSendLevel; // Fixed point U4.12 so 0x1000 means 1.0
@@ -313,7 +324,8 @@ public:
AudioTrackClientProxy(audio_track_cblk_t* cblk, void *buffers, size_t frameCount,
size_t frameSize, bool clientInServer = false)
: ClientProxy(cblk, buffers, frameCount, frameSize, true /*isOut*/,
- clientInServer) { }
+ clientInServer),
+ mPlaybackRateMutator(&cblk->mPlaybackRateQueue) { }
virtual ~AudioTrackClientProxy() { }
// No barriers on the following operations, so the ordering of loads/stores
@@ -333,6 +345,13 @@ public:
mCblk->mSampleRate = sampleRate;
}
+ void setPlaybackRate(float speed, float pitch) {
+ AudioTrackPlaybackRate playbackRate;
+ playbackRate.mSpeed = speed;
+ playbackRate.mPitch = pitch;
+ mPlaybackRateMutator.push(playbackRate);
+ }
+
virtual void flush();
virtual uint32_t getUnderrunFrames() const {
@@ -344,6 +363,9 @@ public:
bool getStreamEndDone() const;
status_t waitStreamEndDone(const struct timespec *requested);
+
+private:
+ AudioTrackPlaybackRateQueue::Mutator mPlaybackRateMutator;
};
class StaticAudioTrackClientProxy : public AudioTrackClientProxy {
@@ -458,8 +480,11 @@ class AudioTrackServerProxy : public ServerProxy {
public:
AudioTrackServerProxy(audio_track_cblk_t* cblk, void *buffers, size_t frameCount,
size_t frameSize, bool clientInServer = false, uint32_t sampleRate = 0)
- : ServerProxy(cblk, buffers, frameCount, frameSize, true /*isOut*/, clientInServer) {
+ : ServerProxy(cblk, buffers, frameCount, frameSize, true /*isOut*/, clientInServer),
+ mPlaybackRateObserver(&cblk->mPlaybackRateQueue) {
mCblk->mSampleRate = sampleRate;
+ mPlaybackRate.mSpeed = AUDIO_TIMESTRETCH_SPEED_NORMAL;
+ mPlaybackRate.mPitch = AUDIO_TIMESTRETCH_PITCH_NORMAL;
}
protected:
virtual ~AudioTrackServerProxy() { }
@@ -493,6 +518,13 @@ public:
// Return the total number of frames that AudioFlinger has obtained and released
virtual size_t framesReleased() const { return mCblk->mServer; }
+
+ // Return the playback speed and pitch read atomically. Not multi-thread safe on server side.
+ void getPlaybackRate(float *speed, float *pitch);
+
+private:
+ AudioTrackPlaybackRate mPlaybackRate; // last observed playback rate
+ AudioTrackPlaybackRateQueue::Observer mPlaybackRateObserver;
};
class StaticAudioTrackServerProxy : public AudioTrackServerProxy {