diff options
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/AudioPolicy.h | 1 | ||||
-rw-r--r-- | include/media/AudioSession.h | 71 | ||||
-rw-r--r-- | include/media/AudioSystem.h | 14 | ||||
-rw-r--r-- | include/media/IAudioPolicyService.h | 3 | ||||
-rw-r--r-- | include/media/IAudioPolicyServiceClient.h | 5 | ||||
-rw-r--r-- | include/media/IMediaDeathNotifier.h | 2 | ||||
-rw-r--r-- | include/media/IOMX.h | 4 | ||||
-rw-r--r-- | include/media/mediametadataretriever.h | 2 | ||||
-rw-r--r-- | include/media/stagefright/CameraSource.h | 3 | ||||
-rw-r--r-- | include/media/stagefright/DataSource.h | 61 | ||||
-rw-r--r-- | include/media/stagefright/MPEG4Writer.h | 9 | ||||
-rw-r--r-- | include/media/stagefright/MediaAdapter.h | 4 | ||||
-rw-r--r-- | include/media/stagefright/MediaBuffer.h | 1 | ||||
-rw-r--r-- | include/media/stagefright/MediaSource.h | 1 | ||||
-rw-r--r-- | include/media/stagefright/MetaData.h | 1 | ||||
-rw-r--r-- | include/media/stagefright/OMXCodec.h | 4 |
16 files changed, 165 insertions, 21 deletions
diff --git a/include/media/AudioPolicy.h b/include/media/AudioPolicy.h index 5a82bae..7e33df7 100644 --- a/include/media/AudioPolicy.h +++ b/include/media/AudioPolicy.h @@ -23,6 +23,7 @@ #include <binder/Parcel.h> #include <utils/String8.h> #include <utils/Vector.h> +#include <media/AudioSession.h> namespace android { diff --git a/include/media/AudioSession.h b/include/media/AudioSession.h new file mode 100644 index 0000000..d9658cc --- /dev/null +++ b/include/media/AudioSession.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2016 The CyanogenMod 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_AUDIOSESSION_H +#define ANDROID_AUDIOSESSION_H + +#include <stdint.h> +#include <sys/types.h> + +#include <system/audio.h> + +#include <utils/RefBase.h> +#include <utils/Errors.h> +#include <binder/Parcel.h> + +namespace android { + +// class to store streaminfo +class AudioSessionInfo : public RefBase { +public: + AudioSessionInfo(int session, audio_stream_type_t stream, audio_output_flags_t flags, + audio_channel_mask_t channelMask, uid_t uid) : + mSessionId(session), mStream(stream), mFlags(flags), mChannelMask(channelMask), + mUid(uid), mRefCount(0) {} + + AudioSessionInfo() : mSessionId(0), mStream(AUDIO_STREAM_DEFAULT), mFlags(AUDIO_OUTPUT_FLAG_NONE), mChannelMask(AUDIO_CHANNEL_NONE), mUid(0) {} + + /*virtual*/ ~AudioSessionInfo() {} + + int mSessionId; + audio_stream_type_t mStream; + audio_output_flags_t mFlags; + audio_channel_mask_t mChannelMask; + uid_t mUid; + + // AudioPolicyManager keeps mLock, no need for lock on reference count here + int mRefCount; + + void readFromParcel(const Parcel &parcel) { + mSessionId = parcel.readInt32(); + mStream = static_cast<audio_stream_type_t>(parcel.readInt32()); + mFlags = static_cast<audio_output_flags_t>(parcel.readInt32()); + mChannelMask = static_cast<audio_channel_mask_t>(parcel.readInt32()); + mUid = static_cast<uid_t>(parcel.readInt32()); + } + + void writeToParcel(Parcel *parcel) const { + parcel->writeInt32(mSessionId); + parcel->writeInt32(mStream); + parcel->writeInt32(mFlags); + parcel->writeInt32(mChannelMask); + parcel->writeInt32(mUid); + } +}; + +}; // namespace android + +#endif // ANDROID_AUDIOSESSION_H diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index 35b06ba..3f4a610 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -31,8 +31,8 @@ namespace android { typedef void (*audio_error_callback)(status_t err); typedef void (*dynamic_policy_callback)(int event, String8 regId, int val); -typedef void (*effect_session_callback)(int event, - audio_stream_type_t stream, audio_unique_id_t sessionId, bool added); +typedef void (*audio_session_callback)(int event, + sp<AudioSessionInfo>& session, bool added); class IAudioFlinger; class IAudioPolicyService; @@ -94,7 +94,7 @@ public: static void setErrorCallback(audio_error_callback cb); static void setDynPolicyCallback(dynamic_policy_callback cb); - static status_t setEffectSessionCallback(effect_session_callback cb); + static status_t setAudioSessionCallback(audio_session_callback cb); // helper function to obtain AudioFlinger service handle static const sp<IAudioFlinger> get_audio_flinger(); @@ -322,6 +322,8 @@ public: audio_io_handle_t *handle); static status_t stopAudioSource(audio_io_handle_t handle); + static status_t listAudioSessions(audio_stream_type_t streams, + Vector< sp<AudioSessionInfo>> &sessions); // ---------------------------------------------------------------------------- @@ -422,9 +424,7 @@ private: virtual void onAudioPortListUpdate(); virtual void onAudioPatchListUpdate(); virtual void onDynamicPolicyMixStateUpdate(String8 regId, int32_t state); - virtual void onOutputSessionEffectsUpdate(audio_stream_type_t stream, - audio_unique_id_t sessionId, - bool added); + virtual void onOutputSessionEffectsUpdate(sp<AudioSessionInfo>& info, bool added); private: Mutex mLock; @@ -444,7 +444,7 @@ private: static sp<IAudioFlinger> gAudioFlinger; static audio_error_callback gAudioErrorCallback; static dynamic_policy_callback gDynPolicyCallback; - static effect_session_callback gEffectSessionCallback; + static audio_session_callback gAudioSessionCallback; static size_t gInBuffSize; // previous parameters for recording buffer size queries diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h index 3a7bd68..1df91ee 100644 --- a/include/media/IAudioPolicyService.h +++ b/include/media/IAudioPolicyService.h @@ -166,7 +166,8 @@ public: audio_io_handle_t *handle) = 0; virtual status_t stopAudioSource(audio_io_handle_t handle) = 0; - virtual status_t setEffectSessionCallbacksEnabled(bool enabled) = 0; + virtual status_t listAudioSessions(audio_stream_type_t streams, + Vector< sp<AudioSessionInfo>> &sessions) = 0; }; diff --git a/include/media/IAudioPolicyServiceClient.h b/include/media/IAudioPolicyServiceClient.h index 3bdeb5a..ec38157 100644 --- a/include/media/IAudioPolicyServiceClient.h +++ b/include/media/IAudioPolicyServiceClient.h @@ -21,6 +21,7 @@ #include <utils/RefBase.h> #include <binder/IInterface.h> #include <system/audio.h> +#include <media/AudioSession.h> namespace android { @@ -38,9 +39,7 @@ public: // Notifies a change in the mixing state of a specific mix in a dynamic audio policy virtual void onDynamicPolicyMixStateUpdate(String8 regId, int32_t state) = 0; // Notifies when a default effect set is attached to a session/stream - virtual void onOutputSessionEffectsUpdate(audio_stream_type_t stream, - audio_unique_id_t sessionId, - bool added) = 0; + virtual void onOutputSessionEffectsUpdate(sp<AudioSessionInfo>& info, bool added) = 0; }; diff --git a/include/media/IMediaDeathNotifier.h b/include/media/IMediaDeathNotifier.h index bb3d0d8..aca6678 100644 --- a/include/media/IMediaDeathNotifier.h +++ b/include/media/IMediaDeathNotifier.h @@ -30,7 +30,7 @@ public: virtual ~IMediaDeathNotifier() { removeObitRecipient(this); } virtual void died() = 0; - static const sp<IMediaPlayerService>& getMediaPlayerService(); + static const sp<IMediaPlayerService> getMediaPlayerService(); private: IMediaDeathNotifier &operator=(const IMediaDeathNotifier &); diff --git a/include/media/IOMX.h b/include/media/IOMX.h index 27ad694..83a177a 100644 --- a/include/media/IOMX.h +++ b/include/media/IOMX.h @@ -107,7 +107,7 @@ public: // Use |params| as an OMX buffer, but limit the size of the OMX buffer to |allottedSize|. virtual status_t useBuffer( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, - buffer_id *buffer, OMX_U32 allottedSize) = 0; + buffer_id *buffer, OMX_U32 allottedSize, OMX_BOOL crossProcess = OMX_FALSE) = 0; virtual status_t useGraphicBuffer( node_id node, OMX_U32 port_index, @@ -149,7 +149,7 @@ public: // may be larger. virtual status_t allocateBufferWithBackup( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, - buffer_id *buffer, OMX_U32 allottedSize) = 0; + buffer_id *buffer, OMX_U32 allottedSize, OMX_BOOL crossProcess = OMX_FALSE) = 0; virtual status_t freeBuffer( node_id node, OMX_U32 port_index, buffer_id buffer) = 0; diff --git a/include/media/mediametadataretriever.h b/include/media/mediametadataretriever.h index f655f35..8ed07ee 100644 --- a/include/media/mediametadataretriever.h +++ b/include/media/mediametadataretriever.h @@ -82,7 +82,7 @@ public: const char* extractMetadata(int keyCode); private: - static const sp<IMediaPlayerService>& getService(); + static const sp<IMediaPlayerService> getService(); class DeathNotifier: public IBinder::DeathRecipient { diff --git a/include/media/stagefright/CameraSource.h b/include/media/stagefright/CameraSource.h index 70149cc..3dcfe4e 100644 --- a/include/media/stagefright/CameraSource.h +++ b/include/media/stagefright/CameraSource.h @@ -243,6 +243,9 @@ protected: status_t checkFrameRate(const CameraParameters& params, int32_t frameRate); + static void adjustIncomingANWBuffer(IMemory* data); + static void adjustOutgoingANWBuffer(IMemory* data); + void stopCameraRecording(); status_t reset(); diff --git a/include/media/stagefright/DataSource.h b/include/media/stagefright/DataSource.h index d627fec..c8ad05e 100644 --- a/include/media/stagefright/DataSource.h +++ b/include/media/stagefright/DataSource.h @@ -19,7 +19,7 @@ #define DATA_SOURCE_H_ #include <sys/types.h> - +#include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/MediaErrors.h> #include <utils/Errors.h> #include <utils/KeyedVector.h> @@ -72,6 +72,20 @@ public: bool getUInt32(off64_t offset, uint32_t *x); bool getUInt64(off64_t offset, uint64_t *x); + // Reads in "count" entries of type T into vector *x. + // Returns true if "count" entries can be read. + // If fewer than "count" entries can be read, return false. In this case, + // the output vector *x will still have those entries that were read. Call + // x->size() to obtain the number of entries read. + // The optional parameter chunkSize specifies how many entries should be + // read from the data source at one time into a temporary buffer. Increasing + // chunkSize can improve the performance at the cost of extra memory usage. + // The default value for chunkSize is set to read at least 4k bytes at a + // time, depending on sizeof(T). + template <typename T> + bool getVector(off64_t offset, Vector<T>* x, size_t count, + size_t chunkSize = (4095 / sizeof(T)) + 1); + // May return ERROR_UNSUPPORTED. virtual status_t getSize(off64_t *size); @@ -128,6 +142,51 @@ private: DataSource &operator=(const DataSource &); }; +template <typename T> +bool DataSource::getVector(off64_t offset, Vector<T>* x, size_t count, + size_t chunkSize) +{ + x->clear(); + if (chunkSize == 0) { + return false; + } + if (count == 0) { + return true; + } + + T tmp[chunkSize]; + ssize_t numBytesRead; + size_t numBytesPerChunk = chunkSize * sizeof(T); + size_t i; + + for (i = 0; i + chunkSize < count; i += chunkSize) { + // This loops is executed when more than chunkSize records need to be + // read. + numBytesRead = this->readAt(offset, (void*)&tmp, numBytesPerChunk); + if (numBytesRead == -1) { // If readAt() returns -1, there is an error. + return false; + } + if (numBytesRead < numBytesPerChunk) { + // This case is triggered when the stream ends before the whole + // chunk is read. + x->appendArray(tmp, (size_t)numBytesRead / sizeof(T)); + return false; + } + x->appendArray(tmp, chunkSize); + offset += numBytesPerChunk; + } + + // There are (count - i) more records to read. + // Right now, (count - i) <= chunkSize. + // We do the same thing as above, but with chunkSize replaced by count - i. + numBytesRead = this->readAt(offset, (void*)&tmp, (count - i) * sizeof(T)); + if (numBytesRead == -1) { + return false; + } + x->appendArray(tmp, (size_t)numBytesRead / sizeof(T)); + return x->size() == count; +} + } // namespace android #endif // DATA_SOURCE_H_ diff --git a/include/media/stagefright/MPEG4Writer.h b/include/media/stagefright/MPEG4Writer.h index aeaad8f..09a48f9 100644 --- a/include/media/stagefright/MPEG4Writer.h +++ b/include/media/stagefright/MPEG4Writer.h @@ -77,13 +77,17 @@ private: int mFd; status_t mInitCheck; bool mIsRealTimeRecording; +protected: bool mUse4ByteNalLength; +private: bool mUse32BitOffset; bool mIsFileSizeLimitExplicitlyRequested; bool mPaused; bool mStarted; // Writer thread + track threads started successfully bool mWriterThreadStarted; // Only writer thread started successfully +protected: off64_t mOffset; +private: off_t mMdatOffset; uint8_t *mMoovBoxBuffer; off64_t mMoovBoxBufferOffset; @@ -194,8 +198,11 @@ private: // Acquire lock before calling these methods off64_t addSample_l(MediaBuffer *buffer); - off64_t addLengthPrefixedSample_l(MediaBuffer *buffer); +protected: + static void StripStartcode(MediaBuffer *buffer); + virtual off64_t addLengthPrefixedSample_l(MediaBuffer *buffer); +private: bool exceedsFileSizeLimit(); bool use32BitFileOffset() const; bool exceedsFileDurationLimit(); diff --git a/include/media/stagefright/MediaAdapter.h b/include/media/stagefright/MediaAdapter.h index 369fce6..8622546 100644 --- a/include/media/stagefright/MediaAdapter.h +++ b/include/media/stagefright/MediaAdapter.h @@ -56,6 +56,8 @@ public: // deep copy, such that after pushBuffer return, the buffer can be re-used. status_t pushBuffer(MediaBuffer *buffer); + virtual void notifyError(status_t err); + private: Mutex mAdapterLock; // Make sure the read() wait for the incoming buffer. @@ -68,6 +70,8 @@ private: bool mStarted; sp<MetaData> mOutputFormat; + status_t mStatus; + DISALLOW_EVIL_CONSTRUCTORS(MediaAdapter); }; diff --git a/include/media/stagefright/MediaBuffer.h b/include/media/stagefright/MediaBuffer.h index c8a50e8..5ab266f 100644 --- a/include/media/stagefright/MediaBuffer.h +++ b/include/media/stagefright/MediaBuffer.h @@ -93,6 +93,7 @@ protected: private: friend class MediaBufferGroup; friend class OMXDecoder; + friend class MediaAdapter; // For use by OMXDecoder, reference count must be 1, drop reference // count to 0 without signalling the observer. diff --git a/include/media/stagefright/MediaSource.h b/include/media/stagefright/MediaSource.h index a653db9..7ab5f62 100644 --- a/include/media/stagefright/MediaSource.h +++ b/include/media/stagefright/MediaSource.h @@ -59,6 +59,7 @@ struct MediaSource : public virtual RefBase { virtual status_t read( MediaBuffer **buffer, const ReadOptions *options = NULL) = 0; + virtual void notifyError(status_t) {} // Options that modify read() behaviour. The default is to // a) not request a seek // b) not be late, i.e. lateness_us = 0 diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h index 2a3df22..66e7d63 100644 --- a/include/media/stagefright/MetaData.h +++ b/include/media/stagefright/MetaData.h @@ -68,6 +68,7 @@ enum { kKeyIsSyncFrame = 'sync', // int32_t (bool) kKeyIsCodecConfig = 'conf', // int32_t (bool) kKeyTime = 'time', // int64_t (usecs) + kKeyTimeBoot = 'timb', // int64_t (usecs) kKeyDecodingTime = 'decT', // int64_t (decoding timestamp in usecs) kKeyNTPTime = 'ntpT', // uint64_t (ntp-timestamp) kKeyTargetTime = 'tarT', // int64_t (usecs) diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h index ea534e0..2f73de8 100644 --- a/include/media/stagefright/OMXCodec.h +++ b/include/media/stagefright/OMXCodec.h @@ -40,10 +40,6 @@ struct OMXCodec : public MediaSource, kPreferSoftwareCodecs = 1, kIgnoreCodecSpecificData = 2, - // The client wants to access the output buffer's video - // data for example for thumbnail extraction. - kClientNeedsFramebuffer = 4, - // Request for software or hardware codecs. If request // can not be fullfilled, Create() returns NULL. kSoftwareCodecsOnly = 8, |