Commit 4d74ddc9 authored by Ghislain MARY's avatar Ghislain MARY

Handle compilation for Android with CMake.

parent 803540f7
......@@ -74,6 +74,7 @@ cmake_dependent_option(ENABLE_ZRTP "Build with ZRTP support." YES "ENABLE_SRTP"
option(ENABLE_SOUND "Can be used to turn off all possible sound backends." YES)
cmake_dependent_option(ENABLE_ALSA "Enable ALSA support." YES "ENABLE_SOUND;LINUX_OR_BSD" NO)
cmake_dependent_option(ENABLE_ANDROIDSND "Enable Android sound support." NO "ENABLE_SOUND;ANDROID" NO)
cmake_dependent_option(ENABLE_ARTSC "Enable artsc (KDE<4) sound input/output." NO "ENABLE_SOUND;LINUX_OR_BSD" NO)
cmake_dependent_option(ENABLE_MACSND "Enable MAC OS X Audio Units sound support." ${ENABLE_MACSND_DEFAULT_VALUE} "ENABLE_SOUND;APPLE" NO)
cmake_dependent_option(ENABLE_MACAQSND "Enable native MAC OS X Audio Queue sound support." ${ENABLE_MACAQSND_DEFAULT_VALUE} "ENABLE_SOUND;APPLE" NO)
......@@ -134,8 +135,6 @@ if(MSVC AND MSVC_VERSION LESS 1800)
list(APPEND CMAKE_REQUIRED_INCLUDES "${MSVC_INCLUDE_DIR}")
endif()
find_package(Threads)
check_include_file(sys/shm.h HAVE_SYS_SHM_H)
check_include_file(alloca.h HAVE_ALLOCA_H)
if(ENABLE_OSS)
......@@ -297,7 +296,7 @@ if(ENABLE_QNX)
endif()
endif()
if(ENABLE_SOUND AND NOT(WIN32 OR ENABLE_ALSA OR ENABLE_ARTSC OR ENABLE_MACSND OR ENABLE_MACAQSND OR ENABLE_OSS OR ENABLE_PORTAUDIO OR ENABLE_PULSEAUDIO OR ENABLE_QSA))
if(ENABLE_SOUND AND NOT(WIN32 OR ENABLE_ALSA OR ENABLE_ARTSC OR ENABLE_MACSND OR ENABLE_MACAQSND OR ENABLE_OSS OR ENABLE_PORTAUDIO OR ENABLE_PULSEAUDIO OR ENABLE_QSA OR ENABLE_ANDROIDSND))
message(FATAL_ERROR "Could not find a support sound driver API. Use -DENABLE_SOUND=NO if you don't care about having sound.")
endif()
......@@ -385,6 +384,12 @@ endif()
if(MSVC_INCLUDE_DIR)
include_directories(${MSVC_INCLUDE_DIR})
endif()
if(ENABLE_ANDROIDSND)
include_directories(
src/android
src/android/media
)
endif()
if(ENABLE_DEBUG_LOGS)
add_definitions(-DDEBUG)
......@@ -478,6 +483,9 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mediastreamer-config.h.cmake ${CMAKE_
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/mediastreamer-config.h PROPERTIES GENERATED ON)
add_definitions("-DHAVE_CONFIG_H")
add_definitions(${ORTP_CPPFLAGS})
if(ANDROID)
add_definitions("-DANDROID")
endif()
set(STRICT_OPTIONS_CPP )
set(STRICT_OPTIONS_C )
......
......@@ -29,13 +29,8 @@
include(CMakePushCheckState)
include(CheckSymbolExists)
set(_FFMPEG_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(LIBAVCODEC_INCLUDE_DIRS
NAMES libavcodec/avcodec.h
HINTS _FFMPEG_ROOT_PATHS
PATH_SUFFIXES include
)
if(LIBAVCODEC_INCLUDE_DIRS)
......@@ -43,7 +38,6 @@ if(LIBAVCODEC_INCLUDE_DIRS)
endif()
find_path(LIBAVUTIL_INCLUDE_DIRS
NAMES libavutil/avutil.h
HINTS _FFMPEG_ROOT_PATHS
PATH_SUFFIXES include
)
if(LIBAVUTIL_INCLUDE_DIRS)
......@@ -51,31 +45,35 @@ if(LIBAVUTIL_INCLUDE_DIRS)
endif()
find_path(LIBSWSCALE_INCLUDE_DIRS
NAMES libswscale/swscale.h
HINTS _FFMPEG_ROOT_PATHS
PATH_SUFFIXES include
)
if(LIBSWSCALE_INCLUDE_DIRS)
set(HAVE_LIBSWSCALE_SWSCALE_H 1)
endif()
find_library(LIBAVCODEC_LIBRARIES
NAMES avcodec
HINTS _FFMPEG_ROOT_PATHS
PATH_SUFFIXES bin lib
)
find_library(LIBAVUTIL_LIBRARIES
NAMES avutil
HINTS _FFMPEG_ROOT_PATHS
PATH_SUFFIXES bin lib
)
find_library(LIBSWSCALE_LIBRARIES
NAMES swscale
HINTS _FFMPEG_ROOT_PATHS
PATH_SUFFIXES bin lib
)
if(ANDROID)
find_library(FFMPEG_LIBRARIES
NAMES ffmpeg-linphone-${CMAKE_SYSTEM_PROCESSOR}
)
else()
find_library(LIBAVCODEC_LIBRARIES
NAMES avcodec
PATH_SUFFIXES bin lib
)
find_library(LIBAVUTIL_LIBRARIES
NAMES avutil
PATH_SUFFIXES bin lib
)
find_library(LIBSWSCALE_LIBRARIES
NAMES swscale
PATH_SUFFIXES bin lib
)
endif()
set(FFMPEG_INCLUDE_DIRS ${LIBAVCODEC_INCLUDE_DIRS} ${LIBAVUTIL_INCLUDE_DIRS} ${LIBSWSCALE_INCLUDE_DIRS})
set(FFMPEG_LIBRARIES ${LIBAVCODEC_LIBRARIES} ${LIBAVUTIL_LIBRARIES} ${LIBSWSCALE_LIBRARIES})
if(NOT ANDROID)
set(FFMPEG_LIBRARIES ${LIBAVCODEC_LIBRARIES} ${LIBAVUTIL_LIBRARIES} ${LIBSWSCALE_LIBRARIES})
endif()
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
list(REMOVE_DUPLICATES FFMPEG_LIBRARIES)
......@@ -83,6 +81,9 @@ if(FFMPEG_LIBRARIES)
cmake_push_check_state(RESET)
list(APPEND CMAKE_REQUIRED_INCLUDES ${FFMPEG_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES})
if(ANDROID)
list(APPEND CMAKE_REQUIRED_LIBRARIES m)
endif()
if(MSVC)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -Dinline=__inline)
endif()
......@@ -95,14 +96,12 @@ if(FFMPEG_LIBRARIES)
cmake_pop_check_state()
endif()
set(VARS FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES LIBAVCODEC_INCLUDE_DIRS LIBAVUTIL_INCLUDE_DIRS LIBSWSCALE_INCLUDE_DIRS)
if(NOT ANDROID)
list(APPEND VARS LIBAVCODEC_LIBRARIES LIBAVUTIL_LIBRARIES LIBSWSCALE_LIBRARIES)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFMpeg
DEFAULT_MSG
FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES
LIBAVCODEC_INCLUDE_DIRS LIBAVUTIL_INCLUDE_DIRS LIBSWSCALE_INCLUDE_DIRS
LIBAVCODEC_LIBRARIES LIBAVUTIL_LIBRARIES LIBSWSCALE_LIBRARIES
)
find_package_handle_standard_args(FFMpeg DEFAULT_MSG ${VARS})
mark_as_advanced(FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES
LIBAVCODEC_INCLUDE_DIRS LIBAVUTIL_INCLUDE_DIRS LIBSWSCALE_INCLUDE_DIRS
LIBAVCODEC_LIBRARIES LIBAVUTIL_LIBRARIES LIBSWSCALE_LIBRARIES)
mark_as_advanced(${VARS})
......@@ -24,6 +24,7 @@ set(HEADER_FILES
allfilters.h
bitratecontrol.h
bits_rw.h
devices.h
dsptools.h
dtls_srtp.h
dtmfgen.h
......
......@@ -20,6 +20,8 @@
#
############################################################################
find_library(LIBM NAMES m)
if(MSVC AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
find_library(LIBGCC NAMES gcc)
find_library(LIBMINGWEX NAMES mingwex)
......@@ -46,6 +48,9 @@ set(BASE_SOURCE_FILES_C
otherfilters/tee.c
otherfilters/void.c
)
if(ANDROID)
list(APPEND BASE_SOURCE_FILES_C utils/msjava.c)
endif()
find_package(Git)
add_custom_target(ms2-git-version
......@@ -92,6 +97,9 @@ endif()
if(ENABLE_SHARED)
add_library(mediastreamer_base SHARED ${MEDIASTREAMER2_HEADER_FILES} ${BASE_SOURCE_FILES_C})
set_target_properties(mediastreamer_base PROPERTIES VERSION ${MEDIASTREAMER_SO_VERSION} LINKER_LANGUAGE C)
if(ANDROID)
set_target_properties(mediastreamer_base PROPERTIES OUTPUT_NAME "mediastreamer_base-${CMAKE_SYSTEM_PROCESSOR}")
endif()
target_link_libraries(mediastreamer_base ${BASE_LIBS})
add_dependencies(mediastreamer_base ms2-git-version ms2-basedescs-header)
if(MSVC)
......@@ -117,7 +125,6 @@ set(VOIP_SOURCE_FILES_C
audiofilters/audiomixer.c
audiofilters/chanadapt.c
audiofilters/devices.c
audiofilters/devices.h
audiofilters/dtmfgen.c
audiofilters/equalizer.c
audiofilters/flowcontrol.c
......@@ -173,10 +180,25 @@ set(VOIP_SOURCE_FILES_C
)
set(VOIP_SOURCE_FILES_CXX )
set(VOIP_SOURCE_FILES_OBJC )
set(VOIP_SOURCE_FILES_ASM )
if(ENABLE_ALSA)
list(APPEND VOIP_SOURCE_FILES_C audiofilters/alsa.c)
endif()
if(ENABLE_ANDROIDSND)
list(APPEND VOIP_SOURCE_FILES_CXX
android/androidsound.cpp
android/androidsound_depr.cpp
android/androidsound_opensles.cpp
android/AudioRecord.cpp
android/AudioSystem.cpp
android/AudioTrack.cpp
android/hardware_echo_canceller.cpp
android/loader.cpp
android/String8.cpp
audiofilters/aac-eld-android.cpp
)
endif()
if(ENABLE_ARTSC)
list(APPEND VOIP_SOURCE_FILES_C audiofilters/arts.c)
endif()
......@@ -284,6 +306,29 @@ if(ENABLE_VIDEO)
if(APPLE)
list(APPEND VOIP_SOURCE_FILES_C videofilters/videotoolbox.c)
endif()
if(ANDROID)
list(APPEND VOIP_SOURCE_FILES_C
android/mediacodech264dec.c
android/mediacodech264enc.c
android/android-display.c
android/android-opengl-display.c
utils/opengles_display.c
utils/opengles_display.h
utils/shaders.c
utils/shaders.h
voip/scaler.c
)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi-v7a")
list(APPEND VOIP_SOURCE_FILES_ASM
voip/scaler_arm.S
)
endif()
list(APPEND VOIP_SOURCE_FILES_CXX
android/android_mediacodec.cpp
android/android-display-bad.cpp
android/androidvideo.cpp
)
endif()
if (ENABLE_QNX)
list(APPEND VOIP_SOURCE_FILES_CXX
videofilters/bb10_display.cpp
......@@ -353,7 +398,7 @@ add_custom_target(ms2-voipdescs-header
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/voipdescs.h"
)
if(APPLE OR GLX_FOUND)
if(APPLE OR ANDROID OR GLX_FOUND)
find_program(XXD_PROGRAM xxd)
if(NOT XXD_PROGRAM)
message(FATAL_ERROR "You need the xxd program to build mediastreamer2.")
......@@ -386,6 +431,22 @@ if(VOIP_SOURCE_FILES_CXX)
endif()
if(ENABLE_VIDEO AND ANDROID AND CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi-v7a")
set_source_files_properties(voip/msvideo_neon.c voip/scaler.c PROPERTIES COMPILE_FLAGS "-mfpu=neon")
endif()
if(VOIP_SOURCE_FILES_ASM)
if(ANDROID AND CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi-v7a")
set(ARCH_OPTIONS "-mfpu=neon")
endif()
get_directory_property(DIRECTORY_PROPERTY_COMPILE_OPTIONS "COMPILE_OPTIONS")
string(REPLACE ";" " " DIRECTORY_PROPERTY_COMPILE_OPTIONS "${DIRECTORY_PROPERTY_COMPILE_OPTIONS}")
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> ${CMAKE_CPP_FLAGS} ${CMAKE_C_FLAGS} ${DIRECTORY_PROPERTY_COMPILE_OPTIONS} ${ARCH_OPTIONS} -o <OBJECT> -c <SOURCE>")
enable_language(ASM)
endif()
set(VOIP_LIBS
${BCTOOLBOX_CORE_LIBRARIES}
${ORTP_LIBRARIES}
......@@ -398,6 +459,12 @@ if(WIN32)
endif()
endif()
endif()
if(LIBM)
list(APPEND VOIP_LIBS ${LIBM})
endif()
if(ANDROID AND ENABLE_VIDEO)
list(APPEND VOIP_LIBS GLESv2)
endif()
if(HAVE_DLOPEN)
list(APPEND VOIP_LIBS dl)
endif()
......@@ -470,13 +537,13 @@ if (CAMAPI_FOUND)
endif()
set(MS2_VOIP_DEPENDENCIES ms2-git-version ms2-voipdescs-header)
if(APPLE OR GLX_FOUND)
if(APPLE OR ANDROID OR GLX_FOUND)
list(APPEND MS2_VOIP_DEPENDENCIES ms2-yuv2rgb-fs-header ms2-yuv2rgb-vs-header)
endif()
string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}")
if(ENABLE_STATIC)
add_library(mediastreamer_voip-static STATIC ${MEDIASTREAMER2_HEADER_FILES} ${VOIP_SOURCE_FILES_C} ${VOIP_SOURCE_FILES_CXX} ${VOIP_SOURCE_FILES_OBJC})
add_library(mediastreamer_voip-static STATIC ${MEDIASTREAMER2_HEADER_FILES} ${VOIP_SOURCE_FILES_C} ${VOIP_SOURCE_FILES_CXX} ${VOIP_SOURCE_FILES_OBJC} ${VOIP_SOURCE_FILES_ASM})
set_target_properties(mediastreamer_voip-static PROPERTIES OUTPUT_NAME mediastreamer_voip)
if(LINK_FLAGS_STR)
set_target_properties(mediastreamer_voip-static PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
......@@ -489,12 +556,15 @@ if(ENABLE_STATIC)
)
endif()
if(ENABLE_SHARED)
add_library(mediastreamer_voip SHARED ${MEDIASTREAMER2_HEADER_FILES} ${VOIP_SOURCE_FILES_C} ${VOIP_SOURCE_FILES_CXX} ${VOIP_SOURCE_FILES_OBJC})
set_target_properties(mediastreamer_voip PROPERTIES VERSION ${MEDIASTREAMER_SO_VERSION} LINKER_LANGUAGE CXX)
add_library(mediastreamer_voip SHARED ${MEDIASTREAMER2_HEADER_FILES} ${VOIP_SOURCE_FILES_C} ${VOIP_SOURCE_FILES_CXX} ${VOIP_SOURCE_FILES_OBJC} ${VOIP_SOURCE_FILES_ASM})
set_target_properties(mediastreamer_voip PROPERTIES SOVERSION ${MEDIASTREAMER_SO_VERSION} LINKER_LANGUAGE CXX)
if(LINK_FLAGS_STR)
set_target_properties(mediastreamer_voip PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
endif()
add_dependencies(mediastreamer_voip ${MS2_VOIP_DEPENDENCIES})
if(ANDROID)
set_target_properties(mediastreamer_voip PROPERTIES OUTPUT_NAME "mediastreamer_voip-${CMAKE_SYSTEM_PROCESSOR}")
endif()
target_link_libraries(mediastreamer_voip mediastreamer_base ${VOIP_LIBS})
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
......
......@@ -17,8 +17,6 @@
#ifndef ANDROID_AUDIOSYSTEM_H_
#define ANDROID_AUDIOSYSTEM_H_
#include <cstddef>
#include "audio.h"
#include "loader.h"
......
......@@ -89,6 +89,8 @@ static void android_display_process(MSFilter *f){
if (ad->android_video_window){
if ((m=ms_queue_peek_last(f->inputs[0]))!=NULL){
if (ms_yuv_buf_init_from_mblk (&pic,m)==0){
JNIEnv *jenv;
/* schedule display of frame */
if (ad->ogl) {
/* m is dupb'ed inside ogl_display */
......@@ -97,7 +99,7 @@ static void android_display_process(MSFilter *f){
ms_warning("%s: opengldisplay not ready (%p)", __FUNCTION__, ad->ogl);
}
JNIEnv *jenv=ms_get_jni_env();
jenv=ms_get_jni_env();
(*jenv)->CallVoidMethod(jenv,ad->android_video_window,ad->request_render_id);
}
}
......
......@@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "mediastreamer2/mscommon.h"
#include "mediastreamer2/msjava.h"
#include <media/NdkMediaCodec.h>
#include <media/NdkMediaFormat.h>
......
......@@ -19,8 +19,10 @@
*/
#include <mediastreamer2/msfilter.h>
#include <mediastreamer2/msjava.h>
#include <mediastreamer2/msticker.h>
#include <mediastreamer2/mssndcard.h>
#include <mediastreamer2/devices.h>
#include "AudioTrack.h"
#include "AudioRecord.h"
......@@ -28,7 +30,6 @@
#include <jni.h>
#include "audiofilters/devices.h"
#include "hardware_echo_canceller.h"
#define NATIVE_USE_HARDWARE_RATE 1
......
......@@ -23,6 +23,7 @@
#include "mediastreamer2/msfilter.h"
#include "mediastreamer2/msticker.h"
#include "mediastreamer2/msjava.h"
#include "mediastreamer2/devices.h"
#include <jni.h>
#include <sys/time.h>
......@@ -31,7 +32,6 @@
#include "mediastreamer2/zrtp.h"
#include <cpu-features.h>
#include "audiofilters/devices.h"
#include "hardware_echo_canceller.h"
static const float sndwrite_flush_threshold=0.020; //ms
......@@ -602,8 +602,6 @@ MSFilter *msandroid_sound_read_new(MSSndCard *card){
return f;
}
MS_FILTER_DESC_EXPORT(msandroid_sound_read_desc)
/***********************************write filter********************/
static int set_write_rate(MSFilter *f, void *arg){
#ifndef USE_HARDWARE_RATE
......@@ -687,10 +685,12 @@ static void* msandroid_write_cb(msandroid_sound_write_data* d) {
int check_point_size=3*(float)d->rate*(float)d->nchannels*2.0; /*3 seconds*/
int nwrites=0;
set_high_prio();
int buff_size = d->write_chunk_size;
uint8_t tmpBuff[buff_size];
JNIEnv *jni_env = ms_get_jni_env();
set_high_prio();
// int write (byte[] audioData, int offsetInBytes, int sizeInBytes)
write_id = jni_env->GetMethodID(d->audio_track_class,"write", "([BII)I");
if(write_id==0) {
......@@ -703,7 +703,6 @@ static void* msandroid_write_cb(msandroid_sound_write_data* d) {
goto end;
}
write_buff = jni_env->NewByteArray(buff_size);
uint8_t tmpBuff[buff_size];
//start playing
jni_env->CallVoidMethod(d->audio_track,play_id);
......@@ -931,8 +930,6 @@ MSFilter *msandroid_sound_write_new(MSSndCard *card){
}
MS_FILTER_DESC_EXPORT(msandroid_sound_write_desc)
/******* Hack for Galaxy S ***********/
......
......@@ -19,8 +19,10 @@
*/
#include <mediastreamer2/msfilter.h>
#include <mediastreamer2/msjava.h>
#include <mediastreamer2/msticker.h>
#include <mediastreamer2/mssndcard.h>
#include <mediastreamer2/devices.h>
#include <sys/types.h>
#include <string.h>
......@@ -29,7 +31,6 @@
#include <SLES/OpenSLES_AndroidConfiguration.h>
#include <jni.h>
#include <dlfcn.h>
#include "audiofilters/devices.h"
namespace fake_opensles {
SLInterfaceID SLW_IID_ENGINE = NULL;
......@@ -389,7 +390,6 @@ static SLresult opensles_recorder_init(OpenSLESInputContext *ictx) {
}
static void compute_timespec(OpenSLESInputContext *ictx) {
static int count = 0;
uint64_t ns = ((1000 * ictx->read_samples) / (uint64_t) ictx->opensles_context->samplerate) * 1000000;
MSTimeSpec ts;
ts.tv_nsec = ns % 1000000000;
......
......@@ -46,8 +46,8 @@ typedef struct _DecData{
}DecData;
static void dec_init(MSFilter *f){
AMediaCodec *codec;
codec = AMediaCodec_createDecoderByType("video/avc");
AMediaFormat *format;
AMediaCodec *codec = AMediaCodec_createDecoderByType("video/avc");
DecData *d=ms_new0(DecData,1);
d->codec = codec;
d->sps=NULL;
......@@ -62,7 +62,7 @@ static void dec_init(MSFilter *f){
d->buf_allocator = ms_yuv_buf_allocator_new();
ms_average_fps_init(&d->fps, " H264 decoder: FPS: %f");
AMediaFormat *format = AMediaFormat_new();
format = AMediaFormat_new();
AMediaFormat_setString(format,"mime","video/avc");
//Size mandatory for decoder configuration
AMediaFormat_setInt32(format,"width",1920);
......@@ -83,7 +83,9 @@ static void dec_preprocess(MSFilter* f) {
static void dec_postprocess(MSFilter *f) {
}
#if 0
static void dec_reinit(DecData *d){
AMediaFormat *format;
AMediaCodec_flush(d->codec);
AMediaCodec_stop(d->codec);
AMediaCodec_delete(d->codec);
......@@ -91,7 +93,7 @@ static void dec_reinit(DecData *d){
ms_message("Restart dec");
d->codec = AMediaCodec_createDecoderByType("video/avc");
AMediaFormat *format = AMediaFormat_new();
format = AMediaFormat_new();
AMediaFormat_setString(format,"mime","video/avc");
//Size mandatory for decoder configuration
AMediaFormat_setInt32(format,"width",1920);
......@@ -101,6 +103,7 @@ static void dec_reinit(DecData *d){
AMediaCodec_start(d->codec);
AMediaFormat_delete(format);
}
#endif
static void dec_uninit(MSFilter *f){
DecData *d=(DecData*)f->data;
......@@ -225,12 +228,12 @@ static int nalusToFrame(DecData *d, MSQueue *naluq, bool_t *new_sps_pps){
static void dec_process(MSFilter *f){
DecData *d=(DecData*)f->data;
MSPicture pic = {0};
MSQueue nalus;
ms_queue_init(&nalus);
mblk_t *im,*om = NULL;
bool_t need_reinit=FALSE;
bool_t request_pli=FALSE;
MSQueue nalus;
ms_queue_init(&nalus);
mblk_t *im,*om = NULL;
while((im=ms_queue_get(f->inputs[0]))!=NULL){
if (d->packet_num==0 && d->sps && d->pps){
mblk_set_timestamp_info(d->sps,mblk_get_timestamp_info(im));
......@@ -245,6 +248,7 @@ static void dec_process(MSFilter *f){
request_pli=TRUE;
}
if (!ms_queue_empty(&nalus)){
AMediaCodecBufferInfo info;
int size;
int width = 0, height = 0, color = 0;
uint8_t *buf=NULL;
......@@ -272,16 +276,16 @@ static void dec_process(MSFilter *f){
}
}
AMediaCodecBufferInfo info;
oBufidx = AMediaCodec_dequeueOutputBuffer(d->codec, &info, TIMEOUT_US);
if(oBufidx >= 0){
AMediaFormat *format;
buf = AMediaCodec_getOutputBuffer(d->codec, oBufidx, &bufsize);
if(buf == NULL){
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_DECODING_ERRORS);
break;
}
AMediaFormat *format = AMediaCodec_getOutputFormat(d->codec);
format = AMediaCodec_getOutputFormat(d->codec);
if(format != NULL){
AMediaFormat_getInt32(format, "width", &width);
AMediaFormat_getInt32(format, "height", &height);
......
......@@ -77,17 +77,19 @@ static void enc_init(MSFilter *f){
}
static void enc_preprocess(MSFilter* f) {
AMediaCodec *codec;
AMediaFormat *format;
media_status_t status;
EncData *d=(EncData*)f->data;
d->packer=rfc3984_new();
rfc3984_set_mode(d->packer,d->mode);
rfc3984_enable_stap_a(d->packer,FALSE);
ms_video_starter_init(&d->starter);
AMediaCodec *codec;
codec = AMediaCodec_createEncoderByType("video/avc");
d->codec = codec;
AMediaFormat *format = AMediaFormat_new();
format = AMediaFormat_new();
AMediaFormat_setString(format, "mime", "video/avc");
AMediaFormat_setInt32(format, "width", d->vconf.vsize.width);
AMediaFormat_setInt32(format, "height", d->vconf.vsize.height);
......@@ -96,7 +98,7 @@ static void enc_preprocess(MSFilter* f) {
AMediaFormat_setInt32(format, "bitrate", d->vconf.required_bitrate);
AMediaFormat_setInt32(format, "frame-rate", d->vconf.fps);
AMediaFormat_setInt32(format, "bitrate-mode",1);
media_status_t status = AMediaCodec_configure(d->codec, format, NULL, NULL, AMEDIACODEC_CONFIGURE_FLAG_ENCODE);
status = AMediaCodec_configure(d->codec, format, NULL, NULL, AMEDIACODEC_CONFIGURE_FLAG_ENCODE);
if(status != 0){
d->isYUV = FALSE;
......@@ -127,6 +129,7 @@ static void pushNalu(uint8_t *begin, uint8_t *end, uint32_t ts, bool marker, MS
uint8_t *src=begin;
size_t nalu_len = (end-begin);
uint8_t nalu_byte = *src++;
unsigned ecount = 0;
mblk_t *m=allocb(nalu_len,0);
......@@ -138,7 +141,6 @@ static void pushNalu(uint8_t *begin, uint8_t *end, uint32_t ts, bool marker, MS
Within the NAL unit, the following three-byte sequence shall not occur at any byte-aligned position: 0x000000, 0x000001, 0x00002
*/
*m->b_wptr++=nalu_byte;
unsigned ecount = 0;
while (src<end-3) {
if (src[0]==0 && src[1]==0 && src[2]==3){
*m->b_wptr++=0;
......@@ -191,6 +193,7 @@ static void enc_process(MSFilter *f){
ms_queue_init(&nalus);
while((im=ms_queue_get(f->inputs[0]))!=NULL){
if (ms_yuv_buf_init_from_mblk(&pic,im)==0){
AMediaCodecBufferInfo info;
uint8_t *buf=NULL;
size_t bufsize;
ssize_t ibufidx, obufidx;
......@@ -206,10 +209,10 @@ static void enc_process(MSFilter *f){
memcpy(buf + ysize, pic.planes[1], usize);
memcpy(buf + ysize+usize, pic.planes[2], usize);
} else {
int i;
size_t size=(size_t) pic.w * pic.h;
uint8_t *dst = pic.planes[0];
memcpy(buf,dst,size);
int i;
for (i = 0; i < pic.w/2*pic.h/2; i++){
buf[size+2*i]=pic.planes[1][i];
......@@ -220,7 +223,6 @@ static void enc_process(MSFilter *f){
}
}
AMediaCodecBufferInfo info;
obufidx = AMediaCodec_dequeueOutputBuffer(d->codec, &info, TIMEOUT_US);
while(obufidx >= 0) {
buf = AMediaCodec_getOutputBuffer(d->codec, obufidx, &bufsize);
......
......@@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <mediastreamer2/msfilter.h>
#include <mediastreamer2/msjava.h>
#include <mediastreamer2/msticker.h>
#include <mediastreamer2/mscodecutils.h>
......
......@@ -20,7 +20,7 @@
#include "devices.h"
#include "mediastreamer2/devices.h"
#ifdef ANDROID
#include "sys/system_properties.h"
......
......@@ -18,11 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "mediastreamer2/msfilter.h"
#ifdef ANDROID
#include "gsm.h"
#else
#include <gsm/gsm.h>
#endif
#ifdef _MSC_VER
#include <malloc.h>
......
......@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ortp/rtp.h"
#include <stdint.h>
#if defined(ANDROID) || defined(MS2_WINDOWS_PHONE)
#if defined(MS2_WINDOWS_PHONE)
#include <opus.h>
#else
#include <opus/opus.h>
......
......@@ -506,11 +506,7 @@ int ms_factory_load_plugins(MSFactory *factory, const char *dir){
snprintf(szDirPath, sizeof(szDirPath), "%s", dir);
// Start searching for .dll files in the current directory.
#ifdef MS2_WINDOWS_DESKTOP
snprintf(szDirPath, sizeof(szDirPath), "%s\\*.dll", dir);
#else
snprintf(szDirPath, sizeof(szDirPath), "%s\\libms*.dll", dir);
#endif
#ifdef UNICODE
mbstowcs(wszDirPath, szDirPath, sizeof(wszDirPath));
hSearch = FindFirstFileExW(wszDirPath, FindExInfoStandard, &FileData, FindExSearchNameMatch, NULL, 0);
......@@ -621,7 +617,7 @@ int ms_factory_load_plugins(MSFactory *factory, const char *dir){
#ifndef __QNX__
(de->d_type==DT_REG || de->d_type==DT_UNKNOWN || de->d_type==DT_LNK) &&
#endif
(ext=strstr(de->d_name,PLUGINS_EXT))!=NULL) {
(strstr(de->d_name, "libms") == de->d_name) && ((ext=strstr(de->d_name,PLUGINS_EXT))!=NULL)) {
void *handle;
snprintf(plugin_name, MIN(sizeof(plugin_name), ext - de->d_name + 1), "%s", de->d_name);
if (ms_list_find_custom(loaded_plugins, (MSCompareFunc)strcmp, plugin_name) != NULL) continue;
......@@ -895,22 +891,26 @@ JNIEXPORT jboolean JNICALL Java_org_linphone_mediastream_Factory_filterFromNameE
#endif
JNIEXPORT jint JNICALL Java_org_linphone_mediastream_MediastreamerAndroidContext_enableFilterFromNameImpl(JNIEnv* env, jobject obj, jstring jname, jboolean enable) {
const char *mime;
int result;
if (ms_factory_get_fallback() == NULL) {
ms_error("Java_org_linphone_mediastream_MediastreamerAndroidContext_enableFilterFromNameImpl(): no fallback factory. Use Factory.enableFilterFromName()");
return -1;
}
const char *mime = jname ? (*env)->GetStringUTFChars(env, jname, NULL) : NULL;
int result = ms_factory_enable_filter_from_name(ms_factory_get_fallback(),mime,enable);
mime = jname ? (*env)->GetStringUTFChars(env, jname, NULL) : NULL;
result = ms_factory_enable_filter_from_name(ms_factory_get_fallback(),mime,enable);
(*env)->ReleaseStringUTFChars(env, jname, mime);
return result;
}
JNIEXPORT jboolean JNICALL Java_org_linphone_mediastream_MediastreamerAndroidContext_filterFromNameEnabledImpl(JNIEnv* env, jobject obj, jstring jname) {
const char *mime;
jboolean result;
if (ms_factory_get_fallback() == NULL) {
ms_error("Java_org_linphone_mediastream_MediastreamerAndroidContext_filterFromNameEnabledImpl(): no fallback factory. Use Factory.filterFromNameEnabled()");
return FALSE;
}
const char *mime = jname ? (*env)->GetStringUTFChars(env, jname, NULL) : NULL;
jboolean result = ms_factory_filter_from_name_enabled(ms_factory_get_fallback(),mime);
mime = jname ? (*env)->GetStringUTFChars(env, jname, NULL) : NULL;
result = ms_factory_filter_from_name_enabled(ms_factory_get_fallback(),mime);
(*env)->ReleaseStringUTFChars(env, jname, mime);
return result;
}
......
......@@ -34,8 +34,8 @@
#undef PACKAGE_TARNAME
#undef PACKAGE_VERSION
#if defined(ANDROID) || defined(MS2_WINDOWS_PHONE)
// Android and Windows phone don't use make install
#if defined(MS2_WINDOWS_PHONE)
// Windows phone doesn't use make install
#include <srtp.h>
//#include <srtp_priv.h>
#else
......
......@@ -40,7 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "private.h"
#ifdef ANDROID
#include "audiofilters/devices.h"
#include "mediastreamer2/devices.h"
#endif
#include <sys/types.h>
......
......@@ -54,7 +54,7 @@ static int32_t premult_ug[256];
static int32_t premult_ub[256];
static bool_t premult_initd=FALSE;
static void init_premults(){
static void init_premults(void){
int i;
for(i=0;i<256;++i){
premult_y[i]=(i-16)*9535;
......@@ -182,10 +182,10 @@ void img_ycrcb420p_to_bgra(uint8_t* src[],unsigned short w,unsigned short h, uin