diff options
Diffstat (limited to 'include')
24 files changed, 1557 insertions, 13 deletions
diff --git a/include/camera/Camera.h b/include/camera/Camera.h index 234e165..ad4db3b 100644 --- a/include/camera/Camera.h +++ b/include/camera/Camera.h @@ -46,6 +46,9 @@ struct CameraInfo { * right of the screen, the value should be 270. */ int orientation; +#ifdef QCOM_HARDWARE + int mode; +#endif }; class ICameraService; diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h index 5540d32..21e907e 100644 --- a/include/camera/CameraParameters.h +++ b/include/camera/CameraParameters.h @@ -36,7 +36,21 @@ struct Size { height = h; } }; - +#ifdef QCOM_HARDWARE +struct FPSRange{ + int minFPS; + int maxFPS; + + FPSRange(){ + minFPS=0; + maxFPS=0; + }; + FPSRange(int min,int max){ + minFPS=min; + maxFPS=max; + }; +}; +#endif class CameraParameters { public: @@ -52,6 +66,9 @@ public: void setFloat(const char *key, float value); const char *get(const char *key) const; int getInt(const char *key) const; +#ifdef SAMSUNG_CAMERA_HARDWARE + int getInt64(const char *key) const; +#endif float getFloat(const char *key) const; void remove(const char *key); @@ -91,6 +108,10 @@ public: void setPreviewFrameRate(int fps); int getPreviewFrameRate() const; void getPreviewFpsRange(int *min_fps, int *max_fps) const; +#ifdef QCOM_HARDWARE + void setPreviewFrameRateMode(const char *mode); + const char *getPreviewFrameRateMode() const; +#endif void setPreviewFormat(const char *format); const char *getPreviewFormat() const; void setPictureSize(int width, int height); @@ -98,6 +119,14 @@ public: void getSupportedPictureSizes(Vector<Size> &sizes) const; void setPictureFormat(const char *format); const char *getPictureFormat() const; +#ifdef QCOM_HARDWARE + void setTouchIndexAec(int x, int y); + void getTouchIndexAec(int *x, int *y) const; + void setTouchIndexAf(int x, int y); + void getTouchIndexAf(int *x, int *y) const; +#endif + + void getMeteringAreaCenter(int * x, int *y) const; void dump() const; status_t dump(int fd, const Vector<String16>& args) const; @@ -112,6 +141,11 @@ public: // Supported preview frame sizes in pixels. // Example value: "800x600,480x320". Read only. static const char KEY_SUPPORTED_PREVIEW_SIZES[]; +#ifdef QCOM_HARDWARE + // Supported PREVIEW/RECORDING SIZES IN HIGH FRAME RATE recording, sizes in pixels. + // Example value: "800x480,432x320". Read only. + static const char KEY_SUPPORTED_HFR_SIZES[]; +#endif // The current minimum and maximum preview fps. This controls the rate of // preview frames received (CAMERA_MSG_PREVIEW_FRAME). The minimum and // maximum fps must be one of the elements from @@ -141,6 +175,14 @@ public: // Supported number of preview frames per second. // Example value: "24,15,10". Read. static const char KEY_SUPPORTED_PREVIEW_FRAME_RATES[]; +#ifdef QCOM_HARDWARE + // The mode of preview frame rate. + // Example value: "frame-rate-auto, frame-rate-fixed". + static const char KEY_PREVIEW_FRAME_RATE_MODE[]; + static const char KEY_SUPPORTED_PREVIEW_FRAME_RATE_MODES[]; + static const char KEY_PREVIEW_FRAME_RATE_AUTO_MODE[]; + static const char KEY_PREVIEW_FRAME_RATE_FIXED_MODE[]; +#endif // The dimensions for captured pictures in pixels (width x height). // Example value: "1024x768". Read/write. static const char KEY_PICTURE_SIZE[]; @@ -203,6 +245,12 @@ public: // header. // Example value: "21.0" or "-5". Write only. static const char KEY_GPS_ALTITUDE[]; + +#ifdef QCOM_HARDWARE + static const char KEY_SKIN_TONE_ENHANCEMENT[] ; + static const char KEY_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES[] ; +#endif + // GPS timestamp (UTC in seconds since January 1, 1970). This should be // stored in JPEG EXIF header. // Example value: "1251192757". Write only. @@ -222,6 +270,15 @@ public: // Supported color effect settings. // Example value: "none,mono,sepia". Read only. static const char KEY_SUPPORTED_EFFECTS[]; +#ifdef QCOM_HARDWARE + //Touch Af/AEC settings. + static const char KEY_TOUCH_AF_AEC[]; + static const char KEY_SUPPORTED_TOUCH_AF_AEC[]; + //Touch Index for AEC. + static const char KEY_TOUCH_INDEX_AEC[]; + //Touch Index for AF. + static const char KEY_TOUCH_INDEX_AF[]; +#endif // Current antibanding setting. // Example value: "auto" or ANTIBANDING_XXX constants. Read/write. static const char KEY_ANTIBANDING[]; @@ -234,6 +291,14 @@ public: // Supported scene mode settings. // Example value: "auto,night,fireworks". Read only. static const char KEY_SUPPORTED_SCENE_MODES[]; +#ifdef QCOM_HARDWARE + // Current auto scene detection mode. + // Example value: "off" or SCENE_DETECT_XXX constants. Read/write. + static const char KEY_SCENE_DETECT[]; + // Supported auto scene detection settings. + // Example value: "off,backlight,snow/cloudy". Read only. + static const char KEY_SUPPORTED_SCENE_DETECT[]; +#endif // Current flash mode. // Example value: "auto" or FLASH_MODE_XXX constants. Read/write. static const char KEY_FLASH_MODE[]; @@ -505,6 +570,23 @@ public: // captured pictures. // Example value: "true" or "false". Read only. static const char KEY_VIDEO_SNAPSHOT_SUPPORTED[]; + static const char KEY_FULL_VIDEO_SNAP_SUPPORTED[]; + +#ifdef QCOM_HARDWARE + static const char KEY_ISO_MODE[]; + static const char KEY_SUPPORTED_ISO_MODES[]; + static const char KEY_LENSSHADE[] ; + static const char KEY_SUPPORTED_LENSSHADE_MODES[] ; + + static const char KEY_AUTO_EXPOSURE[]; + static const char KEY_SUPPORTED_AUTO_EXPOSURE[]; + + static const char KEY_GPS_LATITUDE_REF[]; + static const char KEY_GPS_LONGITUDE_REF[]; + static const char KEY_GPS_ALTITUDE_REF[]; + static const char KEY_GPS_STATUS[]; + static const char KEY_EXIF_DATETIME[]; +#endif // The state of the video stabilization. If set to true, both the // preview stream and the recorded video stream are stabilized by @@ -520,11 +602,42 @@ public: // has no effect on still image capture. static const char KEY_VIDEO_STABILIZATION[]; +#ifdef QCOM_HARDWARE + static const char KEY_MEMORY_COLOR_ENHANCEMENT[]; + static const char KEY_SUPPORTED_MEM_COLOR_ENHANCE_MODES[]; + + static const char KEY_POWER_MODE_SUPPORTED[]; + static const char KEY_POWER_MODE[]; + + static const char KEY_ZSL[]; + static const char KEY_SUPPORTED_ZSL_MODES[]; + + static const char KEY_CAMERA_MODE[]; + + static const char KEY_VIDEO_HIGH_FRAME_RATE[]; + static const char KEY_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES[]; + static const char KEY_HIGH_DYNAMIC_RANGE_IMAGING[]; + static const char KEY_SUPPORTED_HDR_IMAGING_MODES[]; +#endif // Returns true if video stabilization is supported. That is, applications // can set KEY_VIDEO_STABILIZATION to true and have a stabilized preview // stream and record stabilized videos. static const char KEY_VIDEO_STABILIZATION_SUPPORTED[]; +#ifdef HAVE_ISO + static const char KEY_SUPPORTED_ISO_MODES[]; + static const char KEY_ISO_MODE[]; +#endif + +#ifdef SAMSUNG_CAMERA_HARDWARE + static const char KEY_ANTI_SHAKE_MODE[]; + static const char KEY_METERING[]; + static const char KEY_WDR[]; + static const char KEY_WEATHER[]; + static const char KEY_CITYID[]; +#endif + static const char KEY_AE_BRACKET_HDR[]; + // Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED. static const char TRUE[]; static const char FALSE[]; @@ -532,6 +645,24 @@ public: // Value for KEY_FOCUS_DISTANCES. static const char FOCUS_DISTANCE_INFINITY[]; +#ifdef QCOM_HARDWARE + // DENOISE + static const char KEY_DENOISE[]; + static const char KEY_SUPPORTED_DENOISE[]; + + //Selectable zone AF. + static const char KEY_SELECTABLE_ZONE_AF[]; + static const char KEY_SUPPORTED_SELECTABLE_ZONE_AF[]; + + //Face Detection + static const char KEY_FACE_DETECTION[]; + static const char KEY_SUPPORTED_FACE_DETECTION[]; + + //Redeye Reduction + static const char KEY_REDEYE_REDUCTION[]; + static const char KEY_SUPPORTED_REDEYE_REDUCTION[]; +#endif + // Values for white balance settings. static const char WHITE_BALANCE_AUTO[]; static const char WHITE_BALANCE_INCANDESCENT[]; @@ -552,6 +683,15 @@ public: static const char EFFECT_WHITEBOARD[]; static const char EFFECT_BLACKBOARD[]; static const char EFFECT_AQUA[]; +#ifdef QCOM_HARDWARE + static const char EFFECT_EMBOSS[]; + static const char EFFECT_SKETCH[]; + static const char EFFECT_NEON[]; + + // Values for Touch AF/AEC + static const char TOUCH_AF_AEC_OFF[] ; + static const char TOUCH_AF_AEC_ON[] ; +#endif // Values for antibanding settings. static const char ANTIBANDING_AUTO[]; @@ -576,6 +716,7 @@ public: // Values for scene mode settings. static const char SCENE_MODE_AUTO[]; + static const char SCENE_MODE_ASD[]; static const char SCENE_MODE_ACTION[]; static const char SCENE_MODE_PORTRAIT[]; static const char SCENE_MODE_LANDSCAPE[]; @@ -590,6 +731,11 @@ public: static const char SCENE_MODE_SPORTS[]; static const char SCENE_MODE_PARTY[]; static const char SCENE_MODE_CANDLELIGHT[]; +#ifdef QCOM_HARDWARE + static const char SCENE_MODE_BACKLIGHT[]; + static const char SCENE_MODE_FLOWERS[]; + static const char SCENE_MODE_AR[]; +#endif // Applications are looking for a barcode. Camera driver will be optimized // for barcode reading. static const char SCENE_MODE_BARCODE[]; @@ -600,8 +746,15 @@ public: // Pixel color formats for KEY_PREVIEW_FORMAT, KEY_PICTURE_FORMAT, // and KEY_VIDEO_FRAME_FORMAT +#ifdef QCOM_HARDWARE + static const char SCENE_DETECT_OFF[]; + static const char SCENE_DETECT_ON[]; +#endif static const char PIXEL_FORMAT_YUV422SP[]; static const char PIXEL_FORMAT_YUV420SP[]; // NV21 +#ifdef QCOM_HARDWARE + static const char PIXEL_FORMAT_YUV420SP_ADRENO[]; // ADRENO +#endif static const char PIXEL_FORMAT_YUV422I[]; // YUY2 static const char PIXEL_FORMAT_YUV420P[]; // YV12 static const char PIXEL_FORMAT_RGB565[]; @@ -610,9 +763,16 @@ public: // Raw bayer format used for images, which is 10 bit precision samples // stored in 16 bit words. The filter pattern is RGGB. static const char PIXEL_FORMAT_BAYER_RGGB[]; + // Pixel format is not known to the framework static const char PIXEL_FORMAT_ANDROID_OPAQUE[]; +#ifdef QCOM_HARDWARE + static const char PIXEL_FORMAT_RAW[]; + static const char PIXEL_FORMAT_YV12[]; // NV21 + static const char PIXEL_FORMAT_NV12[]; //NV12 +#endif + // Values for focus mode settings. // Auto-focus mode. Applications should call // CameraHardwareInterface.autoFocus to start the focus in this mode. @@ -664,6 +824,107 @@ public: // other modes. static const char FOCUS_MODE_CONTINUOUS_PICTURE[]; +#ifdef QCOM_HARDWARE + // Normal focus mode. Applications should call + // CameraHardwareInterface.autoFocus to start the focus in this mode. + static const char FOCUS_MODE_NORMAL[]; + static const char ISO_AUTO[]; + static const char ISO_HJR[] ; + static const char ISO_100[]; + static const char ISO_200[] ; + static const char ISO_400[]; + static const char ISO_800[]; + static const char ISO_1600[]; + static const char ISO_3200[]; + static const char ISO_6400[]; + // Values for Lens Shading + static const char LENSSHADE_ENABLE[] ; + static const char LENSSHADE_DISABLE[] ; + + // Values for auto exposure settings. + static const char AUTO_EXPOSURE_FRAME_AVG[]; + static const char AUTO_EXPOSURE_CENTER_WEIGHTED[]; + static const char AUTO_EXPOSURE_SPOT_METERING[]; + + static const char KEY_SHARPNESS[]; + static const char KEY_MAX_SHARPNESS[]; + static const char KEY_CONTRAST[]; + static const char KEY_MAX_CONTRAST[]; + static const char KEY_SATURATION[]; + static const char KEY_MAX_SATURATION[]; + + static const char KEY_HISTOGRAM[] ; + static const char KEY_SUPPORTED_HISTOGRAM_MODES[] ; + // Values for HISTOGRAM + static const char HISTOGRAM_ENABLE[] ; + static const char HISTOGRAM_DISABLE[] ; + + // Values for SKIN TONE ENHANCEMENT + static const char SKIN_TONE_ENHANCEMENT_ENABLE[] ; + static const char SKIN_TONE_ENHANCEMENT_DISABLE[] ; + + // Values for Denoise + static const char DENOISE_OFF[] ; + static const char DENOISE_ON[] ; + + // Values for auto exposure settings. + static const char SELECTABLE_ZONE_AF_AUTO[]; + static const char SELECTABLE_ZONE_AF_SPOT_METERING[]; + static const char SELECTABLE_ZONE_AF_CENTER_WEIGHTED[]; + static const char SELECTABLE_ZONE_AF_FRAME_AVERAGE[]; + + // Values for Face Detection settings. + static const char FACE_DETECTION_OFF[]; + static const char FACE_DETECTION_ON[]; + + // Values for MCE settings. + static const char MCE_ENABLE[]; + static const char MCE_DISABLE[]; + + // Values for ZSL settings. + static const char ZSL_OFF[]; + static const char ZSL_ON[]; + + // Values for HDR Bracketing settings. + static const char AE_BRACKET_HDR_OFF[]; + static const char AE_BRACKET_HDR[]; + static const char AE_BRACKET[]; + + //POWER MODE + static const char LOW_POWER[]; + static const char NORMAL_POWER[]; + + // Values for HFR settings. + static const char VIDEO_HFR_OFF[]; + static const char VIDEO_HFR_2X[]; + static const char VIDEO_HFR_3X[]; + static const char VIDEO_HFR_4X[]; + + // Values for Redeye Reduction settings. + static const char REDEYE_REDUCTION_ENABLE[]; + static const char REDEYE_REDUCTION_DISABLE[]; + // Values for HDR settings. + static const char HDR_ENABLE[]; + static const char HDR_DISABLE[]; + + // Values for Redeye Reduction settings. + // static const char REDEYE_REDUCTION_ENABLE[]; + // static const char REDEYE_REDUCTION_DISABLE[]; + // Values for HDR settings. + // static const char HDR_ENABLE[]; + // static const char HDR_DISABLE[]; + + enum { + CAMERA_ORIENTATION_UNKNOWN = 0, + CAMERA_ORIENTATION_PORTRAIT = 1, + CAMERA_ORIENTATION_LANDSCAPE = 2, + }; + int getOrientation() const; + void setOrientation(int orientation); + void setPreviewFpsRange(int minFPS,int maxFPS); + void getSupportedHfrSizes(Vector<Size> &sizes) const; +#endif + private: DefaultKeyedVector<String8,String8> mMap; }; diff --git a/include/media/AudioParameter.h b/include/media/AudioParameter.h index 891bc4b..d29c699 100644 --- a/include/media/AudioParameter.h +++ b/include/media/AudioParameter.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2008-2011 The Android Open Source Project + * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +49,13 @@ public: static const char * const keyFrameCount; static const char * const keyInputSource; static const char * const keyScreenState; +#ifdef QCOM_HARDWARE + static const char * const keyHandleFm; + static const char * const keyVoipCheck; + static const char * const keyFluenceType; + static const char * const keySSR; + static const char * const keyHandleA2dpDevice; +#endif String8 toString(); diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index 49e1afc..d8c57d3 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -1,4 +1,8 @@ /* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Not a Contribution, Apache license notifications and license are retained + * for attribution purposes only. + * * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -144,6 +148,10 @@ public: INPUT_CLOSED, INPUT_CONFIG_CHANGED, STREAM_CONFIG_CHANGED, +#ifdef QCOM_HARDWARE + A2DP_OUTPUT_STATE, + EFFECT_CONFIG_CHANGED, +#endif NUM_CONFIG_EVENTS }; diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h index 34108b3..77a0b26 100644 --- a/include/media/AudioTrack.h +++ b/include/media/AudioTrack.h @@ -31,6 +31,10 @@ #include <cutils/sched_policy.h> #include <utils/threads.h> +#ifdef QCOM_HARDWARE +#include <media/IDirectTrackClient.h> +#endif + namespace android { // ---------------------------------------------------------------------------- @@ -39,7 +43,11 @@ class audio_track_cblk_t; // ---------------------------------------------------------------------------- -class AudioTrack : virtual public RefBase +class AudioTrack : +#ifdef QCOM_HARDWARE + public BnDirectTrackClient, +#endif + virtual public RefBase { public: enum channel_index { @@ -451,6 +459,11 @@ public: */ status_t dump(int fd, const Vector<String16>& args) const; +#ifdef QCOM_HARDWARE + virtual void notify(int msg); + virtual status_t getTimeStamp(uint64_t *tstamp); +#endif + protected: /* copying audio tracks is not allowed */ AudioTrack(const AudioTrack& other); @@ -496,6 +509,9 @@ protected: status_t restoreTrack_l(audio_track_cblk_t*& cblk, bool fromStart); bool stopped_l() const { return !mActive; } +#ifdef QCOM_HARDWARE + sp<IDirectTrack> mDirectTrack; +#endif sp<IAudioTrack> mAudioTrack; sp<IMemory> mCblkMemory; sp<AudioTrackThread> mAudioTrackThread; @@ -529,10 +545,17 @@ protected: uint32_t mUpdatePeriod; bool mFlushed; // FIXME will be made obsolete by making flush() synchronous audio_output_flags_t mFlags; +#ifdef QCOM_HARDWARE + sp<IAudioFlinger> mAudioFlinger; + audio_io_handle_t mAudioDirectOutput; +#endif int mSessionId; int mAuxEffectId; mutable Mutex mLock; status_t mRestoreStatus; +#ifdef QCOM_HARDWARE + void* mObserver; +#endif bool mIsTimed; int mPreviousPriority; // before start() SchedPolicy mPreviousSchedulingGroup; diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h index 5170a87..0700a68 100644..100755 --- a/include/media/IAudioFlinger.h +++ b/include/media/IAudioFlinger.h @@ -1,4 +1,8 @@ /* + * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. + * Not a Contribution, Apache license notifications and license are retained + * for attribution purposes only. + * * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,6 +28,10 @@ #include <utils/RefBase.h> #include <utils/Errors.h> #include <binder/IInterface.h> +#ifdef QCOM_HARDWARE +#include <media/IDirectTrack.h> +#include <media/IDirectTrackClient.h> +#endif #include <media/IAudioTrack.h> #include <media/IAudioRecord.h> #include <media/IAudioFlingerClient.h> @@ -69,6 +77,21 @@ public: int *sessionId, status_t *status) = 0; +#ifdef QCOM_HARDWARE + /* create a direct audio track and registers it with AudioFlinger. + * return null if the track cannot be created. + */ + virtual sp<IDirectTrack> createDirectTrack( + pid_t pid, + uint32_t sampleRate, + audio_channel_mask_t channelMask, + audio_io_handle_t output, + int *sessionId, + IDirectTrackClient* client, + audio_stream_type_t streamType, + status_t *status) = 0; +#endif + virtual sp<IAudioRecord> openRecord( pid_t pid, audio_io_handle_t input, @@ -187,6 +210,9 @@ public: audio_io_handle_t dstOutput) = 0; virtual audio_module_handle_t loadHwModule(const char *name) = 0; +#ifdef QCOM_HARDWARE + virtual status_t deregisterClient(const sp<IAudioFlingerClient>& client) { return false; }; +#endif // helpers for android.media.AudioManager.getProperty(), see description there for meaning // FIXME move these APIs to AudioPolicy to permit a more accurate implementation diff --git a/include/media/IDirectTrack.h b/include/media/IDirectTrack.h new file mode 100644 index 0000000..c1f4f09 --- /dev/null +++ b/include/media/IDirectTrack.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Not a Contribution, Apache license notifications and license are retained + * for attribution purposes only. + * + * 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 diff --git a/include/media/IDirectTrackClient.h b/include/media/IDirectTrackClient.h new file mode 100644 index 0000000..9383690 --- /dev/null +++ b/include/media/IDirectTrackClient.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * Not a Contribution, Apache license notifications and license are retained + * for attribution purposes only. + * + * 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 diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h index b7bee3f..a7570d6 100644 --- a/include/media/MediaPlayerInterface.h +++ b/include/media/MediaPlayerInterface.h @@ -110,6 +110,10 @@ public: virtual status_t setPlaybackRatePermille(int32_t rate) { return INVALID_OPERATION; } virtual bool needsTrailingPadding() { return true; } +#ifdef QCOM_HARDWARE + virtual ssize_t sampleRate() const {return 0;}; + virtual status_t getTimeStamp(uint64_t *tstamp) {return 0;}; +#endif }; MediaPlayerBase() : mCookie(0), mNotify(0) {} diff --git a/include/media/MediaProfiles.h b/include/media/MediaProfiles.h index 9fc962c..0df9fd4 100644 --- a/include/media/MediaProfiles.h +++ b/include/media/MediaProfiles.h @@ -1,6 +1,7 @@ /* ** ** Copyright 2010, The Android Open Source Project. + ** Copyright (c) 2010 - 2012, The Linux Foundation. All rights reserved. ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -32,8 +33,13 @@ enum camcorder_quality { CAMCORDER_QUALITY_480P = 4, CAMCORDER_QUALITY_720P = 5, CAMCORDER_QUALITY_1080P = 6, - CAMCORDER_QUALITY_QVGA = 7, - CAMCORDER_QUALITY_LIST_END = 7, + CAMCORDER_QUALITY_QVGA = 11, + CAMCORDER_QUALITY_FWVGA = 7, + CAMCORDER_QUALITY_WVGA = 8, + CAMCORDER_QUALITY_VGA = 9, + CAMCORDER_QUALITY_WQVGA = 10, + + CAMCORDER_QUALITY_LIST_END = 11, CAMCORDER_QUALITY_TIME_LAPSE_LIST_START = 1000, CAMCORDER_QUALITY_TIME_LAPSE_LOW = 1000, @@ -456,6 +462,10 @@ private: static VideoEncoderCap* createDefaultH263VideoEncoderCap(); static VideoEncoderCap* createDefaultM4vVideoEncoderCap(); static AudioEncoderCap* createDefaultAmrNBEncoderCap(); +#ifdef QCOM_HARDWARE + static AudioEncoderCap* createDefaultAacEncoderCap(); + static AudioEncoderCap* createDefaultLpcmEncoderCap(); +#endif static int findTagForName(const NameToTagMap *map, size_t nMappings, const char *name); diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h index 6d304e0..6dfa5d9 100644 --- a/include/media/mediarecorder.h +++ b/include/media/mediarecorder.h @@ -1,5 +1,6 @@ /* ** Copyright (C) 2008 The Android Open Source Project + ** Copyright (c) 2010 - 2012, The Linux Foundation. All rights reserved. ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -67,6 +68,12 @@ enum output_format { /* H.264/AAC data encapsulated in MPEG2/TS */ OUTPUT_FORMAT_MPEG2TS = 8, +#ifdef QCOM_HARDWARE + OUTPUT_FORMAT_QCP = 9, // QCP file format + OUTPUT_FORMAT_THREE_GPP2 = 10, /*3GPP2*/ + OUTPUT_FORMAT_WAVE = 11, /*WAVE*/ +#endif + OUTPUT_FORMAT_LIST_END // must be last - used to validate format type }; @@ -77,6 +84,11 @@ enum audio_encoder { AUDIO_ENCODER_AAC = 3, AUDIO_ENCODER_HE_AAC = 4, AUDIO_ENCODER_AAC_ELD = 5, +#ifdef QCOM_HARDWARE + AUDIO_ENCODER_EVRC = 6, + AUDIO_ENCODER_QCELP = 7, + AUDIO_ENCODER_LPCM = 8, +#endif AUDIO_ENCODER_LIST_END // must be the last - used to validate the audio encoder type }; @@ -118,6 +130,9 @@ enum media_recorder_event_type { MEDIA_RECORDER_EVENT_LIST_START = 1, MEDIA_RECORDER_EVENT_ERROR = 1, MEDIA_RECORDER_EVENT_INFO = 2, +#ifdef QCOM_HARDWARE + MEDIA_RECORDER_MSG_COMPRESSED_IMAGE = 8, // mzhu: TODO, where to put this? +#endif MEDIA_RECORDER_EVENT_LIST_END = 99, // Track related event types diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index df1c46b..b42a4ac 100644 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -190,6 +190,9 @@ private: status_t freeBuffer(OMX_U32 portIndex, size_t i); status_t allocateOutputBuffersFromNativeWindow(); +#ifdef USE_SAMSUNG_COLORFORMAT + void setNativeWindowColorFormat(OMX_COLOR_FORMATTYPE &eNativeColorFormat); +#endif status_t cancelBufferToNativeWindow(BufferInfo *info); status_t freeOutputBuffersNotOwnedByComponent(); BufferInfo *dequeueBufferFromNativeWindow(); diff --git a/include/media/stagefright/AudioPlayer.h b/include/media/stagefright/AudioPlayer.h index 1dc408f..624fe3e 100644 --- a/include/media/stagefright/AudioPlayer.h +++ b/include/media/stagefright/AudioPlayer.h @@ -43,27 +43,27 @@ public: virtual ~AudioPlayer(); // Caller retains ownership of "source". - void setSource(const sp<MediaSource> &source); + virtual void setSource(const sp<MediaSource> &source); // Return time in us. virtual int64_t getRealTimeUs(); - status_t start(bool sourceAlreadyStarted = false); + virtual status_t start(bool sourceAlreadyStarted = false); - void pause(bool playPendingSamples = false); - void resume(); + virtual void pause(bool playPendingSamples = false); + virtual void resume(); // Returns the timestamp of the last buffer played (in us). - int64_t getMediaTimeUs(); + virtual int64_t getMediaTimeUs(); // Returns true iff a mapping is established, i.e. the AudioPlayer // has played at least one frame of audio. - bool getMediaTimeMapping(int64_t *realtime_us, int64_t *mediatime_us); + virtual bool getMediaTimeMapping(int64_t *realtime_us, int64_t *mediatime_us); - status_t seekTo(int64_t time_us); + virtual status_t seekTo(int64_t time_us); - bool isSeeking(); - bool reachedEOS(status_t *finalStatus); + virtual bool isSeeking(); + virtual bool reachedEOS(status_t *finalStatus); status_t setPlaybackRatePermille(int32_t ratePermille); @@ -91,6 +91,9 @@ private: int64_t mSeekTimeUs; bool mStarted; +#ifdef QCOM_HARDWARE + bool mSourcePaused; +#endif bool mIsFirstBuffer; status_t mFirstBufferResult; diff --git a/include/media/stagefright/AudioSource.h b/include/media/stagefright/AudioSource.h index 99f3c3b..4489254 100644 --- a/include/media/stagefright/AudioSource.h +++ b/include/media/stagefright/AudioSource.h @@ -85,6 +85,7 @@ private: int64_t mInitialReadTimeUs; int64_t mNumFramesReceived; int64_t mNumClientOwnedBuffers; + int64_t mAutoRampStartUs; List<MediaBuffer * > mBuffersReceived; diff --git a/include/media/stagefright/ExtendedWriter.h b/include/media/stagefright/ExtendedWriter.h new file mode 100644 index 0000000..23944b0 --- /dev/null +++ b/include/media/stagefright/ExtendedWriter.h @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * + * Not a Contribution, Apache license notifications and license are retained + * for attribution purposes only. + * + * 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 EXTENDED_WRITER_H_ + +#define EXTENDED_WRITER_H_ + +#include <stdio.h> + +#include <media/stagefright/MediaWriter.h> +#include <utils/threads.h> +#include <cutils/log.h> + +#define LITERAL_TO_STRING_INTERNAL(x) #x +#define LITERAL_TO_STRING(x) LITERAL_TO_STRING_INTERNAL(x) + +#define CHECK_EQ(x,y) \ + LOG_ALWAYS_FATAL_IF( \ + (x) != (y), \ + __FILE__ ":" LITERAL_TO_STRING(__LINE__) " " #x " != " #y) + +#define CHECK(x) \ + LOG_ALWAYS_FATAL_IF( \ + !(x), \ + __FILE__ ":" LITERAL_TO_STRING(__LINE__) " " #x) + +namespace android { + +struct MediaSource; +struct MetaData; + +struct ExtendedWriter : public MediaWriter { + ExtendedWriter(const char *filename); + ExtendedWriter(int fd); + + status_t initCheck() const; + + virtual status_t addSource(const sp<MediaSource> &source); + virtual bool reachedEOS(); + virtual status_t start(MetaData *params = NULL); + virtual status_t stop(); + virtual status_t pause(); + +protected: + virtual ~ExtendedWriter(); + +private: + FILE *mFile; + status_t mInitCheck; + sp<MediaSource> mSource; + bool mStarted; + volatile bool mPaused; + volatile bool mResumed; + volatile bool mDone; + volatile bool mReachedEOS; + pthread_t mThread; + int64_t mEstimatedSizeBytes; + int64_t mEstimatedDurationUs; + + int32_t mFormat; + + //QCP/EVRC header + struct QCPEVRCHeader + { + /* RIFF Section */ + char riff[4]; + unsigned int s_riff; + char qlcm[4]; + + /* Format chunk */ + char fmt[4]; + unsigned int s_fmt; + char mjr; + char mnr; + unsigned int data1; + + /* UNIQUE ID of the codec */ + unsigned short data2; + unsigned short data3; + char data4[8]; + unsigned short ver; + + /* Codec Info */ + char name[80]; + unsigned short abps; + + /* average bits per sec of the codec */ + unsigned short bytes_per_pkt; + unsigned short samp_per_block; + unsigned short samp_per_sec; + unsigned short bits_per_samp; + unsigned char vr_num_of_rates; + + /* Rate Header fmt info */ + unsigned char rvd1[3]; + unsigned short vr_bytes_per_pkt[8]; + unsigned int rvd2[5]; + + /* Vrat chunk */ + unsigned char vrat[4]; + unsigned int s_vrat; + unsigned int v_rate; + unsigned int size_in_pkts; + + /* Data chunk */ + unsigned char data[4]; + unsigned int s_data; + } __attribute__ ((packed)); + + struct QCPEVRCHeader mHeader; + off_t mOffset; //note off_t + + static void *ThreadWrapper(void *); + status_t threadFunc(); + bool exceedsFileSizeLimit(); + bool exceedsFileDurationLimit(); + + ExtendedWriter(const ExtendedWriter &); + ExtendedWriter &operator=(const ExtendedWriter &); + + status_t writeQCPHeader( ); + status_t writeEVRCHeader( ); +}; + +} // namespace android + +#endif // AMR_WRITER_H_ diff --git a/include/media/stagefright/FMRadioSource.h b/include/media/stagefright/FMRadioSource.h new file mode 100644 index 0000000..32db156 --- /dev/null +++ b/include/media/stagefright/FMRadioSource.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) ST-Ericsson SA 2012 + * Copyright (C) 2012 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. + * + * Author: Stefan Ekenberg (stefan.ekenberg@stericsson.com) for ST-Ericsson + */ + +#ifndef FMRADIO_SOURCE_H_ + +#define FMRADIO_SOURCE_H_ + +#include <media/AudioRecord.h> +#include <media/stagefright/DataSource.h> +#include <media/stagefright/foundation/ABase.h> +#include <system/audio.h> + +namespace android { + +class FMRadioSource : public DataSource { +public: + FMRadioSource(); + + virtual status_t initCheck() const; + virtual ssize_t readAt(off64_t offset, void *data, size_t size); + virtual status_t getSize(off64_t *size); + +protected: + virtual ~FMRadioSource(); + +private: + struct Buffer { + size_t frameCount; + size_t size; + int8_t* data; + }; + + status_t openRecord(int frameCount, audio_io_handle_t input); + status_t obtainBuffer(Buffer* audioBuffer); + + status_t mInitCheck; + bool mStarted; + int mSessionId; + sp<IAudioRecord> mAudioRecord; + sp<IMemory> mCblkMemory; + audio_track_cblk_t* mCblk; + + DISALLOW_EVIL_CONSTRUCTORS(FMRadioSource); +}; + +} // namespace android + +#endif // FMRADIO_SOURCE_H_ diff --git a/include/media/stagefright/LPAPlayer.h b/include/media/stagefright/LPAPlayer.h new file mode 100755 index 0000000..b0e1d31 --- /dev/null +++ b/include/media/stagefright/LPAPlayer.h @@ -0,0 +1,291 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved. + * Not a Contribution, Apache license notifications and license are retained + * for attribution purposes only. + * + * 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 <media/IAudioFlinger.h> +#include <utils/threads.h> +#include <utils/List.h> +#include <utils/Vector.h> +#include <fcntl.h> +#include <pthread.h> +#include <binder/IServiceManager.h> +#include <linux/unistd.h> +#include <include/TimedEventQueue.h> +#include <binder/BinderService.h> +#include <binder/MemoryDealer.h> +#include <powermanager/IPowerManager.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 void 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 objectsAlive; + static bool mLpaInProgress; +private: + int64_t mPositionTimeMediaUs; + int64_t mPositionTimeRealUs; + bool mInternalSeeking; + bool mIsAudioRouted; + bool mStarted; + bool mPaused; + bool mA2DPEnabled; + int32_t mChannelMask; + int32_t numChannels; + int32_t mSampleRate; + int64_t mLatencyUs; + size_t mFrameSize; + int64_t mTimeStarted; + int64_t mTimePlayed; + int64_t mNumFramesPlayed; + int64_t mNumFramesPlayedSysTimeUs; + int64_t mNumA2DPBytesPlayed; + + void clearPowerManager(); + + class PMDeathRecipient : public IBinder::DeathRecipient { + public: + PMDeathRecipient(void *obj){parentClass = (LPAPlayer *)obj;} + virtual ~PMDeathRecipient() {} + + // IBinder::DeathRecipient + virtual void binderDied(const wp<IBinder>& who); + + private: + LPAPlayer *parentClass; + PMDeathRecipient(const PMDeathRecipient&); + PMDeathRecipient& operator = (const PMDeathRecipient&); + + friend class LPAPlayer; + }; + + friend class PMDeathRecipient; + + void acquireWakeLock(); + void releaseWakeLock(); + + sp<IPowerManager> mPowerManager; + sp<IBinder> mWakeLockToken; + sp<PMDeathRecipient> mDeathRecipient; + + pthread_t decoderThread; + + pthread_t A2DPNotificationThread; + + //Kill Thread boolean + bool killDecoderThread; + + + + bool killA2DPNotificationThread; + + //Thread alive boolean + bool decoderThreadAlive; + + + bool a2dpNotificationThreadAlive; + + //Declare the condition Variables and Mutex + + pthread_mutex_t decoder_mutex; + + pthread_mutex_t audio_sink_setup_mutex; + + pthread_mutex_t a2dp_notification_mutex; + + + + pthread_cond_t decoder_cv; + + + pthread_cond_t a2dp_notification_cv; + + + // make sure Decoder thread has exited + void requestAndWaitForDecoderThreadExit(); + + + // make sure the Effects thread also exited + void requestAndWaitForA2DPNotificationThreadExit(); + + static void *decoderThreadWrapper(void *me); + void decoderThreadEntry(); + static void *A2DPNotificationThreadWrapper(void *me); + void A2DPNotificationThreadEntry(); + + void createThreads(); + + volatile bool mIsA2DPEnabled; + + //Structure to recieve the BT notification from the flinger. + class AudioFlingerLPAdecodeClient: public IBinder::DeathRecipient, public BnAudioFlingerClient { + public: + AudioFlingerLPAdecodeClient(void *obj); + + LPAPlayer *pBaseClass; + // DeathRecipient + virtual void binderDied(const wp<IBinder>& who); + + // IAudioFlingerClient + + // indicate a change in the configuration of an output or input: keeps the cached + // values for output/input parameters upto date in client process + virtual void ioConfigChanged(int event, audio_io_handle_t ioHandle, const void *param2); + + friend class LPAPlayer; + }; + + sp<IAudioFlinger> mAudioFlinger; + + // helper function to obtain AudioFlinger service handle + void getAudioFlinger(); + + void handleA2DPSwitch(); + void onPauseTimeOut(); + + sp<AudioFlingerLPAdecodeClient> AudioFlingerClient; + friend class AudioFlingerLPAdecodeClient; + Mutex AudioFlingerLock; + sp<MediaSource> mSource; + + MediaBuffer *mInputBuffer; + + Mutex mLock; + Mutex mResumeLock; + + 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); + + enum A2DPState { + A2DP_ENABLED, + A2DP_DISABLED, + A2DP_CONNECT, + A2DP_DISCONNECT + }; + + int64_t getTimeStamp(A2DPState state); + + 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); + + 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_ + diff --git a/include/media/stagefright/MediaDebug.h b/include/media/stagefright/MediaDebug.h new file mode 100644 index 0000000..bcaeeba --- /dev/null +++ b/include/media/stagefright/MediaDebug.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. + * + * Not a Contribution, Apache license notifications and license are retained + * for attribution purposes only + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MEDIA_DEBUG_H_ + +#define MEDIA_DEBUG_H_ + +#include <cutils/log.h> + +#define LITERAL_TO_STRING_INTERNAL(x) #x +#define LITERAL_TO_STRING(x) LITERAL_TO_STRING_INTERNAL(x) + +#define CHECK_EQ(x,y) \ + LOG_ALWAYS_FATAL_IF( \ + (x) != (y), \ + __FILE__ ":" LITERAL_TO_STRING(__LINE__) " " #x " != " #y) + +#define CHECK(x) \ + LOG_ALWAYS_FATAL_IF( \ + !(x), \ + __FILE__ ":" LITERAL_TO_STRING(__LINE__) " " #x) + +#endif // MEDIA_DEBUG_H_ diff --git a/include/media/stagefright/MediaDefs.h b/include/media/stagefright/MediaDefs.h index 457d5d7..f63926c 100644 --- a/include/media/stagefright/MediaDefs.h +++ b/include/media/stagefright/MediaDefs.h @@ -31,6 +31,7 @@ extern const char *MEDIA_MIMETYPE_VIDEO_RAW; extern const char *MEDIA_MIMETYPE_AUDIO_AMR_NB; extern const char *MEDIA_MIMETYPE_AUDIO_AMR_WB; +extern const char *MEDIA_MIMETYPE_AUDIO_AMR_WB_PLUS; extern const char *MEDIA_MIMETYPE_AUDIO_MPEG; // layer III extern const char *MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_I; extern const char *MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II; diff --git a/include/media/stagefright/MediaExtractor.h b/include/media/stagefright/MediaExtractor.h index 94090ee..a458284 100644 --- a/include/media/stagefright/MediaExtractor.h +++ b/include/media/stagefright/MediaExtractor.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 The Android Open Source Project + * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,6 +50,7 @@ public: CAN_SEEK_FORWARD = 2, // the "seek 10secs forward button" CAN_PAUSE = 4, CAN_SEEK = 8, // the "seek bar" + CAN_SEEK_TO_ZERO = 16, // the "previous button" }; // If subclasses do _not_ override this, the default is diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h index 583c3b3..bdd35a4 100644 --- a/include/media/stagefright/OMXCodec.h +++ b/include/media/stagefright/OMXCodec.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 The Android Open Source Project + * Copyright (c) 2010 - 2012, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,9 @@ #include <media/IOMX.h> #include <media/stagefright/MediaBuffer.h> #include <media/stagefright/MediaSource.h> +#ifdef QCOM_HARDWARE +#include <media/stagefright/QCOMXCodec.h> +#endif #include <utils/threads.h> #include <OMX_Audio.h> @@ -100,6 +104,13 @@ struct OMXCodec : public MediaSource, kSupportsMultipleFramesPerInputBuffer = 1024, kRequiresLargerEncoderOutputBuffer = 2048, kOutputBuffersAreUnreadable = 4096, +#ifdef QCOM_HARDWARE + kRequiresGlobalFlush = 0x20000000, // 2^29 + kRequiresWMAProComponent = 0x40000000, //2^30 +#endif +#if defined(OMAP_ENHANCEMENT) + kAvoidMemcopyInputRecordingFrames = 0x20000000, +#endif }; struct CodecNameAndQuirks { @@ -127,6 +138,11 @@ private: // Make sure mLock is accessible to OMXCodecObserver friend class OMXCodecObserver; +#ifdef QCOM_HARDWARE + // QCOMXCodec can access variables of OMXCodec + friend class QCOMXCodec; +#endif + // Call this with mLock hold void on_message(const omx_message &msg); @@ -143,6 +159,9 @@ private: }; enum { +#ifdef QCOM_HARDWARE + kPortIndexBoth = -1, +#endif kPortIndexInput = 0, kPortIndexOutput = 1 }; @@ -250,6 +269,11 @@ private: void setG711Format(int32_t numChannels); +#ifdef QCOM_HARDWARE + void setEVRCFormat( int32_t sampleRate, int32_t numChannels, int32_t bitRate); + void setQCELPFormat( int32_t sampleRate, int32_t numChannels, int32_t bitRate); +#endif + status_t setVideoPortFormatType( OMX_U32 portIndex, OMX_VIDEO_CODINGTYPE compressionFormat, @@ -291,6 +315,9 @@ private: status_t allocateBuffers(); status_t allocateBuffersOnPort(OMX_U32 portIndex); +#ifdef USE_SAMSUNG_COLORFORMAT + void setNativeWindowColorFormat(OMX_COLOR_FORMATTYPE &eNativeColorFormat); +#endif status_t allocateOutputBuffersFromNativeWindow(); status_t queueBufferToNativeWindow(BufferInfo *info); @@ -344,6 +371,9 @@ private: void dumpPortStatus(OMX_U32 portIndex); status_t configureCodec(const sp<MetaData> &meta); +#if defined(OMAP_ENHANCEMENT) + void restorePatchedDataPointer(BufferInfo *info); +#endif status_t applyRotation(); status_t waitForBufferFilled_l(); @@ -358,6 +388,11 @@ private: OMXCodec(const OMXCodec &); OMXCodec &operator=(const OMXCodec &); + +#ifdef QCOM_HARDWARE + status_t setWMAFormat(const sp<MetaData> &inputFormat); + void setAC3Format(int32_t numChannels, int32_t sampleRate); +#endif }; struct CodecCapabilities { diff --git a/include/media/stagefright/QCOMXCodec.h b/include/media/stagefright/QCOMXCodec.h new file mode 100644 index 0000000..485c187 --- /dev/null +++ b/include/media/stagefright/QCOMXCodec.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2012, 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 QC_OMX_CODEC_H_ + +#define QC_OMX_CODEC_H_ + +#include <android/native_window.h> +#include <media/IOMX.h> +#include <media/stagefright/MediaBuffer.h> +#include <media/stagefright/MediaSource.h> +#include <media/stagefright/foundation/AString.h> +#include <utils/threads.h> + +#include <OMX_Audio.h> + +namespace android { + +struct MediaCodecList; +struct OMXCodec; + +enum{ + kRequiresWMAProComponent = 0x40000000, +}; + + +struct QCOMXCodec { + + static uint32_t getQCComponentQuirks(const MediaCodecList *list, size_t index); + + static status_t configureDIVXCodec(const sp<MetaData> &meta, char* mime, + sp<IOMX> OMXhandle,IOMX::node_id nodeID, int port_index); + + static status_t setQCFormat(const sp<MetaData> &meta, char* mime, + sp<IOMX> OMXhandle,IOMX::node_id nodeID, + OMXCodec *handle, bool isEncoder); + + static status_t setWMAFormat(const sp<MetaData> &meta, sp<IOMX> OMXhandle, + IOMX::node_id nodeID, bool isEncoder ); + + static status_t setQCVideoInputFormat(const char *mime, + OMX_VIDEO_CODINGTYPE *compressionFormat); + + static status_t setQCVideoOutputFormat(const char *mime, + OMX_VIDEO_CODINGTYPE *compressionFormat); + + static status_t checkQCFormats(int format, AString* meta); + + static void setASFQuirks(uint32_t quirks, const sp<MetaData> &meta, + const char* componentName); + + static void checkAndAddRawFormat(OMXCodec *handle, const sp<MetaData> &meta); + + static void setEVRCFormat(int32_t numChannels, int32_t sampleRate, + sp<IOMX> OMXhandle, IOMX::node_id nodeID, + OMXCodec *handle, bool isEncoder ); + + static void setQCELPFormat(int32_t numChannels, int32_t sampleRate, + sp<IOMX> OMXhandle, IOMX::node_id nodeID, + OMXCodec *handle, bool isEncoder ); + + static void setAC3Format(int32_t numChannels, int32_t sampleRate, + sp<IOMX> OMXhandle, IOMX::node_id nodeID); + + static void checkQCRole(const sp<IOMX> &omx, IOMX::node_id node, + bool isEncoder,const char *mime); + + static void setQCSpecificVideoFormat(const sp<MetaData> &meta, sp<IOMX> OMXhandle, + IOMX::node_id nodeID, char* componentName ); + +}; + +} +#endif /*QC_OMX_CODEC_H_ */ + diff --git a/include/media/stagefright/TunnelPlayer.h b/include/media/stagefright/TunnelPlayer.h new file mode 100644 index 0000000..04cc750 --- /dev/null +++ b/include/media/stagefright/TunnelPlayer.h @@ -0,0 +1,250 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved. + * Not a Contribution, Apache license notifications and license are retained + * for attribution purposes only. + * + * + * 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 TUNNEL_PLAYER_H_ + +#define TUNNEL_PLAYER_H_ + +#include "AudioPlayer.h" +#include <media/IAudioFlinger.h> +#include <utils/threads.h> +#include <utils/List.h> +#include <utils/Vector.h> +#include <fcntl.h> +#include <pthread.h> +#include <binder/IServiceManager.h> +#include <linux/unistd.h> +#include <include/TimedEventQueue.h> +#include <binder/BinderService.h> +#include <binder/MemoryDealer.h> +#include <powermanager/IPowerManager.h> + +// Pause timeout = 3sec +#define TUNNEL_PAUSE_TIMEOUT_USEC 3000000 +namespace android { + +class TunnelPlayer : public AudioPlayer { +public: + enum { + REACHED_EOS, + SEEK_COMPLETE + }; + + TunnelPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink, bool &initCheck, + AwesomePlayer *audioObserver = NULL, bool hasVideo = false); + + virtual ~TunnelPlayer(); + + // 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 void 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 TunnelPlayer + // 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 mTunnelObjectsAlive; +private: + int64_t mPositionTimeMediaUs; + int64_t mPositionTimeRealUs; + bool mInternalSeeking; + bool mIsAudioRouted; + bool mStarted; + bool mPaused; + bool mA2DPEnabled; + int32_t mChannelMask; + int32_t numChannels; + int32_t mSampleRate; + int64_t mLatencyUs; + size_t mFrameSize; + int64_t mNumFramesPlayed; + int64_t mNumFramesPlayedSysTimeUs; + audio_format_t mFormat; + bool mHasVideo; + void clearPowerManager(); + + class PMDeathRecipient : public IBinder::DeathRecipient { + public: + PMDeathRecipient(void *obj){parentClass = (TunnelPlayer *)obj;} + virtual ~PMDeathRecipient() {} + + // IBinder::DeathRecipient + virtual void binderDied(const wp<IBinder>& who); + + private: + TunnelPlayer *parentClass; + PMDeathRecipient(const PMDeathRecipient&); + PMDeathRecipient& operator = (const PMDeathRecipient&); + + friend class TunnelPlayer; + }; + + friend class PMDeathRecipient; + + void acquireWakeLock(); + void releaseWakeLock(); + + sp<IPowerManager> mPowerManager; + sp<IBinder> mWakeLockToken; + sp<PMDeathRecipient> mDeathRecipient; + + pthread_t extractorThread; + + //Kill Thread boolean + bool killExtractorThread; + + //Thread alive boolean + bool extractorThreadAlive; + + + //Declare the condition Variables and Mutex + + pthread_mutex_t extractor_mutex; + pthread_cond_t extractor_cv; + + + // make sure Decoder thread has exited + void requestAndWaitForExtractorThreadExit(); + + + static void *extractorThreadWrapper(void *me); + void extractorThreadEntry(); + + void createThreads(); + + volatile bool mIsA2DPEnabled; + + //Structure to recieve the BT notification from the flinger. + class AudioFlingerTunneldecodeClient: public IBinder::DeathRecipient, public BnAudioFlingerClient { + public: + AudioFlingerTunneldecodeClient(void *obj); + + TunnelPlayer *pBaseClass; + // DeathRecipient + virtual void binderDied(const wp<IBinder>& who); + + // IAudioFlingerClient + + // indicate a change in the configuration of an output or input: keeps the cached + // values for output/input parameters upto date in client process + virtual void ioConfigChanged(int event, audio_io_handle_t ioHandle, const void *param2); + + friend class TunnelPlayer; + }; + + sp<IAudioFlinger> mAudioFlinger; + + // helper function to obtain AudioFlinger service handle + void getAudioFlinger(); + void onPauseTimeOut(); + + sp<AudioFlingerTunneldecodeClient> mAudioFlingerClient; + friend class AudioFlingerTunneldecodeClient; + Mutex mAudioFlingerLock; + sp<MediaSource> mSource; + + MediaBuffer *mInputBuffer; + + Mutex pmLock; + 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; + + static size_t AudioSinkCallback( + MediaPlayerBase::AudioSink *audioSink, + void *data, size_t size, void *me); + + enum A2DPState { + A2DP_ENABLED, + A2DP_DISABLED, + A2DP_CONNECT, + A2DP_DISCONNECT + }; + + void getPlayedTimeFromDSP_l(int64_t *timeStamp); + void getOffsetRealTime_l(int64_t *offsetTime); + + size_t fillBuffer(void *data, size_t size); + + void reset(); + + TunnelPlayer(const TunnelPlayer &); + TunnelPlayer &operator=(const TunnelPlayer &); +}; + +struct TunnelEvent : public TimedEventQueue::Event { + TunnelEvent(TunnelPlayer *player, + void (TunnelPlayer::*method)()) + : mPlayer(player), + mMethod(method) { + } + +protected: + virtual ~TunnelEvent() {} + + virtual void fire(TimedEventQueue *queue, int64_t /* now_us */) { + (mPlayer->*mMethod)(); + } + +private: + TunnelPlayer *mPlayer; + void (TunnelPlayer::*mMethod)(); + + TunnelEvent(const TunnelEvent &); + TunnelEvent &operator=(const TunnelEvent &); +}; + +} // namespace android + +#endif // LPA_PLAYER_H_ diff --git a/include/media/stagefright/WAVEWriter.h b/include/media/stagefright/WAVEWriter.h new file mode 100644 index 0000000..766d8f4 --- /dev/null +++ b/include/media/stagefright/WAVEWriter.h @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2012, 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 WAVE_WRITER_H_ + +#define WAVE_WRITER_H_ + +#include <stdio.h> + +#include <media/stagefright/MediaWriter.h> +#include <utils/threads.h> + +namespace android { + + +#define ID_RIFF 0x46464952 +#define ID_WAVE 0x45564157 +#define ID_FMT 0x20746d66 +#define ID_DATA 0x61746164 +#define FORMAT_PCM 1 + + +struct MediaSource; +struct MetaData; + +struct wav_header { + uint32_t riff_id; + uint32_t riff_sz; + uint32_t riff_fmt; + uint32_t fmt_id; + uint32_t fmt_sz; + uint16_t audio_format; + uint16_t num_channels; + uint32_t sample_rate; + uint32_t byte_rate; /* sample_rate * num_channels * bps / 8 */ + uint16_t block_align; /* num_channels * bps / 8 */ + uint16_t bits_per_sample; + uint32_t data_id; + uint32_t data_sz; +}; + + +struct WAVEWriter : public MediaWriter { + WAVEWriter(const char *filename); + WAVEWriter(int fd); + + status_t initCheck() const; + + virtual status_t addSource(const sp<MediaSource> &source); + virtual bool reachedEOS(); + virtual status_t start(MetaData *params = NULL); + virtual status_t stop(); + virtual status_t pause(); + +protected: + virtual ~WAVEWriter(); + +private: + int mFd; + status_t mInitCheck; + sp<MediaSource> mSource; + bool mStarted; + volatile bool mPaused; + volatile bool mResumed; + volatile bool mDone; + volatile bool mReachedEOS; + pthread_t mThread; + int64_t mEstimatedSizeBytes; + int64_t mEstimatedDurationUs; + + static void *ThreadWrapper(void *); + status_t threadFunc(); + bool exceedsFileSizeLimit(); + bool exceedsFileDurationLimit(); + + WAVEWriter(const WAVEWriter &); + WAVEWriter &operator=(const WAVEWriter &); +}; + +} // namespace android + +#endif // WAVE_WRITER_H_ |