Fixed #1956: Support for setting audio input source capability in Android JNI audio device

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@5426 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Sauw Ming 2016-08-23 09:13:28 +00:00
parent e8f460ff83
commit f69b5d2fdd
2 changed files with 37 additions and 12 deletions

View File

@ -181,10 +181,11 @@ typedef enum pjmedia_aud_dev_cap
PJMEDIA_AUD_DEV_CAP_OUTPUT_SIGNAL_METER = 64,
/**
* Support for audio input routing. The value of this capability is an
* integer containing #pjmedia_aud_dev_route enumeration.
* Support for audio input routing/source. The value of this capability
* is an integer containing #pjmedia_aud_dev_route enumeration.
*/
PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE = 128,
PJMEDIA_AUD_DEV_CAP_INPUT_SOURCE = 128,
/**
* Support for audio output routing (e.g. loudspeaker vs earpiece). The
@ -236,14 +237,15 @@ typedef enum pjmedia_aud_dev_cap
/**
* This enumeration describes audio routing setting.
* This enumeration describes audio routing/source setting.
*/
typedef enum pjmedia_aud_dev_route
{
/**
* Default route, it is the default audio route of the audio framework
* backend, as in opening audio device without specifying any route
* setting or with specifying neutral route setting.
* Default route/source, it is the default audio route/source of
* the audio framework backend, as in opening audio device without
* specifying any route/source setting or with specifying neutral
* route/source setting.
*/
PJMEDIA_AUD_DEV_ROUTE_DEFAULT = 0,
@ -254,7 +256,21 @@ typedef enum pjmedia_aud_dev_route
PJMEDIA_AUD_DEV_ROUTE_EARPIECE = 2,
/** Route to paired Bluetooth device */
PJMEDIA_AUD_DEV_ROUTE_BLUETOOTH = 4
PJMEDIA_AUD_DEV_ROUTE_BLUETOOTH = 4,
/**
* Custom audio route/source, specific to each audio device
* backend.
*
* For Android JNI audio device, the default is
* VOICE_COMMUNICATION (7). To change it to another value, set
* the input source capability of pjmedia_aud_param accordingly.
* For example:
* pjmedia_aud_param_set_cap(&param, PJMEDIA_AUD_DEV_CAP_INPUT_SOURCE,
* // 4 is VOICE_CALL
* PJMEDIA_AUD_DEV_ROUTE_CUSTOM | 4);
*/
PJMEDIA_AUD_DEV_ROUTE_CUSTOM = 128
} pjmedia_aud_dev_route;
@ -299,9 +315,9 @@ typedef struct pjmedia_aud_dev_info
unsigned caps;
/**
* Supported audio device routes, as bitmask combination of
* Supported audio device routes/sources, as bitmask combination of
* #pjmedia_aud_dev_route. The value may be zero if the device
* does not support audio routing.
* does not support changing audio routes/sources.
*/
unsigned routes;
@ -435,8 +451,9 @@ typedef struct pjmedia_aud_param
unsigned output_vol;
/**
* Set the audio input route. This setting is optional, and will only be
* used if PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE is set in the flags.
* Set the audio input route/source. This setting is optional, and
* will only be used if PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE/
* PJMEDIA_AUD_DEV_CAP_INPUT_SOURCE is set in the flags.
*/
pjmedia_aud_dev_route input_route;

View File

@ -483,9 +483,11 @@ static pj_status_t android_get_dev_info(pjmedia_aud_dev_factory *f,
pj_ansi_strcpy(info->name, "Android JNI");
info->default_samples_per_sec = 8000;
info->caps = PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING;
info->caps = PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING |
PJMEDIA_AUD_DEV_CAP_INPUT_SOURCE;
info->input_count = 1;
info->output_count = 1;
info->routes = PJMEDIA_AUD_DEV_ROUTE_CUSTOM;
return PJ_SUCCESS;
}
@ -666,6 +668,12 @@ static pj_status_t android_create_stream(pjmedia_aud_dev_factory *f,
jobject record_obj;
int mic_source = 0; /* DEFAULT: default audio source */
if ((param->flags & PJMEDIA_AUD_DEV_CAP_INPUT_SOURCE) &&
(param->input_route & PJMEDIA_AUD_DEV_ROUTE_CUSTOM))
{
mic_source = param->input_route & ~PJMEDIA_AUD_DEV_ROUTE_CUSTOM;
}
/* Get pointer to the constructor */
constructor_method = (*jni_env)->GetMethodID(jni_env,
stream->record_class,