├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── tcking
│ │ │ └── github
│ │ │ └── com
│ │ │ └── giraffeplayer
│ │ │ └── example
│ │ │ └── MainActivity.java
│ ├── test
│ │ └── java
│ │ │ └── tcking
│ │ │ └── github
│ │ │ └── com
│ │ │ └── giraffeplayer
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── tcking
│ │ └── github
│ │ └── com
│ │ └── giraffeplayer
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── ijkplayer-java
├── .gitignore
├── gradle.properties
├── src
│ ├── main
│ │ ├── jniLibs
│ │ │ ├── x86
│ │ │ │ ├── libijksdl.so
│ │ │ │ ├── libijkffmpeg.so
│ │ │ │ └── libijkplayer.so
│ │ │ ├── x86_64
│ │ │ │ ├── libijksdl.so
│ │ │ │ ├── libijkffmpeg.so
│ │ │ │ └── libijkplayer.so
│ │ │ ├── armeabi
│ │ │ │ ├── libijksdl.so
│ │ │ │ ├── libijkffmpeg.so
│ │ │ │ └── libijkplayer.so
│ │ │ ├── arm64-v8a
│ │ │ │ ├── libijksdl.so
│ │ │ │ ├── libijkffmpeg.so
│ │ │ │ └── libijkplayer.so
│ │ │ └── armeabi-v7a
│ │ │ │ ├── libijksdl.so
│ │ │ │ ├── libijkffmpeg.so
│ │ │ │ └── libijkplayer.so
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ ├── java
│ │ │ └── tv
│ │ │ │ └── danmaku
│ │ │ │ └── ijk
│ │ │ │ └── media
│ │ │ │ └── player
│ │ │ │ ├── ffmpeg
│ │ │ │ └── FFmpegApi.java
│ │ │ │ ├── pragma
│ │ │ │ ├── Pragma.java
│ │ │ │ └── DebugLog.java
│ │ │ │ ├── IjkLibLoader.java
│ │ │ │ ├── exceptions
│ │ │ │ └── IjkMediaException.java
│ │ │ │ ├── ISurfaceTextureHost.java
│ │ │ │ ├── MediaInfo.java
│ │ │ │ ├── misc
│ │ │ │ ├── IMediaFormat.java
│ │ │ │ ├── IMediaDataSource.java
│ │ │ │ ├── ITrackInfo.java
│ │ │ │ ├── AndroidMediaFormat.java
│ │ │ │ ├── IjkTrackInfo.java
│ │ │ │ ├── AndroidTrackInfo.java
│ │ │ │ └── IjkMediaFormat.java
│ │ │ │ ├── ISurfaceTextureHolder.java
│ │ │ │ ├── annotations
│ │ │ │ ├── AccessedByNative.java
│ │ │ │ └── CalledByNative.java
│ │ │ │ ├── TextureMediaPlayer.java
│ │ │ │ ├── AbstractMediaPlayer.java
│ │ │ │ ├── IMediaPlayer.java
│ │ │ │ ├── MediaPlayerProxy.java
│ │ │ │ ├── IjkMediaCodecInfo.java
│ │ │ │ └── AndroidMediaPlayer.java
│ │ ├── AndroidManifest.xml
│ │ ├── .settings
│ │ │ └── org.eclipse.jdt.core.prefs
│ │ ├── .classpath
│ │ ├── project.properties
│ │ └── .project
│ └── androidTest
│ │ └── java
│ │ └── tv
│ │ └── danmaku
│ │ └── ijk
│ │ └── media
│ │ └── player
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── giraffeplayer
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_stop_white_24dp.png
│ │ │ │ ├── ic_volume_up_white_36dp.png
│ │ │ │ ├── ic_brightness_6_white_36dp.png
│ │ │ │ ├── ic_chevron_left_white_36dp.png
│ │ │ │ ├── ic_fullscreen_white_24dp.png
│ │ │ │ ├── ic_play_arrow_white_24dp.png
│ │ │ │ ├── ic_volume_off_white_36dp.png
│ │ │ │ ├── ic_fullscreen_exit_white_24dp.png
│ │ │ │ ├── ic_fullscreen_exit_white_36dp.png
│ │ │ │ └── ic_play_circle_outline_white_36dp.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_stop_white_24dp.png
│ │ │ │ ├── ic_volume_up_white_36dp.png
│ │ │ │ ├── ic_brightness_6_white_36dp.png
│ │ │ │ ├── ic_chevron_left_white_36dp.png
│ │ │ │ ├── ic_fullscreen_white_24dp.png
│ │ │ │ ├── ic_play_arrow_white_24dp.png
│ │ │ │ ├── ic_volume_off_white_36dp.png
│ │ │ │ ├── ic_fullscreen_exit_white_24dp.png
│ │ │ │ ├── ic_fullscreen_exit_white_36dp.png
│ │ │ │ └── ic_play_circle_outline_white_36dp.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_stop_white_24dp.png
│ │ │ │ ├── ic_fullscreen_white_24dp.png
│ │ │ │ ├── ic_play_arrow_white_24dp.png
│ │ │ │ ├── ic_volume_off_white_36dp.png
│ │ │ │ ├── ic_volume_up_white_36dp.png
│ │ │ │ ├── ic_brightness_6_white_36dp.png
│ │ │ │ ├── ic_chevron_left_white_36dp.png
│ │ │ │ ├── ic_fullscreen_exit_white_24dp.png
│ │ │ │ ├── ic_fullscreen_exit_white_36dp.png
│ │ │ │ └── ic_play_circle_outline_white_36dp.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── ic_stop_white_24dp.png
│ │ │ │ ├── ic_fullscreen_white_24dp.png
│ │ │ │ ├── ic_play_arrow_white_24dp.png
│ │ │ │ ├── ic_volume_off_white_36dp.png
│ │ │ │ ├── ic_volume_up_white_36dp.png
│ │ │ │ ├── ic_brightness_6_white_36dp.png
│ │ │ │ ├── ic_chevron_left_white_36dp.png
│ │ │ │ ├── ic_fullscreen_exit_white_24dp.png
│ │ │ │ ├── ic_fullscreen_exit_white_36dp.png
│ │ │ │ └── ic_play_circle_outline_white_36dp.png
│ │ │ ├── drawable-xxxhdpi
│ │ │ │ ├── ic_stop_white_24dp.png
│ │ │ │ ├── ic_volume_up_white_36dp.png
│ │ │ │ ├── ic_fullscreen_white_24dp.png
│ │ │ │ ├── ic_play_arrow_white_24dp.png
│ │ │ │ ├── ic_volume_off_white_36dp.png
│ │ │ │ ├── ic_brightness_6_white_36dp.png
│ │ │ │ ├── ic_chevron_left_white_36dp.png
│ │ │ │ ├── ic_fullscreen_exit_white_24dp.png
│ │ │ │ ├── ic_fullscreen_exit_white_36dp.png
│ │ │ │ └── ic_play_circle_outline_white_36dp.png
│ │ │ ├── drawable
│ │ │ │ └── app_video_center_bg.xml
│ │ │ ├── values-ch
│ │ │ │ └── strings.xml
│ │ │ ├── values-es
│ │ │ │ └── strings.xml
│ │ │ ├── values-ro
│ │ │ │ └── strings.xml
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ └── color.xml
│ │ │ └── layout
│ │ │ │ └── giraffe_player.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── tcking
│ │ │ └── github
│ │ │ └── com
│ │ │ └── giraffeplayer
│ │ │ ├── IMediaController.java
│ │ │ ├── IRenderView.java
│ │ │ ├── GiraffePlayerActivity.java
│ │ │ ├── SurfaceRenderView.java
│ │ │ ├── TextureRenderView.java
│ │ │ └── MeasureHelper.java
│ ├── test
│ │ └── java
│ │ │ └── tcking
│ │ │ └── github
│ │ │ └── com
│ │ │ └── giraffeplayer
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── tcking
│ │ └── github
│ │ └── com
│ │ └── giraffeplayer
│ │ └── ApplicationTest.java
├── build.gradle
└── proguard-rules.pro
├── screencap
├── device-2015-10-28-142934.png
├── device-2015-10-28-143207.png
├── device-2015-10-28-143304.png
├── device-2015-10-28-143343.png
└── device-2015-10-28-143722.png
├── .idea
└── runConfigurations.xml
├── gradle.properties
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ijkplayer-java/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':giraffeplayer', ':ijkplayer-java'
2 |
--------------------------------------------------------------------------------
/ijkplayer-java/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=ijkplayer-java
2 | POM_ARTIFACT_ID=ijkplayer-java
3 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 | **/*.iml
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GiraffePlayerExample
3 |
4 |
--------------------------------------------------------------------------------
/giraffeplayer/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/screencap/device-2015-10-28-142934.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/screencap/device-2015-10-28-142934.png
--------------------------------------------------------------------------------
/screencap/device-2015-10-28-143207.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/screencap/device-2015-10-28-143207.png
--------------------------------------------------------------------------------
/screencap/device-2015-10-28-143304.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/screencap/device-2015-10-28-143304.png
--------------------------------------------------------------------------------
/screencap/device-2015-10-28-143343.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/screencap/device-2015-10-28-143343.png
--------------------------------------------------------------------------------
/screencap/device-2015-10-28-143722.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/screencap/device-2015-10-28-143722.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/x86/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/x86/libijksdl.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/x86/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/x86/libijkffmpeg.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/x86/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/x86/libijkplayer.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/x86_64/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/x86_64/libijksdl.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/armeabi/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/armeabi/libijksdl.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/arm64-v8a/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/arm64-v8a/libijksdl.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/armeabi-v7a/libijksdl.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/armeabi-v7a/libijksdl.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/armeabi/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/armeabi/libijkffmpeg.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/armeabi/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/armeabi/libijkplayer.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/x86_64/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/x86_64/libijkffmpeg.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/x86_64/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/x86_64/libijkplayer.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/arm64-v8a/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/arm64-v8a/libijkffmpeg.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/arm64-v8a/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/arm64-v8a/libijkplayer.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/armeabi-v7a/libijkffmpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/armeabi-v7a/libijkffmpeg.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/jniLibs/armeabi-v7a/libijkplayer.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/ijkplayer-java/src/main/jniLibs/armeabi-v7a/libijkplayer.so
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-hdpi/ic_stop_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-hdpi/ic_stop_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-mdpi/ic_stop_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-mdpi/ic_stop_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xhdpi/ic_stop_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xhdpi/ic_stop_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxhdpi/ic_stop_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxhdpi/ic_stop_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_stop_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_stop_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-hdpi/ic_volume_up_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-hdpi/ic_volume_up_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-mdpi/ic_volume_up_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-mdpi/ic_volume_up_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-hdpi/ic_brightness_6_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-hdpi/ic_brightness_6_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-hdpi/ic_chevron_left_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-hdpi/ic_chevron_left_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-hdpi/ic_fullscreen_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-hdpi/ic_fullscreen_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-hdpi/ic_play_arrow_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-hdpi/ic_play_arrow_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-hdpi/ic_volume_off_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-hdpi/ic_volume_off_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-mdpi/ic_brightness_6_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-mdpi/ic_brightness_6_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-mdpi/ic_chevron_left_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-mdpi/ic_chevron_left_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-mdpi/ic_fullscreen_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-mdpi/ic_fullscreen_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-mdpi/ic_play_arrow_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-mdpi/ic_play_arrow_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-mdpi/ic_volume_off_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-mdpi/ic_volume_off_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xhdpi/ic_fullscreen_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xhdpi/ic_fullscreen_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xhdpi/ic_play_arrow_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xhdpi/ic_play_arrow_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xhdpi/ic_volume_off_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xhdpi/ic_volume_off_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xhdpi/ic_volume_up_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xhdpi/ic_volume_up_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxhdpi/ic_fullscreen_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxhdpi/ic_fullscreen_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxhdpi/ic_play_arrow_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxhdpi/ic_play_arrow_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxhdpi/ic_volume_off_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxhdpi/ic_volume_off_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxhdpi/ic_volume_up_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxhdpi/ic_volume_up_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_volume_up_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_volume_up_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xhdpi/ic_brightness_6_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xhdpi/ic_brightness_6_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xhdpi/ic_chevron_left_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xhdpi/ic_chevron_left_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxhdpi/ic_brightness_6_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxhdpi/ic_brightness_6_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxhdpi/ic_chevron_left_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxhdpi/ic_chevron_left_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_fullscreen_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_fullscreen_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_play_arrow_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_play_arrow_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_volume_off_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_volume_off_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-hdpi/ic_fullscreen_exit_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-hdpi/ic_fullscreen_exit_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-hdpi/ic_fullscreen_exit_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-hdpi/ic_fullscreen_exit_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-mdpi/ic_fullscreen_exit_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-mdpi/ic_fullscreen_exit_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-mdpi/ic_fullscreen_exit_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-mdpi/ic_fullscreen_exit_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xhdpi/ic_fullscreen_exit_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xhdpi/ic_fullscreen_exit_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xhdpi/ic_fullscreen_exit_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xhdpi/ic_fullscreen_exit_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxhdpi/ic_fullscreen_exit_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxhdpi/ic_fullscreen_exit_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxhdpi/ic_fullscreen_exit_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxhdpi/ic_fullscreen_exit_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_brightness_6_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_brightness_6_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_chevron_left_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_chevron_left_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-hdpi/ic_play_circle_outline_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-hdpi/ic_play_circle_outline_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-mdpi/ic_play_circle_outline_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-mdpi/ic_play_circle_outline_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_fullscreen_exit_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_fullscreen_exit_white_24dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_fullscreen_exit_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_fullscreen_exit_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xhdpi/ic_play_circle_outline_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xhdpi/ic_play_circle_outline_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxhdpi/ic_play_circle_outline_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxhdpi/ic_play_circle_outline_white_36dp.png
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_play_circle_outline_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RDFS/GiraffePlayer/master/giraffeplayer/src/main/res/drawable-xxxhdpi/ic_play_circle_outline_white_36dp.png
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/ffmpeg/FFmpegApi.java:
--------------------------------------------------------------------------------
1 | package tv.danmaku.ijk.media.player.ffmpeg;
2 |
3 | public class FFmpegApi {
4 | public static native String av_base64_encode(byte in[]);
5 | }
6 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Feb 17 09:33:21 CST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/drawable/app_video_center_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/values-ch/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GiraffePlayer
3 | 请指定播放视频的地址
4 | 发送了点小问题,稍后重试
5 | 不能播放此视频
6 | 播放器不支持此设备
7 |
8 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/values-es/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GiraffePlayer
3 | Porfavor introduce la direccion de streaming
4 | El Player tiene una problema
5 | player not support this device
6 |
7 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/values-ro/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GiraffePlayer
3 | Please specify the address of the video playback
4 | Player encountered a small problem
5 | player not support this device
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/test/java/tcking/github/com/giraffeplayer/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package tcking.github.com.giraffeplayer;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GiraffePlayer
3 | Please specify the address of the video playback
4 | Player encountered a small problem
5 | can not play this video
6 | player not support this device
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/giraffeplayer/src/test/java/tcking/github/com/giraffeplayer/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package tcking.github.com.giraffeplayer;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/tcking/github/com/giraffeplayer/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package tcking.github.com.giraffeplayer;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/ijkplayer-java/src/androidTest/java/tv/danmaku/ijk/media/player/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package tv.danmaku.ijk.media.player;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/giraffeplayer/src/androidTest/java/tcking/github/com/giraffeplayer/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package tcking.github.com.giraffeplayer;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #FAFAFA
5 | #F5F5F5
6 | #EEEEEE
7 | #E0E0E0
8 | #BDBDBD
9 | #9E9E9E
10 | #757575
11 | #616161
12 | #424242
13 | #212121
14 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-22
15 | android.library=true
16 |
--------------------------------------------------------------------------------
/ijkplayer-java/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /opt/android/ADK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/tangchao/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/giraffeplayer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 |
4 | android {
5 | compileSdkVersion 23
6 | buildToolsVersion "23.0.1"
7 |
8 | defaultConfig {
9 | minSdkVersion 10
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.1.0'
26 | compile project(':ijkplayer-java')
27 | }
28 |
--------------------------------------------------------------------------------
/giraffeplayer/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/tangchao/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
13 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "tcking.github.com.giraffeplayer"
9 | minSdkVersion 10
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | ndk {
15 | abiFilters "armeabi","armeabi-v7a","arm64-v8a","x86","x86_64"
16 | }
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | compile 'com.android.support:appcompat-v7:23.2.1'
29 | compile project(':giraffeplayer')
30 |
31 | testCompile 'junit:junit:4.12'
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/pragma/Pragma.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package tv.danmaku.ijk.media.player.pragma;
17 |
18 | /*-
19 | * configurated by app project
20 | */
21 | public class Pragma {
22 | public static final boolean ENABLE_VERBOSE = true;
23 | }
24 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/IjkLibLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | public interface IjkLibLoader {
20 | void loadLibrary(String libName) throws UnsatisfiedLinkError,
21 | SecurityException;
22 | }
23 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/exceptions/IjkMediaException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.exceptions;
18 |
19 | public class IjkMediaException extends Exception {
20 | private static final long serialVersionUID = 7234796519009099506L;
21 | }
22 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 | android.useDeprecatedNdk=true
20 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/ISurfaceTextureHost.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.graphics.SurfaceTexture;
20 |
21 | public interface ISurfaceTextureHost {
22 | void releaseSurfaceTexture(SurfaceTexture surfaceTexture);
23 | }
24 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ijkplayer-java
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/MediaInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | public class MediaInfo {
20 | public String mMediaPlayerName;
21 |
22 | public String mVideoDecoder;
23 | public String mVideoDecoderImpl;
24 |
25 | public String mAudioDecoder;
26 | public String mAudioDecoderImpl;
27 |
28 | public IjkMediaMeta mMeta;
29 | }
30 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/IMediaFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | public interface IMediaFormat {
20 | // Common keys
21 | String KEY_MIME = "mime";
22 |
23 | // Video Keys
24 | String KEY_WIDTH = "width";
25 | String KEY_HEIGHT = "height";
26 |
27 | String getString(String name);
28 |
29 | int getInteger(String name);
30 | }
31 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/ISurfaceTextureHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.graphics.SurfaceTexture;
20 |
21 | public interface ISurfaceTextureHolder {
22 | void setSurfaceTexture(SurfaceTexture surfaceTexture);
23 |
24 | SurfaceTexture getSurfaceTexture();
25 |
26 | void setSurfaceTextureHost(ISurfaceTextureHost surfaceTextureHost);
27 | }
28 |
--------------------------------------------------------------------------------
/ijkplayer-java/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | // http://tools.android.com/tech-docs/new-build-system/tips
5 | //noinspection GroovyAssignabilityCheck
6 | compileSdkVersion rootProject.ext.compileSdkVersion
7 | //noinspection GroovyAssignabilityCheck
8 | buildToolsVersion rootProject.ext.buildToolsVersion
9 |
10 | defaultConfig {
11 | minSdkVersion 9
12 | targetSdkVersion rootProject.ext.targetSdkVersion
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | }
25 |
26 | ext {
27 | optionalPlugins = ['tools/gradle-mvn-push.gradle', 'tools/gradle-bintray-upload.gradle'];
28 | }
29 |
30 | ext.optionalPlugins.each{ value ->
31 | def plugin_file = new File(rootProject.projectDir, value);
32 | if (plugin_file.exists()) {
33 | apply from: plugin_file
34 | }
35 | }
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/IMediaDataSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import java.io.IOException;
20 |
21 | @SuppressWarnings("RedundantThrows")
22 | public interface IMediaDataSource {
23 | int readAt(long position, byte[] buffer, int offset, int size) throws IOException;
24 |
25 | long getSize() throws IOException;
26 |
27 | void close() throws IOException;
28 | }
29 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/ITrackInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | public interface ITrackInfo {
20 | int MEDIA_TRACK_TYPE_AUDIO = 2;
21 | int MEDIA_TRACK_TYPE_METADATA = 5;
22 | int MEDIA_TRACK_TYPE_SUBTITLE = 4;
23 | int MEDIA_TRACK_TYPE_TIMEDTEXT = 3;
24 | int MEDIA_TRACK_TYPE_UNKNOWN = 0;
25 | int MEDIA_TRACK_TYPE_VIDEO = 1;
26 |
27 | IMediaFormat getFormat();
28 |
29 | String getLanguage();
30 |
31 | int getTrackType();
32 |
33 | String getInfoInline();
34 | }
35 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/annotations/AccessedByNative.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * is used by the JNI generator to create the necessary JNI
26 | * bindings and expose this method to native code.
27 | */
28 | @Target(ElementType.FIELD)
29 | @Retention(RetentionPolicy.CLASS)
30 | public @interface AccessedByNative {
31 | }
--------------------------------------------------------------------------------
/giraffeplayer/src/main/java/tcking/github/com/giraffeplayer/IMediaController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tcking.github.com.giraffeplayer;
18 |
19 | import android.view.View;
20 | import android.widget.MediaController;
21 |
22 | public interface IMediaController {
23 | void hide();
24 |
25 | boolean isShowing();
26 |
27 | void setAnchorView(View view);
28 |
29 | void setEnabled(boolean enabled);
30 |
31 | void setMediaPlayer(MediaController.MediaPlayerControl player);
32 |
33 | void show(int timeout);
34 |
35 | void show();
36 |
37 | //----------
38 | // Extends
39 | //----------
40 | void showOnce(View view);
41 | }
42 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/annotations/CalledByNative.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * is used by the JNI generator to create the necessary JNI
26 | * bindings and expose this method to native code.
27 | */
28 | @Target(ElementType.METHOD)
29 | @Retention(RetentionPolicy.CLASS)
30 | public @interface CalledByNative {
31 | /*
32 | * If present, tells which inner class the method belongs to.
33 | */
34 | String value() default "";
35 | }
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/AndroidMediaFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import android.annotation.TargetApi;
20 | import android.media.MediaFormat;
21 | import android.os.Build;
22 |
23 | public class AndroidMediaFormat implements IMediaFormat {
24 | private final MediaFormat mMediaFormat;
25 |
26 | public AndroidMediaFormat(MediaFormat mediaFormat) {
27 | mMediaFormat = mediaFormat;
28 | }
29 |
30 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
31 | @Override
32 | public int getInteger(String name) {
33 | if (mMediaFormat == null)
34 | return 0;
35 |
36 | return mMediaFormat.getInteger(name);
37 | }
38 |
39 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
40 | @Override
41 | public String getString(String name) {
42 | if (mMediaFormat == null)
43 | return null;
44 |
45 | return mMediaFormat.getString(name);
46 | }
47 |
48 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
49 | @Override
50 | public String toString() {
51 | StringBuilder out = new StringBuilder(128);
52 | out.append(getClass().getName());
53 | out.append('{');
54 | if (mMediaFormat != null) {
55 | out.append(mMediaFormat.toString());
56 | } else {
57 | out.append("null");
58 | }
59 | out.append('}');
60 | return out.toString();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/java/tcking/github/com/giraffeplayer/IRenderView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tcking.github.com.giraffeplayer;
18 |
19 | import android.graphics.SurfaceTexture;
20 | import android.support.annotation.NonNull;
21 | import android.support.annotation.Nullable;
22 | import android.view.Surface;
23 | import android.view.SurfaceHolder;
24 | import android.view.View;
25 |
26 | import tv.danmaku.ijk.media.player.IMediaPlayer;
27 |
28 | public interface IRenderView {
29 | static final int AR_ASPECT_FIT_PARENT = 0; // without clip
30 | static final int AR_ASPECT_FILL_PARENT = 1; // may clip
31 | static final int AR_ASPECT_WRAP_CONTENT = 2;
32 | static final int AR_MATCH_PARENT = 3;
33 | static final int AR_16_9_FIT_PARENT = 4;
34 | static final int AR_4_3_FIT_PARENT = 5;
35 |
36 | View getView();
37 |
38 | boolean shouldWaitForResize();
39 |
40 | void setVideoSize(int videoWidth, int videoHeight);
41 |
42 | void setVideoSampleAspectRatio(int videoSarNum, int videoSarDen);
43 |
44 | void setVideoRotation(int degree);
45 |
46 | void setAspectRatio(int aspectRatio);
47 |
48 | void addRenderCallback(@NonNull IRenderCallback callback);
49 |
50 | void removeRenderCallback(@NonNull IRenderCallback callback);
51 |
52 | interface ISurfaceHolder {
53 | void bindToMediaPlayer(IMediaPlayer mp);
54 |
55 | @NonNull
56 | IRenderView getRenderView();
57 |
58 | @Nullable
59 | SurfaceHolder getSurfaceHolder();
60 |
61 | @Nullable
62 | Surface openSurface();
63 |
64 | @Nullable
65 | SurfaceTexture getSurfaceTexture();
66 | }
67 |
68 | public interface IRenderCallback {
69 | /**
70 | * @param holder
71 | * @param width could be 0
72 | * @param height could be 0
73 | */
74 | void onSurfaceCreated(@NonNull ISurfaceHolder holder, int width, int height);
75 |
76 | /**
77 | * @param holder
78 | * @param format could be 0
79 | * @param width
80 | * @param height
81 | */
82 | void onSurfaceChanged(@NonNull ISurfaceHolder holder, int format, int width, int height);
83 |
84 | void onSurfaceDestroyed(@NonNull ISurfaceHolder holder);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/TextureMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.annotation.TargetApi;
20 | import android.graphics.SurfaceTexture;
21 | import android.os.Build;
22 | import android.view.Surface;
23 | import android.view.SurfaceHolder;
24 |
25 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
26 | public class TextureMediaPlayer extends MediaPlayerProxy implements IMediaPlayer, ISurfaceTextureHolder {
27 | private SurfaceTexture mSurfaceTexture;
28 | private ISurfaceTextureHost mSurfaceTextureHost;
29 |
30 | public TextureMediaPlayer(IMediaPlayer backEndMediaPlayer) {
31 | super(backEndMediaPlayer);
32 | }
33 |
34 | public void releaseSurfaceTexture() {
35 | if (mSurfaceTexture != null) {
36 | if (mSurfaceTextureHost != null) {
37 | mSurfaceTextureHost.releaseSurfaceTexture(mSurfaceTexture);
38 | } else {
39 | mSurfaceTexture.release();
40 | }
41 | mSurfaceTexture = null;
42 | }
43 | }
44 |
45 | //--------------------
46 | // IMediaPlayer
47 | //--------------------
48 | @Override
49 | public void reset() {
50 | super.reset();
51 | releaseSurfaceTexture();
52 | }
53 |
54 | @Override
55 | public void release() {
56 | super.release();
57 | releaseSurfaceTexture();
58 | }
59 |
60 | @Override
61 | public void setDisplay(SurfaceHolder sh) {
62 | if (mSurfaceTexture == null)
63 | super.setDisplay(sh);
64 | }
65 |
66 | @Override
67 | public void setSurface(Surface surface) {
68 | if (mSurfaceTexture == null)
69 | super.setSurface(surface);
70 | }
71 |
72 | //--------------------
73 | // ISurfaceTextureHolder
74 | //--------------------
75 |
76 | @Override
77 | public void setSurfaceTexture(SurfaceTexture surfaceTexture) {
78 | if (mSurfaceTexture == surfaceTexture)
79 | return;
80 |
81 | releaseSurfaceTexture();
82 | mSurfaceTexture = surfaceTexture;
83 | if (surfaceTexture == null) {
84 | super.setSurface(null);
85 | } else {
86 | super.setSurface(new Surface(surfaceTexture));
87 | }
88 | }
89 |
90 | @Override
91 | public SurfaceTexture getSurfaceTexture() {
92 | return mSurfaceTexture;
93 | }
94 |
95 | @Override
96 | public void setSurfaceTextureHost(ISurfaceTextureHost surfaceTextureHost) {
97 | mSurfaceTextureHost = surfaceTextureHost;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/IjkTrackInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import android.text.TextUtils;
20 |
21 | import tv.danmaku.ijk.media.player.IjkMediaMeta;
22 |
23 | public class IjkTrackInfo implements ITrackInfo {
24 | private int mTrackType = MEDIA_TRACK_TYPE_UNKNOWN;
25 | private IjkMediaMeta.IjkStreamMeta mStreamMeta;
26 |
27 | public IjkTrackInfo(IjkMediaMeta.IjkStreamMeta streamMeta) {
28 | mStreamMeta = streamMeta;
29 | }
30 |
31 | public void setMediaMeta(IjkMediaMeta.IjkStreamMeta streamMeta) {
32 | mStreamMeta = streamMeta;
33 | }
34 |
35 | @Override
36 | public IMediaFormat getFormat() {
37 | return new IjkMediaFormat(mStreamMeta);
38 | }
39 |
40 | @Override
41 | public String getLanguage() {
42 | if (mStreamMeta == null || TextUtils.isEmpty(mStreamMeta.mLanguage))
43 | return "und";
44 |
45 | return mStreamMeta.mLanguage;
46 | }
47 |
48 | @Override
49 | public int getTrackType() {
50 | return mTrackType;
51 | }
52 |
53 | public void setTrackType(int trackType) {
54 | mTrackType = trackType;
55 | }
56 |
57 | @Override
58 | public String toString() {
59 | return getClass().getSimpleName() + '{' + getInfoInline() + "}";
60 | }
61 |
62 | @Override
63 | public String getInfoInline() {
64 | StringBuilder out = new StringBuilder(128);
65 | switch (mTrackType) {
66 | case MEDIA_TRACK_TYPE_VIDEO:
67 | out.append("VIDEO");
68 | out.append(", ");
69 | out.append(mStreamMeta.getCodecShortNameInline());
70 | out.append(", ");
71 | out.append(mStreamMeta.getBitrateInline());
72 | out.append(", ");
73 | out.append(mStreamMeta.getResolutionInline());
74 | break;
75 | case MEDIA_TRACK_TYPE_AUDIO:
76 | out.append("AUDIO");
77 | out.append(", ");
78 | out.append(mStreamMeta.getCodecShortNameInline());
79 | out.append(", ");
80 | out.append(mStreamMeta.getBitrateInline());
81 | out.append(", ");
82 | out.append(mStreamMeta.getSampleRateInline());
83 | break;
84 | case MEDIA_TRACK_TYPE_TIMEDTEXT:
85 | out.append("TIMEDTEXT");
86 | break;
87 | case MEDIA_TRACK_TYPE_SUBTITLE:
88 | out.append("SUBTITLE");
89 | break;
90 | default:
91 | out.append("UNKNOWN");
92 | break;
93 | }
94 | return out.toString();
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GiraffePlayer
2 | out of the box android video player base on [ijkplayer](https://github.com/Bilibili/ijkplayer)
3 |
4 | # features
5 | 1. base on ijkplayer,support RTMP , HLS (http & https) , MP4,M4A etc.
6 | 2. gestures for volume control
7 | 3. gestures for brightness control
8 | 4. gestures for forward or backward
9 | 5. fullscreen by manual or sensor
10 | 6. try to replay when error(only for live video)
11 | 7. set video scale type (double click video will switch the scale types in app,you can find the difference)
12 | 1. fitParent:可能会剪裁,保持原视频的大小,显示在中心,当原视频的大小超过view的大小超过部分裁剪处理
13 | 2. fillParent:可能会剪裁,等比例放大视频,直到填满View为止,超过View的部分作裁剪处理
14 | 3. wrapContent:将视频的内容完整居中显示,如果视频大于view,则按比例缩视频直到完全显示在view中
15 | 4. fitXY:不剪裁,非等比例拉伸画面填满整个View
16 | 5. 16:9:不剪裁,非等比例拉伸画面到16:9,并完全显示在View中
17 | 6. 4:3:不剪裁,非等比例拉伸画面到4:3,并完全显示在View中
18 |
19 | # how to import library
20 | 1. git clone https://github.com/tcking/GiraffePlayer.git
21 | 2. android studio->file->New->Import module->select `giraffeplayer`
22 |
23 | ## notice:
24 | the player default support 6 CPU architecture:ARMv5, ARMv7, ARMv8,x86 and 86_64,if your project need't support all of the architectures,you can remove the folder in `ijkplayer-java/src/main/jniLibs` to generate a light APK.
25 | read this first:[How to use 32-bit native libaries on 64-bit Android device](http://stackoverflow.com/questions/30782848/how-to-use-32-bit-native-libaries-on-64-bit-android-device),[What you should know about .so files](http://ph0b.com/android-abis-and-so-files/),[关于Android的.so文件你所需要知道的](http://www.jianshu.com/p/cb05698a1968)
26 |
27 | # How to use ([example code](https://github.com/tcking/GiraffePlayer/blob/master/app/src/main/java/tcking/github/com/giraffeplayer/example/MainActivity.java))
28 | ## case 1: only what to play a vedio fullscreen
29 | just call`GiraffePlayerActivity.configPlayer(activity).play(url)`,all is done.
30 |
31 | ## case 2: embed a player in a layout
32 | ### step 1: include video layout in your layout xml file
33 | ``` xml
34 |
35 |
39 |
40 | ```
41 | notice:the giraffe player is match_parent default,if you want to specify `height` or `width` you can overwrite `layout_width` and `layout_width` in `include` tag
42 |
43 | ### step 2: new player and call `play`
44 | ``` java
45 |
46 | GiraffePlayer player = new GiraffePlayer(activity);
47 | player.play(url);
48 |
49 | ```
50 |
51 | # API:
52 | * `play(url)` //play video
53 | * `stop()` //stop play
54 | * `pause()`
55 | * `start()`
56 | * `forward()` // forward or back,example: forward(0.1f) forward(-0.1f)
57 | * `getCurrentPosition()`
58 | * `setScaleType()`
59 | * `toggleAspectRatio()`
60 | * `seekTo()` //seek to specify position
61 | * `getDuration()` //get video duration
62 | * `onInfo()` //callback when have some information
63 | * `onError()`
64 | * `onComplete()`
65 | * `onControlPanelVisibilityChange()` //callback when control panel visibility change
66 | # screencap
67 |
68 | 
69 | 
70 | 
71 | 
72 | 
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/AndroidTrackInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import android.annotation.TargetApi;
20 | import android.media.MediaFormat;
21 | import android.media.MediaPlayer;
22 | import android.os.Build;
23 |
24 | public class AndroidTrackInfo implements ITrackInfo {
25 | private final MediaPlayer.TrackInfo mTrackInfo;
26 |
27 | public static AndroidTrackInfo[] fromMediaPlayer(MediaPlayer mp) {
28 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
29 | return fromTrackInfo(mp.getTrackInfo());
30 |
31 | return null;
32 | }
33 |
34 | private static AndroidTrackInfo[] fromTrackInfo(MediaPlayer.TrackInfo[] trackInfos) {
35 | if (trackInfos == null)
36 | return null;
37 |
38 | AndroidTrackInfo androidTrackInfo[] = new AndroidTrackInfo[trackInfos.length];
39 | for (int i = 0; i < trackInfos.length; ++i) {
40 | androidTrackInfo[i] = new AndroidTrackInfo(trackInfos[i]);
41 | }
42 |
43 | return androidTrackInfo;
44 | }
45 |
46 | private AndroidTrackInfo(MediaPlayer.TrackInfo trackInfo) {
47 | mTrackInfo = trackInfo;
48 | }
49 |
50 | @TargetApi(Build.VERSION_CODES.KITKAT)
51 | @Override
52 | public IMediaFormat getFormat() {
53 | if (mTrackInfo == null)
54 | return null;
55 |
56 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
57 | return null;
58 |
59 | MediaFormat mediaFormat = mTrackInfo.getFormat();
60 | if (mediaFormat == null)
61 | return null;
62 |
63 | return new AndroidMediaFormat(mediaFormat);
64 | }
65 |
66 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
67 | @Override
68 | public String getLanguage() {
69 | if (mTrackInfo == null)
70 | return "und";
71 |
72 | return mTrackInfo.getLanguage();
73 | }
74 |
75 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
76 | @Override
77 | public int getTrackType() {
78 | if (mTrackInfo == null)
79 | return MEDIA_TRACK_TYPE_UNKNOWN;
80 |
81 | return mTrackInfo.getTrackType();
82 | }
83 |
84 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
85 | @Override
86 | public String toString() {
87 | StringBuilder out = new StringBuilder(128);
88 | out.append(getClass().getSimpleName());
89 | out.append('{');
90 | if (mTrackInfo != null) {
91 | out.append(mTrackInfo.toString());
92 | } else {
93 | out.append("null");
94 | }
95 | out.append('}');
96 | return out.toString();
97 | }
98 |
99 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
100 | @Override
101 | public String getInfoInline() {
102 | if (mTrackInfo != null) {
103 | return mTrackInfo.toString();
104 | } else {
105 | return "null";
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/AbstractMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import tv.danmaku.ijk.media.player.misc.IMediaDataSource;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public abstract class AbstractMediaPlayer implements IMediaPlayer {
23 | private OnPreparedListener mOnPreparedListener;
24 | private OnCompletionListener mOnCompletionListener;
25 | private OnBufferingUpdateListener mOnBufferingUpdateListener;
26 | private OnSeekCompleteListener mOnSeekCompleteListener;
27 | private OnVideoSizeChangedListener mOnVideoSizeChangedListener;
28 | private OnErrorListener mOnErrorListener;
29 | private OnInfoListener mOnInfoListener;
30 |
31 | public final void setOnPreparedListener(OnPreparedListener listener) {
32 | mOnPreparedListener = listener;
33 | }
34 |
35 | public final void setOnCompletionListener(OnCompletionListener listener) {
36 | mOnCompletionListener = listener;
37 | }
38 |
39 | public final void setOnBufferingUpdateListener(
40 | OnBufferingUpdateListener listener) {
41 | mOnBufferingUpdateListener = listener;
42 | }
43 |
44 | public final void setOnSeekCompleteListener(OnSeekCompleteListener listener) {
45 | mOnSeekCompleteListener = listener;
46 | }
47 |
48 | public final void setOnVideoSizeChangedListener(
49 | OnVideoSizeChangedListener listener) {
50 | mOnVideoSizeChangedListener = listener;
51 | }
52 |
53 | public final void setOnErrorListener(OnErrorListener listener) {
54 | mOnErrorListener = listener;
55 | }
56 |
57 | public final void setOnInfoListener(OnInfoListener listener) {
58 | mOnInfoListener = listener;
59 | }
60 |
61 | public void resetListeners() {
62 | mOnPreparedListener = null;
63 | mOnBufferingUpdateListener = null;
64 | mOnCompletionListener = null;
65 | mOnSeekCompleteListener = null;
66 | mOnVideoSizeChangedListener = null;
67 | mOnErrorListener = null;
68 | mOnInfoListener = null;
69 | }
70 |
71 | protected final void notifyOnPrepared() {
72 | if (mOnPreparedListener != null)
73 | mOnPreparedListener.onPrepared(this);
74 | }
75 |
76 | protected final void notifyOnCompletion() {
77 | if (mOnCompletionListener != null)
78 | mOnCompletionListener.onCompletion(this);
79 | }
80 |
81 | protected final void notifyOnBufferingUpdate(int percent) {
82 | if (mOnBufferingUpdateListener != null)
83 | mOnBufferingUpdateListener.onBufferingUpdate(this, percent);
84 | }
85 |
86 | protected final void notifyOnSeekComplete() {
87 | if (mOnSeekCompleteListener != null)
88 | mOnSeekCompleteListener.onSeekComplete(this);
89 | }
90 |
91 | protected final void notifyOnVideoSizeChanged(int width, int height,
92 | int sarNum, int sarDen) {
93 | if (mOnVideoSizeChangedListener != null)
94 | mOnVideoSizeChangedListener.onVideoSizeChanged(this, width, height,
95 | sarNum, sarDen);
96 | }
97 |
98 | protected final boolean notifyOnError(int what, int extra) {
99 | return mOnErrorListener != null && mOnErrorListener.onError(this, what, extra);
100 | }
101 |
102 | protected final boolean notifyOnInfo(int what, int extra) {
103 | return mOnInfoListener != null && mOnInfoListener.onInfo(this, what, extra);
104 | }
105 |
106 | public void setDataSource(IMediaDataSource mediaDataSource) {
107 | throw new UnsupportedOperationException();
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/pragma/DebugLog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.pragma;
18 |
19 | import java.util.Locale;
20 |
21 |
22 | import android.util.Log;
23 |
24 | @SuppressWarnings({"SameParameterValue", "WeakerAccess"})
25 | public class DebugLog {
26 | public static final boolean ENABLE_ERROR = Pragma.ENABLE_VERBOSE;
27 | public static final boolean ENABLE_INFO = Pragma.ENABLE_VERBOSE;
28 | public static final boolean ENABLE_WARN = Pragma.ENABLE_VERBOSE;
29 | public static final boolean ENABLE_DEBUG = Pragma.ENABLE_VERBOSE;
30 | public static final boolean ENABLE_VERBOSE = Pragma.ENABLE_VERBOSE;
31 |
32 | public static void e(String tag, String msg) {
33 | if (ENABLE_ERROR) {
34 | Log.e(tag, msg);
35 | }
36 | }
37 |
38 | public static void e(String tag, String msg, Throwable tr) {
39 | if (ENABLE_ERROR) {
40 | Log.e(tag, msg, tr);
41 | }
42 | }
43 |
44 | public static void efmt(String tag, String fmt, Object... args) {
45 | if (ENABLE_ERROR) {
46 | String msg = String.format(Locale.US, fmt, args);
47 | Log.e(tag, msg);
48 | }
49 | }
50 |
51 | public static void i(String tag, String msg) {
52 | if (ENABLE_INFO) {
53 | Log.i(tag, msg);
54 | }
55 | }
56 |
57 | public static void i(String tag, String msg, Throwable tr) {
58 | if (ENABLE_INFO) {
59 | Log.i(tag, msg, tr);
60 | }
61 | }
62 |
63 | public static void ifmt(String tag, String fmt, Object... args) {
64 | if (ENABLE_INFO) {
65 | String msg = String.format(Locale.US, fmt, args);
66 | Log.i(tag, msg);
67 | }
68 | }
69 |
70 | public static void w(String tag, String msg) {
71 | if (ENABLE_WARN) {
72 | Log.w(tag, msg);
73 | }
74 | }
75 |
76 | public static void w(String tag, String msg, Throwable tr) {
77 | if (ENABLE_WARN) {
78 | Log.w(tag, msg, tr);
79 | }
80 | }
81 |
82 | public static void wfmt(String tag, String fmt, Object... args) {
83 | if (ENABLE_WARN) {
84 | String msg = String.format(Locale.US, fmt, args);
85 | Log.w(tag, msg);
86 | }
87 | }
88 |
89 | public static void d(String tag, String msg) {
90 | if (ENABLE_DEBUG) {
91 | Log.d(tag, msg);
92 | }
93 | }
94 |
95 | public static void d(String tag, String msg, Throwable tr) {
96 | if (ENABLE_DEBUG) {
97 | Log.d(tag, msg, tr);
98 | }
99 | }
100 |
101 | public static void dfmt(String tag, String fmt, Object... args) {
102 | if (ENABLE_DEBUG) {
103 | String msg = String.format(Locale.US, fmt, args);
104 | Log.d(tag, msg);
105 | }
106 | }
107 |
108 | public static void v(String tag, String msg) {
109 | if (ENABLE_VERBOSE) {
110 | Log.v(tag, msg);
111 | }
112 | }
113 |
114 | public static void v(String tag, String msg, Throwable tr) {
115 | if (ENABLE_VERBOSE) {
116 | Log.v(tag, msg, tr);
117 | }
118 | }
119 |
120 | public static void vfmt(String tag, String fmt, Object... args) {
121 | if (ENABLE_VERBOSE) {
122 | String msg = String.format(Locale.US, fmt, args);
123 | Log.v(tag, msg);
124 | }
125 | }
126 |
127 | public static void printStackTrace(Throwable e) {
128 | if (ENABLE_WARN) {
129 | e.printStackTrace();
130 | }
131 | }
132 |
133 | public static void printCause(Throwable e) {
134 | if (ENABLE_WARN) {
135 | Throwable cause = e.getCause();
136 | if (cause != null)
137 | e = cause;
138 |
139 | printStackTrace(e);
140 | }
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
18 |
22 |
26 |
30 |
31 |
41 |
42 |
49 |
50 |
51 |
54 |
59 |
64 |
69 |
70 |
71 |
72 |
75 |
80 |
85 |
90 |
91 |
92 |
93 |
98 |
103 |
108 |
109 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/java/tcking/github/com/giraffeplayer/GiraffePlayerActivity.java:
--------------------------------------------------------------------------------
1 | package tcking.github.com.giraffeplayer;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.content.res.Configuration;
6 | import android.os.Bundle;
7 | import android.os.Parcel;
8 | import android.os.Parcelable;
9 | import android.text.TextUtils;
10 | import android.view.KeyEvent;
11 | import android.view.Window;
12 | import android.widget.Toast;
13 |
14 | /**
15 | * Created by tcking on 15/10/27.
16 | */
17 | public class GiraffePlayerActivity extends Activity {
18 |
19 | GiraffePlayer player;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | requestWindowFeature(Window.FEATURE_NO_TITLE);
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.giraffe_player);
26 | Config config = getIntent().getParcelableExtra("config");
27 | if (config == null || TextUtils.isEmpty(config.url)) {
28 | Toast.makeText(this, R.string.giraffe_player_url_empty, Toast.LENGTH_SHORT).show();
29 | } else {
30 | player = new GiraffePlayer(this);
31 | player.setTitle(config.title);
32 | player.setDefaultRetryTime(config.defaultRetryTime);
33 | player.setFullScreenOnly(config.fullScreenOnly);
34 | player.setScaleType(TextUtils.isEmpty(config.scaleType) ? GiraffePlayer.SCALETYPE_FITPARENT : config.scaleType);
35 | player.setTitle(TextUtils.isEmpty(config.title) ? "" : config.title);
36 | player.setShowNavIcon(config.showNavIcon);
37 | player.play(config.url);
38 | }
39 | }
40 |
41 | @Override
42 | protected void onPause() {
43 | super.onPause();
44 | if (player != null) {
45 | player.onPause();
46 | }
47 | }
48 |
49 | @Override
50 | protected void onResume() {
51 | super.onResume();
52 | if (player != null) {
53 | player.onResume();
54 | }
55 | }
56 |
57 | @Override
58 | protected void onDestroy() {
59 | super.onDestroy();
60 | if (player != null) {
61 | player.onDestroy();
62 | }
63 | }
64 |
65 | @Override
66 | public void onConfigurationChanged(Configuration newConfig) {
67 | super.onConfigurationChanged(newConfig);
68 | if (player != null) {
69 | player.onConfigurationChanged(newConfig);
70 | }
71 | }
72 |
73 | /**
74 | * play video
75 | *
76 | * @param context
77 | * @param url url,title
78 | */
79 | public static void play(Activity context, String... url) {
80 | Intent intent = new Intent(context, GiraffePlayerActivity.class);
81 | intent.putExtra("url", url[0]);
82 | if (url.length > 1) {
83 | intent.putExtra("title", url[1]);
84 | }
85 | context.startActivity(intent);
86 | }
87 |
88 | public static Config configPlayer(Activity activity) {
89 | return new Config(activity);
90 | }
91 |
92 | public static class Config implements Parcelable {
93 |
94 | private Activity activity;
95 | private String scaleType;
96 | private boolean fullScreenOnly;
97 | private long defaultRetryTime = 5 * 1000;
98 | private String title;
99 | private String url;
100 | private boolean showNavIcon = true;
101 |
102 |
103 | public Config setTitle(String title) {
104 | this.title = title;
105 | return this;
106 | }
107 |
108 |
109 | public Config(Activity activity) {
110 | this.activity = activity;
111 | }
112 |
113 | public void play(String url) {
114 | this.url = url;
115 | Intent intent = new Intent(activity, GiraffePlayerActivity.class);
116 | intent.putExtra("config", this);
117 | activity.startActivity(intent);
118 | }
119 |
120 | public Config setDefaultRetryTime(long defaultRetryTime) {
121 | this.defaultRetryTime = defaultRetryTime;
122 | return this;
123 | }
124 |
125 | public Config setScaleType(String scaleType) {
126 | this.scaleType = scaleType;
127 | return this;
128 | }
129 |
130 | public Config setFullScreenOnly(boolean fullScreenOnly) {
131 | this.fullScreenOnly = fullScreenOnly;
132 | return this;
133 | }
134 |
135 | private Config(Parcel in) {
136 | scaleType = in.readString();
137 | fullScreenOnly = in.readByte() != 0;
138 | defaultRetryTime = in.readLong();
139 | title = in.readString();
140 | url = in.readString();
141 | showNavIcon = in.readByte() != 0;
142 | }
143 |
144 | @Override
145 | public int describeContents() {
146 | return 0;
147 | }
148 |
149 | @Override
150 | public void writeToParcel(Parcel dest, int flags) {
151 | dest.writeString(scaleType);
152 | dest.writeByte((byte) (fullScreenOnly ? 1 : 0));
153 | dest.writeLong(defaultRetryTime);
154 | dest.writeString(title);
155 | dest.writeString(url);
156 | dest.writeByte((byte) (showNavIcon ? 1 : 0));
157 | }
158 |
159 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
160 | public Config createFromParcel(Parcel in) {
161 | return new Config(in);
162 | }
163 |
164 | public Config[] newArray(int size) {
165 | return new Config[size];
166 | }
167 | };
168 | }
169 |
170 | @Override
171 | public void onBackPressed() {
172 | if (player != null && player.onBackPressed()) {
173 | return;
174 | }
175 | super.onBackPressed();
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/IMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013-2014 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.annotation.TargetApi;
20 | import android.content.Context;
21 | import android.net.Uri;
22 | import android.os.Build;
23 | import android.view.Surface;
24 | import android.view.SurfaceHolder;
25 |
26 | import java.io.FileDescriptor;
27 | import java.io.IOException;
28 | import java.util.Map;
29 |
30 | import tv.danmaku.ijk.media.player.misc.IMediaDataSource;
31 | import tv.danmaku.ijk.media.player.misc.ITrackInfo;
32 |
33 | public interface IMediaPlayer {
34 | /*
35 | * Do not change these values without updating their counterparts in native
36 | */
37 | int MEDIA_INFO_UNKNOWN = 1;
38 | int MEDIA_INFO_STARTED_AS_NEXT = 2;
39 | int MEDIA_INFO_VIDEO_RENDERING_START = 3;
40 | int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700;
41 | int MEDIA_INFO_BUFFERING_START = 701;
42 | int MEDIA_INFO_BUFFERING_END = 702;
43 | int MEDIA_INFO_NETWORK_BANDWIDTH = 703;
44 | int MEDIA_INFO_BAD_INTERLEAVING = 800;
45 | int MEDIA_INFO_NOT_SEEKABLE = 801;
46 | int MEDIA_INFO_METADATA_UPDATE = 802;
47 | int MEDIA_INFO_TIMED_TEXT_ERROR = 900;
48 | int MEDIA_INFO_UNSUPPORTED_SUBTITLE = 901;
49 | int MEDIA_INFO_SUBTITLE_TIMED_OUT = 902;
50 |
51 | int MEDIA_INFO_VIDEO_ROTATION_CHANGED = 10001;
52 | int MEDIA_INFO_AUDIO_RENDERING_START = 10002;
53 |
54 | int MEDIA_ERROR_UNKNOWN = 1;
55 | int MEDIA_ERROR_SERVER_DIED = 100;
56 | int MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200;
57 | int MEDIA_ERROR_IO = -1004;
58 | int MEDIA_ERROR_MALFORMED = -1007;
59 | int MEDIA_ERROR_UNSUPPORTED = -1010;
60 | int MEDIA_ERROR_TIMED_OUT = -110;
61 |
62 | void setDisplay(SurfaceHolder sh);
63 |
64 | void setDataSource(Context context, Uri uri)
65 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
66 |
67 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
68 | void setDataSource(Context context, Uri uri, Map headers)
69 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
70 |
71 | void setDataSource(FileDescriptor fd)
72 | throws IOException, IllegalArgumentException, IllegalStateException;
73 |
74 | void setDataSource(String path)
75 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
76 |
77 | String getDataSource();
78 |
79 | void prepareAsync() throws IllegalStateException;
80 |
81 | void start() throws IllegalStateException;
82 |
83 | void stop() throws IllegalStateException;
84 |
85 | void pause() throws IllegalStateException;
86 |
87 | void setScreenOnWhilePlaying(boolean screenOn);
88 |
89 | int getVideoWidth();
90 |
91 | int getVideoHeight();
92 |
93 | boolean isPlaying();
94 |
95 | void seekTo(long msec) throws IllegalStateException;
96 |
97 | long getCurrentPosition();
98 |
99 | long getDuration();
100 |
101 | void release();
102 |
103 | void reset();
104 |
105 | void setVolume(float leftVolume, float rightVolume);
106 |
107 | int getAudioSessionId();
108 |
109 | MediaInfo getMediaInfo();
110 |
111 | @SuppressWarnings("EmptyMethod")
112 | @Deprecated
113 | void setLogEnabled(boolean enable);
114 |
115 | @Deprecated
116 | boolean isPlayable();
117 |
118 | void setOnPreparedListener(OnPreparedListener listener);
119 |
120 | void setOnCompletionListener(OnCompletionListener listener);
121 |
122 | void setOnBufferingUpdateListener(
123 | OnBufferingUpdateListener listener);
124 |
125 | void setOnSeekCompleteListener(
126 | OnSeekCompleteListener listener);
127 |
128 | void setOnVideoSizeChangedListener(
129 | OnVideoSizeChangedListener listener);
130 |
131 | void setOnErrorListener(OnErrorListener listener);
132 |
133 | void setOnInfoListener(OnInfoListener listener);
134 |
135 | /*--------------------
136 | * Listeners
137 | */
138 | interface OnPreparedListener {
139 | void onPrepared(IMediaPlayer mp);
140 | }
141 |
142 | interface OnCompletionListener {
143 | void onCompletion(IMediaPlayer mp);
144 | }
145 |
146 | interface OnBufferingUpdateListener {
147 | void onBufferingUpdate(IMediaPlayer mp, int percent);
148 | }
149 |
150 | interface OnSeekCompleteListener {
151 | void onSeekComplete(IMediaPlayer mp);
152 | }
153 |
154 | interface OnVideoSizeChangedListener {
155 | void onVideoSizeChanged(IMediaPlayer mp, int width, int height,
156 | int sar_num, int sar_den);
157 | }
158 |
159 | interface OnErrorListener {
160 | boolean onError(IMediaPlayer mp, int what, int extra);
161 | }
162 |
163 | interface OnInfoListener {
164 | boolean onInfo(IMediaPlayer mp, int what, int extra);
165 | }
166 |
167 | /*--------------------
168 | * Optional
169 | */
170 | void setAudioStreamType(int streamtype);
171 |
172 | @Deprecated
173 | void setKeepInBackground(boolean keepInBackground);
174 |
175 | int getVideoSarNum();
176 |
177 | int getVideoSarDen();
178 |
179 | @Deprecated
180 | void setWakeMode(Context context, int mode);
181 |
182 | void setLooping(boolean looping);
183 |
184 | boolean isLooping();
185 |
186 | /*--------------------
187 | * AndroidMediaPlayer: JELLY_BEAN
188 | */
189 | ITrackInfo[] getTrackInfo();
190 |
191 | /*--------------------
192 | * AndroidMediaPlayer: ICE_CREAM_SANDWICH:
193 | */
194 | void setSurface(Surface surface);
195 |
196 | /*--------------------
197 | * AndroidMediaPlayer: M:
198 | */
199 | void setDataSource(IMediaDataSource mediaDataSource);
200 | }
201 |
--------------------------------------------------------------------------------
/app/src/main/java/tcking/github/com/giraffeplayer/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package tcking.github.com.giraffeplayer.example;
2 |
3 | import android.content.res.Configuration;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.text.format.Formatter;
7 | import android.view.View;
8 | import android.widget.EditText;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import tcking.github.com.giraffeplayer.GiraffePlayer;
13 | import tcking.github.com.giraffeplayer.GiraffePlayerActivity;
14 | import tv.danmaku.ijk.media.player.IMediaPlayer;
15 |
16 | public class MainActivity extends AppCompatActivity {
17 | GiraffePlayer player;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 | player = new GiraffePlayer(this);
24 | player.onComplete(new Runnable() {
25 | @Override
26 | public void run() {
27 | //callback when video is finish
28 | Toast.makeText(getApplicationContext(), "video play completed",Toast.LENGTH_SHORT).show();
29 | }
30 | }).onInfo(new GiraffePlayer.OnInfoListener() {
31 | @Override
32 | public void onInfo(int what, int extra) {
33 | switch (what) {
34 | case IMediaPlayer.MEDIA_INFO_BUFFERING_START:
35 | //do something when buffering start
36 | break;
37 | case IMediaPlayer.MEDIA_INFO_BUFFERING_END:
38 | //do something when buffering end
39 | break;
40 | case IMediaPlayer.MEDIA_INFO_NETWORK_BANDWIDTH:
41 | //download speed
42 | ((TextView) findViewById(R.id.tv_speed)).setText(Formatter.formatFileSize(getApplicationContext(),extra)+"/s");
43 | break;
44 | case IMediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START:
45 | //do something when video rendering
46 | findViewById(R.id.tv_speed).setVisibility(View.GONE);
47 | break;
48 | }
49 | }
50 | }).onError(new GiraffePlayer.OnErrorListener() {
51 | @Override
52 | public void onError(int what, int extra) {
53 | Toast.makeText(getApplicationContext(), "video play error",Toast.LENGTH_SHORT).show();
54 | }
55 | });
56 | View.OnClickListener clickListener = new View.OnClickListener() {
57 | @Override
58 | public void onClick(View v) {
59 | if (v.getId() == R.id.btn_play) {
60 | String url = ((EditText) findViewById(R.id.et_url)).getText().toString();
61 | player.play(url);
62 | player.setTitle(url);
63 | } else if (v.getId() == R.id.btn_play_sample_1) {
64 | String url = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
65 | ((EditText) findViewById(R.id.et_url)).setText(url);
66 | player.play(url);
67 | player.setTitle(url);
68 | } else if (v.getId() == R.id.btn_play_sample_2) {
69 | String url = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";
70 | ((EditText) findViewById(R.id.et_url)).setText(url);
71 | player.play(url);
72 | player.setTitle(url);
73 | player.setShowNavIcon(false);
74 | }else if (v.getId() == R.id.btn_play_sample_3) {
75 | String url = "https://r13---sn-o097znes.googlevideo.com/videoplayback?mt=1455852432&mv=m&ms=au&source=youtube&key=yt6&requiressl=yes&mm=31&mn=sn-o097znes&initcwndbps=16485000&id=o-AEGdeTbgSTzVGqwV2s8MjH5mlDPz3APWVwGfftr9GDqy&upn=D3A5w5WYU1k&lmt=1410665930307178&ip=2600:3c01::f03c:91ff:fe70:35ff&sparams=dur,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,nh,pl,ratebypass,requiressl,source,upn,expire&fexp=9416126,9420452,9422596,9423341,9423661,9423662,9424038,9424862,9425077,9425730,9426472,9426698,9427379,9428544,9428649,9429218,9429237,9429435,9429589&pl=32&dur=106.370&sver=3&expire=1455874197&nh=IgpwcjAxLnNqYzA3KgkxMjcuMC4wLjE&ratebypass=yes&mime=video/mp4&itag=18&signature=22C4633FCD1259D5F6CD1E0B54AB649982895534.378BAAC5AFAAEA737246C5CE5B92212E40B765BD&ipbits=0";
76 | ((EditText) findViewById(R.id.et_url)).setText(url);
77 | player.play(url);
78 | player.setTitle(url);
79 | player.setShowNavIcon(false);
80 | }else if (v.getId() == R.id.btn_open) {
81 | String url = ((EditText) findViewById(R.id.et_url)).getText().toString();
82 | GiraffePlayerActivity.configPlayer(MainActivity.this).setTitle(url).play(url);
83 | // more configuration example:
84 | // GiraffePlayerActivity.configPlayer(MainActivity.this)
85 | // .setScaleType(GiraffePlayer.SCALETYPE_FITPARENT)
86 | // .setDefaultRetryTime(5 * 1000)
87 | // .setFullScreenOnly(false)
88 | // .setTitle(url)
89 | // .play(url);
90 | }else if (v.getId() == R.id.btn_start) {
91 | player.start();
92 | }else if (v.getId() == R.id.btn_pause) {
93 | player.pause();
94 | }else if (v.getId() == R.id.btn_toggle) {
95 | player.toggleFullScreen();
96 | }else if (v.getId() == R.id.btn_forward) {
97 | player.forward(0.2f);
98 | }else if (v.getId() == R.id.btn_back) {
99 | player.forward(-0.2f);
100 | }else if (v.getId() == R.id.btn_toggle_ratio) {
101 | player.toggleAspectRatio();
102 | }
103 | }
104 | };
105 | findViewById(R.id.btn_play).setOnClickListener(clickListener);
106 | findViewById(R.id.btn_play_sample_1).setOnClickListener(clickListener);
107 | findViewById(R.id.btn_play_sample_2).setOnClickListener(clickListener);
108 | findViewById(R.id.btn_play_sample_3).setOnClickListener(clickListener);
109 | findViewById(R.id.btn_pause).setOnClickListener(clickListener);
110 | findViewById(R.id.btn_start).setOnClickListener(clickListener);
111 | findViewById(R.id.btn_toggle).setOnClickListener(clickListener);
112 | findViewById(R.id.btn_open).setOnClickListener(clickListener);
113 | findViewById(R.id.btn_forward).setOnClickListener(clickListener);
114 | findViewById(R.id.btn_back).setOnClickListener(clickListener);
115 | findViewById(R.id.btn_toggle_ratio).setOnClickListener(clickListener);
116 | }
117 |
118 | @Override
119 | protected void onPause() {
120 | super.onPause();
121 | if (player != null) {
122 | player.onPause();
123 | }
124 | }
125 |
126 | @Override
127 | protected void onResume() {
128 | super.onResume();
129 | if (player != null) {
130 | player.onResume();
131 | }
132 | }
133 |
134 | @Override
135 | protected void onDestroy() {
136 | super.onDestroy();
137 | if (player != null) {
138 | player.onDestroy();
139 | }
140 | }
141 |
142 | @Override
143 | public void onConfigurationChanged(Configuration newConfig) {
144 | super.onConfigurationChanged(newConfig);
145 | if (player != null) {
146 | player.onConfigurationChanged(newConfig);
147 | }
148 | }
149 |
150 | @Override
151 | public void onBackPressed() {
152 | if (player != null && player.onBackPressed()) {
153 | return;
154 | }
155 | super.onBackPressed();
156 | }
157 | }
158 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/misc/IjkMediaFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player.misc;
18 |
19 | import android.annotation.TargetApi;
20 | import android.os.Build;
21 | import android.text.TextUtils;
22 |
23 | import java.util.HashMap;
24 | import java.util.Locale;
25 | import java.util.Map;
26 |
27 | import tv.danmaku.ijk.media.player.IjkMediaMeta;
28 |
29 | public class IjkMediaFormat implements IMediaFormat {
30 | // Common
31 | public static final String KEY_IJK_CODEC_LONG_NAME_UI = "ijk-codec-long-name-ui";
32 | public static final String KEY_IJK_BIT_RATE_UI = "ijk-bit-rate-ui";
33 |
34 | // Video
35 | public static final String KEY_IJK_CODEC_PROFILE_LEVEL_UI = "ijk-profile-level-ui";
36 | public static final String KEY_IJK_CODEC_PIXEL_FORMAT_UI = "ijk-pixel-format-ui";
37 | public static final String KEY_IJK_RESOLUTION_UI = "ijk-resolution-ui";
38 | public static final String KEY_IJK_FRAME_RATE_UI = "ijk-frame-rate-ui";
39 |
40 | // Audio
41 | public static final String KEY_IJK_SAMPLE_RATE_UI = "ijk-sample-rate-ui";
42 | public static final String KEY_IJK_CHANNEL_UI = "ijk-channel-ui";
43 |
44 | // Codec
45 | public static final String CODEC_NAME_H264 = "h264";
46 |
47 | public final IjkMediaMeta.IjkStreamMeta mMediaFormat;
48 |
49 | public IjkMediaFormat(IjkMediaMeta.IjkStreamMeta streamMeta) {
50 | mMediaFormat = streamMeta;
51 | }
52 |
53 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
54 | @Override
55 | public int getInteger(String name) {
56 | if (mMediaFormat == null)
57 | return 0;
58 |
59 | return mMediaFormat.getInt(name);
60 | }
61 |
62 | @Override
63 | public String getString(String name) {
64 | if (mMediaFormat == null)
65 | return null;
66 |
67 | if (sFormatterMap.containsKey(name)) {
68 | Formatter formatter = sFormatterMap.get(name);
69 | return formatter.format(this);
70 | }
71 |
72 | return mMediaFormat.getString(name);
73 | }
74 |
75 | //-------------------------
76 | // Formatter
77 | //-------------------------
78 |
79 | private static abstract class Formatter {
80 | public String format(IjkMediaFormat mediaFormat) {
81 | String value = doFormat(mediaFormat);
82 | if (TextUtils.isEmpty(value))
83 | return getDefaultString();
84 | return value;
85 | }
86 |
87 | protected abstract String doFormat(IjkMediaFormat mediaFormat);
88 |
89 | @SuppressWarnings("SameReturnValue")
90 | protected String getDefaultString() {
91 | return "N/A";
92 | }
93 | }
94 |
95 | private static final Map sFormatterMap = new HashMap();
96 |
97 | {
98 | sFormatterMap.put(KEY_IJK_CODEC_LONG_NAME_UI, new Formatter() {
99 | @Override
100 | public String doFormat(IjkMediaFormat mediaFormat) {
101 | return mMediaFormat.getString(IjkMediaMeta.IJKM_KEY_CODEC_LONG_NAME);
102 | }
103 | });
104 | sFormatterMap.put(KEY_IJK_BIT_RATE_UI, new Formatter() {
105 | @Override
106 | protected String doFormat(IjkMediaFormat mediaFormat) {
107 | int bitRate = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_BITRATE);
108 | if (bitRate <= 0) {
109 | return null;
110 | } else if (bitRate < 1000) {
111 | return String.format(Locale.US, "%d bit/s", bitRate);
112 | } else {
113 | return String.format(Locale.US, "%d kb/s", bitRate / 1000);
114 | }
115 | }
116 | });
117 | sFormatterMap.put(KEY_IJK_CODEC_PROFILE_LEVEL_UI, new Formatter() {
118 | @Override
119 | protected String doFormat(IjkMediaFormat mediaFormat) {
120 | String profile = mediaFormat.getString(IjkMediaMeta.IJKM_KEY_CODEC_PROFILE);
121 | if (TextUtils.isEmpty(profile))
122 | return null;
123 |
124 | StringBuilder sb = new StringBuilder();
125 | sb.append(profile);
126 |
127 | String codecName = mediaFormat.getString(IjkMediaMeta.IJKM_KEY_CODEC_NAME);
128 | if (!TextUtils.isEmpty(codecName) && codecName.equalsIgnoreCase(CODEC_NAME_H264)) {
129 | int level = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_CODEC_LEVEL);
130 | if (level < 10)
131 | return sb.toString();
132 |
133 | sb.append(" Profile Level ");
134 | sb.append((level / 10) % 10);
135 | if ((level % 10) != 0) {
136 | sb.append(".");
137 | sb.append(level % 10);
138 | }
139 | }
140 |
141 | return sb.toString();
142 | }
143 | });
144 | sFormatterMap.put(KEY_IJK_CODEC_PIXEL_FORMAT_UI, new Formatter() {
145 | @Override
146 | protected String doFormat(IjkMediaFormat mediaFormat) {
147 | return mediaFormat.getString(IjkMediaMeta.IJKM_KEY_CODEC_PIXEL_FORMAT);
148 | }
149 | });
150 | sFormatterMap.put(KEY_IJK_RESOLUTION_UI, new Formatter() {
151 | @Override
152 | protected String doFormat(IjkMediaFormat mediaFormat) {
153 | int width = mediaFormat.getInteger(KEY_WIDTH);
154 | int height = mediaFormat.getInteger(KEY_HEIGHT);
155 | int sarNum = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_SAR_NUM);
156 | int sarDen = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_SAR_DEN);
157 |
158 | if (width <= 0 || height <= 0) {
159 | return null;
160 | } else if (sarNum <= 0 || sarDen <= 0) {
161 | return String.format(Locale.US, "%d x %d", width, height);
162 | } else {
163 | return String.format(Locale.US, "%d x %d [SAR %d:%d]", width,
164 | height, sarNum, sarDen);
165 | }
166 | }
167 | });
168 | sFormatterMap.put(KEY_IJK_FRAME_RATE_UI, new Formatter() {
169 | @Override
170 | protected String doFormat(IjkMediaFormat mediaFormat) {
171 | int fpsNum = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_FPS_NUM);
172 | int fpsDen = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_FPS_DEN);
173 | if (fpsNum <= 0 || fpsDen <= 0) {
174 | return null;
175 | } else {
176 | return String.valueOf(((float) (fpsNum)) / fpsDen);
177 | }
178 | }
179 | });
180 | sFormatterMap.put(KEY_IJK_SAMPLE_RATE_UI, new Formatter() {
181 | @Override
182 | protected String doFormat(IjkMediaFormat mediaFormat) {
183 | int sampleRate = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_SAMPLE_RATE);
184 | if (sampleRate <= 0) {
185 | return null;
186 | } else {
187 | return String.format(Locale.US, "%d Hz", sampleRate);
188 | }
189 | }
190 | });
191 | sFormatterMap.put(KEY_IJK_CHANNEL_UI, new Formatter() {
192 | @Override
193 | protected String doFormat(IjkMediaFormat mediaFormat) {
194 | int channelLayout = mediaFormat.getInteger(IjkMediaMeta.IJKM_KEY_CHANNEL_LAYOUT);
195 | if (channelLayout <= 0) {
196 | return null;
197 | } else {
198 | if (channelLayout == IjkMediaMeta.AV_CH_LAYOUT_MONO) {
199 | return "mono";
200 | } else if (channelLayout == IjkMediaMeta.AV_CH_LAYOUT_STEREO) {
201 | return "stereo";
202 | } else {
203 | return String.format(Locale.US, "%x", channelLayout);
204 | }
205 | }
206 | }
207 | });
208 | }
209 | }
210 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/java/tcking/github/com/giraffeplayer/SurfaceRenderView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tcking.github.com.giraffeplayer;
18 |
19 | import android.annotation.TargetApi;
20 | import android.content.Context;
21 | import android.graphics.SurfaceTexture;
22 | import android.os.Build;
23 | import android.support.annotation.NonNull;
24 | import android.support.annotation.Nullable;
25 | import android.util.AttributeSet;
26 | import android.util.Log;
27 | import android.view.Surface;
28 | import android.view.SurfaceHolder;
29 | import android.view.SurfaceView;
30 | import android.view.View;
31 | import android.view.accessibility.AccessibilityEvent;
32 | import android.view.accessibility.AccessibilityNodeInfo;
33 |
34 | import java.lang.ref.WeakReference;
35 | import java.util.Map;
36 | import java.util.concurrent.ConcurrentHashMap;
37 |
38 | import tv.danmaku.ijk.media.player.IMediaPlayer;
39 | import tv.danmaku.ijk.media.player.ISurfaceTextureHolder;
40 |
41 | public class SurfaceRenderView extends SurfaceView implements IRenderView {
42 | private MeasureHelper mMeasureHelper;
43 |
44 | public SurfaceRenderView(Context context) {
45 | super(context);
46 | initView(context);
47 | }
48 |
49 | public SurfaceRenderView(Context context, AttributeSet attrs) {
50 | super(context, attrs);
51 | initView(context);
52 | }
53 |
54 | public SurfaceRenderView(Context context, AttributeSet attrs, int defStyleAttr) {
55 | super(context, attrs, defStyleAttr);
56 | initView(context);
57 | }
58 |
59 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
60 | public SurfaceRenderView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
61 | super(context, attrs, defStyleAttr, defStyleRes);
62 | initView(context);
63 | }
64 |
65 | private void initView(Context context) {
66 | mMeasureHelper = new MeasureHelper(this);
67 | mSurfaceCallback = new SurfaceCallback(this);
68 | getHolder().addCallback(mSurfaceCallback);
69 | //noinspection deprecation
70 | getHolder().setType(SurfaceHolder.SURFACE_TYPE_NORMAL);
71 | }
72 |
73 | @Override
74 | public View getView() {
75 | return this;
76 | }
77 |
78 | @Override
79 | public boolean shouldWaitForResize() {
80 | return true;
81 | }
82 |
83 | //--------------------
84 | // Layout & Measure
85 | //--------------------
86 | @Override
87 | public void setVideoSize(int videoWidth, int videoHeight) {
88 | if (videoWidth > 0 && videoHeight > 0) {
89 | mMeasureHelper.setVideoSize(videoWidth, videoHeight);
90 | getHolder().setFixedSize(videoWidth, videoHeight);
91 | requestLayout();
92 | }
93 | }
94 |
95 | @Override
96 | public void setVideoSampleAspectRatio(int videoSarNum, int videoSarDen) {
97 | if (videoSarNum > 0 && videoSarDen > 0) {
98 | mMeasureHelper.setVideoSampleAspectRatio(videoSarNum, videoSarDen);
99 | requestLayout();
100 | }
101 | }
102 |
103 | @Override
104 | public void setVideoRotation(int degree) {
105 | Log.e("", "SurfaceView doesn't support rotation (" + degree + ")!\n");
106 | }
107 |
108 | @Override
109 | public void setAspectRatio(int aspectRatio) {
110 | mMeasureHelper.setAspectRatio(aspectRatio);
111 | requestLayout();
112 | }
113 |
114 | @Override
115 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
116 | mMeasureHelper.doMeasure(widthMeasureSpec, heightMeasureSpec);
117 | setMeasuredDimension(mMeasureHelper.getMeasuredWidth(), mMeasureHelper.getMeasuredHeight());
118 | }
119 |
120 | //--------------------
121 | // SurfaceViewHolder
122 | //--------------------
123 |
124 | private static final class InternalSurfaceHolder implements IRenderView.ISurfaceHolder {
125 | private SurfaceRenderView mSurfaceView;
126 | private SurfaceHolder mSurfaceHolder;
127 |
128 | public InternalSurfaceHolder(@NonNull SurfaceRenderView surfaceView,
129 | @Nullable SurfaceHolder surfaceHolder) {
130 | mSurfaceView = surfaceView;
131 | mSurfaceHolder = surfaceHolder;
132 | }
133 |
134 | public void bindToMediaPlayer(IMediaPlayer mp) {
135 | if (mp != null) {
136 | if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) &&
137 | (mp instanceof ISurfaceTextureHolder)) {
138 | ISurfaceTextureHolder textureHolder = (ISurfaceTextureHolder) mp;
139 | textureHolder.setSurfaceTexture(null);
140 | }
141 | mp.setDisplay(mSurfaceHolder);
142 | }
143 | }
144 |
145 | @NonNull
146 | @Override
147 | public IRenderView getRenderView() {
148 | return mSurfaceView;
149 | }
150 |
151 | @Nullable
152 | @Override
153 | public SurfaceHolder getSurfaceHolder() {
154 | return mSurfaceHolder;
155 | }
156 |
157 | @Nullable
158 | @Override
159 | public SurfaceTexture getSurfaceTexture() {
160 | return null;
161 | }
162 |
163 | @Nullable
164 | @Override
165 | public Surface openSurface() {
166 | if (mSurfaceHolder == null)
167 | return null;
168 | return mSurfaceHolder.getSurface();
169 | }
170 | }
171 |
172 | //-------------------------
173 | // SurfaceHolder.Callback
174 | //-------------------------
175 |
176 | @Override
177 | public void addRenderCallback(IRenderCallback callback) {
178 | mSurfaceCallback.addRenderCallback(callback);
179 | }
180 |
181 | @Override
182 | public void removeRenderCallback(IRenderCallback callback) {
183 | mSurfaceCallback.removeRenderCallback(callback);
184 | }
185 |
186 | private SurfaceCallback mSurfaceCallback;
187 |
188 | private static final class SurfaceCallback implements SurfaceHolder.Callback {
189 | private SurfaceHolder mSurfaceHolder;
190 | private boolean mIsFormatChanged;
191 | private int mFormat;
192 | private int mWidth;
193 | private int mHeight;
194 |
195 | private WeakReference mWeakSurfaceView;
196 | private Map mRenderCallbackMap = new ConcurrentHashMap();
197 |
198 | public SurfaceCallback(@NonNull SurfaceRenderView surfaceView) {
199 | mWeakSurfaceView = new WeakReference(surfaceView);
200 | }
201 |
202 | public void addRenderCallback(@NonNull IRenderCallback callback) {
203 | mRenderCallbackMap.put(callback, callback);
204 |
205 | ISurfaceHolder surfaceHolder = null;
206 | if (mSurfaceHolder != null) {
207 | if (surfaceHolder == null)
208 | surfaceHolder = new InternalSurfaceHolder(mWeakSurfaceView.get(), mSurfaceHolder);
209 | callback.onSurfaceCreated(surfaceHolder, mWidth, mHeight);
210 | }
211 |
212 | if (mIsFormatChanged) {
213 | if (surfaceHolder == null)
214 | surfaceHolder = new InternalSurfaceHolder(mWeakSurfaceView.get(), mSurfaceHolder);
215 | callback.onSurfaceChanged(surfaceHolder, mFormat, mWidth, mHeight);
216 | }
217 | }
218 |
219 | public void removeRenderCallback(@NonNull IRenderCallback callback) {
220 | mRenderCallbackMap.remove(callback);
221 | }
222 |
223 | @Override
224 | public void surfaceCreated(SurfaceHolder holder) {
225 | mSurfaceHolder = holder;
226 | mIsFormatChanged = false;
227 | mFormat = 0;
228 | mWidth = 0;
229 | mHeight = 0;
230 |
231 | ISurfaceHolder surfaceHolder = new InternalSurfaceHolder(mWeakSurfaceView.get(), mSurfaceHolder);
232 | for (IRenderCallback renderCallback : mRenderCallbackMap.keySet()) {
233 | renderCallback.onSurfaceCreated(surfaceHolder, 0, 0);
234 | }
235 | }
236 |
237 | @Override
238 | public void surfaceDestroyed(SurfaceHolder holder) {
239 | mSurfaceHolder = null;
240 | mIsFormatChanged = false;
241 | mFormat = 0;
242 | mWidth = 0;
243 | mHeight = 0;
244 |
245 | ISurfaceHolder surfaceHolder = new InternalSurfaceHolder(mWeakSurfaceView.get(), mSurfaceHolder);
246 | for (IRenderCallback renderCallback : mRenderCallbackMap.keySet()) {
247 | renderCallback.onSurfaceDestroyed(surfaceHolder);
248 | }
249 | }
250 |
251 | @Override
252 | public void surfaceChanged(SurfaceHolder holder, int format,
253 | int width, int height) {
254 | mSurfaceHolder = holder;
255 | mIsFormatChanged = true;
256 | mFormat = format;
257 | mWidth = width;
258 | mHeight = height;
259 |
260 | // mMeasureHelper.setVideoSize(width, height);
261 |
262 | ISurfaceHolder surfaceHolder = new InternalSurfaceHolder(mWeakSurfaceView.get(), mSurfaceHolder);
263 | for (IRenderCallback renderCallback : mRenderCallbackMap.keySet()) {
264 | renderCallback.onSurfaceChanged(surfaceHolder, format, width, height);
265 | }
266 | }
267 | }
268 |
269 | //--------------------
270 | // Accessibility
271 | //--------------------
272 |
273 | @Override
274 | public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
275 | super.onInitializeAccessibilityEvent(event);
276 | event.setClassName(SurfaceRenderView.class.getName());
277 | }
278 |
279 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
280 | @Override
281 | public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
282 | super.onInitializeAccessibilityNodeInfo(info);
283 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
284 | info.setClassName(SurfaceRenderView.class.getName());
285 | }
286 | }
287 | }
288 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/res/layout/giraffe_player.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
16 |
20 |
21 |
28 |
35 |
36 |
37 |
45 |
46 |
54 |
55 |
61 |
62 |
69 |
70 |
71 |
79 |
80 |
86 |
87 |
96 |
97 |
98 |
107 |
108 |
117 |
118 |
123 |
124 |
131 |
132 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
155 |
156 |
163 |
164 |
165 |
166 |
174 |
175 |
182 |
183 |
190 |
191 |
202 |
203 |
213 |
214 |
224 |
232 |
233 |
234 |
235 |
236 |
237 |
243 |
244 |
249 |
250 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/MediaPlayerProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tv.danmaku.ijk.media.player;
18 |
19 | import android.annotation.TargetApi;
20 | import android.content.Context;
21 | import android.net.Uri;
22 | import android.os.Build;
23 | import android.view.Surface;
24 | import android.view.SurfaceHolder;
25 |
26 | import java.io.FileDescriptor;
27 | import java.io.IOException;
28 | import java.util.Map;
29 |
30 | import tv.danmaku.ijk.media.player.misc.IMediaDataSource;
31 | import tv.danmaku.ijk.media.player.misc.ITrackInfo;
32 |
33 | public class MediaPlayerProxy implements IMediaPlayer {
34 | protected final IMediaPlayer mBackEndMediaPlayer;
35 |
36 | public MediaPlayerProxy(IMediaPlayer backEndMediaPlayer) {
37 | mBackEndMediaPlayer = backEndMediaPlayer;
38 | }
39 |
40 | public IMediaPlayer getInternalMediaPlayer() {
41 | return mBackEndMediaPlayer;
42 | }
43 |
44 | @Override
45 | public void setDisplay(SurfaceHolder sh) {
46 | mBackEndMediaPlayer.setDisplay(sh);
47 | }
48 |
49 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
50 | @Override
51 | public void setSurface(Surface surface) {
52 | mBackEndMediaPlayer.setSurface(surface);
53 | }
54 |
55 | @Override
56 | public void setDataSource(Context context, Uri uri)
57 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
58 | mBackEndMediaPlayer.setDataSource(context, uri);
59 | }
60 |
61 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
62 | @Override
63 | public void setDataSource(Context context, Uri uri, Map headers)
64 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
65 | mBackEndMediaPlayer.setDataSource(context, uri, headers);
66 | }
67 |
68 | @Override
69 | public void setDataSource(FileDescriptor fd)
70 | throws IOException, IllegalArgumentException, IllegalStateException {
71 | mBackEndMediaPlayer.setDataSource(fd);
72 | }
73 |
74 | @Override
75 | public void setDataSource(String path) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
76 | mBackEndMediaPlayer.setDataSource(path);
77 | }
78 |
79 | @Override
80 | public void setDataSource(IMediaDataSource mediaDataSource) {
81 | mBackEndMediaPlayer.setDataSource(mediaDataSource);
82 | }
83 |
84 | @Override
85 | public String getDataSource() {
86 | return mBackEndMediaPlayer.getDataSource();
87 | }
88 |
89 | @Override
90 | public void prepareAsync() throws IllegalStateException {
91 | mBackEndMediaPlayer.prepareAsync();
92 | }
93 |
94 | @Override
95 | public void start() throws IllegalStateException {
96 | mBackEndMediaPlayer.start();
97 | }
98 |
99 | @Override
100 | public void stop() throws IllegalStateException {
101 | mBackEndMediaPlayer.stop();
102 | }
103 |
104 | @Override
105 | public void pause() throws IllegalStateException {
106 | mBackEndMediaPlayer.pause();
107 | }
108 |
109 | @Override
110 | public void setScreenOnWhilePlaying(boolean screenOn) {
111 | mBackEndMediaPlayer.setScreenOnWhilePlaying(screenOn);
112 | }
113 |
114 | @Override
115 | public int getVideoWidth() {
116 | return mBackEndMediaPlayer.getVideoWidth();
117 | }
118 |
119 | @Override
120 | public int getVideoHeight() {
121 | return mBackEndMediaPlayer.getVideoHeight();
122 | }
123 |
124 | @Override
125 | public boolean isPlaying() {
126 | return mBackEndMediaPlayer.isPlaying();
127 | }
128 |
129 | @Override
130 | public void seekTo(long msec) throws IllegalStateException {
131 | mBackEndMediaPlayer.seekTo(msec);
132 | }
133 |
134 | @Override
135 | public long getCurrentPosition() {
136 | return mBackEndMediaPlayer.getCurrentPosition();
137 | }
138 |
139 | @Override
140 | public long getDuration() {
141 | return mBackEndMediaPlayer.getDuration();
142 | }
143 |
144 | @Override
145 | public void release() {
146 | mBackEndMediaPlayer.release();
147 | }
148 |
149 | @Override
150 | public void reset() {
151 | mBackEndMediaPlayer.reset();
152 | }
153 |
154 | @Override
155 | public void setVolume(float leftVolume, float rightVolume) {
156 | mBackEndMediaPlayer.setVolume(leftVolume, rightVolume);
157 | }
158 |
159 | @Override
160 | public int getAudioSessionId() {
161 | return mBackEndMediaPlayer.getAudioSessionId();
162 | }
163 |
164 | @Override
165 | public MediaInfo getMediaInfo() {
166 | return mBackEndMediaPlayer.getMediaInfo();
167 | }
168 |
169 | @Override
170 | public void setLogEnabled(boolean enable) {
171 |
172 | }
173 |
174 | @Override
175 | public boolean isPlayable() {
176 | return false;
177 | }
178 |
179 | @Override
180 | public void setOnPreparedListener(OnPreparedListener listener) {
181 | if (listener != null) {
182 | final OnPreparedListener finalListener = listener;
183 | mBackEndMediaPlayer.setOnPreparedListener(new OnPreparedListener() {
184 | @Override
185 | public void onPrepared(IMediaPlayer mp) {
186 | finalListener.onPrepared(MediaPlayerProxy.this);
187 | }
188 | });
189 | } else {
190 | mBackEndMediaPlayer.setOnPreparedListener(null);
191 | }
192 | }
193 |
194 | @Override
195 | public void setOnCompletionListener(OnCompletionListener listener) {
196 | if (listener != null) {
197 | final OnCompletionListener finalListener = listener;
198 | mBackEndMediaPlayer.setOnCompletionListener(new OnCompletionListener() {
199 | @Override
200 | public void onCompletion(IMediaPlayer mp) {
201 | finalListener.onCompletion(MediaPlayerProxy.this);
202 | }
203 | });
204 | } else {
205 | mBackEndMediaPlayer.setOnCompletionListener(null);
206 | }
207 | }
208 |
209 | @Override
210 | public void setOnBufferingUpdateListener(OnBufferingUpdateListener listener) {
211 | if (listener != null) {
212 | final OnBufferingUpdateListener finalListener = listener;
213 | mBackEndMediaPlayer.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
214 | @Override
215 | public void onBufferingUpdate(IMediaPlayer mp, int percent) {
216 | finalListener.onBufferingUpdate(MediaPlayerProxy.this, percent);
217 | }
218 | });
219 | } else {
220 | mBackEndMediaPlayer.setOnBufferingUpdateListener(null);
221 | }
222 | }
223 |
224 | @Override
225 | public void setOnSeekCompleteListener(OnSeekCompleteListener listener) {
226 | if (listener != null) {
227 | final OnSeekCompleteListener finalListener = listener;
228 | mBackEndMediaPlayer.setOnSeekCompleteListener(new OnSeekCompleteListener() {
229 | @Override
230 | public void onSeekComplete(IMediaPlayer mp) {
231 | finalListener.onSeekComplete(MediaPlayerProxy.this);
232 | }
233 | });
234 | } else {
235 | mBackEndMediaPlayer.setOnSeekCompleteListener(null);
236 | }
237 | }
238 |
239 | @Override
240 | public void setOnVideoSizeChangedListener(OnVideoSizeChangedListener listener) {
241 | if (listener != null) {
242 | final OnVideoSizeChangedListener finalListener = listener;
243 | mBackEndMediaPlayer.setOnVideoSizeChangedListener(new OnVideoSizeChangedListener() {
244 | @Override
245 | public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sar_num, int sar_den) {
246 | finalListener.onVideoSizeChanged(MediaPlayerProxy.this, width, height, sar_num, sar_den);
247 | }
248 | });
249 | } else {
250 | mBackEndMediaPlayer.setOnVideoSizeChangedListener(null);
251 | }
252 | }
253 |
254 | @Override
255 | public void setOnErrorListener(OnErrorListener listener) {
256 | if (listener != null) {
257 | final OnErrorListener finalListener = listener;
258 | mBackEndMediaPlayer.setOnErrorListener(new OnErrorListener() {
259 | @Override
260 | public boolean onError(IMediaPlayer mp, int what, int extra) {
261 | return finalListener.onError(MediaPlayerProxy.this, what, extra);
262 | }
263 | });
264 | } else {
265 | mBackEndMediaPlayer.setOnErrorListener(null);
266 | }
267 | }
268 |
269 | @Override
270 | public void setOnInfoListener(OnInfoListener listener) {
271 | if (listener != null) {
272 | final OnInfoListener finalListener = listener;
273 | mBackEndMediaPlayer.setOnInfoListener(new OnInfoListener() {
274 | @Override
275 | public boolean onInfo(IMediaPlayer mp, int what, int extra) {
276 | return finalListener.onInfo(MediaPlayerProxy.this, what, extra);
277 | }
278 | });
279 | } else {
280 | mBackEndMediaPlayer.setOnInfoListener(null);
281 | }
282 | }
283 |
284 | @Override
285 | public void setAudioStreamType(int streamtype) {
286 | mBackEndMediaPlayer.setAudioStreamType(streamtype);
287 | }
288 |
289 | @Override
290 | public void setKeepInBackground(boolean keepInBackground) {
291 | mBackEndMediaPlayer.setKeepInBackground(keepInBackground);
292 | }
293 |
294 | @Override
295 | public int getVideoSarNum() {
296 | return mBackEndMediaPlayer.getVideoSarNum();
297 | }
298 |
299 | @Override
300 | public int getVideoSarDen() {
301 | return mBackEndMediaPlayer.getVideoSarDen();
302 | }
303 |
304 | @Override
305 | public void setWakeMode(Context context, int mode) {
306 | mBackEndMediaPlayer.setWakeMode(context, mode);
307 | }
308 |
309 | @Override
310 | public ITrackInfo[] getTrackInfo() {
311 | return mBackEndMediaPlayer.getTrackInfo();
312 | }
313 |
314 | @Override
315 | public void setLooping(boolean looping) {
316 | mBackEndMediaPlayer.setLooping(looping);
317 | }
318 |
319 | @Override
320 | public boolean isLooping() {
321 | return mBackEndMediaPlayer.isLooping();
322 | }
323 | }
324 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/java/tcking/github/com/giraffeplayer/TextureRenderView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tcking.github.com.giraffeplayer;
18 |
19 | import android.annotation.TargetApi;
20 | import android.content.Context;
21 | import android.graphics.SurfaceTexture;
22 | import android.os.Build;
23 | import android.support.annotation.NonNull;
24 | import android.support.annotation.Nullable;
25 | import android.util.AttributeSet;
26 | import android.view.Surface;
27 | import android.view.SurfaceHolder;
28 | import android.view.TextureView;
29 | import android.view.View;
30 | import android.view.accessibility.AccessibilityEvent;
31 | import android.view.accessibility.AccessibilityNodeInfo;
32 |
33 | import java.lang.ref.WeakReference;
34 | import java.util.Map;
35 | import java.util.concurrent.ConcurrentHashMap;
36 |
37 | import tv.danmaku.ijk.media.player.IMediaPlayer;
38 | import tv.danmaku.ijk.media.player.ISurfaceTextureHolder;
39 |
40 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
41 | public class TextureRenderView extends TextureView implements IRenderView {
42 | private MeasureHelper mMeasureHelper;
43 |
44 | public TextureRenderView(Context context) {
45 | super(context);
46 | initView(context);
47 | }
48 |
49 | public TextureRenderView(Context context, AttributeSet attrs) {
50 | super(context, attrs);
51 | initView(context);
52 | }
53 |
54 | public TextureRenderView(Context context, AttributeSet attrs, int defStyleAttr) {
55 | super(context, attrs, defStyleAttr);
56 | initView(context);
57 | }
58 |
59 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
60 | public TextureRenderView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
61 | super(context, attrs, defStyleAttr, defStyleRes);
62 | initView(context);
63 | }
64 |
65 | private void initView(Context context) {
66 | mMeasureHelper = new MeasureHelper(this);
67 | mSurfaceCallback = new SurfaceCallback(this);
68 | setSurfaceTextureListener(mSurfaceCallback);
69 | }
70 |
71 | @Override
72 | public View getView() {
73 | return this;
74 | }
75 |
76 | @Override
77 | public boolean shouldWaitForResize() {
78 | return false;
79 | }
80 |
81 | //--------------------
82 | // Layout & Measure
83 | //--------------------
84 | @Override
85 | public void setVideoSize(int videoWidth, int videoHeight) {
86 | if (videoWidth > 0 && videoHeight > 0) {
87 | mMeasureHelper.setVideoSize(videoWidth, videoHeight);
88 | requestLayout();
89 | }
90 | }
91 |
92 | @Override
93 | public void setVideoSampleAspectRatio(int videoSarNum, int videoSarDen) {
94 | if (videoSarNum > 0 && videoSarDen > 0) {
95 | mMeasureHelper.setVideoSampleAspectRatio(videoSarNum, videoSarDen);
96 | requestLayout();
97 | }
98 | }
99 |
100 | @Override
101 | public void setVideoRotation(int degree) {
102 | mMeasureHelper.setVideoRotation(degree);
103 | setRotation(degree);
104 | }
105 |
106 | @Override
107 | public void setAspectRatio(int aspectRatio) {
108 | mMeasureHelper.setAspectRatio(aspectRatio);
109 | requestLayout();
110 | }
111 |
112 | @Override
113 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
114 | mMeasureHelper.doMeasure(widthMeasureSpec, heightMeasureSpec);
115 | setMeasuredDimension(mMeasureHelper.getMeasuredWidth(), mMeasureHelper.getMeasuredHeight());
116 | }
117 |
118 | //--------------------
119 | // TextureViewHolder
120 | //--------------------
121 |
122 | public IRenderView.ISurfaceHolder getSurfaceHolder() {
123 | return new InternalSurfaceHolder(this, mSurfaceCallback.mSurfaceTexture);
124 | }
125 |
126 | private static final class InternalSurfaceHolder implements IRenderView.ISurfaceHolder {
127 | private TextureRenderView mTextureView;
128 | private SurfaceTexture mSurfaceTexture;
129 |
130 | public InternalSurfaceHolder(@NonNull TextureRenderView textureView,
131 | @Nullable SurfaceTexture surfaceTexture) {
132 | mTextureView = textureView;
133 | mSurfaceTexture = surfaceTexture;
134 | }
135 |
136 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
137 | public void bindToMediaPlayer(IMediaPlayer mp) {
138 | if (mp == null)
139 | return;
140 |
141 | if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) &&
142 | (mp instanceof ISurfaceTextureHolder)) {
143 | ISurfaceTextureHolder textureHolder = (ISurfaceTextureHolder) mp;
144 | mTextureView.mSurfaceCallback.setOwnSurfaceTecture(false);
145 |
146 | SurfaceTexture surfaceTexture = textureHolder.getSurfaceTexture();
147 | if (surfaceTexture != null) {
148 | mTextureView.setSurfaceTexture(surfaceTexture);
149 | } else {
150 | textureHolder.setSurfaceTexture(mSurfaceTexture);
151 | }
152 | } else {
153 | mp.setSurface(openSurface());
154 | }
155 | }
156 |
157 | @NonNull
158 | @Override
159 | public IRenderView getRenderView() {
160 | return mTextureView;
161 | }
162 |
163 | @Nullable
164 | @Override
165 | public SurfaceHolder getSurfaceHolder() {
166 | return null;
167 | }
168 |
169 | @Nullable
170 | @Override
171 | public SurfaceTexture getSurfaceTexture() {
172 | return mSurfaceTexture;
173 | }
174 |
175 | @Nullable
176 | @Override
177 | public Surface openSurface() {
178 | if (mSurfaceTexture == null)
179 | return null;
180 | return new Surface(mSurfaceTexture);
181 | }
182 | }
183 |
184 | //-------------------------
185 | // SurfaceHolder.Callback
186 | //-------------------------
187 |
188 | @Override
189 | public void addRenderCallback(IRenderCallback callback) {
190 | mSurfaceCallback.addRenderCallback(callback);
191 | }
192 |
193 | @Override
194 | public void removeRenderCallback(IRenderCallback callback) {
195 | mSurfaceCallback.removeRenderCallback(callback);
196 | }
197 |
198 | private SurfaceCallback mSurfaceCallback;
199 |
200 | private static final class SurfaceCallback implements SurfaceTextureListener {
201 | private SurfaceTexture mSurfaceTexture;
202 | private boolean mIsFormatChanged;
203 | private int mWidth;
204 | private int mHeight;
205 |
206 | private boolean mOwnSurfaceTecture = true;
207 |
208 | private WeakReference mWeakRenderView;
209 | private Map mRenderCallbackMap = new ConcurrentHashMap();
210 |
211 | public SurfaceCallback(@NonNull TextureRenderView renderView) {
212 | mWeakRenderView = new WeakReference(renderView);
213 | }
214 |
215 | public void setOwnSurfaceTecture(boolean ownSurfaceTecture) {
216 | mOwnSurfaceTecture = ownSurfaceTecture;
217 | }
218 |
219 | public void addRenderCallback(@NonNull IRenderCallback callback) {
220 | mRenderCallbackMap.put(callback, callback);
221 |
222 | ISurfaceHolder surfaceHolder = null;
223 | if (mSurfaceTexture != null) {
224 | if (surfaceHolder == null)
225 | surfaceHolder = new InternalSurfaceHolder(mWeakRenderView.get(), mSurfaceTexture);
226 | callback.onSurfaceCreated(surfaceHolder, mWidth, mHeight);
227 | }
228 |
229 | if (mIsFormatChanged) {
230 | if (surfaceHolder == null)
231 | surfaceHolder = new InternalSurfaceHolder(mWeakRenderView.get(), mSurfaceTexture);
232 | callback.onSurfaceChanged(surfaceHolder, 0, mWidth, mHeight);
233 | }
234 | }
235 |
236 | public void removeRenderCallback(@NonNull IRenderCallback callback) {
237 | mRenderCallbackMap.remove(callback);
238 | }
239 |
240 | @Override
241 | public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
242 | mSurfaceTexture = surface;
243 | mIsFormatChanged = false;
244 | mWidth = 0;
245 | mHeight = 0;
246 |
247 | ISurfaceHolder surfaceHolder = new InternalSurfaceHolder(mWeakRenderView.get(), surface);
248 | for (IRenderCallback renderCallback : mRenderCallbackMap.keySet()) {
249 | renderCallback.onSurfaceCreated(surfaceHolder, 0, 0);
250 | }
251 | }
252 |
253 | @Override
254 | public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
255 | mSurfaceTexture = surface;
256 | mIsFormatChanged = true;
257 | mWidth = width;
258 | mHeight = height;
259 |
260 | ISurfaceHolder surfaceHolder = new InternalSurfaceHolder(mWeakRenderView.get(), surface);
261 | for (IRenderCallback renderCallback : mRenderCallbackMap.keySet()) {
262 | renderCallback.onSurfaceChanged(surfaceHolder, 0, width, height);
263 | }
264 | }
265 |
266 | @Override
267 | public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
268 | mSurfaceTexture = surface;
269 | mIsFormatChanged = false;
270 | mWidth = 0;
271 | mHeight = 0;
272 |
273 | ISurfaceHolder surfaceHolder = new InternalSurfaceHolder(mWeakRenderView.get(), surface);
274 | for (IRenderCallback renderCallback : mRenderCallbackMap.keySet()) {
275 | renderCallback.onSurfaceDestroyed(surfaceHolder);
276 | }
277 |
278 | return mOwnSurfaceTecture;
279 | }
280 |
281 | @Override
282 | public void onSurfaceTextureUpdated(SurfaceTexture surface) {
283 | }
284 | }
285 |
286 | //--------------------
287 | // Accessibility
288 | //--------------------
289 |
290 | @Override
291 | public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
292 | super.onInitializeAccessibilityEvent(event);
293 | event.setClassName(TextureRenderView.class.getName());
294 | }
295 |
296 | @Override
297 | public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
298 | super.onInitializeAccessibilityNodeInfo(info);
299 | info.setClassName(TextureRenderView.class.getName());
300 | }
301 | }
302 |
--------------------------------------------------------------------------------
/giraffeplayer/src/main/java/tcking/github/com/giraffeplayer/MeasureHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Zhang Rui
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package tcking.github.com.giraffeplayer;
18 |
19 | import android.view.View;
20 |
21 | import java.lang.ref.WeakReference;
22 |
23 |
24 | public final class MeasureHelper {
25 | private WeakReference mWeakView;
26 |
27 | private int mVideoWidth;
28 | private int mVideoHeight;
29 | private int mVideoSarNum;
30 | private int mVideoSarDen;
31 |
32 | private int mVideoRotationDegree;
33 |
34 | private int mMeasuredWidth;
35 | private int mMeasuredHeight;
36 |
37 | private int mCurrentAspectRatio = IRenderView.AR_ASPECT_FIT_PARENT;
38 |
39 | public MeasureHelper(View view) {
40 | mWeakView = new WeakReference(view);
41 | }
42 |
43 | public View getView() {
44 | if (mWeakView == null)
45 | return null;
46 | return mWeakView.get();
47 | }
48 |
49 | public void setVideoSize(int videoWidth, int videoHeight) {
50 | mVideoWidth = videoWidth;
51 | mVideoHeight = videoHeight;
52 | }
53 |
54 | public void setVideoSampleAspectRatio(int videoSarNum, int videoSarDen) {
55 | mVideoSarNum = videoSarNum;
56 | mVideoSarDen = videoSarDen;
57 | }
58 |
59 | public void setVideoRotation(int videoRotationDegree) {
60 | mVideoRotationDegree = videoRotationDegree;
61 | }
62 |
63 | /**
64 | * Must be called by View.onMeasure(int, int)
65 | *
66 | * @param widthMeasureSpec
67 | * @param heightMeasureSpec
68 | */
69 | public void doMeasure(int widthMeasureSpec, int heightMeasureSpec) {
70 | //Log.i("@@@@", "onMeasure(" + MeasureSpec.toString(widthMeasureSpec) + ", "
71 | // + MeasureSpec.toString(heightMeasureSpec) + ")");
72 | if (mVideoRotationDegree == 90 || mVideoRotationDegree == 270) {
73 | int tempSpec = widthMeasureSpec;
74 | widthMeasureSpec = heightMeasureSpec;
75 | heightMeasureSpec = tempSpec;
76 | }
77 |
78 | int width = View.getDefaultSize(mVideoWidth, widthMeasureSpec);
79 | int height = View.getDefaultSize(mVideoHeight, heightMeasureSpec);
80 | if (mCurrentAspectRatio == IRenderView.AR_MATCH_PARENT) {
81 | width = widthMeasureSpec;
82 | height = heightMeasureSpec;
83 | } else if (mVideoWidth > 0 && mVideoHeight > 0) {
84 | int widthSpecMode = View.MeasureSpec.getMode(widthMeasureSpec);
85 | int widthSpecSize = View.MeasureSpec.getSize(widthMeasureSpec);
86 | int heightSpecMode = View.MeasureSpec.getMode(heightMeasureSpec);
87 | int heightSpecSize = View.MeasureSpec.getSize(heightMeasureSpec);
88 |
89 | if (widthSpecMode == View.MeasureSpec.AT_MOST && heightSpecMode == View.MeasureSpec.AT_MOST) {
90 | float specAspectRatio = (float) widthSpecSize / (float) heightSpecSize;
91 | float displayAspectRatio;
92 | switch (mCurrentAspectRatio) {
93 | case IRenderView.AR_16_9_FIT_PARENT:
94 | displayAspectRatio = 16.0f / 9.0f;
95 | if (mVideoRotationDegree == 90 || mVideoRotationDegree == 270)
96 | displayAspectRatio = 1.0f / displayAspectRatio;
97 | break;
98 | case IRenderView.AR_4_3_FIT_PARENT:
99 | displayAspectRatio = 4.0f / 3.0f;
100 | if (mVideoRotationDegree == 90 || mVideoRotationDegree == 270)
101 | displayAspectRatio = 1.0f / displayAspectRatio;
102 | break;
103 | case IRenderView.AR_ASPECT_FIT_PARENT:
104 | case IRenderView.AR_ASPECT_FILL_PARENT:
105 | case IRenderView.AR_ASPECT_WRAP_CONTENT:
106 | default:
107 | displayAspectRatio = (float) mVideoWidth / (float) mVideoHeight;
108 | if (mVideoSarNum > 0 && mVideoSarDen > 0)
109 | displayAspectRatio = displayAspectRatio * mVideoSarNum / mVideoSarDen;
110 | break;
111 | }
112 | boolean shouldBeWider = displayAspectRatio > specAspectRatio;
113 |
114 | switch (mCurrentAspectRatio) {
115 | case IRenderView.AR_ASPECT_FIT_PARENT:
116 | case IRenderView.AR_16_9_FIT_PARENT:
117 | case IRenderView.AR_4_3_FIT_PARENT:
118 | if (shouldBeWider) {
119 | // too wide, fix width
120 | width = widthSpecSize;
121 | height = (int) (width / displayAspectRatio);
122 | } else {
123 | // too high, fix height
124 | height = heightSpecSize;
125 | width = (int) (height * displayAspectRatio);
126 | }
127 | break;
128 | case IRenderView.AR_ASPECT_FILL_PARENT:
129 | if (shouldBeWider) {
130 | // not high enough, fix height
131 | height = heightSpecSize;
132 | width = (int) (height * displayAspectRatio);
133 | } else {
134 | // not wide enough, fix width
135 | width = widthSpecSize;
136 | height = (int) (width / displayAspectRatio);
137 | }
138 | break;
139 | case IRenderView.AR_ASPECT_WRAP_CONTENT:
140 | default:
141 | if (shouldBeWider) {
142 | // too wide, fix width
143 | width = Math.min(mVideoWidth, widthSpecSize);
144 | height = (int) (width / displayAspectRatio);
145 | } else {
146 | // too high, fix height
147 | height = Math.min(mVideoHeight, heightSpecSize);
148 | width = (int) (height * displayAspectRatio);
149 | }
150 | break;
151 | }
152 | } else if (widthSpecMode == View.MeasureSpec.EXACTLY && heightSpecMode == View.MeasureSpec.EXACTLY) {
153 | // the size is fixed
154 | width = widthSpecSize;
155 | height = heightSpecSize;
156 |
157 | // for compatibility, we adjust size based on aspect ratio
158 | if (mVideoWidth * height < width * mVideoHeight) {
159 | //Log.i("@@@", "image too wide, correcting");
160 | width = height * mVideoWidth / mVideoHeight;
161 | } else if (mVideoWidth * height > width * mVideoHeight) {
162 | //Log.i("@@@", "image too tall, correcting");
163 | height = width * mVideoHeight / mVideoWidth;
164 | }
165 | } else if (widthSpecMode == View.MeasureSpec.EXACTLY) {
166 | // only the width is fixed, adjust the height to match aspect ratio if possible
167 | width = widthSpecSize;
168 | height = width * mVideoHeight / mVideoWidth;
169 | if (heightSpecMode == View.MeasureSpec.AT_MOST && height > heightSpecSize) {
170 | // couldn't match aspect ratio within the constraints
171 | height = heightSpecSize;
172 | }
173 | } else if (heightSpecMode == View.MeasureSpec.EXACTLY) {
174 | // only the height is fixed, adjust the width to match aspect ratio if possible
175 | height = heightSpecSize;
176 | width = height * mVideoWidth / mVideoHeight;
177 | if (widthSpecMode == View.MeasureSpec.AT_MOST && width > widthSpecSize) {
178 | // couldn't match aspect ratio within the constraints
179 | width = widthSpecSize;
180 | }
181 | } else {
182 | // neither the width nor the height are fixed, try to use actual video size
183 | width = mVideoWidth;
184 | height = mVideoHeight;
185 | if (heightSpecMode == View.MeasureSpec.AT_MOST && height > heightSpecSize) {
186 | // too tall, decrease both width and height
187 | height = heightSpecSize;
188 | width = height * mVideoWidth / mVideoHeight;
189 | }
190 | if (widthSpecMode == View.MeasureSpec.AT_MOST && width > widthSpecSize) {
191 | // too wide, decrease both width and height
192 | width = widthSpecSize;
193 | height = width * mVideoHeight / mVideoWidth;
194 | }
195 | }
196 | } else {
197 | // no size yet, just adopt the given spec sizes
198 | }
199 |
200 | mMeasuredWidth = width;
201 | mMeasuredHeight = height;
202 | }
203 |
204 | public int getMeasuredWidth() {
205 | return mMeasuredWidth;
206 | }
207 |
208 | public int getMeasuredHeight() {
209 | return mMeasuredHeight;
210 | }
211 |
212 | public void setAspectRatio(int aspectRatio) {
213 | mCurrentAspectRatio = aspectRatio;
214 | }
215 |
216 | // @NonNull
217 | // public static String getAspectRatioText(Context context, int aspectRatio) {
218 | // String text;
219 | // switch (aspectRatio) {
220 | // case IRenderView.AR_ASPECT_FIT_PARENT:
221 | // text = context.getString(R.string.VideoView_ar_aspect_fit_parent);
222 | // break;
223 | // case IRenderView.AR_ASPECT_FILL_PARENT:
224 | // text = context.getString(R.string.VideoView_ar_aspect_fill_parent);
225 | // break;
226 | // case IRenderView.AR_ASPECT_WRAP_CONTENT:
227 | // text = context.getString(R.string.VideoView_ar_aspect_wrap_content);
228 | // break;
229 | // case IRenderView.AR_MATCH_PARENT:
230 | // text = context.getString(R.string.VideoView_ar_match_parent);
231 | // break;
232 | // case IRenderView.AR_16_9_FIT_PARENT:
233 | // text = context.getString(R.string.VideoView_ar_16_9_fit_parent);
234 | // break;
235 | // case IRenderView.AR_4_3_FIT_PARENT:
236 | // text = context.getString(R.string.VideoView_ar_4_3_fit_parent);
237 | // break;
238 | // default:
239 | // text = context.getString(R.string.N_A);
240 | // break;
241 | // }
242 | // return text;
243 | // }
244 | }
245 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/IjkMediaCodecInfo.java:
--------------------------------------------------------------------------------
1 | package tv.danmaku.ijk.media.player;
2 |
3 | import android.annotation.TargetApi;
4 | import android.media.MediaCodecInfo;
5 | import android.media.MediaCodecInfo.CodecCapabilities;
6 | import android.media.MediaCodecInfo.CodecProfileLevel;
7 | import android.os.Build;
8 | import android.text.TextUtils;
9 | import android.util.Log;
10 |
11 | import java.util.Locale;
12 | import java.util.Map;
13 | import java.util.TreeMap;
14 |
15 | public class IjkMediaCodecInfo {
16 | private final static String TAG = "IjkMediaCodecInfo";
17 |
18 | public static final int RANK_MAX = 1000;
19 | public static final int RANK_TESTED = 800;
20 | public static final int RANK_ACCEPTABLE = 700;
21 | public static final int RANK_LAST_CHANCE = 600;
22 | public static final int RANK_SECURE = 300;
23 | public static final int RANK_SOFTWARE = 200;
24 | public static final int RANK_NON_STANDARD = 100;
25 | public static final int RANK_NO_SENSE = 0;
26 |
27 | public MediaCodecInfo mCodecInfo;
28 | public int mRank = 0;
29 | public String mMimeType;
30 |
31 | private static Map sKnownCodecList;
32 |
33 | private static synchronized Map getKnownCodecList() {
34 | if (sKnownCodecList != null)
35 | return sKnownCodecList;
36 |
37 | sKnownCodecList = new TreeMap(
38 | String.CASE_INSENSITIVE_ORDER);
39 |
40 | // ----- Nvidia -----
41 | // Tegra3
42 | // Nexus 7 (2012)
43 | // Tegra K1
44 | // Nexus 9
45 | sKnownCodecList.put("OMX.Nvidia.h264.decode", RANK_TESTED);
46 | sKnownCodecList.put("OMX.Nvidia.h264.decode.secure", RANK_SECURE);
47 |
48 | // ----- Intel -----
49 | // Atom Z3735
50 | // Teclast X98 Air
51 | sKnownCodecList.put("OMX.Intel.hw_vd.h264", RANK_TESTED + 1);
52 | // Atom Z2560
53 | // Dell Venue 7 3730
54 | sKnownCodecList.put("OMX.Intel.VideoDecoder.AVC", RANK_TESTED);
55 |
56 | // ----- Qualcomm -----
57 | // MSM8260
58 | // Xiaomi MI 1S
59 | sKnownCodecList.put("OMX.qcom.video.decoder.avc", RANK_TESTED);
60 | sKnownCodecList.put("OMX.ittiam.video.decoder.avc", RANK_NO_SENSE);
61 |
62 | // ----- Samsung -----
63 | // Exynos 3110
64 | // Nexus S
65 | sKnownCodecList.put("OMX.SEC.avc.dec", RANK_TESTED);
66 | sKnownCodecList.put("OMX.SEC.AVC.Decoder", RANK_TESTED - 1);
67 | // OMX.SEC.avcdec doesn't reorder output pictures on GT-9100
68 | sKnownCodecList.put("OMX.SEC.avcdec", RANK_TESTED - 2);
69 | sKnownCodecList.put("OMX.SEC.avc.sw.dec", RANK_SOFTWARE);
70 | // Exynos 5 ?
71 | sKnownCodecList.put("OMX.Exynos.avc.dec", RANK_TESTED);
72 | sKnownCodecList.put("OMX.Exynos.AVC.Decoder", RANK_TESTED - 1);
73 |
74 | // ------ Huawei hisilicon ------
75 | // Kirin 910, Mali 450 MP
76 | // Huawei HONOR 3C (H30-L01)
77 | sKnownCodecList.put("OMX.k3.video.decoder.avc", RANK_TESTED);
78 | // Kirin 920, Mali T624
79 | // Huawei HONOR 6
80 | sKnownCodecList.put("OMX.IMG.MSVDX.Decoder.AVC", RANK_TESTED);
81 |
82 | // ----- TI -----
83 | // TI OMAP4460
84 | // Galaxy Nexus
85 | sKnownCodecList.put("OMX.TI.DUCATI1.VIDEO.DECODER", RANK_TESTED);
86 |
87 | // ------ RockChip ------
88 | // Youku TVBox
89 | sKnownCodecList.put("OMX.rk.video_decoder.avc", RANK_TESTED);
90 |
91 | // ------ AMLogic -----
92 | // MiBox1, 1s, 2
93 | sKnownCodecList.put("OMX.amlogic.avc.decoder.awesome", RANK_TESTED);
94 |
95 | // ------ Marvell ------
96 | // Lenovo A788t
97 | sKnownCodecList.put("OMX.MARVELL.VIDEO.HW.CODA7542DECODER", RANK_TESTED);
98 | sKnownCodecList.put("OMX.MARVELL.VIDEO.H264DECODER", RANK_SOFTWARE);
99 |
100 | // ----- TODO: need test -----
101 | sKnownCodecList.remove("OMX.Action.Video.Decoder");
102 | sKnownCodecList.remove("OMX.allwinner.video.decoder.avc");
103 | sKnownCodecList.remove("OMX.BRCM.vc4.decoder.avc");
104 | sKnownCodecList.remove("OMX.brcm.video.h264.hw.decoder");
105 | sKnownCodecList.remove("OMX.brcm.video.h264.decoder");
106 | sKnownCodecList.remove("OMX.cosmo.video.decoder.avc");
107 | sKnownCodecList.remove("OMX.duos.h264.decoder");
108 | sKnownCodecList.remove("OMX.hantro.81x0.video.decoder");
109 | sKnownCodecList.remove("OMX.hantro.G1.video.decoder");
110 | sKnownCodecList.remove("OMX.hisi.video.decoder");
111 | sKnownCodecList.remove("OMX.LG.decoder.video.avc");
112 | sKnownCodecList.remove("OMX.MS.AVC.Decoder");
113 | sKnownCodecList.remove("OMX.RENESAS.VIDEO.DECODER.H264");
114 | sKnownCodecList.remove("OMX.RTK.video.decoder");
115 | sKnownCodecList.remove("OMX.sprd.h264.decoder");
116 | sKnownCodecList.remove("OMX.ST.VFM.H264Dec");
117 | sKnownCodecList.remove("OMX.vpu.video_decoder.avc");
118 | sKnownCodecList.remove("OMX.WMT.decoder.avc");
119 |
120 | // Really ?
121 | sKnownCodecList.remove("OMX.bluestacks.hw.decoder");
122 |
123 | // ---------------
124 | // Useless codec
125 | // ----- google -----
126 | sKnownCodecList.put("OMX.google.h264.decoder", RANK_SOFTWARE);
127 | sKnownCodecList.put("OMX.google.h264.lc.decoder", RANK_SOFTWARE);
128 | // ----- huawei k920 -----
129 | sKnownCodecList.put("OMX.k3.ffmpeg.decoder", RANK_SOFTWARE);
130 | sKnownCodecList.put("OMX.ffmpeg.video.decoder", RANK_SOFTWARE);
131 | // ----- unknown -----
132 | sKnownCodecList.put("OMX.sprd.soft.h264.decoder", RANK_SOFTWARE);
133 |
134 | return sKnownCodecList;
135 | }
136 |
137 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
138 | public static IjkMediaCodecInfo setupCandidate(MediaCodecInfo codecInfo,
139 | String mimeType) {
140 | if (codecInfo == null
141 | || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
142 | return null;
143 |
144 | String name = codecInfo.getName();
145 | if (TextUtils.isEmpty(name))
146 | return null;
147 |
148 | name = name.toLowerCase(Locale.US);
149 | int rank = RANK_NO_SENSE;
150 | if (!name.startsWith("omx.")) {
151 | rank = RANK_NON_STANDARD;
152 | } else if (name.startsWith("omx.pv")) {
153 | rank = RANK_SOFTWARE;
154 | } else if (name.startsWith("omx.google.")) {
155 | rank = RANK_SOFTWARE;
156 | } else if (name.startsWith("omx.ffmpeg.")) {
157 | rank = RANK_SOFTWARE;
158 | } else if (name.startsWith("omx.k3.ffmpeg.")) {
159 | rank = RANK_SOFTWARE;
160 | } else if (name.startsWith("omx.avcodec.")) {
161 | rank = RANK_SOFTWARE;
162 | } else if (name.startsWith("omx.ittiam.")) {
163 | // unknown codec in qualcomm SoC
164 | rank = RANK_NO_SENSE;
165 | } else if (name.startsWith("omx.mtk.")) {
166 | // 1. MTK only works on 4.3 and above
167 | // 2. MTK works on MIUI 6 (4.2.1)
168 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
169 | rank = RANK_NO_SENSE;
170 | else
171 | rank = RANK_TESTED;
172 | } else {
173 | Integer knownRank = getKnownCodecList().get(name);
174 | if (knownRank != null) {
175 | rank = knownRank;
176 | } else {
177 | try {
178 | CodecCapabilities cap = codecInfo
179 | .getCapabilitiesForType(mimeType);
180 | if (cap != null)
181 | rank = RANK_ACCEPTABLE;
182 | else
183 | rank = RANK_LAST_CHANCE;
184 | } catch (Throwable e) {
185 | rank = RANK_LAST_CHANCE;
186 | }
187 | }
188 | }
189 |
190 | IjkMediaCodecInfo candidate = new IjkMediaCodecInfo();
191 | candidate.mCodecInfo = codecInfo;
192 | candidate.mRank = rank;
193 | candidate.mMimeType = mimeType;
194 | return candidate;
195 | }
196 |
197 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
198 | public void dumpProfileLevels(String mimeType) {
199 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
200 | return;
201 |
202 | try {
203 | CodecCapabilities caps = mCodecInfo
204 | .getCapabilitiesForType(mimeType);
205 | int maxProfile = 0;
206 | int maxLevel = 0;
207 | if (caps != null) {
208 | if (caps.profileLevels != null) {
209 | for (CodecProfileLevel profileLevel : caps.profileLevels) {
210 | if (profileLevel == null)
211 | continue;
212 |
213 | maxProfile = Math.max(maxProfile, profileLevel.profile);
214 | maxLevel = Math.max(maxLevel, profileLevel.level);
215 | }
216 | }
217 | }
218 |
219 | Log.i(TAG,
220 | String.format(Locale.US, "%s",
221 | getProfileLevelName(maxProfile, maxLevel)));
222 | } catch (Throwable e) {
223 | Log.i(TAG, "profile-level: exception");
224 | }
225 | }
226 |
227 | public static String getProfileLevelName(int profile, int level) {
228 | return String.format(Locale.US, " %s Profile Level %s (%d,%d)",
229 | getProfileName(profile), getLevelName(level), profile, level);
230 | }
231 |
232 | public static String getProfileName(int profile) {
233 | switch (profile) {
234 | case CodecProfileLevel.AVCProfileBaseline:
235 | return "Baseline";
236 | case CodecProfileLevel.AVCProfileMain:
237 | return "Main";
238 | case CodecProfileLevel.AVCProfileExtended:
239 | return "Extends";
240 | case CodecProfileLevel.AVCProfileHigh:
241 | return "High";
242 | case CodecProfileLevel.AVCProfileHigh10:
243 | return "High10";
244 | case CodecProfileLevel.AVCProfileHigh422:
245 | return "High422";
246 | case CodecProfileLevel.AVCProfileHigh444:
247 | return "High444";
248 | default:
249 | return "Unknown";
250 | }
251 | }
252 |
253 | public static String getLevelName(int level) {
254 | switch (level) {
255 | case CodecProfileLevel.AVCLevel1:
256 | return "1";
257 | case CodecProfileLevel.AVCLevel1b:
258 | return "1b";
259 | case CodecProfileLevel.AVCLevel11:
260 | return "11";
261 | case CodecProfileLevel.AVCLevel12:
262 | return "12";
263 | case CodecProfileLevel.AVCLevel13:
264 | return "13";
265 | case CodecProfileLevel.AVCLevel2:
266 | return "2";
267 | case CodecProfileLevel.AVCLevel21:
268 | return "21";
269 | case CodecProfileLevel.AVCLevel22:
270 | return "22";
271 | case CodecProfileLevel.AVCLevel3:
272 | return "3";
273 | case CodecProfileLevel.AVCLevel31:
274 | return "31";
275 | case CodecProfileLevel.AVCLevel32:
276 | return "32";
277 | case CodecProfileLevel.AVCLevel4:
278 | return "4";
279 | case CodecProfileLevel.AVCLevel41:
280 | return "41";
281 | case CodecProfileLevel.AVCLevel42:
282 | return "42";
283 | case CodecProfileLevel.AVCLevel5:
284 | return "5";
285 | case CodecProfileLevel.AVCLevel51:
286 | return "51";
287 | case 65536: // CodecProfileLevel.AVCLevel52:
288 | return "52";
289 | default:
290 | return "0";
291 | }
292 | }
293 | }
294 |
--------------------------------------------------------------------------------
/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/AndroidMediaPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2006 The Android Open Source Project
3 | * Copyright (C) 2013 Zhang Rui
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package tv.danmaku.ijk.media.player;
19 |
20 | import android.annotation.TargetApi;
21 | import android.content.Context;
22 | import android.media.AudioManager;
23 | import android.media.MediaDataSource;
24 | import android.media.MediaPlayer;
25 | import android.net.Uri;
26 | import android.os.Build;
27 | import android.text.TextUtils;
28 | import android.view.Surface;
29 | import android.view.SurfaceHolder;
30 |
31 | import java.io.FileDescriptor;
32 | import java.io.IOException;
33 | import java.lang.ref.WeakReference;
34 | import java.util.Map;
35 |
36 | import tv.danmaku.ijk.media.player.misc.AndroidTrackInfo;
37 | import tv.danmaku.ijk.media.player.misc.IMediaDataSource;
38 | import tv.danmaku.ijk.media.player.misc.ITrackInfo;
39 | import tv.danmaku.ijk.media.player.pragma.DebugLog;
40 |
41 | public class AndroidMediaPlayer extends AbstractMediaPlayer {
42 | private final MediaPlayer mInternalMediaPlayer;
43 | private final AndroidMediaPlayerListenerHolder mInternalListenerAdapter;
44 | private String mDataSource;
45 | private MediaDataSource mMediaDataSource;
46 |
47 | private final Object mInitLock = new Object();
48 | private boolean mIsReleased;
49 |
50 | private static MediaInfo sMediaInfo;
51 |
52 | public AndroidMediaPlayer() {
53 | synchronized (mInitLock) {
54 | mInternalMediaPlayer = new MediaPlayer();
55 | }
56 | mInternalMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
57 | mInternalListenerAdapter = new AndroidMediaPlayerListenerHolder(this);
58 | attachInternalListeners();
59 | }
60 |
61 | public MediaPlayer getInternalMediaPlayer() {
62 | return mInternalMediaPlayer;
63 | }
64 |
65 | @Override
66 | public void setDisplay(SurfaceHolder sh) {
67 | synchronized (mInitLock) {
68 | if (!mIsReleased) {
69 | mInternalMediaPlayer.setDisplay(sh);
70 | }
71 | }
72 | }
73 |
74 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
75 | @Override
76 | public void setSurface(Surface surface) {
77 | mInternalMediaPlayer.setSurface(surface);
78 | }
79 |
80 | @Override
81 | public void setDataSource(Context context, Uri uri)
82 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
83 | mInternalMediaPlayer.setDataSource(context, uri);
84 | }
85 |
86 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
87 | @Override
88 | public void setDataSource(Context context, Uri uri, Map headers)
89 | throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
90 | mInternalMediaPlayer.setDataSource(context, uri, headers);
91 | }
92 |
93 | @Override
94 | public void setDataSource(FileDescriptor fd)
95 | throws IOException, IllegalArgumentException, IllegalStateException {
96 | mInternalMediaPlayer.setDataSource(fd);
97 | }
98 |
99 | @Override
100 | public void setDataSource(String path) throws IOException,
101 | IllegalArgumentException, SecurityException, IllegalStateException {
102 | mDataSource = path;
103 |
104 | Uri uri = Uri.parse(path);
105 | String scheme = uri.getScheme();
106 | if (!TextUtils.isEmpty(scheme) && scheme.equalsIgnoreCase("file")) {
107 | mInternalMediaPlayer.setDataSource(uri.getPath());
108 | } else {
109 | mInternalMediaPlayer.setDataSource(path);
110 | }
111 | }
112 |
113 | @TargetApi(Build.VERSION_CODES.M)
114 | @Override
115 | public void setDataSource(IMediaDataSource mediaDataSource) {
116 | releaseMediaDataSource();
117 |
118 | mMediaDataSource = new MediaDataSourceProxy(mediaDataSource);
119 | mInternalMediaPlayer.setDataSource(mMediaDataSource);
120 | }
121 |
122 | @TargetApi(Build.VERSION_CODES.M)
123 | private static class MediaDataSourceProxy extends MediaDataSource {
124 | private final IMediaDataSource mMediaDataSource;
125 |
126 | public MediaDataSourceProxy(IMediaDataSource mediaDataSource) {
127 | mMediaDataSource = mediaDataSource;
128 | }
129 |
130 | @Override
131 | public int readAt(long position, byte[] buffer, int offset, int size) throws IOException {
132 | return mMediaDataSource.readAt(position, buffer, offset, size);
133 | }
134 |
135 | @Override
136 | public long getSize() throws IOException {
137 | return mMediaDataSource.getSize();
138 | }
139 |
140 | @Override
141 | public void close() throws IOException {
142 | mMediaDataSource.close();
143 | }
144 | }
145 |
146 | @Override
147 | public String getDataSource() {
148 | return mDataSource;
149 | }
150 |
151 | private void releaseMediaDataSource() {
152 | if (mMediaDataSource != null) {
153 | try {
154 | mMediaDataSource.close();
155 | } catch (IOException e) {
156 | e.printStackTrace();
157 | }
158 | mMediaDataSource = null;
159 | }
160 | }
161 |
162 | @Override
163 | public void prepareAsync() throws IllegalStateException {
164 | mInternalMediaPlayer.prepareAsync();
165 | }
166 |
167 | @Override
168 | public void start() throws IllegalStateException {
169 | mInternalMediaPlayer.start();
170 | }
171 |
172 | @Override
173 | public void stop() throws IllegalStateException {
174 | mInternalMediaPlayer.stop();
175 | }
176 |
177 | @Override
178 | public void pause() throws IllegalStateException {
179 | mInternalMediaPlayer.pause();
180 | }
181 |
182 | @Override
183 | public void setScreenOnWhilePlaying(boolean screenOn) {
184 | mInternalMediaPlayer.setScreenOnWhilePlaying(screenOn);
185 | }
186 |
187 | @Override
188 | public ITrackInfo[] getTrackInfo() {
189 | return AndroidTrackInfo.fromMediaPlayer(mInternalMediaPlayer);
190 | }
191 |
192 | @Override
193 | public int getVideoWidth() {
194 | return mInternalMediaPlayer.getVideoWidth();
195 | }
196 |
197 | @Override
198 | public int getVideoHeight() {
199 | return mInternalMediaPlayer.getVideoHeight();
200 | }
201 |
202 | @Override
203 | public int getVideoSarNum() {
204 | return 1;
205 | }
206 |
207 | @Override
208 | public int getVideoSarDen() {
209 | return 1;
210 | }
211 |
212 | @Override
213 | public boolean isPlaying() {
214 | try {
215 | return mInternalMediaPlayer.isPlaying();
216 | } catch (IllegalStateException e) {
217 | DebugLog.printStackTrace(e);
218 | return false;
219 | }
220 | }
221 |
222 | @Override
223 | public void seekTo(long msec) throws IllegalStateException {
224 | mInternalMediaPlayer.seekTo((int) msec);
225 | }
226 |
227 | @Override
228 | public long getCurrentPosition() {
229 | try {
230 | return mInternalMediaPlayer.getCurrentPosition();
231 | } catch (IllegalStateException e) {
232 | DebugLog.printStackTrace(e);
233 | return 0;
234 | }
235 | }
236 |
237 | @Override
238 | public long getDuration() {
239 | try {
240 | return mInternalMediaPlayer.getDuration();
241 | } catch (IllegalStateException e) {
242 | DebugLog.printStackTrace(e);
243 | return 0;
244 | }
245 | }
246 |
247 | @Override
248 | public void release() {
249 | mIsReleased = true;
250 | mInternalMediaPlayer.release();
251 | releaseMediaDataSource();
252 | resetListeners();
253 | attachInternalListeners();
254 | }
255 |
256 | @Override
257 | public void reset() {
258 | try {
259 | mInternalMediaPlayer.reset();
260 | } catch (IllegalStateException e) {
261 | DebugLog.printStackTrace(e);
262 | }
263 | releaseMediaDataSource();
264 | resetListeners();
265 | attachInternalListeners();
266 | }
267 |
268 | @Override
269 | public void setLooping(boolean looping) {
270 | mInternalMediaPlayer.setLooping(looping);
271 | }
272 |
273 | @Override
274 | public boolean isLooping() {
275 | return mInternalMediaPlayer.isLooping();
276 | }
277 |
278 | @Override
279 | public void setVolume(float leftVolume, float rightVolume) {
280 | mInternalMediaPlayer.setVolume(leftVolume, rightVolume);
281 | }
282 |
283 | @Override
284 | public int getAudioSessionId() {
285 | return mInternalMediaPlayer.getAudioSessionId();
286 | }
287 |
288 | @Override
289 | public MediaInfo getMediaInfo() {
290 | if (sMediaInfo == null) {
291 | MediaInfo module = new MediaInfo();
292 |
293 | module.mVideoDecoder = "android";
294 | module.mVideoDecoderImpl = "HW";
295 |
296 | module.mAudioDecoder = "android";
297 | module.mAudioDecoderImpl = "HW";
298 |
299 | sMediaInfo = module;
300 | }
301 |
302 | return sMediaInfo;
303 | }
304 |
305 | @Override
306 | public void setLogEnabled(boolean enable) {
307 | }
308 |
309 | @Override
310 | public boolean isPlayable() {
311 | return true;
312 | }
313 |
314 | /*--------------------
315 | * misc
316 | */
317 | @Override
318 | public void setWakeMode(Context context, int mode) {
319 | mInternalMediaPlayer.setWakeMode(context, mode);
320 | }
321 |
322 | @Override
323 | public void setAudioStreamType(int streamtype) {
324 | mInternalMediaPlayer.setAudioStreamType(streamtype);
325 | }
326 |
327 | @Override
328 | public void setKeepInBackground(boolean keepInBackground) {
329 | }
330 |
331 | /*--------------------
332 | * Listeners adapter
333 | */
334 | private void attachInternalListeners() {
335 | mInternalMediaPlayer.setOnPreparedListener(mInternalListenerAdapter);
336 | mInternalMediaPlayer
337 | .setOnBufferingUpdateListener(mInternalListenerAdapter);
338 | mInternalMediaPlayer.setOnCompletionListener(mInternalListenerAdapter);
339 | mInternalMediaPlayer
340 | .setOnSeekCompleteListener(mInternalListenerAdapter);
341 | mInternalMediaPlayer
342 | .setOnVideoSizeChangedListener(mInternalListenerAdapter);
343 | mInternalMediaPlayer.setOnErrorListener(mInternalListenerAdapter);
344 | mInternalMediaPlayer.setOnInfoListener(mInternalListenerAdapter);
345 | }
346 |
347 | private class AndroidMediaPlayerListenerHolder implements
348 | MediaPlayer.OnPreparedListener, MediaPlayer.OnCompletionListener,
349 | MediaPlayer.OnBufferingUpdateListener,
350 | MediaPlayer.OnSeekCompleteListener,
351 | MediaPlayer.OnVideoSizeChangedListener,
352 | MediaPlayer.OnErrorListener, MediaPlayer.OnInfoListener {
353 | public final WeakReference mWeakMediaPlayer;
354 |
355 | public AndroidMediaPlayerListenerHolder(AndroidMediaPlayer mp) {
356 | mWeakMediaPlayer = new WeakReference(mp);
357 | }
358 |
359 | @Override
360 | public boolean onInfo(MediaPlayer mp, int what, int extra) {
361 | AndroidMediaPlayer self = mWeakMediaPlayer.get();
362 | return self != null && notifyOnInfo(what, extra);
363 |
364 | }
365 |
366 | @Override
367 | public boolean onError(MediaPlayer mp, int what, int extra) {
368 | AndroidMediaPlayer self = mWeakMediaPlayer.get();
369 | return self != null && notifyOnError(what, extra);
370 |
371 | }
372 |
373 | @Override
374 | public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
375 | AndroidMediaPlayer self = mWeakMediaPlayer.get();
376 | if (self == null)
377 | return;
378 |
379 | notifyOnVideoSizeChanged(width, height, 1, 1);
380 | }
381 |
382 | @Override
383 | public void onSeekComplete(MediaPlayer mp) {
384 | AndroidMediaPlayer self = mWeakMediaPlayer.get();
385 | if (self == null)
386 | return;
387 |
388 | notifyOnSeekComplete();
389 | }
390 |
391 | @Override
392 | public void onBufferingUpdate(MediaPlayer mp, int percent) {
393 | AndroidMediaPlayer self = mWeakMediaPlayer.get();
394 | if (self == null)
395 | return;
396 |
397 | notifyOnBufferingUpdate(percent);
398 | }
399 |
400 | @Override
401 | public void onCompletion(MediaPlayer mp) {
402 | AndroidMediaPlayer self = mWeakMediaPlayer.get();
403 | if (self == null)
404 | return;
405 |
406 | notifyOnCompletion();
407 | }
408 |
409 | @Override
410 | public void onPrepared(MediaPlayer mp) {
411 | AndroidMediaPlayer self = mWeakMediaPlayer.get();
412 | if (self == null)
413 | return;
414 |
415 | notifyOnPrepared();
416 | }
417 | }
418 | }
419 |
--------------------------------------------------------------------------------