Commit 8ac3702d authored by DanmeiChen's avatar DanmeiChen

set speaker on for special devicces

parent d9eef5ff
......@@ -33,6 +33,7 @@
#define DEVICE_HAS_UNSTANDARD_LIBMEDIA (1<<6) /*set when the libmedia backend shall not be used because of proprietary modifications made into it by the manufacturer*/
#define DEVICE_HAS_CRAPPY_OPENGL (1<<7) /*set when the opengl is crappy and our opengl surfaceview will crash */
#define DEVICE_HAS_CRAPPY_OPENSLES (1<<8) /*set when the opensles latency is crappy*/
#define DEVICE_USE_ANDROID_CAMCORDER (1<<9) /*set when the device needs to capture using CAMCORDER instead of Voice communication (I.E kindle fire) */
struct SoundDeviceAudioHacks {
const char *mic_equalizer;
......
......@@ -35,6 +35,10 @@ public class Factory{
public void setDeviceInfo(String manufacturer, String model, String platform, int flags, int delay, int recommended_rate) {
setDeviceInfo(mNativePtr, manufacturer, model, platform, flags, delay, recommended_rate);
}
private native int getDeviceFlags(long nativePtr);
public int getDeviceFlags() {
return getDeviceFlags(mNativePtr);
}
private native String getEncoderText(long nativePtr, String mime);
public String getEncoderText(String mime){
return getEncoderText(mNativePtr, mime);
......
......@@ -30,6 +30,7 @@ public class MediastreamerAndroidContext {
public static final int DEVICE_HAS_BUILTIN_AEC_CRAPPY = 2; // The device has the API to tell us it has a builtin AEC but we shouldn't trust it (so we'll use software AEC)
public static final int DEVICE_USE_ANDROID_MIC = 4;
public static final int DEVICE_HAS_BUILTIN_OPENSLES_AEC = 8; // The device has a builtin AEC and it is working with OpenSLES (which is uncommon)
public static final int DEVICE_USE_ANDROID_CAMCORDER = 512;
private native void setDeviceFavoriteSampleRate(int samplerate);
private native void setDeviceFavoriteBufferSize(int bufferSize);
......@@ -52,7 +53,7 @@ public class MediastreamerAndroidContext {
}
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void setContext(Object c) {
public static void setContext(Object c, org.linphone.mediastream.Factory factory) {
if (c == null)
return;
......@@ -69,6 +70,11 @@ public class MediastreamerAndroidContext {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
{
AudioManager audiomanager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
//setSpeakerphoneOn for special device to enable choose the audio input source
if((factory.getDeviceFlags() & DEVICE_USE_ANDROID_CAMCORDER)!=0) {
audiomanager.setSpeakerphoneOn(true);
}
String bufferProperty = audiomanager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
bufferSize = parseInt(bufferProperty, bufferSize);
String sampleRateProperty = audiomanager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
......
......@@ -199,8 +199,8 @@ static SoundDeviceDescription devices[]={
{ "WIKO", "HIGHWAY 4G", "tegra", DEVICE_HAS_UNSTANDARD_LIBMEDIA, 0 },
{ "Symphony", "HIGHWAY 4G", "", DEVICE_HAS_UNSTANDARD_LIBMEDIA, 0 },
{ "rockchip", "rk3288_box", "rk3288", 0, 0, 16000},
{ "rockchip", "X9-LX", "rk3288", 0, 0, 16000},
{ "rockchip", "rk3288_box", "rk3288", DEVICE_USE_ANDROID_CAMCORDER, 0, 16000},
{ "rockchip", "X9-LX", "rk3288", DEVICE_USE_ANDROID_CAMCORDER, 0, 16000},
{ NULL, NULL, NULL, 0, 0, 0}
};
......
......@@ -22,25 +22,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <mediastreamer2/msfactory.h>
#include <mediastreamer2/devices.h>
static const char* GetStringUTFChars(JNIEnv* env, jstring string) {
extern "C" {
static const char *GetStringUTFChars(JNIEnv *env, jstring string) {
const char *cstring = string ? env->GetStringUTFChars(string, NULL) : NULL;
return cstring;
}
static void ReleaseStringUTFChars(JNIEnv* env, jstring string, const char *cstring) {
static void ReleaseStringUTFChars(JNIEnv *env, jstring string, const char *cstring) {
if (string) env->ReleaseStringUTFChars(string, cstring);
}
JNIEXPORT void JNICALL Java_org_linphone_mediastream_Factory_setDeviceInfo(JNIEnv* env, jobject obj,
jlong factoryPtr, jstring jmanufacturer, jstring jmodel, jstring jplatform, jint flags, jint delay, jint recommended_rate) {
const char *manufacturer = GetStringUTFChars(env, jmanufacturer);
const char *model = GetStringUTFChars(env, jmodel);
const char *platform = GetStringUTFChars(env, jplatform);
JNIEXPORT void JNICALL Java_org_linphone_mediastream_Factory_setDeviceInfo(JNIEnv *env, jobject obj,
jlong factoryPtr, jstring jmanufacturer, jstring jmodel, jstring jplatform, jint flags, jint delay, jint recommended_rate) {
const char *manufacturer = GetStringUTFChars(env, jmanufacturer);
const char *model = GetStringUTFChars(env, jmodel);
const char *platform = GetStringUTFChars(env, jplatform);
ms_message("Device infos: [%s,%s,%s], Flags: %d, Delay: %d, Rate: %d", manufacturer, model, platform, flags, delay, recommended_rate);
ms_devices_info_add(((MSFactory *) factoryPtr)->devices_info, manufacturer, model, platform, flags, delay, recommended_rate);
ms_message("Device infos: [%s,%s,%s], Flags: %d, Delay: %d, Rate: %d",manufacturer,model,platform,flags,delay,recommended_rate);
ms_devices_info_add(((MSFactory *) factoryPtr)->devices_info, manufacturer, model, platform, flags, delay, recommended_rate);
ReleaseStringUTFChars(env, jmanufacturer, manufacturer);
ReleaseStringUTFChars(env, jmodel, model);
ReleaseStringUTFChars(env, jplatform, platform);
}
ReleaseStringUTFChars(env, jmanufacturer, manufacturer);
ReleaseStringUTFChars(env, jmodel, model);
ReleaseStringUTFChars(env, jplatform, platform);
JNIEXPORT jint JNICALL Java_org_linphone_mediastream_Factory_getDeviceFlags(JNIEnv *env, jobject obj, jlong factoryPtr) {
return ms_devices_info_get_sound_device_description(((MSFactory *) factoryPtr)->devices_info)->flags;
}
} // extern "C"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment