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 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/cpp/common/thread.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "thread.h"
3 |
4 | #define LOG_TAG "SongStudioThread"
5 |
6 | Thread::Thread() {
7 | pthread_mutex_init(&mLock, NULL);
8 | pthread_cond_init(&mCondition, NULL);
9 | }
10 |
11 | Thread::~Thread() {
12 | }
13 |
14 | void Thread::start() {
15 | handleRun( NULL);
16 | }
17 |
18 | void Thread::startAsync() {
19 | pthread_create(&mThread, NULL, startThread, this);
20 | }
21 |
22 | int Thread::wait() {
23 | if (!mRunning) {
24 | LOGI("mRunning is false so return 0");
25 | return 0;
26 | }
27 | void* status;
28 | int ret = pthread_join(mThread,&status);
29 | LOGI("pthread_join thread return result is %d ", status);
30 | return (int)ret;
31 | }
32 |
33 | void Thread::stop() {
34 | }
35 |
36 | void* Thread::startThread(void* ptr) {
37 | LOGI("starting thread");
38 | Thread* thread = (Thread *) ptr;
39 | thread->mRunning = true;
40 | thread->handleRun(ptr);
41 | thread->mRunning = false;
42 | }
43 |
44 | void Thread::waitOnNotify() {
45 | pthread_mutex_lock(&mLock);
46 | pthread_cond_wait(&mCondition, &mLock);
47 | pthread_mutex_unlock(&mLock);
48 | }
49 |
50 | void Thread::notify() {
51 | pthread_mutex_lock(&mLock);
52 | pthread_cond_signal(&mCondition);
53 | pthread_mutex_unlock(&mLock);
54 | }
55 |
56 | void Thread::handleRun(void* ptr) {
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/cpp/common/opengl_media/texture_copier/gpu_texture_frame_copier.h:
--------------------------------------------------------------------------------
1 | #ifndef GPU_TEXTURE_FRAME_COPIER_H
2 | #define GPU_TEXTURE_FRAME_COPIER_H
3 |
4 | #include
5 | #include
6 | #include "CommonTools.h"
7 | #include "texture_frame_copier.h"
8 | #include "matrix.h"
9 |
10 |
11 | static char* GPU_FRAME_VERTEX_SHADER =
12 | "attribute vec4 vPosition;\n"
13 | "attribute vec4 vTexCords;\n"
14 | "varying vec2 yuvTexCoords;\n"
15 | "uniform highp mat4 trans; \n"
16 | "void main() {\n"
17 | " yuvTexCoords = vTexCords.xy;\n"
18 | " gl_Position = trans * vPosition;\n"
19 | "}\n";
20 |
21 | static char* GPU_FRAME_FRAGMENT_SHADER =
22 | "#extension GL_OES_EGL_image_external : require\n"
23 | "precision mediump float;\n"
24 | "uniform samplerExternalOES yuvTexSampler;\n"
25 | "varying vec2 yuvTexCoords;\n"
26 | "void main() {\n"
27 | " gl_FragColor = texture2D(yuvTexSampler, yuvTexCoords);\n"
28 | "}\n";
29 |
30 | class GPUTextureFrameCopier : public TextureFrameCopier{
31 | public:
32 | GPUTextureFrameCopier();
33 | virtual ~GPUTextureFrameCopier();
34 |
35 | virtual bool init();
36 | virtual void renderWithCoords(TextureFrame* textureFrame, GLuint texId, GLfloat* vertexCoords, GLfloat* textureCoords);
37 | protected:
38 | GLint mGLUniformTexture;
39 | };
40 |
41 | #endif // GPU_TEXTURE_FRAME_COPIER_H
42 |
--------------------------------------------------------------------------------
/app/src/main/cpp/common/opengl_media/texture_copier/yuv_texture_frame_copier.h:
--------------------------------------------------------------------------------
1 | #ifndef YUV_TEXTURE_FRAME_COPIER_H
2 | #define YUV_TEXTURE_FRAME_COPIER_H
3 |
4 | #include
5 | #include
6 | #include "CommonTools.h"
7 | #include "texture_frame_copier.h"
8 | #include "matrix.h"
9 |
10 | static char* YUV_FRAME_FRAGMENT_SHADER =
11 | "varying highp vec2 yuvTexCoords;\n"
12 | "uniform sampler2D s_texture_y;\n"
13 | "uniform sampler2D s_texture_u;\n"
14 | "uniform sampler2D s_texture_v;\n"
15 | "void main(void)\n"
16 | "{\n"
17 | "highp float y = texture2D(s_texture_y, yuvTexCoords).r;\n"
18 | "highp float u = texture2D(s_texture_u, yuvTexCoords).r - 0.5;\n"
19 | "highp float v = texture2D(s_texture_v, yuvTexCoords).r - 0.5;\n"
20 | "\n"
21 | "highp float r = y + 1.402 * v;\n"
22 | "highp float g = y - 0.344 * u - 0.714 * v;\n"
23 | "highp float b = y + 1.772 * u;\n"
24 | "gl_FragColor = vec4(r,g,b,1.0);\n"
25 | "}\n";
26 |
27 | class YUVTextureFrameCopier: public TextureFrameCopier {
28 | public:
29 | YUVTextureFrameCopier();
30 | virtual ~YUVTextureFrameCopier();
31 |
32 | virtual bool init();
33 | virtual void renderWithCoords(TextureFrame* textureFrame, GLuint texId, GLfloat* vertexCoords, GLfloat* textureCoords);
34 |
35 | protected:
36 | GLint _uniformSamplers[3];
37 | };
38 |
39 | #endif // YUV_TEXTURE_FRAME_COPIER_H
40 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/libavutil/murmur3.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 Reimar Döffinger
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_MURMUR3_H
22 | #define AVUTIL_MURMUR3_H
23 |
24 | #include
25 |
26 | struct AVMurMur3 *av_murmur3_alloc(void);
27 | void av_murmur3_init_seeded(struct AVMurMur3 *c, uint64_t seed);
28 | void av_murmur3_init(struct AVMurMur3 *c);
29 | void av_murmur3_update(struct AVMurMur3 *c, const uint8_t *src, int len);
30 | void av_murmur3_final(struct AVMurMur3 *c, uint8_t dst[16]);
31 |
32 | #endif /* AVUTIL_MURMUR3_H */
33 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/libavcodec/qsv.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Intel MediaSDK QSV public API
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 AVCODEC_QSV_H
22 | #define AVCODEC_QSV_H
23 |
24 | #include
25 |
26 | typedef struct AVQSVContext {
27 | mfxSession session;
28 | int iopattern;
29 |
30 | mfxExtBuffer **ext_buffers;
31 | int nb_ext_buffers;
32 | } AVQSVContext;
33 |
34 | /**
35 | * Allocate a new context.
36 | *
37 | * It must be freed by the caller with av_free().
38 | */
39 | AVQSVContext *av_qsv_alloc_context(void);
40 |
41 | #endif /* AVCODEC_QSV_H */
42 |
--------------------------------------------------------------------------------
/app/src/main/cpp/common/libresampler/Resampler.h:
--------------------------------------------------------------------------------
1 | #ifndef SONGSTUDIO_RESAMPLER_H
2 | #define SONGSTUDIO_RESAMPLER_H
3 | #include "CommonTools.h"
4 | extern "C" {
5 | #include "libavutil/opt.h"
6 | #include "libavutil/channel_layout.h"
7 | #include "libavutil/samplefmt.h"
8 | #include "libswresample/swresample.h"
9 | };
10 |
11 | class Resampler {
12 | private:
13 | int src_rate;
14 | int dst_rate;
15 | int src_nb_samples;
16 | int64_t src_ch_layout, dst_ch_layout;
17 | int src_nb_channels, dst_nb_channels;
18 | int src_linesize, dst_linesize;
19 | int dst_nb_samples, max_dst_nb_samples;
20 | uint8_t **dst_data;
21 | uint8_t **src_data;
22 | enum AVSampleFormat src_sample_fmt, dst_sample_fmt;
23 | int dst_bufsize;
24 | const char *fmt;
25 | struct SwrContext *swr_ctx;
26 | public:
27 | Resampler();
28 | ~Resampler();
29 | //每个channel里面的maxSamples
30 | virtual int init(int _src_rate = 48000, int _dst_rate = 44100, int _max_src_nb_samples = 1024, int src_channels = 1, int to_channels = 1);
31 | virtual int process(short *in_data, uint8_t *out_data, int real_src_nb_samples, int* out_nb_bytes);
32 | virtual int process(short **in_data, uint8_t *out_data, int real_src_nb_samples, int* out_nb_bytes);
33 | virtual int convert(uint8_t *out_data, int real_src_nb_samples, int* out_nb_bytes);
34 | virtual void destroy();
35 |
36 | int getSourceSampleRate(){
37 | return src_rate;
38 | };
39 | };
40 |
41 | #endif //SONGSTUDIO_RESAMPLER_H
42 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 | #endif /* AVUTIL_MACROS_H */
49 |
--------------------------------------------------------------------------------
/app/src/main/cpp/common/egl_core/egl_core.h:
--------------------------------------------------------------------------------
1 | #ifndef ANDROID_EGL_CORE_H_
2 | #define ANDROID_EGL_CORE_H_
3 |
4 | #include "CommonTools.h"
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | typedef EGLBoolean (EGLAPIENTRYP PFNEGLPRESENTATIONTIMEANDROIDPROC)(EGLDisplay display, EGLSurface surface, khronos_stime_nanoseconds_t time);
12 |
13 | class EGLCore {
14 | public:
15 | EGLCore();
16 | virtual ~EGLCore();
17 |
18 | bool init();
19 |
20 | bool init(EGLContext sharedContext);
21 |
22 | bool initWithSharedContext();
23 |
24 | EGLSurface createWindowSurface(ANativeWindow* _window);
25 | EGLSurface createOffscreenSurface(int width, int height);
26 |
27 | bool makeCurrent(EGLSurface eglSurface);
28 |
29 | void doneCurrent();
30 |
31 | bool swapBuffers(EGLSurface eglSurface);
32 |
33 | int querySurface(EGLSurface surface, int what);
34 |
35 | int setPresentationTime(EGLSurface surface, khronos_stime_nanoseconds_t nsecs);
36 |
37 | void releaseSurface(EGLSurface eglSurface);
38 | void release();
39 |
40 | EGLContext getContext();
41 | EGLDisplay getDisplay();
42 | EGLConfig getConfig();
43 |
44 | private:
45 | EGLDisplay display;
46 | EGLConfig config;
47 | EGLContext context;
48 |
49 | PFNEGLPRESENTATIONTIMEANDROIDPROC pfneglPresentationTimeANDROID;
50 | };
51 | #endif // ANDROID_EGL_CORE_H_
52 |
--------------------------------------------------------------------------------
/app/src/main/cpp/common/egl_core/egl_share_context.cpp:
--------------------------------------------------------------------------------
1 | #include "egl_share_context.h"
2 |
3 | #define LOG_TAG "EglShareContext"
4 | EglShareContext* EglShareContext::instance_ = new EglShareContext();
5 |
6 | EglShareContext::EglShareContext() {
7 | init();
8 | }
9 |
10 | void EglShareContext::init() {
11 | LOGI("Create EGLContext EGLCore::init");
12 | sharedContext = EGL_NO_CONTEXT;
13 | EGLint numConfigs;
14 | sharedDisplay = EGL_NO_DISPLAY;
15 | EGLConfig config;
16 | const EGLint attribs[] = { EGL_BUFFER_SIZE, 32, EGL_ALPHA_SIZE, 8,
17 | EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8,
18 | EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_SURFACE_TYPE,
19 | EGL_WINDOW_BIT, EGL_NONE };
20 | if ((sharedDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY))
21 | == EGL_NO_DISPLAY) {
22 | LOGE("eglGetDisplay() returned error %d", eglGetError());
23 | return;
24 | }
25 | if (!eglInitialize(sharedDisplay, 0, 0)) {
26 | LOGE("eglInitialize() returned error %d", eglGetError());
27 | return;
28 | }
29 |
30 | if (!eglChooseConfig(sharedDisplay, attribs, &config, 1, &numConfigs)) {
31 | LOGE("eglChooseConfig() returned error %d", eglGetError());
32 | return;
33 | }
34 |
35 | EGLint eglContextAttributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
36 | if (!(sharedContext = eglCreateContext(sharedDisplay, config,
37 | NULL == sharedContext ? EGL_NO_CONTEXT : sharedContext,
38 | eglContextAttributes))) {
39 | LOGE("eglCreateContext() returned error %d", eglGetError());
40 | return;
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/cpp/common/opengl_media/texture_copier/texture_frame_copier.h:
--------------------------------------------------------------------------------
1 | #ifndef TEXTURE_FRAME_COPIER_H
2 | #define TEXTURE_FRAME_COPIER_H
3 |
4 | #include "CommonTools.h"
5 | #include
6 | #include
7 | #include "opengl_media/texture/texture_frame.h"
8 | #include "egl_core/gl_tools.h"
9 |
10 | static char* NO_FILTER_VERTEX_SHADER =
11 | "attribute vec4 vPosition;\n"
12 | "attribute vec4 vTexCords;\n"
13 | "varying vec2 yuvTexCoords;\n"
14 | "uniform highp mat4 texMatrix;\n"
15 | "uniform highp mat4 trans; \n"
16 | "void main() {\n"
17 | " yuvTexCoords = (texMatrix*vTexCords).xy;\n"
18 | " gl_Position = trans * vPosition;\n"
19 | "}\n";
20 |
21 | static char* NO_FILTER_FRAGMENT_SHADER =
22 | "varying vec2 yuvTexCoords;\n"
23 | "uniform sampler2D yuvTexSampler;\n"
24 | "void main() {\n"
25 | " gl_FragColor = texture2D(yuvTexSampler, yuvTexCoords);\n"
26 | "}\n";
27 |
28 | class TextureFrameCopier {
29 | public:
30 | TextureFrameCopier();
31 | virtual ~TextureFrameCopier();
32 |
33 | virtual bool init() = 0;
34 | virtual void renderWithCoords(TextureFrame* textureFrame, GLuint texId, GLfloat* vertexCoords, GLfloat* textureCoords) = 0;
35 | virtual void destroy();
36 |
37 | protected:
38 | char* mVertexShader;
39 | char* mFragmentShader;
40 |
41 | bool mIsInitialized;
42 | GLuint mGLProgId;
43 | GLuint mGLVertexCoords;
44 | GLuint mGLTextureCoords;
45 |
46 | GLint mUniformTexMatrix;
47 | GLint mUniformTransforms;
48 | };
49 |
50 | #endif // TEXTURE_FRAME_COPIER_H
51 |
--------------------------------------------------------------------------------
/app/src/main/java/media/ushow/as_video_player/MainActivity.java:
--------------------------------------------------------------------------------
1 | package media.ushow.as_video_player;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.TextView;
9 |
10 | public class MainActivity extends AppCompatActivity {
11 |
12 | // Used to load the 'native-lib' library on application startup.
13 | static {
14 | System.loadLibrary("native-lib");
15 | }
16 | private Button forward_video_player;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_main);
22 |
23 | // Example of a call to a native method
24 | TextView tv = (TextView) findViewById(R.id.sample_text);
25 | tv.setText(stringFromJNI());
26 |
27 | forward_video_player = (Button) findViewById(R.id.forward_video_player);
28 | forward_video_player.setOnClickListener(new View.OnClickListener() {
29 | @Override
30 | public void onClick(View v) {
31 | Intent intent = new Intent(MainActivity.this, ChangbaPlayerActivity.class);
32 | startActivity(intent);
33 | }
34 | });
35 | }
36 |
37 | /**
38 | * A native method that is implemented by the 'native-lib' native library,
39 | * which is packaged with this application.
40 | */
41 | public native String stringFromJNI();
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/cpp/common/message_queue/message_queue.h:
--------------------------------------------------------------------------------
1 | #ifndef VIDEO_COMMON_MESSAGE_QUEUE_H
2 | #define VIDEO_COMMON_MESSAGE_QUEUE_H
3 |
4 | #include "CommonTools.h"
5 | #include
6 |
7 |
8 | #define MESSAGE_QUEUE_LOOP_QUIT_FLAG 19900909
9 |
10 | class Handler;
11 |
12 | class Message {
13 | private:
14 | int what;
15 | int arg1;
16 | int arg2;
17 | void* obj;
18 |
19 | public:
20 | Message();
21 | Message(int what);
22 | Message(int what, int arg1, int arg2);
23 | Message(int what, void* obj);
24 | Message(int what, int arg1, int arg2, void* obj);
25 | ~Message();
26 |
27 | int execute();
28 | int getWhat(){
29 | return what;
30 | };
31 | int getArg1(){
32 | return arg1;
33 | };
34 | int getArg2(){
35 | return arg2;
36 | };
37 | void* getObj(){
38 | return obj;
39 | };
40 | Handler* handler;
41 | };
42 |
43 | typedef struct MessageNode {
44 | Message *msg;
45 | struct MessageNode *next;
46 | MessageNode(){
47 | msg = NULL;
48 | next = NULL;
49 | }
50 | } MessageNode;
51 |
52 | class MessageQueue {
53 | private:
54 | MessageNode* mFirst;
55 | MessageNode* mLast;
56 | int mNbPackets;
57 | bool mAbortRequest;
58 | pthread_mutex_t mLock;
59 | pthread_cond_t mCondition;
60 | const char* queueName;
61 |
62 |
63 | public:
64 | MessageQueue();
65 | MessageQueue(const char* queueNameParam);
66 | ~MessageQueue();
67 |
68 | void init();
69 | void flush();
70 | int enqueueMessage(Message* msg);
71 | int dequeueMessage(Message **msg, bool block);
72 | int size();
73 | void abort();
74 |
75 | };
76 |
77 | #endif // VIDEO_COMMON_MESSAGE_QUEUE_H
78 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/libavutil/random_seed.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 Baptiste Coudurier
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 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/music_player_seekbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/cpp/common/opengl_media/movie_frame.h:
--------------------------------------------------------------------------------
1 | #ifndef VIDEO_PLAYER_MOVIE_FRAME_H
2 | #define VIDEO_PLAYER_MOVIE_FRAME_H
3 |
4 | #include "CommonTools.h"
5 |
6 | /** 为了避免类文件过多,现在把有关数据结构的model都写到了这个文件中 **/
7 | typedef enum {
8 | MovieFrameTypeNone,
9 | MovieFrameTypeAudio,
10 | MovieFrameTypeVideo
11 | } MovieFrameType;
12 |
13 | class MovieFrame{
14 | public:
15 | float position;
16 | float duration;
17 | MovieFrame();
18 | virtual MovieFrameType getType() = 0;
19 | };
20 | class AudioFrame: public MovieFrame{
21 | public:
22 | byte * samples;
23 | int size;
24 | AudioFrame();
25 | ~AudioFrame();
26 | MovieFrameType getType(){
27 | return MovieFrameTypeAudio;
28 | };
29 | bool dataUseUp;
30 | void fillFullData();
31 | void useUpData();
32 | bool isDataUseUp();
33 | };
34 |
35 | class VideoFrame: public MovieFrame{
36 | public:
37 | uint8_t * luma;
38 | uint8_t * chromaB;
39 | uint8_t * chromaR;
40 | int width;
41 | int height;
42 | VideoFrame();
43 | ~VideoFrame();
44 |
45 | VideoFrame* clone(){
46 | VideoFrame* frame = new VideoFrame();
47 | frame->width = width;
48 | frame->height = height;
49 | int lumaLength = width * height;
50 | frame->luma = new uint8_t[lumaLength];
51 | memcpy(frame->luma, luma, lumaLength);
52 | int chromaBLength = width * height / 4;
53 | frame->chromaB = new uint8_t[chromaBLength];
54 | memcpy(frame->chromaB, chromaB, chromaBLength);
55 | int chromaRLength = chromaBLength;
56 | frame->chromaR = new uint8_t[chromaRLength];
57 | memcpy(frame->chromaR, chromaR, chromaRLength);
58 | return frame;
59 | }
60 |
61 | MovieFrameType getType(){
62 | return MovieFrameTypeVideo;
63 | };
64 | };
65 |
66 | #endif //VIDEO_PLAYER_MOVIE_FRAME_H
67 |
68 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 | } AVMotionVector;
49 |
50 | #endif /* AVUTIL_MOTION_VECTOR_H */
51 |
--------------------------------------------------------------------------------
/app/src/main/cpp/common/opensl_media/opensl_es_context.h:
--------------------------------------------------------------------------------
1 | #ifndef _MEDIA_OPENSL_ES_CONTEXT_H_
2 | #define _MEDIA_OPENSL_ES_CONTEXT_H_
3 |
4 | #include "opensl_es_util.h"
5 | #include "CommonTools.h"
6 |
7 | class OpenSLESContext {
8 | private:
9 | SLObjectItf engineObject;
10 | SLEngineItf engineEngine;
11 | bool isInited;
12 | /**
13 | * Creates an OpenSL ES engine.
14 | */
15 | SLresult createEngine() {
16 | // OpenSL ES for Android is designed to be thread-safe,
17 | // so this option request will be ignored, but it will
18 | // make the source code portable to other platforms.
19 | SLEngineOption engineOptions[] = { { (SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE } };
20 |
21 | // Create the OpenSL ES engine object
22 | return slCreateEngine(&engineObject, ARRAY_LEN(engineOptions), engineOptions, 0, // no interfaces
23 | 0, // no interfaces
24 | 0); // no required
25 | };
26 | /**
27 | * Realize the given object. Objects needs to be
28 | * realized before using them.
29 | * @param object object instance.
30 | */
31 | SLresult RealizeObject(SLObjectItf object) {
32 | // Realize the engine object
33 | return (*object)->Realize(object, SL_BOOLEAN_FALSE); // No async, blocking call
34 | };
35 | /**
36 | * Gets the engine interface from the given engine object
37 | * in order to create other objects from the engine.
38 | */
39 | SLresult GetEngineInterface() {
40 | // Get the engine interface
41 | return (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
42 | };
43 |
44 | OpenSLESContext();
45 | void init();
46 | static OpenSLESContext* instance;
47 | public:
48 | static OpenSLESContext* GetInstance(); //工厂方法(用来获得实例)
49 | virtual ~OpenSLESContext();
50 | SLEngineItf getEngine() {
51 | return engineEngine;
52 | };
53 | };
54 | #endif //_MEDIA_OPENSL_ES_CONTEXT_H_
55 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 | #ifndef AVUTIL_ADLER32_H
22 | #define AVUTIL_ADLER32_H
23 |
24 | #include
25 | #include "attributes.h"
26 |
27 | /**
28 | * @file
29 | * Public header for libavutil Adler32 hasher
30 | *
31 | * @defgroup lavu_adler32 Adler32
32 | * @ingroup lavu_crypto
33 | * @{
34 | */
35 |
36 | /**
37 | * Calculate the Adler32 checksum of a buffer.
38 | *
39 | * Passing the return value to a subsequent av_adler32_update() call
40 | * allows the checksum of multiple buffers to be calculated as though
41 | * they were concatenated.
42 | *
43 | * @param adler initial checksum value
44 | * @param buf pointer to input buffer
45 | * @param len size of input buffer
46 | * @return updated checksum
47 | */
48 | unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf,
49 | unsigned int len) av_pure;
50 |
51 | /**
52 | * @}
53 | */
54 |
55 | #endif /* AVUTIL_ADLER32_H */
56 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/libavutil/replaygain.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * This file is part of FFmpeg.
4 | *
5 | * FFmpeg is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * FFmpeg is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with FFmpeg; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | #ifndef AVUTIL_REPLAYGAIN_H
21 | #define AVUTIL_REPLAYGAIN_H
22 |
23 | #include
24 |
25 | /**
26 | * ReplayGain information (see
27 | * http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification).
28 | * The size of this struct is a part of the public ABI.
29 | */
30 | typedef struct AVReplayGain {
31 | /**
32 | * Track replay gain in microbels (divide by 100000 to get the value in dB).
33 | * Should be set to INT32_MIN when unknown.
34 | */
35 | int32_t track_gain;
36 | /**
37 | * Peak track amplitude, with 100000 representing full scale (but values
38 | * may overflow). 0 when unknown.
39 | */
40 | uint32_t track_peak;
41 | /**
42 | * Same as track_gain, but for the whole album.
43 | */
44 | int32_t album_gain;
45 | /**
46 | * Same as track_peak, but for the whole album,
47 | */
48 | uint32_t album_peak;
49 | } AVReplayGain;
50 |
51 | #endif /* AVUTIL_REPLAYGAIN_H */
52 |
--------------------------------------------------------------------------------
/app/src/main/cpp/common/opengl_media/texture/gpu_texture_frame.cpp:
--------------------------------------------------------------------------------
1 | #include "gpu_texture_frame.h"
2 |
3 | #define LOG_TAG "GPUTextureFrame"
4 |
5 | GPUTextureFrame::GPUTextureFrame() {
6 | decodeTexId = 0;
7 | }
8 |
9 | GPUTextureFrame::~GPUTextureFrame() {
10 |
11 | }
12 |
13 | bool GPUTextureFrame::createTexture() {
14 | LOGI("enter GPUTextureFrame::createTexture");
15 | decodeTexId = 0;
16 | int ret = initTexture();
17 | if (ret < 0) {
18 | LOGI("init texture failed...");
19 | this->dealloc();
20 | return false;
21 | }
22 | return true;
23 | }
24 |
25 | void GPUTextureFrame::updateTexImage() {
26 | //TODO:调用surfaceTexture
27 | }
28 |
29 | bool GPUTextureFrame::bindTexture(GLint* uniformSamplers) {
30 | glActiveTexture(GL_TEXTURE0);
31 | glBindTexture(GL_TEXTURE_EXTERNAL_OES, decodeTexId);
32 | glUniform1i(*uniformSamplers, 0);
33 | return true;
34 | }
35 |
36 | void GPUTextureFrame::dealloc() {
37 | LOGI("enter GPUTextureFrame::dealloc");
38 | if (decodeTexId) {
39 | glDeleteTextures(1, &decodeTexId);
40 | }
41 | }
42 |
43 | int GPUTextureFrame::initTexture() {
44 | glGenTextures(1, &decodeTexId);
45 | glBindTexture(GL_TEXTURE_EXTERNAL_OES, decodeTexId);
46 | if (checkGlError("glBindTexture")) {
47 | return -1;
48 | }
49 | glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
50 | if (checkGlError("glTexParameteri")) {
51 | return -1;
52 | }
53 | glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
54 | if (checkGlError("glTexParameteri")) {
55 | return -1;
56 | }
57 | glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
58 | if (checkGlError("glTexParameteri")) {
59 | return -1;
60 | }
61 | glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
62 | if (checkGlError("glTexParameteri")) {
63 | return -1;
64 | }
65 | return 1;
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/cpp/video_player/decoder/mediacodec_video_decoder.h:
--------------------------------------------------------------------------------
1 | #ifndef MEDIACODEC_VIDEO_DECODER_H
2 | #define MEDIACODEC_VIDEO_DECODER_H
3 |
4 | #include "video_decoder.h"
5 |
6 | #include "../texture_uploader/texture_frame_uploader.h"
7 | #include "../texture_uploader/gpu_texture_frame_uploader.h"
8 |
9 | class MediaCodecVideoDecoder : public VideoDecoder{
10 | public:
11 | MediaCodecVideoDecoder();
12 | MediaCodecVideoDecoder(JavaVM *g_jvm, jobject obj);
13 | virtual ~MediaCodecVideoDecoder();
14 |
15 | virtual float updateTexImage(TextureFrame* textureFrame);
16 |
17 | protected:
18 | virtual TextureFrameUploader* createTextureFrameUploader();
19 | virtual void seek_frame();
20 | virtual bool decodeVideoFrame(AVPacket packet, int* decodeVideoErrorState);
21 | virtual void flushVideoFrames(AVPacket packet, int* decodeVideoErrorState);
22 | virtual void closeVideoStream();
23 | virtual int initAnalyzeDurationAndProbesize(int* max_analyze_durations, int analyzeDurationSize, int probesize, bool fpsProbeSizeConfigured){
24 | return 1;
25 | };
26 |
27 | private:
28 | bool isMediaCodecInit;
29 | GLuint decodeTexId;
30 | jbyteArray inputBuffer;
31 |
32 | typedef struct {
33 | uint8_t* data;
34 | int size;
35 | } FramePacket;
36 |
37 | void convertPacket(FramePacket* packet);
38 |
39 | bool initializeMediaCodec();
40 | bool initializeMediaCodec(FramePacket * packet);
41 |
42 | void flushMediaCodecBuffers();
43 | void destroyMediaCodec();
44 |
45 | uint32_t findStartCode(uint8_t* in_pBuffer, uint32_t in_ui32BufferSize,
46 | uint32_t in_ui32Code, uint32_t& out_ui32ProcessedBytes);
47 | void parseH264SequenceHeader(uint8_t* in_pBuffer, uint32_t in_ui32Size,
48 | uint8_t** inout_pBufferSPS, int& inout_ui32SizeSPS,
49 | uint8_t** inout_pBufferPPS, int& inout_ui32SizePPS);
50 | };
51 |
52 |
53 | #endif // MEDIACODEC_VIDEO_DECODER_H
54 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 SWR_VERSION_H
22 | #define SWR_VERSION_H
23 |
24 | /**
25 | * @file
26 | * Libswresample version macros
27 | */
28 |
29 | #include "libavutil/avutil.h"
30 |
31 | #define LIBSWRESAMPLE_VERSION_MAJOR 1
32 | #define LIBSWRESAMPLE_VERSION_MINOR 2
33 | #define LIBSWRESAMPLE_VERSION_MICRO 101
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 /* SWR_VERSION_H */
46 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/libpostproc/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 POSTPROC_POSTPROCESS_VERSION_H
22 | #define POSTPROC_POSTPROCESS_VERSION_H
23 |
24 | /**
25 | * @file
26 | * Libpostproc version macros
27 | */
28 |
29 | #include "libavutil/avutil.h"
30 |
31 | #define LIBPOSTPROC_VERSION_MAJOR 53
32 | #define LIBPOSTPROC_VERSION_MINOR 3
33 | #define LIBPOSTPROC_VERSION_MICRO 100
34 |
35 | #define LIBPOSTPROC_VERSION_INT AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, \
36 | LIBPOSTPROC_VERSION_MINOR, \
37 | LIBPOSTPROC_VERSION_MICRO)
38 | #define LIBPOSTPROC_VERSION AV_VERSION(LIBPOSTPROC_VERSION_MAJOR, \
39 | LIBPOSTPROC_VERSION_MINOR, \
40 | LIBPOSTPROC_VERSION_MICRO)
41 | #define LIBPOSTPROC_BUILD LIBPOSTPROC_VERSION_INT
42 |
43 | #define LIBPOSTPROC_IDENT "postproc" AV_STRINGIFY(LIBPOSTPROC_VERSION)
44 |
45 | #ifndef FF_API_QP_TYPE
46 | #define FF_API_QP_TYPE (LIBPOSTPROC_VERSION_MAJOR < 55)
47 | #endif
48 |
49 | #endif /* POSTPROC_POSTPROCESS_VERSION_H */
50 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 |
--------------------------------------------------------------------------------
/app/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html
3 |
4 | # Sets the minimum version of CMake required to build the native library.
5 |
6 | cmake_minimum_required(VERSION 3.4.1)
7 |
8 | set(
9 | PATH_TO_MEDIACORE
10 | CACHE STRING ""
11 | )
12 | set(PATH_TO_NATIVE ${PATH_TO_MEDIACORE}/src/main/cpp)
13 | set(PATH_TO_JNI_LAYER ${PATH_TO_MEDIACORE}/src/main/jni)
14 | set(PATH_TO_THIRDPARTY ${PATH_TO_NATIVE}/thirdparty)
15 | set(PATH_TO_PRE_BUILT ${PATH_TO_THIRDPARTY}/prebuilt/${ANDROID_ABI})
16 |
17 | add_definitions("
18 | -DGL_GLEXT_PROTOTYPES
19 | -DEGL_EGLEXT_PROTOTYPES
20 | ")
21 |
22 | ADD_SUBDIRECTORY(src/main/cpp)
23 |
24 | include_directories(BEFORE ${PATH_TO_THIRDPARTY}/ffmpeg/include/)
25 | include_directories(${PATH_TO_NATIVE}/)
26 | include_directories(${PATH_TO_NATIVE}/common/)
27 | include_directories(${PATH_TO_NATIVE}/video_player/)
28 |
29 | file(GLOB FILES_JNI_LAYER "${PATH_TO_JNI_LAYER}/*.cpp")
30 |
31 | add_library(native-lib SHARED
32 | ${FILES_JNI_LAYER}
33 | )
34 |
35 | target_link_libraries(native-lib
36 | # 引入系统的动态库
37 | log
38 | android
39 | GLESv2
40 | EGL
41 | z
42 | OpenSLES
43 | av-engine
44 | # 引入ffmpeg相关静态库
45 | ${PATH_TO_PRE_BUILT}/libavfilter.a
46 | ${PATH_TO_PRE_BUILT}/libavformat.a
47 | ${PATH_TO_PRE_BUILT}/libavcodec.a
48 | ${PATH_TO_PRE_BUILT}/libpostproc.a
49 | ${PATH_TO_PRE_BUILT}/libswresample.a
50 | ${PATH_TO_PRE_BUILT}/libswscale.a
51 | ${PATH_TO_PRE_BUILT}/libavutil.a
52 | ${PATH_TO_PRE_BUILT}/libpostproc.a
53 | ${PATH_TO_PRE_BUILT}/libfdk-aac.a
54 | ${PATH_TO_PRE_BUILT}/libvo-aacenc.a
55 | ${PATH_TO_PRE_BUILT}/libx264.a
56 | )
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 | typedef struct AVLFG {
26 | unsigned int state[64];
27 | int index;
28 | } AVLFG;
29 |
30 | void av_lfg_init(AVLFG *c, unsigned int seed);
31 |
32 | /**
33 | * Get the next random unsigned 32-bit number using an ALFG.
34 | *
35 | * Please also consider a simple LCG like state= state*1664525+1013904223,
36 | * it may be good enough and faster for your specific use case.
37 | */
38 | static inline unsigned int av_lfg_get(AVLFG *c){
39 | c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63];
40 | return c->state[c->index++ & 63];
41 | }
42 |
43 | /**
44 | * Get the next random unsigned 32-bit number using a MLFG.
45 | *
46 | * Please also consider av_lfg_get() above, it is faster.
47 | */
48 | static inline unsigned int av_mlfg_get(AVLFG *c){
49 | unsigned int a= c->state[(c->index-55) & 63];
50 | unsigned int b= c->state[(c->index-24) & 63];
51 | return c->state[c->index++ & 63] = 2*a*b+a+b;
52 | }
53 |
54 | /**
55 | * Get the next two numbers generated by a Box-Muller Gaussian
56 | * generator using the random numbers issued by lfg.
57 | *
58 | * @param out array where the two generated numbers are placed
59 | */
60 | void av_bmg_get(AVLFG *lfg, double out[2]);
61 |
62 | #endif /* AVUTIL_LFG_H */
63 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 3
30 | #define LIBSWSCALE_VERSION_MINOR 1
31 | #define LIBSWSCALE_VERSION_MICRO 101
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_CPU_CAPS
50 | #define FF_API_SWS_CPU_CAPS (LIBSWSCALE_VERSION_MAJOR < 4)
51 | #endif
52 | #ifndef FF_API_ARCH_BFIN
53 | #define FF_API_ARCH_BFIN (LIBSWSCALE_VERSION_MAJOR < 4)
54 | #endif
55 |
56 | #endif /* SWSCALE_VERSION_H */
57 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/libavutil/xtea.h:
--------------------------------------------------------------------------------
1 | /*
2 | * A 32-bit implementation of the XTEA 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_XTEA_H
23 | #define AVUTIL_XTEA_H
24 |
25 | #include
26 | #include "version.h"
27 |
28 | /**
29 | * @file
30 | * @brief Public header for libavutil XTEA algorithm
31 | * @defgroup lavu_xtea XTEA
32 | * @ingroup lavu_crypto
33 | * @{
34 | */
35 |
36 | typedef struct AVXTEA {
37 | uint32_t key[16];
38 | } AVXTEA;
39 |
40 | /**
41 | * Allocate an AVXTEA context.
42 | */
43 | AVXTEA *av_xtea_alloc(void);
44 |
45 | /**
46 | * Initialize an AVXTEA context.
47 | *
48 | * @param ctx an AVXTEA context
49 | * @param key a key of 16 bytes used for encryption/decryption
50 | */
51 | void av_xtea_init(struct AVXTEA *ctx, const uint8_t key[16]);
52 |
53 | /**
54 | * Encrypt or decrypt a buffer using a previously initialized context.
55 | *
56 | * @param ctx an AVXTEA context
57 | * @param dst destination array, can be equal to src
58 | * @param src source array, can be equal to dst
59 | * @param count number of 8 byte blocks
60 | * @param iv initialization vector for CBC mode, if NULL then ECB will be used
61 | * @param decrypt 0 for encryption, 1 for decryption
62 | */
63 | void av_xtea_crypt(struct AVXTEA *ctx, uint8_t *dst, const uint8_t *src,
64 | int count, uint8_t *iv, int decrypt);
65 |
66 | /**
67 | * @}
68 | */
69 |
70 | #endif /* AVUTIL_XTEA_H */
71 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 | #ifndef AVUTIL_SHA_H
22 | #define AVUTIL_SHA_H
23 |
24 | #include
25 |
26 | #include "attributes.h"
27 | #include "version.h"
28 |
29 | /**
30 | * @defgroup lavu_sha SHA
31 | * @ingroup lavu_crypto
32 | * @{
33 | */
34 |
35 | extern const int av_sha_size;
36 |
37 | struct AVSHA;
38 |
39 | /**
40 | * Allocate an AVSHA context.
41 | */
42 | struct AVSHA *av_sha_alloc(void);
43 |
44 | /**
45 | * Initialize SHA-1 or SHA-2 hashing.
46 | *
47 | * @param context pointer to the function context (of size av_sha_size)
48 | * @param bits number of bits in digest (SHA-1 - 160 bits, SHA-2 224 or 256 bits)
49 | * @return zero if initialization succeeded, -1 otherwise
50 | */
51 | int av_sha_init(struct AVSHA* context, int bits);
52 |
53 | /**
54 | * Update hash value.
55 | *
56 | * @param context hash function context
57 | * @param data input data to update hash with
58 | * @param len input data length
59 | */
60 | void av_sha_update(struct AVSHA* context, const uint8_t* data, unsigned int len);
61 |
62 | /**
63 | * Finish hashing and output digest value.
64 | *
65 | * @param context hash function context
66 | * @param digest buffer where output digest value is stored
67 | */
68 | void av_sha_final(struct AVSHA* context, uint8_t *digest);
69 |
70 | /**
71 | * @}
72 | */
73 |
74 | #endif /* AVUTIL_SHA_H */
75 |
--------------------------------------------------------------------------------
/app/src/main/cpp/video_player/audio_output.h:
--------------------------------------------------------------------------------
1 | #ifndef _VIDEO_PLAYER_AUDIO_OUTPUT_H_
2 | #define _VIDEO_PLAYER_AUDIO_OUTPUT_H_
3 |
4 | #include "CommonTools.h";
5 | #include "opensl_media/opensl_es_util.h"
6 | #include "opensl_media/opensl_es_context.h"
7 | #include
8 |
9 | #define DEFAULT_AUDIO_BUFFER_DURATION_IN_SECS 0.03
10 |
11 | typedef int(*audioPlayerCallback)(byte* , size_t, void* ctx);
12 |
13 | #define PLAYING_STATE_STOPPED (0x00000001)
14 | #define PLAYING_STATE_PLAYING (0x00000002)
15 |
16 | class AudioOutput {
17 | public:
18 | AudioOutput();
19 | virtual ~AudioOutput();
20 |
21 | int playingState;
22 |
23 | SLresult initSoundTrack(int channels, int accompanySampleRate, audioPlayerCallback, void* ctx);
24 | SLresult start();
25 | SLresult play();
26 | SLresult pause();
27 | SLresult stop();
28 | bool isPlaying();
29 | long getCurrentTimeMills();
30 | void destroyContext();
31 | audioPlayerCallback produceDataCallback;
32 | void* ctx;
33 |
34 | private:
35 | SLEngineItf engineEngine;
36 | SLObjectItf outputMixObject;
37 | SLObjectItf audioPlayerObject;
38 | SLAndroidSimpleBufferQueueItf audioPlayerBufferQueue;
39 | SLPlayItf audioPlayerPlay;
40 |
41 | byte* buffer;
42 | size_t bufferSize;
43 | //初始化OpenSL要播放的buffer
44 | void initPlayerBuffer();
45 | //释放OpenSL播放的buffer
46 | void freePlayerBuffer();
47 | //实例化一个对象
48 | SLresult realizeObject(SLObjectItf object);
49 | //销毁这个对象以及这个对象下面的接口
50 | void destroyObject(SLObjectItf& object);
51 | //创建输出对象
52 | SLresult createOutputMix();
53 | //创建OpenSL的AudioPlayer对象
54 | SLresult createAudioPlayer(int channels, int accompanySampleRate);
55 | //获得AudioPlayer对象的bufferQueue的接口
56 | SLresult getAudioPlayerBufferQueueInterface();
57 | //获得AudioPlayer对象的play的接口
58 | SLresult getAudioPlayerPlayInterface();
59 | //设置播放器的状态为播放状态
60 | SLresult setAudioPlayerStatePlaying();
61 | //设置播放器的状态为暂停状态
62 | SLresult setAudioPlayerStatePaused();
63 | //以下三个是进行注册回调函数的
64 | //当OpenSL播放完毕给他的buffer数据之后,就会回调playerCallback
65 | SLresult registerPlayerCallback();
66 | //playerCallback中其实会调用我们的实例方法producePacket
67 | static void playerCallback(SLAndroidSimpleBufferQueueItf bq, void *context);
68 | //这里面会调用在初始化的时候注册过来的回调函数,回调它,由这个回调函数填充数据(这个回调函数还负责音画同步)
69 | void producePacket();
70 | };
71 | #endif //_VIDEO_PLAYER_AUDIO_OUTPUT_H_
72 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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_MD5_H
22 | #define AVUTIL_MD5_H
23 |
24 | #include
25 |
26 | #include "attributes.h"
27 | #include "version.h"
28 |
29 | /**
30 | * @defgroup lavu_md5 MD5
31 | * @ingroup lavu_crypto
32 | * @{
33 | */
34 |
35 | extern const int av_md5_size;
36 |
37 | struct AVMD5;
38 |
39 | /**
40 | * Allocate an AVMD5 context.
41 | */
42 | struct AVMD5 *av_md5_alloc(void);
43 |
44 | /**
45 | * Initialize MD5 hashing.
46 | *
47 | * @param ctx pointer to the function context (of size av_md5_size)
48 | */
49 | void av_md5_init(struct AVMD5 *ctx);
50 |
51 | /**
52 | * Update hash value.
53 | *
54 | * @param ctx hash function context
55 | * @param src input data to update hash with
56 | * @param len input data length
57 | */
58 | void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, int len);
59 |
60 | /**
61 | * Finish hashing and output digest value.
62 | *
63 | * @param ctx hash function context
64 | * @param dst buffer where output digest value is stored
65 | */
66 | void av_md5_final(struct AVMD5 *ctx, uint8_t *dst);
67 |
68 | /**
69 | * Hash an array of data.
70 | *
71 | * @param dst The output buffer to write the digest into
72 | * @param src The data to hash
73 | * @param len The length of the data, in bytes
74 | */
75 | void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len);
76 |
77 | /**
78 | * @}
79 | */
80 |
81 | #endif /* AVUTIL_MD5_H */
82 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 | #ifndef AVUTIL_RIPEMD_H
23 | #define AVUTIL_RIPEMD_H
24 |
25 | #include
26 |
27 | #include "attributes.h"
28 | #include "version.h"
29 |
30 | /**
31 | * @defgroup lavu_ripemd RIPEMD
32 | * @ingroup lavu_crypto
33 | * @{
34 | */
35 |
36 | extern const int av_ripemd_size;
37 |
38 | struct AVRIPEMD;
39 |
40 | /**
41 | * Allocate an AVRIPEMD context.
42 | */
43 | struct AVRIPEMD *av_ripemd_alloc(void);
44 |
45 | /**
46 | * Initialize RIPEMD hashing.
47 | *
48 | * @param context pointer to the function context (of size av_ripemd_size)
49 | * @param bits number of bits in digest (128, 160, 256 or 320 bits)
50 | * @return zero if initialization succeeded, -1 otherwise
51 | */
52 | int av_ripemd_init(struct AVRIPEMD* context, int bits);
53 |
54 | /**
55 | * Update hash value.
56 | *
57 | * @param context hash function context
58 | * @param data input data to update hash with
59 | * @param len input data length
60 | */
61 | void av_ripemd_update(struct AVRIPEMD* context, const uint8_t* data, unsigned int len);
62 |
63 | /**
64 | * Finish hashing and output digest value.
65 | *
66 | * @param context hash function context
67 | * @param digest buffer where output digest value is stored
68 | */
69 | void av_ripemd_final(struct AVRIPEMD* context, uint8_t *digest);
70 |
71 | /**
72 | * @}
73 | */
74 |
75 | #endif /* AVUTIL_RIPEMD_H */
76 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 | #ifndef AVUTIL_SHA512_H
23 | #define AVUTIL_SHA512_H
24 |
25 | #include
26 |
27 | #include "attributes.h"
28 | #include "version.h"
29 |
30 | /**
31 | * @defgroup lavu_sha512 SHA512
32 | * @ingroup lavu_crypto
33 | * @{
34 | */
35 |
36 | extern const int av_sha512_size;
37 |
38 | struct AVSHA512;
39 |
40 | /**
41 | * Allocate an AVSHA512 context.
42 | */
43 | struct AVSHA512 *av_sha512_alloc(void);
44 |
45 | /**
46 | * Initialize SHA-2 512 hashing.
47 | *
48 | * @param context pointer to the function context (of size av_sha512_size)
49 | * @param bits number of bits in digest (224, 256, 384 or 512 bits)
50 | * @return zero if initialization succeeded, -1 otherwise
51 | */
52 | int av_sha512_init(struct AVSHA512* context, int bits);
53 |
54 | /**
55 | * Update hash value.
56 | *
57 | * @param context hash function context
58 | * @param data input data to update hash with
59 | * @param len input data length
60 | */
61 | void av_sha512_update(struct AVSHA512* context, const uint8_t* data, unsigned int len);
62 |
63 | /**
64 | * Finish hashing and output digest value.
65 | *
66 | * @param context hash function context
67 | * @param digest buffer where output digest value is stored
68 | */
69 | void av_sha512_final(struct AVSHA512* context, uint8_t *digest);
70 |
71 | /**
72 | * @}
73 | */
74 |
75 | #endif /* AVUTIL_SHA512_H */
76 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 | /**
34 | * Decode a base64-encoded string.
35 | *
36 | * @param out buffer for decoded data
37 | * @param in null-terminated input string
38 | * @param out_size size in bytes of the out buffer, must be at
39 | * least 3/4 of the length of in
40 | * @return number of bytes written, or a negative value in case of
41 | * invalid input
42 | */
43 | int av_base64_decode(uint8_t *out, const char *in, int out_size);
44 |
45 | /**
46 | * Encode data to base64 and null-terminate.
47 | *
48 | * @param out buffer for encoded data
49 | * @param out_size size in bytes of the out buffer (including the
50 | * null terminator), must be at least AV_BASE64_SIZE(in_size)
51 | * @param in input buffer containing the data to encode
52 | * @param in_size size in bytes of the in buffer
53 | * @return out or NULL in case of error
54 | */
55 | char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size);
56 |
57 | /**
58 | * Calculate the output size needed to base64-encode x bytes to a
59 | * null-terminated string.
60 | */
61 | #define AV_BASE64_SIZE(x) (((x)+2) / 3 * 4 + 1)
62 |
63 | /**
64 | * @}
65 | */
66 |
67 | #endif /* AVUTIL_BASE64_H */
68 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 speedloss.
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 | #else
63 | #define av_assert2(cond) ((void)0)
64 | #endif
65 |
66 | #endif /* AVUTIL_AVASSERT_H */
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/changba/songstudio/video/decoder/MediaCodecDecoderLifeCycle.java:
--------------------------------------------------------------------------------
1 | package com.changba.songstudio.video.decoder;
2 |
3 | import android.os.Build;
4 | import android.util.Log;
5 |
6 | public abstract class MediaCodecDecoderLifeCycle {
7 |
8 | /** MediaCodec related code **/
9 | protected MediaCodecDecoder mediaCodecDecoder;
10 | protected boolean useMediaCodec = false;
11 | /** 1:Java客户端可以强制使用 软件/硬件 解码器 **/
12 | public void setUseMediaCodec(boolean value) {
13 | useMediaCodec = value;
14 | }
15 | /** 2:底层判断是否使用硬件解码器 **/
16 | public boolean isHWCodecAvaliableFromNative() {
17 | boolean ret = false;
18 | Log.i("problem", "useMediaCodec " + useMediaCodec);
19 | if (useMediaCodec) {
20 | String manufacturer = Build.MANUFACTURER;
21 | String model = Build.MODEL;
22 | Log.d("problem", "manufacturer=" + manufacturer + " model=" + model);
23 | if (MediaCodecDecoder.IsInAndriodHardwareBlacklist()){
24 | ret = false;
25 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
26 | // 4.3
27 | // MediaCodec under android 4.3+ seems to be very stable and fast
28 | ret = true;
29 | } else if (MediaCodecDecoder.IsInAndriodHardwareWhitelist()){
30 | ret = true;
31 | }
32 | }
33 | return ret;
34 | }
35 | /** 3:底层创建硬件解码器,比较重要的是texId以及其他MetaData的传入 **/
36 | public boolean createVideoDecoderFromNative(int width, int height, int texId, byte[] sps, int spsSize, byte[] pps,
37 | int ppsSize) {
38 | mediaCodecDecoder = new MediaCodecDecoder();
39 | return mediaCodecDecoder.CreateVideoDecoder(width, height, texId, sps, spsSize, pps, ppsSize);
40 | }
41 |
42 | /** 4-1:当需要解码一个packet(compressedData)的时候调用这个方法 **/
43 | public int decodeFrameFromNative(byte[] frameData, int inputSize, long timeStamp) {
44 | return mediaCodecDecoder.DecodeFrame(frameData, inputSize, timeStamp);
45 | }
46 | /** 4-2:调用了2-1之后需要调用这方法获取纹理 **/
47 | public long updateTexImageFromNative() {
48 | long rec = 0;
49 | if (mediaCodecDecoder == null){
50 | return rec;
51 | } else{
52 | return mediaCodecDecoder.updateTexImage();
53 | }
54 | }
55 | /** 5:当快进等操作执行的时候需要清空现有的解码器内部的数据 **/
56 | public void flushMediaCodecBuffersFromNative() {
57 | if (null != mediaCodecDecoder){
58 | mediaCodecDecoder.beforeSeek();
59 | }
60 | }
61 | /** 6:销毁解码器 **/
62 | public void cleanupDecoderFromNative() {
63 | if (null != mediaCodecDecoder){
64 | mediaCodecDecoder.CleanupDecoder();
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 |
--------------------------------------------------------------------------------
/app/src/main/cpp/thirdparty/ffmpeg/include/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 |
--------------------------------------------------------------------------------
/app/src/main/cpp/common/opengl_media/render/video_gl_surface_render.h:
--------------------------------------------------------------------------------
1 | #ifndef VIDEO_PLAYER_GL_SURFACE_RENDER_H
2 | #define VIDEO_PLAYER_GL_SURFACE_RENDER_H
3 |
4 | #include
5 | #include
6 | #include "CommonTools.h"
7 |
8 | static char* OUTPUT_VIEW_VERTEX_SHADER =
9 | "attribute vec4 position; \n"
10 | "attribute vec2 texcoord; \n"
11 | "varying vec2 v_texcoord; \n"
12 | "void main(void) \n"
13 | "{ \n"
14 | " gl_Position = position; \n"
15 | " v_texcoord = texcoord; \n"
16 | "} \n";
17 |
18 | static char* OUTPUT_VIEW_FRAG_SHADER =
19 | "varying highp vec2 v_texcoord;\n"
20 | "uniform sampler2D yuvTexSampler;\n"
21 | "void main() {\n"
22 | " gl_FragColor = texture2D(yuvTexSampler, v_texcoord);\n"
23 | "}\n";
24 |
25 | /**
26 | * Video OpenGL View
27 | */
28 | class VideoGLSurfaceRender {
29 | public:
30 | VideoGLSurfaceRender();
31 | virtual ~VideoGLSurfaceRender();
32 | bool init(int width, int height);
33 | void resetRenderSize(int left, int top, int width, int height);
34 | void renderToView(GLuint texID, int screenWidth, int screenHeight);
35 | void renderToView(GLuint texID);
36 | void renderToViewWithAutofit(GLuint texID, int screenWidth, int screenHeight, int texWidth, int texHeight);
37 | void renderToViewWithAutoFill(GLuint texID, int screenWidth, int screenHeight, int texWidth, int texHeight);
38 | void renderToVFlipTexture(GLuint inputTexId, GLuint outputTexId);
39 | void renderToTexture(GLuint inputTexId, GLuint outputTexId);
40 | void renderToAutoFitTexture(GLuint inputTexId, int width, int height, GLuint outputTexId);
41 | void renderToCroppedTexture(GLuint inputTexId, GLuint outputTexId, int originalWidth, int originalHeight);
42 | void renderToEncoderTexture(GLuint inputTexId, GLuint outputTexId);
43 | void dealloc();
44 |
45 | protected:
46 | GLint _backingLeft;
47 | GLint _backingTop;
48 | GLint _backingWidth;
49 | GLint _backingHeight;
50 |
51 | char* mVertexShader;
52 | char* mFragmentShader;
53 |
54 | bool mIsInitialized;
55 |
56 | GLuint mGLProgId;
57 | GLuint mGLVertexCoords;
58 | GLuint mGLTextureCoords;
59 | GLint mGLUniformTexture;
60 | void checkGlError(const char* op);
61 | GLuint loadProgram(char* pVertexSource, char* pFragmentSource);
62 | GLuint loadShader(GLenum shaderType, const char* pSource);
63 |
64 | float calcCropRatio(int screenWidth, int screenHeight, int texWidth, int texHeight);
65 | };
66 |
67 | #endif //VIDEO_PLAYER_GL_SURFACE_RENDER_H
68 |
--------------------------------------------------------------------------------
/app/src/main/cpp/video_player/decoder/ffmpeg_video_decoder.cpp:
--------------------------------------------------------------------------------
1 | #include "ffmpeg_video_decoder.h"
2 |
3 | #define LOG_TAG "FFMPEGVideoDecoder"
4 |
5 | FFMPEGVideoDecoder::FFMPEGVideoDecoder() {
6 | }
7 |
8 | FFMPEGVideoDecoder::FFMPEGVideoDecoder(JavaVM *g_jvm, jobject obj)
9 | : VideoDecoder(g_jvm, obj) {
10 | }
11 |
12 | FFMPEGVideoDecoder::~FFMPEGVideoDecoder() {
13 | }
14 |
15 | TextureFrameUploader* FFMPEGVideoDecoder::createTextureFrameUploader() {
16 | TextureFrameUploader* textureFrameUploader = new YUVTextureFrameUploader();
17 | return textureFrameUploader;
18 | }
19 |
20 | float FFMPEGVideoDecoder::updateTexImage(TextureFrame* textureFrame) {
21 | float position = -1;
22 | VideoFrame *yuvFrame = handleVideoFrame();
23 | if (yuvFrame) {
24 | ((YUVTextureFrame*) textureFrame)->setVideoFrame(yuvFrame);
25 | textureFrame->updateTexImage();
26 | position = yuvFrame->position;
27 | delete yuvFrame;
28 | }
29 | return position;
30 | }
31 |
32 | bool FFMPEGVideoDecoder::decodeVideoFrame(AVPacket packet, int* decodeVideoErrorState) {
33 | int pktSize = packet.size;
34 |
35 | int gotframe = 0;
36 |
37 | while (pktSize > 0) {
38 | int len = avcodec_decode_video2(videoCodecCtx, videoFrame, &gotframe, &packet);
39 | if (len < 0) {
40 | LOGI("decode video error, skip packet");
41 | *decodeVideoErrorState = 1;
42 | break;
43 | }
44 | if (gotframe) {
45 | if (videoFrame->interlaced_frame) {
46 | avpicture_deinterlace((AVPicture*) videoFrame, (AVPicture*) videoFrame, videoCodecCtx->pix_fmt, videoCodecCtx->width, videoCodecCtx->height);
47 | }
48 | this->uploadTexture();
49 | }
50 | if (0 == len) {
51 | break;
52 | }
53 | pktSize -= len;
54 | }
55 |
56 | return (bool)gotframe;
57 | }
58 |
59 | void FFMPEGVideoDecoder::flushVideoFrames(AVPacket packet, int* decodeVideoErrorState) {
60 | if (videoCodecCtx->codec->capabilities & CODEC_CAP_DELAY) {
61 | packet.data = 0;
62 | packet.size = 0;
63 | av_init_packet(&packet);
64 | int gotframe = 0;
65 | int len = avcodec_decode_video2(videoCodecCtx, videoFrame, &gotframe, &packet);
66 |
67 | LOGI("flush video %d", gotframe);
68 |
69 | if (len < 0) {
70 | LOGI("decode video error, skip packet");
71 | *decodeVideoErrorState = 1;
72 | }
73 | if (gotframe) {
74 | if (videoFrame->interlaced_frame) {
75 | avpicture_deinterlace((AVPicture*) videoFrame, (AVPicture*) videoFrame, videoCodecCtx->pix_fmt, videoCodecCtx->width, videoCodecCtx->height);
76 | }
77 | this->uploadTexture();
78 | } else {
79 | LOGI("output EOF");
80 | isVideoOutputEOF = true;
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/cpp/video_player/decoder/decoder_request_header.h:
--------------------------------------------------------------------------------
1 | #ifndef VIDEOPLAYER_DECODER_REQUEST_HEADER_H_
2 | #define VIDEOPLAYER_DECODER_REQUEST_HEADER_H_
3 |
4 | #include "CommonTools.h"
5 | #include