| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Overload this file in your device specific config if you need | ||
| // to add extra camera parameters. | ||
| // A typical file would look like this: | ||
| /* | ||
| * Copyright (C) 2014 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. | ||
| */ | ||
| /* | ||
| #define CAMERA_PARAMETERS_EXTRA_C \ | ||
| const char CameraParameters::KEY_SUPPORTED_BURST_NUM[] = "supported-burst-num"; \ | ||
| const char CameraParameters::KEY_BURST_NUM[] = "burst-num"; \ | ||
| const char CameraParameters::KEY_SUPPORTED_HDR_MODES[] = "supported-hdr-modes"; \ | ||
| const char CameraParameters::KEY_HDR_MODE[] = "hdr-mode"; \ | ||
| const char CameraParameters::HDR_MODE_OFF[] = "hdr-mode-off"; \ | ||
| const char CameraParameters::HDR_MODE_HDR[] = "hdr-mode-hdr"; | ||
| #define CAMERA_PARAMETERS_EXTRA_H \ | ||
| static const char KEY_SUPPORTED_BURST_NUM[]; \ | ||
| static const char KEY_BURST_NUM[]; \ | ||
| static const char KEY_SUPPORTED_HDR_MODES[]; \ | ||
| static const char KEY_HDR_MODE[]; \ | ||
| static const char HDR_MODE_OFF[]; \ | ||
| static const char HDR_MODE_HDR[]; | ||
| */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /* | ||
| * Copyright (c) 2012, The Linux Foundation. All rights reserved. | ||
| * Not a Contribution. | ||
| * | ||
| * Copyright (C) 2007 The Android Open Source Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #ifndef ANDROID_IDIRECTTRACK_H | ||
| #define ANDROID_IDIRECTTRACK_H | ||
|
|
||
| #include <stdint.h> | ||
| #include <sys/types.h> | ||
|
|
||
| #include <utils/RefBase.h> | ||
| #include <utils/Errors.h> | ||
| #include <binder/IInterface.h> | ||
| #include <binder/IMemory.h> | ||
|
|
||
|
|
||
| namespace android { | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| class IDirectTrack : public IInterface | ||
| { | ||
| public: | ||
| DECLARE_META_INTERFACE(DirectTrack); | ||
|
|
||
| /* After it's created the track is not active. Call start() to | ||
| * make it active. If set, the callback will start being called. | ||
| */ | ||
| virtual status_t start() = 0; | ||
|
|
||
| /* Stop a track. If set, the callback will cease being called and | ||
| * obtainBuffer will return an error. Buffers that are already released | ||
| * will be processed, unless flush() is called. | ||
| */ | ||
| virtual void stop() = 0; | ||
|
|
||
| /* flush a stopped track. All pending buffers are discarded. | ||
| * This function has no effect if the track is not stoped. | ||
| */ | ||
| virtual void flush() = 0; | ||
|
|
||
| /* mute or unmutes this track. | ||
| * While mutted, the callback, if set, is still called. | ||
| */ | ||
| virtual void mute(bool) = 0; | ||
|
|
||
| /* Pause a track. If set, the callback will cease being called and | ||
| * obtainBuffer will return an error. Buffers that are already released | ||
| * will be processed, unless flush() is called. | ||
| */ | ||
| virtual void pause() = 0; | ||
|
|
||
| /* set volume for both left and right channels. | ||
| */ | ||
| virtual void setVolume(float l, float r) = 0; | ||
|
|
||
| virtual ssize_t write(const void*, size_t) = 0; | ||
|
|
||
| virtual int64_t getTimeStamp() = 0; | ||
| }; | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| class BnDirectTrack : public BnInterface<IDirectTrack> | ||
| { | ||
| public: | ||
| virtual status_t onTransact( uint32_t code, | ||
| const Parcel& data, | ||
| Parcel* reply, | ||
| uint32_t flags = 0); | ||
| }; | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| }; // namespace android | ||
|
|
||
| #endif // ANDROID_IAUDIOTRACK_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Copyright (c) 2012, The Linux Foundation. All rights reserved. | ||
| * Not a Contribution. | ||
| * | ||
| * Copyright (C) 2007 The Android Open Source Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #ifndef ANDROID_IDIRECTTRACKCLIENT_H | ||
| #define ANDROID_IDIRECTTRACKCLIENT_H | ||
|
|
||
| #include <utils/RefBase.h> | ||
| #include <binder/IInterface.h> | ||
| #include <binder/Parcel.h> | ||
|
|
||
| namespace android { | ||
|
|
||
| class IDirectTrackClient: public IInterface | ||
| { | ||
| public: | ||
| DECLARE_META_INTERFACE(DirectTrackClient); | ||
|
|
||
| virtual void notify(int msg) = 0; | ||
| }; | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| class BnDirectTrackClient: public BnInterface<IDirectTrackClient> | ||
| { | ||
| public: | ||
| virtual status_t onTransact( uint32_t code, | ||
| const Parcel& data, | ||
| Parcel* reply, | ||
| uint32_t flags = 0); | ||
| }; | ||
|
|
||
| }; // namespace android | ||
|
|
||
| #endif // ANDROID_IDIRECTTRACKCLIENT_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,292 @@ | ||
| /* Copyright (c) 2013 - 2014, The Linux Foundation. All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are | ||
| * met: | ||
| * * Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * * Redistributions in binary form must reproduce the above | ||
| * copyright notice, this list of conditions and the following | ||
| * disclaimer in the documentation and/or other materials provided | ||
| * with the distribution. | ||
| * * Neither the name of The Linux Foundation nor the names of its | ||
| * contributors may be used to endorse or promote products derived | ||
| * from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED | ||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS | ||
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
| * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
| * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
| * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | ||
| * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
| #ifndef EXTENDED_STATS_H_ | ||
| #define EXTENDED_STATS_H_ | ||
|
|
||
| #include <inttypes.h> | ||
| #include <media/stagefright/foundation/AString.h> | ||
| #include <utils/KeyedVector.h> | ||
| #include <utils/Mutex.h> | ||
| #include <utils/RefBase.h> | ||
| #include <utils/StrongPointer.h> | ||
|
|
||
| #define MEDIA_EXTENDED_STATS "MediaExtendedStats" | ||
|
|
||
| #define STATS_PROFILE_START_LATENCY "Total startup latency" | ||
| #define STATS_PROFILE_ALLOCATE_NODE(isVideo) (isVideo != 0 ? "\tAllocate node (video)" : "\tAllocate node (audio)") | ||
| #define STATS_PROFILE_ALLOCATE_INPUT(isVideo) (isVideo != 0 ? "\tAllocate input buffer (video)" : "\tAllocate input buffer (audio)") | ||
| #define STATS_PROFILE_ALLOCATE_OUTPUT(isVideo) (isVideo != 0 ? "\tAllocate output buffer (video)" : "\tAllocate output buffer (audio)") | ||
| #define STATS_PROFILE_CONFIGURE_CODEC(isVideo) (isVideo != 0 ? "\tConfigure codec (video)" : "\tConfigure codec (audio)") | ||
| #define STATS_PROFILE_FIRST_BUFFER(isVideo) (isVideo != 0 ? "Time to process first buffer (video)" : "Time to process first buffer (audio)") | ||
| #define STATS_PROFILE_PREPARE "Prepare" | ||
| #define STATS_PROFILE_SET_DATA_SOURCE "Set data source" | ||
| #define STATS_PROFILE_PAUSE "Pause" | ||
| #define STATS_PROFILE_SEEK "Seek" | ||
| #define STATS_PROFILE_RESUME "Resume" | ||
|
|
||
| #define STATS_PROFILE_SET_CAMERA_SOURCE "Set camera source" | ||
| #define STATS_PROFILE_SET_ENCODER(isVideo) (isVideo != 0 ? "Set video encoder" : "Set audio encoder") | ||
| #define STATS_PROFILE_STOP "Stop" | ||
| #define STATS_BITRATE "Video Bitrate" | ||
| #define STATS_PROFILE_SF_RECORDER_START_LATENCY "\tStagefrightRecorder start latency" | ||
| #define STATS_PROFILE_CAMERA_SOURCE_START_LATENCY "\tCamera source start latency" | ||
| #define STATS_PROFILE_RECONFIGURE "\tReconfigure latency" | ||
|
|
||
| namespace android { | ||
|
|
||
| /* | ||
| * This class provides support for profiling events and dumping aggregate | ||
| * statistics. It may be used to profile latencies at startup, seek, resume | ||
| * and to report dropped frames etc. | ||
| */ | ||
| typedef int64_t statsDataType; | ||
| class MediaExtendedStats; | ||
|
|
||
| class ExtendedStats : public RefBase { | ||
|
|
||
| public: | ||
|
|
||
| enum { | ||
| MEDIA_STATS_FLAG = 'MeSt', | ||
| }; | ||
|
|
||
| explicit ExtendedStats(const char* id, pid_t tid); | ||
|
|
||
| // Evaluative item; associated with an operation | ||
| struct LogEntry : public RefBase { | ||
| LogEntry(); | ||
| virtual ~LogEntry() { mData = 0;} | ||
| virtual void insert(statsDataType) { } | ||
| virtual void dump(const char* label) const; | ||
| virtual void reset() {mData = 0;} | ||
| inline statsDataType data() const { return mData; } | ||
| protected: | ||
| statsDataType mData; | ||
| }; | ||
|
|
||
| // Supported type of MediaExtendedStats | ||
| enum StatsType { | ||
| PLAYER, | ||
| RECORDER, | ||
| }; | ||
|
|
||
| // Supported evaluations (and hence possible variants of 'LogEntry's) | ||
| enum LogType { | ||
| AVERAGE = 1 << 0, | ||
| MOVING_AVERAGE = 1 << 1, | ||
| PROFILE = 1 << 2, | ||
| }; | ||
|
|
||
| enum { | ||
| PROFILE_START = 1, | ||
| PROFILE_START_ONCE, | ||
| PROFILE_STOP, | ||
| }; | ||
|
|
||
| static const size_t kMaxStringLength = 1024; | ||
| static const int32_t kMaxWindowSize = 120; | ||
|
|
||
| struct AutoProfile { | ||
| AutoProfile(const char* eventName, sp<MediaExtendedStats> mediaExtendedStats = NULL, | ||
| bool condition = true, bool profileOnce = false); | ||
| ~AutoProfile(); | ||
|
|
||
| private: | ||
| AString mEventName; | ||
| sp<ExtendedStats::LogEntry> mLog; | ||
| sp<ExtendedStats> mStats; | ||
| bool mCondition; | ||
| }; | ||
|
|
||
| ~ExtendedStats(); | ||
| void log(LogType type, const char* key, statsDataType value, bool condition = true); | ||
| virtual void dump(const char* key = NULL); | ||
| virtual void reset(const char* key); | ||
| virtual void clear(); | ||
|
|
||
| static int64_t getSystemTime() { | ||
| struct timeval tv; | ||
| gettimeofday(&tv, NULL); | ||
| return (int64_t)tv.tv_sec * 1E6 + tv.tv_usec; | ||
| } | ||
|
|
||
| static sp<LogEntry> createLogEntry(LogType type, int32_t windowSize); | ||
|
|
||
| //only profile once, as opposed to up to kMaxOccurrences | ||
| inline void profileStartOnce(const char* name, bool condition = true) { | ||
| log(PROFILE, name, PROFILE_START_ONCE, condition); | ||
| } | ||
|
|
||
| //wrapper function to start profiling latency | ||
| inline void profileStart(const char* name, bool condition = true) { | ||
| log(PROFILE, name, PROFILE_START, condition); | ||
| } | ||
|
|
||
| //wrapper function to stop profiling. Name must match the name from profileStart | ||
| inline void profileStop(const char* name) { | ||
| log(PROFILE, name, PROFILE_STOP); | ||
| } | ||
|
|
||
| static MediaExtendedStats* Create(enum StatsType statsType, const char* name, pid_t tid); | ||
|
|
||
| //wrapper function to set window size. | ||
| inline void setWindowSize(int32_t windowSize) { | ||
| mWindowSize = windowSize; | ||
| } | ||
|
|
||
| private: | ||
| sp<LogEntry> getLogEntry(const char *key, LogType type); | ||
|
|
||
| protected: | ||
| KeyedVector<AString, sp<LogEntry> > mLogEntry; | ||
| Mutex mLock; | ||
|
|
||
| ExtendedStats(const ExtendedStats&) {} | ||
| AString mName; | ||
| pid_t mTid; | ||
|
|
||
| int32_t mWindowSize; | ||
| }; | ||
|
|
||
| inline ExtendedStats::LogType operator| (ExtendedStats::LogType a, ExtendedStats::LogType b) { | ||
| return static_cast<ExtendedStats::LogType>(static_cast<int>(a) | static_cast<int>(b)); | ||
| } | ||
|
|
||
| /**************************** MediaExtendedStats *********************/ | ||
|
|
||
| class MediaExtendedStats : public RefBase { | ||
| public: | ||
| explicit MediaExtendedStats(const char* name, pid_t tid); | ||
|
|
||
| void logFrameDropped(); | ||
| void logDimensions(int32_t width, int32_t height); | ||
| void logBitRate(int64_t frameSize, int64_t timestamp); | ||
|
|
||
| //only profile once, as opposed to up to kMaxOccurrences | ||
| inline void profileStartOnce(const char* name, bool condition = true) { | ||
| mProfileTimes->profileStartOnce(name, condition); | ||
| } | ||
|
|
||
| //wrapper function to start profiling latency | ||
| inline void profileStart(const char* name, bool condition = true) { | ||
| mProfileTimes->profileStart(name, condition); | ||
| } | ||
|
|
||
| //wrapper function to stop profiling. Name must match the name from profileStart | ||
| inline void profileStop(const char* name) { | ||
| mProfileTimes->profileStop(name); | ||
| } | ||
|
|
||
| sp<ExtendedStats> getProfileTimes() { | ||
| return mProfileTimes; | ||
| } | ||
| virtual void reset(); | ||
|
|
||
| virtual void notifyPause(int64_t pauseTimeUs) = 0; | ||
| virtual void dump() = 0; | ||
|
|
||
| int32_t setFrameRate(int32_t frameRate) { | ||
| mFrameRate = frameRate; | ||
| mProfileTimes->setWindowSize(mFrameRate); | ||
| } | ||
|
|
||
| protected: | ||
| AString mName; | ||
| pid_t mTid; | ||
|
|
||
| int64_t mCurrentConsecutiveFramesDropped; | ||
| int64_t mMaxConsecutiveFramesDropped; | ||
| int64_t mNumChainedDrops; | ||
| int64_t mFramesDropped; | ||
|
|
||
| int64_t mLastPauseTime; | ||
|
|
||
| Vector<int32_t> mWidthDimensions; | ||
| Vector<int32_t> mHeightDimensions; | ||
|
|
||
| sp<ExtendedStats> mProfileTimes; | ||
| int32_t mFrameRate; | ||
| Mutex mLock; | ||
|
|
||
| /* helper functions */ | ||
| void resetConsecutiveFramesDropped(); | ||
|
|
||
| virtual ~MediaExtendedStats(); | ||
| }; | ||
|
|
||
| /************************* PlayerExtendedStats *************************/ | ||
|
|
||
| class PlayerExtendedStats : public MediaExtendedStats { | ||
|
|
||
| public: | ||
| explicit PlayerExtendedStats(const char* name, pid_t tid); | ||
|
|
||
| void logFrameRendered(); | ||
|
|
||
| //functions to alert the logger of discontinuities in playback | ||
| void notifyPlaying(bool isPlaying); | ||
| void notifySeek(int64_t seekTimeUs); | ||
| void notifySeekDone(); | ||
| void notifyEOS(); | ||
|
|
||
| virtual void reset(); | ||
| virtual void dump(); | ||
| virtual void notifyPause(int64_t pauseTimeUs); | ||
|
|
||
| private: | ||
| int64_t mFramesRendered; | ||
|
|
||
| int64_t mTotalPlayingTime; | ||
| int64_t mStartPlayingTime; | ||
| int64_t mLastSeekTime; | ||
|
|
||
| bool mEOS; | ||
| bool mPlaying; | ||
| bool mPaused; //used as a flag for seeking while paused | ||
|
|
||
| void updateTotalPlayingTime(bool wasPlaying); | ||
| }; | ||
|
|
||
| class RecorderExtendedStats : public MediaExtendedStats { | ||
| public: | ||
| explicit RecorderExtendedStats(const char* name, pid_t tid); | ||
|
|
||
| void logFrameEncoded(); | ||
| void logRecordingDuration(int64_t duration); | ||
|
|
||
| virtual void reset(); | ||
| virtual void dump(); | ||
| virtual void notifyPause(int64_t pauseTimeUs); | ||
|
|
||
| private: | ||
| int64_t mFramesEncoded; | ||
| int64_t mTotalRecordingTime; | ||
| }; | ||
|
|
||
| } | ||
| #endif //EXTENDED_STATS_H_ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| /* | ||
| * Copyright (C) 2014 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 FFMPEG_SOFT_CODEC_H_ | ||
| #define FFMPEG_SOFT_CODEC_H_ | ||
|
|
||
| #include <media/IOMX.h> | ||
| #include <media/MediaCodecInfo.h> | ||
|
|
||
| #include <media/stagefright/foundation/AMessage.h> | ||
| #include <media/stagefright/foundation/AString.h> | ||
|
|
||
| #include <media/stagefright/MetaData.h> | ||
|
|
||
| #include <OMX_Audio.h> | ||
| #include <OMX_Video.h> | ||
|
|
||
| namespace android { | ||
|
|
||
| struct MediaCodecList; | ||
| struct OMXCodec; | ||
|
|
||
| struct FFMPEGSoftCodec { | ||
|
|
||
| enum { | ||
| kPortIndexInput = 0, | ||
| kPortIndexOutput = 1 | ||
| }; | ||
| static void convertMessageToMetaData( | ||
| const sp<AMessage> &msg, sp<MetaData> &meta); | ||
|
|
||
| static const char* overrideComponentName( | ||
| uint32_t quirks, const sp<MetaData> &meta, | ||
| const char *mime, bool isEncoder); | ||
|
|
||
| static void overrideComponentName( | ||
| uint32_t quirks, const sp<AMessage> &msg, | ||
| AString* componentName, AString* mime, | ||
| int32_t isEncoder); | ||
|
|
||
| static status_t setSupportedRole( | ||
| const sp<IOMX> &omx, IOMX::node_id node, | ||
| bool isEncoder, const char *mime); | ||
|
|
||
| static status_t setAudioFormat( | ||
| const sp<MetaData> &meta, const char* mime, | ||
| sp<IOMX> OMXhandle, IOMX::node_id nodeID, | ||
| bool isEncoder); | ||
|
|
||
| static status_t setAudioFormat( | ||
| const sp<AMessage> &msg, const char* mime, | ||
| sp<IOMX> OMXhandle, IOMX::node_id nodeID, | ||
| bool isEncoder); | ||
|
|
||
| static status_t setVideoFormat( | ||
| const sp<MetaData> &meta, const char* mime, | ||
| sp<IOMX> OMXhandle,IOMX::node_id nodeID, | ||
| bool isEncoder, OMX_VIDEO_CODINGTYPE *compressionFormat); | ||
|
|
||
| static status_t setVideoFormat( | ||
| const sp<AMessage> &msg, const char* mime, | ||
| sp<IOMX> OMXhandle,IOMX::node_id nodeID, | ||
| bool isEncoder, OMX_VIDEO_CODINGTYPE *compressionFormat); | ||
|
|
||
| static status_t handleSupportedAudioFormats( | ||
| int format, AString* mime); | ||
|
|
||
| static status_t handleSupportedVideoFormats( | ||
| int format, AString* mime); | ||
|
|
||
| private: | ||
| static const char* getMsgKey(int key); | ||
|
|
||
| static status_t setWMVFormat( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| static status_t setRVFormat( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| static status_t setFFmpegVideoFormat( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| static status_t setRawAudioFormat( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| static status_t setWMAFormat( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| static status_t setVORBISFormat( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| static status_t setRAFormat( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| static status_t setFLACFormat( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| static status_t setMP2Format( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| static status_t setAC3Format( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| static status_t setAPEFormat( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| static status_t setDTSFormat( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| static status_t setFFmpegAudioFormat( | ||
| const sp<AMessage> &msg, sp<IOMX> OMXhandle, | ||
| IOMX::node_id nodeID); | ||
|
|
||
| }; | ||
|
|
||
| } | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,198 @@ | ||
| /* | ||
| * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved. | ||
| * Not a Contribution. | ||
| * 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 LPA_PLAYER_H_ | ||
|
|
||
| #define LPA_PLAYER_H_ | ||
|
|
||
| #include "AudioPlayer.h" | ||
| #include <utils/threads.h> | ||
| #include <utils/List.h> | ||
| #include <utils/Vector.h> | ||
| #include <fcntl.h> | ||
| #include <pthread.h> | ||
| #include <include/TimedEventQueue.h> | ||
|
|
||
| // Pause timeout = 3sec | ||
| #define LPA_PAUSE_TIMEOUT_USEC 3000000 | ||
|
|
||
| namespace android { | ||
|
|
||
| class LPAPlayer : public AudioPlayer { | ||
| public: | ||
| enum { | ||
| REACHED_EOS, | ||
| SEEK_COMPLETE | ||
| }; | ||
|
|
||
| enum { | ||
| TRACK_DIRECT, | ||
| TRACK_REGULAR, | ||
| TRACK_NONE | ||
| }; | ||
|
|
||
| LPAPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink, bool &initCheck, | ||
| AwesomePlayer *audioObserver = NULL); | ||
|
|
||
| virtual ~LPAPlayer(); | ||
|
|
||
| // Caller retains ownership of "source". | ||
| virtual void setSource(const sp<MediaSource> &source); | ||
|
|
||
| // Return time in us. | ||
| virtual int64_t getRealTimeUs(); | ||
|
|
||
| virtual status_t start(bool sourceAlreadyStarted = false); | ||
|
|
||
| virtual void pause(bool playPendingSamples = false); | ||
| virtual status_t resume(); | ||
|
|
||
| // Returns the timestamp of the last buffer played (in us). | ||
| virtual int64_t getMediaTimeUs(); | ||
|
|
||
| // Returns true iff a mapping is established, i.e. the LPAPlayer | ||
| // has played at least one frame of audio. | ||
| virtual bool getMediaTimeMapping(int64_t *realtime_us, int64_t *mediatime_us); | ||
|
|
||
| virtual status_t seekTo(int64_t time_us); | ||
|
|
||
| virtual bool isSeeking(); | ||
| virtual bool reachedEOS(status_t *finalStatus); | ||
|
|
||
| static int mObjectsAlive; | ||
| private: | ||
| int64_t mPositionTimeMediaUs; | ||
| int64_t mPositionTimeRealUs; | ||
| bool mInternalSeeking; | ||
| bool mIsAudioRouted; | ||
| bool mStarted; | ||
| bool mPaused; | ||
| int32_t mChannelMask; | ||
| int32_t mNumOutputChannels; | ||
| int32_t mNumInputChannels; | ||
| int32_t mSampleRate; | ||
| int64_t mLatencyUs; | ||
| size_t mFrameSize; | ||
| int64_t mTimeStarted; | ||
| int64_t mTimePlayed; | ||
| int64_t mNumFramesPlayed; | ||
| int64_t mNumFramesPlayedSysTimeUs; | ||
|
|
||
| pthread_t mDecoderThread; | ||
|
|
||
| //Kill Thread boolean | ||
| bool mKillDecoderThread; | ||
|
|
||
| //Thread alive boolean | ||
| bool mDecoderThreadAlive; | ||
|
|
||
| //Declare the condition Variables and Mutex | ||
|
|
||
| Mutex mDecoderMutex; | ||
|
|
||
| Condition mDecoderCv; | ||
|
|
||
| // make sure Decoder thread has exited | ||
| void requestAndWaitForDecoderThreadExit_l(); | ||
|
|
||
| static void *decoderThreadWrapper(void *me); | ||
| void decoderThreadEntry(); | ||
|
|
||
| void createThreads(); | ||
|
|
||
| void onPauseTimeOut(); | ||
|
|
||
| sp<MediaSource> mSource; | ||
|
|
||
| MediaBuffer *mInputBuffer; | ||
|
|
||
| Mutex mLock; | ||
|
|
||
| bool mSeeking; | ||
| bool mReachedEOS; | ||
| bool mReachedOutputEOS; | ||
| status_t mFinalStatus; | ||
| int64_t mSeekTimeUs; | ||
| int64_t mPauseTime; | ||
|
|
||
|
|
||
| bool mIsFirstBuffer; | ||
| status_t mFirstBufferResult; | ||
| MediaBuffer *mFirstBuffer; | ||
| TimedEventQueue mQueue; | ||
| bool mQueueStarted; | ||
| sp<TimedEventQueue::Event> mPauseEvent; | ||
| bool mPauseEventPending; | ||
|
|
||
| sp<MediaPlayerBase::AudioSink> mAudioSink; | ||
| AwesomePlayer *mObserver; | ||
| int mTrackType; | ||
|
|
||
| static size_t AudioSinkCallback( | ||
| MediaPlayerBase::AudioSink *audioSink, | ||
| void *data, size_t size, void *me, | ||
| MediaPlayerBase::AudioSink::cb_event_t event); | ||
|
|
||
| int64_t getTimeStamp(); | ||
|
|
||
| size_t fillBuffer(void *data, size_t size); | ||
|
|
||
| int64_t getRealTimeUsLocked(); | ||
|
|
||
| void reset(); | ||
|
|
||
| status_t setupAudioSink(); | ||
| static size_t AudioCallback( | ||
| MediaPlayerBase::AudioSink *audioSink, | ||
| void *buffer, size_t size, void *cookie); | ||
| size_t AudioCallback(void *cookie, void *data, size_t size); | ||
| int64_t getMediaTimeUs_l(); | ||
| bool seekTooClose(int64_t); | ||
|
|
||
| void convertMonoToStereo(int16_t *data, size_t size); | ||
|
|
||
| LPAPlayer(const LPAPlayer &); | ||
| LPAPlayer &operator=(const LPAPlayer &); | ||
| }; | ||
|
|
||
| struct TimedEvent : public TimedEventQueue::Event { | ||
| TimedEvent(LPAPlayer *player, | ||
| void (LPAPlayer::*method)()) | ||
| : mPlayer(player), | ||
| mMethod(method) { | ||
| } | ||
|
|
||
| protected: | ||
| virtual ~TimedEvent() {} | ||
|
|
||
| virtual void fire(TimedEventQueue *queue, int64_t /* now_us */) { | ||
| (mPlayer->*mMethod)(); | ||
| } | ||
|
|
||
| private: | ||
| LPAPlayer *mPlayer; | ||
| void (LPAPlayer::*mMethod)(); | ||
|
|
||
| TimedEvent(const TimedEvent &); | ||
| TimedEvent &operator=(const TimedEvent &); | ||
| }; | ||
|
|
||
| } // namespace android | ||
|
|
||
| #endif // LPA_PLAYER_H_ | ||
|
|