diff options
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/AudioPolicy.h | 82 | ||||
-rw-r--r-- | include/media/AudioPolicyHelper.h | 53 | ||||
-rw-r--r-- | include/media/AudioRecord.h | 11 | ||||
-rw-r--r-- | include/media/AudioSystem.h | 37 | ||||
-rw-r--r-- | include/media/AudioTrack.h | 11 | ||||
-rw-r--r-- | include/media/IAudioPolicyService.h | 39 | ||||
-rw-r--r-- | include/media/ICrypto.h | 3 | ||||
-rw-r--r-- | include/media/IDrm.h | 3 | ||||
-rw-r--r-- | include/media/MediaPlayerInterface.h | 11 | ||||
-rw-r--r-- | include/media/stagefright/ACodec.h | 15 | ||||
-rw-r--r-- | include/media/stagefright/MediaCodec.h | 2 | ||||
-rw-r--r-- | include/media/stagefright/MediaCodecList.h | 6 | ||||
-rw-r--r-- | include/media/stagefright/MediaCodecSource.h | 4 | ||||
-rw-r--r-- | include/media/stagefright/MediaDefs.h | 1 | ||||
-rw-r--r-- | include/media/stagefright/SurfaceMediaSource.h | 2 | ||||
-rw-r--r-- | include/media/stagefright/foundation/ADebug.h | 30 | ||||
-rw-r--r-- | include/media/stagefright/foundation/AStringUtils.h | 36 | ||||
-rw-r--r-- | include/media/stagefright/foundation/AUtils.h | 6 | ||||
-rw-r--r-- | include/media/stagefright/foundation/AWakeLock.h | 68 |
19 files changed, 366 insertions, 54 deletions
diff --git a/include/media/AudioPolicy.h b/include/media/AudioPolicy.h new file mode 100644 index 0000000..a755e1e --- /dev/null +++ b/include/media/AudioPolicy.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef ANDROID_AUDIO_POLICY_H +#define ANDROID_AUDIO_POLICY_H + +#include <system/audio.h> +#include <system/audio_policy.h> +#include <binder/Parcel.h> +#include <utils/String8.h> +#include <utils/Vector.h> + +namespace android { + +// Keep in sync with AudioMix.java, AudioMixingRule.java, AudioPolicyConfig.java +#define RULE_EXCLUSION_MASK 0x8000 +#define RULE_MATCH_ATTRIBUTE_USAGE 0x1 +#define RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET (0x1 << 1) +#define RULE_EXCLUDE_ATTRIBUTE_USAGE (RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_USAGE) +#define RULE_EXCLUDE_ATTRIBUTE_CAPTURE_PRESET \ + (RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET) + +#define MIX_TYPE_INVALID -1 +#define MIX_TYPE_PLAYERS 0 +#define MIX_TYPE_RECORDERS 1 + +#define ROUTE_FLAG_RENDER 0x1 +#define ROUTE_FLAG_LOOP_BACK (0x1 << 1) + +#define MAX_MIXES_PER_POLICY 10 +#define MAX_CRITERIA_PER_MIX 20 + +class AttributeMatchCriterion { +public: + AttributeMatchCriterion() {} + AttributeMatchCriterion(audio_usage_t usage, audio_source_t source, uint32_t rule); + + status_t readFromParcel(Parcel *parcel); + status_t writeToParcel(Parcel *parcel) const; + + union { + audio_usage_t mUsage; + audio_source_t mSource; + } mAttr; + uint32_t mRule; +}; + +class AudioMix { +public: + AudioMix() {} + AudioMix(Vector<AttributeMatchCriterion> criteria, uint32_t mixType, audio_config_t format, + uint32_t routeFlags, String8 registrationId) : + mCriteria(criteria), mMixType(mixType), mFormat(format), + mRouteFlags(routeFlags), mRegistrationId(registrationId) {} + + status_t readFromParcel(Parcel *parcel); + status_t writeToParcel(Parcel *parcel) const; + + Vector<AttributeMatchCriterion> mCriteria; + uint32_t mMixType; + audio_config_t mFormat; + uint32_t mRouteFlags; + String8 mRegistrationId; +}; + +}; // namespace android + +#endif // ANDROID_AUDIO_POLICY_H diff --git a/include/media/AudioPolicyHelper.h b/include/media/AudioPolicyHelper.h index f4afd45..79231be 100644 --- a/include/media/AudioPolicyHelper.h +++ b/include/media/AudioPolicyHelper.h @@ -18,7 +18,7 @@ #include <system/audio.h> -audio_stream_type_t audio_attributes_to_stream_type(const audio_attributes_t *attr) +static audio_stream_type_t audio_attributes_to_stream_type(const audio_attributes_t *attr) { // flags to stream type mapping if ((attr->flags & AUDIO_FLAG_AUDIBILITY_ENFORCED) == AUDIO_FLAG_AUDIBILITY_ENFORCED) { @@ -61,4 +61,55 @@ audio_stream_type_t audio_attributes_to_stream_type(const audio_attributes_t *at } } +static void stream_type_to_audio_attributes(audio_stream_type_t streamType, + audio_attributes_t *attr) { + memset(attr, 0, sizeof(audio_attributes_t)); + + switch (streamType) { + case AUDIO_STREAM_DEFAULT: + case AUDIO_STREAM_MUSIC: + attr->content_type = AUDIO_CONTENT_TYPE_MUSIC; + attr->usage = AUDIO_USAGE_MEDIA; + break; + case AUDIO_STREAM_VOICE_CALL: + attr->content_type = AUDIO_CONTENT_TYPE_SPEECH; + attr->usage = AUDIO_USAGE_VOICE_COMMUNICATION; + break; + case AUDIO_STREAM_ENFORCED_AUDIBLE: + attr->flags |= AUDIO_FLAG_AUDIBILITY_ENFORCED; + // intended fall through, attributes in common with STREAM_SYSTEM + case AUDIO_STREAM_SYSTEM: + attr->content_type = AUDIO_CONTENT_TYPE_SONIFICATION; + attr->usage = AUDIO_USAGE_ASSISTANCE_SONIFICATION; + break; + case AUDIO_STREAM_RING: + attr->content_type = AUDIO_CONTENT_TYPE_SONIFICATION; + attr->usage = AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE; + break; + case AUDIO_STREAM_ALARM: + attr->content_type = AUDIO_CONTENT_TYPE_SONIFICATION; + attr->usage = AUDIO_USAGE_ALARM; + break; + case AUDIO_STREAM_NOTIFICATION: + attr->content_type = AUDIO_CONTENT_TYPE_SONIFICATION; + attr->usage = AUDIO_USAGE_NOTIFICATION; + break; + case AUDIO_STREAM_BLUETOOTH_SCO: + attr->content_type = AUDIO_CONTENT_TYPE_SPEECH; + attr->usage = AUDIO_USAGE_VOICE_COMMUNICATION; + attr->flags |= AUDIO_FLAG_SCO; + break; + case AUDIO_STREAM_DTMF: + attr->content_type = AUDIO_CONTENT_TYPE_SONIFICATION; + attr->usage = AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING; + break; + case AUDIO_STREAM_TTS: + attr->content_type = AUDIO_CONTENT_TYPE_SPEECH; + attr->usage = AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY; + break; + default: + ALOGE("invalid stream type %d when converting to attributes", streamType); + } +} + #endif //AUDIO_POLICY_HELPER_H_ diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h index 4edc1bf..f70d981 100644 --- a/include/media/AudioRecord.h +++ b/include/media/AudioRecord.h @@ -152,6 +152,7 @@ public: * transferType: How data is transferred from AudioRecord. * flags: See comments on audio_input_flags_t in <system/audio.h> * threadCanCallJava: Not present in parameter list, and so is fixed at false. + * pAttributes: if not NULL, supersedes inputSource for use case selection */ AudioRecord(audio_source_t inputSource, @@ -164,7 +165,8 @@ public: uint32_t notificationFrames = 0, int sessionId = AUDIO_SESSION_ALLOCATE, transfer_type transferType = TRANSFER_DEFAULT, - audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE); + audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE, + const audio_attributes_t* pAttributes = NULL); /* Terminates the AudioRecord and unregisters it from AudioFlinger. * Also destroys all resources associated with the AudioRecord. @@ -198,7 +200,8 @@ public: bool threadCanCallJava = false, int sessionId = AUDIO_SESSION_ALLOCATE, transfer_type transferType = TRANSFER_DEFAULT, - audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE); + audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE, + const audio_attributes_t* pAttributes = NULL); /* Result of constructing the AudioRecord. This must be checked for successful initialization * before using any AudioRecord API (except for set()), because using @@ -219,7 +222,7 @@ public: uint32_t channelCount() const { return mChannelCount; } size_t frameCount() const { return mFrameCount; } size_t frameSize() const { return mFrameSize; } - audio_source_t inputSource() const { return mInputSource; } + audio_source_t inputSource() const { return mAttributes.source; } /* After it's created the track is not active. Call start() to * make it active. If set, the callback will start being called. @@ -489,7 +492,6 @@ private: audio_format_t mFormat; uint32_t mChannelCount; size_t mFrameSize; // app-level frame size == AudioFlinger frame size - audio_source_t mInputSource; uint32_t mLatency; // in ms audio_channel_mask_t mChannelMask; audio_input_flags_t mFlags; @@ -529,6 +531,7 @@ private: sp<DeathNotifier> mDeathNotifier; uint32_t mSequence; // incremented for each new IAudioRecord attempt + audio_attributes_t mAttributes; }; }; // namespace android diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index f8c0198..843a354 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -18,6 +18,7 @@ #define ANDROID_AUDIOSYSTEM_H_ #include <hardware/audio_effect.h> +#include <media/AudioPolicy.h> #include <media/IAudioFlingerClient.h> #include <media/IAudioPolicyServiceClient.h> #include <system/audio.h> @@ -90,7 +91,7 @@ public: static void setErrorCallback(audio_error_callback cb); // helper function to obtain AudioFlinger service handle - static const sp<IAudioFlinger>& get_audio_flinger(); + static const sp<IAudioFlinger> get_audio_flinger(); static float linearToLog(int volume); static int logToLinear(float volume); @@ -99,8 +100,6 @@ public: // to be non-zero if status == NO_ERROR static status_t getOutputSamplingRate(uint32_t* samplingRate, audio_stream_type_t stream); - static status_t getOutputSamplingRateForAttr(uint32_t* samplingRate, - const audio_attributes_t *attr); static status_t getOutputFrameCount(size_t* frameCount, audio_stream_type_t stream); static status_t getOutputLatency(uint32_t* latency, @@ -116,8 +115,6 @@ public: static status_t getLatency(audio_io_handle_t output, uint32_t* latency); - static bool routedToA2dpOutput(audio_stream_type_t streamType); - // return status NO_ERROR implies *buffSize > 0 static status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, audio_channel_mask_t channelMask, size_t* buffSize); @@ -219,7 +216,10 @@ public: audio_channel_mask_t channelMask = AUDIO_CHANNEL_OUT_STEREO, audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, const audio_offload_info_t *offloadInfo = NULL); - static audio_io_handle_t getOutputForAttr(const audio_attributes_t *attr, + static status_t getOutputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *output, + audio_session_t session, + audio_stream_type_t *stream, uint32_t samplingRate = 0, audio_format_t format = AUDIO_FORMAT_DEFAULT, audio_channel_mask_t channelMask = AUDIO_CHANNEL_OUT_STEREO, @@ -227,20 +227,23 @@ public: const audio_offload_info_t *offloadInfo = NULL); static status_t startOutput(audio_io_handle_t output, audio_stream_type_t stream, - int session); + audio_session_t session); static status_t stopOutput(audio_io_handle_t output, audio_stream_type_t stream, - int session); - static void releaseOutput(audio_io_handle_t output); + audio_session_t session); + static void releaseOutput(audio_io_handle_t output, + audio_stream_type_t stream, + audio_session_t session); // Client must successfully hand off the handle reference to AudioFlinger via openRecord(), // or release it with releaseInput(). - static audio_io_handle_t getInput(audio_source_t inputSource, + static status_t getInputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *input, + audio_session_t session, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, - int sessionId, - audio_input_flags_t); + audio_input_flags_t flags); static status_t startInput(audio_io_handle_t input, audio_session_t session); @@ -274,7 +277,7 @@ public: // and output configuration cache (gOutputs) static void clearAudioConfigCache(); - static const sp<IAudioPolicyService>& get_audio_policy_service(); + static const sp<IAudioPolicyService> get_audio_policy_service(); // helpers for android.media.AudioManager.getProperty(), see description there for meaning static uint32_t getPrimaryOutputSamplingRate(); @@ -322,6 +325,8 @@ public: static audio_mode_t getPhoneState(); + static status_t registerPolicyMixes(Vector<AudioMix> mixes, bool registration); + // ---------------------------------------------------------------------------- class AudioPortCallback : public RefBase @@ -377,7 +382,11 @@ private: friend class AudioFlingerClient; friend class AudioPolicyServiceClient; - static Mutex gLock; + static Mutex gLock; // protects gAudioFlinger and gAudioErrorCallback, + static Mutex gLockCache; // protects gOutputs, gPrevInSamplingRate, gPrevInFormat, + // gPrevInChannelMask and gInBuffSize + static Mutex gLockAPS; // protects gAudioPolicyService and gAudioPolicyServiceClient + static Mutex gLockAPC; // protects gAudioPortCallback static sp<IAudioFlinger> gAudioFlinger; static audio_error_callback gAudioErrorCallback; diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h index b5256f0..fd51b8f 100644 --- a/include/media/AudioTrack.h +++ b/include/media/AudioTrack.h @@ -239,6 +239,9 @@ public: * Parameters not listed in the AudioTrack constructors above: * * threadCanCallJava: Whether callbacks are made from an attached thread and thus can call JNI. + * + * Internal state post condition: + * (mStreamType == AUDIO_STREAM_DEFAULT) implies this AudioTrack has valid attributes */ status_t set(audio_stream_type_t streamType, uint32_t sampleRate, @@ -273,7 +276,7 @@ public: /* getters, see constructors and set() */ - audio_stream_type_t streamType() const { return mStreamType; } + audio_stream_type_t streamType() const; audio_format_t format() const { return mFormat; } /* Return frame size in bytes, which for linear PCM is @@ -598,9 +601,6 @@ protected: AudioTrack& operator = (const AudioTrack& other); void setAttributesFromStreamType(audio_stream_type_t streamType); - void setStreamTypeFromAttributes(audio_attributes_t& aa); - /* paa is guaranteed non-NULL */ - bool isValidAttributes(const audio_attributes_t *paa); /* a small internal class to handle the callback */ class AudioTrackThread : public Thread @@ -688,7 +688,8 @@ protected: // constant after constructor or set() audio_format_t mFormat; // as requested by client, not forced to 16-bit - audio_stream_type_t mStreamType; + audio_stream_type_t mStreamType; // mStreamType == AUDIO_STREAM_DEFAULT implies + // this AudioTrack has valid attributes uint32_t mChannelCount; audio_channel_mask_t mChannelMask; sp<IMemory> mSharedBuffer; diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h index 16fe9cf..c98c475 100644 --- a/include/media/IAudioPolicyService.h +++ b/include/media/IAudioPolicyService.h @@ -25,6 +25,7 @@ #include <utils/Errors.h> #include <binder/IInterface.h> #include <media/AudioSystem.h> +#include <media/AudioPolicy.h> #include <media/IAudioPolicyServiceClient.h> #include <system/audio_policy.h> @@ -56,25 +57,31 @@ public: audio_channel_mask_t channelMask = 0, audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, const audio_offload_info_t *offloadInfo = NULL) = 0; - virtual audio_io_handle_t getOutputForAttr(const audio_attributes_t *attr, - uint32_t samplingRate = 0, - audio_format_t format = AUDIO_FORMAT_DEFAULT, - audio_channel_mask_t channelMask = 0, - audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, - const audio_offload_info_t *offloadInfo = NULL) = 0; + virtual status_t getOutputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *output, + audio_session_t session, + audio_stream_type_t *stream, + uint32_t samplingRate = 0, + audio_format_t format = AUDIO_FORMAT_DEFAULT, + audio_channel_mask_t channelMask = 0, + audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, + const audio_offload_info_t *offloadInfo = NULL) = 0; virtual status_t startOutput(audio_io_handle_t output, audio_stream_type_t stream, - int session = 0) = 0; + audio_session_t session) = 0; virtual status_t stopOutput(audio_io_handle_t output, audio_stream_type_t stream, - int session = 0) = 0; - virtual void releaseOutput(audio_io_handle_t output) = 0; - virtual audio_io_handle_t getInput(audio_source_t inputSource, - uint32_t samplingRate, - audio_format_t format, - audio_channel_mask_t channelMask, - int audioSession, - audio_input_flags_t flags) = 0; + audio_session_t session) = 0; + virtual void releaseOutput(audio_io_handle_t output, + audio_stream_type_t stream, + audio_session_t session) = 0; + virtual status_t getInputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *input, + audio_session_t session, + uint32_t samplingRate, + audio_format_t format, + audio_channel_mask_t channelMask, + audio_input_flags_t flags) = 0; virtual status_t startInput(audio_io_handle_t input, audio_session_t session) = 0; virtual status_t stopInput(audio_io_handle_t input, @@ -144,6 +151,8 @@ public: virtual status_t releaseSoundTriggerSession(audio_session_t session) = 0; virtual audio_mode_t getPhoneState() = 0; + + virtual status_t registerPolicyMixes(Vector<AudioMix> mixes, bool registration) = 0; }; diff --git a/include/media/ICrypto.h b/include/media/ICrypto.h index 9dcb8d9..07742ca 100644 --- a/include/media/ICrypto.h +++ b/include/media/ICrypto.h @@ -41,6 +41,8 @@ struct ICrypto : public IInterface { virtual bool requiresSecureDecoderComponent( const char *mime) const = 0; + virtual void notifyResolution(uint32_t width, uint32_t height) = 0; + virtual ssize_t decrypt( bool secure, const uint8_t key[16], @@ -64,4 +66,3 @@ struct BnCrypto : public BnInterface<ICrypto> { } // namespace android #endif // ANDROID_ICRYPTO_H_ - diff --git a/include/media/IDrm.h b/include/media/IDrm.h index 68de87a..affcbd7 100644 --- a/include/media/IDrm.h +++ b/include/media/IDrm.h @@ -73,8 +73,10 @@ struct IDrm : public IInterface { virtual status_t unprovisionDevice() = 0; virtual status_t getSecureStops(List<Vector<uint8_t> > &secureStops) = 0; + virtual status_t getSecureStop(Vector<uint8_t> const &ssid, Vector<uint8_t> &secureStop) = 0; virtual status_t releaseSecureStops(Vector<uint8_t> const &ssRelease) = 0; + virtual status_t releaseAllSecureStops() = 0; virtual status_t getPropertyString(String8 const &name, String8 &value) const = 0; virtual status_t getPropertyByteArray(String8 const &name, @@ -137,4 +139,3 @@ private: } // namespace android #endif // ANDROID_IDRM_H_ - diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h index cf18a45..c412299 100644 --- a/include/media/MediaPlayerInterface.h +++ b/include/media/MediaPlayerInterface.h @@ -208,8 +208,15 @@ public: void sendEvent(int msg, int ext1=0, int ext2=0, const Parcel *obj=NULL) { - Mutex::Autolock autoLock(mNotifyLock); - if (mNotify) mNotify(mCookie, msg, ext1, ext2, obj); + notify_callback_f notifyCB; + void* cookie; + { + Mutex::Autolock autoLock(mNotifyLock); + notifyCB = mNotify; + cookie = mCookie; + } + + if (notifyCB) notifyCB(cookie, msg, ext1, ext2, obj); } virtual status_t dump(int fd, const Vector<String16> &args) const { diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index fcccc6d..595ace8 100644 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -78,7 +78,7 @@ struct ACodec : public AHierarchicalStateMachine, public CodecBase { static bool isFlexibleColorFormat( const sp<IOMX> &omx, IOMX::node_id node, - uint32_t colorFormat, OMX_U32 *flexibleEquivalent); + uint32_t colorFormat, bool usingNativeBuffers, OMX_U32 *flexibleEquivalent); // Returns 0 if configuration is not supported. NOTE: this is treated by // some OMX components as auto level, and by others as invalid level. @@ -131,6 +131,7 @@ private: enum { kFlagIsSecure = 1, kFlagPushBlankBuffersToNativeWindowOnShutdown = 2, + kFlagIsGrallocUsageProtected = 4, }; struct BufferInfo { @@ -182,6 +183,7 @@ private: sp<ANativeWindow> mNativeWindow; sp<AMessage> mInputFormat; sp<AMessage> mOutputFormat; + sp<AMessage> mBaseOutputFormat; Vector<BufferInfo> mBuffers[2]; bool mPortEOS[2]; @@ -249,12 +251,13 @@ private: status_t setVideoPortFormatType( OMX_U32 portIndex, OMX_VIDEO_CODINGTYPE compressionFormat, - OMX_COLOR_FORMATTYPE colorFormat); + OMX_COLOR_FORMATTYPE colorFormat, + bool usingNativeBuffers = false); - status_t setSupportedOutputFormat(); + status_t setSupportedOutputFormat(bool getLegacyFlexibleFormat); status_t setupVideoDecoder( - const char *mime, const sp<AMessage> &msg); + const char *mime, const sp<AMessage> &msg, bool usingNativeBuffers); status_t setupVideoEncoder( const char *mime, const sp<AMessage> &msg); @@ -262,7 +265,7 @@ private: status_t setVideoFormatOnPort( OMX_U32 portIndex, int32_t width, int32_t height, - OMX_VIDEO_CODINGTYPE compressionFormat); + OMX_VIDEO_CODINGTYPE compressionFormat, float frameRate = -1.0); typedef struct drcParams { int32_t drcCut; @@ -281,6 +284,8 @@ private: status_t setupAC3Codec(bool encoder, int32_t numChannels, int32_t sampleRate); + status_t setupEAC3Codec(bool encoder, int32_t numChannels, int32_t sampleRate); + status_t selectAudioPortFormat( OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE desiredFormat); diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h index 54a4e8b..d448097 100644 --- a/include/media/stagefright/MediaCodec.h +++ b/include/media/stagefright/MediaCodec.h @@ -194,7 +194,7 @@ private: }; enum { - kFlagIsSoftwareCodec = 1, + kFlagUsesSoftwareRenderer = 1, kFlagOutputFormatChanged = 2, kFlagOutputBuffersChanged = 4, kFlagStickyError = 8, diff --git a/include/media/stagefright/MediaCodecList.h b/include/media/stagefright/MediaCodecList.h index 8605d99..c2bbe4d 100644 --- a/include/media/stagefright/MediaCodecList.h +++ b/include/media/stagefright/MediaCodecList.h @@ -52,6 +52,12 @@ struct MediaCodecList : public BnMediaCodecList { static sp<IMediaCodecList> getLocalInstance(); private: + class BinderDeathObserver : public IBinder::DeathRecipient { + void binderDied(const wp<IBinder> &the_late_who __unused); + }; + + static sp<BinderDeathObserver> sBinderDeathObserver; + enum Section { SECTION_TOPLEVEL, SECTION_DECODERS, diff --git a/include/media/stagefright/MediaCodecSource.h b/include/media/stagefright/MediaCodecSource.h index 3629c8b..0970b2b 100644 --- a/include/media/stagefright/MediaCodecSource.h +++ b/include/media/stagefright/MediaCodecSource.h @@ -85,8 +85,6 @@ private: status_t initEncoder(); void releaseEncoder(); status_t feedEncoderInputBuffers(); - void scheduleDoMoreWork(); - status_t doMoreWork(int32_t numInput, int32_t numOutput); void suspend(); void resume(int64_t skipFramesBeforeUs = -1ll); void signalEOS(status_t err = ERROR_END_OF_STREAM); @@ -108,8 +106,6 @@ private: bool mDoMoreWorkPending; sp<AMessage> mEncoderActivityNotify; sp<IGraphicBufferProducer> mGraphicBufferProducer; - Vector<sp<ABuffer> > mEncoderInputBuffers; - Vector<sp<ABuffer> > mEncoderOutputBuffers; List<MediaBuffer *> mInputBufferQueue; List<size_t> mAvailEncoderInputIndices; List<int64_t> mDecodingTimeQueue; // decoding time (us) for video diff --git a/include/media/stagefright/MediaDefs.h b/include/media/stagefright/MediaDefs.h index e67d4d5..13695d5 100644 --- a/include/media/stagefright/MediaDefs.h +++ b/include/media/stagefright/MediaDefs.h @@ -47,6 +47,7 @@ extern const char *MEDIA_MIMETYPE_AUDIO_FLAC; extern const char *MEDIA_MIMETYPE_AUDIO_AAC_ADTS; extern const char *MEDIA_MIMETYPE_AUDIO_MSGSM; extern const char *MEDIA_MIMETYPE_AUDIO_AC3; +extern const char *MEDIA_MIMETYPE_AUDIO_EAC3; extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG4; extern const char *MEDIA_MIMETYPE_CONTAINER_WAV; diff --git a/include/media/stagefright/SurfaceMediaSource.h b/include/media/stagefright/SurfaceMediaSource.h index 43b75fd..d15a226 100644 --- a/include/media/stagefright/SurfaceMediaSource.h +++ b/include/media/stagefright/SurfaceMediaSource.h @@ -124,7 +124,7 @@ protected: // Implementation of the BufferQueue::ConsumerListener interface. These // calls are used to notify the Surface of asynchronous events in the // BufferQueue. - virtual void onFrameAvailable(); + virtual void onFrameAvailable(const BufferItem& item); // Used as a hook to BufferQueue::disconnect() // This is called by the client side when it is done diff --git a/include/media/stagefright/foundation/ADebug.h b/include/media/stagefright/foundation/ADebug.h index 450dcfe..1d0e2cb 100644 --- a/include/media/stagefright/foundation/ADebug.h +++ b/include/media/stagefright/foundation/ADebug.h @@ -80,6 +80,36 @@ MAKE_COMPARATOR(GT,>) __FILE__ ":" LITERAL_TO_STRING(__LINE__) \ " Should not be here."); +struct ADebug { + enum Level { + kDebugNone, // no debug + kDebugLifeCycle, // lifecycle events: creation/deletion + kDebugState, // commands and events + kDebugConfig, // configuration + kDebugInternalState, // internal state changes + kDebugAll, // all + kDebugMax = kDebugAll, + + }; + + // parse the property or string to get the debug level for a component name + // string format is: + // <level>[:<glob>][,<level>[:<glob>]...] + // - <level> is 0-5 corresponding to ADebug::Level + // - <glob> is used to match component name case insensitively, if omitted, it + // matches all components + // - string is read left-to-right, and the last matching level is returned, or + // the def if no terms matched + static Level GetDebugLevelFromProperty( + const char *name, const char *propertyName, Level def = kDebugNone); + static Level GetDebugLevelFromString( + const char *name, const char *value, Level def = kDebugNone); + + // remove redundant segments of a codec name, and return a newly allocated + // string suitable for debugging + static char *GetDebugName(const char *name); +}; + } // namespace android #endif // A_DEBUG_H_ diff --git a/include/media/stagefright/foundation/AStringUtils.h b/include/media/stagefright/foundation/AStringUtils.h new file mode 100644 index 0000000..76a7791 --- /dev/null +++ b/include/media/stagefright/foundation/AStringUtils.h @@ -0,0 +1,36 @@ +/* + * Copyright 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef A_STRING_UTILS_H_ +#define A_STRING_UTILS_H_ + +#include <stdlib.h> + +namespace android { + +struct AStringUtils { + // similar to strncmp or strcasecmp, but case sensitivity is parametric + static int Compare(const char *a, const char *b, size_t len, bool ignoreCase); + + // matches a string (str) to a glob pattern that supports: + // * - matches any number of characters + static bool MatchesGlob( + const char *glob, size_t globLen, const char *str, size_t strLen, bool ignoreCase); +}; + +} // namespace android + +#endif // A_STRING_UTILS_H_ diff --git a/include/media/stagefright/foundation/AUtils.h b/include/media/stagefright/foundation/AUtils.h index 255bcbe..47444c1 100644 --- a/include/media/stagefright/foundation/AUtils.h +++ b/include/media/stagefright/foundation/AUtils.h @@ -40,6 +40,12 @@ inline static const T divUp(const T &nom, const T &den) { } } +/* == ceil(nom / den) * den. T must be integer type, alignment must be positive power of 2 */ +template<class T, class U> +inline static const T align(const T &nom, const U &den) { + return (nom + (T)(den - 1)) & (T)~(den - 1); +} + template<class T> inline static T abs(const T &a) { return a < 0 ? -a : a; diff --git a/include/media/stagefright/foundation/AWakeLock.h b/include/media/stagefright/foundation/AWakeLock.h new file mode 100644 index 0000000..57716c1 --- /dev/null +++ b/include/media/stagefright/foundation/AWakeLock.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef A_WAKELOCK_H_ +#define A_WAKELOCK_H_ + +#include <media/stagefright/foundation/ABase.h> +#include <powermanager/IPowerManager.h> +#include <utils/RefBase.h> + +namespace android { + +class AWakeLock : public RefBase { + +public: + AWakeLock(); + + // NOTE: acquire and release are not thread safe + + // returns true if wakelock was acquired + bool acquire(); + void release(bool force = false); + + virtual ~AWakeLock(); + +private: + sp<IPowerManager> mPowerManager; + sp<IBinder> mWakeLockToken; + uint32_t mWakeLockCount; + + class PMDeathRecipient : public IBinder::DeathRecipient { + public: + PMDeathRecipient(AWakeLock *wakeLock) : mWakeLock(wakeLock) {} + virtual ~PMDeathRecipient() {} + + // IBinder::DeathRecipient + virtual void binderDied(const wp<IBinder> &who); + + private: + PMDeathRecipient(const PMDeathRecipient&); + PMDeathRecipient& operator= (const PMDeathRecipient&); + + AWakeLock *mWakeLock; + }; + + const sp<PMDeathRecipient> mDeathRecipient; + + void clearPowerManager(); + + DISALLOW_EVIL_CONSTRUCTORS(AWakeLock); +}; + +} // namespace android + +#endif // A_WAKELOCK_H_ |