提交 5abea0e8 authored 作者: 祁增奎's avatar 祁增奎

Android使用替换

上级 f23762b9
......@@ -22,14 +22,14 @@ external libraries enabled.
##### 2.1.1 Android Tools
- Android SDK Build Tools
- Android NDK r22b or later with LLDB and CMake (See [#292](https://github.com/arthenica/ffmpeg-kit/issues/292) if you want to use NDK r23b or later)
- Android NDK r22b or later with LLDB and CMake (See [#292](https://github.com/arthenica/ffmpeg-kit/issues/292) if you want to use NDK r23b)
##### 2.1.2 Packages
Use your package manager (apt, yum, dnf, brew, etc.) to install the following packages.
```
autoconf automake libtool pkg-config curl git doxygen nasm cmake gcc gperf texinfo yasm bison autogen wget autopoint meson ninja ragel groff gtk-doc-tools libtasn1
autoconf automake libtool pkg-config curl cmake gcc gperf texinfo yasm nasm bison autogen git wget autopoint meson ninja
```
##### 2.1.3 Environment Variables
......@@ -77,7 +77,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
}
dependencies {
implementation 'com.arthenica:ffmpeg-kit-full:6.0-2'
implementation 'com.arthenica:ffmpeg-kit-full:5.1'
}
```
......
......@@ -38,7 +38,7 @@ PROJECT_NAME = "FFmpegKit Android API"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 6.0
PROJECT_NUMBER = 5.1
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
......
-keep class com.arthenica.ffmpegkit.FFmpegKitConfig {
native <methods>;
void log(long, int, byte[]);
void statistics(long, int, float, float, long , double, double, double);
void statistics(long, int, float, float, long , int, double, double);
int safOpen(int);
int safClose(int);
}
......
......@@ -45,7 +45,7 @@ struct CallbackData {
float statisticsFps; // statistics fps
float statisticsQuality; // statistics quality
int64_t statisticsSize; // statistics size
double statisticsTime; // statistics time
int statisticsTime; // statistics time
double statisticsBitrate; // statistics bitrate
double statisticsSpeed; // statistics speed
......@@ -312,7 +312,7 @@ void logCallbackDataAdd(int level, AVBPrint *data) {
/**
* Adds statistics data to the end of callback data list.
*/
void statisticsCallbackDataAdd(int frameNumber, float fps, float quality, int64_t size, double time, double bitrate, double speed) {
void statisticsCallbackDataAdd(int frameNumber, float fps, float quality, int64_t size, int time, double bitrate, double speed) {
// CREATE DATA STRUCT FIRST
struct CallbackData *newData = (struct CallbackData*)av_malloc(sizeof(struct CallbackData));
......@@ -491,7 +491,7 @@ void ffmpegkit_log_callback_function(void *ptr, int level, const char* format, v
* @param bitrate output bit rate in kbits/s
* @param speed processing speed = processed duration / operation duration
*/
void ffmpegkit_statistics_callback_function(int frameNumber, float fps, float quality, int64_t size, double time, double bitrate, double speed) {
void ffmpegkit_statistics_callback_function(int frameNumber, float fps, float quality, int64_t size, int time, double bitrate, double speed) {
statisticsCallbackDataAdd(frameNumber, fps, quality, size, time, bitrate, speed);
}
......@@ -581,30 +581,6 @@ int saf_close(int fd) {
return (*env)->CallStaticIntMethod(env, configClass, safCloseMethod, fd);
}
/**
* Used by JNI methods to enable redirection.
*/
static void enableNativeRedirection() {
mutexLock();
if (redirectionEnabled != 0) {
mutexUnlock();
return;
}
redirectionEnabled = 1;
mutexUnlock();
int rc = pthread_create(&callbackThread, 0, callbackThreadFunction, 0);
if (rc != 0) {
LOGE("Failed to create callback thread (rc=%d).\n", rc);
return;
}
av_log_set_callback(ffmpegkit_log_callback_function);
set_report_callback(ffmpegkit_statistics_callback_function);
}
/**
* Called when 'ffmpegkit' native library is loaded.
*
......@@ -644,7 +620,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_FALSE;
}
statisticsMethod = (*env)->GetStaticMethodID(env, localConfigClass, "statistics", "(JIFFJDDD)V");
statisticsMethod = (*env)->GetStaticMethodID(env, localConfigClass, "statistics", "(JIFFJIDD)V");
if (statisticsMethod == NULL) {
LOGE("OnLoad thread failed to GetStaticMethodID for %s.\n", "statistics");
return JNI_FALSE;
......@@ -689,8 +665,6 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
av_set_saf_open(saf_open);
av_set_saf_close(saf_close);
enableNativeRedirection();
return JNI_VERSION_1_6;
}
......@@ -722,7 +696,24 @@ JNIEXPORT jint JNICALL Java_com_arthenica_ffmpegkit_FFmpegKitConfig_getNativeLog
* @param object reference to the class on which this method is invoked
*/
JNIEXPORT void JNICALL Java_com_arthenica_ffmpegkit_FFmpegKitConfig_enableNativeRedirection(JNIEnv *env, jclass object) {
enableNativeRedirection();
mutexLock();
if (redirectionEnabled != 0) {
mutexUnlock();
return;
}
redirectionEnabled = 1;
mutexUnlock();
int rc = pthread_create(&callbackThread, 0, callbackThreadFunction, 0);
if (rc != 0) {
LOGE("Failed to create callback thread (rc=%d).\n", rc);
return;
}
av_log_set_callback(ffmpegkit_log_callback_function);
set_report_callback(ffmpegkit_statistics_callback_function);
}
/**
......
......@@ -27,7 +27,7 @@
#include "libavutil/ffversion.h"
/** Library version string */
#define FFMPEG_KIT_VERSION "6.0"
#define FFMPEG_KIT_VERSION "5.1"
/** Defines tag used for Android logging. */
#define LIB_NAME "ffmpeg-kit"
......
/*
* Various utilities for command line tools
* Copyright (c) 2000-2003 Fabrice Bellard
* Copyright (c) 2018-2022 Taner Sener
* Copyright (c) 2023 ARTHENICA LTD
* copyright (c) 2018 Taner Sener ( tanersener gmail com )
*
* This file is part of FFmpeg.
*
......@@ -26,12 +25,6 @@
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
*
* ffmpeg-kit changes by ARTHENICA LTD
*
* 07.2023
* --------------------------------------------------------
* - FFmpeg 6.0 changes migrated
*
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
*
* 09.2022
......@@ -136,18 +129,11 @@ void register_exit(void (*cb)(int ret))
program_exit = cb;
}
void report_and_exit(int ret)
{
av_log(NULL, AV_LOG_FATAL, "%s\n", av_err2str(ret));
exit_program(AVUNERROR(ret));
}
void exit_program(int ret)
{
if (program_exit)
program_exit(ret);
// FFmpegKit
// exit disabled and replaced with longjmp, exit value stored in longjmp_value
// exit(ret);
longjmp_value = ret;
......@@ -710,7 +696,7 @@ static void init_parse_context(OptionParseContext *octx,
octx->nb_groups = nb_groups;
octx->groups = av_calloc(octx->nb_groups, sizeof(*octx->groups));
if (!octx->groups)
report_and_exit(AVERROR(ENOMEM));
exit_program(1);
for (i = 0; i < octx->nb_groups; i++)
octx->groups[i].group_def = &groups[i];
......@@ -857,7 +843,12 @@ do { \
void print_error(const char *filename, int err)
{
av_log(NULL, AV_LOG_ERROR, "%s: %s\n", filename, av_err2str(err));
char errbuf[128];
const char *errbuf_ptr = errbuf;
if (av_strerror(err, errbuf, sizeof(errbuf)) < 0)
errbuf_ptr = strerror(AVUNERROR(err));
av_log(NULL, AV_LOG_ERROR, "%s: %s\n", filename, errbuf_ptr);
}
int read_yesno(void)
......@@ -980,7 +971,7 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
break;
}
while ((t = av_dict_iterate(opts, t))) {
while ((t = av_dict_get(opts, "", t, AV_DICT_IGNORE_SUFFIX))) {
const AVClass *priv_class;
char *p = strchr(t->key, ':');
......@@ -1018,8 +1009,11 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
if (!s->nb_streams)
return NULL;
opts = av_calloc(s->nb_streams, sizeof(*opts));
if (!opts)
report_and_exit(AVERROR(ENOMEM));
if (!opts) {
av_log(NULL, AV_LOG_ERROR,
"Could not alloc memory for stream options.\n");
exit_program(1);
}
for (i = 0; i < s->nb_streams; i++)
opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codecpar->codec_id,
s, s->streams[i], NULL);
......@@ -1034,8 +1028,10 @@ void *grow_array(void *array, int elem_size, int *size, int new_size)
}
if (*size < new_size) {
uint8_t *tmp = av_realloc_array(array, new_size, elem_size);
if (!tmp)
report_and_exit(AVERROR(ENOMEM));
if (!tmp) {
av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n");
exit_program(1);
}
memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
*size = new_size;
return tmp;
......@@ -1048,8 +1044,10 @@ void *allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems)
void *new_elem;
if (!(new_elem = av_mallocz(elem_size)) ||
av_dynarray_add_nofree(ptr, nb_elems, new_elem) < 0)
report_and_exit(AVERROR(ENOMEM));
av_dynarray_add_nofree(ptr, nb_elems, new_elem) < 0) {
av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n");
exit_program(1);
}
return new_elem;
}
......
/*
* Various utilities for command line tools
* copyright (c) 2003 Fabrice Bellard
* copyright (c) 2018-2022 Taner Sener
* copyright (c) 2023 ARTHENICA LTD
* copyright (c) 2018 Taner Sener ( tanersener gmail com )
*
* This file is part of FFmpeg.
*
......@@ -26,12 +25,6 @@
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
*
* ffmpeg-kit changes by ARTHENICA LTD
*
* 07.2023
* --------------------------------------------------------
* - FFmpeg 6.0 changes migrated
*
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
*
* 09.2022
......@@ -102,17 +95,6 @@ extern __thread int find_stream_info;
*/
void register_exit(void (*cb)(int ret));
/**
* Reports an error corresponding to the provided
* AVERROR code and calls exit_program() with the
* corresponding POSIX error code.
* @note ret must be an AVERROR-value of a POSIX error code
* (i.e. AVERROR(EFOO) and not AVERROR_FOO).
* library functions can return both, so call this only
* with AVERROR(EFOO) of your own.
*/
void report_and_exit(int ret) av_noreturn;
/**
* Wraps exit with a program-specific cleanup routine.
*/
......@@ -250,6 +232,11 @@ void show_help_children(const AVClass *clazz, int flags);
void show_help_default_ffmpeg(const char *opt, const char *arg);
void show_help_default_ffprobe(const char *opt, const char *arg);
/**
* Generic -h handler common to all fftools.
*/
int show_help(void *optctx, const char *opt, const char *arg);
/**
* Parse the command line arguments.
*
......
This source diff could not be displayed because it is too large. You can view the blob instead.
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论