├── .gitignore
├── LICENSE
├── README.en.md
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── components-zh.puml
├── components.puml
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── cpp
│ ├── CMakeLists.txt
│ ├── base
│ │ ├── Log.cpp
│ │ ├── Log.h
│ │ ├── LoopThread.cpp
│ │ ├── LoopThread.h
│ │ ├── LoopThreadHelper.cpp
│ │ ├── LoopThreadHelper.h
│ │ ├── XThread.cpp
│ │ ├── XThread.h
│ │ ├── XTick.c
│ │ └── XTick.h
│ ├── codec
│ │ ├── Codec.h
│ │ ├── FfmpegAudioDecoder.cpp
│ │ ├── FfmpegAudioDecoder.h
│ │ ├── FfmpegVideoDecoder.cpp
│ │ ├── FfmpegVideoDecoder.h
│ │ ├── MediaCodecAudioDecoder.cpp
│ │ ├── MediaCodecAudioDecoder.h
│ │ ├── MediaCodecVideoDecoder.cpp
│ │ ├── MediaCodecVideoDecoder.h
│ │ └── ffmpeg
│ │ │ ├── libavcodec
│ │ │ ├── avcodec.h
│ │ │ ├── avdct.h
│ │ │ ├── avfft.h
│ │ │ ├── d3d11va.h
│ │ │ ├── dirac.h
│ │ │ ├── dv_profile.h
│ │ │ ├── dxva2.h
│ │ │ ├── jni.h
│ │ │ ├── mediacodec.h
│ │ │ ├── qsv.h
│ │ │ ├── vaapi.h
│ │ │ ├── vda.h
│ │ │ ├── vdpau.h
│ │ │ ├── version.h
│ │ │ ├── videotoolbox.h
│ │ │ ├── vorbis_parser.h
│ │ │ └── xvmc.h
│ │ │ ├── libavdevice
│ │ │ ├── avdevice.h
│ │ │ └── version.h
│ │ │ ├── libavfilter
│ │ │ ├── avfilter.h
│ │ │ ├── avfiltergraph.h
│ │ │ ├── buffersink.h
│ │ │ ├── buffersrc.h
│ │ │ └── version.h
│ │ │ ├── libavformat
│ │ │ ├── avformat.h
│ │ │ ├── avio.h
│ │ │ └── version.h
│ │ │ ├── libavutil
│ │ │ ├── adler32.h
│ │ │ ├── aes.h
│ │ │ ├── aes_ctr.h
│ │ │ ├── attributes.h
│ │ │ ├── audio_fifo.h
│ │ │ ├── avassert.h
│ │ │ ├── avconfig.h
│ │ │ ├── avstring.h
│ │ │ ├── avutil.h
│ │ │ ├── base64.h
│ │ │ ├── blowfish.h
│ │ │ ├── bprint.h
│ │ │ ├── bswap.h
│ │ │ ├── buffer.h
│ │ │ ├── camellia.h
│ │ │ ├── cast5.h
│ │ │ ├── channel_layout.h
│ │ │ ├── common.h
│ │ │ ├── cpu.h
│ │ │ ├── crc.h
│ │ │ ├── des.h
│ │ │ ├── dict.h
│ │ │ ├── display.h
│ │ │ ├── downmix_info.h
│ │ │ ├── error.h
│ │ │ ├── eval.h
│ │ │ ├── ffversion.h
│ │ │ ├── fifo.h
│ │ │ ├── file.h
│ │ │ ├── frame.h
│ │ │ ├── hash.h
│ │ │ ├── hmac.h
│ │ │ ├── hwcontext.h
│ │ │ ├── hwcontext_cuda.h
│ │ │ ├── hwcontext_dxva2.h
│ │ │ ├── hwcontext_qsv.h
│ │ │ ├── hwcontext_vaapi.h
│ │ │ ├── hwcontext_vdpau.h
│ │ │ ├── imgutils.h
│ │ │ ├── intfloat.h
│ │ │ ├── intreadwrite.h
│ │ │ ├── lfg.h
│ │ │ ├── log.h
│ │ │ ├── lzo.h
│ │ │ ├── macros.h
│ │ │ ├── mastering_display_metadata.h
│ │ │ ├── mathematics.h
│ │ │ ├── md5.h
│ │ │ ├── mem.h
│ │ │ ├── motion_vector.h
│ │ │ ├── murmur3.h
│ │ │ ├── opt.h
│ │ │ ├── parseutils.h
│ │ │ ├── pixdesc.h
│ │ │ ├── pixelutils.h
│ │ │ ├── pixfmt.h
│ │ │ ├── random_seed.h
│ │ │ ├── rational.h
│ │ │ ├── rc4.h
│ │ │ ├── replaygain.h
│ │ │ ├── ripemd.h
│ │ │ ├── samplefmt.h
│ │ │ ├── sha.h
│ │ │ ├── sha512.h
│ │ │ ├── spherical.h
│ │ │ ├── stereo3d.h
│ │ │ ├── tea.h
│ │ │ ├── threadmessage.h
│ │ │ ├── time.h
│ │ │ ├── timecode.h
│ │ │ ├── timestamp.h
│ │ │ ├── tree.h
│ │ │ ├── twofish.h
│ │ │ ├── version.h
│ │ │ └── xtea.h
│ │ │ ├── libswresample
│ │ │ ├── swresample.h
│ │ │ └── version.h
│ │ │ └── libswscale
│ │ │ ├── swscale.h
│ │ │ └── version.h
│ ├── demuxing
│ │ ├── adtsenc.c
│ │ ├── adtsenc.h
│ │ ├── avformat_def.c
│ │ └── avformat_def.h
│ ├── j4a
│ │ ├── AudioTrackJni.cpp
│ │ ├── AudioTrackJni.h
│ │ ├── GPlayerJni.cpp
│ │ ├── GPlayerJni.h
│ │ ├── JniHelper.cpp
│ │ ├── JniHelper.h
│ │ └── MainJni.cpp
│ ├── jniLibs
│ │ ├── arm64-v8a
│ │ │ └── ffmpeg-lite
│ │ │ │ ├── build_free_arm64_lite.sh
│ │ │ │ ├── libavcodec.a
│ │ │ │ ├── libavdevice.a
│ │ │ │ ├── libavfilter.a
│ │ │ │ ├── libavformat.a
│ │ │ │ ├── libavutil.a
│ │ │ │ ├── libswresample.a
│ │ │ │ └── libswscale.a
│ │ └── armeabi-v7a
│ │ │ └── ffmpeg-lite
│ │ │ ├── build_free_arm_lite.sh
│ │ │ ├── libavcodec.a
│ │ │ ├── libavdevice.a
│ │ │ ├── libavfilter.a
│ │ │ ├── libavformat.a
│ │ │ ├── libavutil.a
│ │ │ ├── libswresample.a
│ │ │ └── libswscale.a
│ ├── media
│ │ ├── MediaData.cpp
│ │ ├── MediaData.h
│ │ ├── MediaHelper.cpp
│ │ └── MediaHelper.h
│ ├── player
│ │ ├── DecoderHelper.cpp
│ │ ├── DecoderHelper.h
│ │ ├── DemuxerHelper.cpp
│ │ ├── DemuxerHelper.h
│ │ ├── GPlayer.cpp
│ │ ├── GPlayer.h
│ │ ├── MessageHelper.cpp
│ │ ├── MessageHelper.h
│ │ ├── RenderHelper.cpp
│ │ └── RenderHelper.h
│ ├── render
│ │ ├── AudioRenderer.cpp
│ │ ├── AudioRenderer.h
│ │ ├── EglRenderer.cpp
│ │ ├── EglRenderer.h
│ │ ├── SurfaceVideoRenderer.cpp
│ │ ├── SurfaceVideoRenderer.h
│ │ ├── VideoRenderer.h
│ │ ├── YuvGlesProgram.cpp
│ │ ├── YuvGlesProgram.h
│ │ ├── YuvVideoRenderer.cpp
│ │ └── YuvVideoRenderer.h
│ └── source
│ │ ├── ConcurrentQueue.h
│ │ ├── FrameSource.cpp
│ │ ├── FrameSource.h
│ │ ├── MessageSource.cpp
│ │ ├── MessageSource.h
│ │ ├── PacketSource.cpp
│ │ └── PacketSource.h
│ ├── java
│ └── com
│ │ └── gibbs
│ │ └── gplayer
│ │ ├── GPlayer.java
│ │ └── GPlayerView.java
│ └── res
│ └── values
│ └── strings.xml
├── sample
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── playlist.json
│ ├── ic_launcher-web.png
│ ├── ic_launcher_round-web.png
│ ├── java
│ └── com
│ │ └── gibbs
│ │ └── gplayer
│ │ └── sample
│ │ ├── BaseActivity.kt
│ │ ├── LogUtils.java
│ │ ├── MainActivity.kt
│ │ ├── PlayListActivity.kt
│ │ ├── model
│ │ ├── PlayList.java
│ │ ├── VideoItem.kt
│ │ └── VideoItemHolder.kt
│ │ └── widget
│ │ ├── DividerItemDecoration.java
│ │ ├── GVideoView.java
│ │ └── OvalImageView.kt
│ └── res
│ ├── drawable-anydpi
│ ├── ic_pause_video.xml
│ ├── ic_play_video.xml
│ └── ic_video_play.xml
│ ├── drawable-hdpi
│ ├── ic_pause_video.png
│ ├── ic_play_video.png
│ └── ic_video_play.png
│ ├── drawable-mdpi
│ ├── ic_pause_video.png
│ ├── ic_play_video.png
│ └── ic_video_play.png
│ ├── drawable-xhdpi
│ ├── ic_pause_video.png
│ ├── ic_play_video.png
│ └── ic_video_play.png
│ ├── drawable-xxhdpi
│ ├── ic_pause_video.png
│ ├── ic_play_video.png
│ └── ic_video_play.png
│ ├── layout
│ ├── activity_main.xml
│ ├── activity_play_list.xml
│ ├── item_video.xml
│ └── view_video.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── values-zh-rCN
│ └── strings.xml
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | /.idea/caches
6 | /.idea/libraries
7 | /.idea/modules.xml
8 | /.idea/workspace.xml
9 | /.idea/navEditor.xml
10 | /.idea/assetWizardSettings.xml
11 | /.idea/vcs.xml
12 | .DS_Store
13 | /build
14 | /captures
15 | /sample/release
16 | .externalNativeBuild
17 | .cxx
18 |
--------------------------------------------------------------------------------
/README.en.md:
--------------------------------------------------------------------------------
1 | # GPlayer
2 |
3 | #### Introduce
4 | GPlayer is a video player frame base on ffmpeg and mediacodec。GPlayer support software decoding and hardware decoding, then render via AudioTrack and OpenGL。
5 |
6 | #### Download
7 | [](https://www.jitpack.io/#GibbsQin/GPlayer)
8 |
9 | allprojects {
10 | repositories {
11 | ...
12 | maven { url 'https://www.jitpack.io' }
13 | }
14 | }
15 |
16 | dependencies {
17 | implementation 'com.github.GibbsQin:GPlayer:+
18 | }
19 |
20 | #### Usage
21 |
30 |
31 | private GPlayerView mVideoView;
32 | mVideoView = findViewById(R.id.gl_surface_view);
33 | mVideoView.setDataSource(url);
34 | mVideoView.prepare()
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GPlayer
2 |
3 | [README English](README.en.md)
4 |
5 | #### 介绍
6 | GPlayer是一款基于 ffmpeg、mediacodec 的Android视频播放器框架。同时支持软解码和硬解码,通过OpenGL和AudioTrack进行渲染。
7 |
8 | #### 下载
9 | [](https://www.jitpack.io/#GibbsQin/GPlayer)
10 |
11 | allprojects {
12 | repositories {
13 | ...
14 | maven { url 'https://www.jitpack.io' }
15 | }
16 | }
17 |
18 | dependencies {
19 | implementation 'com.github.GibbsQin:GPlayer:+'
20 | }
21 |
22 | #### 使用
23 |
32 |
33 | private GPlayerView mVideoView;
34 | mVideoView = findViewById(R.id.gl_surface_view);
35 | mVideoView.setDataSource(url);
36 | mVideoView.prepare()
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.72'
5 | ext.versionCode = 7
6 | ext.versionName = "1.1"
7 | repositories {
8 | google()
9 | jcenter()
10 |
11 | }
12 | dependencies {
13 | classpath 'com.android.tools.build:gradle:3.2.1'
14 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
15 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
16 |
17 | // NOTE: Do not place your application dependencies here; they belong
18 | // in the individual module build.gradle files
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | google()
25 | jcenter()
26 | maven { url 'https://www.jitpack.io' }
27 |
28 | }
29 | }
30 |
31 | task clean(type: Delete) {
32 | delete rootProject.buildDir
33 | }
34 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Aug 04 12:04:46 CST 2020
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-4.9-all.zip
7 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 |
4 | group='com.github.GibbsQin'
5 |
6 | android {
7 | compileSdkVersion 29
8 | buildToolsVersion "29.0.2"
9 | defaultConfig {
10 | minSdkVersion 21
11 | targetSdkVersion 29
12 | versionCode rootProject.ext.versionCode
13 | versionName rootProject.ext.versionName
14 | sourceSets {
15 | main {
16 | jniLibs.srcDirs = ['src/main/cpp/jniLibs']
17 | }
18 | }
19 | externalNativeBuild {
20 | cmake {
21 | arguments '-DANDROID_PLATFORM=android-21'
22 | abiFilters 'armeabi-v7a', 'arm64-v8a'
23 | }
24 | }
25 | }
26 | buildTypes {
27 | release {
28 | minifyEnabled false
29 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
30 | }
31 | }
32 | externalNativeBuild {
33 | cmake {
34 | path "src/main/cpp/CMakeLists.txt"
35 | }
36 | }
37 | }
38 |
39 | dependencies {
40 | implementation fileTree(dir: 'libs', include: ['*.jar'])
41 | implementation 'androidx.appcompat:appcompat:1.1.0'
42 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
43 | }
44 |
--------------------------------------------------------------------------------
/library/components-zh.puml:
--------------------------------------------------------------------------------
1 | @startuml
2 |
3 | interface "Data" as DATA
4 | component [Protocol]
5 |
6 | package CompressedSource #Yellow {
7 | [AudioCompressedQueue]
8 | [VideoCompressedQueue]
9 | }
10 |
11 | package "GPlayerIml" {
12 | node "AudioThread" {
13 | [AudioLoop]
14 | [AudioInterceptors]
15 | }
16 | node "VideoThread" {
17 | [VideoLoop]
18 | [VideoInterceptors]
19 | }
20 | }
21 |
22 | package "GPlayer" {
23 | node "AudioRenderThread" {
24 | [AudioRenderLoop]
25 | }
26 | node "VideoRenderThread" {
27 | [VideoRenderLoop]
28 | }
29 | }
30 |
31 | package DecodedSource #Green {
32 | [AudioDecodedQueue]
33 | [VideoDecodedQueue]
34 | }
35 |
36 | package "Render" #656565 {
37 | node "AudioRender" {
38 | [AudioTrack]
39 | }
40 | node "VideoRender" {
41 | [OpenGL]
42 | }
43 | }
44 |
45 | [DATA] .up.>[Protocol] : av_init
46 | [DATA] .up.>[Protocol] : av_feed_audio
47 | [DATA] .up.>[Protocol] : av_feed_video
48 | [DATA] .up.>[Protocol] : av_destroy
49 |
50 | [Protocol] .up.>[AudioCompressedQueue]
51 | [Protocol] .up.>[VideoCompressedQueue]
52 |
53 | [AudioCompressedQueue] -up-> [AudioLoop]
54 | [AudioLoop] -left-> [AudioInterceptors]
55 | [AudioInterceptors] -right-> [AudioLoop]
56 |
57 | [VideoCompressedQueue] -up-> [VideoLoop]
58 | [VideoLoop] -right-> [VideoInterceptors]
59 | [VideoInterceptors] -left-> [VideoLoop]
60 |
61 | [VideoLoop] -up-> [VideoDecodedQueue]
62 | [AudioLoop] -up-> [AudioDecodedQueue]
63 |
64 | [AudioDecodedQueue] -up-> [AudioRenderLoop]
65 | [VideoDecodedQueue] -up-> [VideoRenderLoop]
66 |
67 | [AudioRenderLoop] --> [AudioRenderLoop]
68 | [VideoRenderLoop] --> [VideoRenderLoop]
69 | [AudioRenderLoop] -up-> [AudioTrack]
70 | [VideoRenderLoop] -up-> [OpenGL]
71 |
72 | note right of CompressedSource
73 | 媒体压缩数据
74 | end note
75 |
76 | note bottom of [DATA]
77 | 媒体源文件,只要通过相应的协议,
78 | 将数据通过以下4个接口上报数据就
79 | 可以播放:
80 | 1. av_init(上报媒体头信息)
81 | 2. av_feed_audio(上报音频数据)
82 | 3. av_feed_video(上报视频数据)
83 | 4. av_destroy(结束上报)
84 | end note
85 |
86 | note right of DecodedSource
87 | 媒体解码数据
88 | end note
89 |
90 | @enduml
--------------------------------------------------------------------------------
/library/components.puml:
--------------------------------------------------------------------------------
1 | @startuml
2 |
3 | interface "Data" as DATA
4 | component [Protocol]
5 |
6 | package CompressedSource #Yellow {
7 | [AudioCompressedQueue]
8 | [VideoCompressedQueue]
9 | }
10 |
11 | package "GPlayerIml" {
12 | node "AudioThread" {
13 | [AudioLoop]
14 | [AudioInterceptors]
15 | }
16 | node "VideoThread" {
17 | [VideoLoop]
18 | [VideoInterceptors]
19 | }
20 | }
21 |
22 | package "GPlayer" {
23 | node "AudioRenderThread" {
24 | [AudioRenderLoop]
25 | }
26 | node "VideoRenderThread" {
27 | [VideoRenderLoop]
28 | }
29 | }
30 |
31 | package DecodedSource #Green {
32 | [AudioDecodedQueue]
33 | [VideoDecodedQueue]
34 | }
35 |
36 | package "Render" #656565 {
37 | node "AudioRender" {
38 | [AudioTrack]
39 | }
40 | node "VideoRender" {
41 | [OpenGL]
42 | }
43 | }
44 |
45 | [DATA] .up.>[Protocol] : av_init
46 | [DATA] .up.>[Protocol] : av_feed_audio
47 | [DATA] .up.>[Protocol] : av_feed_video
48 | [DATA] .up.>[Protocol] : av_destroy
49 |
50 | [Protocol] .up.>[AudioCompressedQueue]
51 | [Protocol] .up.>[VideoCompressedQueue]
52 |
53 | [AudioCompressedQueue] -up-> [AudioLoop]
54 | [AudioLoop] -left-> [AudioInterceptors]
55 | [AudioInterceptors] -right-> [AudioLoop]
56 |
57 | [VideoCompressedQueue] -up-> [VideoLoop]
58 | [VideoLoop] -right-> [VideoInterceptors]
59 | [VideoInterceptors] -left-> [VideoLoop]
60 |
61 | [VideoLoop] -up-> [VideoDecodedQueue]
62 | [AudioLoop] -up-> [AudioDecodedQueue]
63 |
64 | [AudioDecodedQueue] -up-> [AudioRenderLoop]
65 | [VideoDecodedQueue] -up-> [VideoRenderLoop]
66 |
67 | [AudioRenderLoop] --> [AudioRenderLoop]
68 | [VideoRenderLoop] --> [VideoRenderLoop]
69 | [AudioRenderLoop] -up-> [AudioTrack]
70 | [VideoRenderLoop] -up-> [OpenGL]
71 |
72 | note right of CompressedSource
73 | media compressed data
74 | end note
75 |
76 | note bottom of [DATA]
77 | This is media source. The media source can be played when the media data upload via interface below.
78 | 1. av_init(upload the media info)
79 | 2. av_feed_audio(upload audio data)
80 | 3. av_feed_video(upload video data)
81 | 4. av_destroy(media source disconnected)
82 | Developer can customize own protocol but need use the interfaces.
83 | end note
84 |
85 | note right of DecodedSource
86 | media decoded data
87 | end note
88 |
89 | @enduml
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/library/src/main/cpp/base/Log.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #if defined(_WIN32)
7 | #define _CRT_SECURE_NO_WARNINGS
8 | #endif
9 |
10 | #include "Log.h"
11 |
12 | #include
13 | #include
14 |
15 | #ifdef __ANDROID__
16 | #include
17 | android_LogPriority s_android_logprio[LOG_TRACE + 1] = {
18 | ANDROID_LOG_UNKNOWN,
19 | ANDROID_LOG_FATAL,
20 | ANDROID_LOG_ERROR,
21 | ANDROID_LOG_WARN,
22 | ANDROID_LOG_INFO,
23 | ANDROID_LOG_DEBUG,
24 | ANDROID_LOG_VERBOSE
25 | };
26 |
27 | #endif
28 |
29 | #if defined(_WIN32)
30 | #include
31 | #endif
32 |
33 | void __log_print(int lv, const char *tag, const char *funame, int line, const char *fmt, ...) {
34 | char log_info[2040];
35 | char *buf = log_info;
36 | int ret, len = sizeof(log_info);
37 |
38 | //Android 不需要时间
39 | #ifndef __ANDROID__
40 | if (lv <= LogLevel::LOG_INFO) { // 日志级别不小于INFO则打印时带时间标记
41 | *buf++ = '[';
42 | _get_curtime_str(buf);
43 | //buf = buf + strlen(buf);
44 | buf += 23; // 时间格式为:XXXX - XX - XX XX : XX : XX.XXX 共占23个字节
45 | *buf++ = ']';
46 | *buf++ = ' ';
47 |
48 | len -= buf - log_info;
49 | }
50 |
51 | if (lv <= LogLevel::LOG_WARN) { // 日志级别不小于WARN则打印时带代码行信息
52 | ret = sprintf(buf, "%s line:%-4d ", funame, line);
53 | buf += ret;
54 | len -= ret;
55 | }
56 | #endif
57 |
58 | va_list arglist;
59 | va_start(arglist, fmt);
60 |
61 | int itemLen = buf - log_info;
62 | #if defined( WIN32 )
63 | ret = _vsnprintf(buf, len - 1, fmt, arglist);
64 | #else
65 | ret = vsnprintf(buf, len - 1, fmt, arglist);
66 | #endif
67 | if (ret < 0) {
68 | buf[len - 1] = 0;
69 | buf[len - 2] = '\n';
70 | itemLen += len - 1;
71 | } else
72 | itemLen += ret;
73 |
74 | va_end(arglist);
75 |
76 | #if defined(__ANDROID__)
77 | __android_log_print(s_android_logprio[lv], tag, log_info, "");
78 | #else
79 | //本地输出
80 | printf("Tag=%s %s", tag, log_info);
81 | #endif
82 | }
83 |
--------------------------------------------------------------------------------
/library/src/main/cpp/base/Log.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef __GPLAYER_LOG_H__
7 | #define __GPLAYER_LOG_H__
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | //调试日志开关,1为开,其它为关
14 | #define LOG_OPEN 0
15 |
16 | enum LogLevel
17 | {
18 | LOG_OFF = 0, //!< 不打印日志
19 | LOG_FATAL = 1, //!< 严重
20 | LOG_ERROR = 2, //!< 错误
21 | LOG_WARN = 3, //!< 警告
22 | LOG_INFO = 4, //!< 信息
23 | LOG_DEBUG = 5, //!< 调试
24 | LOG_TRACE = 6, //!< 跟踪
25 | };
26 |
27 | void __log_print(int lv, const char* tag, const char* funame, int line, const char *fmt, ...);
28 |
29 | #define LOGI(TAG, ...) __log_print(LogLevel::LOG_INFO, TAG, __FUNCTION__, __LINE__, __VA_ARGS__)
30 | #define LOGW(TAG, ...) __log_print(LogLevel::LOG_WARN, TAG, __FUNCTION__, __LINE__, __VA_ARGS__)
31 | #define LOGE(TAG, ...) __log_print(LogLevel::LOG_ERROR, TAG, __FUNCTION__, __LINE__, __VA_ARGS__)
32 | #define LOGF(TAG, ...) __log_print(LogLevel::LOG_FATAL, TAG, __FUNCTION__, __LINE__, __VA_ARGS__)
33 |
34 | #if defined(__ANDROID__)
35 | #if(LOG_OPEN == 1)
36 | #define LOGD(TAG,...) __log_print(LogLevel::LOG_DEBUG, TAG, __FUNCTION__, __LINE__, __VA_ARGS__)
37 | #else
38 | #define LOGD(TAG, ...) NULL
39 | #endif
40 | #else
41 | #define LOGD(TAG, ...) __log_print(LogLevel::LOG_DEBUG, TAG, __FUNCTION__, __LINE__, __VA_ARGS__)
42 | #endif
43 |
44 | #ifdef __cplusplus
45 | };
46 | #endif
47 |
48 | #endif // !__GPLAYER_LOG_H__
49 |
--------------------------------------------------------------------------------
/library/src/main/cpp/base/LoopThread.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include "LoopThread.h"
7 |
8 | #include
9 |
10 | LoopThread::LoopThread() {
11 | setFunction(std::bind(&LoopThread::handleRunning, this));
12 | }
13 |
14 | LoopThread::~LoopThread()= default;
15 |
16 | void LoopThread::handleRunning() {
17 | if (startFunc) {
18 | startFunc();
19 | }
20 | if (notifyFunc) {
21 | notifyFunc(NOTIFY_START);
22 | }
23 | isStarted = true;
24 |
25 | while (mRunning) {
26 | if (mPausing) {
27 | std::unique_lock lck(threadLock);
28 | conVar.wait(lck);
29 | continue;
30 | }
31 | if (!updateFunc) {
32 | break;
33 | }
34 | bool hasParams = arg1 >= 0 || arg2 >= 0;
35 | int updateResult = updateFunc(arg1, arg2);
36 | if (hasParams) {
37 | arg1 = -1;
38 | arg2 = -1;
39 | }
40 | if (updateResult == ERROR_EXIST) {
41 | mRunning = false;
42 | continue;
43 | } else if (updateResult == ERROR_PAUSE) {
44 | mPausing = true;
45 | continue;
46 | }
47 | }
48 |
49 | if (endFunc) {
50 | endFunc();
51 | }
52 | if (notifyFunc) {
53 | notifyFunc(NOTIFY_END);
54 | }
55 | isStarted = false;
56 | }
57 |
58 | void LoopThread::setStartFunc(std::function func) {
59 | startFunc = std::move(func);
60 | }
61 |
62 | void LoopThread::setUpdateFunc(std::function func) {
63 | updateFunc = std::move(func);
64 | }
65 |
66 | void LoopThread::setEndFunc(std::function func) {
67 | endFunc = std::move(func);
68 | }
69 |
70 | void LoopThread::setNotifyFunc(std::function func) {
71 | notifyFunc = std::move(func);
72 | }
73 |
74 | void LoopThread::resume() {
75 | XThread::resume();
76 | conVar.notify_all();
77 | }
78 |
79 | bool LoopThread::stop() {
80 | if (isPausing()) {
81 | resume();
82 | }
83 | return XThread::stop();
84 | }
85 |
--------------------------------------------------------------------------------
/library/src/main/cpp/base/LoopThread.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_LOOPTHREAD_H
7 | #define GPLAYER_LOOPTHREAD_H
8 |
9 | #include "XThread.h"
10 | #include
11 | #include
12 | #include
13 |
14 | #define ERROR_EXIST -100
15 | #define ERROR_PAUSE -101
16 |
17 | #define NOTIFY_START 0
18 | #define NOTIFY_END 1
19 |
20 | using namespace std;
21 |
22 | class LoopThread : public XThread {
23 | public:
24 | LoopThread();
25 |
26 | virtual ~LoopThread();
27 |
28 | void setStartFunc(std::function func);
29 |
30 | void setUpdateFunc(std::function func);
31 |
32 | void setEndFunc(std::function func);
33 |
34 | void setNotifyFunc(std::function func);
35 |
36 | void resume() override ;
37 |
38 | bool stop() override ;
39 |
40 | bool hasStarted() {
41 | return isStarted;
42 | }
43 |
44 | void setArgs(int a, long b) {
45 | this->arg1 = a;
46 | this->arg2 = b;
47 | }
48 |
49 | protected:
50 | void handleRunning();
51 |
52 | private:
53 | std::function startFunc;
54 | std::function updateFunc;
55 | std::function endFunc;
56 | std::function notifyFunc;
57 | bool isStarted = false;
58 | std::mutex threadLock;
59 | std::condition_variable conVar;
60 |
61 | int arg1 = -1;
62 | long arg2 = -1;
63 | };
64 |
65 | #endif //GPLAYER_LOOPTHREAD_H
66 |
--------------------------------------------------------------------------------
/library/src/main/cpp/base/LoopThreadHelper.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include "LoopThreadHelper.h"
7 |
8 | LoopThread *
9 | LoopThreadHelper::createLoopThread(const std::function& updateFunc) {
10 | return LoopThreadHelper::createLoopThread(nullptr, updateFunc, nullptr);
11 | }
12 |
13 | LoopThread *LoopThreadHelper::createLoopThread(const std::function& updateFunc,
14 | const std::function& notifyFunc) {
15 | return LoopThreadHelper::createLoopThread(nullptr, updateFunc, nullptr, notifyFunc);
16 | }
17 |
18 | LoopThread *LoopThreadHelper::createLoopThread(const std::function& startFunc,
19 | const std::function& updateFunc,
20 | const std::function& endFunc) {
21 | return LoopThreadHelper::createLoopThread(startFunc, updateFunc, endFunc, nullptr);
22 | }
23 |
24 | LoopThread *LoopThreadHelper::createLoopThread(const std::function& startFunc,
25 | const std::function& updateFunc,
26 | const std::function& endFunc,
27 | const std::function& notifyFunc) {
28 | auto *thread = new LoopThread();
29 | if (startFunc != nullptr) {
30 | thread->setStartFunc(startFunc);
31 | }
32 | if (updateFunc != nullptr) {
33 | thread->setUpdateFunc(updateFunc);
34 | }
35 | if (endFunc != nullptr) {
36 | thread->setEndFunc(endFunc);
37 | }
38 | if (notifyFunc != nullptr) {
39 | thread->setNotifyFunc(notifyFunc);
40 | }
41 | thread->start();
42 | return thread;
43 | }
44 |
--------------------------------------------------------------------------------
/library/src/main/cpp/base/LoopThreadHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_LOOPTHREADHELPER_H
7 | #define GPLAYER_LOOPTHREADHELPER_H
8 |
9 |
10 | #include "LoopThread.h"
11 | #include
12 |
13 | class LoopThreadHelper {
14 | public:
15 | static LoopThread *createLoopThread(const std::function& updateFunc);
16 |
17 | static LoopThread *createLoopThread(const std::function& updateFunc,
18 | const std::function& notifyFunc);
19 |
20 | static LoopThread *createLoopThread(const std::function& startFunc,
21 | const std::function& updateFunc,
22 | const std::function& endFunc);
23 |
24 | static LoopThread *createLoopThread(const std::function& startFunc,
25 | const std::function& updateFunc,
26 | const std::function& endFunc,
27 | const std::function& notifyFunc);
28 | };
29 |
30 |
31 | #endif //GPLAYER_LOOPTHREADHELPER_H
32 |
--------------------------------------------------------------------------------
/library/src/main/cpp/base/XThread.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include "XThread.h"
7 | #include "Log.h"
8 |
9 | #define TAG "Thread"
10 |
11 | XThread::XThread() = default;
12 |
13 | XThread::~XThread() = default;
14 |
15 | bool XThread::start() {
16 | if (mRunning){
17 | return false;
18 | }
19 |
20 | if(!mFunc){
21 | LOGE("XThread", "func is not init");
22 | return false;
23 | }
24 |
25 | delete mThread;
26 | mRunning = true;
27 | mThread = new std::thread(mFunc);
28 |
29 | return true;
30 | }
31 |
32 | void XThread::pause() {
33 | mPausing = true;
34 | }
35 |
36 | void XThread::resume() {
37 | mPausing = false;
38 | }
39 |
40 | bool XThread::stop() {
41 | if (!mRunning) {
42 | return true;
43 | }
44 |
45 | mRunning = false;
46 |
47 | return true;
48 | }
49 |
50 | void XThread::join() {
51 | if (mThread != nullptr && mThread->joinable()) {
52 | mThread->join();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/library/src/main/cpp/base/XThread.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef __GPLAYER_THREAD_H__
7 | #define __GPLAYER_THREAD_H__
8 |
9 | #include
10 | #include
11 |
12 | class XThread {
13 | public:
14 | XThread();
15 |
16 | virtual ~XThread();
17 |
18 | virtual bool start();
19 |
20 | virtual void pause();
21 |
22 | virtual void resume();
23 |
24 | virtual bool stop();
25 |
26 | void join();
27 |
28 | bool isAlive() { return mRunning; }
29 |
30 | bool isPausing() { return mPausing; }
31 |
32 | void setFunction(std::function func) { mFunc = func; }
33 |
34 | protected:
35 | volatile bool mRunning = false;
36 |
37 | volatile bool mPausing = false;
38 |
39 | std::thread *mThread = nullptr;
40 |
41 | std::function mFunc;
42 | };
43 |
44 | #endif //__GPLAYER_THREAD_H__
45 |
--------------------------------------------------------------------------------
/library/src/main/cpp/base/XTick.h:
--------------------------------------------------------------------------------
1 | #ifndef __GPLAYER_XTICK_H__
2 | #define __GPLAYER_XTICK_H__
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #define ONE_HOUR (3600 * 1000)
9 | #define ONE_MINUTE (60 * 1000)
10 | #define ONE_SEC (1000)
11 |
12 | #if defined( _WIN32 )
13 | #include
14 |
15 | #ifdef __cplusplus
16 | extern "C" {
17 | #endif
18 |
19 | int64_t getTickCount64();
20 | int32_t get_tick_sec();
21 |
22 | #define getTickCount() GetTickCount()
23 |
24 | const char* _get_curtime_str(char* pbuf);
25 |
26 | #ifdef __cplusplus
27 | }
28 | #endif
29 |
30 | #else
31 |
32 | #ifdef __cplusplus
33 | extern "C" {
34 | #endif
35 |
36 | #if defined(linux) || defined(APP_IOS)
37 |
38 | #include
39 | #include
40 |
41 | #endif
42 |
43 | /**
44 | * 获取当前系统时间:单位毫秒
45 | * @return
46 | */
47 | int64_t getTickCount64();
48 |
49 | /**
50 | * 获取当前系统时间: 单位秒
51 | * @return
52 | */
53 | int32_t get_tick_sec();
54 |
55 | /**
56 | * 获取当前系统时间:单位毫秒
57 | * @return
58 | */
59 | #define getTickCount() (uint32_t)getTickCount64()
60 |
61 | /**
62 | * 获取当前时间字符串
63 | * 输出格式为:XXXX-XX-XX XX:XX:XX.XXX 一共占23个字节。
64 | * @param pbuf 字符串存储buffer
65 | * @return
66 | */
67 | const char *_get_curtime_str(char *pbuf);
68 |
69 | #ifdef __cplusplus
70 | }
71 | #endif
72 |
73 | #endif //_WIN32
74 |
75 | #endif //__GPLAYER_XTICK_H__
76 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/Codec.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_CODEC_H
7 | #define GPLAYER_CODEC_H
8 |
9 | #include "media/MediaData.h"
10 | #include
11 |
12 | extern "C" {
13 | #include
14 | }
15 |
16 | #define TRY_AGAIN -11
17 | #define INVALID_CODEC -12
18 |
19 | /**
20 | * 音频解码器
21 | */
22 | class AudioDecoder {
23 | public:
24 | virtual ~AudioDecoder() {};
25 |
26 | /**
27 | * 初始化
28 | */
29 | virtual void init(AVCodecParameters *codecParameters) = 0;
30 |
31 | /**
32 | * 往解码器输入一帧
33 | * @param inPacket
34 | * @return 结果
35 | */
36 | virtual int send_packet(AVPacket *inPacket) = 0;
37 |
38 | /**
39 | * 从解码器获取解码后的一帧
40 | * @param outFrame
41 | * @return 结果
42 | */
43 | virtual int receive_frame(MediaData *outFrame) = 0;
44 |
45 | /**
46 | * 释放
47 | */
48 | virtual void release() = 0;
49 |
50 | /**
51 | * 重置
52 | */
53 | virtual void reset() = 0;
54 | };
55 |
56 | /**
57 | * 视频解码器
58 | */
59 | class VideoDecoder {
60 | public:
61 | virtual ~VideoDecoder() {};
62 |
63 | /**
64 | * 初始化
65 | */
66 | virtual void init(AVCodecParameters *codecParameters) = 0;
67 |
68 | /**
69 | * 往解码器输入一帧
70 | * @param inPacket
71 | * @return 结果
72 | */
73 | virtual int send_packet(AVPacket *inPacket) = 0;
74 |
75 | /**
76 | * 从解码器获取解码后的一帧
77 | * @param outFrame
78 | * @return 结果
79 | */
80 | virtual int receive_frame(MediaData *outFrame) = 0;
81 |
82 | /**
83 | * 用于MediaCodec渲染一帧
84 | */
85 | virtual void release_buffer() = 0;
86 |
87 | /**
88 | * 释放
89 | */
90 | virtual void release() = 0;
91 |
92 | /**
93 | * 重置
94 | */
95 | virtual void reset() = 0;
96 |
97 | /**
98 | * 设置nativeWindow
99 | * @param nativeWindow
100 | */
101 | virtual void setNativeWindow(ANativeWindow *nativeWindow) = 0;
102 | };
103 |
104 | #endif //GPLAYER_CODEC_H
105 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/FfmpegAudioDecoder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_FFMPEGAUDIODECODER_H
7 | #define GPLAYER_FFMPEGAUDIODECODER_H
8 |
9 | #include "Codec.h"
10 |
11 | extern "C" {
12 | #include
13 | #include
14 | #include
15 | }
16 |
17 | class FfmpegAudioDecoder : public AudioDecoder {
18 | public:
19 | FfmpegAudioDecoder();
20 |
21 | ~FfmpegAudioDecoder();
22 |
23 | void init(AVCodecParameters *codecParameters) override;
24 |
25 | int send_packet(AVPacket *inPacket) override;
26 |
27 | int receive_frame(MediaData *outFrame) override;
28 |
29 | void release() override;
30 |
31 | void reset() override;
32 |
33 | private:
34 | bool isInitSuccess = false;
35 | AVCodecContext *mCodecContext = nullptr;
36 | AVFrame *mOutFrame = nullptr;
37 | };
38 |
39 |
40 | #endif //GPLAYER_FFMPEGAUDIODECODER_H
41 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/FfmpegVideoDecoder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_FFMPEGVIDEODECODER_H
7 | #define GPLAYER_FFMPEGVIDEODECODER_H
8 |
9 | extern "C" {
10 | #include
11 | #include
12 | }
13 |
14 | #include "Codec.h"
15 |
16 | class FfmpegVideoDecoder : public VideoDecoder {
17 | public:
18 |
19 | FfmpegVideoDecoder();
20 |
21 | ~FfmpegVideoDecoder();
22 |
23 | void init(AVCodecParameters *codecParameters) override;
24 |
25 | int send_packet(AVPacket *inPacket) override;
26 |
27 | int receive_frame(MediaData *outFrame) override;
28 |
29 | void release_buffer() override;
30 |
31 | void release() override;
32 |
33 | void reset() override;
34 |
35 | void setNativeWindow(ANativeWindow *nativeWindow) override;
36 |
37 | static void copy_mediadata_from_frame(MediaData *mediaData, AVFrame *frame);
38 |
39 | private:
40 | bool isInitSuccess = false;
41 | AVCodecContext *mCodecContext = nullptr;
42 | AVFrame *mOutFrame = nullptr;
43 | };
44 |
45 |
46 | #endif //GPLAYER_FFMPEGVIDEODECODER_H
47 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/MediaCodecAudioDecoder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_MEDIACODECAUDIODECODER_H
7 | #define GPLAYER_MEDIACODECAUDIODECODER_H
8 |
9 |
10 | #include "MediaCodecVideoDecoder.h"
11 |
12 | extern "C" {
13 | #include
14 | };
15 |
16 | class MediaCodecAudioDecoder : public AudioDecoder {
17 | public:
18 |
19 | MediaCodecAudioDecoder();
20 |
21 | ~MediaCodecAudioDecoder();
22 |
23 | void init(AVCodecParameters *codecParameters) override;
24 |
25 | int send_packet(AVPacket *inPacket) override;
26 |
27 | int receive_frame(MediaData *outFrame) override;
28 |
29 | void release() override;
30 |
31 | void reset() override;
32 |
33 | static void extractFrame(uint8_t *outputBuf, MediaData *outFrame, AMediaCodecBufferInfo info);
34 |
35 | protected:
36 | AMediaCodec *mAMediaCodec = nullptr;
37 | };
38 |
39 |
40 | #endif //GPLAYER_MEDIACODECAUDIODECODER_H
41 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/MediaCodecVideoDecoder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_MEDIACODECVIDEODECODER_H
7 | #define GPLAYER_MEDIACODECVIDEODECODER_H
8 |
9 |
10 | #include
11 | #include "Codec.h"
12 | #include
13 | #include
14 |
15 | class MediaCodecVideoDecoder : public VideoDecoder {
16 | public:
17 |
18 | MediaCodecVideoDecoder();
19 |
20 | ~MediaCodecVideoDecoder();
21 |
22 | void init(AVCodecParameters *codecParameters) override;
23 |
24 | int send_packet(AVPacket *inPacket) override;
25 |
26 | int receive_frame(MediaData *outFrame) override;
27 |
28 | void release_buffer() override;
29 |
30 | void release() override;
31 |
32 | void reset() override;
33 |
34 | void setNativeWindow(ANativeWindow *window) override {
35 | this->nativeWindow = window;
36 | }
37 |
38 | protected:
39 | AMediaCodec *mAMediaCodec;
40 | ANativeWindow *nativeWindow;
41 | int mWidth = 0;
42 | int mHeight = 0;
43 | ssize_t mCurrentBufferId = -1;
44 | };
45 |
46 |
47 | #endif //GPLAYER_MEDIACODECVIDEODECODER_H
48 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavcodec/avdct.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef AVCODEC_AVDCT_H
20 | #define AVCODEC_AVDCT_H
21 |
22 | #include "libavutil/opt.h"
23 |
24 | /**
25 | * AVDCT context.
26 | * @note function pointers can be NULL if the specific features have been
27 | * disabled at build time.
28 | */
29 | typedef struct AVDCT {
30 | const AVClass *av_class;
31 |
32 | void (*idct)(int16_t *block /* align 16 */);
33 |
34 | /**
35 | * IDCT input permutation.
36 | * Several optimized IDCTs need a permutated input (relative to the
37 | * normal order of the reference IDCT).
38 | * This permutation must be performed before the idct_put/add.
39 | * Note, normally this can be merged with the zigzag/alternate scan
40 | * An example to avoid confusion:
41 | * - (->decode coeffs -> zigzag reorder -> dequant -> reference IDCT -> ...)
42 | * - (x -> reference DCT -> reference IDCT -> x)
43 | * - (x -> reference DCT -> simple_mmx_perm = idct_permutation
44 | * -> simple_idct_mmx -> x)
45 | * - (-> decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant
46 | * -> simple_idct_mmx -> ...)
47 | */
48 | uint8_t idct_permutation[64];
49 |
50 | void (*fdct)(int16_t *block /* align 16 */);
51 |
52 |
53 | /**
54 | * DCT algorithm.
55 | * must use AVOptions to set this field.
56 | */
57 | int dct_algo;
58 |
59 | /**
60 | * IDCT algorithm.
61 | * must use AVOptions to set this field.
62 | */
63 | int idct_algo;
64 |
65 | void (*get_pixels)(int16_t *block /* align 16 */,
66 | const uint8_t *pixels /* align 8 */,
67 | ptrdiff_t line_size);
68 |
69 | int bits_per_sample;
70 | } AVDCT;
71 |
72 | /**
73 | * Allocates a AVDCT context.
74 | * This needs to be initialized with avcodec_dct_init() after optionally
75 | * configuring it with AVOptions.
76 | *
77 | * To free it use av_free()
78 | */
79 | AVDCT *avcodec_dct_alloc(void);
80 | int avcodec_dct_init(AVDCT *);
81 |
82 | const AVClass *avcodec_dct_get_class(void);
83 |
84 | #endif /* AVCODEC_AVDCT_H */
85 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavcodec/dxva2.h:
--------------------------------------------------------------------------------
1 | /*
2 | * DXVA2 HW acceleration
3 | *
4 | * copyright (c) 2009 Laurent Aimar
5 | *
6 | * This file is part of FFmpeg.
7 | *
8 | * FFmpeg is free software; you can redistribute it and/or
9 | * modify it under the terms of the GNU Lesser General Public
10 | * License as published by the Free Software Foundation; either
11 | * version 2.1 of the License, or (at your option) any later version.
12 | *
13 | * FFmpeg is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | * Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public
19 | * License along with FFmpeg; if not, write to the Free Software
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef AVCODEC_DXVA2_H
24 | #define AVCODEC_DXVA2_H
25 |
26 | /**
27 | * @file
28 | * @ingroup lavc_codec_hwaccel_dxva2
29 | * Public libavcodec DXVA2 header.
30 | */
31 |
32 | #if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0602
33 | #undef _WIN32_WINNT
34 | #define _WIN32_WINNT 0x0602
35 | #endif
36 |
37 | #include
38 | #include
39 | #include
40 |
41 | /**
42 | * @defgroup lavc_codec_hwaccel_dxva2 DXVA2
43 | * @ingroup lavc_codec_hwaccel
44 | *
45 | * @{
46 | */
47 |
48 | #define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards
49 | #define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO 2 ///< Work around for DXVA2 and old Intel GPUs with ClearVideo interface
50 |
51 | /**
52 | * This structure is used to provides the necessary configurations and data
53 | * to the DXVA2 FFmpeg HWAccel implementation.
54 | *
55 | * The application must make it available as AVCodecContext.hwaccel_context.
56 | */
57 | struct dxva_context {
58 | /**
59 | * DXVA2 decoder object
60 | */
61 | IDirectXVideoDecoder *decoder;
62 |
63 | /**
64 | * DXVA2 configuration used to create the decoder
65 | */
66 | const DXVA2_ConfigPictureDecode *cfg;
67 |
68 | /**
69 | * The number of surface in the surface array
70 | */
71 | unsigned surface_count;
72 |
73 | /**
74 | * The array of Direct3D surfaces used to create the decoder
75 | */
76 | LPDIRECT3DSURFACE9 *surface;
77 |
78 | /**
79 | * A bit field configuring the workarounds needed for using the decoder
80 | */
81 | uint64_t workaround;
82 |
83 | /**
84 | * Private to the FFmpeg AVHWAccel implementation
85 | */
86 | unsigned report_id;
87 | };
88 |
89 | /**
90 | * @}
91 | */
92 |
93 | #endif /* AVCODEC_DXVA2_H */
94 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavcodec/jni.h:
--------------------------------------------------------------------------------
1 | /*
2 | * JNI public API functions
3 | *
4 | * Copyright (c) 2015-2016 Matthieu Bouron
5 | *
6 | * This file is part of FFmpeg.
7 | *
8 | * FFmpeg is free software; you can redistribute it and/or
9 | * modify it under the terms of the GNU Lesser General Public
10 | * License as published by the Free Software Foundation; either
11 | * version 2.1 of the License, or (at your option) any later version.
12 | *
13 | * FFmpeg is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | * Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public
19 | * License along with FFmpeg; if not, write to the Free Software
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef AVCODEC_JNI_H
24 | #define AVCODEC_JNI_H
25 |
26 | /*
27 | * Manually set a Java virtual machine which will be used to retrieve the JNI
28 | * environment. Once a Java VM is set it cannot be changed afterwards, meaning
29 | * you can call multiple times av_jni_set_java_vm with the same Java VM pointer
30 | * however it will error out if you try to set a different Java VM.
31 | *
32 | * @param vm Java virtual machine
33 | * @param log_ctx context used for logging, can be NULL
34 | * @return 0 on success, < 0 otherwise
35 | */
36 | int av_jni_set_java_vm(void *vm, void *log_ctx);
37 |
38 | /*
39 | * Get the Java virtual machine which has been set with av_jni_set_java_vm.
40 | *
41 | * @param vm Java virtual machine
42 | * @return a pointer to the Java virtual machine
43 | */
44 | void *av_jni_get_java_vm(void *log_ctx);
45 |
46 | #endif /* AVCODEC_JNI_H */
47 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavcodec/vorbis_parser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | /**
20 | * @file
21 | * A public API for Vorbis parsing
22 | *
23 | * Determines the duration for each packet.
24 | */
25 |
26 | #ifndef AVCODEC_VORBIS_PARSER_H
27 | #define AVCODEC_VORBIS_PARSER_H
28 |
29 | #include
30 |
31 | typedef struct AVVorbisParseContext AVVorbisParseContext;
32 |
33 | /**
34 | * Allocate and initialize the Vorbis parser using headers in the extradata.
35 | *
36 | * @param avctx codec context
37 | * @param s Vorbis parser context
38 | */
39 | AVVorbisParseContext *av_vorbis_parse_init(const uint8_t *extradata,
40 | int extradata_size);
41 |
42 | /**
43 | * Free the parser and everything associated with it.
44 | */
45 | void av_vorbis_parse_free(AVVorbisParseContext **s);
46 |
47 | #define VORBIS_FLAG_HEADER 0x00000001
48 | #define VORBIS_FLAG_COMMENT 0x00000002
49 | #define VORBIS_FLAG_SETUP 0x00000004
50 |
51 | /**
52 | * Get the duration for a Vorbis packet.
53 | *
54 | * If @p flags is @c NULL,
55 | * special frames are considered invalid.
56 | *
57 | * @param s Vorbis parser context
58 | * @param buf buffer containing a Vorbis frame
59 | * @param buf_size size of the buffer
60 | * @param flags flags for special frames
61 | */
62 | int av_vorbis_parse_frame_flags(AVVorbisParseContext *s, const uint8_t *buf,
63 | int buf_size, int *flags);
64 |
65 | /**
66 | * Get the duration for a Vorbis packet.
67 | *
68 | * @param s Vorbis parser context
69 | * @param buf buffer containing a Vorbis frame
70 | * @param buf_size size of the buffer
71 | */
72 | int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf,
73 | int buf_size);
74 |
75 | void av_vorbis_parse_reset(AVVorbisParseContext *s);
76 |
77 | #endif /* AVCODEC_VORBIS_PARSER_H */
78 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavdevice/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef AVDEVICE_VERSION_H
20 | #define AVDEVICE_VERSION_H
21 |
22 | /**
23 | * @file
24 | * @ingroup lavd
25 | * Libavdevice version macros
26 | */
27 |
28 | #include "libavutil/version.h"
29 |
30 | #define LIBAVDEVICE_VERSION_MAJOR 57
31 | #define LIBAVDEVICE_VERSION_MINOR 6
32 | #define LIBAVDEVICE_VERSION_MICRO 100
33 |
34 | #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
35 | LIBAVDEVICE_VERSION_MINOR, \
36 | LIBAVDEVICE_VERSION_MICRO)
37 | #define LIBAVDEVICE_VERSION AV_VERSION(LIBAVDEVICE_VERSION_MAJOR, \
38 | LIBAVDEVICE_VERSION_MINOR, \
39 | LIBAVDEVICE_VERSION_MICRO)
40 | #define LIBAVDEVICE_BUILD LIBAVDEVICE_VERSION_INT
41 |
42 | #define LIBAVDEVICE_IDENT "Lavd" AV_STRINGIFY(LIBAVDEVICE_VERSION)
43 |
44 | /**
45 | * FF_API_* defines may be placed below to indicate public API that will be
46 | * dropped at a future version bump. The defines themselves are not part of
47 | * the public API and may change, break or disappear at any time.
48 | */
49 |
50 | #endif /* AVDEVICE_VERSION_H */
51 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavfilter/avfiltergraph.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Filter graphs
3 | * copyright (c) 2007 Bobby Bingham
4 | *
5 | * This file is part of FFmpeg.
6 | *
7 | * FFmpeg is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * FFmpeg is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with FFmpeg; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | #ifndef AVFILTER_AVFILTERGRAPH_H
23 | #define AVFILTER_AVFILTERGRAPH_H
24 |
25 | #include "avfilter.h"
26 | #include "libavutil/log.h"
27 |
28 | #endif /* AVFILTER_AVFILTERGRAPH_H */
29 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavfilter/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Version macros.
3 | *
4 | * This file is part of FFmpeg.
5 | *
6 | * FFmpeg is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * FFmpeg is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with FFmpeg; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | #ifndef AVFILTER_VERSION_H
22 | #define AVFILTER_VERSION_H
23 |
24 | /**
25 | * @file
26 | * @ingroup lavfi
27 | * Libavfilter version macros
28 | */
29 |
30 | #include "libavutil/version.h"
31 |
32 | #define LIBAVFILTER_VERSION_MAJOR 6
33 | #define LIBAVFILTER_VERSION_MINOR 82
34 | #define LIBAVFILTER_VERSION_MICRO 100
35 |
36 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
37 | LIBAVFILTER_VERSION_MINOR, \
38 | LIBAVFILTER_VERSION_MICRO)
39 | #define LIBAVFILTER_VERSION AV_VERSION(LIBAVFILTER_VERSION_MAJOR, \
40 | LIBAVFILTER_VERSION_MINOR, \
41 | LIBAVFILTER_VERSION_MICRO)
42 | #define LIBAVFILTER_BUILD LIBAVFILTER_VERSION_INT
43 |
44 | #define LIBAVFILTER_IDENT "Lavfi" AV_STRINGIFY(LIBAVFILTER_VERSION)
45 |
46 | /**
47 | * FF_API_* defines may be placed below to indicate public API that will be
48 | * dropped at a future version bump. The defines themselves are not part of
49 | * the public API and may change, break or disappear at any time.
50 | */
51 |
52 | #ifndef FF_API_OLD_FILTER_OPTS
53 | #define FF_API_OLD_FILTER_OPTS (LIBAVFILTER_VERSION_MAJOR < 7)
54 | #endif
55 | #ifndef FF_API_OLD_FILTER_OPTS_ERROR
56 | #define FF_API_OLD_FILTER_OPTS_ERROR (LIBAVFILTER_VERSION_MAJOR < 7)
57 | #endif
58 | #ifndef FF_API_AVFILTER_OPEN
59 | #define FF_API_AVFILTER_OPEN (LIBAVFILTER_VERSION_MAJOR < 7)
60 | #endif
61 | #ifndef FF_API_AVFILTER_INIT_FILTER
62 | #define FF_API_AVFILTER_INIT_FILTER (LIBAVFILTER_VERSION_MAJOR < 7)
63 | #endif
64 | #ifndef FF_API_OLD_FILTER_REGISTER
65 | #define FF_API_OLD_FILTER_REGISTER (LIBAVFILTER_VERSION_MAJOR < 7)
66 | #endif
67 | #ifndef FF_API_NOCONST_GET_NAME
68 | #define FF_API_NOCONST_GET_NAME (LIBAVFILTER_VERSION_MAJOR < 7)
69 | #endif
70 | #ifndef FF_API_LAVR_OPTS
71 | #define FF_API_LAVR_OPTS (LIBAVFILTER_VERSION_MAJOR < 7)
72 | #endif
73 |
74 | #endif /* AVFILTER_VERSION_H */
75 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/adler32.h:
--------------------------------------------------------------------------------
1 | /*
2 | * copyright (c) 2006 Mans Rullgard
3 | *
4 | * This file is part of FFmpeg.
5 | *
6 | * FFmpeg is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * FFmpeg is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with FFmpeg; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | /**
22 | * @file
23 | * @ingroup lavu_adler32
24 | * Public header for Adler-32 hash function implementation.
25 | */
26 |
27 | #ifndef AVUTIL_ADLER32_H
28 | #define AVUTIL_ADLER32_H
29 |
30 | #include
31 | #include "attributes.h"
32 |
33 | /**
34 | * @defgroup lavu_adler32 Adler-32
35 | * @ingroup lavu_hash
36 | * Adler-32 hash function implementation.
37 | *
38 | * @{
39 | */
40 |
41 | /**
42 | * Calculate the Adler32 checksum of a buffer.
43 | *
44 | * Passing the return value to a subsequent av_adler32_update() call
45 | * allows the checksum of multiple buffers to be calculated as though
46 | * they were concatenated.
47 | *
48 | * @param adler initial checksum value
49 | * @param buf pointer to input buffer
50 | * @param len size of input buffer
51 | * @return updated checksum
52 | */
53 | unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf,
54 | unsigned int len) av_pure;
55 |
56 | /**
57 | * @}
58 | */
59 |
60 | #endif /* AVUTIL_ADLER32_H */
61 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/aes.h:
--------------------------------------------------------------------------------
1 | /*
2 | * copyright (c) 2007 Michael Niedermayer
3 | *
4 | * This file is part of FFmpeg.
5 | *
6 | * FFmpeg is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * FFmpeg is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with FFmpeg; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | #ifndef AVUTIL_AES_H
22 | #define AVUTIL_AES_H
23 |
24 | #include
25 |
26 | #include "attributes.h"
27 | #include "version.h"
28 |
29 | /**
30 | * @defgroup lavu_aes AES
31 | * @ingroup lavu_crypto
32 | * @{
33 | */
34 |
35 | extern const int av_aes_size;
36 |
37 | struct AVAES;
38 |
39 | /**
40 | * Allocate an AVAES context.
41 | */
42 | struct AVAES *av_aes_alloc(void);
43 |
44 | /**
45 | * Initialize an AVAES context.
46 | * @param key_bits 128, 192 or 256
47 | * @param decrypt 0 for encryption, 1 for decryption
48 | */
49 | int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt);
50 |
51 | /**
52 | * Encrypt or decrypt a buffer using a previously initialized context.
53 | * @param count number of 16 byte blocks
54 | * @param dst destination array, can be equal to src
55 | * @param src source array, can be equal to dst
56 | * @param iv initialization vector for CBC mode, if NULL then ECB will be used
57 | * @param decrypt 0 for encryption, 1 for decryption
58 | */
59 | void av_aes_crypt(struct AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
60 |
61 | /**
62 | * @}
63 | */
64 |
65 | #endif /* AVUTIL_AES_H */
66 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/aes_ctr.h:
--------------------------------------------------------------------------------
1 | /*
2 | * AES-CTR cipher
3 | * Copyright (c) 2015 Eran Kornblau
4 | *
5 | * This file is part of FFmpeg.
6 | *
7 | * FFmpeg is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * FFmpeg is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with FFmpeg; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | #ifndef AVUTIL_AES_CTR_H
23 | #define AVUTIL_AES_CTR_H
24 |
25 | #include
26 |
27 | #include "attributes.h"
28 | #include "version.h"
29 |
30 | #define AES_CTR_KEY_SIZE (16)
31 | #define AES_CTR_IV_SIZE (8)
32 |
33 | struct AVAESCTR;
34 |
35 | /**
36 | * Allocate an AVAESCTR context.
37 | */
38 | struct AVAESCTR *av_aes_ctr_alloc(void);
39 |
40 | /**
41 | * Initialize an AVAESCTR context.
42 | * @param key encryption key, must have a length of AES_CTR_KEY_SIZE
43 | */
44 | int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key);
45 |
46 | /**
47 | * Release an AVAESCTR context.
48 | */
49 | void av_aes_ctr_free(struct AVAESCTR *a);
50 |
51 | /**
52 | * Process a buffer using a previously initialized context.
53 | * @param dst destination array, can be equal to src
54 | * @param src source array, can be equal to dst
55 | * @param size the size of src and dst
56 | */
57 | void av_aes_ctr_crypt(struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int size);
58 |
59 | /**
60 | * Get the current iv
61 | */
62 | const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a);
63 |
64 | /**
65 | * Generate a random iv
66 | */
67 | void av_aes_ctr_set_random_iv(struct AVAESCTR *a);
68 |
69 | /**
70 | * Forcefully change the iv
71 | */
72 | void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv);
73 |
74 | /**
75 | * Increment the top 64 bit of the iv (performed after each frame)
76 | */
77 | void av_aes_ctr_increment_iv(struct AVAESCTR *a);
78 |
79 | /**
80 | * @}
81 | */
82 |
83 | #endif /* AVUTIL_AES_CTR_H */
84 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/avassert.h:
--------------------------------------------------------------------------------
1 | /*
2 | * copyright (c) 2010 Michael Niedermayer
3 | *
4 | * This file is part of FFmpeg.
5 | *
6 | * FFmpeg is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * FFmpeg is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with FFmpeg; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | /**
22 | * @file
23 | * simple assert() macros that are a bit more flexible than ISO C assert().
24 | * @author Michael Niedermayer
25 | */
26 |
27 | #ifndef AVUTIL_AVASSERT_H
28 | #define AVUTIL_AVASSERT_H
29 |
30 | #include
31 | #include "avutil.h"
32 | #include "log.h"
33 |
34 | /**
35 | * assert() equivalent, that is always enabled.
36 | */
37 | #define av_assert0(cond) do { \
38 | if (!(cond)) { \
39 | av_log(NULL, AV_LOG_PANIC, "Assertion %s failed at %s:%d\n", \
40 | AV_STRINGIFY(cond), __FILE__, __LINE__); \
41 | abort(); \
42 | } \
43 | } while (0)
44 |
45 |
46 | /**
47 | * assert() equivalent, that does not lie in speed critical code.
48 | * These asserts() thus can be enabled without fearing speed loss.
49 | */
50 | #if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 0
51 | #define av_assert1(cond) av_assert0(cond)
52 | #else
53 | #define av_assert1(cond) ((void)0)
54 | #endif
55 |
56 |
57 | /**
58 | * assert() equivalent, that does lie in speed critical code.
59 | */
60 | #if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
61 | #define av_assert2(cond) av_assert0(cond)
62 | #define av_assert2_fpu() av_assert0_fpu()
63 | #else
64 | #define av_assert2(cond) ((void)0)
65 | #define av_assert2_fpu() ((void)0)
66 | #endif
67 |
68 | /**
69 | * Assert that floating point opperations can be executed.
70 | *
71 | * This will av_assert0() that the cpu is not in MMX state on X86
72 | */
73 | void av_assert0_fpu(void);
74 |
75 | #endif /* AVUTIL_AVASSERT_H */
76 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/avconfig.h:
--------------------------------------------------------------------------------
1 | /* Generated by ffconf */
2 | #ifndef AVUTIL_AVCONFIG_H
3 | #define AVUTIL_AVCONFIG_H
4 | #define AV_HAVE_BIGENDIAN 0
5 | #define AV_HAVE_FAST_UNALIGNED 1
6 | #endif /* AVUTIL_AVCONFIG_H */
7 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/base64.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2006 Ryan Martell. (rdm4@martellventures.com)
3 | *
4 | * This file is part of FFmpeg.
5 | *
6 | * FFmpeg is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * FFmpeg is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with FFmpeg; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | #ifndef AVUTIL_BASE64_H
22 | #define AVUTIL_BASE64_H
23 |
24 | #include
25 |
26 | /**
27 | * @defgroup lavu_base64 Base64
28 | * @ingroup lavu_crypto
29 | * @{
30 | */
31 |
32 | /**
33 | * Decode a base64-encoded string.
34 | *
35 | * @param out buffer for decoded data
36 | * @param in null-terminated input string
37 | * @param out_size size in bytes of the out buffer, must be at
38 | * least 3/4 of the length of in, that is AV_BASE64_DECODE_SIZE(strlen(in))
39 | * @return number of bytes written, or a negative value in case of
40 | * invalid input
41 | */
42 | int av_base64_decode(uint8_t *out, const char *in, int out_size);
43 |
44 | /**
45 | * Calculate the output size in bytes needed to decode a base64 string
46 | * with length x to a data buffer.
47 | */
48 | #define AV_BASE64_DECODE_SIZE(x) ((x) * 3LL / 4)
49 |
50 | /**
51 | * Encode data to base64 and null-terminate.
52 | *
53 | * @param out buffer for encoded data
54 | * @param out_size size in bytes of the out buffer (including the
55 | * null terminator), must be at least AV_BASE64_SIZE(in_size)
56 | * @param in input buffer containing the data to encode
57 | * @param in_size size in bytes of the in buffer
58 | * @return out or NULL in case of error
59 | */
60 | char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size);
61 |
62 | /**
63 | * Calculate the output size needed to base64-encode x bytes to a
64 | * null-terminated string.
65 | */
66 | #define AV_BASE64_SIZE(x) (((x)+2) / 3 * 4 + 1)
67 |
68 | /**
69 | * @}
70 | */
71 |
72 | #endif /* AVUTIL_BASE64_H */
73 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/blowfish.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Blowfish algorithm
3 | * Copyright (c) 2012 Samuel Pitoiset
4 | *
5 | * This file is part of FFmpeg.
6 | *
7 | * FFmpeg is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * FFmpeg is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with FFmpeg; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | #ifndef AVUTIL_BLOWFISH_H
23 | #define AVUTIL_BLOWFISH_H
24 |
25 | #include
26 |
27 | /**
28 | * @defgroup lavu_blowfish Blowfish
29 | * @ingroup lavu_crypto
30 | * @{
31 | */
32 |
33 | #define AV_BF_ROUNDS 16
34 |
35 | typedef struct AVBlowfish {
36 | uint32_t p[AV_BF_ROUNDS + 2];
37 | uint32_t s[4][256];
38 | } AVBlowfish;
39 |
40 | /**
41 | * Allocate an AVBlowfish context.
42 | */
43 | AVBlowfish *av_blowfish_alloc(void);
44 |
45 | /**
46 | * Initialize an AVBlowfish context.
47 | *
48 | * @param ctx an AVBlowfish context
49 | * @param key a key
50 | * @param key_len length of the key
51 | */
52 | void av_blowfish_init(struct AVBlowfish *ctx, const uint8_t *key, int key_len);
53 |
54 | /**
55 | * Encrypt or decrypt a buffer using a previously initialized context.
56 | *
57 | * @param ctx an AVBlowfish context
58 | * @param xl left four bytes halves of input to be encrypted
59 | * @param xr right four bytes halves of input to be encrypted
60 | * @param decrypt 0 for encryption, 1 for decryption
61 | */
62 | void av_blowfish_crypt_ecb(struct AVBlowfish *ctx, uint32_t *xl, uint32_t *xr,
63 | int decrypt);
64 |
65 | /**
66 | * Encrypt or decrypt a buffer using a previously initialized context.
67 | *
68 | * @param ctx an AVBlowfish context
69 | * @param dst destination array, can be equal to src
70 | * @param src source array, can be equal to dst
71 | * @param count number of 8 byte blocks
72 | * @param iv initialization vector for CBC mode, if NULL ECB will be used
73 | * @param decrypt 0 for encryption, 1 for decryption
74 | */
75 | void av_blowfish_crypt(struct AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
76 | int count, uint8_t *iv, int decrypt);
77 |
78 | /**
79 | * @}
80 | */
81 |
82 | #endif /* AVUTIL_BLOWFISH_H */
83 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/camellia.h:
--------------------------------------------------------------------------------
1 | /*
2 | * An implementation of the CAMELLIA algorithm as mentioned in RFC3713
3 | * Copyright (c) 2014 Supraja Meedinti
4 | *
5 | * This file is part of FFmpeg.
6 | *
7 | * FFmpeg is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * FFmpeg is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with FFmpeg; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | #ifndef AVUTIL_CAMELLIA_H
23 | #define AVUTIL_CAMELLIA_H
24 |
25 | #include
26 |
27 |
28 | /**
29 | * @file
30 | * @brief Public header for libavutil CAMELLIA algorithm
31 | * @defgroup lavu_camellia CAMELLIA
32 | * @ingroup lavu_crypto
33 | * @{
34 | */
35 |
36 | extern const int av_camellia_size;
37 |
38 | struct AVCAMELLIA;
39 |
40 | /**
41 | * Allocate an AVCAMELLIA context
42 | * To free the struct: av_free(ptr)
43 | */
44 | struct AVCAMELLIA *av_camellia_alloc(void);
45 |
46 | /**
47 | * Initialize an AVCAMELLIA context.
48 | *
49 | * @param ctx an AVCAMELLIA context
50 | * @param key a key of 16, 24, 32 bytes used for encryption/decryption
51 | * @param key_bits number of keybits: possible are 128, 192, 256
52 | */
53 | int av_camellia_init(struct AVCAMELLIA *ctx, const uint8_t *key, int key_bits);
54 |
55 | /**
56 | * Encrypt or decrypt a buffer using a previously initialized context
57 | *
58 | * @param ctx an AVCAMELLIA context
59 | * @param dst destination array, can be equal to src
60 | * @param src source array, can be equal to dst
61 | * @param count number of 16 byte blocks
62 | * @paran iv initialization vector for CBC mode, NULL for ECB mode
63 | * @param decrypt 0 for encryption, 1 for decryption
64 | */
65 | void av_camellia_crypt(struct AVCAMELLIA *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t* iv, int decrypt);
66 |
67 | /**
68 | * @}
69 | */
70 | #endif /* AVUTIL_CAMELLIA_H */
71 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/cast5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * An implementation of the CAST128 algorithm as mentioned in RFC2144
3 | * Copyright (c) 2014 Supraja Meedinti
4 | *
5 | * This file is part of FFmpeg.
6 | *
7 | * FFmpeg is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * FFmpeg is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with FFmpeg; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | #ifndef AVUTIL_CAST5_H
23 | #define AVUTIL_CAST5_H
24 |
25 | #include
26 |
27 |
28 | /**
29 | * @file
30 | * @brief Public header for libavutil CAST5 algorithm
31 | * @defgroup lavu_cast5 CAST5
32 | * @ingroup lavu_crypto
33 | * @{
34 | */
35 |
36 | extern const int av_cast5_size;
37 |
38 | struct AVCAST5;
39 |
40 | /**
41 | * Allocate an AVCAST5 context
42 | * To free the struct: av_free(ptr)
43 | */
44 | struct AVCAST5 *av_cast5_alloc(void);
45 | /**
46 | * Initialize an AVCAST5 context.
47 | *
48 | * @param ctx an AVCAST5 context
49 | * @param key a key of 5,6,...16 bytes used for encryption/decryption
50 | * @param key_bits number of keybits: possible are 40,48,...,128
51 | * @return 0 on success, less than 0 on failure
52 | */
53 | int av_cast5_init(struct AVCAST5 *ctx, const uint8_t *key, int key_bits);
54 |
55 | /**
56 | * Encrypt or decrypt a buffer using a previously initialized context, ECB mode only
57 | *
58 | * @param ctx an AVCAST5 context
59 | * @param dst destination array, can be equal to src
60 | * @param src source array, can be equal to dst
61 | * @param count number of 8 byte blocks
62 | * @param decrypt 0 for encryption, 1 for decryption
63 | */
64 | void av_cast5_crypt(struct AVCAST5 *ctx, uint8_t *dst, const uint8_t *src, int count, int decrypt);
65 |
66 | /**
67 | * Encrypt or decrypt a buffer using a previously initialized context
68 | *
69 | * @param ctx an AVCAST5 context
70 | * @param dst destination array, can be equal to src
71 | * @param src source array, can be equal to dst
72 | * @param count number of 8 byte blocks
73 | * @param iv initialization vector for CBC mode, NULL for ECB mode
74 | * @param decrypt 0 for encryption, 1 for decryption
75 | */
76 | void av_cast5_crypt2(struct AVCAST5 *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
77 | /**
78 | * @}
79 | */
80 | #endif /* AVUTIL_CAST5_H */
81 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/des.h:
--------------------------------------------------------------------------------
1 | /*
2 | * DES encryption/decryption
3 | * Copyright (c) 2007 Reimar Doeffinger
4 | *
5 | * This file is part of FFmpeg.
6 | *
7 | * FFmpeg is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * FFmpeg is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with FFmpeg; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | #ifndef AVUTIL_DES_H
23 | #define AVUTIL_DES_H
24 |
25 | #include
26 |
27 | /**
28 | * @defgroup lavu_des DES
29 | * @ingroup lavu_crypto
30 | * @{
31 | */
32 |
33 | typedef struct AVDES {
34 | uint64_t round_keys[3][16];
35 | int triple_des;
36 | } AVDES;
37 |
38 | /**
39 | * Allocate an AVDES context.
40 | */
41 | AVDES *av_des_alloc(void);
42 |
43 | /**
44 | * @brief Initializes an AVDES context.
45 | *
46 | * @param key_bits must be 64 or 192
47 | * @param decrypt 0 for encryption/CBC-MAC, 1 for decryption
48 | * @return zero on success, negative value otherwise
49 | */
50 | int av_des_init(struct AVDES *d, const uint8_t *key, int key_bits, int decrypt);
51 |
52 | /**
53 | * @brief Encrypts / decrypts using the DES algorithm.
54 | *
55 | * @param count number of 8 byte blocks
56 | * @param dst destination array, can be equal to src, must be 8-byte aligned
57 | * @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL
58 | * @param iv initialization vector for CBC mode, if NULL then ECB will be used,
59 | * must be 8-byte aligned
60 | * @param decrypt 0 for encryption, 1 for decryption
61 | */
62 | void av_des_crypt(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
63 |
64 | /**
65 | * @brief Calculates CBC-MAC using the DES algorithm.
66 | *
67 | * @param count number of 8 byte blocks
68 | * @param dst destination array, can be equal to src, must be 8-byte aligned
69 | * @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL
70 | */
71 | void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count);
72 |
73 | /**
74 | * @}
75 | */
76 |
77 | #endif /* AVUTIL_DES_H */
78 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/ffversion.h:
--------------------------------------------------------------------------------
1 | /* Automatically generated by version.sh, do not manually edit! */
2 | #ifndef AVUTIL_FFVERSION_H
3 | #define AVUTIL_FFVERSION_H
4 | #define FFMPEG_VERSION "3.3.9"
5 | #endif /* AVUTIL_FFVERSION_H */
6 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/file.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef AVUTIL_FILE_H
20 | #define AVUTIL_FILE_H
21 |
22 | #include
23 |
24 | #include "avutil.h"
25 |
26 | /**
27 | * @file
28 | * Misc file utilities.
29 | */
30 |
31 | /**
32 | * Read the file with name filename, and put its content in a newly
33 | * allocated buffer or map it with mmap() when available.
34 | * In case of success set *bufptr to the read or mmapped buffer, and
35 | * *size to the size in bytes of the buffer in *bufptr.
36 | * The returned buffer must be released with av_file_unmap().
37 | *
38 | * @param log_offset loglevel offset used for logging
39 | * @param log_ctx context used for logging
40 | * @return a non negative number in case of success, a negative value
41 | * corresponding to an AVERROR error code in case of failure
42 | */
43 | av_warn_unused_result
44 | int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
45 | int log_offset, void *log_ctx);
46 |
47 | /**
48 | * Unmap or free the buffer bufptr created by av_file_map().
49 | *
50 | * @param size size in bytes of bufptr, must be the same as returned
51 | * by av_file_map()
52 | */
53 | void av_file_unmap(uint8_t *bufptr, size_t size);
54 |
55 | /**
56 | * Wrapper to work around the lack of mkstemp() on mingw.
57 | * Also, tries to create file in /tmp first, if possible.
58 | * *prefix can be a character constant; *filename will be allocated internally.
59 | * @return file descriptor of opened file (or negative value corresponding to an
60 | * AVERROR code on error)
61 | * and opened file name in **filename.
62 | * @note On very old libcs it is necessary to set a secure umask before
63 | * calling this, av_tempfile() can't call umask itself as it is used in
64 | * libraries and could interfere with the calling application.
65 | * @deprecated as fd numbers cannot be passed saftely between libs on some platforms
66 | */
67 | int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx);
68 |
69 | #endif /* AVUTIL_FILE_H */
70 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/hwcontext_cuda.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 |
20 | #ifndef AVUTIL_HWCONTEXT_CUDA_H
21 | #define AVUTIL_HWCONTEXT_CUDA_H
22 |
23 | #ifndef CUDA_VERSION
24 | #include
25 | #endif
26 |
27 | #include "pixfmt.h"
28 |
29 | /**
30 | * @file
31 | * An API-specific header for AV_HWDEVICE_TYPE_CUDA.
32 | *
33 | * This API supports dynamic frame pools. AVHWFramesContext.pool must return
34 | * AVBufferRefs whose data pointer is a CUdeviceptr.
35 | */
36 |
37 | typedef struct AVCUDADeviceContextInternal AVCUDADeviceContextInternal;
38 |
39 | /**
40 | * This struct is allocated as AVHWDeviceContext.hwctx
41 | */
42 | typedef struct AVCUDADeviceContext {
43 | CUcontext cuda_ctx;
44 | AVCUDADeviceContextInternal *internal;
45 | } AVCUDADeviceContext;
46 |
47 | /**
48 | * AVHWFramesContext.hwctx is currently not used
49 | */
50 |
51 | #endif /* AVUTIL_HWCONTEXT_CUDA_H */
52 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/hwcontext_dxva2.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 |
20 | #ifndef AVUTIL_HWCONTEXT_DXVA2_H
21 | #define AVUTIL_HWCONTEXT_DXVA2_H
22 |
23 | /**
24 | * @file
25 | * An API-specific header for AV_HWDEVICE_TYPE_DXVA2.
26 | *
27 | * Only fixed-size pools are supported.
28 | *
29 | * For user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs
30 | * with the data pointer set to a pointer to IDirect3DSurface9.
31 | */
32 |
33 | #include
34 | #include
35 |
36 | /**
37 | * This struct is allocated as AVHWDeviceContext.hwctx
38 | */
39 | typedef struct AVDXVA2DeviceContext {
40 | IDirect3DDeviceManager9 *devmgr;
41 | } AVDXVA2DeviceContext;
42 |
43 | /**
44 | * This struct is allocated as AVHWFramesContext.hwctx
45 | */
46 | typedef struct AVDXVA2FramesContext {
47 | /**
48 | * The surface type (e.g. DXVA2_VideoProcessorRenderTarget or
49 | * DXVA2_VideoDecoderRenderTarget). Must be set by the caller.
50 | */
51 | DWORD surface_type;
52 |
53 | /**
54 | * The surface pool. When an external pool is not provided by the caller,
55 | * this will be managed (allocated and filled on init, freed on uninit) by
56 | * libavutil.
57 | */
58 | IDirect3DSurface9 **surfaces;
59 | int nb_surfaces;
60 |
61 | /**
62 | * Certain drivers require the decoder to be destroyed before the surfaces.
63 | * To allow internally managed pools to work properly in such cases, this
64 | * field is provided.
65 | *
66 | * If it is non-NULL, libavutil will call IDirectXVideoDecoder_Release() on
67 | * it just before the internal surface pool is freed.
68 | */
69 | IDirectXVideoDecoder *decoder_to_release;
70 | } AVDXVA2FramesContext;
71 |
72 | #endif /* AVUTIL_HWCONTEXT_DXVA2_H */
73 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/hwcontext_qsv.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef AVUTIL_HWCONTEXT_QSV_H
20 | #define AVUTIL_HWCONTEXT_QSV_H
21 |
22 | #include
23 |
24 | /**
25 | * @file
26 | * An API-specific header for AV_HWDEVICE_TYPE_QSV.
27 | *
28 | * This API does not support dynamic frame pools. AVHWFramesContext.pool must
29 | * contain AVBufferRefs whose data pointer points to an mfxFrameSurface1 struct.
30 | */
31 |
32 | /**
33 | * This struct is allocated as AVHWDeviceContext.hwctx
34 | */
35 | typedef struct AVQSVDeviceContext {
36 | mfxSession session;
37 | } AVQSVDeviceContext;
38 |
39 | /**
40 | * This struct is allocated as AVHWFramesContext.hwctx
41 | */
42 | typedef struct AVQSVFramesContext {
43 | mfxFrameSurface1 *surfaces;
44 | int nb_surfaces;
45 |
46 | /**
47 | * A combination of MFX_MEMTYPE_* describing the frame pool.
48 | */
49 | int frame_type;
50 | } AVQSVFramesContext;
51 |
52 | #endif /* AVUTIL_HWCONTEXT_QSV_H */
53 |
54 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/hwcontext_vdpau.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef AVUTIL_HWCONTEXT_VDPAU_H
20 | #define AVUTIL_HWCONTEXT_VDPAU_H
21 |
22 | #include
23 |
24 | /**
25 | * @file
26 | * An API-specific header for AV_HWDEVICE_TYPE_VDPAU.
27 | *
28 | * This API supports dynamic frame pools. AVHWFramesContext.pool must return
29 | * AVBufferRefs whose data pointer is a VdpVideoSurface.
30 | */
31 |
32 | /**
33 | * This struct is allocated as AVHWDeviceContext.hwctx
34 | */
35 | typedef struct AVVDPAUDeviceContext {
36 | VdpDevice device;
37 | VdpGetProcAddress *get_proc_address;
38 | } AVVDPAUDeviceContext;
39 |
40 | /**
41 | * AVHWFramesContext.hwctx is currently not used
42 | */
43 |
44 | #endif /* AVUTIL_HWCONTEXT_VDPAU_H */
45 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/intfloat.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Mans Rullgard
3 | *
4 | * This file is part of FFmpeg.
5 | *
6 | * FFmpeg is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * FFmpeg is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with FFmpeg; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | #ifndef AVUTIL_INTFLOAT_H
22 | #define AVUTIL_INTFLOAT_H
23 |
24 | #include
25 | #include "attributes.h"
26 |
27 | union av_intfloat32 {
28 | uint32_t i;
29 | float f;
30 | };
31 |
32 | union av_intfloat64 {
33 | uint64_t i;
34 | double f;
35 | };
36 |
37 | /**
38 | * Reinterpret a 32-bit integer as a float.
39 | */
40 | static av_always_inline float av_int2float(uint32_t i)
41 | {
42 | union av_intfloat32 v;
43 | v.i = i;
44 | return v.f;
45 | }
46 |
47 | /**
48 | * Reinterpret a float as a 32-bit integer.
49 | */
50 | static av_always_inline uint32_t av_float2int(float f)
51 | {
52 | union av_intfloat32 v;
53 | v.f = f;
54 | return v.i;
55 | }
56 |
57 | /**
58 | * Reinterpret a 64-bit integer as a double.
59 | */
60 | static av_always_inline double av_int2double(uint64_t i)
61 | {
62 | union av_intfloat64 v;
63 | v.i = i;
64 | return v.f;
65 | }
66 |
67 | /**
68 | * Reinterpret a double as a 64-bit integer.
69 | */
70 | static av_always_inline uint64_t av_double2int(double f)
71 | {
72 | union av_intfloat64 v;
73 | v.f = f;
74 | return v.i;
75 | }
76 |
77 | #endif /* AVUTIL_INTFLOAT_H */
78 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/lfg.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Lagged Fibonacci PRNG
3 | * Copyright (c) 2008 Michael Niedermayer
4 | *
5 | * This file is part of FFmpeg.
6 | *
7 | * FFmpeg is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * FFmpeg is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with FFmpeg; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | #ifndef AVUTIL_LFG_H
23 | #define AVUTIL_LFG_H
24 |
25 | #include
26 |
27 | typedef struct AVLFG {
28 | unsigned int state[64];
29 | int index;
30 | } AVLFG;
31 |
32 | void av_lfg_init(AVLFG *c, unsigned int seed);
33 |
34 | /**
35 | * Seed the state of the ALFG using binary data.
36 | *
37 | * Return value: 0 on success, negative value (AVERROR) on failure.
38 | */
39 | int av_lfg_init_from_data(AVLFG *c, const uint8_t *data, unsigned int length);
40 |
41 | /**
42 | * Get the next random unsigned 32-bit number using an ALFG.
43 | *
44 | * Please also consider a simple LCG like state= state*1664525+1013904223,
45 | * it may be good enough and faster for your specific use case.
46 | */
47 | static inline unsigned int av_lfg_get(AVLFG *c){
48 | c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63];
49 | return c->state[c->index++ & 63];
50 | }
51 |
52 | /**
53 | * Get the next random unsigned 32-bit number using a MLFG.
54 | *
55 | * Please also consider av_lfg_get() above, it is faster.
56 | */
57 | static inline unsigned int av_mlfg_get(AVLFG *c){
58 | unsigned int a= c->state[(c->index-55) & 63];
59 | unsigned int b= c->state[(c->index-24) & 63];
60 | return c->state[c->index++ & 63] = 2*a*b+a+b;
61 | }
62 |
63 | /**
64 | * Get the next two numbers generated by a Box-Muller Gaussian
65 | * generator using the random numbers issued by lfg.
66 | *
67 | * @param out array where the two generated numbers are placed
68 | */
69 | void av_bmg_get(AVLFG *lfg, double out[2]);
70 |
71 | #endif /* AVUTIL_LFG_H */
72 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/lzo.h:
--------------------------------------------------------------------------------
1 | /*
2 | * LZO 1x decompression
3 | * copyright (c) 2006 Reimar Doeffinger
4 | *
5 | * This file is part of FFmpeg.
6 | *
7 | * FFmpeg is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * FFmpeg is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with FFmpeg; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | #ifndef AVUTIL_LZO_H
23 | #define AVUTIL_LZO_H
24 |
25 | /**
26 | * @defgroup lavu_lzo LZO
27 | * @ingroup lavu_crypto
28 | *
29 | * @{
30 | */
31 |
32 | #include
33 |
34 | /** @name Error flags returned by av_lzo1x_decode
35 | * @{ */
36 | /// end of the input buffer reached before decoding finished
37 | #define AV_LZO_INPUT_DEPLETED 1
38 | /// decoded data did not fit into output buffer
39 | #define AV_LZO_OUTPUT_FULL 2
40 | /// a reference to previously decoded data was wrong
41 | #define AV_LZO_INVALID_BACKPTR 4
42 | /// a non-specific error in the compressed bitstream
43 | #define AV_LZO_ERROR 8
44 | /** @} */
45 |
46 | #define AV_LZO_INPUT_PADDING 8
47 | #define AV_LZO_OUTPUT_PADDING 12
48 |
49 | /**
50 | * @brief Decodes LZO 1x compressed data.
51 | * @param out output buffer
52 | * @param outlen size of output buffer, number of bytes left are returned here
53 | * @param in input buffer
54 | * @param inlen size of input buffer, number of bytes left are returned here
55 | * @return 0 on success, otherwise a combination of the error flags above
56 | *
57 | * Make sure all buffers are appropriately padded, in must provide
58 | * AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes.
59 | */
60 | int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen);
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | #endif /* AVUTIL_LZO_H */
67 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/macros.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | /**
20 | * @file
21 | * @ingroup lavu
22 | * Utility Preprocessor macros
23 | */
24 |
25 | #ifndef AVUTIL_MACROS_H
26 | #define AVUTIL_MACROS_H
27 |
28 | /**
29 | * @addtogroup preproc_misc Preprocessor String Macros
30 | *
31 | * String manipulation macros
32 | *
33 | * @{
34 | */
35 |
36 | #define AV_STRINGIFY(s) AV_TOSTRING(s)
37 | #define AV_TOSTRING(s) #s
38 |
39 | #define AV_GLUE(a, b) a ## b
40 | #define AV_JOIN(a, b) AV_GLUE(a, b)
41 |
42 | /**
43 | * @}
44 | */
45 |
46 | #define AV_PRAGMA(s) _Pragma(#s)
47 |
48 | #define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
49 |
50 | #endif /* AVUTIL_MACROS_H */
51 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/mastering_display_metadata.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2016 Neil Birkbeck
3 | *
4 | * This file is part of FFmpeg.
5 | *
6 | * FFmpeg is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * FFmpeg is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with FFmpeg; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | #ifndef AVUTIL_MASTERING_DISPLAY_METADATA_H
22 | #define AVUTIL_MASTERING_DISPLAY_METADATA_H
23 |
24 | #include "frame.h"
25 | #include "rational.h"
26 |
27 |
28 | /**
29 | * Mastering display metadata capable of representing the color volume of
30 | * the display used to master the content (SMPTE 2086:2014).
31 | *
32 | * To be used as payload of a AVFrameSideData or AVPacketSideData with the
33 | * appropriate type.
34 | *
35 | * @note The struct should be allocated with av_mastering_display_metadata_alloc()
36 | * and its size is not a part of the public ABI.
37 | */
38 | typedef struct AVMasteringDisplayMetadata {
39 | /**
40 | * CIE 1931 xy chromaticity coords of color primaries (r, g, b order).
41 | */
42 | AVRational display_primaries[3][2];
43 |
44 | /**
45 | * CIE 1931 xy chromaticity coords of white point.
46 | */
47 | AVRational white_point[2];
48 |
49 | /**
50 | * Min luminance of mastering display (cd/m^2).
51 | */
52 | AVRational min_luminance;
53 |
54 | /**
55 | * Max luminance of mastering display (cd/m^2).
56 | */
57 | AVRational max_luminance;
58 |
59 | /**
60 | * Flag indicating whether the display primaries (and white point) are set.
61 | */
62 | int has_primaries;
63 |
64 | /**
65 | * Flag indicating whether the luminance (min_ and max_) have been set.
66 | */
67 | int has_luminance;
68 |
69 | } AVMasteringDisplayMetadata;
70 |
71 | /**
72 | * Allocate an AVMasteringDisplayMetadata structure and set its fields to
73 | * default values. The resulting struct can be freed using av_freep().
74 | *
75 | * @return An AVMasteringDisplayMetadata filled with default values or NULL
76 | * on failure.
77 | */
78 | AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);
79 |
80 | /**
81 | * Allocate a complete AVMasteringDisplayMetadata and add it to the frame.
82 | *
83 | * @param frame The frame which side data is added to.
84 | *
85 | * @return The AVMasteringDisplayMetadata structure to be filled by caller.
86 | */
87 | AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFrame *frame);
88 |
89 | #endif /* AVUTIL_MASTERING_DISPLAY_METADATA_H */
90 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/md5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * copyright (c) 2006 Michael Niedermayer
3 | *
4 | * This file is part of FFmpeg.
5 | *
6 | * FFmpeg is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * FFmpeg is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with FFmpeg; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | /**
22 | * @file
23 | * @ingroup lavu_md5
24 | * Public header for MD5 hash function implementation.
25 | */
26 |
27 | #ifndef AVUTIL_MD5_H
28 | #define AVUTIL_MD5_H
29 |
30 | #include
31 |
32 | #include "attributes.h"
33 | #include "version.h"
34 |
35 | /**
36 | * @defgroup lavu_md5 MD5
37 | * @ingroup lavu_hash
38 | * MD5 hash function implementation.
39 | *
40 | * @{
41 | */
42 |
43 | extern const int av_md5_size;
44 |
45 | struct AVMD5;
46 |
47 | /**
48 | * Allocate an AVMD5 context.
49 | */
50 | struct AVMD5 *av_md5_alloc(void);
51 |
52 | /**
53 | * Initialize MD5 hashing.
54 | *
55 | * @param ctx pointer to the function context (of size av_md5_size)
56 | */
57 | void av_md5_init(struct AVMD5 *ctx);
58 |
59 | /**
60 | * Update hash value.
61 | *
62 | * @param ctx hash function context
63 | * @param src input data to update hash with
64 | * @param len input data length
65 | */
66 | void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, int len);
67 |
68 | /**
69 | * Finish hashing and output digest value.
70 | *
71 | * @param ctx hash function context
72 | * @param dst buffer where output digest value is stored
73 | */
74 | void av_md5_final(struct AVMD5 *ctx, uint8_t *dst);
75 |
76 | /**
77 | * Hash an array of data.
78 | *
79 | * @param dst The output buffer to write the digest into
80 | * @param src The data to hash
81 | * @param len The length of the data, in bytes
82 | */
83 | void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len);
84 |
85 | /**
86 | * @}
87 | */
88 |
89 | #endif /* AVUTIL_MD5_H */
90 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/motion_vector.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef AVUTIL_MOTION_VECTOR_H
20 | #define AVUTIL_MOTION_VECTOR_H
21 |
22 | #include
23 |
24 | typedef struct AVMotionVector {
25 | /**
26 | * Where the current macroblock comes from; negative value when it comes
27 | * from the past, positive value when it comes from the future.
28 | * XXX: set exact relative ref frame reference instead of a +/- 1 "direction".
29 | */
30 | int32_t source;
31 | /**
32 | * Width and height of the block.
33 | */
34 | uint8_t w, h;
35 | /**
36 | * Absolute source position. Can be outside the frame area.
37 | */
38 | int16_t src_x, src_y;
39 | /**
40 | * Absolute destination position. Can be outside the frame area.
41 | */
42 | int16_t dst_x, dst_y;
43 | /**
44 | * Extra flag information.
45 | * Currently unused.
46 | */
47 | uint64_t flags;
48 | /**
49 | * Motion vector
50 | * src_x = dst_x + motion_x / motion_scale
51 | * src_y = dst_y + motion_y / motion_scale
52 | */
53 | int32_t motion_x, motion_y;
54 | uint16_t motion_scale;
55 | } AVMotionVector;
56 |
57 | #endif /* AVUTIL_MOTION_VECTOR_H */
58 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/pixelutils.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef AVUTIL_PIXELUTILS_H
20 | #define AVUTIL_PIXELUTILS_H
21 |
22 | #include
23 | #include
24 | #include "common.h"
25 |
26 | /**
27 | * Sum of abs(src1[x] - src2[x])
28 | */
29 | typedef int (*av_pixelutils_sad_fn)(const uint8_t *src1, ptrdiff_t stride1,
30 | const uint8_t *src2, ptrdiff_t stride2);
31 |
32 | /**
33 | * Get a potentially optimized pointer to a Sum-of-absolute-differences
34 | * function (see the av_pixelutils_sad_fn prototype).
35 | *
36 | * @param w_bits 1<
3 | *
4 | * This file is part of FFmpeg.
5 | *
6 | * FFmpeg is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * FFmpeg is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with FFmpeg; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | #ifndef AVUTIL_RANDOM_SEED_H
22 | #define AVUTIL_RANDOM_SEED_H
23 |
24 | #include
25 | /**
26 | * @addtogroup lavu_crypto
27 | * @{
28 | */
29 |
30 | /**
31 | * Get a seed to use in conjunction with random functions.
32 | * This function tries to provide a good seed at a best effort bases.
33 | * Its possible to call this function multiple times if more bits are needed.
34 | * It can be quite slow, which is why it should only be used as seed for a faster
35 | * PRNG. The quality of the seed depends on the platform.
36 | */
37 | uint32_t av_get_random_seed(void);
38 |
39 | /**
40 | * @}
41 | */
42 |
43 | #endif /* AVUTIL_RANDOM_SEED_H */
44 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/rc4.h:
--------------------------------------------------------------------------------
1 | /*
2 | * RC4 encryption/decryption/pseudo-random number generator
3 | *
4 | * This file is part of FFmpeg.
5 | *
6 | * FFmpeg is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * FFmpeg is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with FFmpeg; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | #ifndef AVUTIL_RC4_H
22 | #define AVUTIL_RC4_H
23 |
24 | #include
25 |
26 | /**
27 | * @defgroup lavu_rc4 RC4
28 | * @ingroup lavu_crypto
29 | * @{
30 | */
31 |
32 | typedef struct AVRC4 {
33 | uint8_t state[256];
34 | int x, y;
35 | } AVRC4;
36 |
37 | /**
38 | * Allocate an AVRC4 context.
39 | */
40 | AVRC4 *av_rc4_alloc(void);
41 |
42 | /**
43 | * @brief Initializes an AVRC4 context.
44 | *
45 | * @param key_bits must be a multiple of 8
46 | * @param decrypt 0 for encryption, 1 for decryption, currently has no effect
47 | * @return zero on success, negative value otherwise
48 | */
49 | int av_rc4_init(struct AVRC4 *d, const uint8_t *key, int key_bits, int decrypt);
50 |
51 | /**
52 | * @brief Encrypts / decrypts using the RC4 algorithm.
53 | *
54 | * @param count number of bytes
55 | * @param dst destination array, can be equal to src
56 | * @param src source array, can be equal to dst, may be NULL
57 | * @param iv not (yet) used for RC4, should be NULL
58 | * @param decrypt 0 for encryption, 1 for decryption, not (yet) used
59 | */
60 | void av_rc4_crypt(struct AVRC4 *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | #endif /* AVUTIL_RC4_H */
67 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/replaygain.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef AVUTIL_REPLAYGAIN_H
20 | #define AVUTIL_REPLAYGAIN_H
21 |
22 | #include
23 |
24 | /**
25 | * ReplayGain information (see
26 | * http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification).
27 | * The size of this struct is a part of the public ABI.
28 | */
29 | typedef struct AVReplayGain {
30 | /**
31 | * Track replay gain in microbels (divide by 100000 to get the value in dB).
32 | * Should be set to INT32_MIN when unknown.
33 | */
34 | int32_t track_gain;
35 | /**
36 | * Peak track amplitude, with 100000 representing full scale (but values
37 | * may overflow). 0 when unknown.
38 | */
39 | uint32_t track_peak;
40 | /**
41 | * Same as track_gain, but for the whole album.
42 | */
43 | int32_t album_gain;
44 | /**
45 | * Same as track_peak, but for the whole album,
46 | */
47 | uint32_t album_peak;
48 | } AVReplayGain;
49 |
50 | #endif /* AVUTIL_REPLAYGAIN_H */
51 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/ripemd.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2007 Michael Niedermayer
3 | * Copyright (C) 2013 James Almer
4 | *
5 | * This file is part of FFmpeg.
6 | *
7 | * FFmpeg is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * FFmpeg is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with FFmpeg; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | /**
23 | * @file
24 | * @ingroup lavu_ripemd
25 | * Public header for RIPEMD hash function implementation.
26 | */
27 |
28 | #ifndef AVUTIL_RIPEMD_H
29 | #define AVUTIL_RIPEMD_H
30 |
31 | #include
32 |
33 | #include "attributes.h"
34 | #include "version.h"
35 |
36 | /**
37 | * @defgroup lavu_ripemd RIPEMD
38 | * @ingroup lavu_hash
39 | * RIPEMD hash function implementation.
40 | *
41 | * @{
42 | */
43 |
44 | extern const int av_ripemd_size;
45 |
46 | struct AVRIPEMD;
47 |
48 | /**
49 | * Allocate an AVRIPEMD context.
50 | */
51 | struct AVRIPEMD *av_ripemd_alloc(void);
52 |
53 | /**
54 | * Initialize RIPEMD hashing.
55 | *
56 | * @param context pointer to the function context (of size av_ripemd_size)
57 | * @param bits number of bits in digest (128, 160, 256 or 320 bits)
58 | * @return zero if initialization succeeded, -1 otherwise
59 | */
60 | int av_ripemd_init(struct AVRIPEMD* context, int bits);
61 |
62 | /**
63 | * Update hash value.
64 | *
65 | * @param context hash function context
66 | * @param data input data to update hash with
67 | * @param len input data length
68 | */
69 | void av_ripemd_update(struct AVRIPEMD* context, const uint8_t* data, unsigned int len);
70 |
71 | /**
72 | * Finish hashing and output digest value.
73 | *
74 | * @param context hash function context
75 | * @param digest buffer where output digest value is stored
76 | */
77 | void av_ripemd_final(struct AVRIPEMD* context, uint8_t *digest);
78 |
79 | /**
80 | * @}
81 | */
82 |
83 | #endif /* AVUTIL_RIPEMD_H */
84 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/sha.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2007 Michael Niedermayer
3 | *
4 | * This file is part of FFmpeg.
5 | *
6 | * FFmpeg is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * FFmpeg is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with FFmpeg; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | /**
22 | * @file
23 | * @ingroup lavu_sha
24 | * Public header for SHA-1 & SHA-256 hash function implementations.
25 | */
26 |
27 | #ifndef AVUTIL_SHA_H
28 | #define AVUTIL_SHA_H
29 |
30 | #include
31 |
32 | #include "attributes.h"
33 | #include "version.h"
34 |
35 | /**
36 | * @defgroup lavu_sha SHA
37 | * @ingroup lavu_hash
38 | * SHA-1 and SHA-256 (Secure Hash Algorithm) hash function implementations.
39 | *
40 | * This module supports the following SHA hash functions:
41 | *
42 | * - SHA-1: 160 bits
43 | * - SHA-224: 224 bits, as a variant of SHA-2
44 | * - SHA-256: 256 bits, as a variant of SHA-2
45 | *
46 | * @see For SHA-384, SHA-512, and variants thereof, see @ref lavu_sha512.
47 | *
48 | * @{
49 | */
50 |
51 | extern const int av_sha_size;
52 |
53 | struct AVSHA;
54 |
55 | /**
56 | * Allocate an AVSHA context.
57 | */
58 | struct AVSHA *av_sha_alloc(void);
59 |
60 | /**
61 | * Initialize SHA-1 or SHA-2 hashing.
62 | *
63 | * @param context pointer to the function context (of size av_sha_size)
64 | * @param bits number of bits in digest (SHA-1 - 160 bits, SHA-2 224 or 256 bits)
65 | * @return zero if initialization succeeded, -1 otherwise
66 | */
67 | int av_sha_init(struct AVSHA* context, int bits);
68 |
69 | /**
70 | * Update hash value.
71 | *
72 | * @param context hash function context
73 | * @param data input data to update hash with
74 | * @param len input data length
75 | */
76 | void av_sha_update(struct AVSHA* context, const uint8_t* data, unsigned int len);
77 |
78 | /**
79 | * Finish hashing and output digest value.
80 | *
81 | * @param context hash function context
82 | * @param digest buffer where output digest value is stored
83 | */
84 | void av_sha_final(struct AVSHA* context, uint8_t *digest);
85 |
86 | /**
87 | * @}
88 | */
89 |
90 | #endif /* AVUTIL_SHA_H */
91 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/sha512.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2007 Michael Niedermayer
3 | * Copyright (C) 2013 James Almer
4 | *
5 | * This file is part of FFmpeg.
6 | *
7 | * FFmpeg is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * FFmpeg is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with FFmpeg; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | /**
23 | * @file
24 | * @ingroup lavu_sha512
25 | * Public header for SHA-512 implementation.
26 | */
27 |
28 | #ifndef AVUTIL_SHA512_H
29 | #define AVUTIL_SHA512_H
30 |
31 | #include
32 |
33 | #include "attributes.h"
34 | #include "version.h"
35 |
36 | /**
37 | * @defgroup lavu_sha512 SHA-512
38 | * @ingroup lavu_hash
39 | * SHA-512 (Secure Hash Algorithm) hash function implementations.
40 | *
41 | * This module supports the following SHA-2 hash functions:
42 | *
43 | * - SHA-512/224: 224 bits
44 | * - SHA-512/256: 256 bits
45 | * - SHA-384: 384 bits
46 | * - SHA-512: 512 bits
47 | *
48 | * @see For SHA-1, SHA-256, and variants thereof, see @ref lavu_sha.
49 | *
50 | * @{
51 | */
52 |
53 | extern const int av_sha512_size;
54 |
55 | struct AVSHA512;
56 |
57 | /**
58 | * Allocate an AVSHA512 context.
59 | */
60 | struct AVSHA512 *av_sha512_alloc(void);
61 |
62 | /**
63 | * Initialize SHA-2 512 hashing.
64 | *
65 | * @param context pointer to the function context (of size av_sha512_size)
66 | * @param bits number of bits in digest (224, 256, 384 or 512 bits)
67 | * @return zero if initialization succeeded, -1 otherwise
68 | */
69 | int av_sha512_init(struct AVSHA512* context, int bits);
70 |
71 | /**
72 | * Update hash value.
73 | *
74 | * @param context hash function context
75 | * @param data input data to update hash with
76 | * @param len input data length
77 | */
78 | void av_sha512_update(struct AVSHA512* context, const uint8_t* data, unsigned int len);
79 |
80 | /**
81 | * Finish hashing and output digest value.
82 | *
83 | * @param context hash function context
84 | * @param digest buffer where output digest value is stored
85 | */
86 | void av_sha512_final(struct AVSHA512* context, uint8_t *digest);
87 |
88 | /**
89 | * @}
90 | */
91 |
92 | #endif /* AVUTIL_SHA512_H */
93 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/tea.h:
--------------------------------------------------------------------------------
1 | /*
2 | * A 32-bit implementation of the TEA algorithm
3 | * Copyright (c) 2015 Vesselin Bontchev
4 | *
5 | * This file is part of FFmpeg.
6 | *
7 | * FFmpeg is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * FFmpeg is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with FFmpeg; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | #ifndef AVUTIL_TEA_H
23 | #define AVUTIL_TEA_H
24 |
25 | #include
26 |
27 | /**
28 | * @file
29 | * @brief Public header for libavutil TEA algorithm
30 | * @defgroup lavu_tea TEA
31 | * @ingroup lavu_crypto
32 | * @{
33 | */
34 |
35 | extern const int av_tea_size;
36 |
37 | struct AVTEA;
38 |
39 | /**
40 | * Allocate an AVTEA context
41 | * To free the struct: av_free(ptr)
42 | */
43 | struct AVTEA *av_tea_alloc(void);
44 |
45 | /**
46 | * Initialize an AVTEA context.
47 | *
48 | * @param ctx an AVTEA context
49 | * @param key a key of 16 bytes used for encryption/decryption
50 | * @param rounds the number of rounds in TEA (64 is the "standard")
51 | */
52 | void av_tea_init(struct AVTEA *ctx, const uint8_t key[16], int rounds);
53 |
54 | /**
55 | * Encrypt or decrypt a buffer using a previously initialized context.
56 | *
57 | * @param ctx an AVTEA context
58 | * @param dst destination array, can be equal to src
59 | * @param src source array, can be equal to dst
60 | * @param count number of 8 byte blocks
61 | * @param iv initialization vector for CBC mode, if NULL then ECB will be used
62 | * @param decrypt 0 for encryption, 1 for decryption
63 | */
64 | void av_tea_crypt(struct AVTEA *ctx, uint8_t *dst, const uint8_t *src,
65 | int count, uint8_t *iv, int decrypt);
66 |
67 | /**
68 | * @}
69 | */
70 |
71 | #endif /* AVUTIL_TEA_H */
72 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/time.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2003 Fabrice Bellard
3 | *
4 | * This file is part of FFmpeg.
5 | *
6 | * FFmpeg is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * FFmpeg is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with FFmpeg; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | #ifndef AVUTIL_TIME_H
22 | #define AVUTIL_TIME_H
23 |
24 | #include
25 |
26 | /**
27 | * Get the current time in microseconds.
28 | */
29 | int64_t av_gettime(void);
30 |
31 | /**
32 | * Get the current time in microseconds since some unspecified starting point.
33 | * On platforms that support it, the time comes from a monotonic clock
34 | * This property makes this time source ideal for measuring relative time.
35 | * The returned values may not be monotonic on platforms where a monotonic
36 | * clock is not available.
37 | */
38 | int64_t av_gettime_relative(void);
39 |
40 | /**
41 | * Indicates with a boolean result if the av_gettime_relative() time source
42 | * is monotonic.
43 | */
44 | int av_gettime_relative_is_monotonic(void);
45 |
46 | /**
47 | * Sleep for a period of time. Although the duration is expressed in
48 | * microseconds, the actual delay may be rounded to the precision of the
49 | * system timer.
50 | *
51 | * @param usec Number of microseconds to sleep.
52 | * @return zero on success or (negative) error code.
53 | */
54 | int av_usleep(unsigned usec);
55 |
56 | #endif /* AVUTIL_TIME_H */
57 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/timestamp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | /**
20 | * @file
21 | * timestamp utils, mostly useful for debugging/logging purposes
22 | */
23 |
24 | #ifndef AVUTIL_TIMESTAMP_H
25 | #define AVUTIL_TIMESTAMP_H
26 |
27 | #include "common.h"
28 |
29 | #if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) && !defined(PRId64)
30 | #error missing -D__STDC_FORMAT_MACROS / #define __STDC_FORMAT_MACROS
31 | #endif
32 |
33 | #define AV_TS_MAX_STRING_SIZE 32
34 |
35 | /**
36 | * Fill the provided buffer with a string containing a timestamp
37 | * representation.
38 | *
39 | * @param buf a buffer with size in bytes of at least AV_TS_MAX_STRING_SIZE
40 | * @param ts the timestamp to represent
41 | * @return the buffer in input
42 | */
43 | static inline char *av_ts_make_string(char *buf, int64_t ts)
44 | {
45 | if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
46 | else snprintf(buf, AV_TS_MAX_STRING_SIZE, "%" PRId64, ts);
47 | return buf;
48 | }
49 |
50 | /**
51 | * Convenience macro, the return value should be used only directly in
52 | * function arguments but never stand-alone.
53 | */
54 | #define av_ts2str(ts) av_ts_make_string((char[AV_TS_MAX_STRING_SIZE]){0}, ts)
55 |
56 | /**
57 | * Fill the provided buffer with a string containing a timestamp time
58 | * representation.
59 | *
60 | * @param buf a buffer with size in bytes of at least AV_TS_MAX_STRING_SIZE
61 | * @param ts the timestamp to represent
62 | * @param tb the timebase of the timestamp
63 | * @return the buffer in input
64 | */
65 | static inline char *av_ts_make_time_string(char *buf, int64_t ts, AVRational *tb)
66 | {
67 | if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
68 | else snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.6g", av_q2d(*tb) * ts);
69 | return buf;
70 | }
71 |
72 | /**
73 | * Convenience macro, the return value should be used only directly in
74 | * function arguments but never stand-alone.
75 | */
76 | #define av_ts2timestr(ts, tb) av_ts_make_time_string((char[AV_TS_MAX_STRING_SIZE]){0}, ts, tb)
77 |
78 | #endif /* AVUTIL_TIMESTAMP_H */
79 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libavutil/twofish.h:
--------------------------------------------------------------------------------
1 | /*
2 | * An implementation of the TwoFish algorithm
3 | * Copyright (c) 2015 Supraja Meedinti
4 | *
5 | * This file is part of FFmpeg.
6 | *
7 | * FFmpeg is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU Lesser General Public
9 | * License as published by the Free Software Foundation; either
10 | * version 2.1 of the License, or (at your option) any later version.
11 | *
12 | * FFmpeg is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with FFmpeg; if not, write to the Free Software
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | #ifndef AVUTIL_TWOFISH_H
23 | #define AVUTIL_TWOFISH_H
24 |
25 | #include
26 |
27 |
28 | /**
29 | * @file
30 | * @brief Public header for libavutil TWOFISH algorithm
31 | * @defgroup lavu_twofish TWOFISH
32 | * @ingroup lavu_crypto
33 | * @{
34 | */
35 |
36 | extern const int av_twofish_size;
37 |
38 | struct AVTWOFISH;
39 |
40 | /**
41 | * Allocate an AVTWOFISH context
42 | * To free the struct: av_free(ptr)
43 | */
44 | struct AVTWOFISH *av_twofish_alloc(void);
45 |
46 | /**
47 | * Initialize an AVTWOFISH context.
48 | *
49 | * @param ctx an AVTWOFISH context
50 | * @param key a key of size ranging from 1 to 32 bytes used for encryption/decryption
51 | * @param key_bits number of keybits: 128, 192, 256 If less than the required, padded with zeroes to nearest valid value; return value is 0 if key_bits is 128/192/256, -1 if less than 0, 1 otherwise
52 | */
53 | int av_twofish_init(struct AVTWOFISH *ctx, const uint8_t *key, int key_bits);
54 |
55 | /**
56 | * Encrypt or decrypt a buffer using a previously initialized context
57 | *
58 | * @param ctx an AVTWOFISH context
59 | * @param dst destination array, can be equal to src
60 | * @param src source array, can be equal to dst
61 | * @param count number of 16 byte blocks
62 | * @paran iv initialization vector for CBC mode, NULL for ECB mode
63 | * @param decrypt 0 for encryption, 1 for decryption
64 | */
65 | void av_twofish_crypt(struct AVTWOFISH *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t* iv, int decrypt);
66 |
67 | /**
68 | * @}
69 | */
70 | #endif /* AVUTIL_TWOFISH_H */
71 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libswresample/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Version macros.
3 | *
4 | * This file is part of libswresample
5 | *
6 | * libswresample is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * libswresample is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with libswresample; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | #ifndef SWRESAMPLE_VERSION_H
22 | #define SWRESAMPLE_VERSION_H
23 |
24 | /**
25 | * @file
26 | * Libswresample version macros
27 | */
28 |
29 | #include "libavutil/avutil.h"
30 |
31 | #define LIBSWRESAMPLE_VERSION_MAJOR 2
32 | #define LIBSWRESAMPLE_VERSION_MINOR 7
33 | #define LIBSWRESAMPLE_VERSION_MICRO 100
34 |
35 | #define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \
36 | LIBSWRESAMPLE_VERSION_MINOR, \
37 | LIBSWRESAMPLE_VERSION_MICRO)
38 | #define LIBSWRESAMPLE_VERSION AV_VERSION(LIBSWRESAMPLE_VERSION_MAJOR, \
39 | LIBSWRESAMPLE_VERSION_MINOR, \
40 | LIBSWRESAMPLE_VERSION_MICRO)
41 | #define LIBSWRESAMPLE_BUILD LIBSWRESAMPLE_VERSION_INT
42 |
43 | #define LIBSWRESAMPLE_IDENT "SwR" AV_STRINGIFY(LIBSWRESAMPLE_VERSION)
44 |
45 | #endif /* SWRESAMPLE_VERSION_H */
46 |
--------------------------------------------------------------------------------
/library/src/main/cpp/codec/ffmpeg/libswscale/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of FFmpeg.
3 | *
4 | * FFmpeg is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * FFmpeg is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with FFmpeg; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef SWSCALE_VERSION_H
20 | #define SWSCALE_VERSION_H
21 |
22 | /**
23 | * @file
24 | * swscale version macros
25 | */
26 |
27 | #include "libavutil/version.h"
28 |
29 | #define LIBSWSCALE_VERSION_MAJOR 4
30 | #define LIBSWSCALE_VERSION_MINOR 6
31 | #define LIBSWSCALE_VERSION_MICRO 100
32 |
33 | #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
34 | LIBSWSCALE_VERSION_MINOR, \
35 | LIBSWSCALE_VERSION_MICRO)
36 | #define LIBSWSCALE_VERSION AV_VERSION(LIBSWSCALE_VERSION_MAJOR, \
37 | LIBSWSCALE_VERSION_MINOR, \
38 | LIBSWSCALE_VERSION_MICRO)
39 | #define LIBSWSCALE_BUILD LIBSWSCALE_VERSION_INT
40 |
41 | #define LIBSWSCALE_IDENT "SwS" AV_STRINGIFY(LIBSWSCALE_VERSION)
42 |
43 | /**
44 | * FF_API_* defines may be placed below to indicate public API that will be
45 | * dropped at a future version bump. The defines themselves are not part of
46 | * the public API and may change, break or disappear at any time.
47 | */
48 |
49 | #ifndef FF_API_SWS_VECTOR
50 | #define FF_API_SWS_VECTOR (LIBSWSCALE_VERSION_MAJOR < 6)
51 | #endif
52 |
53 | #endif /* SWSCALE_VERSION_H */
54 |
--------------------------------------------------------------------------------
/library/src/main/cpp/demuxing/adtsenc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include "adtsenc.h"
7 |
8 | int create_adts_context(ADTSContext *adts, unsigned char *pbuf, int bufsize) {
9 | int aot;
10 | int aotext;
11 | int samfreindex;
12 | int channelconfig;
13 | unsigned char *p = pbuf;
14 | if (!adts || !pbuf || bufsize < 2) {
15 | return -1;
16 | }
17 | aot = (p[0] >> 3) & 0x1f;
18 | if (aot == 31) {
19 | aotext = (p[0] << 3 | (p[1] >> 5)) & 0x3f;
20 | aot = 32 + aotext;
21 | samfreindex = (p[1] >> 1) & 0x0f;
22 | if (samfreindex == 0x0f) {
23 | channelconfig = ((p[4] << 3) | (p[5] >> 5)) & 0x0f;
24 | } else {
25 | channelconfig = ((p[1] << 3) | (p[2] >> 5)) & 0x0f;
26 | }
27 | } else {
28 | samfreindex = ((p[0] << 1) | p[1] >> 7) & 0x0f;
29 | if (samfreindex == 0x0f) {
30 | channelconfig = (p[4] >> 3) & 0x0f;
31 | } else {
32 | channelconfig = (p[1] >> 3) & 0x0f;
33 | }
34 | }
35 | #ifdef AOT_PROFILE_CTRL
36 | if (aot < 2) aot = 2;
37 | #endif
38 | adts->objecttype = (uint32_t) (aot - 1);
39 | adts->sample_rate_index = (uint32_t) samfreindex;
40 | adts->channel_conf = (uint32_t) channelconfig;
41 | adts->write_adts = 1;
42 | return 0;
43 | }
44 |
45 | int insert_adts_head(ADTSContext *adts, unsigned char *buf, uint32_t size) {
46 | unsigned char byte;
47 | buf[0] = 0xff;
48 | buf[1] = 0xf1;
49 | byte = 0;
50 | byte |= (adts->objecttype & 0x03) << 6;
51 | byte |= (adts->sample_rate_index & 0x0f) << 2;
52 | byte |= (adts->channel_conf & 0x07) >> 2;
53 | buf[2] = byte;
54 | byte = 0;
55 | byte |= (adts->channel_conf & 0x07) << 6;
56 | byte |= (ADTS_HEADER_SIZE + size) >> 11;
57 | buf[3] = byte;
58 | byte = 0;
59 | byte |= (ADTS_HEADER_SIZE + size) >> 3;
60 | buf[4] = byte;
61 | byte = 0;
62 | byte |= ((ADTS_HEADER_SIZE + size) & 0x7) << 5;
63 | byte |= (0x7ff >> 6) & 0x1f;
64 | buf[5] = byte;
65 | byte = 0;
66 | byte |= (0x7ff & 0x3f) << 2;
67 | buf[6] = byte;
68 | return 0;
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/library/src/main/cpp/demuxing/adtsenc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_ADTSENC_H
7 | #define GPLAYER_ADTSENC_H
8 |
9 | #include
10 |
11 | #define ADTS_HEADER_SIZE 7
12 |
13 | typedef struct ADTSContext {
14 | uint32_t write_adts;
15 | uint32_t objecttype;
16 | uint32_t sample_rate_index;
17 | uint32_t channel_conf;
18 | } ADTSContext;
19 |
20 | int create_adts_context(ADTSContext *adts, unsigned char *pbuf, int bufsize);
21 |
22 | int insert_adts_head(ADTSContext *adts, unsigned char *buf, uint32_t size);
23 |
24 | #endif //GPLAYER_ADTSENC_H
25 |
--------------------------------------------------------------------------------
/library/src/main/cpp/demuxing/avformat_def.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include "avformat_def.h"
7 |
8 | char *get_mime_by_codec_id(CODEC_TYPE type) {
9 | switch (type) {
10 | case CODEC_VIDEO_MPEG2VIDEO:
11 | return MIME_VIDEO_MPEG2VIDEO;
12 | case CODEC_VIDEO_H263:
13 | return MIME_VIDEO_H263;
14 | case CODEC_VIDEO_MPEG4:
15 | return MIME_VIDEO_MPEG4;
16 | case CODEC_VIDEO_AVC:
17 | return MIME_VIDEO_AVC;
18 | case CODEC_VIDEO_VP8:
19 | return MIME_VIDEO_VP8;
20 | case CODEC_VIDEO_VP9:
21 | return MIME_VIDEO_VP9;
22 | case CODEC_VIDEO_HEVC:
23 | return MIME_VIDEO_HEVC;
24 | case CODEC_AUDIO_G711_ALAW:
25 | return MIME_AUDIO_G711_ALAW;
26 | case CODEC_AUDIO_G711_MLAW:
27 | return MIME_AUDIO_G711_MLAW;
28 | case CODEC_AUDIO_AMR_NB:
29 | return MIME_AUDIO_AMR_NB;
30 | case CODEC_AUDIO_AMR_WB:
31 | return MIME_AUDIO_AMR_WB;
32 | case CODEC_AUDIO_MP3:
33 | return MIME_AUDIO_MP3;
34 | case CODEC_AUDIO_RAW_AAC:
35 | return MIME_AUDIO_RAW_AAC;
36 | case CODEC_AUDIO_VORBIS:
37 | return MIME_AUDIO_VORBIS;
38 | default:
39 | return NULL;
40 | }
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/library/src/main/cpp/demuxing/avformat_def.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_AVFORMAT_DEF_H
7 | #define GPLAYER_AVFORMAT_DEF_H
8 |
9 | #include "../codec/ffmpeg/libavcodec/avcodec.h"
10 | #include "../codec/ffmpeg/libavformat/avformat.h"
11 |
12 | typedef struct FormatInfo {
13 | AVCodecParameters *audcodecpar;
14 | AVCodecParameters *vidcodecpar;
15 | AVCodecParameters *subcodecpar;
16 | int duration;
17 | int vidrotate;
18 | int vidframerate;
19 | } FormatInfo;
20 |
21 | typedef enum CODEC_TYPE {
22 | CODEC_START = 0,
23 | CODEC_VIDEO_MPEG2VIDEO = AV_CODEC_ID_MPEG2VIDEO,//2
24 | CODEC_VIDEO_H263 = AV_CODEC_ID_H263,//224
25 | CODEC_VIDEO_MPEG4 = AV_CODEC_ID_MPEG4,//232
26 | CODEC_VIDEO_AVC = AV_CODEC_ID_H264,//247
27 | CODEC_VIDEO_VP8 = AV_CODEC_ID_VP8,//360
28 | CODEC_VIDEO_VP9 = AV_CODEC_ID_VP9,//388
29 | CODEC_VIDEO_HEVC = AV_CODEC_ID_HEVC,//394
30 | CODEC_AUDIO_G711_ALAW = AV_CODEC_ID_PCM_ALAW,//445
31 | CODEC_AUDIO_G711_MLAW = AV_CODEC_ID_PCM_ALAW + 1,
32 | CODEC_AUDIO_AMR_NB = AV_CODEC_ID_AMR_NB,//533
33 | CODEC_AUDIO_AMR_WB = AV_CODEC_ID_AMR_WB,//534
34 | CODEC_AUDIO_MP3 = AV_CODEC_ID_MP3,//550
35 | CODEC_AUDIO_RAW_AAC = AV_CODEC_ID_AAC,//551
36 | CODEC_AUDIO_VORBIS = AV_CODEC_ID_VORBIS,//554
37 | CODEC_END = 0xffffffff,
38 | } CODEC_TYPE;
39 |
40 | #define MIME_VIDEO_MPEG2VIDEO "video/mpeg2" //- MPEG2 video
41 | #define MIME_VIDEO_H263 "video/3gpp" //- H.263 video
42 | #define MIME_VIDEO_MPEG4 "video/mp4v-es" //- MPEG4 video
43 | #define MIME_VIDEO_AVC "video/avc" //- H.264/AVC video
44 | #define MIME_VIDEO_VP8 "video/x-vnd.on2.vp8" //- VP8 video (i.e. video in .webm)
45 | #define MIME_VIDEO_VP9 "video/x-vnd.on2.vp9" //- VP9 video (i.e. video in .webm)
46 | #define MIME_VIDEO_HEVC "video/hevc" //- H.265/HEVC video
47 | #define MIME_AUDIO_G711_ALAW "audio/g711-alaw" //- G.711 alaw audio
48 | #define MIME_AUDIO_G711_MLAW "audio/g711-mlaw" //- G.711 ulaw audio
49 | #define MIME_AUDIO_AMR_NB "audio/3gpp" //- AMR narrowband audio
50 | #define MIME_AUDIO_AMR_WB "audio/amr-wb" //- AMR wideband audio
51 | #define MIME_AUDIO_MP3 "audio/mpeg" //- MPEG1/2 audio layer III
52 | #define MIME_AUDIO_RAW_AAC "audio/mp4a-latm" //- AAC audio (note, this is raw AAC packets, not packaged in LATM!)
53 | #define MIME_AUDIO_VORBIS "audio/vorbis" //- vorbis audio
54 |
55 | char *get_mime_by_codec_id(CODEC_TYPE type);
56 |
57 | #endif //GPLAYER_AVFORMAT_DEF_H
58 |
--------------------------------------------------------------------------------
/library/src/main/cpp/j4a/AudioTrackJni.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include
7 | #include "AudioTrackJni.h"
8 | #include "JniHelper.h"
9 |
10 | #define TAG "AudioTrackJni"
11 |
12 | AudioTrackJni::AudioTrackJni(jobject obj) {
13 | JNIEnv *env = JniHelper::getJNIEnv();
14 | audioTrackObj = env->NewGlobalRef(obj);
15 | audioTrackClass = env->GetObjectClass(obj);
16 | audioTrackStart = env->GetMethodID(audioTrackClass, "open", "(IIII)V");
17 | audioTrackWrite = env->GetMethodID(audioTrackClass, "write", "(Ljava/nio/ByteBuffer;I)I");
18 | audioTrackStop = env->GetMethodID(audioTrackClass, "close", "()V");
19 | }
20 |
21 | AudioTrackJni::~AudioTrackJni() = default;
22 |
23 | void AudioTrackJni::start(int sampleRate, int sampleFormat, int channels, int bytesPerSample) {
24 | LOGI(TAG, "start %d %d %d %d", sampleRate, sampleFormat, channels, bytesPerSample);
25 | bool attach = JniHelper::attachCurrentThread();
26 | if (audioTrackObj != nullptr && audioTrackStart != nullptr) {
27 | JniHelper::callVoidMethod(audioTrackObj, audioTrackStart, sampleRate, sampleFormat,
28 | channels, bytesPerSample);
29 | }
30 | if (attach) {
31 | JniHelper::detachCurrentThread();
32 | }
33 | }
34 |
35 | int AudioTrackJni::write(uint8_t *buffer, int size) {
36 | bool attach = JniHelper::attachCurrentThread();
37 | if (audioTrackObj != nullptr && audioTrackWrite != nullptr) {
38 | JNIEnv *env = JniHelper::getJNIEnv();
39 | jobject byteBuffer = JniHelper::createByteBuffer(env, buffer, size);
40 | int result = JniHelper::callIntMethod(audioTrackObj, audioTrackWrite, byteBuffer, size);
41 | env->DeleteLocalRef(byteBuffer);
42 | return result;
43 | }
44 | if (attach) {
45 | JniHelper::detachCurrentThread();
46 | }
47 | return -1;
48 | }
49 |
50 | void AudioTrackJni::stop() {
51 | bool attach = JniHelper::attachCurrentThread();
52 | if (audioTrackObj != nullptr && audioTrackStop != nullptr) {
53 | JniHelper::callVoidMethod(audioTrackObj, audioTrackStop);
54 | }
55 | if (attach) {
56 | JniHelper::detachCurrentThread();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/library/src/main/cpp/j4a/AudioTrackJni.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_AUDIOTRACKJNI_H
7 | #define GPLAYER_AUDIOTRACKJNI_H
8 |
9 |
10 | #include
11 | #include "source/FrameSource.h"
12 |
13 | class AudioTrackJni {
14 | public:
15 | AudioTrackJni(jobject obj);
16 |
17 | ~AudioTrackJni();
18 |
19 | void start(int sampleRate, int sampleFormat, int channels, int bytesPerSample);
20 |
21 | int write(uint8_t *buffer, int size);
22 |
23 | void stop();
24 |
25 | private:
26 | jclass audioTrackClass;
27 | jmethodID audioTrackStart;
28 | jmethodID audioTrackWrite;
29 | jmethodID audioTrackStop;
30 |
31 | private:
32 | jobject audioTrackObj;
33 | };
34 |
35 |
36 | #endif //GPLAYER_AUDIOTRACKJNI_H
37 |
--------------------------------------------------------------------------------
/library/src/main/cpp/j4a/GPlayerJni.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include
7 | #include
8 | #include "GPlayerJni.h"
9 |
10 | #define TAG "MediaSourceJni"
11 |
12 | GPlayerJni::GPlayerJni(jobject obj) {
13 | LOGI(TAG, "create GPlayerJni");
14 | JNIEnv *env = JniHelper::getJNIEnv();
15 | playerJObj = env->NewGlobalRef(obj);
16 | jclass sourceClass = env->GetObjectClass(obj);
17 | onMessageCallbackMethod = env->GetMethodID(sourceClass, "onMessageCallback",
18 | "(IIJLjava/lang/String;Ljava/lang/String;Ljava/lang/Object;)V");
19 | }
20 |
21 | GPlayerJni::~GPlayerJni() {
22 | bool attach = JniHelper::attachCurrentThread();
23 | JNIEnv *env = JniHelper::getJNIEnv();
24 | if (playerJObj != nullptr && env) {
25 | env->DeleteGlobalRef(playerJObj);
26 | playerJObj = nullptr;
27 | onMessageCallbackMethod = nullptr;
28 | }
29 | if (attach) {
30 | JniHelper::detachCurrentThread();
31 | }
32 | LOGE(TAG, "GPlayerJni destroyed");
33 | }
34 |
35 | void
36 | GPlayerJni::onMessageCallback(int msgId, int arg1, long arg2, const char *msg1, const char *msg2) {
37 | onMessageCallback(msgId, arg1, arg2, msg1, msg2, (jobject)nullptr);
38 | }
39 |
40 | void
41 | GPlayerJni::onMessageCallback(int msgId, int arg1, long arg2, const char *msg1, const char *msg2, jobject obj) {
42 | if (playerJObj != nullptr && onMessageCallbackMethod != nullptr) {
43 | bool attach = JniHelper::attachCurrentThread();
44 |
45 | JNIEnv *env = JniHelper::getJNIEnv();
46 | jstring jMsg1 = msg1 ? JniHelper::newStringUTF(env, msg1) : nullptr;
47 | jstring jMsg2 = msg2 ? JniHelper::newStringUTF(env, msg2) : nullptr;
48 | JniHelper::callVoidMethod(playerJObj, onMessageCallbackMethod, msgId, arg1, arg2, jMsg1,
49 | jMsg2, obj);
50 | if (jMsg1) {
51 | env->DeleteLocalRef(jMsg1);
52 | }
53 | if (jMsg2) {
54 | env->DeleteLocalRef(jMsg2);
55 | }
56 | if (attach) {
57 | JniHelper::detachCurrentThread();
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/library/src/main/cpp/j4a/GPlayerJni.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_GPLAYERJNI_H
7 | #define GPLAYER_GPLAYERJNI_H
8 |
9 | #include
10 | #include
11 |
12 | extern "C" {
13 | #include
14 | }
15 |
16 | class GPlayerJni {
17 | public:
18 | GPlayerJni(jobject obj);
19 |
20 | ~GPlayerJni();
21 |
22 | void onMessageCallback(int msgId, int arg1, long arg2, const char *msg1, const char *msg2);
23 |
24 | void onMessageCallback(int msgId, int arg1, long arg2, const char *msg1, const char *msg2, jobject obj);
25 |
26 | private:
27 | jobject playerJObj;
28 | jmethodID onMessageCallbackMethod;
29 | };
30 |
31 |
32 | #endif //GPLAYER_GPLAYERJNI_H
33 |
--------------------------------------------------------------------------------
/library/src/main/cpp/j4a/JniHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_JNIHELPER_H
7 | #define GPLAYER_JNIHELPER_H
8 |
9 | #include
10 | #include
11 |
12 | using namespace std;
13 |
14 | class JniHelper {
15 | public:
16 | static JNIEnv *getJNIEnv();
17 |
18 | static bool attachCurrentThread();
19 |
20 | static void detachCurrentThread();
21 |
22 | static void throwException(JNIEnv *env, const char *className, const char *msg);
23 |
24 | static jstring newStringUTF(JNIEnv *env, const char *data);
25 |
26 | static string getStringUTF(JNIEnv *env, jstring obj);
27 |
28 | static char *getCharArrayUTF(JNIEnv *env, jstring obj);
29 |
30 | static jobject createByteBuffer(JNIEnv *env, unsigned char *buffer, int size);
31 |
32 | static jobject createByteBuffer(JNIEnv *env, int size);
33 |
34 | static void deleteLocalRef(jobject jobj);
35 |
36 | static void callVoidMethod(jobject obj, jmethodID methodId);
37 |
38 | static void callVoidMethod(jobject obj, jmethodID methodId, jint arg1, jint arg2, jint arg3, jint arg4);
39 |
40 | static void callVoidMethod(jobject obj, jmethodID methodId, jint arg1, jint arg2,
41 | jint arg3, jstring arg4, jstring arg5, jobject arg6);
42 |
43 | static int callIntMethod(jobject obj, jmethodID methodId, jobject arg1, jint arg2);
44 |
45 | static void callStaticVoidMethod(jclass cls, jmethodID methodId, jint arg1);
46 |
47 | static jobject callObjectMethod(jobject obj, jmethodID methodId);
48 |
49 | static jboolean callBooleanMethod(jobject obj, jmethodID methodId);
50 |
51 | public:
52 | static JavaVM *sJavaVM;
53 | };
54 |
55 | #endif //GPLAYER_JNIHELPER_H
56 |
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libavcodec.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libavcodec.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libavdevice.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libavdevice.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libavfilter.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libavfilter.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libavformat.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libavformat.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libavutil.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libavutil.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libswresample.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libswresample.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libswscale.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/arm64-v8a/ffmpeg-lite/libswscale.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libavcodec.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libavcodec.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libavdevice.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libavdevice.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libavfilter.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libavfilter.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libavformat.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libavformat.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libavutil.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libavutil.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libswresample.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libswresample.a
--------------------------------------------------------------------------------
/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libswscale.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/library/src/main/cpp/jniLibs/armeabi-v7a/ffmpeg-lite/libswscale.a
--------------------------------------------------------------------------------
/library/src/main/cpp/media/MediaData.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include "MediaData.h"
11 | #include "MediaHelper.h"
12 |
13 | MediaData::MediaData() = default;
14 |
15 | MediaData::MediaData(uint32_t s, uint32_t s1, uint32_t s2) {
16 | if (s > 0) {
17 | data = static_cast(malloc(s));
18 | }
19 | if (s1 > 0) {
20 | data1 = static_cast(malloc(s1));
21 | }
22 | if (s2 > 0) {
23 | data2 = static_cast(malloc(s2));
24 | }
25 | }
26 |
27 | MediaData::MediaData(uint8_t *d, uint32_t s, uint8_t *d1, uint32_t s1, uint8_t *d2, uint32_t s2) {
28 | if (s > 0) {
29 | data = static_cast(malloc(s));
30 | }
31 | if (s1 > 0) {
32 | data1 = static_cast(malloc(s1));
33 | }
34 | if (s2 > 0) {
35 | data2 = static_cast(malloc(s2));
36 | }
37 | if (d != nullptr && s > 0) {
38 | memcpy(data, d, s);
39 | size = s;
40 | }
41 | if (d1 != nullptr && s1 > 0) {
42 | memcpy(data1, d1, s1);
43 | size1 = s1;
44 | }
45 | if (d2 != nullptr && s2 > 0) {
46 | memcpy(data2, d2, s2);
47 | size2 = s2;
48 | }
49 | }
50 |
51 | MediaData::~MediaData() {
52 | if (data != nullptr) {
53 | free(data);
54 | data = nullptr;
55 | }
56 | if (data1 != nullptr) {
57 | free(data1);
58 | data1 = nullptr;
59 | }
60 | if (data2 != nullptr) {
61 | free(data2);
62 | data2 = nullptr;
63 | }
64 | }
65 |
66 | void MediaData::print() const {
67 | LOGI("MediaData", "print MediaData %d %d %d", size, size1, size2);
68 | }
69 |
--------------------------------------------------------------------------------
/library/src/main/cpp/media/MediaData.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_MEDIADATA_H
7 | #define GPLAYER_MEDIADATA_H
8 |
9 | #include
10 |
11 | class MediaData {
12 | public:
13 | MediaData();
14 |
15 | MediaData(uint32_t s, uint32_t s1, uint32_t s2);
16 |
17 | MediaData(uint8_t *d, uint32_t s, uint8_t *d1, uint32_t s1, uint8_t *d2, uint32_t s2);
18 |
19 | ~MediaData();
20 |
21 | void print() const;
22 |
23 | public:
24 | uint8_t *data = nullptr;
25 | uint32_t size = 0;
26 | uint8_t *data1 = nullptr;
27 | uint32_t size1 = 0;
28 | uint8_t *data2 = nullptr;
29 | uint32_t size2 = 0;
30 |
31 | uint64_t pts = 0;
32 | uint64_t dts = 0;
33 | uint32_t width = 0;
34 | uint32_t height = 0;
35 | uint8_t flag = 0;//与FLAG_KEY_相关
36 | };
37 |
38 |
39 | #endif //GPLAYER_MEDIADATA_H
40 |
--------------------------------------------------------------------------------
/library/src/main/cpp/media/MediaHelper.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include
7 | #include
8 | #include "MediaHelper.h"
9 |
10 | void MediaHelper::copy(MediaData *src, MediaData *des) {
11 | des->pts = src->pts;
12 | des->dts = src->dts;
13 | des->width = src->width;
14 | des->height = src->height;
15 | des->flag = src->flag;
16 | if (src->data != nullptr && src->size > 0) {
17 | des->data = static_cast(malloc(src->size));
18 | memcpy(des->data, src->data, src->size);
19 | des->size = src->size;
20 | }
21 |
22 | if (src->data1 != nullptr && src->size1 > 0) {
23 | des->data1 = static_cast(malloc(src->size1));
24 | memcpy(des->data1, src->data1, src->size1);
25 | des->size1 = src->size1;
26 | }
27 |
28 | if (src->data2 != nullptr && src->size2 > 0) {
29 | des->data2 = static_cast(malloc(src->size2));
30 | memcpy(des->data2, src->data2, src->size2);
31 | des->size2 = src->size2;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/library/src/main/cpp/media/MediaHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_MEDIAHELPER_H
7 | #define GPLAYER_MEDIAHELPER_H
8 |
9 |
10 | #include
11 | #include
12 |
13 | class MediaHelper {
14 | public:
15 | static void copy(MediaData *src, MediaData *des);
16 | };
17 |
18 |
19 | #endif //GPLAYER_MEDIAHELPER_H
20 |
--------------------------------------------------------------------------------
/library/src/main/cpp/player/DecoderHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_DECODERHELPER_H
7 | #define GPLAYER_DECODERHELPER_H
8 |
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | class DecoderHelper {
18 | public:
19 | DecoderHelper(PacketSource *inputSource, FrameSource *outputSource,MessageSource *messageSource,
20 | bool hasAudio, bool hasVideo);
21 |
22 | ~DecoderHelper();
23 |
24 | int onInit();
25 |
26 | int processAudioBuffer(int type, long extra);
27 |
28 | int processVideoBuffer(int type, long extra);
29 |
30 | void onRelease();
31 |
32 | void reset();
33 |
34 | void setMediaCodec(bool enable) {
35 | mediaCodecFirst = enable;
36 | }
37 |
38 | void setANativeWindow(ANativeWindow *window) {
39 | nativeWindow = window;
40 | }
41 |
42 | void setStopWhenEmpty(bool enable) {
43 | stopWhenEmpty = enable;
44 | }
45 |
46 | private:
47 | void createAudioDecoder();
48 |
49 | void createVideoDecoder();
50 |
51 | private:
52 | bool hasInit;
53 | bool mediaCodecFirst;
54 | bool stopWhenEmpty = false;
55 | bool hasAudio = false;
56 | bool hasVideo = false;
57 | PacketSource *inputSource;
58 | FrameSource *outputSource;
59 | MessageSource *messageSource;
60 | VideoDecoder *videoDecoder{};
61 | AudioDecoder *audioDecoder{};
62 | MediaData *videoOutFrame{};
63 | MediaData *audioOutFrame{};
64 | std::mutex audioLock;
65 | std::mutex videoLock;
66 | ANativeWindow *nativeWindow{};
67 | };
68 |
69 |
70 | #endif //GPLAYER_DECODERHELPER_H
71 |
--------------------------------------------------------------------------------
/library/src/main/cpp/player/DemuxerHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_DEMUXERHELPER_H
7 | #define GPLAYER_DEMUXERHELPER_H
8 |
9 | #include
10 | #include
11 |
12 | extern "C" {
13 | #include "adtsenc.h"
14 | #include
15 | }
16 |
17 | #define HAS_AUDIO 0x1
18 | #define HAS_VIDEO 0x2
19 |
20 | class DemuxerHelper {
21 | public:
22 | DemuxerHelper(const std::string &url, PacketSource *input, MessageSource *messageSource);
23 |
24 | ~DemuxerHelper();
25 |
26 | void init();
27 |
28 | int readPacket(int type, long extra);
29 |
30 | void release();
31 |
32 | void notifyError(int ret);
33 |
34 | bool needDiscardPkt(AVPacket pkt);
35 |
36 | private:
37 | char *filename;
38 | PacketSource *inputSource;
39 | MessageSource *messageSource;
40 |
41 | AVFormatContext *ifmt_ctx = nullptr;
42 | int audio_stream_index = -1;
43 | int video_stream_index = -1;
44 | int subtitle_stream_index = -1;
45 | int64_t seekFrameUs = -1;
46 | bool errorExist = false;
47 |
48 | int needVideoStreamFilter = 0;
49 | int needAudioStreamFilter = 0;
50 | ADTSContext mADTSContext{};
51 | unsigned char mADTSHeader[ADTS_HEADER_SIZE] = {0};
52 | AVBSFContext *video_abs_ctx = nullptr;
53 | const AVBitStreamFilter *video_abs_filter = nullptr;
54 | };
55 |
56 |
57 | #endif //GPLAYER_DEMUXERHELPER_H
58 |
--------------------------------------------------------------------------------
/library/src/main/cpp/player/GPlayer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_GPLAYER_H
7 | #define GPLAYER_GPLAYER_H
8 |
9 | #include
10 | #include "DecoderHelper.h"
11 | #include "DemuxerHelper.h"
12 | #include "MessageHelper.h"
13 | #include "GPlayerJni.h"
14 | #include "LoopThread.h"
15 | #include "PacketSource.h"
16 | #include "FrameSource.h"
17 | #include "MessageSource.h"
18 | #include "RenderHelper.h"
19 |
20 | #define AV_FLAG_SOURCE_MEDIA_CODEC 0x00000002
21 |
22 | class GPlayer {
23 |
24 | public:
25 | GPlayer(uint32_t flag, jobject obj);
26 |
27 | ~GPlayer();
28 |
29 | public:
30 | void setSurface(ANativeWindow *window);
31 |
32 | void setAudioTrack(AudioTrackJni *track);
33 |
34 | void prepare(const std::string &url);
35 |
36 | void start();
37 |
38 | void pause();
39 |
40 | void resume();
41 |
42 | void seekTo(uint32_t secondUs);
43 |
44 | void stop();
45 |
46 | void setFlags(uint32_t flags) {
47 | mFlags = flags;
48 | }
49 |
50 | int getDuration();
51 |
52 | int getVideoWidth();
53 |
54 | int getVideoHeight();
55 |
56 | void onDemuxingChanged(int state);
57 |
58 | void onDecodingChanged(int state);
59 |
60 | void onRenderingChanged(int state);
61 |
62 | void onSeekStateChanged(int state);
63 |
64 | void onBufferStateChanged(int state);
65 |
66 | void onPlayStateChanged(int state, long extra);
67 |
68 | private:
69 | int processMessage(int arg1, long arg2);
70 |
71 | void startMessageLoop();
72 |
73 | void stopMessageLoop();
74 |
75 | void startDemuxing(const std::string &url);
76 |
77 | void stopDemuxing();
78 |
79 | void startDecoding();
80 |
81 | void stopDecoding();
82 |
83 | void startRendering();
84 |
85 | void stopRendering();
86 |
87 | void pauseThreads(bool demuxing, bool decoding, bool rendering, bool messaging);
88 |
89 | void resumeThreads(bool demuxing, bool decoding, bool rendering, bool messaging);
90 |
91 | private:
92 | uint32_t mFlags;
93 | ANativeWindow *nativeWindow = nullptr;
94 | AudioTrackJni *audioTrackJni = nullptr;
95 |
96 | PacketSource *packetSource;
97 | FrameSource *frameSource;
98 | MessageSource *messageSource;
99 | DemuxerHelper *demuxerHelper;
100 | DecoderHelper *decoderHelper;
101 | RenderHelper *renderHelper;
102 | MessageHelper *messageHelper;
103 |
104 | LoopThread *demuxerThread;
105 | LoopThread *audioDecodeThread;
106 | LoopThread *videoDecodeThread;
107 | LoopThread *audioRenderThread;
108 | LoopThread *videoRenderThread;
109 | LoopThread *messageThread;
110 |
111 | int playState = -1;
112 | int bufferState = -1;
113 | int seekState = -1;
114 | bool isEof = false;
115 | bool hasAudio = false;
116 | bool hasVideo = false;
117 | std::mutex playerLock;
118 | };
119 |
120 |
121 | #endif //GPLAYER_GPLAYER_H
122 |
--------------------------------------------------------------------------------
/library/src/main/cpp/player/MessageHelper.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include
7 | #include
8 | #include "MessageHelper.h"
9 |
10 | extern "C" {
11 | #include
12 | }
13 |
14 | MessageHelper::MessageHelper(MessageSource *messageSource, jobject obj) {
15 | this->messageSource = messageSource;
16 | playerJni = new GPlayerJni(obj);
17 | }
18 |
19 | MessageHelper::~MessageHelper() {
20 | notifyJava(MSG_DOMAIN_STATE, STATE_END, 0, nullptr, nullptr);
21 | delete playerJni;
22 | }
23 |
24 | void MessageHelper::handleErrorMessage(Message *message) {
25 | const char *errorMsg = error2String(message->type, (int)message->extra);
26 | playerJni->onMessageCallback(MSG_DOMAIN_ERROR, message->type, message->extra, errorMsg, nullptr);
27 | }
28 |
29 | const char *MessageHelper::error2String(int errorCode, int errorExtra) {
30 | const char *errorMsg = nullptr;
31 | if (errorCode == MSG_ERROR_DEMUXING || errorCode == MSG_ERROR_DECODING) {
32 | if (errorExtra < 0) {
33 | errorMsg = av_err2str(errorExtra);
34 | } else if (errorExtra == MSG_ERROR_DEMUXING) {
35 | errorMsg = "demuxing error";
36 | } else if (errorExtra == MSG_ERROR_DECODING) {
37 | errorMsg = "decoding error";
38 | } else if (errorExtra == MSG_ERROR_SEEK) {
39 | errorMsg = "seek error";
40 | } else {
41 | errorMsg = "unknown error";
42 | }
43 | }
44 | return errorMsg;
45 | }
46 |
47 | void MessageHelper::notifyJava(int msgId, int arg1, long arg2, const char *msg1, const char *msg2) {
48 | playerJni->onMessageCallback(msgId, arg1, arg2, msg1, msg2);
49 | }
50 |
--------------------------------------------------------------------------------
/library/src/main/cpp/player/MessageHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_MESSAGEHELPER_H
7 | #define GPLAYER_MESSAGEHELPER_H
8 |
9 |
10 | #include "GPlayerJni.h"
11 | #include "MessageSource.h"
12 |
13 | class MessageHelper {
14 | public:
15 | MessageHelper(MessageSource *messageSource, jobject obj);
16 |
17 | ~MessageHelper();
18 |
19 | void handleErrorMessage(Message *message);
20 |
21 | static const char *error2String(int errorCode, int errorExtra);
22 |
23 | void notifyJava(int msgId, int arg1, long arg2, const char* msg1, const char* msg2);
24 |
25 | private:
26 | MessageSource *messageSource;
27 | GPlayerJni *playerJni;
28 | };
29 |
30 |
31 | #endif //GPLAYER_MESSAGEHELPER_H
32 |
--------------------------------------------------------------------------------
/library/src/main/cpp/player/RenderHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_RENDERHELPER_H
7 | #define GPLAYER_RENDERHELPER_H
8 |
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #define FELLOW_AUDIO 0
15 | #define FELLOW_CLOCK 1
16 |
17 | #define MAX_PTS 9223372036854775807
18 |
19 | class RenderHelper {
20 | public:
21 | RenderHelper(FrameSource *source, MessageSource *messageSource, int mediaCodecFlag,
22 | bool hasAudio, bool hasVideo);
23 |
24 | ~RenderHelper();
25 |
26 | void setNativeWindow(ANativeWindow *window);
27 |
28 | void setAudioTrack(AudioTrackJni *track);
29 |
30 | void setVideoParams(int width, int height);
31 |
32 | void setAudioParams(int sampleRate, int channels, int format, int bytesPerSample);
33 |
34 | void initAudioRenderer();
35 |
36 | void initVideoRenderer();
37 |
38 | int renderAudio(int arg1, long arg2);
39 |
40 | int renderVideo(int arg1, long arg2);
41 |
42 | void releaseAudioRenderer();
43 |
44 | void releaseVideoRenderer();
45 |
46 | void setStopWhenEmpty(bool enable) {
47 | stopWhenEmpty = enable;
48 | }
49 |
50 | private:
51 | AudioRenderer *audioRenderer = nullptr;
52 | VideoRenderer *videoRenderer = nullptr;
53 | MessageSource *messageSource = nullptr;
54 | ANativeWindow *nativeWindow = nullptr;
55 | int videoWidth = 0;
56 | int videoHeight = 0;
57 | uint64_t nowPts = 0;
58 | uint64_t startPts = 0;
59 | uint64_t firstFramePts = 0;
60 | bool hasNotifyFirstFrame = false;
61 | bool stopWhenEmpty = false;
62 | bool hasAudio = false;
63 | bool hasVideo = false;
64 | int avSyncMethod = FELLOW_AUDIO;
65 | };
66 |
67 |
68 | #endif //GPLAYER_RENDERHELPER_H
69 |
--------------------------------------------------------------------------------
/library/src/main/cpp/render/AudioRenderer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include
7 | #include
8 | #include "AudioRenderer.h"
9 |
10 | AudioRenderer::AudioRenderer(FrameSource *source) {
11 | frameSource = source;
12 | audioTrackJni = nullptr;
13 | }
14 |
15 | AudioRenderer::~AudioRenderer() = default;
16 |
17 | void AudioRenderer::setAudioTrack(AudioTrackJni *track) {
18 | audioTrackJni = track;
19 | }
20 |
21 | void AudioRenderer::setAudioParams(int rate, int count, int fmt, int bytes) {
22 | this->sampleRate = rate;
23 | this->channels = count;
24 | this->format = fmt;
25 | this->bytesPerSample = bytes;
26 | }
27 |
28 | void AudioRenderer::init() {
29 | audioTrackJni->start(sampleRate, format, channels, bytesPerSample);
30 | }
31 |
32 | uint64_t AudioRenderer::render(uint64_t nowMs) {
33 | MediaData *mediaData;
34 | if (frameSource->readAudFrame(&mediaData) > 0) {
35 | audioTrackJni->write(mediaData->data, mediaData->size);
36 | frameSource->popAudFrame(mediaData);
37 | return mediaData->pts;
38 | } else {
39 | std::this_thread::sleep_for(std::chrono::milliseconds(5));
40 | }
41 | return 0;
42 | }
43 |
44 | void AudioRenderer::release() {
45 | audioTrackJni->stop();
46 | delete audioTrackJni;
47 | audioTrackJni = nullptr;
48 | }
49 |
--------------------------------------------------------------------------------
/library/src/main/cpp/render/AudioRenderer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_AUDIORENDERER_H
7 | #define GPLAYER_AUDIORENDERER_H
8 |
9 |
10 | #include
11 | #include
12 |
13 | class AudioRenderer {
14 | public:
15 | AudioRenderer(FrameSource *source);
16 |
17 | ~AudioRenderer();
18 |
19 | void setAudioTrack(AudioTrackJni *track);
20 |
21 | void setAudioParams(int rate, int channels, int format, int bytesPerSample);
22 |
23 | void init();
24 |
25 | uint64_t render(uint64_t nowMs);
26 |
27 | void release();
28 |
29 | private:
30 | FrameSource *frameSource;
31 | AudioTrackJni *audioTrackJni;
32 | int sampleRate = 0;
33 | int channels = 0;
34 | int format = 0;
35 | int bytesPerSample = 0;
36 | };
37 |
38 |
39 | #endif //GPLAYER_AUDIORENDERER_H
40 |
--------------------------------------------------------------------------------
/library/src/main/cpp/render/EglRenderer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef EGL_RENDERER_H
7 | #define EGL_RENDERER_H
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include "YuvGlesProgram.h"
14 |
15 | class EglRenderer {
16 |
17 | public:
18 | EglRenderer();
19 |
20 | ~EglRenderer();
21 |
22 | void setWindow(ANativeWindow *window);
23 |
24 | void setVideoSize(int width, int height);
25 |
26 | bool initialize();
27 |
28 | void destroy();
29 |
30 | void swapBuffers();
31 |
32 | private:
33 | ANativeWindow *_window{};
34 | int videoWidth = 0;
35 | int videoHeight = 0;
36 |
37 | EGLDisplay _display{};
38 | EGLSurface _surface{};
39 | EGLContext _context{};
40 | };
41 |
42 | #endif // EGL_RENDERER_H
43 |
--------------------------------------------------------------------------------
/library/src/main/cpp/render/SurfaceVideoRenderer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include
7 | #include
8 | #include "SurfaceVideoRenderer.h"
9 |
10 | SurfaceVideoRenderer::SurfaceVideoRenderer(FrameSource *source) {
11 | LOGI("VideoRenderer", "CoreFlow : new SurfaceVideoRenderer");
12 | mediaSource = source;
13 | }
14 |
15 | SurfaceVideoRenderer::~SurfaceVideoRenderer() = default;
16 |
17 | void SurfaceVideoRenderer::surfaceCreated(ANativeWindow *window, int videoWidth, int videoHeight) {
18 |
19 | }
20 |
21 | void SurfaceVideoRenderer::surfaceChanged(int width, int height) {
22 |
23 | }
24 |
25 | void SurfaceVideoRenderer::surfaceDestroyed() {
26 |
27 | }
28 |
29 | uint64_t SurfaceVideoRenderer::render(uint64_t nowMs) {
30 | MediaData *mediaData;
31 | if (mediaSource->readVidFrame(&mediaData) > 0) {
32 | if (nowMs > mediaData->pts) {
33 | mediaSource->popVidFrame(mediaData);
34 | return mediaData->pts;
35 | }
36 | }
37 | std::this_thread::sleep_for(std::chrono::milliseconds(5));
38 | return 0;
39 | }
40 |
--------------------------------------------------------------------------------
/library/src/main/cpp/render/SurfaceVideoRenderer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_SURFACEVIDEORENDERER_H
7 | #define GPLAYER_SURFACEVIDEORENDERER_H
8 |
9 |
10 | #include
11 | #include "VideoRenderer.h"
12 | #include "source/FrameSource.h"
13 |
14 | class SurfaceVideoRenderer : public VideoRenderer {
15 | public:
16 | SurfaceVideoRenderer(FrameSource *source);
17 |
18 | ~SurfaceVideoRenderer();
19 |
20 | void surfaceCreated(ANativeWindow *window, int videoWidth, int videoHeight);
21 |
22 | void surfaceChanged(int width, int height);
23 |
24 | void surfaceDestroyed();
25 |
26 | uint64_t render(uint64_t nowMs);
27 |
28 | bool isRenderValid() {
29 | return true;
30 | }
31 |
32 | private:
33 | FrameSource *mediaSource;
34 | };
35 |
36 |
37 | #endif //GPLAYER_SURFACEVIDEORENDERER_H
38 |
--------------------------------------------------------------------------------
/library/src/main/cpp/render/VideoRenderer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_VIDEORENDERER_H
7 | #define GPLAYER_VIDEORENDERER_H
8 |
9 |
10 | class VideoRenderer {
11 | public:
12 | virtual ~VideoRenderer() {};
13 |
14 | virtual void surfaceCreated(ANativeWindow *window, int videoWidth, int videoHeight) = 0;
15 |
16 | virtual void surfaceChanged(int width, int height) = 0;
17 |
18 | virtual void surfaceDestroyed() = 0;
19 |
20 | virtual uint64_t render(uint64_t nowMs) = 0;
21 |
22 | virtual bool isRenderValid() = 0;
23 | };
24 |
25 |
26 | #endif //GPLAYER_VIDEORENDERER_H
27 |
--------------------------------------------------------------------------------
/library/src/main/cpp/render/YuvGlesProgram.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_YUVGLESPROGRAM_H
7 | #define GPLAYER_YUVGLESPROGRAM_H
8 |
9 | #include
10 | #include
11 | #include
12 |
13 |
14 | #define VERTEX_SHADER \
15 | "attribute vec4 a_position;\n" \
16 | "attribute vec2 a_texCoord;\n" \
17 | "varying vec2 v_color;\n" \
18 | "uniform mat4 u_mvp;\n" \
19 | "void main() {\n" \
20 | "gl_Position = u_mvp * a_position;\n" \
21 | "v_color = a_texCoord;\n" \
22 | "}\n"
23 |
24 | #define FRAGMENT_SHADER \
25 | "precision mediump float;\n" \
26 | "uniform sampler2D tex_y;\n" \
27 | "uniform sampler2D tex_u;\n" \
28 | "uniform sampler2D tex_v;\n" \
29 | "varying vec2 v_color;\n" \
30 | "void main() {\n" \
31 | "vec4 c = vec4((texture2D(tex_y, v_color).r - 16./255.) * 1.164);\n" \
32 | "vec4 U = vec4(texture2D(tex_u, v_color).r - 128./255.);\n" \
33 | "vec4 V = vec4(texture2D(tex_v, v_color).r - 128./255.);\n" \
34 | "c += V * vec4(1.596, -0.813, 0, 0);\n" \
35 | "c += U * vec4(0, -0.392, 2.017, 0);\n" \
36 | "c.a = 1.0;\n" \
37 | "gl_FragColor = c;\n" \
38 | "}\n"
39 |
40 | class YuvGlesProgram {
41 |
42 | private:
43 | GLfloat *SQUARE_VERTICES;
44 | GLfloat *COORD_VERTICES;
45 | GLfloat *MVP_MATRIX;
46 |
47 | public:
48 | YuvGlesProgram();
49 |
50 | ~YuvGlesProgram();
51 |
52 | bool buildProgram();
53 |
54 | void buildTextures(uint8_t *y, uint8_t *u, uint8_t *v, uint32_t width, uint32_t height);
55 |
56 | void drawFrame();
57 |
58 | private:
59 | GLuint createProgram(char *vertexSource, char *fragmentSource);
60 |
61 | GLuint loadShader(GLenum shaderType, char *source);
62 |
63 | private:
64 | // program id
65 | GLuint _program;
66 | // texture id
67 | GLuint _textureI;
68 | GLuint _textureII;
69 | GLuint _textureIII;
70 | // texture index in gles
71 | GLuint _tIindex;
72 | GLuint _tIIindex;
73 | GLuint _tIIIindex;
74 | // handles
75 | GLuint _mvpHandle;
76 | GLuint _positionHandle, _coordHandle;
77 | GLuint _yhandle, _uhandle, _vhandle;
78 | GLuint _ytid, _utid, _vtid;
79 | // video width and height
80 | uint32_t _video_width;
81 | uint32_t _video_height;
82 | };
83 |
84 |
85 | #endif //GPLAYER_YUVGLESPROGRAM_H
86 |
--------------------------------------------------------------------------------
/library/src/main/cpp/render/YuvVideoRenderer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include
7 | #include "YuvVideoRenderer.h"
8 | #include "media/MediaData.h"
9 |
10 | YuvVideoRenderer::YuvVideoRenderer(FrameSource *source) {
11 | LOGI("VideoRenderer", "CoreFlow : new YuvVideoRenderer");
12 | eglRenderer = new EglRenderer();
13 | glProgram = new YuvGlesProgram();
14 | mediaSource = source;
15 | }
16 |
17 | YuvVideoRenderer::~YuvVideoRenderer() {
18 | delete eglRenderer;
19 | eglRenderer = nullptr;
20 | delete glProgram;
21 | glProgram = nullptr;
22 | }
23 |
24 | void YuvVideoRenderer::surfaceCreated(ANativeWindow *window, int videoWidth, int videoHeight) {
25 | eglRenderer->setWindow(window);
26 | eglRenderer->setVideoSize(videoWidth, videoHeight);
27 | if (eglRenderer->initialize()) {
28 | isEglInit = glProgram->buildProgram();
29 | }
30 |
31 | LOGE("VideoRenderer", "surfaceCreated isEglInit %d", isEglInit);
32 | }
33 |
34 | void YuvVideoRenderer::surfaceChanged(int width, int height) {
35 |
36 | }
37 |
38 | void YuvVideoRenderer::surfaceDestroyed() {
39 | eglRenderer->destroy();
40 | }
41 |
42 | uint64_t YuvVideoRenderer::render(uint64_t nowMs) {
43 | MediaData *mediaData;
44 | if (mediaSource->readVidFrame(&mediaData) > 0) {
45 | if (nowMs > mediaData->pts) {
46 | glProgram->buildTextures(mediaData->data, mediaData->data1, mediaData->data2,
47 | mediaData->width, mediaData->height);
48 | glProgram->drawFrame();
49 | eglRenderer->swapBuffers();
50 | mediaSource->popVidFrame(mediaData);
51 | return mediaData->pts;
52 | }
53 | }
54 | std::this_thread::sleep_for(std::chrono::milliseconds(5));
55 | return 0;
56 | }
57 |
--------------------------------------------------------------------------------
/library/src/main/cpp/render/YuvVideoRenderer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_YUVVIDEORENDERER_H
7 | #define GPLAYER_YUVVIDEORENDERER_H
8 |
9 |
10 | #include "EglRenderer.h"
11 | #include "source/FrameSource.h"
12 | #include "VideoRenderer.h"
13 |
14 | class YuvVideoRenderer : public VideoRenderer {
15 | public:
16 | YuvVideoRenderer(FrameSource *source);
17 |
18 | ~YuvVideoRenderer();
19 |
20 | void surfaceCreated(ANativeWindow *window, int videoWidth, int videoHeight);
21 |
22 | void surfaceChanged(int width, int height);
23 |
24 | void surfaceDestroyed();
25 |
26 | uint64_t render(uint64_t nowMs);
27 |
28 | bool isRenderValid() {
29 | return isEglInit;
30 | }
31 |
32 | private:
33 | EglRenderer *eglRenderer;
34 | YuvGlesProgram *glProgram;
35 | FrameSource *mediaSource;
36 | bool isEglInit = false;
37 | };
38 |
39 |
40 | #endif //GPLAYER_YUVVIDEORENDERER_H
41 |
--------------------------------------------------------------------------------
/library/src/main/cpp/source/FrameSource.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include
7 | #include
8 | #include
9 | #include "FrameSource.h"
10 |
11 | #define TAG "FrameSource"
12 |
13 | FrameSource::FrameSource(int audioMaxSize, int videoMaxSize) {
14 | LOGI(TAG, "CoreFlow : create FrameSource");
15 | audioPacketQueue = new ConcurrentQueue(audioMaxSize, "AudioFrameQueue");
16 | videoPacketQueue = new ConcurrentQueue(videoMaxSize, "VideoFrameQueue");
17 | }
18 |
19 | FrameSource::~FrameSource() {
20 | LOGI(TAG, "CoreFlow : FrameSource destroyed %d %d",
21 | audioPacketQueue->size(), videoPacketQueue->size());
22 | delete audioPacketQueue;
23 | audioPacketQueue = nullptr;
24 | delete videoPacketQueue;
25 | videoPacketQueue = nullptr;
26 | }
27 |
28 | unsigned long FrameSource::pushAudFrame(MediaData *frame) {
29 | LOGD(TAG, "pushAudFrame %lld", frame->pts);
30 | auto desBuffer = new MediaData();
31 | MediaHelper::copy(frame, desBuffer);
32 | return audioPacketQueue->push(desBuffer);
33 | }
34 |
35 | unsigned long FrameSource::pushVidFrame(MediaData *frame) {
36 | LOGD(TAG, "pushVidFrame %lld", frame->pts);
37 | auto desBuffer = new MediaData();
38 | MediaHelper::copy(frame, desBuffer);
39 | return videoPacketQueue->push(desBuffer);
40 | }
41 |
42 | unsigned long FrameSource::readAudFrame(MediaData **frame) {
43 | unsigned long size = audioPacketQueue->front(frame);
44 | if (size > 0) {
45 | LOGD(TAG, "readAudFrame %lld", (*frame)->pts);
46 | }
47 | return size;
48 | }
49 |
50 | unsigned long FrameSource::readVidFrame(MediaData **frame) {
51 | unsigned long size = videoPacketQueue->front(frame);
52 | if (size > 0) {
53 | LOGD(TAG, "readVidFrame %lld", (*frame)->pts);
54 | }
55 | return size;
56 | }
57 |
58 | void FrameSource::popAudFrame(MediaData *frame) {
59 | LOGD(TAG, "popAudFrame %lld", frame->pts);
60 | audioPacketQueue->pop();
61 | }
62 |
63 | void FrameSource::popVidFrame(MediaData *frame) {
64 | LOGD(TAG, "popVidFrame %lld", frame->pts);
65 | videoPacketQueue->pop();
66 | }
67 |
68 | void FrameSource::flush() {
69 | audioPacketQueue->flush();
70 | videoPacketQueue->flush();
71 | LOGI(TAG, "flushBuffer");
72 | }
73 |
74 | void FrameSource::reset() {
75 | audioPacketQueue->reset();
76 | videoPacketQueue->reset();
77 | }
78 |
79 | unsigned long FrameSource::audioSize() {
80 | return audioPacketQueue->size();
81 | }
82 |
83 | unsigned long FrameSource::videoSize() {
84 | return videoPacketQueue->size();
85 | }
86 |
--------------------------------------------------------------------------------
/library/src/main/cpp/source/FrameSource.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_FRAMESOURCE_H
7 | #define GPLAYER_FRAMESOURCE_H
8 |
9 |
10 | #include "media/MediaData.h"
11 | #include "ConcurrentQueue.h"
12 |
13 | extern "C" {
14 | #include
15 | }
16 |
17 | class FrameSource {
18 |
19 | public:
20 | FrameSource(int audioMaxSize, int videoMaxSize);
21 |
22 | ~FrameSource();
23 |
24 | public:
25 | unsigned long pushAudFrame(MediaData *frame);
26 |
27 | unsigned long pushVidFrame(MediaData *frame);
28 |
29 | unsigned long readAudFrame(MediaData **frame);
30 |
31 | unsigned long readVidFrame(MediaData **frame);
32 |
33 | void popAudFrame(MediaData *frame);
34 |
35 | void popVidFrame(MediaData *frame);
36 |
37 | void flush();
38 |
39 | void reset();
40 |
41 | unsigned long audioSize();
42 |
43 | unsigned long videoSize();
44 |
45 | private:
46 | ConcurrentQueue *audioPacketQueue;
47 | ConcurrentQueue *videoPacketQueue;
48 | };
49 |
50 |
51 | #endif //GPLAYER_FRAMESOURCE_H
52 |
--------------------------------------------------------------------------------
/library/src/main/cpp/source/MessageSource.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #include
7 | #include
8 | #include "MessageSource.h"
9 |
10 | #define TAG "MessageSource"
11 |
12 | MessageSource::MessageSource() {
13 | LOGI("MessageSource", "CoreFlow : create MessageSource");
14 | msgQueue = new ConcurrentQueue(1000000, "MessageQueue");
15 | }
16 |
17 | MessageSource::~MessageSource() {
18 | LOGI("MessageSource", "CoreFlow : MessageSource destroyed %d", msgQueue->size());
19 | delete msgQueue;
20 | msgQueue = nullptr;
21 | }
22 |
23 | void MessageSource::pushMessage(int from, int type, long extra) {
24 | if (from == MSG_DOMAIN_TIME) {
25 | if (currentTime == type) {
26 | return;
27 | }
28 | currentTime = type;
29 | auto message = new Message(from, type, extra);
30 | msgQueue->push(message);
31 | } else {
32 | auto message = new Message(from, type, extra);
33 | msgQueue->push(message);
34 | }
35 | LOGI(TAG, "pushMessage size = %d", msgQueue->size());
36 | }
37 |
38 | unsigned long MessageSource::readMessage(Message **message) {
39 | unsigned long size = msgQueue->front(message);
40 | return size;
41 | }
42 |
43 | void MessageSource::popMessage() {
44 | msgQueue->pop();
45 | }
46 |
47 | void MessageSource::flush() {
48 | msgQueue->flush();
49 | LOGI(TAG, "flushBuffer");
50 | }
51 |
52 | void MessageSource::reset() {
53 | msgQueue->reset();
54 | }
55 |
56 | unsigned long MessageSource::size() {
57 | return msgQueue->size();
58 | }
59 |
--------------------------------------------------------------------------------
/library/src/main/cpp/source/MessageSource.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_MESSAGESOURCE_H
7 | #define GPLAYER_MESSAGESOURCE_H
8 |
9 | #include "ConcurrentQueue.h"
10 |
11 | #define MAX_BUFFER_PACKET_SIZE 200
12 | #define MAX_BUFFER_FRAME_SIZE 5
13 |
14 | #define MSG_DOMAIN_ERROR 0
15 | #define MSG_DOMAIN_STATE 1
16 | #define MSG_DOMAIN_TIME 2
17 | #define MSG_DOMAIN_BUFFER 3
18 | #define MSG_DOMAIN_DEMUXING 4
19 | #define MSG_DOMAIN_DECODING 5
20 | #define MSG_DOMAIN_COMPLETE 6
21 | #define MSG_DOMAIN_SEEK 7
22 |
23 | #define MSG_ERROR_DEMUXING 0
24 | #define MSG_ERROR_DECODING 1
25 | #define MSG_ERROR_RENDERING 2
26 | #define MSG_ERROR_SEEK 3
27 |
28 | #define MSG_DEMUXING_INIT 0
29 | #define MSG_DEMUXING_DESTROY 1
30 | #define MSG_DEMUXING_EOF 2
31 |
32 | #define MSG_SEEK_START 0
33 | #define MSG_SEEK_END 1
34 |
35 | #define STATE_IDLE 0
36 | #define STATE_INITIALIZED 1
37 | #define STATE_PREPARING 2
38 | #define STATE_PREPARED 3
39 | #define STATE_STARTED 4
40 | #define STATE_PAUSED 5
41 | #define STATE_STOPPED 6
42 | #define STATE_COMPLETED 7
43 | #define STATE_END 8
44 | #define STATE_ERROR 9
45 |
46 |
47 | class Message {
48 | public:
49 | Message(int from, int type, long extra) {
50 | this->from = from;
51 | this->type = type;
52 | this->extra = extra;
53 | }
54 |
55 | int from;
56 | int type;
57 | long extra;
58 | };
59 |
60 | class MessageSource {
61 | public:
62 | MessageSource();
63 |
64 | ~MessageSource();
65 |
66 | void pushMessage(int from, int type, long extra);
67 |
68 | unsigned long readMessage(Message **message);
69 |
70 | void popMessage();
71 |
72 | void flush();
73 |
74 | void reset();
75 |
76 | unsigned long size();
77 |
78 | private:
79 | ConcurrentQueue *msgQueue;
80 | int currentTime = 0;
81 | };
82 |
83 |
84 | #endif //GPLAYER_MESSAGESOURCE_H
85 |
--------------------------------------------------------------------------------
/library/src/main/cpp/source/PacketSource.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Gibbs on 2021/1/1.
3 | * Copyright (c) 2021 Gibbs. All rights reserved.
4 | */
5 |
6 | #ifndef GPLAYER_PACKETSOURCE_H
7 | #define GPLAYER_PACKETSOURCE_H
8 |
9 |
10 | #include "MessageSource.h"
11 | #include "ConcurrentQueue.h"
12 |
13 | extern "C" {
14 | #include
15 | #include "codec/ffmpeg/libavcodec/avcodec.h"
16 | }
17 |
18 | class PacketSource {
19 |
20 | public:
21 | PacketSource(int audioMaxSize, int videoMaxSize);
22 |
23 | ~PacketSource();
24 |
25 | public:
26 | void setFormatInfo(FormatInfo *formatInfo);
27 |
28 | FormatInfo* getFormatInfo();
29 |
30 | AVCodecParameters* getAudioAVCodecParameters();
31 |
32 | AVCodecParameters* getVideoAVCodecParameters();
33 |
34 | unsigned long pushAudPkt(AVPacket *pkt, AVRational time_base);
35 |
36 | unsigned long pushVidPkt(AVPacket *pkt, AVRational time_base);
37 |
38 | unsigned long readAudPkt(AVPacket **pkt);
39 |
40 | unsigned long readVidPkt(AVPacket **pkt);
41 |
42 | void popAudPkt(AVPacket *pkt);
43 |
44 | void popVidPkt(AVPacket *pkt);
45 |
46 | void flush();
47 |
48 | void reset();
49 |
50 | unsigned long audioSize();
51 |
52 | unsigned long videoSize();
53 |
54 | private:
55 | FormatInfo *mFormatInfo;
56 | AvConcurrentQueue *videoPacketQueue;
57 | AvConcurrentQueue *audioPacketQueue;
58 | };
59 |
60 |
61 | #endif //GPLAYER_PACKETSOURCE_H
62 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 29
7 | buildToolsVersion "29.0.2"
8 |
9 |
10 | defaultConfig {
11 | applicationId "com.gibbs.gplayer.sample"
12 | minSdkVersion 21
13 | targetSdkVersion 29
14 | versionCode rootProject.ext.versionCode
15 | versionName rootProject.ext.versionName
16 |
17 | consumerProguardFiles 'consumer-rules.pro'
18 | ndk {
19 | abiFilters 'armeabi-v7a', 'arm64-v8a'
20 | }
21 | }
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 | android.applicationVariants.all {
29 | variant ->
30 | variant.outputs.all {
31 | outputFileName = "GPlayer-sample-${variant.buildType.name}-${versionName}-v${versionCode}.apk"
32 | }
33 | }
34 | }
35 |
36 | dependencies {
37 | implementation fileTree(dir: 'libs', include: ['*.jar'])
38 |
39 | //google open source
40 | implementation "androidx.core:core-ktx:1.3.1"
41 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
42 | implementation 'androidx.appcompat:appcompat:1.1.0'
43 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
44 | implementation 'androidx.preference:preference:1.1.1'
45 | implementation 'androidx.recyclerview:recyclerview:1.1.0'
46 | implementation "com.google.android.material:material:1.1.0"
47 |
48 | //第三方库
49 | implementation 'com.github.bumptech.glide:glide:4.11.0'
50 | implementation 'com.google.code.gson:gson:2.8.6'
51 | annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
52 |
53 | implementation project(":library")
54 | }
55 | repositories {
56 | mavenCentral()
57 | }
58 |
--------------------------------------------------------------------------------
/sample/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/consumer-rules.pro
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
17 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/sample/src/main/assets/playlist.json:
--------------------------------------------------------------------------------
1 | {
2 | "links": [
3 | ]
4 | }
5 |
--------------------------------------------------------------------------------
/sample/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/sample/src/main/ic_launcher_round-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/ic_launcher_round-web.png
--------------------------------------------------------------------------------
/sample/src/main/java/com/gibbs/gplayer/sample/BaseActivity.kt:
--------------------------------------------------------------------------------
1 | package com.gibbs.gplayer.sample
2 |
3 | import android.os.Bundle
4 | import android.view.MenuItem
5 | import androidx.appcompat.app.AppCompatActivity
6 |
7 | open class BaseActivity : AppCompatActivity() {
8 | override fun onCreate(savedInstanceState: Bundle?) {
9 | super.onCreate(savedInstanceState)
10 | supportActionBar?.setDisplayHomeAsUpEnabled(true)
11 | supportActionBar?.setDisplayShowHomeEnabled(true)
12 | }
13 |
14 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
15 | LogUtils.i("BaseActivity", "onOptionsItemSelected ${item.itemId}")
16 | if (item.itemId == android.R.id.home) {
17 | LogUtils.i("BaseActivity", "finish activity")
18 | finish()
19 | return true
20 | }
21 | return super.onOptionsItemSelected(item)
22 | }
23 | }
--------------------------------------------------------------------------------
/sample/src/main/java/com/gibbs/gplayer/sample/LogUtils.java:
--------------------------------------------------------------------------------
1 | package com.gibbs.gplayer.sample;
2 |
3 | import android.util.Log;
4 |
5 |
6 | public class LogUtils {
7 | private static final boolean LOG_SWITCH = false;
8 |
9 | public static void e(final String tag, final String msg) {
10 | e(tag, msg, (Object[]) null);
11 | }
12 |
13 | public static void w(final String tag, final String msg) {
14 | w(tag, msg, (Object[]) null);
15 | }
16 |
17 | public static void i(final String tag, final String msg) {
18 | i(tag, msg, (Object[]) null);
19 | }
20 |
21 | public static void d(final String tag, final String msg) {
22 | d(tag, msg, (Object[]) null);
23 | }
24 |
25 | public static void v(final String tag, final String msg) {
26 | v(tag, msg, (Object[]) null);
27 | }
28 |
29 | public static void e(String tag, final String format, final Object... obj) {
30 | Log.e(tag, format);
31 | }
32 |
33 | public static void w(String tag, final String format, final Object... obj) {
34 | Log.w(tag, format);
35 | }
36 |
37 | public static void i(String tag, final String format, final Object... obj) {
38 | Log.i(tag, format);
39 | }
40 |
41 | public static void d(String tag, final String format, final Object... obj) {
42 | if (LOG_SWITCH) Log.d(tag, format);
43 | }
44 |
45 | public static void v(String tag, final String format, final Object... obj) {
46 | Log.v(tag, format);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/gibbs/gplayer/sample/model/PlayList.java:
--------------------------------------------------------------------------------
1 | package com.gibbs.gplayer.sample.model;
2 |
3 | import com.google.gson.Gson;
4 |
5 | import java.util.List;
6 |
7 | public class PlayList {
8 | public static PlayList createPlayList(String jsonString) {
9 | Gson gson = new Gson();
10 | return gson.fromJson(jsonString, PlayList.class);
11 | }
12 |
13 | private List links;
14 |
15 | public List getLinks() {
16 | return links;
17 | }
18 |
19 | public void setLinks(List links) {
20 | this.links = links;
21 | }
22 |
23 | public static class Links {
24 | /**
25 | * name : cctv1_2
26 | * url : http://cctvalih5ca.v.myalicdn.com/live/cctv1_2/index.m3u8
27 | */
28 |
29 | private String name;
30 | private String url;
31 |
32 | public String getName() {
33 | return name;
34 | }
35 |
36 | public void setName(String name) {
37 | this.name = name;
38 | }
39 |
40 | public String getUrl() {
41 | return url;
42 | }
43 |
44 | public void setUrl(String url) {
45 | this.url = url;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/gibbs/gplayer/sample/model/VideoItem.kt:
--------------------------------------------------------------------------------
1 | package com.gibbs.gplayer.sample.model
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 |
6 | data class VideoItem(val videoPath: String, val name: String) : Parcelable {
7 | constructor(parcel: Parcel) : this(
8 | parcel.readString()!!,
9 | parcel.readString()!!) {
10 | }
11 |
12 | override fun writeToParcel(dest: Parcel?, flags: Int) {
13 | dest?.writeString(videoPath)
14 | dest?.writeString(name)
15 | }
16 |
17 | override fun describeContents(): Int {
18 | return 0
19 | }
20 |
21 | companion object CREATOR : Parcelable.Creator {
22 | override fun createFromParcel(parcel: Parcel): VideoItem {
23 | return VideoItem(parcel)
24 | }
25 |
26 | override fun newArray(size: Int): Array {
27 | return arrayOfNulls(size)
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/sample/src/main/java/com/gibbs/gplayer/sample/model/VideoItemHolder.kt:
--------------------------------------------------------------------------------
1 | package com.gibbs.gplayer.sample.model
2 |
3 | import android.view.View
4 | import android.widget.TextView
5 | import androidx.appcompat.widget.AppCompatImageView
6 | import androidx.constraintlayout.widget.ConstraintLayout
7 | import androidx.recyclerview.widget.RecyclerView
8 | import com.gibbs.gplayer.sample.R
9 |
10 | class VideoItemHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
11 | val rootView: ConstraintLayout = itemView.findViewById(R.id.root_view)
12 | val videoThumbnail: AppCompatImageView = itemView.findViewById(R.id.video_thumbnail)
13 | val videoName: TextView = itemView.findViewById(R.id.video_name)
14 | }
--------------------------------------------------------------------------------
/sample/src/main/java/com/gibbs/gplayer/sample/widget/OvalImageView.kt:
--------------------------------------------------------------------------------
1 | package com.gibbs.gplayer.sample.widget
2 |
3 | import android.content.Context
4 | import android.content.res.Resources
5 | import android.graphics.Canvas
6 | import android.graphics.Path
7 | import android.graphics.RectF
8 | import android.util.AttributeSet
9 | import android.util.TypedValue
10 | import androidx.appcompat.widget.AppCompatImageView
11 |
12 | class OvalImageView : AppCompatImageView {
13 | private val circleValue = 8f
14 | private val rids = floatArrayOf(dp2px(circleValue).toFloat(), dp2px(circleValue).toFloat(), dp2px(circleValue).toFloat(), dp2px(circleValue).toFloat(),
15 | dp2px(circleValue).toFloat(), dp2px(circleValue).toFloat(), dp2px(circleValue).toFloat(), dp2px(circleValue).toFloat())
16 | private val path = Path()
17 | private val rect = RectF()
18 |
19 | constructor(context: Context?) : super(context)
20 | constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
21 | constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
22 |
23 | override fun onDraw(canvas: Canvas) {
24 | val w = this.width
25 | val h = this.height
26 | rect[0f, 0f, w.toFloat()] = h.toFloat()
27 | path.addRoundRect(rect, rids, Path.Direction.CW)
28 | canvas.clipPath(path)
29 | super.onDraw(canvas)
30 | }
31 |
32 | private fun dp2px(dp: Float): Int {
33 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
34 | Resources.getSystem().displayMetrics).toInt()
35 | }
36 | }
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-anydpi/ic_pause_video.xml:
--------------------------------------------------------------------------------
1 |
8 |
12 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-anydpi/ic_play_video.xml:
--------------------------------------------------------------------------------
1 |
8 |
12 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-anydpi/ic_video_play.xml:
--------------------------------------------------------------------------------
1 |
8 |
10 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-hdpi/ic_pause_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/drawable-hdpi/ic_pause_video.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-hdpi/ic_play_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/drawable-hdpi/ic_play_video.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-hdpi/ic_video_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/drawable-hdpi/ic_video_play.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-mdpi/ic_pause_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/drawable-mdpi/ic_pause_video.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-mdpi/ic_play_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/drawable-mdpi/ic_play_video.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-mdpi/ic_video_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/drawable-mdpi/ic_video_play.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xhdpi/ic_pause_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/drawable-xhdpi/ic_pause_video.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xhdpi/ic_play_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/drawable-xhdpi/ic_play_video.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xhdpi/ic_video_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/drawable-xhdpi/ic_video_play.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/ic_pause_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/drawable-xxhdpi/ic_pause_video.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/ic_play_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/drawable-xxhdpi/ic_play_video.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/ic_video_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/drawable-xxhdpi/ic_video_play.png
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
22 |
23 |
29 |
30 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_play_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
27 |
28 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_video.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
22 |
23 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GibbsQin/GPlayer/82f5bd975fe2dd473fe5c75cd091720dcbf27415/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/values-zh-rCN/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GPlayer sample
3 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #00AAC6
4 | #7D26CD
5 | #698B22
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GPlayer sample
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
21 |
22 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library', ':sample'
2 | rootProject.name='GPlayer'
3 |
--------------------------------------------------------------------------------