Skip to content

Commit 6c2dd43

Browse files
committed
add ijksoundtouch
1 parent a8f0a26 commit 6c2dd43

6 files changed

Lines changed: 181 additions & 3 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ ios/openssl-*
88
extra
99
.DS_Store
1010
ijkmedia/ijkyuv/
11-
ijkmedia/ijksoundtouch
1211
ijkprof/android-ndk-profiler/
1312

1413
# built application files

android/ijkplayer/ijkplayer-cmake/src/main/cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ include_directories(${ijkmedia}/ijkplayer)
2828
file(GLOB_RECURSE SOURCE_IJKJ4A ${ijkmedia}/ijkj4a/*.c ${ijkmedia}/ijkj4a/*.cpp)
2929
file(GLOB_RECURSE SOURCE_SDL ${ijkmedia}/ijksdl/*.c ${ijkmedia}/ijksdl/*.cpp)
3030
file(GLOB_RECURSE SOURCE_IJKPLAYER ${ijkmedia}/ijkplayer/*.c ${ijkmedia}/ijkplayer/*.cpp)
31-
file(GLOB_RECURSE SOURCE_SOUNDTOUCH ${ijkmedia}/ijksoundtouch/*.cpp)
31+
file(GLOB_RECURSE SOURCE_SOUNDTOUCH ${ijkmedia}/ijksoundtouch/ijksoundtouch_wrap.cpp)
3232

3333
add_library(${CMAKE_PROJECT_NAME}
3434
SHARED

android/install-ffmpeg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#! /usr/bin/env bash
22
#
33

4-
../FFToolChain/main.sh install -l ijkffmpeg -p android
4+
../FFToolChain/main.sh install -l 'soundtouch yuv ijkffmpeg' -p android
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*****************************************************************************
2+
* ijksoundtouch_log.h
3+
*****************************************************************************
4+
*
5+
* Copyright (c) 2017 Bilibili
6+
* copyright (c) 2017 Raymond Zheng <raymondzheng1412@gmail.com>
7+
*
8+
* This file is part of ijkPlayer.
9+
*
10+
* ijkPlayer is free software; you can redistribute it and/or
11+
* modify it under the terms of the GNU Lesser General Public
12+
* License as published by the Free Software Foundation; either
13+
* version 2.1 of the License, or (at your option) any later version.
14+
*
15+
* ijkPlayer is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18+
* Lesser General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Lesser General Public
21+
* License along with ijkPlayer; if not, write to the Free Software
22+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23+
*/
24+
25+
#ifndef IJKSDL__IJKSOUNDTOUCH_LOG_H
26+
#define IJKSDL__IJKSOUNDTOUCH_LOG_H
27+
28+
#include <stdio.h>
29+
30+
#ifdef __ANDROID__
31+
32+
#include <android/log.h>
33+
34+
#define IJK_LOG_UNKNOWN ANDROID_LOG_UNKNOWN
35+
#define IJK_LOG_DEFAULT ANDROID_LOG_DEFAULT
36+
37+
#define IJK_LOG_VERBOSE ANDROID_LOG_VERBOSE
38+
#define IJK_LOG_DEBUG ANDROID_LOG_DEBUG
39+
#define IJK_LOG_INFO ANDROID_LOG_INFO
40+
#define IJK_LOG_WARN ANDROID_LOG_WARN
41+
#define IJK_LOG_ERROR ANDROID_LOG_ERROR
42+
#define IJK_LOG_FATAL ANDROID_LOG_FATAL
43+
#define IJK_LOG_SILENT ANDROID_LOG_SILENT
44+
45+
#define VLOG(level, TAG, ...) ((void)__android_log_vprint(level, TAG, __VA_ARGS__))
46+
#define ALOG(level, TAG, ...) ((void)__android_log_print(level, TAG, __VA_ARGS__))
47+
48+
#else
49+
50+
#define IJK_LOG_UNKNOWN 0
51+
#define IJK_LOG_DEFAULT 1
52+
53+
#define IJK_LOG_VERBOSE 2
54+
#define IJK_LOG_DEBUG 3
55+
#define IJK_LOG_INFO 4
56+
#define IJK_LOG_WARN 5
57+
#define IJK_LOG_ERROR 6
58+
#define IJK_LOG_FATAL 7
59+
#define IJK_LOG_SILENT 8
60+
61+
#define VLOG(level, TAG, ...) ((void)vprintf(__VA_ARGS__))
62+
#define ALOG(level, TAG, ...) ((void)printf(__VA_ARGS__))
63+
64+
#endif
65+
66+
#define IJK_LOG_TAG "IJKMEDIA"
67+
68+
#define VLOGV(...) VLOG(IJK_LOG_VERBOSE, IJK_LOG_TAG, __VA_ARGS__)
69+
#define VLOGD(...) VLOG(IJK_LOG_DEBUG, IJK_LOG_TAG, __VA_ARGS__)
70+
#define VLOGI(...) VLOG(IJK_LOG_INFO, IJK_LOG_TAG, __VA_ARGS__)
71+
#define VLOGW(...) VLOG(IJK_LOG_WARN, IJK_LOG_TAG, __VA_ARGS__)
72+
#define VLOGE(...) VLOG(IJK_LOG_ERROR, IJK_LOG_TAG, __VA_ARGS__)
73+
74+
#define ALOGV(...) ALOG(IJK_LOG_VERBOSE, IJK_LOG_TAG, __VA_ARGS__)
75+
#define ALOGD(...) ALOG(IJK_LOG_DEBUG, IJK_LOG_TAG, __VA_ARGS__)
76+
#define ALOGI(...) ALOG(IJK_LOG_INFO, IJK_LOG_TAG, __VA_ARGS__)
77+
#define ALOGW(...) ALOG(IJK_LOG_WARN, IJK_LOG_TAG, __VA_ARGS__)
78+
#define ALOGE(...) ALOG(IJK_LOG_ERROR, IJK_LOG_TAG, __VA_ARGS__)
79+
#define LOG_ALWAYS_FATAL(...) do { ALOGE(__VA_ARGS__); exit(1); } while (0)
80+
81+
#endif
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) 2017 Bilibili
3+
* copyright (c) 2017 Raymond Zheng <raymondzheng1412@gmail.com>
4+
*
5+
* This file is part of ijkPlayer.
6+
*
7+
* ijkPlayer 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+
* ijkPlayer 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 ijkPlayer; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*/
21+
22+
#include <soundtouch/SoundTouch.h>
23+
#include "ijksoundtouch_log.h"
24+
25+
using namespace std;
26+
27+
using namespace soundtouch;
28+
extern "C" void* ijk_soundtouch_create();
29+
extern "C" int ijk_soundtouch_translate(void *handle, short* data, float speed, float pitch, int len, int bytes_per_sample, int n_channel, int n_sampleRate);
30+
extern "C" void ijk_soundtouch_destroy(void *handle);
31+
32+
void* ijk_soundtouch_create() {
33+
SoundTouch *handle_ptr = new SoundTouch();
34+
return handle_ptr;
35+
}
36+
37+
int ijk_soundtouch_translate(void *handle, short* data, float speed, float pitch, int len, int bytes_per_sample, int n_channel, int n_sampleRate) {
38+
SoundTouch *handle_ptr = (SoundTouch*)handle;
39+
int put_n_sample = len / n_channel;
40+
int nb = 0;
41+
int pcm_data_size = 0;
42+
if (handle_ptr == NULL)
43+
return 0;
44+
45+
handle_ptr->setPitch(pitch);
46+
handle_ptr->setRate(speed);
47+
48+
handle_ptr->setSampleRate(n_sampleRate);
49+
handle_ptr->setChannels(n_channel);
50+
51+
handle_ptr->putSamples((SAMPLETYPE*)data, put_n_sample);
52+
53+
do {
54+
nb = handle_ptr->receiveSamples((SAMPLETYPE*)data, n_sampleRate / n_channel);
55+
pcm_data_size += nb * n_channel * bytes_per_sample;
56+
} while (nb != 0);
57+
58+
return pcm_data_size;
59+
}
60+
61+
void ijk_soundtouch_destroy(void *handle) {
62+
SoundTouch *handle_ptr = (SoundTouch*)handle;
63+
if (handle_ptr == NULL)
64+
return;
65+
handle_ptr->clear();
66+
delete handle_ptr;
67+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2017 Bilibili
3+
* copyright (c) 2017 Raymond Zheng <raymondzheng1412@gmail.com>
4+
*
5+
* This file is part of ijkPlayer.
6+
*
7+
* ijkPlayer 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+
* ijkPlayer 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 ijkPlayer; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*/
21+
22+
#ifndef IJKSOUNDTOUCHWRAP_H
23+
#define IJKSOUNDTOUCHWRAP_H
24+
25+
#include <stdint.h>
26+
27+
void* ijk_soundtouch_create();
28+
int ijk_soundtouch_translate(void *handle, short* data, float speed, float pitch, int len, int bytes_per_sample, int n_channel, int n_sampleRate);
29+
void ijk_soundtouch_destroy(void *handle);
30+
31+
#endif /* IJKSOUNDTOUCHWRAP_H */

0 commit comments

Comments
 (0)