├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── drawable-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── playback_player_control_button.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── layout │ │ │ │ ├── activity_main.xml │ │ │ │ └── activity_surfaceview_player.xml │ │ │ ├── drawable │ │ │ │ └── music_player_seekbar.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── cpp │ │ │ ├── thirdparty │ │ │ │ ├── ffmpeg │ │ │ │ │ └── include │ │ │ │ │ │ ├── libavutil │ │ │ │ │ │ ├── audioconvert.h │ │ │ │ │ │ ├── ffversion.h │ │ │ │ │ │ ├── avconfig.h │ │ │ │ │ │ ├── murmur3.h │ │ │ │ │ │ ├── macros.h │ │ │ │ │ │ ├── random_seed.h │ │ │ │ │ │ ├── motion_vector.h │ │ │ │ │ │ ├── adler32.h │ │ │ │ │ │ ├── replaygain.h │ │ │ │ │ │ ├── time.h │ │ │ │ │ │ ├── intfloat.h │ │ │ │ │ │ ├── aes.h │ │ │ │ │ │ ├── lfg.h │ │ │ │ │ │ ├── xtea.h │ │ │ │ │ │ ├── sha.h │ │ │ │ │ │ ├── pixelutils.h │ │ │ │ │ │ ├── md5.h │ │ │ │ │ │ ├── tea.h │ │ │ │ │ │ ├── ripemd.h │ │ │ │ │ │ ├── sha512.h │ │ │ │ │ │ ├── base64.h │ │ │ │ │ │ ├── avassert.h │ │ │ │ │ │ ├── camellia.h │ │ │ │ │ │ ├── twofish.h │ │ │ │ │ │ ├── file.h │ │ │ │ │ │ ├── blowfish.h │ │ │ │ │ │ ├── cast5.h │ │ │ │ │ │ ├── timestamp.h │ │ │ │ │ │ ├── crc.h │ │ │ │ │ │ ├── bswap.h │ │ │ │ │ │ ├── threadmessage.h │ │ │ │ │ │ ├── hmac.h │ │ │ │ │ │ ├── display.h │ │ │ │ │ │ └── downmix_info.h │ │ │ │ │ │ ├── libavfilter │ │ │ │ │ │ ├── avfiltergraph.h │ │ │ │ │ │ ├── avcodec.h │ │ │ │ │ │ ├── version.h │ │ │ │ │ │ └── asrc_abuffer.h │ │ │ │ │ │ ├── libavcodec │ │ │ │ │ │ ├── qsv.h │ │ │ │ │ │ ├── vorbis_parser.h │ │ │ │ │ │ ├── dxva2.h │ │ │ │ │ │ ├── d3d11va.h │ │ │ │ │ │ └── avfft.h │ │ │ │ │ │ ├── libswresample │ │ │ │ │ │ └── version.h │ │ │ │ │ │ ├── libpostproc │ │ │ │ │ │ ├── version.h │ │ │ │ │ │ └── postprocess.h │ │ │ │ │ │ ├── libswscale │ │ │ │ │ │ └── version.h │ │ │ │ │ │ └── libavformat │ │ │ │ │ │ └── version.h │ │ │ │ └── prebuilt │ │ │ │ │ └── armeabi-v7a │ │ │ │ │ ├── libavutil.a │ │ │ │ │ ├── libx264.a │ │ │ │ │ ├── libavcodec.a │ │ │ │ │ ├── libavfilter.a │ │ │ │ │ ├── libavformat.a │ │ │ │ │ ├── libfdk-aac.a │ │ │ │ │ ├── libpostproc.a │ │ │ │ │ ├── libswscale.a │ │ │ │ │ ├── libswresample.a │ │ │ │ │ └── libvo-aacenc.a │ │ │ ├── video_player │ │ │ │ ├── decoder │ │ │ │ │ ├── decoder_request_header.cpp │ │ │ │ │ ├── ffmpeg_video_decoder.h │ │ │ │ │ ├── mediacodec_video_decoder.h │ │ │ │ │ ├── ffmpeg_video_decoder.cpp │ │ │ │ │ └── decoder_request_header.h │ │ │ │ ├── texture_uploader │ │ │ │ │ ├── yuv_texture_frame_uploader.h │ │ │ │ │ ├── gpu_texture_frame_uploader.h │ │ │ │ │ ├── yuv_texture_frame_uploader.cpp │ │ │ │ │ └── gpu_texture_frame_uploader.cpp │ │ │ │ ├── audio_output.h │ │ │ │ └── video_player_controller.h │ │ │ └── common │ │ │ │ ├── opengl_media │ │ │ │ ├── texture_copier │ │ │ │ │ ├── texture_frame_copier.cpp │ │ │ │ │ ├── gpu_texture_frame_copier.h │ │ │ │ │ ├── yuv_texture_frame_copier.h │ │ │ │ │ ├── texture_frame_copier.h │ │ │ │ │ ├── gpu_texture_frame_copier.cpp │ │ │ │ │ └── yuv_texture_frame_copier.cpp │ │ │ │ ├── texture │ │ │ │ │ ├── texture_frame.cpp │ │ │ │ │ ├── texture_frame.h │ │ │ │ │ ├── gpu_texture_frame.h │ │ │ │ │ ├── yuv_texture_frame.h │ │ │ │ │ ├── gpu_texture_frame.cpp │ │ │ │ │ └── yuv_texture_frame.cpp │ │ │ │ ├── movie_frame.cpp │ │ │ │ ├── movie_frame.h │ │ │ │ └── render │ │ │ │ │ └── video_gl_surface_render.h │ │ │ │ ├── message_queue │ │ │ │ ├── handler.h │ │ │ │ ├── handler.cpp │ │ │ │ └── message_queue.h │ │ │ │ ├── egl_core │ │ │ │ ├── egl_share_context.h │ │ │ │ ├── egl_core.h │ │ │ │ ├── egl_share_context.cpp │ │ │ │ └── gl_tools.h │ │ │ │ ├── thread.h │ │ │ │ ├── matrix.h │ │ │ │ ├── opensl_media │ │ │ │ ├── opensl_es_context.cpp │ │ │ │ └── opensl_es_context.h │ │ │ │ ├── thread.cpp │ │ │ │ └── libresampler │ │ │ │ └── Resampler.h │ │ ├── java │ │ │ ├── com │ │ │ │ └── changba │ │ │ │ │ └── songstudio │ │ │ │ │ └── video │ │ │ │ │ ├── player │ │ │ │ │ ├── OnInitializedCallback.java │ │ │ │ │ ├── OnStoppedCallback.java │ │ │ │ │ └── ChangbaPlayer.java │ │ │ │ │ └── decoder │ │ │ │ │ └── MediaCodecDecoderLifeCycle.java │ │ │ └── media │ │ │ │ └── ushow │ │ │ │ └── as_video_player │ │ │ │ └── MainActivity.java │ │ ├── jni │ │ │ ├── native-lib.cpp │ │ │ └── com_changba_songstudio_video_player_ChangbaPlayer.h │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── media │ │ │ └── ushow │ │ │ └── as_video_player │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── media │ │ └── ushow │ │ └── as_video_player │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro ├── CMakeLists.txt └── build.gradle ├── settings.gradle ├── README.md ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── .idea ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml └── misc.xml ├── gradle.properties └── gradlew.bat /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-as_video_player 2 | # as_video_player 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/ffmpeg/include/libavutil/audioconvert.h: -------------------------------------------------------------------------------- 1 | 2 | #include "version.h" 3 | 4 | #if FF_API_AUDIOCONVERT 5 | #include "channel_layout.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libavutil.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libavutil.a -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libx264.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libx264.a -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libavcodec.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libavcodec.a -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libavfilter.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libavfilter.a -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libavformat.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libavformat.a -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libfdk-aac.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libfdk-aac.a -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libpostproc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libpostproc.a -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libswscale.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libswscale.a -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libswresample.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libswresample.a -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libvo-aacenc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/cpp/thirdparty/prebuilt/armeabi-v7a/libvo-aacenc.a -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/playback_player_control_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhanxiaokai/as_video_player/HEAD/app/src/main/res/drawable-hdpi/playback_player_control_button.png -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/ffmpeg/include/libavutil/ffversion.h: -------------------------------------------------------------------------------- 1 | #ifndef AVUTIL_FFVERSION_H 2 | #define AVUTIL_FFVERSION_H 3 | #define FFMPEG_VERSION "2.8.5" 4 | #endif /* AVUTIL_FFVERSION_H */ 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Apr 07 21:35:47 CST 2018 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.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/ffmpeg/include/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 | #define AV_HAVE_INCOMPATIBLE_LIBAV_ABI 0 7 | #endif /* AVUTIL_AVCONFIG_H */ 8 | -------------------------------------------------------------------------------- /app/src/main/cpp/video_player/decoder/decoder_request_header.cpp: -------------------------------------------------------------------------------- 1 | #include "decoder_request_header.h" 2 | 3 | #define LOG_TAG "DecoderRequestHeader" 4 | 5 | DecoderRequestHeader::DecoderRequestHeader() { 6 | uri = NULL; 7 | maxAnalyzeDurations = NULL; 8 | extraData = NULL; 9 | } 10 | DecoderRequestHeader::~DecoderRequestHeader() { 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/changba/songstudio/video/player/OnInitializedCallback.java: -------------------------------------------------------------------------------- 1 | package com.changba.songstudio.video.player; 2 | 3 | public interface OnInitializedCallback { 4 | 5 | enum OnInitialStatus{ 6 | CONNECT_SUCESS, 7 | CONNECT_FAILED, 8 | CLINET_CANCEL 9 | }; 10 | public void onInitialized(OnInitialStatus onInitialStatus); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/jni/native-lib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" 5 | JNIEXPORT jstring 6 | 7 | JNICALL 8 | Java_media_ushow_as_1video_1player_MainActivity_stringFromJNI( 9 | JNIEnv *env, 10 | jobject /* this */) { 11 | std::string hello = "Hello From VideoPlayer >>>"; 12 | return env->NewStringUTF(hello.c_str()); 13 | } 14 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | video_player 5 | 暂停 6 | 播放 7 | Video Player 8 | 进入播放页 9 | Settings 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/cpp/common/opengl_media/texture_copier/texture_frame_copier.cpp: -------------------------------------------------------------------------------- 1 | #include "texture_frame_copier.h" 2 | 3 | #define LOG_TAG "TextureFrameCopier" 4 | 5 | TextureFrameCopier::TextureFrameCopier() { 6 | } 7 | 8 | TextureFrameCopier::~TextureFrameCopier() { 9 | } 10 | 11 | void TextureFrameCopier::destroy() { 12 | mIsInitialized = false; 13 | if (mGLProgId) { 14 | glDeleteProgram(mGLProgId); 15 | mGLProgId = 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/cpp/common/message_queue/handler.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_COMMON_HANDLER_H 2 | #define VIDEO_COMMON_HANDLER_H 3 | 4 | #include "CommonTools.h" 5 | #include "./message_queue.h" 6 | 7 | class Handler { 8 | private: 9 | MessageQueue* mQueue; 10 | 11 | public: 12 | Handler(MessageQueue* mQueue); 13 | ~Handler(); 14 | 15 | int postMessage(Message* msg); 16 | virtual void handleMessage(Message* msg){}; 17 | }; 18 | 19 | #endif // VIDEO_COMMON_HANDLER_H 20 | -------------------------------------------------------------------------------- /app/src/main/cpp/common/message_queue/handler.cpp: -------------------------------------------------------------------------------- 1 | #include "./handler.h" 2 | 3 | #define LOG_TAG "Handler" 4 | 5 | /******************* Handler class *******************/ 6 | Handler::Handler(MessageQueue* queue) { 7 | this->mQueue = queue; 8 | } 9 | 10 | Handler::~Handler() { 11 | } 12 | 13 | int Handler::postMessage(Message* msg){ 14 | msg->handler = this; 15 | // LOGI("enqueue msg what is %d", msg->getWhat()); 16 | return mQueue->enqueueMessage(msg); 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/cpp/common/opengl_media/texture/texture_frame.cpp: -------------------------------------------------------------------------------- 1 | #include "texture_frame.h" 2 | 3 | #define LOG_TAG "TextureFrame" 4 | 5 | TextureFrame::TextureFrame() { 6 | 7 | } 8 | 9 | TextureFrame::~TextureFrame() { 10 | 11 | } 12 | 13 | bool TextureFrame::checkGlError(const char* op) { 14 | GLint error; 15 | for (error = glGetError(); error; error = glGetError()) { 16 | LOGI("error::after %s() glError (0x%x)\n", op, error); 17 | return true; 18 | } 19 | return false; 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/cpp/video_player/texture_uploader/yuv_texture_frame_uploader.h: -------------------------------------------------------------------------------- 1 | #ifndef YUV_TEXTURE_FRAME_UPLOADER_H 2 | #define YUV_TEXTURE_FRAME_UPLOADER_H 3 | 4 | #include "texture_frame_uploader.h" 5 | 6 | class YUVTextureFrameUploader: public TextureFrameUploader { 7 | public: 8 | YUVTextureFrameUploader(); 9 | virtual ~YUVTextureFrameUploader(); 10 | 11 | protected: 12 | virtual bool initialize(); 13 | virtual void destroy(); 14 | }; 15 | 16 | #endif // YUV_TEXTURE_FRAME_UPLOADER_H 17 | -------------------------------------------------------------------------------- /app/src/test/java/media/ushow/as_video_player/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package media.ushow.as_video_player; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/cpp/video_player/texture_uploader/gpu_texture_frame_uploader.h: -------------------------------------------------------------------------------- 1 | #ifndef GPU_TEXTURE_FRAME_UPLOADER_H 2 | #define GPU_TEXTURE_FRAME_UPLOADER_H 3 | 4 | #include "texture_frame_uploader.h" 5 | 6 | class GPUTextureFrameUploader: public TextureFrameUploader { 7 | public: 8 | GPUTextureFrameUploader(); 9 | virtual ~GPUTextureFrameUploader(); 10 | 11 | GLuint getDecodeTexId(){ 12 | return decodeTexId; 13 | }; 14 | 15 | protected: 16 | GLuint decodeTexId; 17 | 18 | virtual bool initialize(); 19 | virtual void destroy(); 20 | }; 21 | 22 | #endif // GPU_TEXTURE_FRAME_UPLOADER_H 23 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/cpp/common/egl_core/egl_share_context.h: -------------------------------------------------------------------------------- 1 | #ifndef ANDROID_EGL_SHARE_CONTEXT_H_ 2 | #define ANDROID_EGL_SHARE_CONTEXT_H_ 3 | 4 | #include "./egl_core.h" 5 | 6 | class EglShareContext { 7 | public: 8 | ~EglShareContext() { 9 | } 10 | static EGLContext getSharedContext() { 11 | if (instance_->sharedDisplay == EGL_NO_DISPLAY){ 12 | instance_->init(); 13 | } 14 | return instance_->sharedContext; 15 | } 16 | protected: 17 | EglShareContext(); 18 | void init(); 19 | 20 | 21 | private: 22 | static EglShareContext* instance_; 23 | EGLContext sharedContext; 24 | EGLDisplay sharedDisplay; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /app/src/main/cpp/common/opengl_media/texture/texture_frame.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_PLAYER_TEXTURE_FRAME_H 2 | #define VIDEO_PLAYER_TEXTURE_FRAME_H 3 | #include "CommonTools.h" 4 | #include 5 | #include 6 | 7 | /** 8 | * Video Texture 9 | */ 10 | class TextureFrame { 11 | protected: 12 | bool checkGlError(const char* op); 13 | 14 | public: 15 | TextureFrame(); 16 | virtual ~TextureFrame(); 17 | 18 | virtual bool createTexture() = 0; 19 | virtual void updateTexImage() = 0; 20 | virtual bool bindTexture(GLint* uniformSamplers) = 0; 21 | virtual void dealloc() = 0; 22 | }; 23 | 24 | #endif //VIDEO_PLAYER_TEXTURE_FRAME_H 25 | -------------------------------------------------------------------------------- /app/src/main/cpp/common/thread.h: -------------------------------------------------------------------------------- 1 | #ifndef SONG_STUDIO_THREAD_H 2 | #define SONG_STUDIO_THREAD_H 3 | 4 | #include 5 | #include "CommonTools.h" 6 | 7 | class Thread { 8 | public: 9 | Thread(); 10 | ~Thread(); 11 | 12 | void start(); 13 | void startAsync(); 14 | int wait(); 15 | 16 | void waitOnNotify(); 17 | void notify(); 18 | virtual void stop(); 19 | 20 | protected: 21 | bool mRunning; 22 | 23 | virtual void handleRun(void* ptr); 24 | 25 | protected: 26 | pthread_t mThread; 27 | pthread_mutex_t mLock; 28 | pthread_cond_t mCondition; 29 | 30 | static void* startThread(void* ptr); 31 | }; 32 | 33 | #endif //SONG_STUDIO_THREAD_H 34 | -------------------------------------------------------------------------------- /app/src/main/cpp/common/opengl_media/texture/gpu_texture_frame.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_PLAYER_GPU_TEXTURE_FRAME_H 2 | #define VIDEO_PLAYER_GPU_TEXTURE_FRAME_H 3 | 4 | #include "texture_frame.h" 5 | 6 | /** 7 | * Video Host Texture 8 | */ 9 | class GPUTextureFrame: public TextureFrame { 10 | private: 11 | GLuint decodeTexId; 12 | int initTexture(); 13 | 14 | public: 15 | GPUTextureFrame(); 16 | virtual ~GPUTextureFrame(); 17 | 18 | bool createTexture(); 19 | void updateTexImage(); 20 | bool bindTexture(GLint* uniformSamplers); 21 | void dealloc(); 22 | 23 | GLuint getDecodeTexId() { 24 | return decodeTexId; 25 | }; 26 | 27 | }; 28 | 29 | #endif //VIDEO_PLAYER_GPU_TEXTURE_FRAME_H 30 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/cpp/common/opengl_media/texture/yuv_texture_frame.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_PLAYER_YUV_TEXTURE_FRAME_H 2 | #define VIDEO_PLAYER_YUV_TEXTURE_FRAME_H 3 | 4 | #include "opengl_media/movie_frame.h" 5 | #include "texture_frame.h" 6 | 7 | /** 8 | * Video Host Texture 9 | */ 10 | class YUVTextureFrame: public TextureFrame { 11 | private: 12 | bool writeFlag; 13 | GLuint textures[3]; 14 | int initTexture(); 15 | 16 | VideoFrame *frame; 17 | public: 18 | YUVTextureFrame(); 19 | virtual ~YUVTextureFrame(); 20 | 21 | void setVideoFrame(VideoFrame *yuvFrame); 22 | 23 | bool createTexture(); 24 | void updateTexImage(); 25 | bool bindTexture(GLint* uniformSamplers); 26 | void dealloc(); 27 | }; 28 | 29 | #endif //VIDEO_PLAYER_YUV_TEXTURE_FRAME_H 30 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/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 | -------------------------------------------------------------------------------- /app/src/main/java/com/changba/songstudio/video/player/OnStoppedCallback.java: -------------------------------------------------------------------------------- 1 | package com.changba.songstudio.video.player; 2 | 3 | import java.util.List; 4 | 5 | public interface OnStoppedCallback { 6 | public void onStopped(); 7 | 8 | //观看结束打点数据 9 | /** 10 | * @param beginOpen 开始试图去打开一个直播流 11 | * @param successOpen 成功打开流 12 | * @param firstScreenTimeMills 首屏时间 13 | * @param failOpen 流打开失败 14 | * @param failOpenType 流打开失败类型 15 | * @param duration 时长 16 | * @param retryOpen 重试 17 | * @param videoQueueFull 解码缓冲区满 18 | * @param videoQueueEmpty 解码缓冲区空 19 | */ 20 | public void getstaticsData(long beginOpen, float successOpen, float firstScreenTimeMills, float failOpen, int failOpenType, float duration, 21 | List retryOpen, List videoQueueFull, List videoQueueEmpty); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/cpp/common/matrix.h: -------------------------------------------------------------------------------- 1 | #ifndef MATRIX_H 2 | #define MATRIX_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | void matrixSetIdentityM(float *m); 9 | void matrixSetRotateM(float *m, float a, float x, float y, float z); 10 | void matrixMultiplyMM(float *m, float *lhs, float *rhs); 11 | void matrixScaleM(float *m, float x, float y, float z); 12 | void matrixTranslateM(float *m, float x, float y, float z); 13 | void matrixRotateM(float *m, float a, float x, float y, float z); 14 | void matrixLookAtM(float *m, float eyeX, float eyeY, float eyeZ, float cenX, 15 | float cenY, float cenZ, float upX, float upY, float upZ); 16 | void matrixFrustumM(float *m, float left, float right, float bottom, float top, float near, float far); 17 | 18 | void getTranslateMatrix(float *m, float x, float y, float z); 19 | 20 | #endif // MATRIX_H 21 | -------------------------------------------------------------------------------- /app/src/androidTest/java/media/ushow/as_video_player/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package media.ushow.as_video_player; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("media.ushow.as_video_player", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/cpp/video_player/decoder/ffmpeg_video_decoder.h: -------------------------------------------------------------------------------- 1 | #ifndef FFMPEG_VIDEO_DECODER_H 2 | #define FFMPEG_VIDEO_DECODER_H 3 | 4 | #include "video_decoder.h" 5 | 6 | #include "../texture_uploader/texture_frame_uploader.h" 7 | #include "../texture_uploader/yuv_texture_frame_uploader.h" 8 | 9 | class FFMPEGVideoDecoder : public VideoDecoder{ 10 | public: 11 | FFMPEGVideoDecoder(); 12 | FFMPEGVideoDecoder(JavaVM *g_jvm, jobject obj); 13 | virtual ~FFMPEGVideoDecoder(); 14 | 15 | virtual float updateTexImage(TextureFrame* textureFrame); 16 | 17 | protected: 18 | virtual TextureFrameUploader* createTextureFrameUploader(); 19 | virtual bool decodeVideoFrame(AVPacket packet, int* decodeVideoErrorState); 20 | virtual void flushVideoFrames(AVPacket packet, int* decodeVideoErrorState); 21 | virtual int initAnalyzeDurationAndProbesize(int* max_analyze_durations, int analyzeDurationSize, int probesize, bool fpsProbeSizeConfigured){ 22 | return 1; 23 | }; 24 | }; 25 | #endif // FFMPEG_VIDEO_DECODER_H 26 | -------------------------------------------------------------------------------- /app/src/main/cpp/common/opensl_media/opensl_es_context.cpp: -------------------------------------------------------------------------------- 1 | #include "opensl_es_context.h" 2 | 3 | #define LOG_TAG "OpenSLESContext" 4 | 5 | OpenSLESContext* OpenSLESContext::instance = new OpenSLESContext(); 6 | 7 | void OpenSLESContext::init() { 8 | LOGI("createEngine"); 9 | SLresult result = createEngine(); 10 | LOGI("createEngine result is s%", ResultToString(result)); 11 | if (SL_RESULT_SUCCESS == result) { 12 | LOGI("Realize the engine object"); 13 | // Realize the engine object 14 | result = RealizeObject(engineObject); 15 | if (SL_RESULT_SUCCESS == result) { 16 | LOGI("Get the engine interface"); 17 | // Get the engine interface 18 | result = GetEngineInterface(); 19 | } 20 | } 21 | } 22 | 23 | OpenSLESContext::OpenSLESContext() { 24 | isInited = false; 25 | } 26 | OpenSLESContext::~OpenSLESContext() { 27 | } 28 | 29 | OpenSLESContext* OpenSLESContext::GetInstance() { 30 | if (!instance->isInited) { 31 | instance->init(); 32 | instance->isInited = true; 33 | } 34 | return instance; 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/cpp/common/opengl_media/movie_frame.cpp: -------------------------------------------------------------------------------- 1 | #include "movie_frame.h" 2 | 3 | #define LOG_TAG "MovieFrame" 4 | 5 | MovieFrame::MovieFrame() { 6 | position = 0.0f; 7 | duration = 0.0f; 8 | } 9 | 10 | AudioFrame::AudioFrame() { 11 | dataUseUp = true; 12 | samples = NULL; 13 | size = 0; 14 | } 15 | void AudioFrame::fillFullData() { 16 | dataUseUp = false; 17 | } 18 | void AudioFrame::useUpData() { 19 | dataUseUp = true; 20 | } 21 | bool AudioFrame::isDataUseUp() { 22 | return dataUseUp; 23 | } 24 | AudioFrame::~AudioFrame() { 25 | if (NULL != samples) { 26 | delete[] samples; 27 | samples = NULL; 28 | } 29 | } 30 | 31 | VideoFrame::VideoFrame() { 32 | luma = NULL; 33 | chromaB = NULL; 34 | chromaR = NULL; 35 | width = 0; 36 | height = 0; 37 | } 38 | 39 | VideoFrame::~VideoFrame() { 40 | if (NULL != luma) { 41 | delete[] luma; 42 | luma = NULL; 43 | } 44 | if (NULL != chromaB) { 45 | delete[] chromaB; 46 | chromaB = NULL; 47 | } 48 | if (NULL != chromaR) { 49 | delete[] chromaR; 50 | chromaR = NULL; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/cpp/video_player/texture_uploader/yuv_texture_frame_uploader.cpp: -------------------------------------------------------------------------------- 1 | #include "yuv_texture_frame_uploader.h" 2 | 3 | #define LOG_TAG "YUVTextureFrameUploader" 4 | 5 | YUVTextureFrameUploader::YUVTextureFrameUploader(){ 6 | LOGI("TextureFrameUploader instance created"); 7 | } 8 | 9 | YUVTextureFrameUploader::~YUVTextureFrameUploader() { 10 | LOGI("TextureFrameUploader instance destroyed"); 11 | } 12 | 13 | bool YUVTextureFrameUploader::initialize() { 14 | TextureFrameUploader::initialize(); 15 | //init decodeTexId 16 | textureFrame = new YUVTextureFrame(); 17 | textureFrame->createTexture(); 18 | textureFrameCopier = new YUVTextureFrameCopier(); 19 | textureFrameCopier->init(); 20 | return true; 21 | } 22 | 23 | void YUVTextureFrameUploader::destroy() { 24 | eglCore->makeCurrent(copyTexSurface); 25 | if (textureFrameCopier) { 26 | textureFrameCopier->destroy(); 27 | delete textureFrameCopier; 28 | textureFrameCopier = NULL; 29 | } 30 | if (textureFrame) { 31 | textureFrame->dealloc(); 32 | 33 | delete textureFrame; 34 | textureFrame = NULL; 35 | } 36 | TextureFrameUploader::destroy(); 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/cpp/thirdparty/ffmpeg/include/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 | -------------------------------------------------------------------------------- /app/src/main/cpp/video_player/texture_uploader/gpu_texture_frame_uploader.cpp: -------------------------------------------------------------------------------- 1 | #include "gpu_texture_frame_uploader.h" 2 | 3 | #define LOG_TAG "GPUTextureFrameUploader" 4 | 5 | GPUTextureFrameUploader::GPUTextureFrameUploader(){ 6 | decodeTexId = 0; 7 | LOGI("GPUTextureFrameUploader instance created"); 8 | } 9 | 10 | GPUTextureFrameUploader::~GPUTextureFrameUploader() { 11 | LOGI("GPUTextureFrameUploader instance destroyed"); 12 | } 13 | 14 | bool GPUTextureFrameUploader::initialize() { 15 | TextureFrameUploader::initialize(); 16 | //init decodeTexId 17 | textureFrame = new GPUTextureFrame(); 18 | textureFrame->createTexture(); 19 | 20 | // todo: need write lock 21 | decodeTexId = ((GPUTextureFrame *)textureFrame)->getDecodeTexId(); 22 | LOGI("createTexture success!!!!!!!!!! %d", decodeTexId); 23 | 24 | textureFrameCopier = new GPUTextureFrameCopier(); 25 | textureFrameCopier->init(); 26 | return true; 27 | } 28 | 29 | void GPUTextureFrameUploader::destroy() { 30 | if (textureFrameCopier) { 31 | textureFrameCopier->destroy(); 32 | delete textureFrameCopier; 33 | textureFrameCopier = NULL; 34 | } 35 | if (textureFrame) { 36 | textureFrame->dealloc(); 37 | } 38 | TextureFrameUploader::destroy(); 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 |