From 4957cf29ab15ef237fa671e4ea56daf4d88ea762 Mon Sep 17 00:00:00 2001 From: Alan Marchesan Date: Thu, 21 Jun 2012 13:12:59 +0200 Subject: [PATCH] merge allwinner code (part 1) --- Android.mk | 1 + api/current.txt | 246 +++++ build/tablet-dalvik-heap.mk | 2 +- core/java/android/app/ContextImpl.java | 6 + core/java/android/content/Context.java | 10 + core/java/android/content/Intent.java | 24 + core/java/android/hardware/Camera.java | 2 + core/java/android/provider/MediaStore.java | 5 + core/java/android/view/DisplayManager.aidl | 21 + core/java/android/view/DisplayManager.java | 398 ++++++++ core/java/android/view/IDisplayManager.aidl | 54 ++ core/java/android/view/MotionEvent.java | 5 + core/jni/android_hardware_Camera.cpp | 12 + core/jni/android_view_MotionEvent.cpp | 10 + include/camera/Camera.h | 3 + include/camera/ICameraService.h | 4 +- include/gui/ISurfaceTexture.h | 2 + include/gui/SurfaceTexture.h | 4 + include/gui/SurfaceTextureClient.h | 4 + include/media/IMediaPlayer.h | 45 + include/media/IMediaPlayerClient.h | 5 + include/media/IMediaPlayerService.h | 28 + include/media/MediaPlayerInterface.h | 254 +++++ include/media/mediaplayer.h | 96 ++ include/media/mediaplayerinfo.h | 122 +++ include/media/stagefright/ACodec.h | 3 + include/media/stagefright/AudioPlayer.h | 18 +- include/media/stagefright/CedarAAudioPlayer.h | 120 +++ include/media/stagefright/CedarXAudioPlayer.h | 127 +++ .../media/stagefright/CedarXMediaScanner.h | 46 + include/media/stagefright/MediaSource.h | 1 + include/media/stagefright/MetaData.h | 2 + .../media/stagefright/SurfaceMediaSource.h | 4 + include/media/stagefright/openmax/OMX_Core.h | 2 + include/media/stagefright/openmax/OMX_Index.h | 5 + include/surfaceflinger/ISurfaceComposer.h | 5 + .../surfaceflinger/SurfaceComposerClient.h | 3 + include/ui/DisplayDispatcher.h | 123 +++ include/ui/DisplaySemaphore.h | 63 ++ include/ui/Input.h | 3 + libs/camera/Camera.cpp | 10 + libs/camera/ICameraService.cpp | 18 + libs/gui/ISurfaceComposer.cpp | 46 + libs/gui/ISurfaceTexture.cpp | 100 +- libs/gui/SurfaceComposerClient.cpp | 14 + libs/gui/SurfaceTexture.cpp | 46 +- libs/gui/SurfaceTextureClient.cpp | 57 +- libs/ui/Android.mk | 2 + libs/ui/DisplayDispatcher.cpp | 531 +++++++++++ libs/ui/DisplaySemaphore.cpp | 126 +++ libs/ui/Input.cpp | 23 + media/java/android/media/MediaFile.java | 42 +- media/java/android/media/MediaPlayer.java | 568 ++++++++++- media/jni/android_media_MediaPlayer.cpp | 774 +++++++++++++++ media/libmedia/IMediaPlayer.cpp | 638 +++++++++++++ media/libmedia/IMediaPlayerService.cpp | 218 +++++ media/libmedia/mediaplayer.cpp | 569 +++++++++++ media/libmediaplayerservice/Android.mk | 13 +- .../CedarAPlayerWrapper.cpp | 211 ++++ .../CedarAPlayerWrapper.h | 77 ++ media/libmediaplayerservice/CedarPlayer.cpp | 417 ++++++++ media/libmediaplayerservice/CedarPlayer.h | 121 +++ .../MediaPlayerService.cpp | 901 +++++++++++++++++- .../MediaPlayerService.h | 136 +++ .../MetadataRetrieverClient.cpp | 9 +- .../SimpleMediaFormatProbe.cpp | 616 ++++++++++++ .../SimpleMediaFormatProbe.h | 54 ++ .../StagefrightRecorder.cpp | 132 ++- .../StagefrightRecorder.h | 5 + .../nuplayer/HTTPLiveSource.cpp | 11 +- .../nuplayer/HTTPLiveSource.h | 3 +- .../nuplayer/NuPlayer.cpp | 28 +- .../nuplayer/NuPlayerDriver.cpp | 5 + .../nuplayer/NuPlayerDriver.h | 1 + .../nuplayer/NuPlayerRenderer.cpp | 2 +- .../nuplayer/NuPlayerSource.h | 2 +- media/libstagefright/ACodec.cpp | 88 +- media/libstagefright/Android.mk | 4 +- media/libstagefright/MPEG4Extractor.cpp | 55 +- media/libstagefright/MPEG4Writer.cpp | 41 +- media/libstagefright/OMXCodec.cpp | 27 +- 81 files changed, 8505 insertions(+), 124 deletions(-) create mode 100644 core/java/android/view/DisplayManager.aidl create mode 100644 core/java/android/view/DisplayManager.java create mode 100644 core/java/android/view/IDisplayManager.aidl create mode 100644 include/media/mediaplayerinfo.h create mode 100644 include/media/stagefright/CedarAAudioPlayer.h create mode 100644 include/media/stagefright/CedarXAudioPlayer.h create mode 100644 include/media/stagefright/CedarXMediaScanner.h create mode 100644 include/ui/DisplayDispatcher.h create mode 100644 include/ui/DisplaySemaphore.h create mode 100644 libs/ui/DisplayDispatcher.cpp create mode 100644 libs/ui/DisplaySemaphore.cpp create mode 100644 media/libmediaplayerservice/CedarAPlayerWrapper.cpp create mode 100644 media/libmediaplayerservice/CedarAPlayerWrapper.h create mode 100644 media/libmediaplayerservice/CedarPlayer.cpp create mode 100644 media/libmediaplayerservice/CedarPlayer.h create mode 100644 media/libmediaplayerservice/SimpleMediaFormatProbe.cpp create mode 100644 media/libmediaplayerservice/SimpleMediaFormatProbe.h diff --git a/Android.mk b/Android.mk index 0e5320c8d7050..8bff1bb6e52a9 100644 --- a/Android.mk +++ b/Android.mk @@ -141,6 +141,7 @@ LOCAL_SRC_FILES += \ core/java/android/view/IWindow.aidl \ core/java/android/view/IWindowManager.aidl \ core/java/android/view/IWindowSession.aidl \ + core/java/android/view/IDisplayManager.aidl \ core/java/android/speech/IRecognitionListener.aidl \ core/java/android/speech/IRecognitionService.aidl \ core/java/android/speech/tts/ITextToSpeechCallback.aidl \ diff --git a/api/current.txt b/api/current.txt index 405c7954426f6..7055fb3167c68 100644 --- a/api/current.txt +++ b/api/current.txt @@ -5109,6 +5109,7 @@ package android.content { field public static final int CONTEXT_INCLUDE_CODE = 1; // 0x1 field public static final int CONTEXT_RESTRICTED = 4; // 0x4 field public static final java.lang.String DEVICE_POLICY_SERVICE = "device_policy"; + field public static final java.lang.String DISPLAY_SERVICE = "display"; field public static final java.lang.String DOWNLOAD_SERVICE = "download"; field public static final java.lang.String DROPBOX_SERVICE = "dropbox"; field public static final java.lang.String INPUT_METHOD_SERVICE = "input_method"; @@ -5440,6 +5441,7 @@ package android.content { field public static final java.lang.String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; field public static final java.lang.String ACTION_GTALK_SERVICE_CONNECTED = "android.intent.action.GTALK_CONNECTED"; field public static final java.lang.String ACTION_GTALK_SERVICE_DISCONNECTED = "android.intent.action.GTALK_DISCONNECTED"; + field public static final java.lang.String ACTION_HDMISTATUS_CHANGED = "android.intent.action.HDMISTATUS_CHANGED"; field public static final java.lang.String ACTION_HEADSET_PLUG = "android.intent.action.HEADSET_PLUG"; field public static final java.lang.String ACTION_INPUT_METHOD_CHANGED = "android.intent.action.INPUT_METHOD_CHANGED"; field public static final java.lang.String ACTION_INSERT = "android.intent.action.INSERT"; @@ -5497,6 +5499,7 @@ package android.content { field public static final java.lang.String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED"; field public static final java.lang.String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET"; field public static final java.lang.String ACTION_TIME_TICK = "android.intent.action.TIME_TICK"; + field public static final java.lang.String ACTION_TVDACSTATUS_CHANGED = "android.intent.action.TVDACSTATUS_CHANGED"; field public static final java.lang.String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; field public static final deprecated java.lang.String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED"; field public static final deprecated java.lang.String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED"; @@ -9281,6 +9284,7 @@ package android.hardware { method public static android.hardware.Camera open(); method public final void reconnect() throws java.io.IOException; method public final void release(); + method public static int setCameraScreen(int); method public final void setDisplayOrientation(int); method public final void setErrorCallback(android.hardware.Camera.ErrorCallback); method public final void setFaceDetectionListener(android.hardware.Camera.FaceDetectionListener); @@ -10739,42 +10743,177 @@ package android.media { method public static android.media.MediaPlayer create(android.content.Context, android.net.Uri); method public static android.media.MediaPlayer create(android.content.Context, android.net.Uri, android.view.SurfaceHolder); method public static android.media.MediaPlayer create(android.content.Context, int); + method public void enableScaleMode(boolean, int, int); + method public int getAnaglaghType(); + method public int getAudioBitRate(); + method public java.lang.String getAudioEncode(); + method public int getAudioSampleRate(); method public int getAudioSessionId(); + method public static int getBlackExtend(); + method public static int getChromaSharp(); + method public int getCurSub(); + method public int getCurTrack(); method public int getCurrentPosition(); method public int getDuration(); + method public int getInputDimensionType(); + method public static int getLumaSharp(); + method public int getOutputDimensionType(); + method public static int getScreen(); + method public java.lang.String getSubCharset(); + method public int getSubColor(); + method public int getSubDelay(); + method public int getSubFontSize(); + method public int getSubFrameColor(); + method public boolean getSubGate(); + method public android.media.MediaPlayer.SubInfo[] getSubList(); + method public int getSubPosition(); + method public android.media.MediaPlayer.TrackInfo[] getTrackList(); + method public java.lang.String getVideoEncode(); + method public int getVideoFrameRate(); method public int getVideoHeight(); method public int getVideoWidth(); + method public static boolean getVppGate(); + method public static int getWhiteExtend(); method public boolean isLooping(); method public boolean isPlaying(); + method public static boolean isPlayingVideo(); method public void pause() throws java.lang.IllegalStateException; method public void prepare() throws java.io.IOException, java.lang.IllegalStateException; method public void prepareAsync() throws java.lang.IllegalStateException; method public void release(); method public void reset(); method public void seekTo(int) throws java.lang.IllegalStateException; + method public int setAnaglaghType(int); method public void setAudioSessionId(int) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException; method public void setAudioStreamType(int); method public void setAuxEffectSendLevel(float); + method public static int setBlackExtend(int); + method public static int setChromaSharp(int); method public void setDataSource(android.content.Context, android.net.Uri) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; method public void setDataSource(java.lang.String) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; method public void setDataSource(java.io.FileDescriptor) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException; method public void setDataSource(java.io.FileDescriptor, long, long) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException; method public void setDisplay(android.view.SurfaceHolder); + method public int setInputDimensionType(int); method public void setLooping(boolean); + method public static int setLumaSharp(int); method public void setOnBufferingUpdateListener(android.media.MediaPlayer.OnBufferingUpdateListener); method public void setOnCompletionListener(android.media.MediaPlayer.OnCompletionListener); method public void setOnErrorListener(android.media.MediaPlayer.OnErrorListener); method public void setOnInfoListener(android.media.MediaPlayer.OnInfoListener); + method public void setOnParse3dFileListener(android.media.MediaPlayer.OnParse3dFileListener); method public void setOnPreparedListener(android.media.MediaPlayer.OnPreparedListener); method public void setOnSeekCompleteListener(android.media.MediaPlayer.OnSeekCompleteListener); method public void setOnVideoSizeChangedListener(android.media.MediaPlayer.OnVideoSizeChangedListener); + method public int setOutputDimensionType(int); + method public static void setScreen(int) throws java.lang.IllegalStateException; method public void setScreenOnWhilePlaying(boolean); + method public int setSubCharset(java.lang.String); + method public int setSubColor(int); + method public int setSubDelay(int); + method public int setSubFontSize(int); + method public int setSubFrameColor(int); + method public int setSubGate(boolean); + method public int setSubPosition(int); method public void setSurface(android.view.Surface); method public void setVolume(float, float); + method public static int setVppGate(boolean); method public void setWakeMode(android.content.Context, int); + method public static int setWhiteExtend(int); method public void start() throws java.lang.IllegalStateException; method public void stop() throws java.lang.IllegalStateException; + method public int switchSub(int); + method public int switchTrack(int); + field public static final int ANAGLAGH_COLOR = 3; // 0x3 + field public static final int ANAGLAGH_HALF_COLOR = 4; // 0x4 + field public static final int ANAGLAGH_OPTIMIZED = 5; // 0x5 + field public static final int ANAGLAGH_RED_BLUE = 0; // 0x0 + field public static final int ANAGLAGH_RED_CYAN = 2; // 0x2 + field public static final int ANAGLAGH_RED_GREEN = 1; // 0x1 + field public static final int ANAGLAGH_YELLOW_BLUE = 6; // 0x6 + field public static final java.lang.String CHARSET_BIG5 = "Big5"; + field public static final java.lang.String CHARSET_BIG5_HKSCS = "Big5-HKSCS"; + field public static final java.lang.String CHARSET_BOCU_1 = "BOCU-1"; + field public static final java.lang.String CHARSET_CESU_8 = "CESU-8"; + field public static final java.lang.String CHARSET_CP864 = "cp864"; + field public static final java.lang.String CHARSET_EUC_JP = "EUC-JP"; + field public static final java.lang.String CHARSET_EUC_KR = "EUC-KR"; + field public static final java.lang.String CHARSET_GB18030 = "GB18030"; + field public static final java.lang.String CHARSET_GBK = "GBK"; + field public static final java.lang.String CHARSET_HZ_GB_2312 = "HZ-GB-2312"; + field public static final java.lang.String CHARSET_ISO_2022_CN = "ISO-2022-CN"; + field public static final java.lang.String CHARSET_ISO_2022_CN_EXT = "ISO-2022-CN-EXT"; + field public static final java.lang.String CHARSET_ISO_2022_JP = "ISO-2022-JP"; + field public static final java.lang.String CHARSET_ISO_2022_KR = "ISO-2022-KR"; + field public static final java.lang.String CHARSET_ISO_8859_1 = "ISO-8859-1"; + field public static final java.lang.String CHARSET_ISO_8859_10 = "ISO-8859-10"; + field public static final java.lang.String CHARSET_ISO_8859_13 = "ISO-8859-13"; + field public static final java.lang.String CHARSET_ISO_8859_14 = "ISO-8859-14"; + field public static final java.lang.String CHARSET_ISO_8859_15 = "ISO-8859-15"; + field public static final java.lang.String CHARSET_ISO_8859_16 = "ISO-8859-16"; + field public static final java.lang.String CHARSET_ISO_8859_2 = "ISO-8859-2"; + field public static final java.lang.String CHARSET_ISO_8859_3 = "ISO-8859-3"; + field public static final java.lang.String CHARSET_ISO_8859_4 = "ISO-8859-4"; + field public static final java.lang.String CHARSET_ISO_8859_5 = "ISO-8859-5"; + field public static final java.lang.String CHARSET_ISO_8859_6 = "ISO-8859-6"; + field public static final java.lang.String CHARSET_ISO_8859_7 = "ISO-8859-7"; + field public static final java.lang.String CHARSET_ISO_8859_8 = "ISO-8859-8"; + field public static final java.lang.String CHARSET_ISO_8859_9 = "ISO-8859-9"; + field public static final java.lang.String CHARSET_KOI8_R = "KOI8-R"; + field public static final java.lang.String CHARSET_KOI8_U = "KOI8-U"; + field public static final java.lang.String CHARSET_MACINTOSH = "macintosh"; + field public static final java.lang.String CHARSET_SCSU = "SCSU"; + field public static final java.lang.String CHARSET_SHIFT_JIS = "Shift_JIS"; + field public static final java.lang.String CHARSET_TIS_620 = "TIS-620"; + field public static final java.lang.String CHARSET_UNKNOWN = "UNKNOWN"; + field public static final java.lang.String CHARSET_US_ASCII = "US-ASCII"; + field public static final java.lang.String CHARSET_UTF_16 = "UTF-16"; + field public static final java.lang.String CHARSET_UTF_16BE = "UTF-16BE"; + field public static final java.lang.String CHARSET_UTF_16LE = "UTF-16LE"; + field public static final java.lang.String CHARSET_UTF_32 = "UTF-32"; + field public static final java.lang.String CHARSET_UTF_32BE = "UTF-32BE"; + field public static final java.lang.String CHARSET_UTF_32LE = "UTF-32LE"; + field public static final java.lang.String CHARSET_UTF_7 = "UTF-7"; + field public static final java.lang.String CHARSET_UTF_8 = "UTF-8"; + field public static final java.lang.String CHARSET_WINDOWS_1250 = "windows-1250"; + field public static final java.lang.String CHARSET_WINDOWS_1251 = "windows-1251"; + field public static final java.lang.String CHARSET_WINDOWS_1252 = "windows-1252"; + field public static final java.lang.String CHARSET_WINDOWS_1253 = "windows-1253"; + field public static final java.lang.String CHARSET_WINDOWS_1254 = "windows-1254"; + field public static final java.lang.String CHARSET_WINDOWS_1255 = "windows-1255"; + field public static final java.lang.String CHARSET_WINDOWS_1256 = "windows-1256"; + field public static final java.lang.String CHARSET_WINDOWS_1257 = "windows-1257"; + field public static final java.lang.String CHARSET_WINDOWS_1258 = "windows-1258"; + field public static final java.lang.String CHARSET_X_DOCOMO_SHIFT_JIS_2007 = "x-docomo-shift_jis-2007"; + field public static final java.lang.String CHARSET_X_GSM_03_38_2000 = "x-gsm-03.38-2000"; + field public static final java.lang.String CHARSET_X_IBM_1383_P110_1999 = "x-ibm-1383_P110-1999"; + field public static final java.lang.String CHARSET_X_IMAP_MAILBOX_NAME = "x-IMAP-mailbox-name"; + field public static final java.lang.String CHARSET_X_ISCII_BE = "x-iscii-be"; + field public static final java.lang.String CHARSET_X_ISCII_DE = "x-iscii-de"; + field public static final java.lang.String CHARSET_X_ISCII_GU = "x-iscii-gu"; + field public static final java.lang.String CHARSET_X_ISCII_KA = "x-iscii-ka"; + field public static final java.lang.String CHARSET_X_ISCII_MA = "x-iscii-ma"; + field public static final java.lang.String CHARSET_X_ISCII_OR = "x-iscii-or"; + field public static final java.lang.String CHARSET_X_ISCII_PA = "x-iscii-pa"; + field public static final java.lang.String CHARSET_X_ISCII_TA = "x-iscii-ta"; + field public static final java.lang.String CHARSET_X_ISCII_TE = "x-iscii-te"; + field public static final java.lang.String CHARSET_X_ISO_8859_11_2001 = "x-iso-8859_11-2001"; + field public static final java.lang.String CHARSET_X_JAVAUNICODE = "x-JavaUnicode"; + field public static final java.lang.String CHARSET_X_KDDI_SHIFT_JIS_2007 = "x-kddi-shift_jis-2007"; + field public static final java.lang.String CHARSET_X_MAC_CYRILLIC = "x-mac-cyrillic"; + field public static final java.lang.String CHARSET_X_SOFTBANK_SHIFT_JIS_2007 = "x-softbank-shift_jis-2007"; + field public static final java.lang.String CHARSET_X_UNICODEBIG = "x-UnicodeBig"; + field public static final java.lang.String CHARSET_X_UTF16_OPPOSITEENDIAN = "x-UTF16_OppositeEndian"; + field public static final java.lang.String CHARSET_X_UTF16_PLATFORMENDIAN = "x-UTF16_PlatformEndian"; + field public static final java.lang.String CHARSET_X_UTF32_OPPOSITEENDIAN = "x-UTF32_OppositeEndian"; + field public static final java.lang.String CHARSET_X_UTF32_PLATFORMENDIAN = "x-UTF32_PlatformEndian"; + field public static final java.lang.String CHARSET_X_UTF_16LE_BOM = "x-UTF-16LE-BOM"; + field public static final int DISPLAY_3D_MODE_2D = 0; // 0x0 + field public static final int DISPLAY_3D_MODE_3D = 1; // 0x1 + field public static final int DISPLAY_3D_MODE_ANAGLAGH = 3; // 0x3 + field public static final int DISPLAY_3D_MODE_HALF_PICTURE = 2; // 0x2 + field public static final int MASTER_SCREEN = 0; // 0x0 field public static final int MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200; // 0xc8 field public static final int MEDIA_ERROR_SERVER_DIED = 100; // 0x64 field public static final int MEDIA_ERROR_UNKNOWN = 1; // 0x1 @@ -10785,6 +10924,15 @@ package android.media { field public static final int MEDIA_INFO_NOT_SEEKABLE = 801; // 0x321 field public static final int MEDIA_INFO_UNKNOWN = 1; // 0x1 field public static final int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700; // 0x2bc + field public static final int PICTURE_3D_MODE_COLUME_INTERLEAVE = 5; // 0x5 + field public static final int PICTURE_3D_MODE_DOUBLE_STREAM = 1; // 0x1 + field public static final int PICTURE_3D_MODE_LINE_INTERLEAVE = 4; // 0x4 + field public static final int PICTURE_3D_MODE_NONE = 0; // 0x0 + field public static final int PICTURE_3D_MODE_SIDE_BY_SIDE = 2; // 0x2 + field public static final int PICTURE_3D_MODE_TOP_TO_BOTTOM = 3; // 0x3 + field public static final int SLAVE_SCREEN = 1; // 0x1 + field public static final int SUBTITLE_TYPE_BITMAP = 1; // 0x1 + field public static final int SUBTITLE_TYPE_TEXT = 0; // 0x0 } public static abstract interface MediaPlayer.OnBufferingUpdateListener { @@ -10802,6 +10950,10 @@ package android.media { public static abstract interface MediaPlayer.OnInfoListener { method public abstract boolean onInfo(android.media.MediaPlayer, int, int); } + + public static abstract interface MediaPlayer.OnParse3dFileListener { + method public abstract int onParse3dFile(int); + } public static abstract interface MediaPlayer.OnPreparedListener { method public abstract void onPrepared(android.media.MediaPlayer); @@ -10814,6 +10966,19 @@ package android.media { public static abstract interface MediaPlayer.OnVideoSizeChangedListener { method public abstract void onVideoSizeChanged(android.media.MediaPlayer, int, int); } + + public static class MediaPlayer.SubInfo { + ctor public MediaPlayer.SubInfo(byte[], java.lang.String, int); + field public java.lang.String charset; + field public byte[] name; + field public int type; + } + + public static class MediaPlayer.TrackInfo { + ctor public MediaPlayer.TrackInfo(byte[], java.lang.String); + field public java.lang.String charset; + field public byte[] name; + } public class MediaRecorder { ctor public MediaRecorder(); @@ -17092,6 +17257,9 @@ package android.provider { field public static final java.lang.String INTENT_ACTION_VIDEO_CAMERA = "android.media.action.VIDEO_CAMERA"; field public static final java.lang.String MEDIA_IGNORE_FILENAME = ".nomedia"; field public static final java.lang.String MEDIA_SCANNER_VOLUME = "volume"; + field public static final java.lang.String PLAYLIST_TYPE = "android.intent.extra.playListType"; + field public static final java.lang.String PLAYLIST_TYPE_CUR_FOLDER = "curFolder"; + field public static final java.lang.String PLAYLIST_TYPE_MEDIA_PROVIDER = "mediaProvider"; field public static final java.lang.String UNKNOWN_STRING = ""; } @@ -21881,6 +22049,84 @@ package android.view { method public deprecated int getWidth(); field public static final int DEFAULT_DISPLAY = 0; // 0x0 } + + public class DisplayManager { + ctor public DisplayManager(); + method public int closeDisplay(int); + method public int getDisplayBacklightMode(); + method public int getDisplayCount(); + method public int getDisplayHeight(int); + method public int getDisplayHotPlugStatus(int); + method public int getDisplayMaster(); + method public int getDisplayMode(); + method public boolean getDisplayOpenStatus(int); + method public int getDisplayOutputFormat(int); + method public int getDisplayOutputType(int); + method public int getDisplayPixelFormat(int); + method public int getDisplayWidth(int); + method public int getMaxHdmiMode(); + method public int getMaxWidthDisplay(); + method public int openDisplay(int); + method public int setDisplayBacklightMode(int); + method public int setDisplayMaster(int); + method public int setDisplayMode(int); + method public int setDisplayOutputType(int, int, int); + method public int setDisplayParameter(int, int, int); + field public static final int DISPLAY_DEVICE_OFF = 1; // 0x1 + field public static final int DISPLAY_DEVICE_ON = 0; // 0x0 + field public static final int DISPLAY_DEVICE_PLUGIN = 0; // 0x0 + field public static final int DISPLAY_DEVICE_PLUGOUT = 1; // 0x1 + field public static final int DISPLAY_MODE_DUALDIFF = 2; // 0x2 + field public static final int DISPLAY_MODE_DUALLCD = 1; // 0x1 + field public static final int DISPLAY_MODE_DUALSAME = 3; // 0x3 + field public static final int DISPLAY_MODE_SINGLE = 0; // 0x0 + field public static final int DISPLAY_OUTPUT_TYPE_HDMI = 3; // 0x3 + field public static final int DISPLAY_OUTPUT_TYPE_LCD = 1; // 0x1 + field public static final int DISPLAY_OUTPUT_TYPE_NONE = 0; // 0x0 + field public static final int DISPLAY_OUTPUT_TYPE_TV = 2; // 0x2 + field public static final int DISPLAY_OUTPUT_TYPE_VGA = 4; // 0x4 + field public static final int DISPLAY_TVDAC_CVBS = 2; // 0x2 + field public static final int DISPLAY_TVDAC_NONE = 0; // 0x0 + field public static final int DISPLAY_TVDAC_SVIDEO = 3; // 0x3 + field public static final int DISPLAY_TVDAC_YPBPR = 1; // 0x1 + field public static final int DISPLAY_TVFORMAT_1080I_50HZ = 6; // 0x6 + field public static final int DISPLAY_TVFORMAT_1080I_60HZ = 7; // 0x7 + field public static final int DISPLAY_TVFORMAT_1080P_24HZ = 8; // 0x8 + field public static final int DISPLAY_TVFORMAT_1080P_50HZ = 9; // 0x9 + field public static final int DISPLAY_TVFORMAT_1080P_60HZ = 10; // 0xa + field public static final int DISPLAY_TVFORMAT_480I = 0; // 0x0 + field public static final int DISPLAY_TVFORMAT_480P = 2; // 0x2 + field public static final int DISPLAY_TVFORMAT_576I = 1; // 0x1 + field public static final int DISPLAY_TVFORMAT_576P = 3; // 0x3 + field public static final int DISPLAY_TVFORMAT_720P_50HZ = 4; // 0x4 + field public static final int DISPLAY_TVFORMAT_720P_60HZ = 5; // 0x5 + field public static final int DISPLAY_TVFORMAT_NTSC = 14; // 0xe + field public static final int DISPLAY_TVFORMAT_NTSC_CVBS_SVIDEO = 16; // 0x10 + field public static final int DISPLAY_TVFORMAT_NTSC_SVIDEO = 15; // 0xf + field public static final int DISPLAY_TVFORMAT_PAL = 11; // 0xb + field public static final int DISPLAY_TVFORMAT_PAL_CVBS_SVIDEO = 13; // 0xd + field public static final int DISPLAY_TVFORMAT_PAL_M = 17; // 0x11 + field public static final int DISPLAY_TVFORMAT_PAL_M_CVBS_SVIDEO = 19; // 0x13 + field public static final int DISPLAY_TVFORMAT_PAL_M_SVIDEO = 18; // 0x12 + field public static final int DISPLAY_TVFORMAT_PAL_NC = 20; // 0x14 + field public static final int DISPLAY_TVFORMAT_PAL_NC_CVBS_SVIDEO = 22; // 0x16 + field public static final int DISPLAY_TVFORMAT_PAL_NC_SVIDEO = 21; // 0x15 + field public static final int DISPLAY_TVFORMAT_PAL_SVIDEO = 12; // 0xc + field public static final int DISPLAY_VGA_H1024_V768 = 27; // 0x1b + field public static final int DISPLAY_VGA_H1280_V1024 = 26; // 0x1a + field public static final int DISPLAY_VGA_H1280_V720 = 34; // 0x22 + field public static final int DISPLAY_VGA_H1360_V768 = 25; // 0x19 + field public static final int DISPLAY_VGA_H1440_V900 = 24; // 0x18 + field public static final int DISPLAY_VGA_H1440_V900_RB = 30; // 0x1e + field public static final int DISPLAY_VGA_H1680_V1050 = 23; // 0x17 + field public static final int DISPLAY_VGA_H1680_V1050_RB = 31; // 0x1f + field public static final int DISPLAY_VGA_H1920_V1080 = 33; // 0x21 + field public static final int DISPLAY_VGA_H1920_V1080_RB = 32; // 0x20 + field public static final int DISPLAY_VGA_H640_V480 = 29; // 0x1d + field public static final int DISPLAY_VGA_H800_V600 = 28; // 0x1c + field public static final java.lang.String EXTRA_HDMISTATUS = "hdmistatus"; + field public static final java.lang.String EXTRA_TVSTATUS = "tvdacstatus"; + } public class DragEvent implements android.os.Parcelable { method public int describeContents(); diff --git a/build/tablet-dalvik-heap.mk b/build/tablet-dalvik-heap.mk index 826a380232a0f..bcd4f832309f8 100644 --- a/build/tablet-dalvik-heap.mk +++ b/build/tablet-dalvik-heap.mk @@ -18,5 +18,5 @@ PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.heapstartsize=5m \ - dalvik.vm.heapgrowthlimit=48m \ + dalvik.vm.heapgrowthlimit=64m \ dalvik.vm.heapsize=256m diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 45d0d3a2243da..ec55769db8c62 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -88,6 +88,7 @@ import android.util.Log; import android.view.ContextThemeWrapper; import android.view.WindowManagerImpl; +import android.view.DisplayManager; import android.view.accessibility.AccessibilityManager; import android.view.inputmethod.InputMethodManager; import android.view.textservice.TextServicesManager; @@ -452,6 +453,11 @@ public Object createService(ContextImpl ctx) { IWifiP2pManager service = IWifiP2pManager.Stub.asInterface(b); return new WifiP2pManager(service); }}); + + registerService(DISPLAY_SERVICE, new ServiceFetcher() { + public Object createService(ContextImpl ctx) { + return new DisplayManager(); + }}); registerService(WINDOW_SERVICE, new ServiceFetcher() { public Object getService(ContextImpl ctx) { diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index bfbd0ac5ed05c..18f1d07c71276 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -1680,6 +1680,16 @@ public abstract boolean startInstrumentation(ComponentName className, * @see android.telephony.TelephonyManager */ public static final String TELEPHONY_SERVICE = "phone"; + + /** + * Use with {@link #getSystemService} to retrieve a + * {@link android.telephony.TelephonyManager} for handling management the + * display features of the device. + * + * @see #getSystemService + * @see android.view.DisplayManager + */ + public static final String DISPLAY_SERVICE = "display"; /** * Use with {@link #getSystemService} to retrieve a diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 5abc4db6b1d0e..cd2c3f1617f62 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -1715,6 +1715,30 @@ public static Intent createChooser(Intent target, CharSequence title) { */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN"; + /** + * Broadcast Action: HDMI Hotplug Changed. + * This is broadcast when the hdmi hotplug status (completely turned + * off, not sleeping). Once the broadcast is complete, the final shutdown + * will proceed and all unsaved data lost. Apps will not normally need + * to handle this, since the foreground activity will be paused as well. + * + *

This is a protected intent that can only be sent + * by the system. + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_HDMISTATUS_CHANGED = "android.intent.action.HDMISTATUS_CHANGED"; + /** + * Broadcast Action: tvdac Hotplug Changed. + * This is broadcast when the tvdac hotplug status (completely turned + * off, not sleeping). Once the broadcast is complete, the final shutdown + * will proceed and all unsaved data lost. Apps will not normally need + * to handle this, since the foreground activity will be paused as well. + * + *

This is a protected intent that can only be sent + * by the system. + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_TVDACSTATUS_CHANGED = "android.intent.action.TVDACSTATUS_CHANGED"; /** * Activity Action: Start this activity to request system shutdown. * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index 86725acb29a61..d12d88c4266ee 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -4628,4 +4628,6 @@ private boolean same(String s1, String s2) { return false; } }; + + public static native int setCameraScreen(int screen); } diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java index 4e016723eba33..f22ed53fb400c 100644 --- a/core/java/android/provider/MediaStore.java +++ b/core/java/android/provider/MediaStore.java @@ -138,6 +138,11 @@ public final class MediaStore { * This is a boolean property that specifies whether or not to show action icons. */ public static final String EXTRA_SHOW_ACTION_ICONS = "android.intent.extra.showActionIcons"; + + //by Bevis, for VideoPlayer to create playlist + public static final String PLAYLIST_TYPE = "android.intent.extra.playListType"; + public static final String PLAYLIST_TYPE_CUR_FOLDER = "curFolder"; + public static final String PLAYLIST_TYPE_MEDIA_PROVIDER = "mediaProvider"; /** * The name of the Intent-extra used to control the onCompletion behavior of a MovieView. diff --git a/core/java/android/view/DisplayManager.aidl b/core/java/android/view/DisplayManager.aidl new file mode 100644 index 0000000000000..ff7047125c77f --- /dev/null +++ b/core/java/android/view/DisplayManager.aidl @@ -0,0 +1,21 @@ +/* //device/java/android/android/view/WindowManager.aidl +** +** Copyright 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. +*/ + +package android.view; + +parcelable DisplayManager; + diff --git a/core/java/android/view/DisplayManager.java b/core/java/android/view/DisplayManager.java new file mode 100644 index 0000000000000..a752a4648cc8d --- /dev/null +++ b/core/java/android/view/DisplayManager.java @@ -0,0 +1,398 @@ +/* + * Copyright (C) 2006 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. + */ + +package android.view; + +import android.content.pm.ActivityInfo; +import android.graphics.PixelFormat; +import android.os.IBinder; +import android.os.Parcel; +import android.os.Parcelable; +import android.text.TextUtils; +import android.util.Log; +import android.content.Context; +import android.os.Binder; +import android.os.RemoteException; +import android.os.IBinder; +import android.os.ServiceManager; +import android.view.IDisplayManager; + +/** + * The interface that apps use to talk to the display manager. + *

+ * Use Context.getSystemService(Context.WINDOW_SERVICE) to get one of these. + * + * @see android.content.Context#getSystemService + * @see android.content.Context#DISPLAY_SERVICE + */ +public class DisplayManager +{ + private static final String TAG = "DisplayManager"; + /** + * Use this method to get the default Display object. + * + * @return default Display object + */ + public static final String EXTRA_HDMISTATUS = "hdmistatus"; + + /** + * Extra for {@link android.content.Intent#ACTION_TVDACSTATUS_CHANGED}: + * integer containing the current health constant. + */ + public static final String EXTRA_TVSTATUS = "tvdacstatus"; + + public static final int DISPLAY_DEVICE_ON = 0; + public static final int DISPLAY_DEVICE_OFF = 1; + + public static final int DISPLAY_DEVICE_PLUGIN = 0; + public static final int DISPLAY_DEVICE_PLUGOUT = 1; + + public static final int DISPLAY_OUTPUT_TYPE_NONE = 0; + public static final int DISPLAY_OUTPUT_TYPE_LCD = 1; + public static final int DISPLAY_OUTPUT_TYPE_TV = 2; + public static final int DISPLAY_OUTPUT_TYPE_HDMI = 3; + public static final int DISPLAY_OUTPUT_TYPE_VGA = 4; + + public static final int DISPLAY_MODE_SINGLE = 0; + public static final int DISPLAY_MODE_DUALLCD = 1; + public static final int DISPLAY_MODE_DUALDIFF = 2; + public static final int DISPLAY_MODE_DUALSAME = 3; + + public static final int DISPLAY_TVDAC_NONE = 0; + public static final int DISPLAY_TVDAC_YPBPR = 1; + public static final int DISPLAY_TVDAC_CVBS = 2; + public static final int DISPLAY_TVDAC_SVIDEO = 3; + + public static final int DISPLAY_TVFORMAT_480I = 0; + public static final int DISPLAY_TVFORMAT_576I = 1; + public static final int DISPLAY_TVFORMAT_480P = 2; + public static final int DISPLAY_TVFORMAT_576P = 3; + public static final int DISPLAY_TVFORMAT_720P_50HZ = 4; + public static final int DISPLAY_TVFORMAT_720P_60HZ = 5; + public static final int DISPLAY_TVFORMAT_1080I_50HZ = 6; + public static final int DISPLAY_TVFORMAT_1080I_60HZ = 7; + public static final int DISPLAY_TVFORMAT_1080P_24HZ = 8; + public static final int DISPLAY_TVFORMAT_1080P_50HZ = 9; + public static final int DISPLAY_TVFORMAT_1080P_60HZ = 0xa; + public static final int DISPLAY_TVFORMAT_PAL = 0xb; + public static final int DISPLAY_TVFORMAT_PAL_SVIDEO = 0xc; + public static final int DISPLAY_TVFORMAT_PAL_CVBS_SVIDEO = 0xd; + public static final int DISPLAY_TVFORMAT_NTSC = 0xe; + public static final int DISPLAY_TVFORMAT_NTSC_SVIDEO = 0xf; + public static final int DISPLAY_TVFORMAT_NTSC_CVBS_SVIDEO = 0x10; + public static final int DISPLAY_TVFORMAT_PAL_M = 0x11; + public static final int DISPLAY_TVFORMAT_PAL_M_SVIDEO = 0x12; + public static final int DISPLAY_TVFORMAT_PAL_M_CVBS_SVIDEO = 0x13; + public static final int DISPLAY_TVFORMAT_PAL_NC = 0x14; + public static final int DISPLAY_TVFORMAT_PAL_NC_SVIDEO = 0x15; + public static final int DISPLAY_TVFORMAT_PAL_NC_CVBS_SVIDEO = 0x16; + + + public static final int DISPLAY_VGA_H1680_V1050 = 0x17; + public static final int DISPLAY_VGA_H1440_V900 = 0x18; + public static final int DISPLAY_VGA_H1360_V768 = 0x19; + public static final int DISPLAY_VGA_H1280_V1024 = 0x1a; + public static final int DISPLAY_VGA_H1024_V768 = 0x1b; + public static final int DISPLAY_VGA_H800_V600 = 0x1c; + public static final int DISPLAY_VGA_H640_V480 = 0x1d; + public static final int DISPLAY_VGA_H1440_V900_RB = 0x1e; + public static final int DISPLAY_VGA_H1680_V1050_RB = 0x1f; + public static final int DISPLAY_VGA_H1920_V1080_RB = 0x20; + public static final int DISPLAY_VGA_H1920_V1080 = 0x21; + public static final int DISPLAY_VGA_H1280_V720 = 0x22; + + private IDisplayManager mService; + private IBinder mToken = new Binder(); + + public DisplayManager() + { + mService = IDisplayManager.Stub.asInterface(ServiceManager.getService(Context.DISPLAY_SERVICE)); + } + + public int getDisplayCount() + { + try + { + return mService.getDisplayCount(); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public boolean getDisplayOpenStatus(int mDisplay) + { + try + { + return mService.getDisplayOpenStatus(mDisplay); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return false; + } + } + + public int getDisplayHotPlugStatus(int mDisplay) + { + try + { + return mService.getDisplayHotPlugStatus(mDisplay); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int getDisplayOutputType(int mDisplay) + { + try + { + return mService.getDisplayOutputType(mDisplay); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int getDisplayOutputFormat(int mDisplay) + { + try + { + return mService.getDisplayOutputFormat(mDisplay); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int getDisplayWidth(int mDisplay) + { + try + { + return mService.getDisplayWidth(mDisplay); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int getDisplayHeight(int mDisplay) + { + try + { + return mService.getDisplayHeight(mDisplay); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int getDisplayPixelFormat(int mDisplay) + { + try + { + Log.d(TAG,"setDisplayParameter"); + return mService.getDisplayPixelFormat(mDisplay); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int setDisplayParameter(int mDisplay,int param0,int param1) + { + try + { + Log.d(TAG,"setDisplayParameter"); + return mService.setDisplayParameter(mDisplay,param0,param1); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int setDisplayMode(int mode) + { + try + { + Log.d(TAG,"setDisplayMode"); + setDisplayBacklightMode(1); + return mService.setDisplayMode(mode); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int getDisplayMode() + { + try + { + Log.d(TAG,"setDisplayParameter"); + return mService.getDisplayMode(); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int setDisplayOutputType(int mDisplay,int type,int format) + { + try + { + Log.d(TAG,"setDisplayParameter"); + return mService.setDisplayOutputType(mDisplay,type,format); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int openDisplay(int mDisplay) + { + try + { + Log.d(TAG,"setDisplayParameter"); + return mService.openDisplay(mDisplay); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int closeDisplay(int mDisplay) + { + try + { + Log.d(TAG,"setDisplayParameter"); + return mService.closeDisplay(mDisplay); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int setDisplayBacklightMode(int mode) + { + try + { + Log.d(TAG,"11111111111111111111111111111111111111111111111111111111111111111111111111111111111"); + return mService.setDisplayBacklightMode(mode); + } + catch (RemoteException ex) + { + return -1; + } + } + + public int setDisplayMaster(int mDisplay) + { + try + { + Log.d(TAG,"setDisplayParameter"); + return mService.setDisplayMaster(mDisplay); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int getDisplayMaster() + { + try + { + Log.d(TAG,"setDisplayParameter"); + return mService.getDisplayMaster(); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int getMaxWidthDisplay() + { + try + { + Log.d(TAG,"getMaxWidthDisplay"); + + return mService.getMaxWidthDisplay(); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + + public int getMaxHdmiMode() + { + try + { + Log.d(TAG,"getMaxHdmiMode"); + + return mService.getMaxHdmiMode(); + } + catch (RemoteException ex) + { + // system process is dead anyway. + return -1; + } + } + public int getDisplayBacklightMode() + { + try + { + // get display backlight mode + return mService.getDisplayBacklightMode(); + } + catch (RemoteException ex) + { + return -1; + } + } +} + diff --git a/core/java/android/view/IDisplayManager.aidl b/core/java/android/view/IDisplayManager.aidl new file mode 100644 index 0000000000000..de9f1ff78d106 --- /dev/null +++ b/core/java/android/view/IDisplayManager.aidl @@ -0,0 +1,54 @@ +/* //device/java/android/android/view/IWindowManager.aidl +** +** Copyright 2006, 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. +*/ + +package android.view; + +import com.android.internal.view.IInputContext; +import com.android.internal.view.IInputMethodClient; + +import android.content.res.Configuration; + + +/** + * System private interface to the window manager. + * + * {@hide} + */ +interface IDisplayManager +{ + int getDisplayCount(); + boolean getDisplayOpenStatus(int mDisplay); + int getDisplayHotPlugStatus(int mDisplay); + int getDisplayTvDacPlugStatus(int mDisplay); + int getDisplayOutputType(int mDisplay); + int getDisplayOutputFormat(int mDisplay); + int getDisplayWidth(int mDisplay); + int getDisplayHeight(int mDisplay); + int setDisplayParameter(int mDisplay,int param0,int param1); + int getDisplayPixelFormat(int mDisplay); + int setDisplayMode(int mode); + int getDisplayMode(); + int setDisplayOutputType(int mDisplay,int type,int format); + int openDisplay(int mDisplay); + int closeDisplay(int mDisplay); + int setDisplayMaster(int mDisplay); + int getDisplayMaster(); + int getMaxWidthDisplay(); + int getMaxHdmiMode(); + int setDisplayBacklightMode(int mode); + int getDisplayBacklightMode(); +} diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index 8e0ab1a125021..1580162d65fc5 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -1367,6 +1367,7 @@ private static native void nativeGetPointerProperties(int nativePtr, int pointerIndex, PointerProperties outPointerProperties); private static native void nativeScale(int nativePtr, float scale); + private static native void nativeScaleXY(int mNativePtr, float scaleX,float scaleY); private static native void nativeTransform(int nativePtr, Matrix matrix); private static native int nativeReadFromParcel(int nativePtr, Parcel parcel); @@ -1678,6 +1679,10 @@ public final void recycle() { public final void scale(float scale) { nativeScale(mNativePtr, scale); } + + public final void scale(float scaleX,float scaleY) { + nativeScaleXY(mNativePtr, scaleX, scaleY); + } /** {@inheritDoc} */ @Override diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index c8dd098706822..bbb441801fa8e 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -831,6 +831,15 @@ static void android_hardware_Camera_stopFaceDetection(JNIEnv *env, jobject thiz) } } +// add for setting video screen +static jint android_hardware_Camera_setCameraScreen(JNIEnv *env, jobject thiz, + jint screen) +{ + LOGV("JNI setCameraScreen"); + return Camera::setCameraScreen(screen); +} + + //------------------------------------------------- static JNINativeMethod camMethods[] = { @@ -912,6 +921,9 @@ static JNINativeMethod camMethods[] = { { "_stopFaceDetection", "()V", (void *)android_hardware_Camera_stopFaceDetection}, + { "setCameraScreen", + "(I)I", + (void *)android_hardware_Camera_setCameraScreen }, }; struct field { diff --git a/core/jni/android_view_MotionEvent.cpp b/core/jni/android_view_MotionEvent.cpp index fef06b2561c6d..a1b3b9a20af27 100644 --- a/core/jni/android_view_MotionEvent.cpp +++ b/core/jni/android_view_MotionEvent.cpp @@ -674,6 +674,12 @@ static void android_view_MotionEvent_nativeScale(JNIEnv* env, jclass clazz, MotionEvent* event = reinterpret_cast(nativePtr); event->scale(scale); } +static void android_view_MotionEvent_nativeScaleXY(JNIEnv* env, jclass clazz, + jint nativePtr, jfloat scalex, jfloat scaley) { + MotionEvent* event = reinterpret_cast(nativePtr); + event->scale(scalex,scaley); +} + static void android_view_MotionEvent_nativeTransform(JNIEnv* env, jclass clazz, jint nativePtr, jobject matrixObj) { @@ -820,6 +826,10 @@ static JNINativeMethod gMotionEventMethods[] = { { "nativeScale", "(IF)V", (void*)android_view_MotionEvent_nativeScale }, + { "nativeScaleXY", + "(IFF)V", + (void*)android_view_MotionEvent_nativeScaleXY }, + { "nativeTransform", "(ILandroid/graphics/Matrix;)V", (void*)android_view_MotionEvent_nativeTransform }, diff --git a/include/camera/Camera.h b/include/camera/Camera.h index ad4db3b65e175..5e041d657cc5c 100644 --- a/include/camera/Camera.h +++ b/include/camera/Camera.h @@ -147,6 +147,9 @@ class Camera : public BnCameraClient, public IBinder::DeathRecipient virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp& dataPtr); sp remote(); + + // add for set overlay screen + static int setCameraScreen(int screen); class RecordingProxy : public BnCameraRecordingProxy { diff --git a/include/camera/ICameraService.h b/include/camera/ICameraService.h index 7d70c1e48ac48..5d966af610214 100644 --- a/include/camera/ICameraService.h +++ b/include/camera/ICameraService.h @@ -32,7 +32,8 @@ class ICameraService : public IInterface enum { GET_NUMBER_OF_CAMERAS = IBinder::FIRST_CALL_TRANSACTION, GET_CAMERA_INFO, - CONNECT + CONNECT, + SET_CAMERA_SCREEN }; public: @@ -43,6 +44,7 @@ class ICameraService : public IInterface struct CameraInfo* cameraInfo) = 0; virtual sp connect(const sp& cameraClient, int cameraId) = 0; + virtual int setCameraScreen(int screen) = 0; }; // ---------------------------------------------------------------------------- diff --git a/include/gui/ISurfaceTexture.h b/include/gui/ISurfaceTexture.h index fbec6a167705d..a57981838e2a2 100644 --- a/include/gui/ISurfaceTexture.h +++ b/include/gui/ISurfaceTexture.h @@ -141,6 +141,8 @@ class ISurfaceTexture : public IInterface int arg3) = 0; #endif + virtual uint32_t getParameter(uint32_t cmd) = 0; + virtual int setParameter(uint32_t cmd,uint32_t value) = 0; }; // ---------------------------------------------------------------------------- diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h index 36c5b72d1e632..978a095364919 100644 --- a/include/gui/SurfaceTexture.h +++ b/include/gui/SurfaceTexture.h @@ -105,6 +105,10 @@ class SurfaceTexture : public BnSurfaceTexture { virtual status_t setScalingMode(int mode); virtual int query(int what, int* value); + + virtual bool IsHardwareRenderSupport(); + virtual int setParameter(uint32_t cmd,uint32_t value); + virtual uint32_t getParameter(uint32_t cmd); #ifdef QCOM_HARDWARE virtual int performQcomOperation(int operation, int arg1, int arg2, int arg3); diff --git a/include/gui/SurfaceTextureClient.h b/include/gui/SurfaceTextureClient.h index 9e2e696b2ca56..4dc6b87fcb6e7 100644 --- a/include/gui/SurfaceTextureClient.h +++ b/include/gui/SurfaceTextureClient.h @@ -74,6 +74,8 @@ class SurfaceTextureClient #ifdef QCOM_HARDWARE int dispatchPerformQcomOperation(int operation, va_list args); #endif + int dispatchSetParameter(va_list args); + int dispatchGetParameter(va_list args); protected: virtual int cancelBuffer(ANativeWindowBuffer* buffer); @@ -85,6 +87,8 @@ class SurfaceTextureClient virtual int setSwapInterval(int interval); virtual int connect(int api); + virtual int setParameter(uint32_t cmd,uint32_t value); + virtual int getParameter(uint32_t cmd); virtual int disconnect(int api); virtual int setBufferCount(int bufferCount); virtual int setBuffersDimensions(int w, int h); diff --git a/include/media/IMediaPlayer.h b/include/media/IMediaPlayer.h index e9059031fbfaa..92c25f68875c0 100644 --- a/include/media/IMediaPlayer.h +++ b/include/media/IMediaPlayer.h @@ -20,6 +20,7 @@ #include #include #include +#include "mediaplayerinfo.h" #include namespace android { @@ -56,6 +57,50 @@ class IMediaPlayer: public IInterface virtual status_t setVolume(float leftVolume, float rightVolume) = 0; virtual status_t setAuxEffectSendLevel(float level) = 0; virtual status_t attachAuxEffect(int effectId) = 0; + + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-15 10:25:10 */ + /* expend interfaces about subtitle, track and so on */ + virtual int getSubCount() = 0; + virtual int getSubList(MediaPlayer_SubInfo *infoList, int count) = 0; + virtual int getCurSub() = 0; + virtual status_t switchSub(int index) = 0; + virtual status_t setSubGate(bool showSub) = 0; + virtual bool getSubGate() = 0; + virtual status_t setSubColor(int color) = 0; + virtual int getSubColor() = 0; + virtual status_t setSubFrameColor(int color) = 0; + virtual int getSubFrameColor() = 0; + virtual status_t setSubFontSize(int size) = 0; + virtual int getSubFontSize() = 0; + virtual status_t setSubCharset(const char *charset) = 0; + virtual status_t getSubCharset(char *charset) = 0; + virtual status_t setSubPosition(int percent) = 0; + virtual int getSubPosition() = 0; + virtual status_t setSubDelay(int time) = 0; + virtual int getSubDelay() = 0; + virtual int getTrackCount() = 0; + virtual int getTrackList(MediaPlayer_TrackInfo *infoList, int count) = 0; + virtual int getCurTrack() = 0; + virtual status_t switchTrack(int index) = 0; + virtual status_t setInputDimensionType(int type) = 0; + virtual int getInputDimensionType() = 0; + virtual status_t setOutputDimensionType(int type) = 0; + virtual int getOutputDimensionType() = 0; + virtual status_t setAnaglaghType(int type) = 0; + virtual int getAnaglaghType() = 0; + virtual status_t getVideoEncode(char *encode) = 0; + virtual int getVideoFrameRate() = 0; + virtual status_t getAudioEncode(char *encode) = 0; + virtual int getAudioBitRate() = 0; + virtual int getAudioSampleRate() = 0; + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + virtual status_t enableScaleMode(bool enable, int width, int height) = 0; + /* add by Gary. end -----------------------------------}} */ virtual status_t setParameter(int key, const Parcel& request) = 0; virtual status_t getParameter(int key, Parcel* reply) = 0; diff --git a/include/media/IMediaPlayerClient.h b/include/media/IMediaPlayerClient.h index daec1c7076936..b61ea0d43d453 100644 --- a/include/media/IMediaPlayerClient.h +++ b/include/media/IMediaPlayerClient.h @@ -29,6 +29,11 @@ class IMediaPlayerClient: public IInterface DECLARE_META_INTERFACE(MediaPlayerClient); virtual void notify(int msg, int ext1, int ext2, const Parcel *obj) = 0; + /* add by Gary. start {{----------------------------------- */ + /* 2011-10-9 8:54:30 */ + /* add callback for parsing 3d source */ + virtual int parse3dFile(int type) {return 0;}; + /* add by Gary. end -----------------------------------}} */ }; // ---------------------------------------------------------------------------- diff --git a/include/media/IMediaPlayerService.h b/include/media/IMediaPlayerService.h index 93bbe13ea4c10..cd6669d7ffbde 100644 --- a/include/media/IMediaPlayerService.h +++ b/include/media/IMediaPlayerService.h @@ -34,6 +34,14 @@ class IMediaRecorder; class IOMX; struct IStreamSource; +/* add by Gary. start {{----------------------------------- */ +/** +* screen name +*/ +#define MASTER_SCREEN 0 +#define SLAVE_SCREEN 1 +/* add by Gary. end -----------------------------------}} */ + class IMediaPlayerService: public IInterface { public: @@ -46,6 +54,26 @@ class IMediaPlayerService: public IInterface virtual sp decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0; virtual sp decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0; virtual sp getOMX() = 0; + /* add by Gary. start {{----------------------------------- */ + virtual status_t setScreen(int screen) = 0; + virtual status_t getScreen(int *screen) = 0; + virtual status_t isPlayingVideo(int *playing) = 0; + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + virtual status_t setVppGate(bool enableVpp) = 0; + virtual bool getVppGate() = 0; + virtual status_t setLumaSharp(int value) = 0; + virtual int getLumaSharp() = 0; + virtual status_t setChromaSharp(int value) = 0; + virtual int getChromaSharp() = 0; + virtual status_t setWhiteExtend(int value) = 0; + virtual int getWhiteExtend() = 0; + virtual status_t setBlackExtend(int value) = 0; + virtual int getBlackExtend() = 0; + /* add by Gary. end -----------------------------------}} */ // codecs and audio devices usage tracking for the battery app enum BatteryDataBits { diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h index e05e5c5678e94..745fa34e3391f 100644 --- a/include/media/MediaPlayerInterface.h +++ b/include/media/MediaPlayerInterface.h @@ -29,8 +29,17 @@ #include #include +#include "mediaplayerinfo.h" namespace android { +/* add by Gary. start {{----------------------------------- */ +/** +* screen name +*/ +#define MASTER_SCREEN 0 +#define SLAVE_SCREEN 1 +/* add by Gary. end -----------------------------------}} */ + class Parcel; class Surface; class ISurfaceTexture; @@ -46,8 +55,20 @@ enum player_type { // The shared library with the test player is passed passed as an // argument to the 'test:' url in the setDataSource call. TEST_PLAYER = 5, + + CEDARX_PLAYER = 8, + CEDARA_PLAYER = 9, }; +enum player_states { + PLAYER_STATE_UNKOWN = 0, + PLAYER_STATE_PREPARED, + PLAYER_STATE_PAUSE, + PLAYER_STATE_PLAYING, + PLAYER_STATE_SEEKING, + PLAYER_STATE_SUSPEND, + PLAYER_STATE_RESUME, +}; #define DEFAULT_AUDIOSINK_BUFFERCOUNT 4 #define DEFAULT_AUDIOSINK_BUFFERSIZE 1200 @@ -57,6 +78,11 @@ enum player_type { // callback mechanism for passing messages to MediaPlayer object typedef void (*notify_callback_f)(void* cookie, int msg, int ext1, int ext2, const Parcel *obj); +/* add by Gary. start {{----------------------------------- */ +/* 2011-10-9 8:54:30 */ +/* add callback for parsing 3d source */ +typedef void (*parse3dFile_callback_f)(void* cookie, int type); +/* add by Gary. end -----------------------------------}} */ // abstract base class - use MediaPlayerInterface class MediaPlayerBase : public RefBase @@ -149,6 +175,229 @@ class MediaPlayerBase : public RefBase virtual status_t setParameter(int key, const Parcel &request) = 0; virtual status_t getParameter(int key, Parcel *reply) = 0; + /* add by Gary. start {{----------------------------------- */ + virtual status_t setScreen(int screen){ + return OK; + }; + virtual int getMeidaPlayerState(){ + return PLAYER_STATE_UNKOWN; + }; + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-14 14:27:12 */ + /* expend interfaces about subtitle, track and so on */ + virtual int getSubCount() + { + return 0; + } + + virtual int getSubList(MediaPlayer_SubInfo *infoList, int count) + { + return 0; + } + + virtual int getCurSub() + { + return -1; + } + + virtual status_t switchSub(int index) + { + return OK; + } + + virtual status_t setSubGate(bool showSub) + { + return OK; + } + + virtual bool getSubGate() + { + return true; + } + + virtual status_t setSubColor(int color) + { + return OK; + } + + virtual int getSubColor() + { + return 0xFFFFFFFF; + } + + virtual status_t setSubFrameColor(int color) + { + return OK; + } + + virtual int getSubFrameColor() + { + return 0xFFFFFFFF; + } + + virtual status_t setSubFontSize(int size) + { + return OK; + } + + virtual int getSubFontSize() + { + return -1; + } + + virtual status_t setSubCharset(const char *charset) + { + return OK; + } + + virtual status_t getSubCharset(char *charset) + { + return OK; + } + + virtual status_t setSubPosition(int percent) + { + return OK; + } + + virtual int getSubPosition() + { + return -1; + } + + virtual status_t setSubDelay(int time) + { + return OK; + } + + virtual int getSubDelay() + { + return -1; + } + + virtual int getTrackCount() + { + return 0; + } + + virtual int getTrackList(MediaPlayer_TrackInfo *infoList, int count) + { + return 0; + } + + virtual int getCurTrack() + { + return -1; + } + + virtual status_t switchTrack(int index) + { + return OK; + } + + virtual status_t setInputDimensionType(int type) + { + return -1; + } + + virtual int getInputDimensionType() + { + return -1; + } + + virtual status_t setOutputDimensionType(int type) + { + return -1; + } + + virtual int getOutputDimensionType() + { + return -1; + } + + virtual status_t setAnaglaghType(int type) + { + return -1; + } + + virtual int getAnaglaghType() + { + return -1; + } + + virtual status_t getVideoEncode(char *encode) + { + return -1; + } + + virtual int getVideoFrameRate() + { + return -1; + } + + virtual status_t getAudioEncode(char *encode) + { + return -1; + } + + virtual int getAudioBitRate() + { + return -1; + } + + virtual int getAudioSampleRate() + { + return -1; + } + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-10-9 8:54:30 */ + /* add callback for parsing 3d source */ + virtual void setParse3dFileCallback(void* cookie, parse3dFile_callback_f func) { mParse3dFile = func; return; } + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + virtual status_t enableScaleMode(bool enable, int width, int height) + { + return -1; + } + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + virtual status_t setVppGate(bool enableVpp) + { + return OK; + } + virtual status_t setLumaSharp(int value) + { + return OK; + } + virtual status_t setChromaSharp(int value) + { + return OK; + } + virtual status_t setWhiteExtend(int value) + { + return OK; + } + virtual status_t setBlackExtend(int value) + { + return OK; + } + + virtual status_t extensionControl(int command, int para0, int para1) + { + return OK; + } + /* add by Gary. end -----------------------------------}} */ + // Invoke a generic method on the player by using opaque parcels // for the request and reply. // @@ -192,6 +441,11 @@ class MediaPlayerBase : public RefBase Mutex mNotifyLock; void* mCookie; notify_callback_f mNotify; + /* add by Gary. start {{----------------------------------- */ + /* 2011-10-9 8:54:30 */ + /* add callback for parsing 3d source */ + parse3dFile_callback_f mParse3dFile; + /* add by Gary. end -----------------------------------}} */ }; // Implement this class for media players that use the AudioFlinger software mixer diff --git a/include/media/mediaplayer.h b/include/media/mediaplayer.h index e6a0cc569b462..a1a86be6f3de4 100644 --- a/include/media/mediaplayer.h +++ b/include/media/mediaplayer.h @@ -25,6 +25,7 @@ #include #include +#include "mediaplayerinfo.h" class ANativeWindow; @@ -43,6 +44,7 @@ enum media_event_type { MEDIA_TIMED_TEXT = 99, MEDIA_ERROR = 100, MEDIA_INFO = 200, + MEDIA_INFO_SRC_3D_MODE = 1024, }; // Generic error codes for the media player framework. Errors are fatal, the @@ -118,6 +120,13 @@ enum media_info_type { }; +/* add by Gary. start {{----------------------------------- */ +/** +* screen name +*/ +#define MASTER_SCREEN 0 +#define SLAVE_SCREEN 1 +/* add by Gary. end -----------------------------------}} */ enum media_player_states { MEDIA_PLAYER_STATE_ERROR = 0, @@ -153,6 +162,11 @@ class MediaPlayerListener: virtual public RefBase { public: virtual void notify(int msg, int ext1, int ext2, const Parcel *obj) = 0; + /* add by Gary. start {{----------------------------------- */ + /* 2011-10-9 8:54:30 */ + /* add callback for parsing 3d source */ + virtual int parse3dFile(int type) = 0; + /* add by Gary. end -----------------------------------}} */ }; class MediaPlayer : public BnMediaPlayerClient, @@ -201,6 +215,75 @@ class MediaPlayer : public BnMediaPlayerClient, status_t attachAuxEffect(int effectId); status_t setParameter(int key, const Parcel& request); status_t getParameter(int key, Parcel* reply); + /* add by Gary. start {{----------------------------------- */ + static status_t setScreen(int screen); + static status_t getScreen(int *screen); + static status_t isPlayingVideo(bool *playing); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-13 14:05:05 */ + /* expend interfaces about subtitle, track and so on */ + int getSubCount(); + int getSubList(MediaPlayer_SubInfo *infoList, int count); + int getCurSub(); + status_t switchSub(int index); + status_t setSubGate(bool showSub); + bool getSubGate(); + status_t setSubColor(int color); + int getSubColor(); + status_t setSubFrameColor(int color); + int getSubFrameColor(); + status_t setSubFontSize(int size); + int getSubFontSize(); + status_t setSubCharset(const char *charset); + status_t getSubCharset(char *charset); + status_t setSubPosition(int percent); + int getSubPosition(); + status_t setSubDelay(int time); + int getSubDelay(); + int getTrackCount(); + int getTrackList(MediaPlayer_TrackInfo *infoList, int count); + int getCurTrack(); + status_t switchTrack(int index); + status_t setInputDimensionType(int type); + int getInputDimensionType(); + status_t setOutputDimensionType(int type); + int getOutputDimensionType(); + status_t setAnaglaghType(int type); + int getAnaglaghType(); + status_t getVideoEncode(char *encode); + int getVideoFrameRate(); + status_t getAudioEncode(char *encode); + int getAudioBitRate(); + int getAudioSampleRate(); + /* add by Gary. end -----------------------------------}} */ + /* add by Gary. start {{----------------------------------- */ + /* 2011-10-9 8:54:30 */ + /* add callback for parsing 3d source */ + int parse3dFile(int type); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + status_t enableScaleMode(bool enable, int width, int height); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + static status_t setVppGate(bool enableVpp); + static bool getVppGate(); + static status_t setLumaSharp(int value); + static int getLumaSharp(); + static status_t setChromaSharp(int value); + static int getChromaSharp(); + static status_t setWhiteExtend(int value); + static int getWhiteExtend(); + static status_t setBlackExtend(int value); + static int getBlackExtend(); + /* add by Gary. end -----------------------------------}} */ private: void clear_l(); @@ -231,6 +314,19 @@ class MediaPlayer : public BnMediaPlayerClient, int mVideoHeight; int mAudioSessionId; float mSendLevel; + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-28 16:28:24 */ + /* save properties before creating the real player */ + bool mSubGate; + int mSubColor; + int mSubFrameColor; + int mSubPosition; + int mSubDelay; + int mSubFontSize; + char mSubCharset[MEDIAPLAYER_NAME_LEN_MAX]; + int mSubIndex; + int mTrackIndex; + /* add by Gary. end -----------------------------------}} */ }; }; // namespace android diff --git a/include/media/mediaplayerinfo.h b/include/media/mediaplayerinfo.h new file mode 100644 index 0000000000000..a25c0c203e7c0 --- /dev/null +++ b/include/media/mediaplayerinfo.h @@ -0,0 +1,122 @@ +/* + * 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_MEDIAPLAYER_INFO_H +#define ANDROID_MEDIAPLAYER_INFO_H + +/* add by Gary. start {{----------------------------------- */ +/* 2011-9-13 14:05:05 */ +/* expend interfaces about subtitle, track and so on */ +#define SUBTITLE_TYPE_TEXT 0 +#define SUBTITLE_TYPE_BITMAP 1 + +#define MEDIAPLAYER_NAME_LEN_MAX 256 + +typedef struct _MediaPlayer_SubInfo{ + char name[MEDIAPLAYER_NAME_LEN_MAX]; + int len; + char charset[MEDIAPLAYER_NAME_LEN_MAX]; + int type; // text or bitmap +}MediaPlayer_SubInfo; + +typedef struct _MediaPlayer_TrackInfo{ + char name[MEDIAPLAYER_NAME_LEN_MAX]; + int len; + char charset[MEDIAPLAYER_NAME_LEN_MAX]; +}MediaPlayer_TrackInfo; + +#define CHARSET_UNKNOWN "UNKNOWN" //无法识别出æ¥çš„字符集 +#define CHARSET_BIG5 "Big5" //ç¹ä½“中文 +#define CHARSET_BIG5_HKSCS "Big5-HKSCS" // +#define CHARSET_BOCU_1 "BOCU-1" // +#define CHARSET_CESU_8 "CESU-8" // +#define CHARSET_CP864 "cp864" // +#define CHARSET_EUC_JP "EUC-JP" // +#define CHARSET_EUC_KR "EUC-KR" // +#define CHARSET_GB18030 "GB18030" // +#define CHARSET_GBK "GBK" //简体中文 +#define CHARSET_HZ_GB_2312 "HZ-GB-2312" // +#define CHARSET_ISO_2022_CN "ISO-2022-CN" // +#define CHARSET_ISO_2022_CN_EXT "ISO-2022-CN-EXT" // +#define CHARSET_ISO_2022_JP "ISO-2022-JP" // +#define CHARSET_ISO_2022_KR "ISO-2022-KR" //韩文 +#define CHARSET_ISO_8859_1 "ISO-8859-1" //西欧语系 +#define CHARSET_ISO_8859_10 "ISO-8859-10" //北欧斯堪的纳维亚语系 +#define CHARSET_ISO_8859_13 "ISO-8859-13" //波罗的海语系 +#define CHARSET_ISO_8859_14 "ISO-8859-14" //凯尔特人语系 +#define CHARSET_ISO_8859_15 "ISO-8859-15" //扩展了法语和芬兰语的西欧语系 +#define CHARSET_ISO_8859_16 "ISO-8859-16" //扩展的东å—欧语系 +#define CHARSET_ISO_8859_2 "ISO-8859-2" //中欧语言 +#define CHARSET_ISO_8859_3 "ISO-8859-3" //å—欧语言 +#define CHARSET_ISO_8859_4 "ISO-8859-4" //北欧语言 +#define CHARSET_ISO_8859_5 "ISO-8859-5" //è¥¿é‡Œå°”å­—æ¯ +#define CHARSET_ISO_8859_6 "ISO-8859-6" //阿拉伯语 +#define CHARSET_ISO_8859_7 "ISO-8859-7" //希腊语 +#define CHARSET_ISO_8859_8 "ISO-8859-8" //希伯æ¥è¯­ +#define CHARSET_ISO_8859_9 "ISO-8859-9" //土耳其语 +#define CHARSET_KOI8_R "KOI8-R" //ä¿„æ–‡ +#define CHARSET_KOI8_U "KOI8-U" // +#define CHARSET_MACINTOSH "macintosh" // +#define CHARSET_SCSU "SCSU" // +#define CHARSET_SHIFT_JIS "Shift_JIS" //日文 +#define CHARSET_TIS_620 "TIS-620" //æ³°æ–‡ +#define CHARSET_US_ASCII "US-ASCII" // +#define CHARSET_UTF_16 "UTF-16" // +#define CHARSET_UTF_16BE "UTF-16BE" //UTF16 big endian +#define CHARSET_UTF_16LE "UTF-16LE" //UTF16 little endian +#define CHARSET_UTF_32 "UTF-32" // +#define CHARSET_UTF_32BE "UTF-32BE" // +#define CHARSET_UTF_32LE "UTF-32LE" // +#define CHARSET_UTF_7 "UTF-7" // +#define CHARSET_UTF_8 "UTF-8" //UTF8 +#define CHARSET_WINDOWS_1250 "windows-1250" //中欧 +#define CHARSET_WINDOWS_1251 "windows-1251" //西里尔文 +#define CHARSET_WINDOWS_1252 "windows-1252" //土耳其语 +#define CHARSET_WINDOWS_1253 "windows-1253" //希腊文 +#define CHARSET_WINDOWS_1254 "windows-1254" //西欧语系 +#define CHARSET_WINDOWS_1255 "windows-1255" //希伯æ¥æ–‡ +#define CHARSET_WINDOWS_1256 "windows-1256" //阿拉伯文 +#define CHARSET_WINDOWS_1257 "windows-1257" //波罗的海文 +#define CHARSET_WINDOWS_1258 "windows-1258" //è¶Šå— +#define CHARSET_X_DOCOMO_SHIFT_JIS_2007 "x-docomo-shift_jis-2007" // +#define CHARSET_X_GSM_03_38_2000 "x-gsm-03.38-2000" // +#define CHARSET_X_IBM_1383_P110_1999 "x-ibm-1383_P110-1999" // +#define CHARSET_X_IMAP_MAILBOX_NAME "x-IMAP-mailbox-name" // +#define CHARSET_X_ISCII_BE "x-iscii-be" // +#define CHARSET_X_ISCII_DE "x-iscii-de" // +#define CHARSET_X_ISCII_GU "x-iscii-gu" // +#define CHARSET_X_ISCII_KA "x-iscii-ka" // +#define CHARSET_X_ISCII_MA "x-iscii-ma" // +#define CHARSET_X_ISCII_OR "x-iscii-or" // +#define CHARSET_X_ISCII_PA "x-iscii-pa" // +#define CHARSET_X_ISCII_TA "x-iscii-ta" // +#define CHARSET_X_ISCII_TE "x-iscii-te" // +#define CHARSET_X_ISO_8859_11_2001 "x-iso-8859_11-2001" // +#define CHARSET_X_JAVAUNICODE "x-JavaUnicode" // +#define CHARSET_X_KDDI_SHIFT_JIS_2007 "x-kddi-shift_jis-2007" // +#define CHARSET_X_MAC_CYRILLIC "x-mac-cyrillic" // +#define CHARSET_X_SOFTBANK_SHIFT_JIS_2007 "x-softbank-shift_jis-2007" // +#define CHARSET_X_UNICODEBIG "x-UnicodeBig" // +#define CHARSET_X_UTF_16LE_BOM "x-UTF-16LE-BOM" // +#define CHARSET_X_UTF16_OPPOSITEENDIAN "x-UTF16_OppositeEndian" // +#define CHARSET_X_UTF16_PLATFORMENDIAN "x-UTF16_PlatformEndian" // +#define CHARSET_X_UTF32_OPPOSITEENDIAN "x-UTF32_OppositeEndian" // +#define CHARSET_X_UTF32_PLATFORMENDIAN "x-UTF32_PlatformEndian" // + +/* add by Gary. end -----------------------------------}} */ + + +#endif // ANDROID_MEDIAPLAYER_H diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index ea6565278d410..a8ee4a2583201 100755 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -119,6 +119,9 @@ struct ACodec : public AHierarchicalStateMachine { sp mDealer[2]; sp mNativeWindow; + + sp mNativeWindowSoft; + int32_t mVideoWidth,mVideoHeight; Vector mBuffers[2]; bool mPortEOS[2]; diff --git a/include/media/stagefright/AudioPlayer.h b/include/media/stagefright/AudioPlayer.h index bb05ba3cc0326..7adefaa465e78 100644 --- a/include/media/stagefright/AudioPlayer.h +++ b/include/media/stagefright/AudioPlayer.h @@ -42,27 +42,27 @@ class AudioPlayer : public TimeSource { virtual ~AudioPlayer(); // Caller retains ownership of "source". - virtual void setSource(const sp &source); + void setSource(const sp &source); // Return time in us. virtual int64_t getRealTimeUs(); - virtual status_t start(bool sourceAlreadyStarted = false); + status_t start(bool sourceAlreadyStarted = false); - virtual void pause(bool playPendingSamples = false); - virtual void resume(); + void pause(bool playPendingSamples = false); + void resume(); // Returns the timestamp of the last buffer played (in us). - virtual int64_t getMediaTimeUs(); + int64_t getMediaTimeUs(); // Returns true iff a mapping is established, i.e. the AudioPlayer // has played at least one frame of audio. - virtual bool getMediaTimeMapping(int64_t *realtime_us, int64_t *mediatime_us); + bool getMediaTimeMapping(int64_t *realtime_us, int64_t *mediatime_us); - virtual status_t seekTo(int64_t time_us); + status_t seekTo(int64_t time_us); - virtual bool isSeeking(); - virtual bool reachedEOS(status_t *finalStatus); + bool isSeeking(); + bool reachedEOS(status_t *finalStatus); private: friend class VideoEditorAudioPlayer; diff --git a/include/media/stagefright/CedarAAudioPlayer.h b/include/media/stagefright/CedarAAudioPlayer.h new file mode 100644 index 0000000000000..3b6d3de49c0ed --- /dev/null +++ b/include/media/stagefright/CedarAAudioPlayer.h @@ -0,0 +1,120 @@ +/* + * 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 CEDARX_AUDIO_PLAYER_H_ + +#define CEDARX_AUDIO_PLAYER_H_ + +#include +#include +#include +#include +//#include + +namespace android { + +class MediaSource; +class AudioTrack; +class CedarAPlayer; + +class CedarAAudioPlayer { +public: + enum { + REACHED_EOS, + SEEK_COMPLETE + }; + + CedarAAudioPlayer(const sp &audioSink, + CedarAPlayer *audioObserver = NULL); + + virtual ~CedarAAudioPlayer(); + + // Caller retains ownership of "source". + void setSource(const sp &source); + + void setFormat(int samplerate, int channel); + + + status_t start(bool sourceAlreadyStarted = false); + + void pause(bool playPendingSamples = false); + void resume(); + + int getLatency(); + int getSpace(); + int render(void* data, int len); + + status_t seekTo(int64_t time_us); + + bool isSeeking(); + bool reachedEOS(status_t *finalStatus); + //void setEventMark(uint32_t event); + +private: + sp mSource; + AudioTrack *mAudioTrack; + + //bool mInitMediaClock; + //MediaClock *mMediaClock; + + MediaBuffer *mInputBuffer; + + int mSampleRate; + int mNumChannels; + int64_t mLatencyUs; + size_t mFrameSize; + + Mutex mLock; + int64_t mNumFramesPlayed; + + int64_t mPositionTimeMediaUs; + int64_t mPositionTimeRealUs; + + bool mSeeking; + bool mReachedEOS; + status_t mFinalStatus; + int64_t mSeekTimeUs; + + bool mStarted; + + bool mIsFirstBuffer; + status_t mFirstBufferResult; + MediaBuffer *mFirstBuffer; + + sp mAudioSink; + CedarAPlayer *mObserver; + char *mAudioBufferPtr; + int mAudioBufferSize; + + static void AudioCallback(int event, void *user, void *info); + void AudioCallback(int event, void *info); + + static size_t AudioSinkCallback( + MediaPlayerBase::AudioSink *audioSink, + void *data, size_t size, void *me); + + size_t fillBuffer(void *data, size_t size); + + + void reset(); + + CedarAAudioPlayer(const CedarAAudioPlayer &); + CedarAAudioPlayer &operator=(const CedarAAudioPlayer &); +}; + +} // namespace android + +#endif // AUDIO_PLAYER_H_ diff --git a/include/media/stagefright/CedarXAudioPlayer.h b/include/media/stagefright/CedarXAudioPlayer.h new file mode 100644 index 0000000000000..09b98ed2a97f7 --- /dev/null +++ b/include/media/stagefright/CedarXAudioPlayer.h @@ -0,0 +1,127 @@ +/* + * 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 CEDARX_AUDIO_PLAYER_H_ + +#define CEDARX_AUDIO_PLAYER_H_ + +#include +#include +#include +#include +//#include + +namespace android { + +class MediaSource; +class AudioTrack; +class CedarXPlayer; + +class CedarXAudioPlayer { +public: + enum { + REACHED_EOS, + SEEK_COMPLETE + }; + + enum { + FlagsFillBuffer = 1, + }; + + CedarXAudioPlayer(const sp &audioSink, + CedarXPlayer *audioObserver = NULL); + + virtual ~CedarXAudioPlayer(); + + // Caller retains ownership of "source". + void setSource(const sp &source); + + void setFormat(int samplerate, int channel); + + + status_t start(bool sourceAlreadyStarted = false); + + void pause(bool playPendingSamples = false); + void resume(); + + int getLatency(); + int getSpace(); + int render(void* data, int len); + + status_t seekTo(int64_t time_us); + + bool isSeeking(); + bool reachedEOS(status_t *finalStatus); + //void setEventMark(uint32_t event); + +private: + sp mSource; + AudioTrack *mAudioTrack; + + //bool mInitMediaClock; + //MediaClock *mMediaClock; + + MediaBuffer *mInputBuffer; + + int mSampleRate; + int numChannels; + int64_t mLatencyUs; + size_t mFrameSize; + + Mutex mLock, mLock2; + int64_t mNumFramesPlayed; + + int64_t mPositionTimeMediaUs; + int64_t mPositionTimeRealUs; + + bool mSeeking; + bool mReachedEOS; + status_t mFinalStatus; + int64_t mSeekTimeUs; + + bool mStarted; + + bool mIsFirstBuffer; + status_t mFirstBufferResult; + MediaBuffer *mFirstBuffer; + + sp mAudioSink; + CedarXPlayer *mObserver; + char *mAudioBufferPtr; + int mAudioBufferSize; + char *mAudioBufferPtrBak; + int mAudioBufferSizeBak; + int mFlags; + + static void AudioCallback(int event, void *user, void *info); + void AudioCallback(int event, void *info); + + static size_t AudioSinkCallback( + MediaPlayerBase::AudioSink *audioSink, + void *data, size_t size, void *me); + + size_t fillBuffer(void *data, size_t size); + Condition mFillBufferCondition; + + void reset(); + + CedarXAudioPlayer(const CedarXAudioPlayer &); + CedarXAudioPlayer &operator=(const CedarXAudioPlayer &); +}; + +} // namespace android + +#endif // AUDIO_PLAYER_H_ diff --git a/include/media/stagefright/CedarXMediaScanner.h b/include/media/stagefright/CedarXMediaScanner.h new file mode 100644 index 0000000000000..ffd7dc1eec9ba --- /dev/null +++ b/include/media/stagefright/CedarXMediaScanner.h @@ -0,0 +1,46 @@ +/* + * 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 CEDARX_MEDIA_SCANNER_H_ + +#define CEDARX_MEDIA_SCANNER_H_ + +#include + +namespace android { + +struct MediaMetadataRetriever; + +struct CedarXMediaScanner : public MediaScanner { + CedarXMediaScanner(); + virtual ~CedarXMediaScanner(); + + virtual status_t processFile( + const char *path, const char *mimeType, + MediaScannerClient &client); + + virtual char *extractAlbumArt(int fd); + +private: + sp mRetriever; + + CedarXMediaScanner(const CedarXMediaScanner &); + CedarXMediaScanner &operator=(const CedarXMediaScanner &); +}; + +} // namespace android + +#endif // STAGEFRIGHT_MEDIA_SCANNER_H_ diff --git a/include/media/stagefright/MediaSource.h b/include/media/stagefright/MediaSource.h index 3818e63ff4e9f..5122d3e96c084 100644 --- a/include/media/stagefright/MediaSource.h +++ b/include/media/stagefright/MediaSource.h @@ -68,6 +68,7 @@ struct MediaSource : public virtual RefBase { SEEK_NEXT_SYNC, SEEK_CLOSEST_SYNC, SEEK_CLOSEST, + SEEK_VENDOR_OPT = 100, }; ReadOptions(); diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h index 45927be033ba2..ef26ec65eb83e 100755 --- a/include/media/stagefright/MetaData.h +++ b/include/media/stagefright/MetaData.h @@ -155,6 +155,8 @@ enum { kKeyUseArbitraryMode = 'ArbM' //bool (int32_t) #endif + kKeyScreenID = 'scrn', + kKeyOffset = 'offs' }; enum { diff --git a/include/media/stagefright/SurfaceMediaSource.h b/include/media/stagefright/SurfaceMediaSource.h index 4fedf1c2e032a..3b1430e984142 100644 --- a/include/media/stagefright/SurfaceMediaSource.h +++ b/include/media/stagefright/SurfaceMediaSource.h @@ -157,6 +157,10 @@ class SurfaceMediaSource : public BnSurfaceTexture, public MediaSource, // This method will fail if the the SurfaceMediaSource is not currently // connected to the specified client API. virtual status_t disconnect(int api); + + virtual int setParameter(uint32_t cmd,uint32_t value) {return 0;}; + + virtual uint32_t getParameter(uint32_t cmd) {return 0;}; // getqueuedCount returns the number of queued frames waiting in the // FIFO. In asynchronous mode, this always returns 0 or 1 since diff --git a/include/media/stagefright/openmax/OMX_Core.h b/include/media/stagefright/openmax/OMX_Core.h index 9fb0f6fdb7c14..01c7f0f39f8ee 100644 --- a/include/media/stagefright/openmax/OMX_Core.h +++ b/include/media/stagefright/openmax/OMX_Core.h @@ -409,6 +409,8 @@ typedef struct OMX_PARAM_COMPONENTROLETYPE { */ #define OMX_BUFFERFLAG_CODECCONFIG 0x00000080 +#define OMX_BUFFERFLAG_VENDOR_SEEK_SYNC 0x00010000 + /** @ingroup buf */ diff --git a/include/media/stagefright/openmax/OMX_Index.h b/include/media/stagefright/openmax/OMX_Index.h index c0b8d9296d770..58a3cd0d70226 100644 --- a/include/media/stagefright/openmax/OMX_Index.h +++ b/include/media/stagefright/openmax/OMX_Index.h @@ -262,6 +262,11 @@ typedef enum OMX_INDEXTYPE { to 0x7FFFFFFE. This range is not broken out by vendor, so private indexes are not guaranteed unique and therefore should only be sent to the appropriate component. */ + + OMX_IndexParamEnableAndroidBuffers = 0x7FF00000, + OMX_IndexParamGetAndroidNativeBuffer, + OMX_IndexParamUseAndroidNativeBuffer, + OMX_IndexParamUseAndroidNativeBuffer2, OMX_IndexMax = 0x7FFFFFFF diff --git a/include/surfaceflinger/ISurfaceComposer.h b/include/surfaceflinger/ISurfaceComposer.h index c96f88a084d5f..6fa99bf00f9b8 100644 --- a/include/surfaceflinger/ISurfaceComposer.h +++ b/include/surfaceflinger/ISurfaceComposer.h @@ -126,6 +126,9 @@ class ISurfaceComposer : public IInterface virtual status_t turnElectronBeamOff(int32_t mode) = 0; virtual status_t turnElectronBeamOn(int32_t mode) = 0; + + virtual int setDisplayProp(int cmd,int param0,int param1,int param2) = 0; + virtual int getDisplayProp(int cmd,int param0,int param1) = 0; /* verify that an ISurfaceTexture was created by SurfaceFlinger. */ @@ -160,6 +163,8 @@ class BnSurfaceComposer : public BnInterface #ifdef QCOM_HDMI_OUT EXTERNAL_DISPLAY, #endif + SET_DISPLAYPROP, + GET_DISPLAYPROP, }; virtual status_t onTransact( uint32_t code, diff --git a/include/surfaceflinger/SurfaceComposerClient.h b/include/surfaceflinger/SurfaceComposerClient.h index c853d6a1271f3..15ac6ca55669e 100644 --- a/include/surfaceflinger/SurfaceComposerClient.h +++ b/include/surfaceflinger/SurfaceComposerClient.h @@ -119,6 +119,9 @@ class SurfaceComposerClient : public RefBase //! Resume updates on the specified display. static status_t unfreezeDisplay(DisplayID dpy, uint32_t flags = 0); + + static int setDisplayProp(int cmd,int param0,int param1,int param2); + static int getDisplayProp(int cmd,int param0,int param1); //! Set the orientation of the given display static int setOrientation(DisplayID dpy, int orientation, uint32_t flags); diff --git a/include/ui/DisplayDispatcher.h b/include/ui/DisplayDispatcher.h new file mode 100644 index 0000000000000..593a150da8e82 --- /dev/null +++ b/include/ui/DisplayDispatcher.h @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2010 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 _UI_DISPLAY_DISPATCHER_H +#define _UI_DISPLAY_DISPATCHER_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DISPLAYDISPATCH_MAXBUFNO 3 + +#define DISPLAY_CMD_SETDISPPARA 0 +#define DISPLAY_CMD_CHANGEDISPMODE 1 +#define DISPLAY_CMD_OPENDISP 2 +#define DISPLAY_CMD_CLOSEDISP 3 +#define DISPLAY_CMD_GETHDMISTATUS 4 +#define DISPLAY_CMD_GETTVSTATUS 5 +#define DISPLAY_CMD_GETDISPPARA 6 +#define DISPLAY_CMD_SETMASTERDISP 7 +#define DISPLAY_CMD_GETMASTERDISP 8 +#define DISPLAY_CMD_GETMAXWIDTHDISP 9 +#define DISPLAY_CMD_GETMAXHDMIMODE 10 +#define DISPLAY_CMD_GETDISPLAYMODE 11 +#define DISPLAY_CMD_GETDISPCOUNT 12 +#define DISPLAY_CMD_SETDISPMODE 13 +#define DISPLAY_CMD_SETBACKLIGHTMODE 14 +namespace android +{ + /* ͬÏÔʱµÄÖ¡¹ÜÀíÏß³Ì */ + class DisplayDispatcherThread : public Thread + { + public: + explicit DisplayDispatcherThread(display_device_t* mDevice); + ~DisplayDispatcherThread(); + void setSrcBuf(int srcfb_id,int srcfb_offset); + void signalEvent(); + void waitForEvent(); + void resetEvent(); + + private: + sp mSemaphore; + int mSrcfbid; + int mSrcfboffset; + int mCurfb; /*¶¨ÒåͬÏÔʱÐèÒªÏÔʾ¸±ÆÁÐèÒªÏÔʾµÄfb no*/ + int mFbOffset; /*¶¨Ò嵱ǰÔÚ¸±ÆÁÉÏÏÔʾµÄfbÖеÄbuffer id*/ + int mFrameidx[DISPLAYDISPATCH_MAXBUFNO]; /*ÿ¸öbuffer¹ÜÀíµÄÖ¡ºÅ*/ + void enqueuebuf(int frameidx); + virtual bool threadLoop(); + void LooperOnce(); + display_device_t* mDispDevice; + }; + + class DisplayDispatcher:public virtual RefBase + { + public: + DisplayDispatcher(); + ~DisplayDispatcher(); + + int setDispProp(int cmd,int param0,int param1,int param2); + int getDispProp(int cmd,int param0,int param1); + void startSwapBuffer(); + private: + int changeDisplayMode(int displayno, int value0,int value1); + int setDisplayParameter(int displayno, int value0,int value1); + int setDisplayMode(int mode); + int openDisplay(int displayno); + int closeDisplay(int displayno); + int getHdmiStatus(void); + int getTvDacStatus(void); + int getDisplayParameter(int displayno, int param); + int setMasterDisplay(int displayno); + int getMasterDisplay(); + int getDisplayMode(); + int getDisplayCount(); + int getMaxWidthDisplay(); + int getMaxHdmiMode(); + int setDisplayBacklightMode(int mode); + + bool mDisplayOpen0; + bool mDisplayOpen1; + int mDisplayMaster; + int mDisplayMode; + int mDisplayPixelFormat0; + int mDisplayPixelFormat1; + int mDisplayType0; + int mDisplayType1; + int mDisplayFormat0; + int mDisplayFormat1; + sp mThread; + display_device_t* mDevice; + + }; + +} // namespace android + +#endif // _UI_INPUT_DISPATCHER_H diff --git a/include/ui/DisplaySemaphore.h b/include/ui/DisplaySemaphore.h new file mode 100644 index 0000000000000..ab96943138b90 --- /dev/null +++ b/include/ui/DisplaySemaphore.h @@ -0,0 +1,63 @@ +/** + src/tsemaphore.h + + Implements a simple inter-thread semaphore so not to have to deal with IPC + creation and the like. + + Copyright (C) 2007-2009 STMicroelectronics + Copyright (C) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). + + This library is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free + Software Foundation; either version 2.1 of the License, or (at your option) + any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin St, Fifth Floor, Boston, MA + 02110-1301 USA + +*/ + +#ifndef __UI_DISPLAYSEMAPHORE_H_ +#define __UI_DISPLAYSEMAPHORE_H_ + +#include +#include + +/** The structure contains the semaphore value, mutex and green light flag + */ + +namespace android +{ + class DisplaySemaphore:public virtual RefBase + { + public: + DisplaySemaphore(unsigned int val); + ~DisplaySemaphore(); + + void down(); + void up(); + void reset(); + void wait(); + + /** Signal the condition,if waiting + * + * @param tsem the semaphore to signal + */ + void signal(); + private: + pthread_cond_t condition; + pthread_mutex_t mutex; + unsigned int semval; + }; +} + + +#endif + diff --git a/include/ui/Input.h b/include/ui/Input.h index cf9fb8690632e..7c3d42a0065e9 100644 --- a/include/ui/Input.h +++ b/include/ui/Input.h @@ -209,6 +209,8 @@ struct PointerCoords { status_t setAxisValue(int32_t axis, float value); void scale(float scale); + + void scale(float scalex,float scaley); inline float getX() const { return getAxisValue(AMOTION_EVENT_AXIS_X); @@ -547,6 +549,7 @@ class MotionEvent : public InputEvent { void offsetLocation(float xOffset, float yOffset); void scale(float scaleFactor); + void scale(float scalex, float scaley); #ifdef HAVE_ANDROID_OS void transform(const SkMatrix* matrix); diff --git a/libs/camera/Camera.cpp b/libs/camera/Camera.cpp index 7ac3cc1df7181..ba4114a41a0f1 100644 --- a/libs/camera/Camera.cpp +++ b/libs/camera/Camera.cpp @@ -101,6 +101,16 @@ Camera::~Camera() // deadlock if we call any method of ICamera here. } +// add for set overlay screen +int Camera::setCameraScreen(int screen) +{ + LOGD("setCameraScreen: %d", screen); + const sp& cs = getCameraService(); + if (cs == 0) return UNKNOWN_ERROR; + + return cs->setCameraScreen(screen); +} + int32_t Camera::getNumberOfCameras() { const sp& cs = getCameraService(); diff --git a/libs/camera/ICameraService.cpp b/libs/camera/ICameraService.cpp index 85f1a29feb1a5..3e96ae5d25d23 100644 --- a/libs/camera/ICameraService.cpp +++ b/libs/camera/ICameraService.cpp @@ -65,6 +65,16 @@ class BpCameraService: public BpInterface remote()->transact(BnCameraService::CONNECT, data, &reply); return interface_cast(reply.readStrongBinder()); } + + // add for set overlay screen + virtual int setCameraScreen(int screen) + { + Parcel data, reply; + data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); + data.writeInt32(screen); + remote()->transact(BnCameraService::SET_CAMERA_SCREEN, data, &reply); + return reply.readInt32(); + } }; IMPLEMENT_META_INTERFACE(CameraService, "android.hardware.ICameraService"); @@ -97,6 +107,14 @@ status_t BnCameraService::onTransact( reply->writeStrongBinder(camera->asBinder()); return NO_ERROR; } break; + // add for set overlay screen + case SET_CAMERA_SCREEN: { + LOGV("SET_CAMERA_SCREEN"); + CHECK_INTERFACE(ICameraService, data, reply); + int screen = data.readInt32(); + reply->writeInt32(setCameraScreen(screen)); + return NO_ERROR; + } break; default: return BBinder::onTransact(code, data, reply, flags); } diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 1b18d4f7590d4..ae54ba40c4458 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -122,6 +122,29 @@ class BpSurfaceComposer : public BpInterface return reply.readInt32(); } + virtual int setDisplayProp(int cmd,int param0,int param1,int param2) + { + Parcel data, reply; + data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); + data.writeInt32(cmd); + data.writeInt32(param0); + data.writeInt32(param1); + data.writeInt32(param2); + remote()->transact(BnSurfaceComposer::SET_DISPLAYPROP, data, &reply); + return reply.readInt32(); + } + + virtual int getDisplayProp(int cmd,int param0,int param1) + { + Parcel data, reply; + data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); + data.writeInt32(cmd); + data.writeInt32(param0); + data.writeInt32(param1); + remote()->transact(BnSurfaceComposer::GET_DISPLAYPROP, data, &reply); + return reply.readInt32(); + } + virtual status_t turnElectronBeamOff(int32_t mode) { Parcel data, reply; @@ -274,6 +297,29 @@ status_t BnSurfaceComposer::onTransact( enableExternalDisplay(disp_type, enable); } break; #endif + case SET_DISPLAYPROP: + { + CHECK_INTERFACE(ISurfaceComposer, data, reply); + int cmd = data.readInt32(); + int param0 = data.readInt32(); + int param1 = data.readInt32(); + int param2 = data.readInt32(); + int res = setDisplayProp(cmd,param0,param1,param2); + reply->writeInt32(res); + } + break; + + case GET_DISPLAYPROP: + { + CHECK_INTERFACE(ISurfaceComposer, data, reply); + int cmd = data.readInt32(); + int param0 = data.readInt32(); + int param1 = data.readInt32(); + int res = getDisplayProp(cmd,param0,param1); + reply->writeInt32(res); + } + break; + default: return BBinder::onTransact(code, data, reply, flags); } diff --git a/libs/gui/ISurfaceTexture.cpp b/libs/gui/ISurfaceTexture.cpp index 860e54cd24f4c..cc8faed89b7c7 100644 --- a/libs/gui/ISurfaceTexture.cpp +++ b/libs/gui/ISurfaceTexture.cpp @@ -24,7 +24,7 @@ #include #include - +#include #include namespace android { @@ -43,6 +43,8 @@ enum { CONNECT, DISCONNECT, SET_SCALING_MODE, + SET_PARAMETER, + GET_PARAMETER, #ifdef QCOM_HARDWARE PERFORM_QCOM_OPERATION, #endif @@ -237,6 +239,56 @@ class BpSurfaceTexture : public BpInterface return result; } #endif + + virtual int setParameter(uint32_t cmd,uint32_t value) + { + Parcel data, reply; + data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor()); + data.writeInt32(cmd); + if(cmd == HWC_LAYER_SETINITPARA) + { + layerinitpara_t *layer_info = (layerinitpara_t *)value; + LOGD("layer_info.w = %d\n",layer_info->w); + LOGD("layer_info.h = %d\n",layer_info->h); + LOGD("layer_info.format = %d\n",layer_info->format); + LOGD("layer_info.screenid = %d\n",layer_info->screenid); + + data.write((void *)value,sizeof(layerinitpara_t)); + } + else if(cmd == HWC_LAYER_SETFRAMEPARA) + { + data.write((void *)value,sizeof(libhwclayerpara_t)); + } + else if(cmd == HWC_LAYER_SET3DMODE) + { + data.write((void *)value,sizeof(video3Dinfo_t)); + } + else + { + data.writeInt32(value); + } + status_t result = remote()->transact(SET_PARAMETER, data, &reply); + if (result != NO_ERROR) + { + return result; + } + result = reply.readInt32(); + return result; + } + + virtual uint32_t getParameter(uint32_t cmd) + { + Parcel data, reply; + data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor()); + data.writeInt32(cmd); + status_t result =remote()->transact(GET_PARAMETER, data, &reply); + if (result != NO_ERROR) + { + return result; + } + result = reply.readInt32(); + return result; + } }; IMPLEMENT_META_INTERFACE(SurfaceTexture, "android.gui.SurfaceTexture"); @@ -369,6 +421,52 @@ status_t BnSurfaceTexture::onTransact( return NO_ERROR; } break; #endif + case SET_PARAMETER: { + CHECK_INTERFACE(ISurfaceTexture, data, reply); + uint32_t cmd = (uint32_t)data.readInt32(); + uint32_t value; + if(cmd == HWC_LAYER_SETINITPARA) + { + layerinitpara_t layer_info; + + data.read((void *)&layer_info,sizeof(layerinitpara_t)); + + value = (uint32_t)&layer_info; + + LOGD("layer_info.w = %d\n",layer_info.w); + LOGD("layer_info.h = %d\n",layer_info.h); + LOGD("layer_info.format = %d\n",layer_info.format); + LOGD("layer_info.screenid = %d\n",layer_info.screenid); + } + else if(cmd == HWC_LAYER_SETFRAMEPARA) + { + libhwclayerpara_t frame_info; + + data.read((void *)&frame_info,sizeof(libhwclayerpara_t)); + + value = (uint32_t)&frame_info; + } + else if(cmd == HWC_LAYER_SET3DMODE) + { + video3Dinfo_t _3d_info; + data.read((void *)&_3d_info, sizeof(video3Dinfo_t)); + value = (uint32_t)&_3d_info; + } + else + { + value = (uint32_t)data.readInt32(); + } + int res = setParameter(cmd,value); + reply->writeInt32(res); + return NO_ERROR; + } break; + case GET_PARAMETER: { + CHECK_INTERFACE(ISurfaceTexture, data, reply); + uint32_t cmd = (uint32_t)data.readInt32(); + uint32_t res = getParameter(cmd); + reply->writeInt32((int32_t)res); + return NO_ERROR; + } break; } return BBinder::onTransact(code, data, reply, flags); } diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 4e570e84fe50f..0d555d8e06e3f 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -545,6 +545,20 @@ status_t SurfaceComposerClient::unfreezeDisplay(DisplayID dpy, uint32_t flags) return NO_ERROR; } +int SurfaceComposerClient::setDisplayProp(int cmd,int param0,int param1,int param2) +{ + sp s(ComposerService::getComposerService()); + if (s == NULL) return NO_INIT; + return s->setDisplayProp(cmd,param0,param1,param2); +} + +int SurfaceComposerClient::getDisplayProp(int cmd,int param0,int param1) +{ + sp s(ComposerService::getComposerService()); + if (s == NULL) return NO_INIT; + + return s->getDisplayProp(cmd,param0,param1); +} // ---------------------------------------------------------------------------- ScreenshotClient::ScreenshotClient() diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp index 35ad9ace6158c..436f6d9018d26 100644 --- a/libs/gui/SurfaceTexture.cpp +++ b/libs/gui/SurfaceTexture.cpp @@ -28,7 +28,7 @@ #include #include - +#include #include #include #include @@ -741,7 +741,9 @@ status_t SurfaceTexture::connect(int api, case NATIVE_WINDOW_API_CPU: case NATIVE_WINDOW_API_MEDIA: case NATIVE_WINDOW_API_CAMERA: - if (mConnectedApi != NO_CONNECTED_API) { + case NATIVE_WINDOW_API_MEDIA_HW: + case NATIVE_WINDOW_API_CAMERA_HW: + if (mConnectedApi != NO_CONNECTED_API && (mConnectedApi != api)) { ST_LOGE("connect: already connected (cur=%d, req=%d)", mConnectedApi, api); err = -EINVAL; @@ -775,6 +777,8 @@ status_t SurfaceTexture::disconnect(int api) { case NATIVE_WINDOW_API_CPU: case NATIVE_WINDOW_API_MEDIA: case NATIVE_WINDOW_API_CAMERA: + case NATIVE_WINDOW_API_MEDIA_HW: + case NATIVE_WINDOW_API_CAMERA_HW: if (mConnectedApi == api) { drainQueueAndFreeBuffersLocked(); mConnectedApi = NO_CONNECTED_API; @@ -1252,6 +1256,44 @@ void SurfaceTexture::setName(const String8& name) { mName = name; } +bool SurfaceTexture::IsHardwareRenderSupport() +{ + if(mPixelFormat >= HWC_FORMAT_MINVALUE && mPixelFormat <= HWC_FORMAT_MAXVALUE) + { + return true; + } + + return false; +} + +int SurfaceTexture::setParameter(uint32_t cmd,uint32_t value) +{ + mCurrentTransform = mNextTransform; + mCurrentCrop = mNextCrop; + mCurrentScalingMode = mNextScalingMode; + if(cmd == HWC_LAYER_SETINITPARA) + { + layerinitpara_t *layer_info; + + layer_info = (layerinitpara_t *)value; + mPixelFormat = layer_info->format; + } + + if(IsHardwareRenderSupport()) + { + return 100; + } + else + { + return 0; + } +} + +uint32_t SurfaceTexture::getParameter(uint32_t cmd) +{ + return 0; +} + void SurfaceTexture::dump(String8& result) const { char buffer[1024]; diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp index 03a971b3245de..f644b0b50ebd0 100644 --- a/libs/gui/SurfaceTextureClient.cpp +++ b/libs/gui/SurfaceTextureClient.cpp @@ -20,7 +20,7 @@ #include #include #include - +#include #include #ifdef QCOM_HARDWARE @@ -336,6 +336,15 @@ int SurfaceTextureClient::perform(int operation, va_list args) case NATIVE_WINDOW_API_DISCONNECT: res = dispatchDisconnect(args); break; + + case NATIVE_WINDOW_SETPARAMETER: + res = dispatchSetParameter(args); + break; + + case NATIVE_WINDOW_GETPARAMETER: + res = dispatchGetParameter(args); + break; + default: #ifdef QCOM_HARDWARE res = dispatchPerformQcomOperation(operation, args); @@ -376,6 +385,21 @@ int SurfaceTextureClient::dispatchDisconnect(va_list args) { return disconnect(api); } +int SurfaceTextureClient::dispatchSetParameter(va_list args) +{ + int cmd = va_arg(args,int); + int value = va_arg(args,int); + + return setParameter((uint32_t)cmd,(uint32_t)value); +} + +int SurfaceTextureClient::dispatchGetParameter(va_list args) +{ + int cmd = va_arg(args,int); + + return getParameter((uint32_t)cmd); +} + int SurfaceTextureClient::dispatchSetUsage(va_list args) { int usage = va_arg(args, int); return setUsage(usage); @@ -392,9 +416,11 @@ int SurfaceTextureClient::dispatchSetBufferCount(va_list args) { } int SurfaceTextureClient::dispatchSetBuffersGeometry(va_list args) { + layerinitpara_t layer_info; int w = va_arg(args, int); int h = va_arg(args, int); int f = va_arg(args, int); + int screenid = va_arg(args, int); int err = setBuffersDimensions(w, h); if (err != 0) { return err; @@ -406,7 +432,20 @@ int SurfaceTextureClient::dispatchSetBuffersGeometry(va_list args) { return err; } #endif - return setBuffersFormat(f); + LOGD("dispatchSetBuffersGeometry1!\n"); + err = setBuffersFormat(f); + if (err != 0) + { + return err; + } + + LOGD("dispatchSetBuffersGeometry2!\n"); + + layer_info.w = w; + layer_info.h = h; + layer_info.format = f; + layer_info.screenid = screenid; + return setParameter(HWC_LAYER_SETINITPARA,(uint32_t)&layer_info); } int SurfaceTextureClient::dispatchSetBuffersDimensions(va_list args) { @@ -492,6 +531,20 @@ int SurfaceTextureClient::disconnect(int api) { return err; } +int SurfaceTextureClient::setParameter(uint32_t cmd,uint32_t value) +{ + LOGV("SurfaceTextureClient::setParameter"); + + return mSurfaceTexture->setParameter(cmd,value); +} + +int SurfaceTextureClient::getParameter(uint32_t cmd) +{ + LOGV("SurfaceTextureClient::setParameter"); + + return mSurfaceTexture->getParameter(cmd); +} + int SurfaceTextureClient::setUsage(uint32_t reqUsage) { LOGV("SurfaceTextureClient::setUsage"); diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk index 98454cc1ef914..33ec9aef7fd45 100644 --- a/libs/ui/Android.mk +++ b/libs/ui/Android.mk @@ -48,6 +48,8 @@ LOCAL_SRC_FILES:= \ GraphicBufferAllocator.cpp \ GraphicBufferMapper.cpp \ GraphicLog.cpp \ + DisplayDispatcher.cpp \ + DisplaySemaphore.cpp \ InputTransport.cpp \ PixelFormat.cpp \ Rect.cpp \ diff --git a/libs/ui/DisplayDispatcher.cpp b/libs/ui/DisplayDispatcher.cpp new file mode 100644 index 0000000000000..1cccfa584fda0 --- /dev/null +++ b/libs/ui/DisplayDispatcher.cpp @@ -0,0 +1,531 @@ +// +// Copyright 2010 The Android Open Source Project +// +// The Display dispatcher. +// +#define LOG_TAG "DisplayDispatcher" + +//#define LOG_NDEBUG 0 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define INDENT " " +#define INDENT2 " " + +#define MAX_FRAMEID 2147483640 + +namespace android +{ + void DisplayDispatcherThread::enqueuebuf(int frameidx) + { + int i; + int tmp; + + tmp = mFrameidx[frameidx]; + //LOGD("frameidx = %d\n",frameidx); + //LOGD("mFrameidx0[0] = %d\n",mFrameidx[0]); + //LOGD("mFrameidx0[1] = %d\n",mFrameidx[1]); + //LOGD("mFrameidx0[2] = %d\n",mFrameidx[2]); + for(i = frameidx;i > 0;i--) + { + mFrameidx[i] = mFrameidx[i - 1]; + } + + mFrameidx[0] = tmp; + + //LOGD("mFrameidx1[0] = %d\n",mFrameidx[0]); + //LOGD("mFrameidx1[1] = %d\n",mFrameidx[1]); + //LOGD("mFrameidx1[2] = %d\n",mFrameidx[2]); + } + + void DisplayDispatcherThread::setSrcBuf(int srcfb_id,int srcfb_offset) + { + mSrcfbid = srcfb_id; + mSrcfboffset = srcfb_offset; + } + + void DisplayDispatcherThread::signalEvent() + { + //LOGD("signalEvent!\n"); + mSemaphore->up(); + } + + void DisplayDispatcherThread::waitForEvent() + { + //LOGD("waitForEvent!\n"); + mSemaphore->down(); + } + + void DisplayDispatcherThread::resetEvent() + { + //LOGD("waitForEvent!\n"); + mSemaphore->reset(); + } + + // --- InputDispatcherThread --- + void DisplayDispatcherThread::LooperOnce() + { + int writebufid; + int showbufid; + int ret; + int write_index; + + //LOGD("before waitForEvent!\n"); + waitForEvent(); + //LOGD("after waitForEvent!\n"); + + mDispDevice->request_modelock(mDispDevice); + + if(mFrameidx[DISPLAYDISPATCH_MAXBUFNO - 1] == mFbOffset) + { + writebufid = mFrameidx[DISPLAYDISPATCH_MAXBUFNO - 2]; + + write_index = DISPLAYDISPATCH_MAXBUFNO - 2; + } + else + { + writebufid = mFrameidx[DISPLAYDISPATCH_MAXBUFNO - 1]; + + write_index = DISPLAYDISPATCH_MAXBUFNO - 1; + } + + //LOGD("writebufid = %d\n",writebufid); + + ret = mDispDevice->copysrcfbtodstfb(mDispDevice,mSrcfbid,1 - mSrcfboffset,1 - mSrcfbid,writebufid); + if(ret != 0) + { + //LOGE("copy src fb failed!\n"); + + mDispDevice->release_modelock(mDispDevice); + + return ; + } + + enqueuebuf(write_index); + + showbufid = mFrameidx[0]; + + mFbOffset = showbufid; + + //LOGD("showbufid = %d,mSrcfbid = %d\n",showbufid,mSrcfbid); + + mDispDevice->pandisplay(mDispDevice,1 - mSrcfbid,showbufid); + + mDispDevice->release_modelock(mDispDevice); + } + + DisplayDispatcherThread::DisplayDispatcherThread(display_device_t* mDevice) : + Thread(/*canCallJava*/ true), mDispDevice(mDevice) + { + for(int i = 0;i < DISPLAYDISPATCH_MAXBUFNO;i++) + { + mFrameidx[i] = i; + } + + mSemaphore = new DisplaySemaphore(0); + } + + DisplayDispatcherThread::~DisplayDispatcherThread() + { + + } + + + bool DisplayDispatcherThread::threadLoop() + { + this->LooperOnce(); + return true; + } + + DisplayDispatcher::DisplayDispatcher() + { + int err; + hw_module_t* module; + status_t result; + char property[PROPERTY_VALUE_MAX]; + err = hw_get_module(DISPLAY_HARDWARE_MODULE_ID, (hw_module_t const**)&module); + if (err == 0) + { + LOGD("DisplayDispatcher createing1 err = %d!\n",err); + + err = display_open(module, &mDevice); + if (err == 0) + { + LOGE("Open Display Device Failed!\n"); + } + } + else + { + LOGD("hw_get display module Failed!\n"); + } + + if (property_get("ro.display.switch", property, NULL) > 0) + { + if (atoi(property) == 1) + { + LOGW("display dispatcher enabled"); + mThread = new DisplayDispatcherThread(mDevice); + result = mThread->run("DisplayDispatcheR", PRIORITY_HIGHEST); + if (result) + { + LOGE("Could not start DisplayDispatcheR thread due to error %d.", result); + + mThread->requestExit(); + } + } + else + { + LOGW("display dispatcher disable"); + } + } + else + { + LOGW("display dispatcher disable"); + } + //LOGD("DisplayDispatcher createing err2 = %d!\n",err); + + + } + + DisplayDispatcher::~DisplayDispatcher() + { + + } + + int DisplayDispatcher::changeDisplayMode(int displayno, int value0,int value1) + { + int ret; + + if(mDevice) + { + return mDevice->changemode(mDevice,displayno,value0,value1); + } + + return -1; + } + + int DisplayDispatcher::setDisplayParameter(int displayno, int value0,int value1) + { + if(displayno == 0) + { + if(value0 == DISPLAY_DEVICE_LCD) + { + mDisplayType0 = DISPLAY_DEVICE_LCD; + } + else if(value0 == DISPLAY_DEVICE_TV) + { + mDisplayType0 = DISPLAY_DEVICE_TV; + mDisplayFormat0 = value1; + } + else if(value0 == DISPLAY_DEVICE_HDMI) + { + mDisplayType0 = DISPLAY_DEVICE_HDMI; + mDisplayFormat0 = value1; + } + else if(value0 == DISPLAY_DEVICE_VGA) + { + mDisplayType0 = DISPLAY_DEVICE_VGA; + mDisplayFormat0 = value1; + } + else + { + mDisplayPixelFormat0 = value1; + } + } + else + { + if(value0 == DISPLAY_DEVICE_LCD) + { + mDisplayType1 = DISPLAY_DEVICE_LCD; + } + else if(value0 == DISPLAY_DEVICE_TV) + { + mDisplayType1 = DISPLAY_DEVICE_TV; + mDisplayFormat1 = value1; + } + else if(value0 == DISPLAY_DEVICE_HDMI) + { + mDisplayType1 = DISPLAY_DEVICE_HDMI; + mDisplayFormat1 = value1; + } + else if(value0 == DISPLAY_DEVICE_VGA) + { + mDisplayType1 = DISPLAY_DEVICE_VGA; + mDisplayFormat1 = value1; + } + else + { + mDisplayPixelFormat1 = value1; + } + } + + return 0; + } + + + int DisplayDispatcher::setDisplayMode(int mode) + { + if(mDevice) + { + struct display_modepara_t disp_para; + + disp_para.d0type = mDisplayType0; + disp_para.d1type = mDisplayType1; + disp_para.d0format = mDisplayFormat0; + disp_para.d1format = mDisplayFormat1; + disp_para.d0pixelformat = mDisplayPixelFormat0; + disp_para.d1pixelformat = mDisplayPixelFormat1; + disp_para.masterdisplay = mDisplayMaster; + + return mDevice->setdisplaymode(mDevice,mode,&disp_para); + } + + return -1; + } + + int DisplayDispatcher::openDisplay(int displayno) + { + if(mDevice) + { + if(displayno == 0) + { + mDisplayOpen0 = true; + } + else + { + mDisplayOpen1 = true; + } + + return mDevice->opendisplay(mDevice,displayno); + } + + return -1; + } + + int DisplayDispatcher::closeDisplay(int displayno) + { + if(mDevice) + { + if(displayno == 0) + { + mDisplayOpen0 = false; + } + else + { + mDisplayOpen1 = false; + } + return mDevice->closedisplay(mDevice,displayno); + } + + return -1; + } + + int DisplayDispatcher::getHdmiStatus(void) + { + if(mDevice) + { + return mDevice->gethdmistatus(mDevice); + } + + return -1; + } + + int DisplayDispatcher::getTvDacStatus(void) + { + if(mDevice) + { + return mDevice->gettvdacstatus(mDevice); + } + + return -1; + } + + int DisplayDispatcher::getDisplayParameter(int displayno, int param) + { + if(mDevice) + { + return mDevice->getdisplayparameter(mDevice,displayno,param); + } + + return -1; + } + + int DisplayDispatcher::setMasterDisplay(int displayno) + { + if(mDevice) + { + return mDevice->setmasterdisplay(mDevice,displayno); + } + + return -1; + } + + int DisplayDispatcher::getMasterDisplay() + { + if(mDevice) + { + return mDevice->getmasterdisplay(mDevice); + } + + return -1; + } + + int DisplayDispatcher::getMaxWidthDisplay() + { + if(mDevice) + { + return mDevice->getmaxwidthdisplay(mDevice); + } + + return -1; + } + + int DisplayDispatcher::getMaxHdmiMode() + { + if(mDevice) + { + return mDevice->gethdmimaxmode(mDevice); + } + + return -1; + } + + int DisplayDispatcher::getDisplayMode() + { + if(mDevice) + { + return mDevice->getdisplaymode(mDevice); + } + + return -1; + } + + int DisplayDispatcher::getDisplayCount() + { + if(mDevice) + { + return mDevice->getdisplaycount(mDevice); + } + + return -1; + } + int DisplayDispatcher::setDisplayBacklightMode(int mode) + { + if(mDevice) + { + return mDevice->setdisplaybacklightmode(mDevice,mode); + } + + return -1; + } + int DisplayDispatcher::setDispProp(int cmd,int param0,int param1,int param2) + { + switch(cmd) + { + case DISPLAY_CMD_SETDISPPARA: + return setDisplayParameter(param0,param1,param2); + + case DISPLAY_CMD_CHANGEDISPMODE: + return changeDisplayMode(param0,param1,param2); + + case DISPLAY_CMD_CLOSEDISP: + return closeDisplay(param0); + + case DISPLAY_CMD_OPENDISP: + return openDisplay(param0); + + case DISPLAY_CMD_GETDISPCOUNT: + return getDisplayCount(); + + case DISPLAY_CMD_GETDISPLAYMODE: + return getDisplayMode(); + + case DISPLAY_CMD_GETDISPPARA: + return getDisplayParameter(param0,param1); + + case DISPLAY_CMD_GETHDMISTATUS: + return getHdmiStatus(); + + case DISPLAY_CMD_GETMASTERDISP: + return getMasterDisplay(); + + case DISPLAY_CMD_GETMAXHDMIMODE: + return getMaxHdmiMode(); + + case DISPLAY_CMD_GETMAXWIDTHDISP: + return getMaxWidthDisplay(); + + case DISPLAY_CMD_GETTVSTATUS: + return getTvDacStatus(); + + case DISPLAY_CMD_SETMASTERDISP: + return setMasterDisplay(param0); + + case DISPLAY_CMD_SETDISPMODE: + return setDisplayMode(param0); + + case DISPLAY_CMD_SETBACKLIGHTMODE: + return setDisplayBacklightMode(param0); + + default: + LOGE("Display Cmd not Support!\n"); + return -1; + } + } + + int DisplayDispatcher::getDispProp(int cmd,int param0,int param1) + { + return 0; + } + + void DisplayDispatcher::startSwapBuffer() + { + int master_bufid; + int master_display; + int mode; + int outputtype; + int plugin; + + mode = mDevice->getdisplaymode(mDevice); + master_display = mDevice->getmasterdisplay(mDevice); + outputtype = mDevice->getdisplayparameter(mDevice,1 - master_display,DISPLAY_OUTPUT_TYPE); + if(outputtype == DISPLAY_DEVICE_HDMI) + { + plugin = mDevice->gethdmistatus(mDevice); + if(plugin == 0) + { + mThread->resetEvent(); + + return ; + } + } + else if(outputtype == DISPLAY_DEVICE_TV) + { + plugin = mDevice->gettvdacstatus(mDevice); + if(plugin == 0) + { + mThread->resetEvent(); + + return ; + } + } + + if(mode == DISPLAY_MODE_DUALSAME) + { + master_bufid = mDevice->getdisplaybufid(mDevice,master_display); + + mThread->setSrcBuf(master_display,master_bufid); + mThread->signalEvent(); + } + } + +} // namespace android diff --git a/libs/ui/DisplaySemaphore.cpp b/libs/ui/DisplaySemaphore.cpp new file mode 100644 index 0000000000000..bddd55ea4eece --- /dev/null +++ b/libs/ui/DisplaySemaphore.cpp @@ -0,0 +1,126 @@ +/** + src/tsemaphore.c + + Implements a simple inter-thread semaphore so not to have to deal with IPC + creation and the like. + + Copyright (C) 2007-2009 STMicroelectronics + Copyright (C) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). + + This library is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free + Software Foundation; either version 2.1 of the License, or (at your option) + any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin St, Fifth Floor, Boston, MA + 02110-1301 USA + +*/ + +#include +#include +#include +#include +#include + +#define LOG_NDEBUG 0 + +/** Initializes the semaphore at a given value + * + * @param tsem the semaphore to initialize + * @param val the initial value of the semaphore + * + */ +namespace android +{ + /** Initializes the semaphore at a given value + * + * @param tsem the semaphore to initialize + * @param val the initial value of the semaphore + * + */ + DisplaySemaphore::DisplaySemaphore(unsigned int val) + { + pthread_cond_init(&condition, NULL); + pthread_mutex_init(&mutex, NULL); + semval = val; + } + + /** Destroy the semaphore + * + * @param tsem the semaphore to destroy + */ + DisplaySemaphore::~DisplaySemaphore() + { + pthread_cond_destroy(&condition); + pthread_mutex_destroy(&mutex); + } + + /** Decreases the value of the semaphore. Blocks if the semaphore + * value is zero. + * + * @param tsem the semaphore to decrease + */ + void DisplaySemaphore::down() + { + pthread_mutex_lock(&mutex); + while (semval == 0) + { + pthread_cond_wait(&condition, &mutex); + } + semval--; + pthread_mutex_unlock(&mutex); + } + + /** Increases the value of the semaphore + * + * @param tsem the semaphore to increase + */ + void DisplaySemaphore::up() + { + pthread_mutex_lock(&mutex); + semval++; + pthread_cond_signal(&condition); + pthread_mutex_unlock(&mutex); + } + + /** Reset the value of the semaphore + * + * @param tsem the semaphore to reset + */ + void DisplaySemaphore::reset() + { + pthread_mutex_lock(&mutex); + semval=0; + pthread_mutex_unlock(&mutex); + } + + /** Wait on the condition. + * + * @param tsem the semaphore to wait + */ + void DisplaySemaphore::wait() + { + pthread_mutex_lock(&mutex); + pthread_cond_wait(&condition, &mutex); + pthread_mutex_unlock(&mutex); + } + + /** Signal the condition,if waiting + * + * @param tsem the semaphore to signal + */ + void DisplaySemaphore::signal() + { + pthread_mutex_lock(&mutex); + pthread_cond_signal(&condition); + pthread_mutex_unlock(&mutex); + } +} diff --git a/libs/ui/Input.cpp b/libs/ui/Input.cpp index 3de75bae94045..942d29fbd2e3a 100644 --- a/libs/ui/Input.cpp +++ b/libs/ui/Input.cpp @@ -318,6 +318,17 @@ void PointerCoords::scale(float scaleFactor) { scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOOL_MINOR, scaleFactor); } +void PointerCoords::scale(float scalexFactor,float scaleyFactor) { + // No need to scale pressure or size since they are normalized. + // No need to scale orientation since it is meaningless to do so. + scaleAxisValue(*this, AMOTION_EVENT_AXIS_X, scalexFactor); + scaleAxisValue(*this, AMOTION_EVENT_AXIS_Y, scaleyFactor); + scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOUCH_MAJOR, scalexFactor); + scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOUCH_MINOR, scalexFactor); + scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOOL_MAJOR, scalexFactor); + scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOOL_MINOR, scalexFactor); +} + #ifdef HAVE_ANDROID_OS status_t PointerCoords::readFromParcel(Parcel* parcel) { bits = parcel->readInt64(); @@ -524,6 +535,18 @@ void MotionEvent::scale(float scaleFactor) { } } +void MotionEvent::scale(float scalexFactor, float scaleyFactor) { + mXOffset *= scalexFactor; + mYOffset *= scaleyFactor; + mXPrecision *= scalexFactor; + mYPrecision *= scaleyFactor; + + size_t numSamples = mSamplePointerCoords.size(); + for (size_t i = 0; i < numSamples; i++) { + mSamplePointerCoords.editItemAt(i).scale(scalexFactor,scaleyFactor); + } +} + #ifdef HAVE_ANDROID_OS static inline float transformAngle(const SkMatrix* matrix, float angleRadians) { // Construct and transform a vector oriented at the specified clockwise angle from vertical. diff --git a/media/java/android/media/MediaFile.java b/media/java/android/media/MediaFile.java index 142a829aecd3b..e499afef59ffc 100755 --- a/media/java/android/media/MediaFile.java +++ b/media/java/android/media/MediaFile.java @@ -79,8 +79,12 @@ public class MediaFile { // More video file types public static final int FILE_TYPE_MP2PS = 200; + public static final int FILE_TYPE_CEDARV = 201; private static final int FIRST_VIDEO_FILE_TYPE2 = FILE_TYPE_MP2PS; - private static final int LAST_VIDEO_FILE_TYPE2 = FILE_TYPE_MP2PS; + private static final int LAST_VIDEO_FILE_TYPE2 = FILE_TYPE_CEDARV; + + // More audio file types + private static final int FILE_TYPE_CEDARA = 300; // Image file types public static final int FILE_TYPE_JPEG = 32; @@ -184,9 +188,7 @@ private static boolean isWMVEnabled() { addFileType("AMR", FILE_TYPE_AMR, "audio/amr"); addFileType("AWB", FILE_TYPE_AWB, "audio/amr-wb"); addFileType("DIVX", FILE_TYPE_DIVX, "video/divx"); - if (isWMAEnabled()) { - addFileType("WMA", FILE_TYPE_WMA, "audio/x-ms-wma", MtpConstants.FORMAT_WMA); - } + addFileType("WMA", FILE_TYPE_WMA, "audio/x-ms-wma", MtpConstants.FORMAT_WMA); addFileType("QCP", FILE_TYPE_QCP, "audio/qcp"); addFileType("OGG", FILE_TYPE_OGG, "application/ogg", MtpConstants.FORMAT_OGG); addFileType("OGA", FILE_TYPE_OGG, "application/ogg", MtpConstants.FORMAT_OGG); @@ -194,6 +196,16 @@ private static boolean isWMVEnabled() { addFileType("AAC", FILE_TYPE_AAC, "audio/aac", MtpConstants.FORMAT_AAC); addFileType("AAC", FILE_TYPE_AAC, "audio/aac-adts", MtpConstants.FORMAT_AAC); addFileType("MKA", FILE_TYPE_MKA, "audio/x-matroska"); + + addFileType("APE", FILE_TYPE_CEDARA, "audio/cedara"); + //addFileType("FLAC",FILE_TYPE_CEDARA, "audio/cedara"); + addFileType("AC3", FILE_TYPE_CEDARA, "audio/cedara"); + addFileType("DTS", FILE_TYPE_CEDARA, "audio/cedara"); + addFileType("OMG", FILE_TYPE_CEDARA, "audio/cedara"); + addFileType("M4R", FILE_TYPE_CEDARA, "audio/cedara"); + addFileType("RA", FILE_TYPE_CEDARA, "audio/cedara"); + //addFileType("MP1", FILE_TYPE_CEDARA, "audio/cedara"); + //addFileType("MP2", FILE_TYPE_CEDARA, "audio/cedara"); addFileType("MID", FILE_TYPE_MID, "audio/midi"); addFileType("MIDI", FILE_TYPE_MID, "audio/midi"); @@ -216,12 +228,23 @@ private static boolean isWMVEnabled() { addFileType("MKV", FILE_TYPE_MKV, "video/x-matroska"); addFileType("WEBM", FILE_TYPE_WEBM, "video/webm"); addFileType("TS", FILE_TYPE_MP2TS, "video/mp2ts"); + addFileType("TP", FILE_TYPE_MP2TS, "video/mp2ts"); + addFileType("M2TS",FILE_TYPE_MP2TS, "video/mp2ts"); addFileType("AVI", FILE_TYPE_AVI, "video/avi"); - if (isWMVEnabled()) { - addFileType("WMV", FILE_TYPE_WMV, "video/x-ms-wmv", MtpConstants.FORMAT_WMV); - addFileType("ASF", FILE_TYPE_ASF, "video/x-ms-asf"); - } + addFileType("RMVB",FILE_TYPE_CEDARV, "video/cedarx"); + addFileType("RM", FILE_TYPE_CEDARV, "video/cedarx"); + addFileType("AVI", FILE_TYPE_CEDARV, "video/cedarx"); + addFileType("MOV", FILE_TYPE_CEDARV, "video/cedarx"); + addFileType("FLV", FILE_TYPE_CEDARV, "video/cedarx"); + addFileType("F4V", FILE_TYPE_CEDARV, "video/cedarx"); + addFileType("VOB", FILE_TYPE_CEDARV, "video/cedarx"); + addFileType("PMP", FILE_TYPE_CEDARV, "video/cedarx"); + addFileType("3DM", FILE_TYPE_CEDARV, "video/cedarx"); + addFileType("3DV", FILE_TYPE_CEDARV, "video/cedarx"); + + addFileType("WMV", FILE_TYPE_WMV, "video/x-ms-wmv", MtpConstants.FORMAT_WMV); + addFileType("ASF", FILE_TYPE_ASF, "video/x-ms-asf"); addFileType("JPG", FILE_TYPE_JPEG, "image/jpeg", MtpConstants.FORMAT_EXIF_JPEG); addFileType("JPEG", FILE_TYPE_JPEG, "image/jpeg", MtpConstants.FORMAT_EXIF_JPEG); @@ -258,7 +281,8 @@ public static boolean isAudioFileType(int fileType) { return ((fileType >= FIRST_AUDIO_FILE_TYPE && fileType <= LAST_AUDIO_FILE_TYPE) || (fileType >= FIRST_MIDI_FILE_TYPE && - fileType <= LAST_MIDI_FILE_TYPE)); + fileType <= LAST_MIDI_FILE_TYPE || + fileType == FILE_TYPE_CEDARA); } public static boolean isVideoFileType(int fileType) { diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index 8d71dcf644d01..1606e21f9d941 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -18,12 +18,15 @@ import android.content.ContentResolver; import android.content.Context; +import android.content.pm.PermissionInfo; import android.content.res.AssetFileDescriptor; import android.net.Uri; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Parcel; +import android.os.ServiceManager; +import android.os.RemoteException; import android.os.ParcelFileDescriptor; import android.os.PowerManager; import android.util.Log; @@ -32,13 +35,15 @@ import android.graphics.Bitmap; import android.graphics.SurfaceTexture; import android.media.AudioManager; +import android.content.pm.IPackageManager; import java.io.FileDescriptor; import java.io.IOException; import java.util.Map; import java.util.Set; import java.lang.ref.WeakReference; - +import android.view.WindowManager; +import android.view.IWindowManager; /** * MediaPlayer class can be used to control playback * of audio/video files and streams. An example on how to use the methods in @@ -521,6 +526,16 @@ public class MediaPlayer */ public static final boolean BYPASS_METADATA_FILTER = false; + /* add by Gary. start {{----------------------------------- */ + /** + * screen name + */ + private IWindowManager mWindowManager; + private IPackageManager mPackageManager; + public static final int MASTER_SCREEN = 0; + public static final int SLAVE_SCREEN = 1; + /* add by Gary. end -----------------------------------}} */ + static { System.loadLibrary("media_jni"); native_init(); @@ -563,6 +578,9 @@ public MediaPlayer() { * It's easier to create it here than in C++. */ native_setup(new WeakReference(this)); + + mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window")); + mPackageManager = IPackageManager.Stub.asInterface(ServiceManager.getService("package")); } /* @@ -631,6 +649,16 @@ public void setDisplay(SurfaceHolder sh) { surface = null; } _setVideoSurface(surface); + if(mWindowManager != null) + { + try + { + mWindowManager.updateRotation(true); + } + catch (RemoteException e) + { + } + } updateSurfaceScreenOn(); } @@ -1931,4 +1959,542 @@ public void setOnInfoListener(OnInfoListener listener) private OnInfoListener mOnInfoListener; + /* add by Gary. start {{----------------------------------- */ + public static native void setScreen(int screen) throws IllegalStateException; + public static native int getScreen(); + public static native boolean isPlayingVideo(); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-13 9:50:50 */ + /* expend interfaces about subtitle, track and so on */ + public static final int SUBTITLE_TYPE_TEXT = 0; + public static final int SUBTITLE_TYPE_BITMAP = 1; + + public static class SubInfo{ + public byte[] name; + public String charset; + public int type; // text or bitmap + + public SubInfo(byte[] oName, String oCharset, int oType){ + name = oName; + charset = oCharset; + type = oType; + } + }; + + /** + * Get the subtitle list of the current playing video. + *

+ * + * @return subtitle list. null means there is no subtitle. + */ + public native SubInfo[] getSubList(); + + /** + * get the index of the current showing subtitle in the subtitle list. + *

+ * + * @return the index of the current showing subtitle in the subtitle list. <0 means no subtitle. + */ + public native int getCurSub(); + + /** + * switch another subtitle to show. + *

+ * + * @param index the subtitle��s index in the subtitle list�� + * @return ==0 means successful, !=0 means failed. + */ + public native int switchSub(int index); + + /** + * show or hide a subitle. + *

+ * + * @param showSub whether to show subtitle or not + * @return ==0 means successful, !=0 means failed. + */ + public native int setSubGate(boolean showSub); + + /** + * check whether subtitles is allowed showing. + *

+ * + * @return true if subtitles is allowed showing, false otherwise. + */ + public native boolean getSubGate(); + + /** + * Set the subtitle��s color. + *

+ * + * @param color subtitle��s color. + * @return ==0 means successful, !=0 means failed. + */ + public native int setSubColor(int color); + + /** + * Get the subtitle��s color. + *

+ * + * @return the subtitle��s color. + */ + public native int getSubColor(); + + /** + * Set the subtitle frame��s color. + *

+ * + * @param color subtitle frame��s color. + * @return ==0 means successful, !=0 means failed. + */ + public native int setSubFrameColor(int color); + + /** + * Get the subtitle frame��s color. + *

+ * + * @return the subtitle frame��s color. + */ + public native int getSubFrameColor(); + + /** + * Set the subtitle��s font size. + *

+ * + * @param size font size in pixel. + * @return ==0 means successful, !=0 means failed. + */ + public native int setSubFontSize(int size); + + /** + * Get the subtitle��s font size. + *

+ * + * @return the subtitle��s font size. <0 means failed. + */ + public native int getSubFontSize(); + + /** + * Set the subtitle��s charset. If the underlying mediaplayer can absolutely parse the charset + * of the subtitles, still use the parsed charset; otherwise, use the charset argument. + *

+ * + * @param charset the canonical name of a charset. + * @return ==0 means successful, !=0 means failed. + */ + public native int setSubCharset(String charset); + + /** + * Get the subtitle��s charset. + *

+ * + * @return the canonical name of a charset. + */ + public native String getSubCharset(); + + /** + * Set the subtitle��s position vertically in the screen. + *

+ * + * @param percent ��Ļ���ؾ�����Ļ���صľ���ռ������Ļ�߶ȵİٷֱȡ�����һ������ֵ��Ʃ��˵��10%������Ӧ����10. + * @return ==0 means successful, !=0 means failed. + */ + public native int setSubPosition(int percent); + + /** + * Get the subtitle��s position vertically in the screen. + *

+ * + * @return percent ��Ļ���ؾ�����Ļ���صľ���ռ������Ļ�߶ȵİٷֱȡ�����һ������ֵ��Ʃ��˵��10%����������10. + */ + public native int getSubPosition(); + + /** + * Set the subtitle��s delay time. + *

+ * + * @param time delay time in milliseconds. It can be <0. + * @return ==0 means successful, !=0 means failed. + */ + public native int setSubDelay(int time); + + /** + * Get the subtitle��s delay time. + *

+ * + * @return delay time in milliseconds. + */ + public native int getSubDelay(); + + public static class TrackInfo{ + public byte[] name; + public String charset; + + public TrackInfo(byte[] oName, String oCharset){ + name = oName; + charset = oCharset; + } + }; + /** + * Get the track list of the current playing video. + *

+ * + * @return track list. null means there is no track. + */ + public native TrackInfo[] getTrackList(); + + /** + * get the index of the current track in the track list. + *

+ * + * @return the index of the current track in the track list. <0 means no track. + */ + public native int getCurTrack(); + + /** + * switch another track to play. + *

+ * + * @param index the track��s index in the track list�� + * @return ==0 means successful, !=0 means failed. + */ + public native int switchTrack(int index); + + /** + * charset list + */ + public static final String CHARSET_UNKNOWN = "UNKNOWN"; //�޷�ʶ��������ַ��� + public static final String CHARSET_BIG5 = "Big5"; //�������� + public static final String CHARSET_BIG5_HKSCS = "Big5-HKSCS"; // + public static final String CHARSET_BOCU_1 = "BOCU-1"; // + public static final String CHARSET_CESU_8 = "CESU-8"; // + public static final String CHARSET_CP864 = "cp864"; // + public static final String CHARSET_EUC_JP = "EUC-JP"; // + public static final String CHARSET_EUC_KR = "EUC-KR"; // + public static final String CHARSET_GB18030 = "GB18030"; // + public static final String CHARSET_GBK = "GBK"; //�������� + public static final String CHARSET_HZ_GB_2312 = "HZ-GB-2312"; // + public static final String CHARSET_ISO_2022_CN = "ISO-2022-CN"; // + public static final String CHARSET_ISO_2022_CN_EXT = "ISO-2022-CN-EXT"; // + public static final String CHARSET_ISO_2022_JP = "ISO-2022-JP"; // + public static final String CHARSET_ISO_2022_KR = "ISO-2022-KR"; //���� + public static final String CHARSET_ISO_8859_1 = "ISO-8859-1"; //��ŷ��ϵ + public static final String CHARSET_ISO_8859_10 = "ISO-8859-10"; //��ŷ˹������ά����ϵ + public static final String CHARSET_ISO_8859_13 = "ISO-8859-13"; //���޵ĺ���ϵ + public static final String CHARSET_ISO_8859_14 = "ISO-8859-14"; //����������ϵ + public static final String CHARSET_ISO_8859_15 = "ISO-8859-15"; //�չ�˷����ͷ��������ŷ��ϵ + public static final String CHARSET_ISO_8859_16 = "ISO-8859-16"; //�չ�Ķ���ŷ��ϵ + public static final String CHARSET_ISO_8859_2 = "ISO-8859-2"; //��ŷ���� + public static final String CHARSET_ISO_8859_3 = "ISO-8859-3"; //��ŷ���� + public static final String CHARSET_ISO_8859_4 = "ISO-8859-4"; //��ŷ���� + public static final String CHARSET_ISO_8859_5 = "ISO-8859-5"; //��������ĸ + public static final String CHARSET_ISO_8859_6 = "ISO-8859-6"; //������� + public static final String CHARSET_ISO_8859_7 = "ISO-8859-7"; //ϣ��� + public static final String CHARSET_ISO_8859_8 = "ISO-8859-8"; //ϣ����� + public static final String CHARSET_ISO_8859_9 = "ISO-8859-9"; //������� + public static final String CHARSET_KOI8_R = "KOI8-R"; //���� + public static final String CHARSET_KOI8_U = "KOI8-U"; // + public static final String CHARSET_MACINTOSH = "macintosh"; // + public static final String CHARSET_SCSU = "SCSU"; // + public static final String CHARSET_SHIFT_JIS = "Shift_JIS"; //���� + public static final String CHARSET_TIS_620 = "TIS-620"; //̩�� + public static final String CHARSET_US_ASCII = "US-ASCII"; // + public static final String CHARSET_UTF_16 = "UTF-16"; // + public static final String CHARSET_UTF_16BE = "UTF-16BE"; //UTF16 big endian + public static final String CHARSET_UTF_16LE = "UTF-16LE"; //UTF16 little endian + public static final String CHARSET_UTF_32 = "UTF-32"; // + public static final String CHARSET_UTF_32BE = "UTF-32BE"; // + public static final String CHARSET_UTF_32LE = "UTF-32LE"; // + public static final String CHARSET_UTF_7 = "UTF-7"; // + public static final String CHARSET_UTF_8 = "UTF-8"; //UTF8 + public static final String CHARSET_WINDOWS_1250 = "windows-1250"; //��ŷ + public static final String CHARSET_WINDOWS_1251 = "windows-1251"; //�������� + public static final String CHARSET_WINDOWS_1252 = "windows-1252"; //������� + public static final String CHARSET_WINDOWS_1253 = "windows-1253"; //ϣ��� + public static final String CHARSET_WINDOWS_1254 = "windows-1254"; //��ŷ��ϵ + public static final String CHARSET_WINDOWS_1255 = "windows-1255"; //ϣ����� + public static final String CHARSET_WINDOWS_1256 = "windows-1256"; //������� + public static final String CHARSET_WINDOWS_1257 = "windows-1257"; //���޵ĺ��� + public static final String CHARSET_WINDOWS_1258 = "windows-1258"; //Խ�� + public static final String CHARSET_X_DOCOMO_SHIFT_JIS_2007 = "x-docomo-shift_jis-2007"; // + public static final String CHARSET_X_GSM_03_38_2000 = "x-gsm-03.38-2000"; // + public static final String CHARSET_X_IBM_1383_P110_1999 = "x-ibm-1383_P110-1999"; // + public static final String CHARSET_X_IMAP_MAILBOX_NAME = "x-IMAP-mailbox-name"; // + public static final String CHARSET_X_ISCII_BE = "x-iscii-be"; // + public static final String CHARSET_X_ISCII_DE = "x-iscii-de"; // + public static final String CHARSET_X_ISCII_GU = "x-iscii-gu"; // + public static final String CHARSET_X_ISCII_KA = "x-iscii-ka"; // + public static final String CHARSET_X_ISCII_MA = "x-iscii-ma"; // + public static final String CHARSET_X_ISCII_OR = "x-iscii-or"; // + public static final String CHARSET_X_ISCII_PA = "x-iscii-pa"; // + public static final String CHARSET_X_ISCII_TA = "x-iscii-ta"; // + public static final String CHARSET_X_ISCII_TE = "x-iscii-te"; // + public static final String CHARSET_X_ISO_8859_11_2001 = "x-iso-8859_11-2001"; // + public static final String CHARSET_X_JAVAUNICODE = "x-JavaUnicode"; // + public static final String CHARSET_X_KDDI_SHIFT_JIS_2007 = "x-kddi-shift_jis-2007"; // + public static final String CHARSET_X_MAC_CYRILLIC = "x-mac-cyrillic"; // + public static final String CHARSET_X_SOFTBANK_SHIFT_JIS_2007 = "x-softbank-shift_jis-2007"; // + public static final String CHARSET_X_UNICODEBIG = "x-UnicodeBig"; // + public static final String CHARSET_X_UTF_16LE_BOM = "x-UTF-16LE-BOM"; // + public static final String CHARSET_X_UTF16_OPPOSITEENDIAN = "x-UTF16_OppositeEndian"; // + public static final String CHARSET_X_UTF16_PLATFORMENDIAN = "x-UTF16_PlatformEndian"; // + public static final String CHARSET_X_UTF32_OPPOSITEENDIAN = "x-UTF32_OppositeEndian"; // + public static final String CHARSET_X_UTF32_PLATFORMENDIAN = "x-UTF32_PlatformEndian"; // + + /* + * input 3D picture format list. + * defined by ChenXiaoChuan. + */ + public static final int PICTURE_3D_MODE_NONE = 0; //* 2D + public static final int PICTURE_3D_MODE_DOUBLE_STREAM = 1; //* ��ͼ��ʽ + public static final int PICTURE_3D_MODE_SIDE_BY_SIDE = 2; //* ���Ҹ�ʽ + public static final int PICTURE_3D_MODE_TOP_TO_BOTTOM = 3; //* ���¸�ʽ + public static final int PICTURE_3D_MODE_LINE_INTERLEAVE = 4; //* �н�֯��ʽ + public static final int PICTURE_3D_MODE_COLUME_INTERLEAVE = 5; //* �н�֯��ʽ + + /** + * set the dimension type of the source file. + *

+ * + * @param type the 3D picture format of the source file + * @return ==0 means successful, !=0 means failed. + */ + public native int setInputDimensionType(int type); + + /** + * get the dimension type of the source file. + *

+ * + * @return the 3D picture format of the source file. -1 means failed. + */ + public native int getInputDimensionType(); + + /* + * 3D picture display method, defined how to display pictures. + * defined by ChenXiaoChuan. + */ + public static final int DISPLAY_3D_MODE_2D = 0; //* ��ʾ2Dͼ�񣬶��ڷ�ͼ��ʽ��ֻ��ʾһ��ͼ���������»����Ҹ�ʽ����ʾ���ͼ + public static final int DISPLAY_3D_MODE_3D = 1; //* ��ʾ3Dͼ�� + public static final int DISPLAY_3D_MODE_HALF_PICTURE = 2; //* ��ʾ��ͼ���������һ����¸�ʽ��ͼ������ + public static final int DISPLAY_3D_MODE_ANAGLAGH = 3; //* ��ʾ��ɫͼ�񣬿��Խ����һ������¸�ʽ��ͼ��ת���ɷ�ɫͼ����ʾ + + /** + * set display method of the 3D pictures. + *

+ * + * @param type the display method of the 3D pictures + * @return ==0 means successful, !=0 means failed. + */ + public native int setOutputDimensionType(int type); + + /** + * get the dimension type of the output. + *

+ * + * @return the dimension type of the output. -1 means failed. + */ + public native int getOutputDimensionType(); + + /* + * anaglagh type list + */ + public static final int ANAGLAGH_RED_BLUE = 0; + public static final int ANAGLAGH_RED_GREEN = 1; + public static final int ANAGLAGH_RED_CYAN = 2; + public static final int ANAGLAGH_COLOR = 3; + public static final int ANAGLAGH_HALF_COLOR = 4; + public static final int ANAGLAGH_OPTIMIZED = 5; + public static final int ANAGLAGH_YELLOW_BLUE = 6; + + /** + * set the anaglagh type of the output. + *

+ * + * @param type the anaglagh type of the output + * @return ==0 means successful, !=0 means failed. + */ + public native int setAnaglaghType(int type); + + /** + * get the anaglagh type of the output. + *

+ * + * @return the anaglagh type of the output. -1 means failed. + */ + public native int getAnaglaghType(); + + /** + * get the video encode. + *

+ * + * @return the name of the video encode. null means unknown. + */ + public native String getVideoEncode(); + + /** + * get the video frame rate. + *

+ * + * @return the video frame rate. <0 means unknown. + */ + public native int getVideoFrameRate(); + + /** + * get the audio encode. + *

+ * + * @return the name of the audio encode. null means unknown. + */ + public native String getAudioEncode(); + + /** + * get the audio bit rate. + *

+ * + * @return the audio bit rate. <0 means unknown. + */ + public native int getAudioBitRate(); + + /** + * get the audio sample rate. + *

+ * + * @return the audio sample rate. <0 means unknown. + */ + public native int getAudioSampleRate(); + + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-10-9 8:54:30 */ + /* add callback for parsing 3d source */ + private OnParse3dFileListener mOnParse3dFileListener = null; + + public void setOnParse3dFileListener(OnParse3dFileListener listener){ + mOnParse3dFileListener = listener; + } + + public interface OnParse3dFileListener{ + public int onParse3dFile(int type); + } + + static private int parse3dFile(Object mediaplayer_ref, int type) + { + MediaPlayer mp = (MediaPlayer)((WeakReference)mediaplayer_ref).get(); + if (mp == null) { + return 0; + } + if(mp.mOnParse3dFileListener != null){ + return mp.mOnParse3dFileListener.onParse3dFile(type); + } + + return 0; + } + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + /** + * enable or disable scale mode for playing video. + *

+ * + * @param enable if true, enable the scale mode, else disable the scale mode. + * @param width the expected width of the video. Only valid when enable. + * @param height the expected height of the video. Only valid when enable. + */ + public native void enableScaleMode(boolean enable, int width, int height); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + /** + * enable or disable VPP for playing video. + *

+ * + * @param enableVpp if true, enable VPP, else disable VPP. + * @return ==0 means successful, !=0 means failed. + */ + public static native int setVppGate(boolean enableVpp); + + /** + * get the VPP's status. + *

+ * + * @return the VPP's status. + */ + public static native boolean getVppGate(); + + /** + * adjust the luma. + *

+ * + * @param value the value of luma. value ranges 0~~4. + * @return ==0 means successful, !=0 means failed. + */ + public static native int setLumaSharp(int value); + + /** + * get the value of the luma. + *

+ * + * @return the value of the luma. + */ + public static native int getLumaSharp(); + + /** + * adjust the chroma. + *

+ * + * @param value the value of chroma. value ranges 0~~4. + * @return ==0 means successful, !=0 means failed. + */ + public static native int setChromaSharp(int value); + + /** + * get the value of the chroma. + *

+ * + * @return the value of the chroma. + */ + public static native int getChromaSharp(); + + /** + * adjust the white extended. + *

+ * + * @param value the value of white extended. value ranges 0~~4. + * @return ==0 means successful, !=0 means failed. + */ + public static native int setWhiteExtend(int value); + + /** + * get the value of the white extended. + *

+ * + * @return the value of the white extended. + */ + public static native int getWhiteExtend(); + + /** + * adjust the black extended. + *

+ * + * @param value the value of black extended. value ranges 0~~4. + * @return ==0 means successful, !=0 means failed. + */ + public static native int setBlackExtend(int value); + + /** + * get the value of the black extended. + *

+ * + * @return the value of the black extended. + */ + public static native int getBlackExtend(); + + /* add by Gary. end -----------------------------------}} */ } diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index 63cbf5e076b2d..f8da9cef8f81c 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -54,6 +54,7 @@ struct fields_t { jfieldID surface_texture; jmethodID post_event; + jmethodID parse3dFile; }; static fields_t fields; @@ -67,6 +68,7 @@ class JNIMediaPlayerListener: public MediaPlayerListener JNIMediaPlayerListener(JNIEnv* env, jobject thiz, jobject weak_thiz); ~JNIMediaPlayerListener(); virtual void notify(int msg, int ext1, int ext2, const Parcel *obj = NULL); + int parse3dFile(int type); private: JNIMediaPlayerListener(); jclass mClass; // Reference to MediaPlayer class @@ -118,6 +120,16 @@ void JNIMediaPlayerListener::notify(int msg, int ext1, int ext2, const Parcel *o } } +/* add by Gary. start {{----------------------------------- */ +/* 2011-10-9 8:54:30 */ +/* add callback for parsing 3d source */ +int JNIMediaPlayerListener::parse3dFile(int type) +{ + JNIEnv *env = AndroidRuntime::getJNIEnv(); + return env->CallStaticIntMethod(mClass, fields.parse3dFile, mObject, type); +} +/* add by Gary. end -----------------------------------}} */ + // ---------------------------------------------------------------------------- static sp getMediaPlayer(JNIEnv* env, jobject thiz) @@ -592,6 +604,702 @@ android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update return media_player->getMetadata(update_only, apply_filter, metadata) == OK; } +/* add by Gary. start {{----------------------------------- */ +static void +android_media_MediaPlayer_setScreen(JNIEnv *env, jobject thiz, jint screen) +{ + LOGV("setScreen"); + MediaPlayer::setScreen(screen); +} + +static jint +android_media_MediaPlayer_getScreen(JNIEnv *env, jobject thiz) +{ + LOGV("getScreen"); + + jint screen; + if( OK != MediaPlayer::getScreen(&screen) ){ + LOGV("Fail in getting screen"); + screen = MASTER_SCREEN; + } + + return screen; +} + +static jboolean +android_media_MediaPlayer_isPlayingVideo(JNIEnv *env, jobject thiz) +{ + LOGV("isPlayingVideo"); + + bool playing; + if( OK != MediaPlayer::isPlayingVideo(&playing) ){ + LOGV("Fail in isPlayingVideo()"); + playing = false; + } + + return (jboolean)playing; +} +/* add by Gary. end -----------------------------------}} */ + +/* add by Gary. start {{----------------------------------- */ +/* 2011-9-13 10:25:47 */ +/* expend interfaces about subtitle, track and so on */ +static jobject _composeObjSubInfo(JNIEnv *env, jclass classSubInfo, jmethodID methodSubInfo, MediaPlayer_SubInfo *info) +{ + jstring charset = env->NewStringUTF((const char*)info->charset); + jbyteArray name = env->NewByteArray(info->len); + env->SetByteArrayRegion(name, 0, info->len, (jbyte*)info->name); + jobject objSubInfo = env->NewObject(classSubInfo, methodSubInfo, name, charset, info->type); + if(objSubInfo == NULL ) + LOGE("Fail in creating SubInfo object."); + + env->DeleteLocalRef(name); + env->DeleteLocalRef(charset); + return objSubInfo; +} + +static jobjectArray +android_media_MediaPlayer_getSubList(JNIEnv *env, jobject thiz) +{ + LOGE("enter android_media_MediaPlayer_getSubList"); + + jobjectArray jsubList = NULL; + MediaPlayer_SubInfo *csubList = NULL; + status_t ret; + jclass classSubInfo; + jmethodID methodSubInfo; + + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return NULL; + } + + classSubInfo = env->FindClass("android/media/MediaPlayer$SubInfo"); + if(classSubInfo == NULL ){ + LOGE("Fail in finding class android/media/MediaPlayer$SubInfo"); + return NULL; + } + + int count = mp->getSubCount(); + if(count <= 0) + return NULL; + + jsubList = env->NewObjectArray(count, classSubInfo, NULL ); + if(jsubList == NULL){ + LOGE("Fail in creating subInfo array."); + goto error; + } + csubList = new MediaPlayer_SubInfo[count]; + if(csubList == NULL ){ + LOGE("Fail in allocating memory."); + goto error; + } + count = mp->getSubList(csubList, count); + if(count <= 0){ + LOGE("Fail in getting sublist."); + goto error; + } + methodSubInfo = env->GetMethodID(classSubInfo, "", + "([BLjava/lang/String;I)V"); + if(methodSubInfo == NULL){ + LOGE("Fail in getting method \"SubInfo\"."); + goto error; + } + for(int i = 0; i < count; i++){ + jobject objSubInfo = _composeObjSubInfo(env, classSubInfo, methodSubInfo, csubList+i); + env->SetObjectArrayElement(jsubList, i, objSubInfo); + env->DeleteLocalRef(objSubInfo); + } + + delete[] csubList; + return jsubList; + +error: + if(jsubList != NULL) + env->DeleteLocalRef(jsubList); + if(csubList != NULL) + delete[] csubList; + return NULL; +} + +static jint +android_media_MediaPlayer_getCurSub(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->getCurSub(); +} + +static jint +android_media_MediaPlayer_switchSub(JNIEnv *env, jobject thiz, jint index) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->switchSub(index); +} + +static jint +android_media_MediaPlayer_setSubGate(JNIEnv *env, jobject thiz, jboolean showSub) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->setSubGate((bool)showSub); +} + +static jboolean +android_media_MediaPlayer_getSubGate(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return (jboolean)mp->getSubGate(); +} + +static jint +android_media_MediaPlayer_setSubColor(JNIEnv *env, jobject thiz, jint color) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->setSubColor(color); +} + +static jint +android_media_MediaPlayer_getSubColor(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->getSubColor(); +} + +static jint +android_media_MediaPlayer_setSubFrameColor(JNIEnv *env, jobject thiz, jint color) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->setSubFrameColor(color); +} + +static jint +android_media_MediaPlayer_getSubFrameColor(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return 0xFFFFFFFF; + } + + return mp->getSubFrameColor(); +} + +static jint +android_media_MediaPlayer_setSubFontSize(JNIEnv *env, jobject thiz, jint size) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->setSubFontSize(size); +} + +static jint +android_media_MediaPlayer_getSubFontSize(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->getSubFontSize(); +} + +static jint +android_media_MediaPlayer_setSubCharset(JNIEnv *env, jobject thiz, jstring charset) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + const char *ccharset = env->GetStringUTFChars(charset, NULL); + if(ccharset == NULL){ + LOGE("Fail in converting jstring to cstring."); + return -1; + } + + status_t ret = mp->setSubCharset(ccharset); + env->ReleaseStringUTFChars(charset, ccharset); + return ret; +} + +static jstring +android_media_MediaPlayer_getSubCharset(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return NULL; + } + char *ccharset = new char[MEDIAPLAYER_NAME_LEN_MAX]; + if(ccharset == NULL){ + LOGE("Fail in allocating memory."); + return NULL; + } + + status_t ret = mp->getSubCharset(ccharset); + if(ret == OK){ + jstring charset = env->NewStringUTF(ccharset); + if(charset == NULL){ + LOGE("Fail in creating java string with %s.", ccharset); + } + delete[] ccharset; + return charset; + }else { + delete[] ccharset; + return NULL; + } +} + +static jint +android_media_MediaPlayer_setSubPosition(JNIEnv *env, jobject thiz, jint pencent) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->setSubPosition(pencent); +} + +static jint +android_media_MediaPlayer_getSubPosition(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->getSubPosition(); +} + +static jint +android_media_MediaPlayer_setSubDelay(JNIEnv *env, jobject thiz, jint delay) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->setSubDelay(delay); +} + +static jint +android_media_MediaPlayer_getSubDelay(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->getSubDelay(); +} + +static jobject _composeObjTrackInfo(JNIEnv *env, jclass classTrackInfo, jmethodID methodTrackInfo, MediaPlayer_TrackInfo *info) +{ + jstring charset = env->NewStringUTF((const char*)info->charset); + jbyteArray name = env->NewByteArray(info->len); + env->SetByteArrayRegion(name, 0, info->len, (jbyte*)info->name); + jobject objTrackInfo = env->NewObject(classTrackInfo, methodTrackInfo, name, charset); + if(objTrackInfo == NULL ) + LOGE("Fail in creating TrackInfo object."); + + env->DeleteLocalRef(name); + env->DeleteLocalRef(charset); + return objTrackInfo; +} + +static jobjectArray +android_media_MediaPlayer_getTrackList(JNIEnv *env, jobject thiz) +{ + LOGE("enter android_media_MediaPlayer_getTrackList"); + + jobjectArray jtrackList = NULL; + MediaPlayer_TrackInfo *ctrackList = NULL; + status_t ret; + jclass classTrackInfo; + jmethodID methodTrackInfo; + + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return NULL; + } + + classTrackInfo = env->FindClass("android/media/MediaPlayer$TrackInfo"); + if(classTrackInfo == NULL ){ + LOGE("Fail in finding class android/media/MediaPlayer$TrackInfo"); + return NULL; + } + + int count = mp->getTrackCount(); + if(count <= 0) + return NULL; + + jtrackList = env->NewObjectArray(count, classTrackInfo, NULL ); + if(jtrackList == NULL){ + LOGE("Fail in creating trackInfo array."); + goto error; + } + ctrackList = new MediaPlayer_TrackInfo[count]; + if(ctrackList == NULL ){ + LOGE("Fail in allocating memory."); + goto error; + } + count = mp->getTrackList(ctrackList, count); + if(count < 0){ + LOGE("Fail in getting tracklist."); + goto error; + } + methodTrackInfo = env->GetMethodID(classTrackInfo, "", + "([BLjava/lang/String;)V"); + if(methodTrackInfo == NULL){ + LOGE("Fail in getting method \"TrackInfo\"."); + goto error; + } + for(int i = 0; i < count; i++){ + jobject objTrackInfo = _composeObjTrackInfo(env, classTrackInfo, methodTrackInfo, ctrackList+i); + env->SetObjectArrayElement(jtrackList, i, objTrackInfo); + env->DeleteLocalRef(objTrackInfo); + } + + delete[] ctrackList; + return jtrackList; + +error: + if(jtrackList != NULL) + env->DeleteLocalRef(jtrackList); + if(ctrackList != NULL) + delete[] ctrackList; + return NULL; +} + + +static jint +android_media_MediaPlayer_getCurTrack(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->getCurTrack(); +} + +static jint +android_media_MediaPlayer_switchTrack(JNIEnv *env, jobject thiz, jint index) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->switchTrack(index); +} + +static jint +android_media_MediaPlayer_setInputDimensionType(JNIEnv *env, jobject thiz, jint type) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->setInputDimensionType(type); +} + +static jint +android_media_MediaPlayer_getInputDimensionType(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->getInputDimensionType(); +} + +static jint +android_media_MediaPlayer_setOutputDimensionType(JNIEnv *env, jobject thiz, jint type) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->setOutputDimensionType(type); +} + +static jint +android_media_MediaPlayer_getOutputDimensionType(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->getOutputDimensionType(); +} + +static jint +android_media_MediaPlayer_setAnaglaghType(JNIEnv *env, jobject thiz, jint type) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->setAnaglaghType(type); +} + +static jint +android_media_MediaPlayer_getAnaglaghType(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->getAnaglaghType(); +} + +static jstring +android_media_MediaPlayer_getVideoEncode(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return NULL; + } + + char *encode = new char[MEDIAPLAYER_NAME_LEN_MAX]; + if(encode == NULL){ + LOGE("Fail in allocating memory."); + return NULL; + } + status_t ret = mp->getVideoEncode(encode); + if(ret != OK){ + delete[] encode; + return NULL; + } + jstring jencode = env->NewStringUTF(encode); + if(jencode == NULL){ + delete[] encode; + return NULL; + } + return jencode; +} + +static jint +android_media_MediaPlayer_getVideoFrameRate(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->getVideoFrameRate(); +} + +static jstring +android_media_MediaPlayer_getAudioEncode(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return NULL; + } + + char *encode = new char[MEDIAPLAYER_NAME_LEN_MAX]; + if(encode == NULL){ + LOGE("Fail in allocating memory."); + return NULL; + } + status_t ret = mp->getAudioEncode(encode); + if(ret != OK){ + delete[] encode; + return NULL; + } + jstring jencode = env->NewStringUTF(encode); + if(jencode == NULL){ + delete[] encode; + return NULL; + } + return jencode; +} + +static jint +android_media_MediaPlayer_getAudioBitRate(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->getAudioBitRate(); +} + +static jint +android_media_MediaPlayer_getAudioSampleRate(JNIEnv *env, jobject thiz) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return -1; + } + + return mp->getAudioSampleRate(); +} + +/* add by Gary. end -----------------------------------}} */ + +/* add by Gary. start {{----------------------------------- */ +/* 2011-11-14 */ +/* support scale mode */ +static void +android_media_MediaPlayer_enableScaleMode(JNIEnv *env, jobject thiz, jboolean enable, jint width, jint height) +{ + sp mp = getMediaPlayer(env, thiz); + if (mp == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return; + } + + mp->enableScaleMode((bool)enable, width, height); +} +/* add by Gary. end -----------------------------------}} */ + +/* add by Gary. start {{----------------------------------- */ +/* 2011-11-14 */ +/* support adjusting colors while playing video */ +static void +android_media_MediaPlayer_setVppGate(JNIEnv *env, jobject thiz, jboolean enableVpp) +{ + MediaPlayer::setVppGate((bool)enableVpp); +} + +static jboolean +android_media_MediaPlayer_getVppGate(JNIEnv *env, jobject thiz) +{ + return (jboolean)MediaPlayer::getVppGate(); +} + +static jint +android_media_MediaPlayer_setLumaSharp(JNIEnv *env, jobject thiz, jint value) +{ + if(OK == MediaPlayer::setLumaSharp(value)) + return 0; + else + return -1; +} + +static jint +android_media_MediaPlayer_getLumaSharp(JNIEnv *env, jobject thiz) +{ + return MediaPlayer::getLumaSharp(); +} + +static jint +android_media_MediaPlayer_setChromaSharp(JNIEnv *env, jobject thiz, jint value) +{ + if(OK == MediaPlayer::setChromaSharp(value)) + return 0; + else + return -1; +} + +static jint +android_media_MediaPlayer_getChromaSharp(JNIEnv *env, jobject thiz) +{ + return MediaPlayer::getChromaSharp(); +} + +static jint +android_media_MediaPlayer_setWhiteExtend(JNIEnv *env, jobject thiz, jint value) +{ + if(OK == MediaPlayer::setWhiteExtend(value)) + return 0; + else + return -1; +} + +static jint +android_media_MediaPlayer_getWhiteExtend(JNIEnv *env, jobject thiz) +{ + return MediaPlayer::getWhiteExtend(); +} + +static jint +android_media_MediaPlayer_setBlackExtend(JNIEnv *env, jobject thiz, jint value) +{ + if(OK == MediaPlayer::setBlackExtend(value)) + return 0; + else + return -1; +} + +static jint +android_media_MediaPlayer_getBlackExtend(JNIEnv *env, jobject thiz) +{ + return MediaPlayer::getBlackExtend(); +} + +/* add by Gary. end -----------------------------------}} */ + // This function gets some field IDs, which in turn causes class initialization. // It is called from a static block in MediaPlayer, which won't run until the // first time an instance of this class is used. @@ -616,6 +1324,13 @@ android_media_MediaPlayer_native_init(JNIEnv *env) return; } + fields.parse3dFile = env->GetStaticMethodID(clazz, "parse3dFile", + "(Ljava/lang/Object;I)I"); + if (fields.parse3dFile == NULL) { + jniThrowException(env, "java/lang/RuntimeException", "Can't find MediaPlayer.parse3dFile"); + return; + } + fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "I"); if (fields.surface_texture == NULL) { return; @@ -799,6 +1514,65 @@ static JNINativeMethod gMethods[] = { {"native_pullBatteryData", "(Landroid/os/Parcel;)I", (void *)android_media_MediaPlayer_pullBatteryData}, {"setParameter", "(ILandroid/os/Parcel;)Z", (void *)android_media_MediaPlayer_setParameter}, {"getParameter", "(ILandroid/os/Parcel;)V", (void *)android_media_MediaPlayer_getParameter}, + /* add by Gary. start {{----------------------------------- */ + {"getScreen", "()I", (void *)android_media_MediaPlayer_getScreen}, + {"setScreen", "(I)V", (void *)android_media_MediaPlayer_setScreen}, + {"isPlayingVideo", "()Z", (void *)android_media_MediaPlayer_isPlayingVideo}, + /* add by Gary. end -----------------------------------}} */ + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-13 10:25:47 */ + /* expend interfaces about subtitle, track and so on */ + {"getSubList", "()[Landroid/media/MediaPlayer$SubInfo;", (void *)android_media_MediaPlayer_getSubList}, + {"getCurSub", "()I", (void *)android_media_MediaPlayer_getCurSub}, + {"switchSub", "(I)I", (void *)android_media_MediaPlayer_switchSub}, + {"setSubGate", "(Z)I", (void *)android_media_MediaPlayer_setSubGate}, + {"getSubGate", "()Z", (void *)android_media_MediaPlayer_getSubGate}, + {"setSubColor", "(I)I", (void *)android_media_MediaPlayer_setSubColor}, + {"getSubColor", "()I", (void *)android_media_MediaPlayer_getSubColor}, + {"setSubFrameColor", "(I)I", (void *)android_media_MediaPlayer_setSubFrameColor}, + {"getSubFrameColor", "()I", (void *)android_media_MediaPlayer_getSubFrameColor}, + {"setSubFontSize", "(I)I", (void *)android_media_MediaPlayer_setSubFontSize}, + {"getSubFontSize", "()I", (void *)android_media_MediaPlayer_getSubFontSize}, + {"setSubCharset", "(Ljava/lang/String;)I", (void *)android_media_MediaPlayer_setSubCharset}, + {"getSubCharset", "()Ljava/lang/String;", (void *)android_media_MediaPlayer_getSubCharset}, + {"setSubPosition", "(I)I", (void *)android_media_MediaPlayer_setSubPosition}, + {"getSubPosition", "()I", (void *)android_media_MediaPlayer_getSubPosition}, + {"setSubDelay", "(I)I", (void *)android_media_MediaPlayer_setSubDelay}, + {"getSubDelay", "()I", (void *)android_media_MediaPlayer_getSubDelay}, + {"getTrackList", "()[Landroid/media/MediaPlayer$TrackInfo;", (void *)android_media_MediaPlayer_getTrackList}, + {"getCurTrack", "()I", (void *)android_media_MediaPlayer_getCurTrack}, + {"switchTrack", "(I)I", (void *)android_media_MediaPlayer_switchTrack}, + {"setInputDimensionType", "(I)I", (void *)android_media_MediaPlayer_setInputDimensionType}, + {"getInputDimensionType", "()I", (void *)android_media_MediaPlayer_getInputDimensionType}, + {"setOutputDimensionType", "(I)I", (void *)android_media_MediaPlayer_setOutputDimensionType}, + {"getOutputDimensionType", "()I", (void *)android_media_MediaPlayer_getOutputDimensionType}, + {"setAnaglaghType", "(I)I", (void *)android_media_MediaPlayer_setAnaglaghType}, + {"getAnaglaghType", "()I", (void *)android_media_MediaPlayer_getAnaglaghType}, + {"getVideoEncode", "()Ljava/lang/String;", (void *)android_media_MediaPlayer_getVideoEncode}, + {"getVideoFrameRate", "()I", (void *)android_media_MediaPlayer_getVideoFrameRate}, + {"getAudioEncode", "()Ljava/lang/String;", (void *)android_media_MediaPlayer_getAudioEncode}, + {"getAudioBitRate", "()I", (void *)android_media_MediaPlayer_getAudioBitRate}, + {"getAudioSampleRate", "()I", (void *)android_media_MediaPlayer_getAudioSampleRate}, + /* add by Gary. end -----------------------------------}} */ + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + {"enableScaleMode", "(ZII)V", (void *)android_media_MediaPlayer_enableScaleMode}, + /* add by Gary. end -----------------------------------}} */ + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + {"setVppGate", "(Z)I", (void *)android_media_MediaPlayer_setVppGate}, + {"getVppGate", "()Z", (void *)android_media_MediaPlayer_getVppGate}, + {"setLumaSharp", "(I)I", (void *)android_media_MediaPlayer_setLumaSharp}, + {"getLumaSharp", "()I", (void *)android_media_MediaPlayer_getLumaSharp}, + {"setChromaSharp", "(I)I", (void *)android_media_MediaPlayer_setChromaSharp}, + {"getChromaSharp", "()I", (void *)android_media_MediaPlayer_getChromaSharp}, + {"setWhiteExtend", "(I)I", (void *)android_media_MediaPlayer_setWhiteExtend}, + {"getWhiteExtend", "()I", (void *)android_media_MediaPlayer_getWhiteExtend}, + {"setBlackExtend", "(I)I", (void *)android_media_MediaPlayer_setBlackExtend}, + {"getBlackExtend", "()I", (void *)android_media_MediaPlayer_getBlackExtend}, + /* add by Gary. end -----------------------------------}} */ }; static const char* const kClassPathName = "android/media/MediaPlayer"; diff --git a/media/libmedia/IMediaPlayer.cpp b/media/libmedia/IMediaPlayer.cpp index 9c1e6b727b38f..f007c96fbd867 100644 --- a/media/libmedia/IMediaPlayer.cpp +++ b/media/libmedia/IMediaPlayer.cpp @@ -55,6 +55,49 @@ enum { SET_VIDEO_SURFACETEXTURE, SET_PARAMETER, GET_PARAMETER, + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-15 10:51:10 */ + /* expend interfaces about subtitle, track and so on */ + GET_SUB_COUNT, + GET_SUB_LIST, + GET_CUR_SUB, + SWITCH_SUB, + SET_SUB_GATE, + GET_SUB_GATE, + SET_SUB_COLOR, + GET_SUB_COLOR, + SET_SUB_FRAME_COLOR, + GET_SUB_FRAME_COLOR, + SET_SUB_FONT_SIZE, + GET_SUB_FONT_SIZE, + SET_SUB_CHARSET, + GET_SUB_CHARSET, + SET_SUB_POSITION, + GET_SUB_POSITION, + SET_SUB_DELAY, + GET_SUB_DELAY, + GET_TRACK_COUNT, + GET_TRACK_LIST, + GET_CUR_TRACK, + SWITCH_TRACK, + SET_INPUT_DIMENSION_TYPE, + GET_INPUT_DIMENSION_TYPE, + SET_OUTPUT_DIMENSION_TYPE, + GET_OUTPUT_DIMENSION_TYPE, + SET_ANAGLAGH_TYPE, + GET_ANAGLAGH_TYPE, + GET_VIDEO_ENCODE, + GET_VIDEO_FRAME_RATE, + GET_AUDIO_ENCODE, + GET_AUDIO_BIT_RATE, + GET_AUDIO_SAMPLE_RATE, + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + ENABLE_SCALE_MODE, + /* add by Gary. end -----------------------------------}} */ }; class BpMediaPlayer: public BpInterface @@ -290,6 +333,346 @@ class BpMediaPlayer: public BpInterface data.writeInt32(key); return remote()->transact(GET_PARAMETER, data, reply); } + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-14 14:27:12 */ + /* expend interfaces about subtitle, track and so on */ + int getSubCount() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_SUB_COUNT, data, &reply); + return reply.readInt32(); + } + + int getSubList(MediaPlayer_SubInfo *infoList, int count) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(count); + remote()->transact(GET_SUB_LIST, data, &reply); + int nr = reply.readInt32(); + if(nr > 0){ + MediaPlayer_SubInfo *info; + for(int i = 0; i < nr; i++){ + info = infoList + i; + info->len = reply.readInt32(); + if(info->len >= 0) + reply.read(info->name, info->len); + strcpy(info->charset, reply.readCString()); + info->type = reply.readInt32(); + } + } + return nr; + } + + int getCurSub() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_CUR_SUB, data, &reply); + return reply.readInt32(); + } + + status_t switchSub(int index) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(index); + remote()->transact(SWITCH_SUB, data, &reply); + return reply.readInt32(); + } + + status_t setSubGate(bool showSub) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + int v = 0; + if(showSub) + v = 1; + data.writeInt32(v); + remote()->transact(SET_SUB_GATE, data, &reply); + return reply.readInt32(); + } + + bool getSubGate() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_SUB_GATE, data, &reply); + int ret = reply.readInt32(); + if(ret) + return true; + else + return false; + } + + status_t setSubColor(int color) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(color); + remote()->transact(SET_SUB_COLOR, data, &reply); + return reply.readInt32(); + } + + int getSubColor() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_SUB_COLOR, data, &reply); + return reply.readInt32(); + } + + status_t setSubFrameColor(int color) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(color); + remote()->transact(SET_SUB_FRAME_COLOR, data, &reply); + return reply.readInt32(); + } + + int getSubFrameColor() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_SUB_FRAME_COLOR, data, &reply); + return reply.readInt32(); + } + + status_t setSubFontSize(int size) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(size); + remote()->transact(SET_SUB_FONT_SIZE, data, &reply); + return reply.readInt32(); + } + + int getSubFontSize() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_SUB_FONT_SIZE, data, &reply); + return reply.readInt32(); + } + + status_t setSubCharset(const char *charset) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeCString(charset); + remote()->transact(SET_SUB_CHARSET, data, &reply); + return reply.readInt32(); + } + + status_t getSubCharset(char *charset) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_SUB_CHARSET, data, &reply); + status_t ret = reply.readInt32(); + if(ret == OK) + strcpy(charset, reply.readCString()); + return ret; + } + + status_t setSubPosition(int percent) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(percent); + remote()->transact(SET_SUB_POSITION, data, &reply); + return reply.readInt32(); + } + + int getSubPosition() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_SUB_POSITION, data, &reply); + return reply.readInt32(); + } + + status_t setSubDelay(int time) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(time); + remote()->transact(SET_SUB_DELAY, data, &reply); + return reply.readInt32(); + } + + int getSubDelay() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_SUB_DELAY, data, &reply); + return reply.readInt32(); + } + + int getTrackCount() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_TRACK_COUNT, data, &reply); + return reply.readInt32(); + } + + int getTrackList(MediaPlayer_TrackInfo *infoList, int count) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(count); + remote()->transact(GET_TRACK_LIST, data, &reply); + int nr = reply.readInt32(); + if(nr > 0){ + MediaPlayer_TrackInfo *info; + for(int i = 0; i < nr; i++){ + info = infoList + i; + info->len = reply.readInt32(); + if(info->len >= 0) + reply.read(info->name, info->len); + strcpy(info->charset, reply.readCString()); + } + } + return nr; + } + + int getCurTrack() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_CUR_TRACK, data, &reply); + return reply.readInt32(); + } + + status_t switchTrack(int index) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(index); + remote()->transact(SWITCH_TRACK, data, &reply); + return reply.readInt32(); + } + + status_t setInputDimensionType(int type) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(type); + remote()->transact(SET_INPUT_DIMENSION_TYPE, data, &reply); + return reply.readInt32(); + } + + int getInputDimensionType() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_INPUT_DIMENSION_TYPE, data, &reply); + return reply.readInt32(); + } + + status_t setOutputDimensionType(int type) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(type); + remote()->transact(SET_OUTPUT_DIMENSION_TYPE, data, &reply); + return reply.readInt32(); + } + + int getOutputDimensionType() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_OUTPUT_DIMENSION_TYPE, data, &reply); + return reply.readInt32(); + } + + status_t setAnaglaghType(int type) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(type); + remote()->transact(SET_ANAGLAGH_TYPE, data, &reply); + return reply.readInt32(); + } + + int getAnaglaghType() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_ANAGLAGH_TYPE, data, &reply); + return reply.readInt32(); + } + + status_t getVideoEncode(char *encode) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_VIDEO_ENCODE, data, &reply); + status_t ret = reply.readInt32(); + if(ret == OK){ + const char *temp = reply.readCString(); + strcpy(encode, temp); + } + return ret; + } + + int getVideoFrameRate() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_VIDEO_FRAME_RATE, data, &reply); + return reply.readInt32(); + } + + status_t getAudioEncode(char *encode) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_AUDIO_ENCODE, data, &reply); + status_t ret = reply.readInt32(); + if(ret == OK){ + const char *temp = reply.readCString(); + strcpy(encode, temp); + } + return ret; + } + + int getAudioBitRate() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_AUDIO_BIT_RATE, data, &reply); + return reply.readInt32(); + } + + int getAudioSampleRate() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + remote()->transact(GET_AUDIO_SAMPLE_RATE, data, &reply); + return reply.readInt32(); + } + + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + status_t enableScaleMode(bool enable, int width, int height) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + data.writeInt32(enable); + data.writeInt32(width); + data.writeInt32(height); + remote()->transact(ENABLE_SCALE_MODE, data, &reply); + return reply.readInt32(); + } + /* add by Gary. end -----------------------------------}} */ }; @@ -459,6 +842,261 @@ status_t BnMediaPlayer::onTransact( CHECK_INTERFACE(IMediaPlayer, data, reply); return getParameter(data.readInt32(), reply); } break; + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-15 13:06:54 */ + /* expend interfaces about subtitle, track and so on */ + case GET_SUB_COUNT: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getSubCount()); + return NO_ERROR; + } break; + case GET_SUB_LIST: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + int count = data.readInt32(); + MediaPlayer_SubInfo *subList = new MediaPlayer_SubInfo[count]; + if(subList == NULL){ + reply->writeInt32(-1); + return NO_ERROR; + } + count = getSubList(subList, count); + if(count > 0){ + reply->writeInt32(count); + MediaPlayer_SubInfo *info; + for(int i = 0; i < count; i++){ + info = subList + i; + reply->writeInt32(info->len); + if(info->len > 0) + reply->write(info->name, info->len); + reply->writeCString(info->charset); + reply->writeInt32(info->type); + } + } + delete[] subList; + return NO_ERROR; + } break; + case GET_CUR_SUB: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getCurSub()); + return NO_ERROR; + } break; + case SWITCH_SUB: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(switchSub(data.readInt32())); + return NO_ERROR; + } break; + case SET_SUB_GATE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + int v = data.readInt32(); + bool b = false; + if(v) + b = true; + reply->writeInt32(setSubGate(b)); + return NO_ERROR; + } break; + case GET_SUB_GATE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + bool b = getSubGate(); + int v = 0; + if(b) + v = 1; + reply->writeInt32(v); + return NO_ERROR; + } break; + case SET_SUB_COLOR: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(setSubColor(data.readInt32())); + return NO_ERROR; + } break; + case GET_SUB_COLOR: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getSubColor()); + return NO_ERROR; + } break; + case SET_SUB_FRAME_COLOR: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(setSubFrameColor(data.readInt32())); + return NO_ERROR; + } break; + case GET_SUB_FRAME_COLOR: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getSubFrameColor()); + return NO_ERROR; + } break; + case SET_SUB_FONT_SIZE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(setSubFontSize(data.readInt32())); + return NO_ERROR; + } break; + case GET_SUB_FONT_SIZE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getSubFontSize()); + return NO_ERROR; + } break; + case SET_SUB_CHARSET: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(setSubCharset(data.readCString())); + return NO_ERROR; + } break; + case GET_SUB_CHARSET: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + char *charset = new char[MEDIAPLAYER_NAME_LEN_MAX]; + status_t ret = getSubCharset(charset); + reply->writeInt32(ret); + if(ret == OK) + reply->writeCString(charset); + delete[] charset; + return NO_ERROR; + } break; + case SET_SUB_POSITION: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(setSubPosition(data.readInt32())); + return NO_ERROR; + } break; + case GET_SUB_POSITION: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getSubPosition()); + return NO_ERROR; + } break; + case SET_SUB_DELAY: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(setSubDelay(data.readInt32())); + return NO_ERROR; + } break; + case GET_SUB_DELAY: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getSubDelay()); + return NO_ERROR; + } break; + case GET_TRACK_COUNT: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getTrackCount()); + return NO_ERROR; + } break; + case GET_TRACK_LIST: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + int count = data.readInt32(); + MediaPlayer_TrackInfo *trackList = new MediaPlayer_TrackInfo[count]; + if(trackList == NULL){ + reply->writeInt32(-1); + return NO_ERROR; + } + count = getTrackList(trackList, count); + if(count > 0){ + reply->writeInt32(count); + MediaPlayer_TrackInfo *info; + for(int i = 0; i < count; i++){ + info = trackList + i; + reply->writeInt32(info->len); + if(info->len > 0) + reply->write(info->name, info->len); + reply->writeCString(info->charset); + } + } + delete[] trackList; + return NO_ERROR; + } break; + case GET_CUR_TRACK: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getCurTrack()); + return NO_ERROR; + } break; + case SWITCH_TRACK: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(switchTrack(data.readInt32())); + return NO_ERROR; + } break; + case SET_INPUT_DIMENSION_TYPE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + int type = data.readInt32(); + reply->writeInt32(setInputDimensionType(type)); + return NO_ERROR; + } break; + case GET_INPUT_DIMENSION_TYPE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getInputDimensionType()); + return NO_ERROR; + } break; + case SET_OUTPUT_DIMENSION_TYPE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + int type = data.readInt32(); + reply->writeInt32(setOutputDimensionType(type)); + return NO_ERROR; + } break; + case GET_OUTPUT_DIMENSION_TYPE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getOutputDimensionType()); + return NO_ERROR; + } break; + case SET_ANAGLAGH_TYPE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + int type = data.readInt32(); + reply->writeInt32(setAnaglaghType(type)); + return NO_ERROR; + } break; + case GET_ANAGLAGH_TYPE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getAnaglaghType()); + return NO_ERROR; + } break; + case GET_VIDEO_ENCODE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + char *encode = new char[MEDIAPLAYER_NAME_LEN_MAX]; + if(encode == NULL){ + reply->writeInt32(-1); + return NO_ERROR; + } + status_t ret = getVideoEncode(encode); + reply->writeInt32(ret); + if(ret == OK){ + reply->writeCString(encode); + } + delete[] encode; + return NO_ERROR; + } break; + case GET_VIDEO_FRAME_RATE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getVideoFrameRate()); + return NO_ERROR; + } break; + case GET_AUDIO_ENCODE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + char *encode = new char[MEDIAPLAYER_NAME_LEN_MAX]; + if(encode == NULL){ + reply->writeInt32(-1); + return NO_ERROR; + } + status_t ret = getAudioEncode(encode); + reply->writeInt32(ret); + if(ret == OK){ + reply->writeCString(encode); + } + delete[] encode; + return NO_ERROR; + } break; + case GET_AUDIO_BIT_RATE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getAudioBitRate()); + return NO_ERROR; + } break; + case GET_AUDIO_SAMPLE_RATE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getAudioSampleRate()); + return NO_ERROR; + } break; + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + case ENABLE_SCALE_MODE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + int type = data.readInt32(); + int width = data.readInt32(); + int height = data.readInt32(); + reply->writeInt32(enableScaleMode(type, width, height)); + return NO_ERROR; + } break; + /* add by Gary. end -----------------------------------}} */ default: return BBinder::onTransact(code, data, reply, flags); } diff --git a/media/libmedia/IMediaPlayerService.cpp b/media/libmedia/IMediaPlayerService.cpp index 8e4dd04f811ac..5659e84f4b97c 100644 --- a/media/libmedia/IMediaPlayerService.cpp +++ b/media/libmedia/IMediaPlayerService.cpp @@ -38,6 +38,28 @@ enum { GET_OMX, ADD_BATTERY_DATA, PULL_BATTERY_DATA + /* add by Gary. start {{----------------------------------- */ + , + SET_SCREEN, + GET_SCREEN, + IS_PLAYING_VIDEO + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + , + SET_VPP_GATE, + GET_VPP_GATE, + SET_LUMA_SHARP, + GET_LUMA_SHARP, + SET_CHROMA_SHARP, + GET_CHROMA_SHARP, + SET_WHITE_EXTEND, + GET_WHITE_EXTEND, + SET_BLACK_EXTEND, + GET_BLACK_EXTEND + /* add by Gary. end -----------------------------------}} */ }; class BpMediaPlayerService: public BpInterface @@ -123,6 +145,124 @@ class BpMediaPlayerService: public BpInterface data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); return remote()->transact(PULL_BATTERY_DATA, data, reply); } + /* add by Gary. start {{----------------------------------- */ + status_t setScreen(int screen) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + data.writeInt32(screen); + remote()->transact(SET_SCREEN, data, &reply); + return reply.readInt32(); + } + + status_t getScreen(int *screen) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + remote()->transact(GET_SCREEN, data, &reply); + *screen = reply.readInt32(); + return reply.readInt32(); + } + + status_t isPlayingVideo(int *ret) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + remote()->transact(IS_PLAYING_VIDEO, data, &reply); + *ret = reply.readInt32(); + return reply.readInt32(); + } + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + status_t setVppGate(bool enableVpp) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + data.writeInt32(enableVpp); + remote()->transact(SET_VPP_GATE, data, &reply); + return reply.readInt32(); + } + + bool getVppGate() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + remote()->transact(GET_VPP_GATE, data, &reply); + return reply.readInt32(); + } + + status_t setLumaSharp(int value) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + data.writeInt32(value); + remote()->transact(SET_LUMA_SHARP, data, &reply); + return reply.readInt32(); + } + + int getLumaSharp() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + remote()->transact(GET_LUMA_SHARP, data, &reply); + return reply.readInt32(); + } + + status_t setChromaSharp(int value) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + data.writeInt32(value); + remote()->transact(SET_CHROMA_SHARP, data, &reply); + return reply.readInt32(); + } + + int getChromaSharp() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + remote()->transact(GET_CHROMA_SHARP, data, &reply); + return reply.readInt32(); + } + + status_t setWhiteExtend(int value) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + data.writeInt32(value); + remote()->transact(SET_WHITE_EXTEND, data, &reply); + return reply.readInt32(); + } + + int getWhiteExtend() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + remote()->transact(GET_WHITE_EXTEND, data, &reply); + return reply.readInt32(); + } + + status_t setBlackExtend(int value) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + data.writeInt32(value); + remote()->transact(SET_BLACK_EXTEND, data, &reply); + return reply.readInt32(); + } + + int getBlackExtend() + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); + remote()->transact(GET_BLACK_EXTEND, data, &reply); + return reply.readInt32(); + } + + /* add by Gary. end -----------------------------------}} */ }; IMPLEMENT_META_INTERFACE(MediaPlayerService, "android.media.IMediaPlayerService"); @@ -202,6 +342,84 @@ status_t BnMediaPlayerService::onTransact( pullBatteryData(reply); return NO_ERROR; } break; + /* add by Gary. start {{----------------------------------- */ + case SET_SCREEN: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(setScreen(data.readInt32())); + return NO_ERROR; + } break; + case GET_SCREEN: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + int screen; + status_t ret = getScreen(&screen); + reply->writeInt32(screen); + reply->writeInt32(ret); + return NO_ERROR; + } break; + case IS_PLAYING_VIDEO: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + int playing; + status_t ret = isPlayingVideo(&playing); + reply->writeInt32(playing); + reply->writeInt32(ret); + return NO_ERROR; + } break; + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + case SET_VPP_GATE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(setVppGate(data.readInt32())); + return NO_ERROR; + } break; + case GET_VPP_GATE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getVppGate()); + return NO_ERROR; + } break; + case SET_LUMA_SHARP: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(setLumaSharp(data.readInt32())); + return NO_ERROR; + } break; + case GET_LUMA_SHARP: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getLumaSharp()); + return NO_ERROR; + } break; + case SET_CHROMA_SHARP: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(setChromaSharp(data.readInt32())); + return NO_ERROR; + } break; + case GET_CHROMA_SHARP: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getChromaSharp()); + return NO_ERROR; + } break; + case SET_WHITE_EXTEND: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(setWhiteExtend(data.readInt32())); + return NO_ERROR; + } break; + case GET_WHITE_EXTEND: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getWhiteExtend()); + return NO_ERROR; + } break; + case SET_BLACK_EXTEND: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(setBlackExtend(data.readInt32())); + return NO_ERROR; + } break; + case GET_BLACK_EXTEND: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + reply->writeInt32(getBlackExtend()); + return NO_ERROR; + } break; + /* add by Gary. end -----------------------------------}} */ default: return BBinder::onTransact(code, data, reply, flags); } diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp index c2e1ddfaf43b6..dc727ba4ab298 100644 --- a/media/libmedia/mediaplayer.cpp +++ b/media/libmedia/mediaplayer.cpp @@ -63,6 +63,19 @@ MediaPlayer::MediaPlayer() mAudioSessionId = AudioSystem::newAudioSessionId(); AudioSystem::acquireAudioSessionId(mAudioSessionId); mSendLevel = 0; + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-28 16:28:24 */ + /* save properties before creating the real player */ + mSubGate = true; + mSubColor = 0xFFFFFFFF; + mSubFrameColor = 0xFF000000; + mSubPosition = 0; + mSubDelay = 0; + mSubFontSize = 24; + strcpy(mSubCharset, CHARSET_GBK); + mSubIndex = 0; + mTrackIndex = 0; + /* add by Gary. end -----------------------------------}} */ } MediaPlayer::~MediaPlayer() @@ -149,6 +162,21 @@ status_t MediaPlayer::setDataSource( if (NO_ERROR != player->setDataSource(url, headers)) { player.clear(); } + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-28 16:28:24 */ + /* save properties before creating the real player */ + if(player != 0) { + player->setSubGate(mSubGate); + player->setSubColor(mSubColor); + player->setSubFrameColor(mSubFrameColor); + player->setSubPosition(mSubPosition); + player->setSubDelay(mSubDelay); + player->setSubFontSize(mSubFontSize); + player->setSubCharset(mSubCharset); + player->switchSub(mSubIndex); + player->switchTrack(mTrackIndex); + } + /* add by Gary. end -----------------------------------}} */ err = attachNewPlayer(player); } } @@ -709,6 +737,44 @@ void MediaPlayer::notify(int msg, int ext1, int ext2, const Parcel *obj) } } +/* add by Gary. start {{----------------------------------- */ +/* 2011-10-9 8:54:30 */ +/* add callback for parsing 3d source */ +int MediaPlayer::parse3dFile(int type) +{ + LOGD("type = %d", type); + bool locked = false; + + // TODO: In the future, we might be on the same thread if the app is + // running in the same process as the media server. In that case, + // this will deadlock. + // + // The threadId hack below works around this for the care of prepare + // and seekTo within the same process. + // FIXME: Remember, this is a hack, it's not even a hack that is applied + // consistently for all use-cases, this needs to be revisited. + if (mLockThreadId != getThreadId()) { + mLock.lock(); + locked = true; + } + + sp listener = mListener; + if (locked) mLock.unlock(); + + // this prevents re-entrant calls into client code + if (listener != 0) { +// Mutex::Autolock _l(mNotifyLock); + LOGV("callback application"); + listener->parse3dFile(type); + LOGV("back from callback"); + + return 0; + } + + return -1; +} +/* add by Gary. end -----------------------------------}} */ + /*static*/ sp MediaPlayer::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) { LOGV("decode(%s)", url); @@ -743,4 +809,507 @@ void MediaPlayer::died() } +/* add by Gary. {{----------------------------------- */ +status_t MediaPlayer::setScreen(int screen) +{ + LOGV("setScreen"); + const sp& service(getMediaPlayerService()); + if (service != 0) { + return service->setScreen(screen); + }else { + return BAD_VALUE; + } +} + +status_t MediaPlayer::getScreen(int *screen) +{ + LOGV("getScreen"); + const sp& service(getMediaPlayerService()); + if (service != 0) { + return service->getScreen(screen); + }else { + return BAD_VALUE; + } +} + +status_t MediaPlayer::isPlayingVideo(bool *playing) +{ + LOGV("isPlayingVideo"); + int b; + int r; + + const sp& service(getMediaPlayerService()); + if (service != 0) { + r = service->isPlayingVideo(&b); + if(b) + *playing = true; + else + *playing = false; + + return r; + }else { + return BAD_VALUE; + } +} +/* add by Gary. end -----------------------------------}} */ + +/* add by Gary. start {{----------------------------------- */ +/* 2011-9-14 14:27:12 */ +/* expend interfaces about subtitle, track and so on */ +int MediaPlayer::getSubCount() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getSubCount(); +} + +int MediaPlayer::getSubList(MediaPlayer_SubInfo *infoList, int count) +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getSubList(infoList, count); +} + +int MediaPlayer::getCurSub() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getCurSub(); +} + + +status_t MediaPlayer::switchSub(int index) +{ + Mutex::Autolock lock(mLock); + mSubIndex = index; + if (mPlayer == NULL) { + return NO_INIT; + } + return mPlayer->switchSub(index); +} + + +status_t MediaPlayer::setSubGate(bool showSub) +{ + Mutex::Autolock lock(mLock); + mSubGate = showSub; + if (mPlayer == NULL) { + return OK; + } + return mPlayer->setSubGate(showSub); +} + + +bool MediaPlayer::getSubGate() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return false; + } + return mPlayer->getSubGate(); +} + + +status_t MediaPlayer::setSubColor(int color) +{ + Mutex::Autolock lock(mLock); + mSubColor = color; + if (mPlayer == NULL) { + return OK; + } + return mPlayer->setSubColor(color); +} + + +int MediaPlayer::getSubColor() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return 0xFFFFFFFF; + } + return mPlayer->getSubColor(); +} + + +status_t MediaPlayer::setSubFrameColor(int color) +{ + Mutex::Autolock lock(mLock); + mSubFrameColor = color; + if (mPlayer == NULL) { + return OK; + } + return mPlayer->setSubFrameColor(color); +} + + +int MediaPlayer::getSubFrameColor() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return 0xFFFFFFFF; + } + return mPlayer->getSubFrameColor(); +} + + +status_t MediaPlayer::setSubFontSize(int size) +{ + Mutex::Autolock lock(mLock); + mSubFontSize = size; + if (mPlayer == NULL) { + return OK; + } + return mPlayer->setSubFontSize(size); +} + + +int MediaPlayer::getSubFontSize() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getSubFontSize(); +} + + +status_t MediaPlayer::setSubCharset(const char *charset) +{ + Mutex::Autolock lock(mLock); + strcpy(mSubCharset, charset); + if (mPlayer == NULL) { + return OK; + } + return mPlayer->setSubCharset(charset); +} + + +status_t MediaPlayer::getSubCharset(char *charset) +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return NO_INIT; + } + return mPlayer->getSubCharset(charset); +} + + +status_t MediaPlayer::setSubPosition(int percent) +{ + Mutex::Autolock lock(mLock); + mSubPosition = percent; + if (mPlayer == NULL) { + return OK; + } + return mPlayer->setSubPosition(percent); +} + + +int MediaPlayer::getSubPosition() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return NO_INIT; + } + return mPlayer->getSubPosition(); +} + + +status_t MediaPlayer::setSubDelay(int time) +{ + Mutex::Autolock lock(mLock); + mSubDelay = time; + if (mPlayer == NULL) { + return OK; + } + return mPlayer->setSubDelay(time); +} + + +int MediaPlayer::getSubDelay() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getSubDelay(); +} + + +int MediaPlayer::getTrackCount() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getTrackCount(); +} + + +int MediaPlayer::getTrackList(MediaPlayer_TrackInfo *infoList, int count) +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getTrackList((MediaPlayer_TrackInfo *)infoList, count); +} + + +int MediaPlayer::getCurTrack() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getCurTrack(); +} + + +status_t MediaPlayer::switchTrack(int index) +{ + Mutex::Autolock lock(mLock); + mTrackIndex = index; + if (mPlayer == NULL) { + return NO_INIT; + } + return mPlayer->switchTrack(index); +} + + +status_t MediaPlayer::setInputDimensionType(int type) +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return NO_INIT; + } + return mPlayer->setInputDimensionType(type); +} + + +int MediaPlayer::getInputDimensionType() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getInputDimensionType(); +} + + +status_t MediaPlayer::setOutputDimensionType(int type) +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return NO_INIT; + } + return mPlayer->setOutputDimensionType(type); +} + + +int MediaPlayer::getOutputDimensionType() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getOutputDimensionType(); +} + + +status_t MediaPlayer::setAnaglaghType(int type) +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return NO_INIT; + } + return mPlayer->setAnaglaghType(type); +} + + +int MediaPlayer::getAnaglaghType() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getAnaglaghType(); +} + + +status_t MediaPlayer::getVideoEncode(char *encode) +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getVideoEncode(encode); +} + + +int MediaPlayer::getVideoFrameRate() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getVideoFrameRate(); +} + + +status_t MediaPlayer::getAudioEncode(char *encode) +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getAudioEncode(encode); +} + + +int MediaPlayer::getAudioBitRate() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getAudioBitRate(); +} + + +int MediaPlayer::getAudioSampleRate() +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return -1; + } + return mPlayer->getAudioSampleRate(); +} + + +/* add by Gary. end -----------------------------------}} */ + +/* add by Gary. start {{----------------------------------- */ +/* 2011-11-14 */ +/* support scale mode */ +status_t MediaPlayer::enableScaleMode(bool enable, int width, int height) +{ + Mutex::Autolock lock(mLock); + if (mPlayer == NULL) { + return NO_INIT; + } + return mPlayer->enableScaleMode(enable, width, height); +} +/* add by Gary. end -----------------------------------}} */ + +/* add by Gary. start {{----------------------------------- */ +/* 2011-11-14 */ +/* support adjusting colors while playing video */ +status_t MediaPlayer::setVppGate(bool enableVpp) +{ + const sp& service(getMediaPlayerService()); + if (service != 0) { + return service->setVppGate(enableVpp); + }else { + return BAD_VALUE; + } +} + +bool MediaPlayer::getVppGate() +{ + const sp& service(getMediaPlayerService()); + if (service != 0) { + return service->getVppGate(); + }else { + return false; + } +} + +status_t MediaPlayer::setLumaSharp(int value) +{ + const sp& service(getMediaPlayerService()); + if (service != 0) { + return service->setLumaSharp(value); + }else { + return BAD_VALUE; + } +} + +int MediaPlayer::getLumaSharp() +{ + const sp& service(getMediaPlayerService()); + if (service != 0) { + return service->getLumaSharp(); + }else { + return -1; + } +} + +int MediaPlayer::getChromaSharp() +{ + const sp& service(getMediaPlayerService()); + if (service != 0) { + return service->getChromaSharp(); + }else { + return -1; + } +} + +status_t MediaPlayer::setChromaSharp(int value) +{ + const sp& service(getMediaPlayerService()); + if (service != 0) { + return service->setChromaSharp(value); + }else { + return BAD_VALUE; + } +} + +int MediaPlayer::getWhiteExtend() +{ + const sp& service(getMediaPlayerService()); + if (service != 0) { + return service->getWhiteExtend(); + }else { + return -1; + } +} + +status_t MediaPlayer::setWhiteExtend(int value) +{ + const sp& service(getMediaPlayerService()); + if (service != 0) { + return service->setWhiteExtend(value); + }else { + return BAD_VALUE; + } +} + +int MediaPlayer::getBlackExtend() +{ + const sp& service(getMediaPlayerService()); + if (service != 0) { + return service->getBlackExtend(); + }else { + return -1; + } +} + +status_t MediaPlayer::setBlackExtend(int value) +{ + const sp& service(getMediaPlayerService()); + if (service != 0) { + return service->setBlackExtend(value); + }else { + return BAD_VALUE; + } +} + +/* add by Gary. end -----------------------------------}} */ }; // namespace android diff --git a/media/libmediaplayerservice/Android.mk b/media/libmediaplayerservice/Android.mk index a975613aab054..75302b17b7c47 100644 --- a/media/libmediaplayerservice/Android.mk +++ b/media/libmediaplayerservice/Android.mk @@ -14,7 +14,10 @@ LOCAL_SRC_FILES:= \ MidiMetadataRetriever.cpp \ MidiFile.cpp \ StagefrightPlayer.cpp \ - StagefrightRecorder.cpp + StagefrightRecorder.cpp \ + CedarPlayer.cpp \ + CedarAPlayerWrapper.cpp \ + SimpleMediaFormatProbe.cpp LOCAL_SHARED_LIBRARIES := \ libcutils \ @@ -25,6 +28,8 @@ LOCAL_SHARED_LIBRARIES := \ libmedia \ libcamera_client \ libandroid_runtime \ + libCedarX \ + libCedarA \ libstagefright \ libstagefright_omx \ libstagefright_foundation \ @@ -38,6 +43,12 @@ LOCAL_STATIC_LIBRARIES := \ LOCAL_C_INCLUDES := \ $(JNI_H_INCLUDE) \ $(call include-path-for, graphics corecg) \ + $(TOP)/external/cedarx/CedarXAndroid/IceCreamSandwich \ + $(TOP)/external/cedarx/CedarX/include \ + $(TOP)/external/cedarx/CedarX/include/include_audio \ + $(TOP)/external/cedarx/CedarX/include/include_cedarv \ + $(TOP)/external/cedarx/CedarA \ + $(TOP)/external/cedarx/CedarA/include \ $(TOP)/frameworks/base/include/media/stagefright/openmax \ $(TOP)/frameworks/base/media/libstagefright/include \ $(TOP)/frameworks/base/media/libstagefright/rtsp \ diff --git a/media/libmediaplayerservice/CedarAPlayerWrapper.cpp b/media/libmediaplayerservice/CedarAPlayerWrapper.cpp new file mode 100644 index 0000000000000..b46c9bd8c9a38 --- /dev/null +++ b/media/libmediaplayerservice/CedarAPlayerWrapper.cpp @@ -0,0 +1,211 @@ +//#define LOG_NDEBUG 0 +#define LOG_TAG "CedarAPlayerWrapperWrapper" +#include + +#include "CedarAPlayerWrapper.h" + +#include + +#include +#include + +namespace android { + +CedarAPlayerWrapper::CedarAPlayerWrapper() + : mPlayer(new CedarAPlayer) { + LOGV("CedarAPlayerWrapper"); + + mPlayer->setListener(this); +} + +CedarAPlayerWrapper::~CedarAPlayerWrapper() { + LOGV("~CedarAPlayerWrapper"); + reset(); + + delete mPlayer; + mPlayer = NULL; +} + +status_t CedarAPlayerWrapper::initCheck() { + LOGV("initCheck"); + return OK; +} + +status_t CedarAPlayerWrapper::setUID(uid_t uid) { + mPlayer->setUID(uid); + + return OK; +} + +status_t CedarAPlayerWrapper::setDataSource( + const char *url, const KeyedVector *headers) { + LOGD("setDataSource('%s')", url); + return mPlayer->setDataSource(url, headers); +} + +// Warning: The filedescriptor passed into this method will only be valid until +// the method returns, if you want to keep it, dup it! +status_t CedarAPlayerWrapper::setDataSource(int fd, int64_t offset, int64_t length) { + LOGD("setDataSource(%d, %lld, %lld)", fd, offset, length); + return mPlayer->setDataSource(dup(fd), offset, length); +} + +status_t CedarAPlayerWrapper::setDataSource(const sp &source) { + return mPlayer->setDataSource(source); +} + +status_t CedarAPlayerWrapper::setParameter(int key, const Parcel &request) { + LOGV("setParameter"); + return mPlayer->setParameter(key, request); +} + +status_t CedarAPlayerWrapper::getParameter(int key, Parcel *reply) { + LOGV("getParameter"); + return mPlayer->getParameter(key, reply); +} + +status_t CedarAPlayerWrapper::setVideoSurface(const sp &surface) { + LOGV("setVideoSurface"); + + return mPlayer->setSurface(surface); +} + +status_t CedarAPlayerWrapper::setVideoSurfaceTexture( + const sp &surfaceTexture) { + LOGV("setVideoSurfaceTexture"); + + return mPlayer->setSurfaceTexture(surfaceTexture); +} + +status_t CedarAPlayerWrapper::prepare() { + return mPlayer->prepare(); +} + +status_t CedarAPlayerWrapper::prepareAsync() { + return mPlayer->prepareAsync(); +} + +status_t CedarAPlayerWrapper::start() { + LOGV("start"); + + return mPlayer->play(); +} + +status_t CedarAPlayerWrapper::stop() { + LOGV("stop"); + + return mPlayer->stop(); // what's the difference? +} + +status_t CedarAPlayerWrapper::pause() { + LOGV("pause"); + + return mPlayer->pause(); +} + +bool CedarAPlayerWrapper::isPlaying() { + LOGV("isPlaying"); + return mPlayer->isPlaying(); +} + +status_t CedarAPlayerWrapper::seekTo(int msec) { + LOGV("seekTo"); + + status_t err = mPlayer->seekTo((int64_t)msec); + + return err; +} + +status_t CedarAPlayerWrapper::getCurrentPosition(int *msec) { + LOGV("getCurrentPosition"); + + int64_t positionUs; + status_t err = mPlayer->getPosition(&positionUs); + + if (err != OK) { + return err; + } + + *msec = (positionUs + 500) / 1000; + + return OK; +} + +status_t CedarAPlayerWrapper::getDuration(int *msec) { + LOGV("getDuration"); + + int64_t durationUs; + status_t err = mPlayer->getDuration(&durationUs); + + if (err != OK) { + *msec = 0; + return OK; + } + + *msec = (durationUs + 500) / 1000; + + return OK; +} + +status_t CedarAPlayerWrapper::reset() { + LOGV("reset"); + + mPlayer->reset(); + + return OK; +} + +status_t CedarAPlayerWrapper::setLooping(int loop) { + LOGV("setLooping"); + + return mPlayer->setLooping(loop); +} + +player_type CedarAPlayerWrapper::playerType() { + LOGV("playerType"); + return CEDARX_PLAYER; +} + +//status_t CedarAPlayerWrapper::setScreen(int screen) { +// LOGV("setScreen"); +// return mPlayer->setScreen(screen); +//} + +status_t CedarAPlayerWrapper::invoke(const Parcel &request, Parcel *reply) { + return INVALID_OPERATION; +} + +void CedarAPlayerWrapper::setAudioSink(const sp &audioSink) { + MediaPlayerInterface::setAudioSink(audioSink); + + mPlayer->setAudioSink(audioSink); +} + +status_t CedarAPlayerWrapper::getMetadata( + const media::Metadata::Filter& ids, Parcel *records) { + using media::Metadata; + + uint32_t flags = mPlayer->flags(); + + Metadata metadata(records); + + metadata.appendBool( + Metadata::kPauseAvailable, + flags & MediaExtractor::CAN_PAUSE); + + metadata.appendBool( + Metadata::kSeekBackwardAvailable, + flags & MediaExtractor::CAN_SEEK_BACKWARD); + + metadata.appendBool( + Metadata::kSeekForwardAvailable, + flags & MediaExtractor::CAN_SEEK_FORWARD); + + metadata.appendBool( + Metadata::kSeekAvailable, + flags & MediaExtractor::CAN_SEEK); + + return OK; +} + +} // namespace android diff --git a/media/libmediaplayerservice/CedarAPlayerWrapper.h b/media/libmediaplayerservice/CedarAPlayerWrapper.h new file mode 100644 index 0000000000000..069492414ba93 --- /dev/null +++ b/media/libmediaplayerservice/CedarAPlayerWrapper.h @@ -0,0 +1,77 @@ +/* +** +** Copyright 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 ANDROID_CedarAPlayerWrapper_H +#define ANDROID_CedarAPlayerWrapper_H + +#include + +namespace android { + +struct CedarAPlayer; + +class CedarAPlayerWrapper : public MediaPlayerInterface { +public: + CedarAPlayerWrapper(); + virtual ~CedarAPlayerWrapper(); + + virtual status_t initCheck(); + + virtual status_t setUID(uid_t uid); + + virtual status_t setDataSource( + const char *url, const KeyedVector *headers); + + virtual status_t setDataSource(int fd, int64_t offset, int64_t length); + + virtual status_t setDataSource(const sp &source); + + virtual status_t setVideoSurface(const sp &surface); + virtual status_t setVideoSurfaceTexture( + const sp &surfaceTexture); + virtual status_t prepare(); + virtual status_t prepareAsync(); + virtual status_t start(); + virtual status_t stop(); + virtual status_t pause(); + virtual bool isPlaying(); + virtual status_t seekTo(int msec); + virtual status_t getCurrentPosition(int *msec); + virtual status_t getDuration(int *msec); + virtual status_t reset(); + virtual status_t setLooping(int loop); + virtual player_type playerType(); + virtual status_t invoke(const Parcel &request, Parcel *reply); + virtual void setAudioSink(const sp &audioSink); + virtual status_t setParameter(int key, const Parcel &request); + virtual status_t getParameter(int key, Parcel *reply); + //virtual status_t setScreen(int screen); + + virtual status_t getMetadata( + const media::Metadata::Filter& ids, Parcel *records); + + //virtual status_t dump(int fd, const Vector &args) const; +private: + CedarAPlayer *mPlayer; + + CedarAPlayerWrapper(const CedarAPlayerWrapper &); + CedarAPlayerWrapper &operator=(const CedarAPlayerWrapper &); +}; + +} // namespace android + +#endif // ANDROID_CedarPlayer_H diff --git a/media/libmediaplayerservice/CedarPlayer.cpp b/media/libmediaplayerservice/CedarPlayer.cpp new file mode 100644 index 0000000000000..721f8179484f2 --- /dev/null +++ b/media/libmediaplayerservice/CedarPlayer.cpp @@ -0,0 +1,417 @@ +//#define LOG_NDEBUG 0 +#define LOG_TAG "CedarPlayerWrapper" +#include + +#include "CedarPlayer.h" + +#include + +#include +#include + +namespace android { + +CedarPlayer::CedarPlayer() + : mPlayer(new CedarXPlayer) { + LOGV("CedarPlayer"); + + mPlayer->setListener(this); +} + +CedarPlayer::~CedarPlayer() { + LOGV("~CedarPlayer"); + reset(); + + delete mPlayer; + mPlayer = NULL; +} + +status_t CedarPlayer::initCheck() { + LOGV("initCheck"); + return OK; +} + +status_t CedarPlayer::setUID(uid_t uid) { + mPlayer->setUID(uid); + + return OK; +} + +status_t CedarPlayer::setDataSource( + const char *url, const KeyedVector *headers) { + LOGI("setDataSource('%s')", url); + return mPlayer->setDataSource(url, headers); +} + +// Warning: The filedescriptor passed into this method will only be valid until +// the method returns, if you want to keep it, dup it! +status_t CedarPlayer::setDataSource(int fd, int64_t offset, int64_t length) { + LOGV("setDataSource(%d, %lld, %lld)", fd, offset, length); + return mPlayer->setDataSource(dup(fd), offset, length); +} + +status_t CedarPlayer::setDataSource(const sp &source) { + return mPlayer->setDataSource(source); +} + +status_t CedarPlayer::setParameter(int key, const Parcel &request) { + LOGV("setParameter"); + return mPlayer->setParameter(key, request); +} + +status_t CedarPlayer::getParameter(int key, Parcel *reply) { + LOGV("getParameter"); + return mPlayer->getParameter(key, reply); +} + +status_t CedarPlayer::setVideoSurface(const sp &surface) { + LOGV("setVideoSurface"); + + return mPlayer->setSurface(surface); +} + +status_t CedarPlayer::setVideoSurfaceTexture( + const sp &surfaceTexture) { + LOGV("setVideoSurfaceTexture"); + + return mPlayer->setSurfaceTexture(surfaceTexture); +} + +status_t CedarPlayer::prepare() { + return mPlayer->prepare(); +} + +status_t CedarPlayer::prepareAsync() { + return mPlayer->prepareAsync(); +} + +status_t CedarPlayer::start() { + LOGV("start"); + + return mPlayer->play(); +} + +status_t CedarPlayer::stop() { + LOGV("stop"); + + return mPlayer->stop(); // what's the difference? +} + +status_t CedarPlayer::pause() { + LOGV("pause"); + + return mPlayer->pause(); +} + +bool CedarPlayer::isPlaying() { + LOGV("isPlaying"); + return mPlayer->isPlaying(); +} + +status_t CedarPlayer::seekTo(int msec) { + LOGV("seekTo"); + + status_t err = mPlayer->seekTo((int64_t)msec); + + return err; +} + +status_t CedarPlayer::getCurrentPosition(int *msec) { + LOGV("getCurrentPosition"); + + int64_t positionUs; + status_t err = mPlayer->getPosition(&positionUs); + + if (err != OK) { + return err; + } + + *msec = (positionUs + 500) / 1000; + + return OK; +} + +status_t CedarPlayer::getDuration(int *msec) { + LOGV("getDuration"); + + int64_t durationUs; + status_t err = mPlayer->getDuration(&durationUs); + + if (err != OK) { + *msec = 0; + return OK; + } + + *msec = (durationUs + 500) / 1000; + + return OK; +} + +status_t CedarPlayer::reset() { + LOGV("reset"); + + mPlayer->reset(); + + return OK; +} + +status_t CedarPlayer::setLooping(int loop) { + LOGV("setLooping"); + + return mPlayer->setLooping(loop); +} + +player_type CedarPlayer::playerType() { + LOGV("playerType"); + return CEDARX_PLAYER; +} + +status_t CedarPlayer::setScreen(int screen) { + LOGV("setScreen"); + return mPlayer->setScreen(screen); +} + +int CedarPlayer::getMeidaPlayerState() { + LOGV("getMeidaPlayerState"); + return mPlayer->getMeidaPlayerState(); +} + +status_t CedarPlayer::invoke(const Parcel &request, Parcel *reply) { + return INVALID_OPERATION; +} + +void CedarPlayer::setAudioSink(const sp &audioSink) { + MediaPlayerInterface::setAudioSink(audioSink); + + mPlayer->setAudioSink(audioSink); +} + +status_t CedarPlayer::getMetadata( + const media::Metadata::Filter& ids, Parcel *records) { + using media::Metadata; + + uint32_t flags = mPlayer->flags(); + + Metadata metadata(records); + + metadata.appendBool( + Metadata::kPauseAvailable, + flags & MediaExtractor::CAN_PAUSE); + + metadata.appendBool( + Metadata::kSeekBackwardAvailable, + flags & MediaExtractor::CAN_SEEK_BACKWARD); + + metadata.appendBool( + Metadata::kSeekForwardAvailable, + flags & MediaExtractor::CAN_SEEK_FORWARD); + + metadata.appendBool( + Metadata::kSeekAvailable, + flags & MediaExtractor::CAN_SEEK); + + return OK; +} + +int CedarPlayer::getSubCount() +{ + return mPlayer->getSubCount(); +} + +int CedarPlayer::getSubList(MediaPlayer_SubInfo *infoList, int count) +{ + return mPlayer->getSubList(infoList,count); +} + +int CedarPlayer::getCurSub() +{ + LOGD("CedarPlayer::getCurSub"); + return mPlayer->getCurSub(); +} + +status_t CedarPlayer::switchSub(int index) +{ + return mPlayer->switchSub(index); +} + +status_t CedarPlayer::setSubGate(bool showSub) +{ + return mPlayer->setSubGate(showSub); +} + +bool CedarPlayer::getSubGate() +{ + return mPlayer->getSubGate(); +} + +status_t CedarPlayer::setSubColor(int color) +{ + return mPlayer->setSubColor(color); +} + +int CedarPlayer::getSubColor() +{ + return mPlayer->getSubColor(); +}; + +status_t CedarPlayer::setSubFrameColor(int color) +{ + return mPlayer->setSubFrameColor(color); +} + +int CedarPlayer::getSubFrameColor() +{ + return mPlayer->getSubFrameColor(); +} + +status_t CedarPlayer::setSubFontSize(int size) +{ + return mPlayer->setSubFontSize(size); +} + +int CedarPlayer::getSubFontSize() +{ + return mPlayer->getSubFontSize(); +} + +status_t CedarPlayer::setSubCharset(const char *charset) +{ + return mPlayer->setSubCharset(charset); +} + +status_t CedarPlayer::getSubCharset(char *charset) +{ + return mPlayer->getSubCharset(charset); +} + +status_t CedarPlayer::setSubPosition(int percent) +{ + return mPlayer->setSubPosition(percent); +} + +int CedarPlayer::getSubPosition() +{ + return mPlayer->getSubPosition(); +} + +status_t CedarPlayer::setSubDelay(int time) +{ + return mPlayer->setSubDelay(time); +} + +int CedarPlayer::getSubDelay() +{ + return mPlayer->getSubDelay(); +} + +int CedarPlayer::getTrackCount() +{ + return mPlayer->getTrackCount(); +} + +int CedarPlayer::getTrackList(MediaPlayer_TrackInfo *infoList, int count) +{ + return mPlayer->getTrackList(infoList, count); +} + +int CedarPlayer::getCurTrack() +{ + return mPlayer->getCurTrack(); +} + +status_t CedarPlayer::switchTrack(int index) +{ + return mPlayer->switchTrack(index); +} + +status_t CedarPlayer::setInputDimensionType(int type) +{ + return mPlayer->setInputDimensionType(type); +} + +int CedarPlayer::getInputDimensionType() +{ + return mPlayer->getInputDimensionType(); +} + +status_t CedarPlayer::setOutputDimensionType(int type) +{ + return mPlayer->setOutputDimensionType(type); +} + +int CedarPlayer::getOutputDimensionType() +{ + return mPlayer->getOutputDimensionType(); +} + +status_t CedarPlayer::setAnaglaghType(int type) +{ + return mPlayer->setAnaglaghType(type); +} + +int CedarPlayer::getAnaglaghType() +{ + return mPlayer->getAnaglaghType(); +} + +status_t CedarPlayer::getVideoEncode(char *encode) +{ + return -1; +} + +int CedarPlayer::getVideoFrameRate() +{ + return -1; +} + +status_t CedarPlayer::getAudioEncode(char *encode) +{ + return -1; +} + +int CedarPlayer::getAudioBitRate() +{ + return -1; +} + +int CedarPlayer::getAudioSampleRate() +{ + return -1; +} + +status_t CedarPlayer::enableScaleMode(bool enable, int width, int height) +{ + return mPlayer->enableScaleMode(enable, width, height); +} + +status_t CedarPlayer::setVppGate(bool enableVpp) +{ + return mPlayer->setVppGate(enableVpp); +} + +status_t CedarPlayer::setLumaSharp(int value) +{ + return mPlayer->setLumaSharp(value); +} + +status_t CedarPlayer::setChromaSharp(int value) +{ + return mPlayer->setChromaSharp(value); +} + +status_t CedarPlayer::setWhiteExtend(int value) +{ + return mPlayer->setWhiteExtend(value); +} + +status_t CedarPlayer::setBlackExtend(int value) +{ + return mPlayer->setBlackExtend(value); +} + +status_t CedarPlayer::extensionControl(int command, int para0, int para1) +{ + return mPlayer->extensionControl(command, para0, para1); +} + +} // namespace android diff --git a/media/libmediaplayerservice/CedarPlayer.h b/media/libmediaplayerservice/CedarPlayer.h new file mode 100644 index 0000000000000..21cb5856337e7 --- /dev/null +++ b/media/libmediaplayerservice/CedarPlayer.h @@ -0,0 +1,121 @@ +/* +** +** Copyright 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 ANDROID_CEDARTPLAYER_H +#define ANDROID_CEDARTPLAYER_H + +#include + +namespace android { + +struct CedarXPlayer; + +class CedarPlayer : public MediaPlayerInterface { +public: + CedarPlayer(); + virtual ~CedarPlayer(); + + virtual status_t initCheck(); + + virtual status_t setUID(uid_t uid); + + virtual status_t setDataSource( + const char *url, const KeyedVector *headers); + + virtual status_t setDataSource(int fd, int64_t offset, int64_t length); + + virtual status_t setDataSource(const sp &source); + + virtual status_t setVideoSurface(const sp &surface); + virtual status_t setVideoSurfaceTexture( + const sp &surfaceTexture); + virtual status_t prepare(); + virtual status_t prepareAsync(); + virtual status_t start(); + virtual status_t stop(); + virtual status_t pause(); + virtual bool isPlaying(); + virtual status_t seekTo(int msec); + virtual status_t getCurrentPosition(int *msec); + virtual status_t getDuration(int *msec); + virtual status_t reset(); + virtual status_t setLooping(int loop); + virtual player_type playerType(); + virtual status_t invoke(const Parcel &request, Parcel *reply); + virtual void setAudioSink(const sp &audioSink); + virtual status_t setParameter(int key, const Parcel &request); + virtual status_t getParameter(int key, Parcel *reply); + virtual status_t setScreen(int screen); + virtual int getMeidaPlayerState(); + + virtual status_t getMetadata( + const media::Metadata::Filter& ids, Parcel *records); + + //virtual status_t dump(int fd, const Vector &args) const; + + virtual int getSubCount(); + virtual int getSubList(MediaPlayer_SubInfo *infoList, int count); + virtual int getCurSub(); + virtual status_t switchSub(int index); + virtual status_t setSubGate(bool showSub); + virtual bool getSubGate(); + virtual status_t setSubColor(int color); + virtual int getSubColor(); + virtual status_t setSubFrameColor(int color); + virtual int getSubFrameColor(); + virtual status_t setSubFontSize(int size); + virtual int getSubFontSize(); + virtual status_t setSubCharset(const char *charset); + virtual status_t getSubCharset(char *charset); + virtual status_t setSubPosition(int percent); + virtual int getSubPosition(); + virtual status_t setSubDelay(int time); + virtual int getSubDelay(); + virtual int getTrackCount(); + virtual int getTrackList(MediaPlayer_TrackInfo *infoList, int count); + virtual int getCurTrack(); + virtual status_t switchTrack(int index); + virtual status_t setInputDimensionType(int type); + virtual int getInputDimensionType(); + virtual status_t setOutputDimensionType(int type); + virtual int getOutputDimensionType(); + virtual status_t setAnaglaghType(int type); + virtual int getAnaglaghType(); + virtual status_t getVideoEncode(char *encode); + virtual int getVideoFrameRate(); + virtual status_t getAudioEncode(char *encode); + virtual int getAudioBitRate(); + virtual int getAudioSampleRate(); + + virtual status_t enableScaleMode(bool enable, int width, int height); + virtual status_t setVppGate(bool enableVpp); + virtual status_t setLumaSharp(int value); + virtual status_t setChromaSharp(int value); + virtual status_t setWhiteExtend(int value); + virtual status_t setBlackExtend(int value); + virtual status_t extensionControl(int command, int para0, int para1); + //don't add any extension interface in future!! +private: + CedarXPlayer *mPlayer; + + CedarPlayer(const CedarPlayer &); + CedarPlayer &operator=(const CedarPlayer &); +}; + +} // namespace android + +#endif // ANDROID_CedarPlayer_H diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index 2888888bb5a57..f04c7deda5969 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -68,8 +68,40 @@ #include "TestPlayerStub.h" #include "StagefrightPlayer.h" #include "nuplayer/NuPlayerDriver.h" +#include "CedarPlayer.h" +#include "CedarAPlayerWrapper.h" +#include "SimpleMediaFormatProbe.h" #include +/* add by Gary. start {{----------------------------------- */ +/* save the screen info */ +#define PROP_SCREEN_KEY "mediasw.sft.screen" +#define PROP_MASTER_SCREEN "master" +#define PROP_SLAVE_SCREEN "slave" +#define PROP_SCREEN_DEFAULT_VALUE PROP_MASTER_SCREEN +/* add by Gary. end -----------------------------------}} */ + +/* add by Gary. start {{----------------------------------- */ +/* 2011-11-14 */ +/* support adjusting colors while playing video */ +#define PROP_VPP_GATE_KEY "mediasw.sft.vpp_gate" +#define PROP_ENABLE_VPP "enable vpp" +#define PROP_DISABLE_VPP "disable vpp" +#define PROP_VPP_GATE_DEFAULT_VALUE PROP_DISABLE_VPP + +#define PROP_LUMA_SHARP_KEY "mediasw.sft.luma_sharp" +#define PROP_LUMA_SHARP_DEFAULT_VALUE PROP_DISABLE_VPP + +#define PROP_CHROMA_SHARP_KEY "mediasw.sft.chroma_sharp" +#define PROP_CHROMA_SHARP_DEFAULT_VALUE PROP_DISABLE_VPP + +#define PROP_WHITE_EXTEND_KEY "mediasw.sft.white_extend" +#define PROP_WHITE_EXTEND_DEFAULT_VALUE PROP_DISABLE_VPP + +#define PROP_BLACK_EXTEND_KEY "mediasw.sft.black_extend" +#define PROP_BLACK_EXTEND_DEFAULT_VALUE PROP_DISABLE_VPP + +/* add by Gary. end -----------------------------------}} */ namespace { using android::media::Metadata; @@ -195,6 +227,18 @@ typedef struct { const player_type playertype; } extmap; extmap FILE_EXTS [] = { + {".ogg", STAGEFRIGHT_PLAYER}, + {".mp3", STAGEFRIGHT_PLAYER}, + {".wav", STAGEFRIGHT_PLAYER}, + {".amr", STAGEFRIGHT_PLAYER}, + {".flac", STAGEFRIGHT_PLAYER}, + {".m4a", STAGEFRIGHT_PLAYER}, + {".out", STAGEFRIGHT_PLAYER}, + {".mp3?nolength", STAGEFRIGHT_PLAYER}, + {".ogg?nolength", STAGEFRIGHT_PLAYER}, + //{".3gp", STAGEFRIGHT_PLAYER}, + + //{".aac", STAGEFRIGHT_PLAYER}, {".mid", SONIVOX_PLAYER}, {".midi", SONIVOX_PLAYER}, {".smf", SONIVOX_PLAYER}, @@ -203,6 +247,13 @@ extmap FILE_EXTS [] = { {".rtttl", SONIVOX_PLAYER}, {".rtx", SONIVOX_PLAYER}, {".ota", SONIVOX_PLAYER}, + {".ape", CEDARA_PLAYER}, + {".ac3", CEDARA_PLAYER}, + {".dts", CEDARA_PLAYER}, + {".wma", CEDARA_PLAYER}, + {".aac", CEDARA_PLAYER}, + {".mp2", CEDARA_PLAYER}, + {".mp1", CEDARA_PLAYER}, }; // TODO: Find real cause of Audio/Video delay in PV framework and remove this workaround @@ -227,6 +278,62 @@ MediaPlayerService::MediaPlayerService() } // speaker is on by default mBatteryAudio.deviceOn[SPEAKER] = 1; + /* add by Gary. start {{----------------------------------- */ + char prop_value[PROPERTY_VALUE_MAX]; + property_get(PROP_SCREEN_KEY, prop_value, PROP_SCREEN_DEFAULT_VALUE); + LOGV("prop_value = %s", prop_value); + String8 value( prop_value ); + if(value == PROP_MASTER_SCREEN) + mScreen = MASTER_SCREEN; + else + mScreen = SLAVE_SCREEN; + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + property_get(PROP_VPP_GATE_KEY, prop_value, PROP_VPP_GATE_DEFAULT_VALUE); + LOGV("prop_value of PROP_VPP_GATE_KEY = %s", prop_value); + String8 vpp_value(prop_value); + if(vpp_value == PROP_ENABLE_VPP) + mVppGate = true; + else + mVppGate = false; + + int int_value; + + property_get(PROP_LUMA_SHARP_KEY, prop_value, PROP_LUMA_SHARP_DEFAULT_VALUE); + LOGV("prop_value of PROP_LUMA_SHARP_KEY = %s", prop_value); + int_value = prop_value[0] - '0'; + if(int_value < 0) + int_value = 0; + int_value %= 5; + mLumaSharp = int_value; + + property_get(PROP_CHROMA_SHARP_KEY, prop_value, PROP_CHROMA_SHARP_DEFAULT_VALUE); + LOGV("prop_value of PROP_CHROMA_SHARP_KEY = %s", prop_value); + int_value = prop_value[0] - '0'; + if(int_value < 0) + int_value = 0; + int_value %= 5; + mChromaSharp = int_value; + + property_get(PROP_WHITE_EXTEND_KEY, prop_value, PROP_WHITE_EXTEND_DEFAULT_VALUE); + LOGV("prop_value of PROP_WHITE_EXTEND_KEY = %s", prop_value); + int_value = prop_value[0] - '0'; + if(int_value < 0) + int_value = 0; + int_value %= 5; + mWhiteExtend = int_value; + + property_get(PROP_BLACK_EXTEND_KEY, prop_value, PROP_BLACK_EXTEND_DEFAULT_VALUE); + LOGV("prop_value of PROP_BLACK_EXTEND_KEY = %s", prop_value); + int_value = prop_value[0] - '0'; + if(int_value < 0) + int_value = 0; + int_value %= 5; + mBlackExtend = int_value; + /* add by Gary. end -----------------------------------}} */ } MediaPlayerService::~MediaPlayerService() @@ -269,6 +376,20 @@ sp MediaPlayerService::create(pid_t pid, const spgetCallingUid()); + /* add by Gary. start {{----------------------------------- */ + c->setScreen(mScreen); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + c->setVppGate(mVppGate); + c->setLumaSharp(mLumaSharp); + c->setChromaSharp(mChromaSharp); + c->setWhiteExtend(mWhiteExtend); + c->setBlackExtend(mBlackExtend); + /* add by Gary. end -----------------------------------}} */ + wp w = c; { @@ -489,6 +610,30 @@ MediaPlayerService::Client::Client( mAudioSessionId = audioSessionId; mUID = uid; + /* add by Gary. start {{----------------------------------- */ + mHasSurface = 0; + /* add by Gary. end -----------------------------------}} */ + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-28 16:28:24 */ + /* save properties before creating the real player */ + mSubGate = true; + mSubColor = 0xFFFFFFFF; + mSubFrameColor = 0xFF000000; + mSubPosition = 0; + mSubDelay = 0; + mSubFontSize = 24; + strcpy(mSubCharset, CHARSET_GBK); + mSubIndex = 0; + mTrackIndex = 0; + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + mEnableScaleMode = false; + mScaleWidth = 0; + mScaleHeight = 0; + /* add by Gary. end -----------------------------------}} */ #if CALLBACK_ANTAGONIZER LOGD("create Antagonizer"); mAntagonizer = new Antagonizer(notify, this); @@ -536,14 +681,17 @@ void MediaPlayerService::Client::disconnect() } static player_type getDefaultPlayerType() { - return STAGEFRIGHT_PLAYER; + return CEDARX_PLAYER; + //return STAGEFRIGHT_PLAYER; } -player_type getPlayerType(int fd, int64_t offset, int64_t length) +player_type getPlayerType(int fd, int64_t offset, int64_t length, bool check_cedar) { - char buf[20]; + int r_size; + int file_format; + char buf[2048]; lseek(fd, offset, SEEK_SET); - read(fd, buf, sizeof(buf)); + r_size = read(fd, buf, sizeof(buf)); lseek(fd, offset, SEEK_SET); long ident = *((long*)buf); @@ -569,7 +717,25 @@ player_type getPlayerType(int fd, int64_t offset, int64_t length) EAS_Shutdown(easdata); } - return getDefaultPlayerType(); + if (check_cedar) { + file_format = audio_format_detect((unsigned char*)buf, r_size); + LOGV("getPlayerType: %d",file_format); + + if(file_format < MEDIA_FORMAT_STAGEFRIGHT_MAX && file_format > MEDIA_FORMAT_STAGEFRIGHT_MIN){ + LOGV("use STAGEFRIGHT_PLAYER"); + return STAGEFRIGHT_PLAYER; + } + else if(file_format < MEDIA_FORMAT_CEDARA_MAX && file_format > MEDIA_FORMAT_CEDARA_MIN){ + LOGV("use CEDARA_PLAYER"); + return CEDARA_PLAYER; + } + else if(file_format < MEDIA_FORMAT_CEDARX_MAX && file_format > MEDIA_FORMAT_CEDARX_MIN){ + LOGV("use CEDARX_PLAYER"); + return CEDARX_PLAYER; + } + } + + return STAGEFRIGHT_PLAYER; //getDefaultPlayerType(); } player_type getPlayerType(const char* url) @@ -577,7 +743,7 @@ player_type getPlayerType(const char* url) if (TestPlayerStub::canBeUsed(url)) { return TEST_PLAYER; } - +#if 0 if (!strncasecmp("http://", url, 7) || !strncasecmp("https://", url, 8)) { size_t len = strlen(url); @@ -593,7 +759,7 @@ player_type getPlayerType(const char* url) if (!strncasecmp("rtsp://", url, 7)) { return NU_PLAYER; } - +#endif // use MidiFile for MIDI extensions int lenURL = strlen(url); for (int i = 0; i < NELEM(FILE_EXTS); ++i) { @@ -614,6 +780,14 @@ static sp createPlayer(player_type playerType, void* cookie, { sp p; switch (playerType) { + case CEDARX_PLAYER: + LOGV(" create CedarXPlayer"); + p = new CedarPlayer; + break; + case CEDARA_PLAYER: + LOGV(" create CedarAPlayer"); + p = new CedarAPlayerWrapper; + break; case SONIVOX_PLAYER: LOGV(" create MidiFile"); p = new MidiFile(); @@ -707,6 +881,44 @@ status_t MediaPlayerService::Client::setDataSource( mAudioOutput = new AudioOutput(mAudioSessionId); static_cast(p.get())->setAudioSink(mAudioOutput); } + + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-28 16:28:24 */ + /* save properties before creating the real player */ + p->setSubGate(mSubGate); + p->setSubColor(mSubColor); + p->setSubFrameColor(mSubFrameColor); + p->setSubPosition(mSubPosition); + p->setSubDelay(mSubDelay); + p->setSubFontSize(mSubFontSize); + p->setSubCharset(mSubCharset); + p->switchSub(mSubIndex); + p->switchTrack(mTrackIndex); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-10-9 8:54:30 */ + /* add callback for parsing 3d source */ + p->setParse3dFileCallback(this, parse3dFile); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + p->enableScaleMode(mEnableScaleMode, mScaleWidth, mScaleHeight); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-30 */ + /* fix the bug about setting global attibute */ + LOGD("MediaPlayerService::Client::setDataSource() : screen = %d", mScreen); + p->setScreen(mScreen); + p->setVppGate(mVppGate); + p->setLumaSharp(mLumaSharp); + p->setChromaSharp(mChromaSharp); + p->setWhiteExtend(mWhiteExtend); + p->setBlackExtend(mBlackExtend); + /* add by Gary. end -----------------------------------}} */ // now set data source LOGV(" setDataSource"); @@ -746,7 +958,7 @@ status_t MediaPlayerService::Client::setDataSource(int fd, int64_t offset, int64 LOGV("calculated length = %lld", length); } - player_type playerType = getPlayerType(fd, offset, length); + player_type playerType = getPlayerType(fd, offset, length, true); LOGV("player type = %d", playerType); // create the right type of player @@ -778,6 +990,43 @@ status_t MediaPlayerService::Client::setDataSource( mAudioOutput = new AudioOutput(mAudioSessionId); static_cast(p.get())->setAudioSink(mAudioOutput); } + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-28 16:28:24 */ + /* save properties before creating the real player */ + p->setSubGate(mSubGate); + p->setSubColor(mSubColor); + p->setSubFrameColor(mSubFrameColor); + p->setSubPosition(mSubPosition); + p->setSubDelay(mSubDelay); + p->setSubFontSize(mSubFontSize); + p->setSubCharset(mSubCharset); + p->switchSub(mSubIndex); + p->switchTrack(mTrackIndex); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-10-9 8:54:30 */ + /* add callback for parsing 3d source */ + p->setParse3dFileCallback(this, parse3dFile); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + p->enableScaleMode(mEnableScaleMode, mScaleWidth, mScaleHeight); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-30 */ + /* fix the bug about setting global attibute */ + LOGD("MediaPlayerService::Client::setDataSource() : screen = %d", mScreen); + p->setScreen(mScreen); + p->setVppGate(mVppGate); + p->setLumaSharp(mLumaSharp); + p->setChromaSharp(mChromaSharp); + p->setWhiteExtend(mWhiteExtend); + p->setBlackExtend(mBlackExtend); + /* add by Gary. end -----------------------------------}} */ // now set data source mStatus = p->setDataSource(source); @@ -792,7 +1041,7 @@ status_t MediaPlayerService::Client::setDataSource( void MediaPlayerService::Client::disconnectNativeWindow() { if (mConnectedWindow != NULL) { status_t err = native_window_api_disconnect(mConnectedWindow.get(), - NATIVE_WINDOW_API_MEDIA); + NATIVE_WINDOW_API_MEDIA_HW); if (err != OK) { LOGW("native_window_api_disconnect returned an error: %s (%d)", @@ -819,7 +1068,7 @@ status_t MediaPlayerService::Client::setVideoSurfaceTexture( if (surfaceTexture != NULL) { anw = new SurfaceTextureClient(surfaceTexture); status_t err = native_window_api_connect(anw.get(), - NATIVE_WINDOW_API_MEDIA); + NATIVE_WINDOW_API_MEDIA_HW); if (err != OK) { LOGE("setVideoSurfaceTexture failed: %d", err); @@ -839,6 +1088,10 @@ status_t MediaPlayerService::Client::setVideoSurfaceTexture( // on the disconnected ANW, which may result in errors. status_t err = p->setVideoSurfaceTexture(surfaceTexture); + /* add by Gary. start {{----------------------------------- */ + mHasSurface = 1; + /* add by Gary. end -----------------------------------}} */ + disconnectNativeWindow(); mConnectedWindow = anw; @@ -1068,6 +1321,628 @@ status_t MediaPlayerService::Client::getParameter(int key, Parcel *reply) { return p->getParameter(key, reply); } +/* add by Gary. start {{----------------------------------- */ +status_t MediaPlayerService::setScreen(int screen) +{ + LOGV("setScreen(%d)", screen); + if( screen != MASTER_SCREEN && screen != SLAVE_SCREEN ) + return BAD_VALUE; + if( screen == mScreen ) + return OK; + + status_t ret = OK; + for (int i = 0, n = mClients.size(); i < n; ++i) { + sp c = mClients[i].promote(); + if (c != 0) { + status_t temp = c->setScreen(screen); + if( temp != OK ) + ret = temp; + } + } + + mScreen = screen; + + if(mScreen == MASTER_SCREEN) + property_set(PROP_SCREEN_KEY, PROP_MASTER_SCREEN); + else + property_set(PROP_SCREEN_KEY, PROP_SLAVE_SCREEN); + char prop_value[PROPERTY_VALUE_MAX]; + property_get(PROP_SCREEN_KEY, prop_value, "no screen"); + LOGV("prop_value = %s", prop_value); + + return ret; +} + +status_t MediaPlayerService::getScreen(int *screen) +{ + LOGV("get Screen"); + if( screen == NULL ) + return BAD_VALUE; + + *screen = mScreen; + return OK; +} + +status_t MediaPlayerService::Client::setScreen(int screen) +{ + LOGV("[%d] setScreen(%d)", mConnId, screen); + mScreen = screen; + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->setScreen(screen); +} + +status_t MediaPlayerService::isPlayingVideo(int *playing) +{ + status_t ret = OK; + *playing = 0; + for (int i = 0, n = mClients.size(); i < n; ++i) { + sp c = mClients[i].promote(); + if (c != 0) { + c->isPlayingVideo(playing); + if( *playing == 1 ) + return OK; + } + } + + return ret; +} + +status_t MediaPlayerService::Client::isPlayingVideo(int *playing) +{ + sp p = getPlayer(); + if (p == 0) { + *playing = 0; + return OK; + } + *playing = mHasSurface && (p->getMeidaPlayerState() != PLAYER_STATE_SUSPEND); + return OK; +} + +/* add by Gary. end -----------------------------------}} */ + +/* add by Gary. start {{----------------------------------- */ +/* 2011-9-15 15:41:36 */ +/* expend interfaces about subtitle, track and so on */ +int MediaPlayerService::Client::getSubCount() +{ + sp p = getPlayer(); + if (p == 0) + return -1; + return p->getSubCount(); +} + + +int MediaPlayerService::Client::getSubList(MediaPlayer_SubInfo *infoList, int count) +{ + sp p = getPlayer(); + if (p == 0) + return -1; + return p->getSubList((MediaPlayer_SubInfo *)infoList, count); +} + +int MediaPlayerService::Client::getCurSub() +{ + sp p = getPlayer(); + if (p == 0) + return -1; + return p->getCurSub(); +} + +status_t MediaPlayerService::Client::switchSub(int index) +{ + mSubIndex = index; + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->switchSub(index); +} + +status_t MediaPlayerService::Client::setSubGate(bool showSub) +{ + mSubGate = showSub; + sp p = getPlayer(); + if (p == 0) + return OK; + return p->setSubGate(showSub); +} + +bool MediaPlayerService::Client::getSubGate() +{ + sp p = getPlayer(); + if (p == 0) + return true; + return p->getSubGate(); +} + +status_t MediaPlayerService::Client::setSubColor(int color) +{ + mSubColor = color; + sp p = getPlayer(); + if (p == 0) + return OK; + return p->setSubColor(color); +} + +int MediaPlayerService::Client::getSubColor() +{ + sp p = getPlayer(); + if (p == 0) + return 0xFFFFFFFF; + return p->getSubColor(); +} + +status_t MediaPlayerService::Client::setSubFrameColor(int color) +{ + mSubFrameColor = color; + sp p = getPlayer(); + if (p == 0) + return OK; + return p->setSubFrameColor(color); +} + +int MediaPlayerService::Client::getSubFrameColor() +{ + sp p = getPlayer(); + if (p == 0) + return 0xFFFFFFFF; + return p->getSubFrameColor(); +} + +status_t MediaPlayerService::Client::setSubFontSize(int size) +{ + mSubFontSize = size; + sp p = getPlayer(); + if (p == 0) + return OK; + return p->setSubFontSize(size); +} + +int MediaPlayerService::Client::getSubFontSize() +{ + sp p = getPlayer(); + if (p == 0) + return -1; + return p->getSubFontSize(); +} + +status_t MediaPlayerService::Client::setSubCharset(const char *charset) +{ + strcpy(mSubCharset, charset); + sp p = getPlayer(); + if (p == 0) + return OK; + return p->setSubCharset(charset); +} + +status_t MediaPlayerService::Client::getSubCharset(char *charset) +{ + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->getSubCharset(charset); +} + +status_t MediaPlayerService::Client::setSubPosition(int percent) +{ + mSubPosition = percent; + sp p = getPlayer(); + if (p == 0) + return OK; + return p->setSubPosition(percent); +} + +int MediaPlayerService::Client::getSubPosition() +{ + sp p = getPlayer(); + if (p == 0) + return -1; + return p->getSubPosition(); +} + +status_t MediaPlayerService::Client::setSubDelay(int time) +{ + mSubDelay = time; + sp p = getPlayer(); + if (p == 0) + return OK; + return p->setSubDelay(time); +} + +int MediaPlayerService::Client::getSubDelay() +{ + sp p = getPlayer(); + if (p == 0) + return 0; + return p->getSubDelay(); +} + +int MediaPlayerService::Client::getTrackCount() +{ + sp p = getPlayer(); + if (p == 0) + return -1; + return p->getTrackCount(); +} + +int MediaPlayerService::Client::getTrackList(MediaPlayer_TrackInfo *infoList, int count) +{ + sp p = getPlayer(); + + if (p == 0) + return -1; + return p->getTrackList((MediaPlayer_TrackInfo *)infoList, count); +} + +int MediaPlayerService::Client::getCurTrack() +{ + sp p = getPlayer(); + if (p == 0) + return -1; + return p->getCurTrack(); +} + +status_t MediaPlayerService::Client::switchTrack(int index) +{ + mTrackIndex = index; + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->switchTrack(index); +} + +status_t MediaPlayerService::Client::setInputDimensionType(int type) +{ + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->setInputDimensionType(type); +} + +int MediaPlayerService::Client::getInputDimensionType() +{ + sp p = getPlayer(); + if (p == 0) + return -1; + return p->getInputDimensionType(); +} + +status_t MediaPlayerService::Client::setOutputDimensionType(int type) +{ + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->setOutputDimensionType(type); +} + +int MediaPlayerService::Client::getOutputDimensionType() +{ + sp p = getPlayer(); + if (p == 0) + return -1; + return p->getOutputDimensionType(); +} + +status_t MediaPlayerService::Client::setAnaglaghType(int type) +{ + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->setAnaglaghType(type); +} + +int MediaPlayerService::Client::getAnaglaghType() +{ + sp p = getPlayer(); + if (p == 0) + return -1; + return p->getAnaglaghType(); +} + +status_t MediaPlayerService::Client::getVideoEncode(char *encode) +{ + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->getVideoEncode(encode); +} + +int MediaPlayerService::Client::getVideoFrameRate() +{ + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->getVideoFrameRate(); +} + +status_t MediaPlayerService::Client::getAudioEncode(char *encode) +{ + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->getAudioEncode(encode); +} + +int MediaPlayerService::Client::getAudioBitRate() +{ + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->getAudioBitRate(); +} + +int MediaPlayerService::Client::getAudioSampleRate() +{ + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->getAudioSampleRate(); +} + +/* add by Gary. end -----------------------------------}} */ + +/* add by Gary. start {{----------------------------------- */ +/* 2011-10-9 8:54:30 */ +/* add callback for parsing 3d source */ +void MediaPlayerService::Client::parse3dFile(void* cookie, int type) +{ + Client* client = static_cast(cookie); + + LOGV("Client::parse3dFile: type = %d", type); + client->mClient->parse3dFile(type); +} +/* add by Gary. end -----------------------------------}} */ + +/* add by Gary. start {{----------------------------------- */ +/* 2011-11-14 */ +/* support scale mode */ +status_t MediaPlayerService::Client::enableScaleMode(bool enable, int width, int height) +{ + mEnableScaleMode = enable; + mScaleWidth = width; + mScaleHeight = height; + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->enableScaleMode(enable, width, height); +} +/* add by Gary. end -----------------------------------}} */ + +/* add by Gary. start {{----------------------------------- */ +/* 2011-11-14 */ +/* support adjusting colors while playing video */ +status_t MediaPlayerService::setVppGate(bool enableVpp) +{ + if( enableVpp == mVppGate ) + return OK; + + status_t ret = OK; + for (int i = 0, n = mClients.size(); i < n; ++i) { + sp c = mClients[i].promote(); + if (c != 0) { + status_t temp = c->setVppGate(enableVpp); + if( temp != OK ) + ret = temp; + } + } + + mVppGate = enableVpp; + + if(mVppGate) + property_set(PROP_VPP_GATE_KEY, PROP_ENABLE_VPP); + else + property_set(PROP_VPP_GATE_KEY, PROP_DISABLE_VPP); + char prop_value[PROPERTY_VALUE_MAX]; + property_get(PROP_VPP_GATE_KEY, prop_value, "no enableVpp"); + LOGV("prop_value of PROP_VPP_GATE_KEY = %s", prop_value); + + return ret; +} + +bool MediaPlayerService::getVppGate() +{ + return mVppGate; +} + +status_t MediaPlayerService::Client::setVppGate(bool enableVpp) +{ + mVppGate = enableVpp; + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->setVppGate(enableVpp); +} + +status_t MediaPlayerService::setLumaSharp(int value) +{ + if(value < 0) + return BAD_VALUE; + + value %= 5; + + if( value == mLumaSharp ) + return OK; + + status_t ret = OK; + for (int i = 0, n = mClients.size(); i < n; ++i) { + sp c = mClients[i].promote(); + if (c != 0) { + status_t temp = c->setLumaSharp(value); + if( temp != OK ) + ret = temp; + } + } + + mLumaSharp = value; + + char prop_value[2] = "\0"; + prop_value[0] = "01234"[value]; + property_set(PROP_LUMA_SHARP_KEY, prop_value); + + char prop_value2[PROPERTY_VALUE_MAX]; + property_get(PROP_LUMA_SHARP_KEY, prop_value2, "no proper LUMA_SHARP"); + LOGV("prop_value of PROP_LUMA_SHARP_KEY = %s", prop_value2); + + return ret; +} + +int MediaPlayerService::getLumaSharp() +{ + return mLumaSharp; +} + +status_t MediaPlayerService::Client::setLumaSharp(int value) +{ + mLumaSharp = value; + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->setLumaSharp(value); +} + +status_t MediaPlayerService::setChromaSharp(int value) +{ + if(value < 0) + return BAD_VALUE; + + value %= 5; + + if( value == mChromaSharp ) + return OK; + + status_t ret = OK; + for (int i = 0, n = mClients.size(); i < n; ++i) { + sp c = mClients[i].promote(); + if (c != 0) { + status_t temp = c->setChromaSharp(value); + if( temp != OK ) + ret = temp; + } + } + + mChromaSharp = value; + + char prop_value[2] = "\0"; + prop_value[0] = "01234"[value]; + property_set(PROP_CHROMA_SHARP_KEY, prop_value); + + char prop_value2[PROPERTY_VALUE_MAX]; + property_get(PROP_CHROMA_SHARP_KEY, prop_value2, "no proper CHROMA_SHARP"); + LOGV("prop_value of PROP_CHROMA_SHARP_KEY = %s", prop_value2); + + return ret; +} + +int MediaPlayerService::getChromaSharp() +{ + return mChromaSharp; +} + +status_t MediaPlayerService::Client::setChromaSharp(int value) +{ + mChromaSharp = value; + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->setChromaSharp(value); +} + +status_t MediaPlayerService::setWhiteExtend(int value) +{ + if(value < 0) + return BAD_VALUE; + + value %= 5; + + if( value == mWhiteExtend ) + return OK; + + status_t ret = OK; + for (int i = 0, n = mClients.size(); i < n; ++i) { + sp c = mClients[i].promote(); + if (c != 0) { + status_t temp = c->setWhiteExtend(value); + if( temp != OK ) + ret = temp; + } + } + + mWhiteExtend = value; + + char prop_value[2] = "\0"; + prop_value[0] = "01234"[value]; + property_set(PROP_WHITE_EXTEND_KEY, prop_value); + + char prop_value2[PROPERTY_VALUE_MAX]; + property_get(PROP_WHITE_EXTEND_KEY, prop_value2, "no proper WHITE_EXTEND"); + LOGV("prop_value of PROP_WHITE_EXTEND_KEY = %s", prop_value2); + + return ret; +} + +int MediaPlayerService::getWhiteExtend() +{ + return mWhiteExtend; +} + +status_t MediaPlayerService::Client::setWhiteExtend(int value) +{ + mWhiteExtend = value; + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->setWhiteExtend(value); +} + +status_t MediaPlayerService::setBlackExtend(int value) +{ + if(value < 0) + return BAD_VALUE; + + value %= 5; + + if( value == mBlackExtend ) + return OK; + + status_t ret = OK; + for (int i = 0, n = mClients.size(); i < n; ++i) { + sp c = mClients[i].promote(); + if (c != 0) { + status_t temp = c->setBlackExtend(value); + if( temp != OK ) + ret = temp; + } + } + + mBlackExtend = value; + + char prop_value[2] = "\0"; + prop_value[0] = "01234"[value]; + property_set(PROP_BLACK_EXTEND_KEY, prop_value); + + char prop_value2[PROPERTY_VALUE_MAX]; + property_get(PROP_BLACK_EXTEND_KEY, prop_value2, "no proper BLACK_EXTEND"); + LOGV("prop_value of PROP_BLACK_EXTEND_KEY = %s", prop_value2); + + return ret; +} + +int MediaPlayerService::getBlackExtend() +{ + return mBlackExtend; +} + +status_t MediaPlayerService::Client::setBlackExtend(int value) +{ + mBlackExtend = value; + sp p = getPlayer(); + if (p == 0) + return UNKNOWN_ERROR; + return p->setBlackExtend(value); +} + +/* add by Gary. end -----------------------------------}} */ void MediaPlayerService::Client::notify( void* cookie, int msg, int ext1, int ext2, const Parcel *obj) { @@ -1166,6 +2041,9 @@ sp MediaPlayerService::decode(const char* url, uint32_t *pSampleRate, i } player_type playerType = getPlayerType(url); + if (playerType == CEDARX_PLAYER || playerType == CEDARA_PLAYER) { + playerType = STAGEFRIGHT_PLAYER; + } LOGV("player type = %d", playerType); // create the right type of player @@ -1212,7 +2090,7 @@ sp MediaPlayerService::decode(int fd, int64_t offset, int64_t length, u sp mem; sp player; - player_type playerType = getPlayerType(fd, offset, length); + player_type playerType = getPlayerType(fd, offset, length, false); LOGV("player type = %d", playerType); // create the right type of player @@ -1269,6 +2147,7 @@ MediaPlayerService::AudioOutput::AudioOutput(int sessionId) mStreamType = AUDIO_STREAM_MUSIC; mLeftVolume = 1.0; mRightVolume = 1.0; + mLatency = 0; mMsecsPerFrame = 0; mAuxEffectId = 0; mSendLevel = 0.0; diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h index 2b66b7a534647..b29efb76ecb9f 100644 --- a/media/libmediaplayerservice/MediaPlayerService.h +++ b/media/libmediaplayerservice/MediaPlayerService.h @@ -125,6 +125,7 @@ class MediaPlayerService : public BnMediaPlayerService float mLeftVolume; float mRightVolume; float mMsecsPerFrame; + uint32_t mLatency; int mSessionId; float mSendLevel; int mAuxEffectId; @@ -254,6 +255,27 @@ class MediaPlayerService : public BnMediaPlayerService virtual void addBatteryData(uint32_t params); // API for the Battery app to pull the data of codecs usage virtual status_t pullBatteryData(Parcel* reply); + /* add by Gary. start {{----------------------------------- */ + virtual status_t setScreen(int screen); + virtual status_t getScreen(int *screen); + virtual status_t isPlayingVideo(int *playing); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + virtual status_t setVppGate(bool enableVpp); + virtual bool getVppGate(); + virtual status_t setLumaSharp(int value); + virtual int getLumaSharp(); + virtual status_t setChromaSharp(int value); + virtual int getChromaSharp(); + virtual status_t setWhiteExtend(int value); + virtual int getWhiteExtend(); + virtual status_t setBlackExtend(int value); + virtual int getBlackExtend(); + /* add by Gary. end -----------------------------------}} */ + private: class Client : public BnMediaPlayer { @@ -284,6 +306,71 @@ class MediaPlayerService : public BnMediaPlayerService virtual status_t setParameter(int key, const Parcel &request); virtual status_t getParameter(int key, Parcel *reply); + /* add by Gary. start {{----------------------------------- */ + virtual status_t setScreen(int screen); + virtual status_t isPlayingVideo(int *playing); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-15 15:39:01 */ + /* expend interfaces about subtitle, track and so on */ + virtual int getSubCount(); + virtual int getSubList(MediaPlayer_SubInfo *infoList, int count); + virtual int getCurSub(); + virtual status_t switchSub(int index); + virtual status_t setSubGate(bool showSub); + virtual bool getSubGate(); + virtual status_t setSubColor(int color); + virtual int getSubColor(); + virtual status_t setSubFrameColor(int color); + virtual int getSubFrameColor(); + virtual status_t setSubFontSize(int size); + virtual int getSubFontSize(); + virtual status_t setSubCharset(const char *charset); + virtual status_t getSubCharset(char *charset); + virtual status_t setSubPosition(int percent); + virtual int getSubPosition(); + virtual status_t setSubDelay(int time); + virtual int getSubDelay(); + virtual int getTrackCount(); + virtual int getTrackList(MediaPlayer_TrackInfo *infoList, int count); + virtual int getCurTrack(); + virtual status_t switchTrack(int index); + virtual status_t setInputDimensionType(int type); + virtual int getInputDimensionType(); + virtual status_t setOutputDimensionType(int type); + virtual int getOutputDimensionType(); + virtual status_t setAnaglaghType(int type); + virtual int getAnaglaghType(); + virtual status_t getVideoEncode(char *encode); + virtual int getVideoFrameRate(); + virtual status_t getAudioEncode(char *encode); + virtual int getAudioBitRate(); + virtual int getAudioSampleRate(); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-10-9 8:54:30 */ + /* add callback for parsing 3d source */ + static void parse3dFile(void* cookie, int type); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + virtual status_t enableScaleMode(bool enable, int width, int height); + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + virtual status_t setVppGate(bool enableVpp); + virtual status_t setLumaSharp(int value); + virtual status_t setChromaSharp(int value); + virtual status_t setWhiteExtend(int value); + virtual status_t setBlackExtend(int value); + /* add by Gary. end -----------------------------------}} */ + sp createPlayer(player_type playerType); virtual status_t setDataSource( @@ -345,6 +432,42 @@ class MediaPlayerService : public BnMediaPlayerService uid_t mUID; sp mConnectedWindow; sp mConnectedWindowBinder; + /* add by Gary. start {{----------------------------------- */ + int mHasSurface; + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-9-28 16:28:24 */ + /* save properties before creating the real player */ + bool mSubGate; + int mSubColor; + int mSubFrameColor; + int mSubPosition; + int mSubDelay; + int mSubFontSize; + char mSubCharset[MEDIAPLAYER_NAME_LEN_MAX]; + int mSubIndex; + int mTrackIndex; + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support scale mode */ + bool mEnableScaleMode; + int mScaleWidth; + int mScaleHeight; + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-30 */ + /* fix the bug about setting global attibute */ + int mScreen; + bool mVppGate; + int mLumaSharp; + int mChromaSharp; + int mWhiteExtend; + int mBlackExtend; + /* add by Gary. end -----------------------------------}} */ // Metadata filters. media::Metadata::Filter mMetadataAllow; // protected by mLock @@ -371,6 +494,19 @@ class MediaPlayerService : public BnMediaPlayerService SortedVector< wp > mMediaRecorderClients; int32_t mNextConnId; sp mOMX; + /* add by Gary. start {{----------------------------------- */ + int mScreen; + /* add by Gary. end -----------------------------------}} */ + + /* add by Gary. start {{----------------------------------- */ + /* 2011-11-14 */ + /* support adjusting colors while playing video */ + bool mVppGate; + int mLumaSharp; + int mChromaSharp; + int mWhiteExtend; + int mBlackExtend; + /* add by Gary. end -----------------------------------}} */ }; // ---------------------------------------------------------------------------- diff --git a/media/libmediaplayerservice/MetadataRetrieverClient.cpp b/media/libmediaplayerservice/MetadataRetrieverClient.cpp index d574ea3904f05..b2ba5c6a77671 100644 --- a/media/libmediaplayerservice/MetadataRetrieverClient.cpp +++ b/media/libmediaplayerservice/MetadataRetrieverClient.cpp @@ -38,11 +38,12 @@ #include "MidiMetadataRetriever.h" #include "MetadataRetrieverClient.h" #include "StagefrightMetadataRetriever.h" +#include "CedarXMetadataRetriever.h" namespace android { extern player_type getPlayerType(const char* url); -extern player_type getPlayerType(int fd, int64_t offset, int64_t length); +extern player_type getPlayerType(int fd, int64_t offset, int64_t length, bool check_cedar); MetadataRetrieverClient::MetadataRetrieverClient(pid_t pid) { @@ -86,6 +87,10 @@ static sp createRetriever(player_type playerType) { sp p; switch (playerType) { + case CEDARX_PLAYER: + case CEDARA_PLAYER: + p = new CedarXMetadataRetriever; + break; case STAGEFRIGHT_PLAYER: { p = new StagefrightMetadataRetriever; @@ -150,7 +155,7 @@ status_t MetadataRetrieverClient::setDataSource(int fd, int64_t offset, int64_t LOGV("calculated length = %lld", length); } - player_type playerType = getPlayerType(fd, offset, length); + player_type playerType = getPlayerType(fd, offset, length, false); LOGV("player type = %d", playerType); sp p = createRetriever(playerType); if (p == NULL) { diff --git a/media/libmediaplayerservice/SimpleMediaFormatProbe.cpp b/media/libmediaplayerservice/SimpleMediaFormatProbe.cpp new file mode 100644 index 0000000000000..bf0204346501e --- /dev/null +++ b/media/libmediaplayerservice/SimpleMediaFormatProbe.cpp @@ -0,0 +1,616 @@ +/******************************************************************************* +-- -- +-- CedarX Multimedia Framework -- +-- -- +-- the Multimedia Framework for Linux/Android System -- +-- -- +-- This software is confidential and proprietary and may be used -- +-- only as expressly authorized by a licensing agreement from -- +-- Softwinner Products. -- +-- -- +-- (C) COPYRIGHT 2011 SOFTWINNER PRODUCTS -- +-- ALL RIGHTS RESERVED -- +-- -- +-- The entire notice above must be reproduced -- +-- on all copies and should not be removed. -- +-- -- +*******************************************************************************/ + +//#define LOG_NDEBUG 0 +#define LOG_TAG "MediaPlayerServiceMediaFormatProbe" +#include + +#include "SimpleMediaFormatProbe.h" + +namespace android { + +#define AVPROBE_SCORE_MAX 100 + + +#define AV_RB32(x) ((((const unsigned char*)(x))[0] << 24) | \ + (((const unsigned char*)(x))[1] << 16) | \ + (((const unsigned char*)(x))[2] << 8) | \ + ((const unsigned char*)(x))[3]) + +#define AV_RL32(x) ((((const unsigned char*)(x))[3] << 24) | \ + (((const unsigned char*)(x))[2] << 16) | \ + (((const unsigned char*)(x))[1] << 8) | \ + ((const unsigned char*)(x))[0]) + +#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) + +#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) + +//---------------------------- Audio stream format probe ----------------------------------- +#define ID3v2_HEADER_SIZE 10 +#define MPA_STEREO 0 +#define MPA_JSTEREO 1 +#define MPA_DUAL 2 +#define MPA_MONO 3 + +const uint16_t ff_mpa_freq_tab[3] = { 44100, 48000, 32000 }; + +const uint16_t ff_mpa_bitrate_tab[2][3][15] = { + { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 }, + {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 }, + {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } }, + { {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256}, + {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}, + {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160} + } +}; + +#define MPA_DECODE_HEADER \ + int frame_size; \ + int error_protection; \ + int layer; \ + int sample_rate; \ + int sample_rate_index; /* between 0 and 8 */ \ + int bit_rate; \ + int nb_channels; \ + int mode; \ + int mode_ext; \ + int lsf; + +typedef struct MPADecodeHeader { + MPA_DECODE_HEADER +} MPADecodeHeader; + + +static int ff_id3v2_match(const uint8_t *buf) +{ + return buf[0] == 'I' && + buf[1] == 'D' && + buf[2] == '3' && + buf[3] != 0xff && + buf[4] != 0xff && + (buf[6] & 0x80) == 0 && + (buf[7] & 0x80) == 0 && + (buf[8] & 0x80) == 0 && + (buf[9] & 0x80) == 0; +} + +static int ff_id3v2_tag_len(const uint8_t * buf) +{ + int len = ((buf[6] & 0x7f) << 21) + + ((buf[7] & 0x7f) << 14) + + ((buf[8] & 0x7f) << 7) + + (buf[9] & 0x7f) + + ID3v2_HEADER_SIZE; + if (buf[5] & 0x10) + len += ID3v2_HEADER_SIZE; + return len; +} + +/* fast header check for resync */ +static inline int ff_mpa_check_header(uint32_t header){ + /* header */ + if ((header & 0xffe00000) != 0xffe00000) + return -1; + /* layer check */ + if ((header & (3<<17)) == 0) + return -1; + /* bit rate */ + if ((header & (0xf<<12)) == 0xf<<12) + return -1; + /* frequency */ + if ((header & (3<<10)) == 3<<10) + return -1; + return 0; +} + +static int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) +{ + int sample_rate, frame_size, mpeg25, padding; + int sample_rate_index, bitrate_index; + if (header & (1<<20)) { + s->lsf = (header & (1<<19)) ? 0 : 1; + mpeg25 = 0; + } else { + s->lsf = 1; + mpeg25 = 1; + } + + s->layer = 4 - ((header >> 17) & 3); + /* extract frequency */ + sample_rate_index = (header >> 10) & 3; + sample_rate = ff_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); + sample_rate_index += 3 * (s->lsf + mpeg25); + s->sample_rate_index = sample_rate_index; + s->error_protection = ((header >> 16) & 1) ^ 1; + s->sample_rate = sample_rate; + + bitrate_index = (header >> 12) & 0xf; + padding = (header >> 9) & 1; + //extension = (header >> 8) & 1; + s->mode = (header >> 6) & 3; + s->mode_ext = (header >> 4) & 3; + //copyright = (header >> 3) & 1; + //original = (header >> 2) & 1; + //emphasis = header & 3; + + if (s->mode == MPA_MONO) + s->nb_channels = 1; + else + s->nb_channels = 2; + + if (bitrate_index != 0) { + frame_size = ff_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index]; + s->bit_rate = frame_size * 1000; + switch(s->layer) { + case 1: + frame_size = (frame_size * 12000) / sample_rate; + frame_size = (frame_size + padding) * 4; + break; + case 2: + frame_size = (frame_size * 144000) / sample_rate; + frame_size += padding; + break; + default: + case 3: + frame_size = (frame_size * 144000) / (sample_rate << s->lsf); + frame_size += padding; + break; + } + s->frame_size = frame_size; + } else { + /* if no frame size computed, signal it */ + return 1; + } + + return 0; +} + +/* useful helper to get mpeg audio stream infos. Return -1 if error in + header, otherwise the coded frame size in bytes */ +static int ff_mpa_decode_header(uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate,int *layer) +{ + MPADecodeHeader s1, *s = &s1; + + if (ff_mpa_check_header(head) != 0) + return -1; + + if (ff_mpegaudio_decode_header(s, head) != 0) { + return -1; + } + + switch(s->layer) { + case 1: + //avctx->codec_id = CODEC_ID_MP1; + *frame_size = 384; + break; + case 2: + //avctx->codec_id = CODEC_ID_MP2; + *frame_size = 1152; + break; + default: + case 3: + //avctx->codec_id = CODEC_ID_MP3; + if (s->lsf) + *frame_size = 576; + else + *frame_size = 1152; + break; + } + + *sample_rate = s->sample_rate; + *channels = s->nb_channels; + *bit_rate = s->bit_rate; + *layer = s->layer; + //avctx->sub_id = s->layer; + return s->frame_size; +} + +static int mp3_probe(media_probe_data_t *p) +{ + int max_frames, first_frames = 0; + int fsize, frames, sample_rate; + uint32_t header; + uint8_t *buf, *buf0, *buf2, *end; + int layer = 0; + + buf0 = p->buf; + if(ff_id3v2_match(buf0)) { + buf0 += ff_id3v2_tag_len(buf0); + } + end = p->buf + p->buf_size - sizeof(uint32_t); + while(buf0 < end && !*buf0) + buf0++; + + max_frames = 0; + buf = buf0; + + for(; buf < end; buf= buf2+1) { + buf2 = buf; + + for(frames = 0; buf2 < end; frames++) { + header = AV_RB32(buf2); + fsize = ff_mpa_decode_header(header, &sample_rate, &sample_rate, &sample_rate, &sample_rate,&layer); + if(fsize < 0) + return 0;//break;//for error check aac->mp3; + buf2 += fsize; + } + max_frames = FFMAX(max_frames, frames); + if(buf == buf0) + first_frames= frames; + } + + //LOGV("first_frames:%d max_frames:%d",first_frames,max_frames); + + // keep this in sync with ac3 probe, both need to avoid + // issues with MPEG-files! + if((layer==1)||(layer==2)) + return AVPROBE_SCORE_MAX -3; + if (first_frames>=4) return AVPROBE_SCORE_MAX/2+1; + else if(max_frames>500)return AVPROBE_SCORE_MAX/2; + else if(max_frames>=2) return AVPROBE_SCORE_MAX/4; + else if(buf0!=p->buf) return AVPROBE_SCORE_MAX/4-1; + //else if(max_frames>=1) return 1; + else return 0; +//mpegps_mp3_unrecognized_format.mpg has max_frames=3 +} + +static int ogg_probe(media_probe_data_t *p) +{ + if (p->buf[0] == 'O' && p->buf[1] == 'g' && + p->buf[2] == 'g' && p->buf[3] == 'S' && + p->buf[4] == 0x0 && p->buf[5] <= 0x7 ) + return AVPROBE_SCORE_MAX; + else + return 0; +} + +static int wav_probe(media_probe_data_t *p) +{ + /* check file header */ + if (p->buf_size <= 32) + return 0; + if (!memcmp(p->buf + 8, "WAVE", 4)) { + if (!memcmp(p->buf, "RIFF", 4)) { + /* + Since ACT demuxer has standard WAV header at top of it's own, + returning score is decreased to avoid probe conflict + between ACT and WAV. + */ + int i, buflen = p->buf_size; + unsigned char *ptr = p->buf; + + for(i=0x10; i<(buflen > 512 ? 512 : buflen); i++) + { + if((ptr[i] == 0x64)&&(ptr[i+1] == 0x61)&&(ptr[i+2] == 0x74)&&(ptr[i+3] == 0x61)) + break; + } + i+=8; + if(i 512 ? 512 : buflen); i++) + { + if((ptr[i] == 0x66)&&(ptr[i+1] == 0x6D)&&(ptr[i+2] == 0x74)&&(ptr[i+3] == 0x20))//fmt + break; + } + if(ibuf, "RF64", 4) && + !memcmp(p->buf + 12, "ds64", 4)) + return AVPROBE_SCORE_MAX; + } + + return 0; +} + +static const char AMR_header [] = "#!AMR\n"; + +static int amr_probe(media_probe_data_t *p) +{ + //Only check for "#!AMR" which could be amr-wb, amr-nb. + //This will also trigger multichannel files: "#!AMR_MC1.0\n" and + //"#!AMR-WB_MC1.0\n" (not supported) + + if(memcmp(p->buf,AMR_header,5)==0) + return AVPROBE_SCORE_MAX; + else + return 0; +} + +static int ape_probe(media_probe_data_t * p) +{ + if (p->buf[0] == 'M' && p->buf[1] == 'A' && p->buf[2] == 'C' && p->buf[3] == ' ') + return AVPROBE_SCORE_MAX; + + return 0; +} + +static int flac_probe(media_probe_data_t *p) +{ + unsigned char *bufptr = p->buf; + unsigned char *end = p->buf + p->buf_size; + + if (p->buf[0] == 'f' && p->buf[1] == 'L' && p->buf[2] == 'a' && p->buf[3] == 'C') + return AVPROBE_SCORE_MAX; + + if(ff_id3v2_match(bufptr)) + bufptr += ff_id3v2_tag_len(bufptr); + + if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0; + else return AVPROBE_SCORE_MAX/2; +} + +static int wma_probe(media_probe_data_t *p) +{ + unsigned char asf_header[] = { 0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, + 0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C }; + + if(memcmp(p->buf, asf_header, 16) == 0) + { + return AVPROBE_SCORE_MAX; + } + + return 0; +} + +static int ac3_probe(media_probe_data_t *p) +{ + unsigned char *ptr = p->buf; + + if(((ptr[0] == 0x77)&&(ptr[1] == 0x0b)) + ||((ptr[0] == 0x0b)&&(ptr[1] == 0x77)) + ||((ptr[0] == 0x72)&&(ptr[1] == 0xf8)&&(ptr[2] == 0xbb)&&(ptr[3] == 0x6f)) + ||((ptr[0] == 0xf8)&&(ptr[1] == 0x72)&&(ptr[2] == 0x6f)&&(ptr[3] == 0xbb)) + ||((ptr[0] == 0x72)&&(ptr[1] == 0xf8)&&(ptr[2] == 0xba)&&(ptr[3] == 0x6f)) + ||((ptr[0] == 0xf8)&&(ptr[1] == 0x72)&&(ptr[2] == 0x6f)&&(ptr[3] == 0xba))) + //0x72f8bb6f//0xf8726fbb//0x72f8ba6f//0xf8726fba + { + return AVPROBE_SCORE_MAX; + } + + return 0; +} + +static int dts_probe(media_probe_data_t *p) +{ + unsigned char *ptr = p->buf; + + if ((ptr[0] == 0xff && ptr[1] == 0x1f && + ptr[2] == 0x00 && ptr[3] == 0xe8 && + (ptr[4] & 0xf0) == 0xf0 && ptr[5] == 0x07) + ||(ptr[0] == 0x1f && ptr[1] == 0xff && + ptr[2] == 0xe8 && ptr[3] == 0x00 && + ptr[4] == 0x07 && (ptr[5] & 0xf0) == 0xf0) + ||(ptr[0] == 0xfe && ptr[1] == 0x7f && + ptr[2] == 0x01 && ptr[3] == 0x80) + ||(ptr[0] == 0x7f && ptr[1] == 0xfe && + ptr[2] == 0x80 && ptr[3] == 0x01)) + { + return AVPROBE_SCORE_MAX; + } + + return 0; +} + +static int aac_probe(media_probe_data_t *p) +{ + unsigned char *ptr = p->buf; + + if((((ptr[0]&0xff)==0xff)&&((ptr[1]&0xf0)==0xf0)) + ||(((ptr[0]&0xff)==0x56)&&((ptr[1]&0xe0)==0xe0))) + { + return AVPROBE_SCORE_MAX; + } + + return 0; +} + +#define MAX_FTYPE_SIZE 64 + +static int mp4_probe(media_probe_data_t *p) { + unsigned int offset; + unsigned int tag; + int score = 0; + int ftyp_size; + char ftype_data[MAX_FTYPE_SIZE]; + + /* check file header */ + offset = 0; + for (;;) { + /* ignore invalid offset */ + if ((offset + 8) > (unsigned int) p->buf_size) + return score; + tag = AV_RL32(p->buf + offset + 4); + switch (tag) { + /* check for obvious tags */ + case MKTAG('j','P',' ',' '): /* jpeg 2000 signature */ + case MKTAG('m','o','o','v'): + case MKTAG('m','d','a','t'): + case MKTAG('p','n','o','t'): /* detect movs with preview pics like ew.mov and april.mov */ + case MKTAG('u','d','t','a'): /* Packet Video PVAuthor adds this and a lot of more junk */ + return AVPROBE_SCORE_MAX; + /* those are more common words, so rate then a bit less */ + case MKTAG('e','d','i','w'): /* xdcam files have reverted first tags */ + case MKTAG('w','i','d','e'): + case MKTAG('f','r','e','e'): + case MKTAG('j','u','n','k'): + case MKTAG('p','i','c','t'): + return AVPROBE_SCORE_MAX - 5; + case MKTAG('f','t','y','p'): + ftyp_size = AV_RB32(p->buf+offset) - 8; + ftyp_size = ftyp_size > MAX_FTYPE_SIZE ? MAX_FTYPE_SIZE-1 : ftyp_size; + memcpy(ftype_data, p->buf+offset+8, ftyp_size); + ftype_data[ftyp_size] = '\0'; + if(strstr(ftype_data,"3gp") != NULL) { + return 77; + } + return AVPROBE_SCORE_MAX; + case MKTAG(0x82,0x82,0x7f,0x7d ): + case MKTAG('s','k','i','p'): + case MKTAG('u','u','i','d'): + case MKTAG('p','r','f','l'): + offset = AV_RB32(p->buf+offset) + offset; + /* if we only find those cause probedata is too small at least rate them */ + score = AVPROBE_SCORE_MAX - 50; + break; + default: + /* unrecognized tag */ + return score; + } + } + + return score; +} + +int audio_format_detect(unsigned char *buf, int buf_size) +{ + media_probe_data_t prob; + int file_format = MEDIA_FORMAT_UNKOWN; + int ret = 0; + + prob.buf = buf; + prob.buf_size = buf_size; + + if(ogg_probe(&prob) > 0){ + return MEDIA_FORMAT_OGG; + } + + if(amr_probe(&prob) > 0){ + return MEDIA_FORMAT_AMR; + } + + if((ret = mp3_probe(&prob)) >= AVPROBE_SCORE_MAX/4-1){ + if(ret == (AVPROBE_SCORE_MAX - 3)) { + return MEDIA_FORMAT_CEDARA;//mp1,mp2 + } + else + { + return MEDIA_FORMAT_MP3; + } + } + + if(ff_id3v2_match(buf)) { + ret = ff_id3v2_tag_len(buf); + prob.buf = buf + ret; + prob.buf_size = buf_size - ret; + } + + if( (ret = wav_probe(&prob)) > 0){ + if(ret == (AVPROBE_SCORE_MAX - 2)) { + return MEDIA_FORMAT_DTS; + } + else if(ret == (AVPROBE_SCORE_MAX - 3)) { + LOGD("adpcm probe!"); + return MEDIA_FORMAT_CEDARA;//adpcm + } + else { + return MEDIA_FORMAT_WAV; + } + } + + if((ret = mp4_probe(&prob)) > 0) { + if(ret == 77) { + return MEDIA_FORMAT_3GP; + } + else { + return MEDIA_FORMAT_M4A; + } + } + + if(wma_probe(&prob) > 0){ + return MEDIA_FORMAT_WMA; + } + + if(ape_probe(&prob) > 0){ + return MEDIA_FORMAT_APE; + } + + if(flac_probe(&prob) > 0){ + return MEDIA_FORMAT_FLAC; + } + + if(ac3_probe(&prob) > 0){ + return MEDIA_FORMAT_AC3; + } + + if(dts_probe(&prob) > 0){ + return MEDIA_FORMAT_DTS; + } + + if(aac_probe(&prob) > 0){ + return MEDIA_FORMAT_AAC; + } + + return file_format; +} + +int stagefright_system_format_detect(unsigned char *buf, int buf_size) +{ + media_probe_data_t prob; + int file_format = MEDIA_FORMAT_UNKOWN; + int ret = 0; + + prob.buf = buf; + prob.buf_size = buf_size; + + if(ogg_probe(&prob) > 0){ + return MEDIA_FORMAT_OGG; + } + + if(amr_probe(&prob) > 0){ + return MEDIA_FORMAT_AMR; + } + + return file_format; +} + +} // android namespace diff --git a/media/libmediaplayerservice/SimpleMediaFormatProbe.h b/media/libmediaplayerservice/SimpleMediaFormatProbe.h new file mode 100644 index 0000000000000..dd3a11f2ecaf7 --- /dev/null +++ b/media/libmediaplayerservice/SimpleMediaFormatProbe.h @@ -0,0 +1,54 @@ +/******************************************************************************* +-- -- +-- CedarX Multimedia Framework -- +-- -- +-- the Multimedia Framework for Linux/Android System -- +-- -- +-- This software is confidential and proprietary and may be used -- +-- only as expressly authorized by a licensing agreement from -- +-- Softwinner Products. -- +-- -- +-- (C) COPYRIGHT 2011 SOFTWINNER PRODUCTS -- +-- ALL RIGHTS RESERVED -- +-- -- +-- The entire notice above must be reproduced -- +-- on all copies and should not be removed. -- +-- -- +*******************************************************************************/ + +namespace android { + +typedef struct media_probe_data_t{ + unsigned char *buf; + int buf_size; +}media_probe_data_t; + +typedef enum MEDIA_CONTAINER_FORMAT{ + MEDIA_FORMAT_UNKOWN = 0, //don't touch the order + MEDIA_FORMAT_STAGEFRIGHT_MIN = 0, + MEDIA_FORMAT_MP3 = 1, + MEDIA_FORMAT_OGG = 2, + MEDIA_FORMAT_WAV = 3, + MEDIA_FORMAT_AMR = 4, + MEDIA_FORMAT_FLAC = 5, + MEDIA_FORMAT_M4A = 6, + MEDIA_FORMAT_STAGEFRIGHT_MAX = 8, + + MEDIA_FORMAT_CEDARX_MIN = 8, + MEDIA_FORMAT_3GP = 9, + MEDIA_FORMAT_CEDARX_MAX = 16, + + MEDIA_FORMAT_CEDARA_MIN = 16, + MEDIA_FORMAT_APE = 17, + MEDIA_FORMAT_WMA = 19, + MEDIA_FORMAT_AC3 = 20, + MEDIA_FORMAT_DTS = 21, + MEDIA_FORMAT_AAC = 22, + MEDIA_FORMAT_CEDARA = 31, + MEDIA_FORMAT_CEDARA_MAX = 32, +}MEDIA_CONTAINER_FORMAT; + +extern int audio_format_detect(unsigned char *buf, int buf_size); +extern int stagefright_system_format_detect(unsigned char *buf, int buf_size); + +} // android namespace diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index 8c89dd9fb5704..8175a4f366d33 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -59,6 +59,8 @@ #include #endif +#define F_LOG LOGV("%s, line: %d", __FUNCTION__, __LINE__); + namespace android { // To collect the encoder usage for the battery app @@ -81,10 +83,11 @@ StagefrightRecorder::StagefrightRecorder() mStarted(false), mSurfaceMediaSource(NULL), mDisableAudio(false) { #else - mStarted(false), mSurfaceMediaSource(NULL) { + mStarted(false), mSurfaceMediaSource(NULL), #endif - + mpCedarXRecorder(NULL), + mbHWEncoder(false) { LOGV("Constructor"); reset(); } @@ -92,10 +95,32 @@ StagefrightRecorder::StagefrightRecorder() StagefrightRecorder::~StagefrightRecorder() { LOGV("Destructor"); stop(); + + if (mpCedarXRecorder != NULL) + { + delete mpCedarXRecorder; + mpCedarXRecorder = NULL; + } + mbHWEncoder = false; } status_t StagefrightRecorder::init() { LOGV("init"); + + if (mpCedarXRecorder != NULL) + { + LOGW("mpCedarXRecorder should be NULL at first\n"); + delete mpCedarXRecorder; + mpCedarXRecorder = NULL; + } + + mpCedarXRecorder = new CedarXRecorder(); + if (mpCedarXRecorder == NULL) + { + LOGE("create CedarXRecorder failed\n"); + return UNKNOWN_ERROR; + } + return OK; } @@ -209,7 +234,7 @@ status_t StagefrightRecorder::setVideoEncoder(video_encoder ve) { } if (ve == VIDEO_ENCODER_DEFAULT) { - mVideoEncoder = VIDEO_ENCODER_H263; + mVideoEncoder = VIDEO_ENCODER_H264; } else { mVideoEncoder = ve; } @@ -769,19 +794,90 @@ status_t StagefrightRecorder::setListener(const sp &listen } status_t StagefrightRecorder::prepare() { - return OK; + F_LOG; + status_t error = OK; + + // do not care audio encoder format + if(mVideoEncoder == VIDEO_ENCODER_H264 + && mpCedarXRecorder != NULL) + { + mbHWEncoder = true; + } + + if (mbHWEncoder) + { + mpCedarXRecorder->setPreviewSurface(mPreviewSurface); + + error = mpCedarXRecorder->setCamera(mCamera, mCameraProxy); + if (error != OK) + { + goto ERROR; + } + mpCedarXRecorder->setListener(mListener); + + // audio + if (mAudioSource != AUDIO_SOURCE_CNT) + { + mpCedarXRecorder->setAudioSource(mAudioSource); + mpCedarXRecorder->setAudioEncoder(mAudioEncoder); + mpCedarXRecorder->setParamAudioEncodingBitRate(mAudioBitRate); + mpCedarXRecorder->setParamAudioNumberOfChannels(mAudioChannels); + mpCedarXRecorder->setParamAudioSamplingRate(mSampleRate); + } + + // video + if (mVideoSource != VIDEO_SOURCE_LIST_END) + { + mpCedarXRecorder->setVideoSource(mVideoSource); + mpCedarXRecorder->setVideoEncoder(mVideoEncoder); + mpCedarXRecorder->setVideoSize(mVideoWidth, mVideoHeight); + mpCedarXRecorder->setParamVideoEncodingBitRate(mVideoBitRate); + mpCedarXRecorder->setVideoFrameRate(mFrameRate); + mpCedarXRecorder->setParamVideoRotation(mRotationDegrees); + } + + // output + mpCedarXRecorder->setParamMaxFileDurationUs(mMaxFileDurationUs); + mpCedarXRecorder->setParamMaxFileSizeBytes(mMaxFileSizeBytes); + mpCedarXRecorder->setOutputFile(mOutputFd); + mpCedarXRecorder->setOutputFormat(mOutputFormat); + + // location + mpCedarXRecorder->setParamGeoDataLatitude(mLatitudex10000); + mpCedarXRecorder->setParamGeoDataLongitude(mLongitudex10000); + + // lapse + mpCedarXRecorder->setParamTimeLapseEnable(mCaptureTimeLapse); + mpCedarXRecorder->setParamTimeBetweenTimeLapseFrameCapture(mTimeBetweenTimeLapseFrameCaptureUs); + + error = mpCedarXRecorder->prepare(); + if (error != OK) + { + goto ERROR; + } + } + +ERROR: + return error; } status_t StagefrightRecorder::start() { + F_LOG; CHECK(mOutputFd >= 0); + status_t status = OK; + + if (mbHWEncoder) + { + status = mpCedarXRecorder->start(); + goto HWENC_BATTERY; + } + if (mWriter != NULL) { LOGE("File writer is not avaialble"); return UNKNOWN_ERROR; } - status_t status = OK; - switch (mOutputFormat) { case OUTPUT_FORMAT_DEFAULT: case OUTPUT_FORMAT_THREE_GPP: @@ -818,6 +914,8 @@ status_t StagefrightRecorder::start() { break; } +HWENC_BATTERY: + if ((status == OK) && (!mStarted)) { mStarted = true; @@ -1727,11 +1825,20 @@ status_t StagefrightRecorder::startMPEG4Recording() { status_t StagefrightRecorder::pause() { LOGV("pause"); + + if (mbHWEncoder) + { + mpCedarXRecorder->pause(); + goto HWENC_BATTERY; + } + if (mWriter == NULL) { return UNKNOWN_ERROR; } mWriter->pause(); +HWENC_BATTERY: + if (mStarted) { mStarted = false; @@ -1759,11 +1866,19 @@ status_t StagefrightRecorder::stop() { mCameraSourceTimeLapse = NULL; } + if (mbHWEncoder) + { + err = mpCedarXRecorder->stop(); + goto HWENC_BATTERY; + } + if (mWriter != NULL) { err = mWriter->stop(); mWriter.clear(); } +HWENC_BATTERY: + if (mOutputFd >= 0) { ::close(mOutputFd); mOutputFd = -1; @@ -1862,6 +1977,11 @@ status_t StagefrightRecorder::getMaxAmplitude(int *max) { return BAD_VALUE; } + if (mbHWEncoder) + { + return mpCedarXRecorder->getMaxAmplitude(max); + } + if (mAudioSourceNode != 0) { *max = mAudioSourceNode->getMaxAmplitude(); } else { diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h index ef33ede62ae80..612be8528b3f3 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.h +++ b/media/libmediaplayerservice/StagefrightRecorder.h @@ -24,6 +24,8 @@ #include +#include + namespace android { class Camera; @@ -187,6 +189,9 @@ struct StagefrightRecorder : public MediaRecorderBase { void clipNumberOfAudioChannels(); void setDefaultProfileIfNecessary(); +private: + CedarXRecorder * mpCedarXRecorder; + bool mbHWEncoder; StagefrightRecorder(const StagefrightRecorder &); StagefrightRecorder &operator=(const StagefrightRecorder &); diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp index 44e6bb19eb582..079f6fa019525 100644 --- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp +++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp @@ -169,21 +169,14 @@ status_t NuPlayer::HTTPLiveSource::getDuration(int64_t *durationUs) { return mLiveSession->getDuration(durationUs); } -status_t NuPlayer::HTTPLiveSource::seekTo(int64_t seekTimeUs, int64_t* newSeekTime) { +status_t NuPlayer::HTTPLiveSource::seekTo(int64_t seekTimeUs) { // We need to make sure we're not seeking until we have seen the very first // PTS timestamp in the whole stream (from the beginning of the stream). while (!mTSParser->PTSTimeDeltaEstablished() && feedMoreTSData() == OK) { usleep(100000); } - if( mFinalResult != OK ) { - LOGW("Error state %d, Ignore this seek", mFinalResult); - return mFinalResult; - } - mLiveSession->seekTo(seekTimeUs, newSeekTime); - if( *newSeekTime >= 0 ) { - mTSParser->signalDiscontinuity( ATSParser::DISCONTINUITY_SEEK, NULL); - } + mLiveSession->seekTo(seekTimeUs); return OK; } diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h index 7d028f744d123..f22af5bee607a 100644 --- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h +++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h @@ -41,8 +41,7 @@ struct NuPlayer::HTTPLiveSource : public NuPlayer::Source { virtual status_t dequeueAccessUnit(bool audio, sp *accessUnit); virtual status_t getDuration(int64_t *durationUs); - virtual status_t seekTo(int64_t seekTimeUs, int64_t* newSeek = NULL); - + virtual status_t seekTo(int64_t seekTimeUs); virtual bool isSeekable(); protected: diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index aef118b225c38..50da88c9d1e9b 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -514,42 +514,18 @@ void NuPlayer::onMessageReceived(const sp &msg) { case kWhatSeek: { Mutex::Autolock autoLock(mLock); - int64_t seekTimeUs = -1, newSeekTime = -1; + int64_t seekTimeUs; CHECK(msg->findInt64("seekTimeUs", &seekTimeUs)); LOGV("kWhatSeek seekTimeUs=%lld us (%.2f secs)", seekTimeUs, seekTimeUs / 1E6); - mSource->seekTo(seekTimeUs, &newSeekTime); - LOGV("newSeekTime %lld", newSeekTime); - - if( newSeekTime >= 0 ) { - if( (mAudioDecoder != NULL) && - (mFlushingAudio == NONE || mFlushingAudio == AWAITING_DISCONTINUITY) ) { - flushDecoder( true, true ); - } - if( (mVideoDecoder != NULL) && - (mFlushingVideo == NONE || mFlushingVideo == AWAITING_DISCONTINUITY) ) { - flushDecoder( false, true ); - } - if( mAudioDecoder == NULL ) { - LOGV("Audio is not there, set it to shutdown"); - mFlushingAudio = SHUT_DOWN; - - } - if( mVideoDecoder == NULL ) { - LOGV("Video is not there, set it to shutdown"); - mFlushingVideo = SHUT_DOWN; - } - } + mSource->seekTo(seekTimeUs); if (mDriver != NULL) { sp driver = mDriver.promote(); if (driver != NULL) { driver->notifySeekComplete(); - if( newSeekTime >= 0 ) { - driver->notifyPosition( newSeekTime ); - } } } diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp index 5aa99bfa1ead5..23578ba4bf569 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp @@ -172,6 +172,11 @@ bool NuPlayerDriver::isPlaying() { return mState == PLAYING && !mAtEOS; } +int NuPlayerDriver::getMeidaPlayerState() { + LOGV("getMeidaPlayerState"); + return PLAYER_STATE_SUSPEND; +} + status_t NuPlayerDriver::seekTo(int msec) { int64_t seekTimeUs = msec * 1000ll; diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h index 4a0026ca90ad4..84775776f1ff1 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h @@ -45,6 +45,7 @@ struct NuPlayerDriver : public MediaPlayerInterface { virtual status_t stop(); virtual status_t pause(); virtual bool isPlaying(); + virtual int getMeidaPlayerState(); virtual status_t seekTo(int msec); virtual status_t getCurrentPosition(int *msec); virtual status_t getDuration(int *msec); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp index 0cb7f45b6f628..91178155831af 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp @@ -373,7 +373,7 @@ void NuPlayer::Renderer::onDrainVideoQueue() { int64_t realTimeUs = mediaTimeUs - mAnchorTimeMediaUs + mAnchorTimeRealUs; mVideoLateByUs = ALooper::GetNowUs() - realTimeUs; - bool tooLate = (mVideoLateByUs > 40000); + bool tooLate = (mVideoLateByUs > 40000*3); if (tooLate) { LOGV("video late by %lld us (%.2f secs)", lateByUs, lateByUs / 1E6); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h index 5b8b80e40066e..531b29f8b464a 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h @@ -43,7 +43,7 @@ struct NuPlayer::Source : public RefBase { return INVALID_OPERATION; } - virtual status_t seekTo(int64_t seekTimeUs, int64_t* newSeekTime = NULL ) { + virtual status_t seekTo(int64_t seekTimeUs) { return INVALID_OPERATION; } diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index f201682b62de1..85361be59631b 100755 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -58,8 +58,17 @@ Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved. #include "include/ColorFormat.h" #endif +#include +#include +#include + namespace android { +static int ALIGN(int x, int y) { + // y must be a power of 2. + return (x + y - 1) & ~(y - 1); +} + template static void InitOMXParams(T *params) { params->nSize = sizeof(T); @@ -2046,6 +2055,7 @@ void ACodec::BaseState::onOutputBufferDrained(const sp &msg) { HandleExtraData( bufferID ); } #endif + LOGV("onOutputBufferDrained mNativeWindowSoft!=NULL?%d",mCodec->mNativeWindowSoft!=NULL); int32_t render; if (mCodec->mNativeWindow != NULL && msg->findInt32("render", &render) && render != 0) { @@ -2059,7 +2069,44 @@ void ACodec::BaseState::onOutputBufferDrained(const sp &msg) { mCodec->signalError(); info->mStatus = BufferInfo::OWNED_BY_US; } - } else { + } + else if (mCodec->mNativeWindowSoft != NULL + && msg->findInt32("render", &render) && render != 0) { + ANativeWindowBuffer *buf; + int err; + if ((err = mCodec->mNativeWindowSoft->dequeueBuffer(mCodec->mNativeWindowSoft.get(), &buf)) != 0) { + LOGW("Surface::dequeueBuffer returned error %d", err); + return; + } + + CHECK_EQ(0, mCodec->mNativeWindowSoft->lockBuffer(mCodec->mNativeWindowSoft.get(), buf)); + + GraphicBufferMapper &mapper = GraphicBufferMapper::get(); + + Rect bounds(mCodec->mVideoWidth, mCodec->mVideoHeight); + + void *dst; + CHECK_EQ(0, mapper.lock( + buf->handle, GRALLOC_USAGE_SW_WRITE_OFTEN, bounds, &dst)); + + //LOGV("mColorFormat: %d", mColorFormat); + size_t dst_y_size = buf->stride * buf->height; + size_t dst_c_stride = ALIGN(buf->stride / 2, 16); + size_t dst_c_size = dst_c_stride * buf->height / 2; + + memcpy(dst, info->mData->data(), dst_y_size + dst_c_size*2); + LOGV("soft render buffer...%dX%d",mCodec->mVideoWidth,mCodec->mVideoHeight); + + CHECK_EQ(0, mapper.unlock(buf->handle)); + + if ((err = mCodec->mNativeWindowSoft->queueBuffer(mCodec->mNativeWindowSoft.get(), buf)) != 0) { + LOGW("Surface::queueBuffer returned error %d", err); + } + buf = NULL; + + info->mStatus = BufferInfo::OWNED_BY_US; + } + else { info->mStatus = BufferInfo::OWNED_BY_US; } @@ -2238,12 +2285,48 @@ void ACodec::UninitializedState::onSetup( sp obj; if (msg->findObject("native-window", &obj) - && strncmp("OMX.google.", componentName.c_str(), 11)) { + && (strncmp("OMX.google.", componentName.c_str(), 11) || !strncmp("OMX.google.h264", componentName.c_str(), 15))) { sp nativeWindow( static_cast(obj.get())); CHECK(nativeWindow != NULL); mCodec->mNativeWindow = nativeWindow->getNativeWindow(); } + else if (msg->findObject("native-window", &obj) + && mCodec->mNativeWindow == NULL) { + sp nativeWindow( + static_cast(obj.get())); + CHECK(nativeWindow != NULL); + + mCodec->mNativeWindowSoft = nativeWindow->getNativeWindow(); + LOGV("setup software native window"); + + if (!strncasecmp(mime.c_str(), "video/", 6)) { + int32_t width, height; + CHECK(msg->findInt32("width", &width)); + CHECK(msg->findInt32("height", &height)); + + mCodec->mVideoWidth = width; + mCodec->mVideoHeight = height; + + CHECK_EQ(0, + native_window_set_usage( + mCodec->mNativeWindowSoft.get(), + GRALLOC_USAGE_SW_READ_NEVER | GRALLOC_USAGE_SW_WRITE_OFTEN + | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP)); + + CHECK_EQ(0, + native_window_set_scaling_mode( + mCodec->mNativeWindowSoft.get(), + NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW)); + + // Width must be multiple of 32??? + CHECK_EQ(0, native_window_set_buffers_geometry( + mCodec->mNativeWindowSoft.get(), + width, + height, + HAL_PIXEL_FORMAT_YV12)); + } + } CHECK_EQ((status_t)OK, mCodec->initNativeWindow()); @@ -2787,6 +2870,7 @@ bool ACodec::IdleToLoadedState::onOMXEvent( CHECK_EQ(mCodec->mOMX->freeNode(mCodec->mNode), (status_t)OK); mCodec->mNativeWindow.clear(); + mCodec->mNativeWindowSoft.clear(); mCodec->mNode = NULL; mCodec->mOMX.clear(); mCodec->mComponentName.clear(); diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk index 14a41dfe8f2da..4995367a00591 100644 --- a/media/libstagefright/Android.mk +++ b/media/libstagefright/Android.mk @@ -136,7 +136,6 @@ LOCAL_STATIC_LIBRARIES := \ libstagefright_timedtext \ libvpx \ libstagefright_mpeg2ts \ - libstagefright_httplive \ libstagefright_id3 \ libFLAC \ @@ -154,6 +153,9 @@ ifeq ($(BOARD_USES_PROPRIETARY_OMX),SAMSUNG) LOCAL_CFLAGS += -DSAMSUNG_OMX endif +LOCAL_LDFLAGS += \ + $(TOP)/external/cedarx/CedarAndroidLib/LIB_ICS_F23/libstagefright_httplive_opt.a + ################################################################################ # The following was shamelessly copied from external/webkit/Android.mk and diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index 1a81afcd0e7d4..10205da3cde0d 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -360,7 +360,7 @@ sp MPEG4Extractor::getTrackMetaData( CHECK(track->meta->findCString(kKeyMIMEType, &mime)); if (!strncasecmp("video/", mime, 6)) { uint32_t sampleIndex; - uint32_t sampleTime; + uint64_t sampleTime; if (track->sampleTable->findThumbnailSample(&sampleIndex) == OK && track->sampleTable->getMetaDataForSample( sampleIndex, NULL /* offset */, NULL /* size */, @@ -2028,6 +2028,7 @@ size_t MPEG4Source::parseNALSize(const uint8_t *data) const { status_t MPEG4Source::read( MediaBuffer **out, const ReadOptions *options) { Mutex::Autolock autoLock(mLock); + bool isSeekMode = false; CHECK(mStarted); @@ -2044,6 +2045,7 @@ status_t MPEG4Source::read( findFlags = SampleTable::kFlagBefore; break; case ReadOptions::SEEK_NEXT_SYNC: + case ReadOptions::SEEK_VENDOR_OPT: findFlags = SampleTable::kFlagAfter; break; case ReadOptions::SEEK_CLOSEST_SYNC: @@ -2054,6 +2056,8 @@ status_t MPEG4Source::read( CHECK(!"Should not be here."); break; } + + isSeekMode = true; uint32_t sampleIndex; status_t err = mSampleTable->findSampleAtTime( @@ -2073,7 +2077,46 @@ status_t MPEG4Source::read( sampleIndex, &syncSampleIndex, findFlags); } - uint32_t sampleTime; + if (mode == ReadOptions::SEEK_VENDOR_OPT) { + off64_t offset; + size_t size; + uint64_t cts; + status_t err; + uint32_t currSampleIndex = syncSampleIndex; + int64_t offsetBefind; + uint32_t left; + uint32_t right; + + offsetBefind = options->getLateBy(); + mSampleTable->getMetaDataForSample(currSampleIndex, &offset, &size, &cts); + + if(offset < offsetBefind) { + left = currSampleIndex; + right = mSampleTable->countSamples() - 1; + + while (left < right) { + uint32_t center = (left + right) / 2; + mSampleTable->getMetaDataForSample(center, &offset, &size, &cts); + LOGV("offsetBefind:0x%llx offset:0x%llx center:%d left:%d right:%d",offsetBefind, offset, center, left, right); + if (offsetBefind < offset) { + right = center; + } else if (offsetBefind > offset) { + left = center + 1; + } else { + left = center; + break; + } + } + + currSampleIndex = left; + + mSampleTable->getMetaDataForSample(currSampleIndex, &offset, &size, &cts); + } + + syncSampleIndex = sampleIndex = currSampleIndex; + } + + uint64_t sampleTime; if (err == OK) { err = mSampleTable->getMetaDataForSample( sampleIndex, NULL, NULL, &sampleTime); @@ -2118,7 +2161,7 @@ status_t MPEG4Source::read( off64_t offset; size_t size; - uint32_t cts; + uint64_t cts; bool isSyncSample; bool newBuffer = false; if (mBuffer == NULL) { @@ -2160,6 +2203,9 @@ status_t MPEG4Source::read( mBuffer->meta_data()->clear(); mBuffer->meta_data()->setInt64( kKeyTime, ((int64_t)cts * 1000000) / mTimescale); + if (isSeekMode) { //set video offset + mBuffer->meta_data()->setInt64(kKeyOffset, offset); + } if (targetSampleTimeUs >= 0) { mBuffer->meta_data()->setInt64( @@ -2296,6 +2342,9 @@ status_t MPEG4Source::read( mBuffer->meta_data()->clear(); mBuffer->meta_data()->setInt64( kKeyTime, ((int64_t)cts * 1000000) / mTimescale); + if (isSeekMode) { //set video offset + mBuffer->meta_data()->setInt64(kKeyOffset, offset); + } if (targetSampleTimeUs >= 0) { mBuffer->meta_data()->setInt64( diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp index e8b8b442268a1..a7b13f5de1825 100755 --- a/media/libstagefright/MPEG4Writer.cpp +++ b/media/libstagefright/MPEG4Writer.cpp @@ -226,11 +226,11 @@ class MPEG4Writer::Track { void writeDrefBox(); void writeDinfBox(); void writeDamrBox(); - void writeMdhdBox(int64_t now); + void writeMdhdBox(time_t now); void writeSmhdBox(); void writeVmhdBox(); void writeHdlrBox(); - void writeTkhdBox(int64_t now); + void writeTkhdBox(time_t now); void writeMp4aEsdsBox(); void writeMp4vEsdsBox(); void writeAudioFourCCBox(); @@ -714,14 +714,14 @@ status_t MPEG4Writer::stop() { } void MPEG4Writer::writeMvhdBox(int64_t durationUs) { - int64_t now = time(NULL) + kTimestampConversion; + time_t now = time(NULL); beginBox("mvhd"); - writeInt32(0x01000000); // version=1, flags=0 - writeInt64(now); // creation time - writeInt64(now); // modification time + writeInt32(0); // version=0, flags=0 + writeInt32(now); // creation time + writeInt32(now); // modification time writeInt32(mTimeScale); // mvhd timescale int32_t duration = (durationUs * mTimeScale + 5E5) / 1E6; - writeInt64(duration); + writeInt32(duration); writeInt32(0x10000); // rate: 1.0 writeInt16(0x100); // volume writeInt16(0); // reserved @@ -1843,7 +1843,7 @@ status_t MPEG4Writer::Track::threadEntry() { int32_t sampleCount = 1; // Sample count in the current stts table entry int64_t currCttsDurTicks = 0; // Timescale based ticks int64_t lastCttsDurTicks = 0; // Timescale based ticks - int32_t cttsSampleCount = 0; // Sample count in the current ctts table entry + int32_t cttsSampleCount = 1; // Sample count in the current ctts table entry uint32_t previousSampleSize = 0; // Size of the previous sample int64_t previousPausedDurationUs = 0; int64_t timestampUs = 0; @@ -2366,7 +2366,7 @@ void MPEG4Writer::Track::writeTrackHeader(bool use32BitOffset) { LOGV("%s track time scale: %d", mIsAudio? "Audio": "Video", mTimeScale); - int64_t now = time(NULL) + kTimestampConversion; + time_t now = time(NULL); mOwner->beginBox("trak"); writeTkhdBox(now); mOwner->beginBox("mdia"); @@ -2579,20 +2579,20 @@ void MPEG4Writer::Track::writeMp4vEsdsBox() { mOwner->endBox(); // esds } -void MPEG4Writer::Track::writeTkhdBox(int64_t now) { +void MPEG4Writer::Track::writeTkhdBox(time_t now) { mOwner->beginBox("tkhd"); // Flags = 7 to indicate that the track is enabled, and // part of the presentation - mOwner->writeInt32(0x01000007); // version=1, flags=7 - mOwner->writeInt64(now); // creation time - mOwner->writeInt64(now); // modification time + mOwner->writeInt32(0x07); // version=0, flags=7 + mOwner->writeInt32(now); // creation time + mOwner->writeInt32(now); // modification time mOwner->writeInt32(mTrackId + 1); // track id starts with 1 mOwner->writeInt32(0); // reserved int64_t trakDurationUs = getDurationUs(); int32_t mvhdTimeScale = mOwner->getTimeScale(); int32_t tkhdDuration = (trakDurationUs * mvhdTimeScale + 5E5) / 1E6; - mOwner->writeInt64(tkhdDuration); // in mvhd timescale + mOwner->writeInt32(tkhdDuration); // in mvhd timescale mOwner->writeInt32(0); // reserved mOwner->writeInt32(0); // reserved mOwner->writeInt16(0); // layer @@ -2648,15 +2648,15 @@ void MPEG4Writer::Track::writeHdlrBox() { mOwner->endBox(); } -void MPEG4Writer::Track::writeMdhdBox(int64_t now) { +void MPEG4Writer::Track::writeMdhdBox(time_t now) { int64_t trakDurationUs = getDurationUs(); mOwner->beginBox("mdhd"); - mOwner->writeInt32(0x01000000); // version=1, flags=0 - mOwner->writeInt64(now); // creation time - mOwner->writeInt64(now); // modification time + mOwner->writeInt32(0); // version=0, flags=0 + mOwner->writeInt32(now); // creation time + mOwner->writeInt32(now); // modification time mOwner->writeInt32(mTimeScale); // media timescale int32_t mdhdDuration = (trakDurationUs * mTimeScale + 5E5) / 1E6; - mOwner->writeInt64(mdhdDuration); // use media timescale + mOwner->writeInt32(mdhdDuration); // use media timescale // Language follows the three letter standard ISO-639-2/T // 'e', 'n', 'g' for "English", for instance. // Each character is packed as the difference between its ASCII value and 0x60. @@ -2774,7 +2774,7 @@ void MPEG4Writer::Track::writeCttsBox() { mOwner->beginBox("ctts"); if (mHasNegativeCttsDeltaDuration) { - mOwner->writeInt32(0x01000000); // version=1 (1 byte), flags=0 (3 bytes) + mOwner->writeInt32(0x00010000); // version=1, flags=0 } else { mOwner->writeInt32(0); // version=0, flags=0 } @@ -2787,7 +2787,6 @@ void MPEG4Writer::Track::writeCttsBox() { mOwner->writeInt32(it->sampleDuration); totalCount += it->sampleCount; } - LOGV("totalCount = %lld, mNumSamples = %d", totalCount, mNumSamples); CHECK(totalCount == mNumSamples); mOwner->endBox(); // ctts } diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index 8947a0a3b946b..ae1e9dd0967ef 100644 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -670,7 +670,8 @@ sp OMXCodec::Create( sp softwareCodec; if (createEncoder) { - softwareCodec = InstantiateSoftwareEncoder(componentName, source, meta); + sp softwareCodec = + InstantiateSoftwareEncoder(componentName, source, meta); #ifdef WITH_QCOM_LPA } else { softwareCodec = InstantiateSoftwareDecoder(componentName, source); @@ -901,13 +902,6 @@ status_t OMXCodec::configureCodec(const sp &meta) { LOGE("Profile and/or level exceed the decoder's capabilities."); return ERROR_UNSUPPORTED; } - if(!strcmp(mComponentName, "OMX.google.h264.decoder") - && (profile != kAVCProfileBaseline)) { - LOGE("%s does not support profiles > kAVCProfileBaseline", mComponentName); - // The profile is unsupported by the decoder - return ERROR_UNSUPPORTED; - } - } else if (meta->findData(kKeyVorbisInfo, &type, &data, &size)) { addCodecSpecificData(data, size); @@ -1659,6 +1653,7 @@ status_t OMXCodec::setupH263EncoderParameters(const sp& meta) { h263type.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP; + h263type.nPFrames = setPFramesSpacing(iFramesInterval, frameRate); if (h263type.nPFrames == 0) { h263type.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI; } @@ -2902,7 +2897,7 @@ int64_t OMXCodec::retrieveDecodingTimeUs(bool isCodecSpecific) { } void OMXCodec::on_message(const omx_message &msg) { - if (mState == ERROR && !strncmp(mComponentName, "OMX.google.", 11)) { + if (mState == ERROR) { LOGW("Dropping OMX message - we're in ERROR state."); return; } @@ -4313,9 +4308,17 @@ status_t OMXCodec::waitForBufferFilled_l() { } status_t err = mBufferFilled.waitRelative(mLock, kBufferFilledEventTimeOutNs); if (err != OK) { - CODEC_LOGE("Timed out waiting for output buffers: %d/%d", - countBuffersWeOwn(mPortBuffers[kPortIndexInput]), - countBuffersWeOwn(mPortBuffers[kPortIndexOutput])); + if(countBuffersWeOwn(mPortBuffers[kPortIndexOutput]) > 0) { +// CODEC_LOGI("Warnning Timed out waiting for output buffers: %d/%d", +// countBuffersWeOwn(mPortBuffers[kPortIndexInput]), +// countBuffersWeOwn(mPortBuffers[kPortIndexOutput])); + return OK; + } + else { + CODEC_LOGE("Timed out waiting for output buffers: %d/%d", + countBuffersWeOwn(mPortBuffers[kPortIndexInput]), + countBuffersWeOwn(mPortBuffers[kPortIndexOutput])); + } } return err; }