Commit 55271ff6 authored by Pierre-Eric Pelloux-Prayer's avatar Pierre-Eric Pelloux-Prayer
Browse files

Update coreapi to improve Android app

parent 0ce2d7cd
/*
linphone
Copyright (C) 2010 Belledonne Communications SARL
Copyright (C) 2010 Belledonne Communications SARL
(simon.morlat@linphone.org)
This program is free software; you can redistribute it and/or
......@@ -165,14 +165,14 @@ static SalMediaDescription *_create_local_media_description(LinphoneCore *lc, Li
LinphoneAddress *addr=linphone_address_new(me);
const char *username=linphone_address_get_username (addr);
SalMediaDescription *md=sal_media_description_new();
md->session_id=session_id;
md->session_ver=session_ver;
md->nstreams=1;
strncpy(md->addr,call->localip,sizeof(md->addr));
strncpy(md->username,username,sizeof(md->username));
md->bandwidth=linphone_core_get_download_bandwidth(lc);
/*set audio capabilities */
strncpy(md->streams[0].addr,call->localip,sizeof(md->streams[0].addr));
md->streams[0].port=call->audio_port;
......@@ -183,7 +183,7 @@ static SalMediaDescription *_create_local_media_description(LinphoneCore *lc, Li
pt=payload_type_clone(rtp_profile_get_payload_from_mime(&av_profile,"telephone-event"));
l=ms_list_append(l,pt);
md->streams[0].payloads=l;
if (call->params.has_video){
md->nstreams++;
......@@ -250,7 +250,7 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from,
if (port_offset==-1) return;
call->audio_port=linphone_core_get_audio_port(call->core)+port_offset;
call->video_port=linphone_core_get_video_port(call->core)+port_offset;
}
static void discover_mtu(LinphoneCore *lc, const char *remote){
......@@ -306,7 +306,7 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
sal_ping(call->ping_op,linphone_core_find_best_identity(lc,from,NULL),from_str);
ms_free(from_str);
}
linphone_address_clean(from);
linphone_core_get_local_ip(lc,linphone_address_get_domain(from),call->localip);
linphone_call_init_common(call, from, to);
......@@ -327,13 +327,13 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
static void linphone_call_set_terminated(LinphoneCall *call){
LinphoneCore *lc=call->core;
linphone_core_update_allocated_audio_bandwidth(lc);
call->owns_call_log=FALSE;
linphone_call_log_completed(call);
if (call == lc->current_call){
ms_message("Resetting the current call");
lc->current_call=NULL;
......@@ -342,10 +342,10 @@ static void linphone_call_set_terminated(LinphoneCall *call){
if (linphone_core_del_call(lc,call) != 0){
ms_error("Could not remove the call from the list !!!");
}
if (ms_list_size(lc->calls)==0)
linphone_core_notify_all_friends(lc,lc->presence_mode);
}
const char *linphone_call_state_to_string(LinphoneCallState cs){
......@@ -419,7 +419,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
if (cstate == LinphoneCallConnected) {
call->log->status=LinphoneCallSuccess;
}
if (lc->vtable.call_state_changed)
lc->vtable.call_state_changed(lc,call,cstate,message);
if (cstate==LinphoneCallReleased){
......@@ -588,7 +588,7 @@ const char *linphone_call_get_remote_user_agent(LinphoneCall *call){
* executed yet.
* Pending transfers are executed when this call is being paused or closed,
* locally or by remote endpoint.
* If the call is already paused while receiving the transfer request, the
* If the call is already paused while receiving the transfer request, the
* transfer immediately occurs.
**/
bool_t linphone_call_has_transfer_pending(const LinphoneCall *call){
......@@ -746,7 +746,7 @@ void linphone_call_init_media_streams(LinphoneCall *call){
LinphoneCore *lc=call->core;
SalMediaDescription *md=call->localdesc;
AudioStream *audiostream;
call->audiostream=audiostream=audio_stream_new(md->streams[0].port,linphone_core_ipv6_enabled(lc));
if (linphone_core_echo_limiter_enabled(lc)){
const char *type=lp_config_get_string(lc->config,"sound","el_type","mic");
......@@ -772,7 +772,7 @@ void linphone_call_init_media_streams(LinphoneCall *call){
int enabled=lp_config_get_int(lc->config,"sound","noisegate",0);
audio_stream_enable_noise_gate(audiostream,enabled);
}
if (lc->a_rtp)
rtp_session_set_transports(audiostream->session,lc->a_rtp,lc->a_rtcp);
......@@ -844,10 +844,10 @@ static void post_configure_audio_streams(LinphoneCall*call){
float ng_thres=lp_config_get_float(lc->config,"sound","ng_thres",0.05);
float ng_floorgain=lp_config_get_float(lc->config,"sound","ng_floorgain",0);
int dc_removal=lp_config_get_int(lc->config,"sound","dc_removal",0);
if (!call->audio_muted)
audio_stream_set_mic_gain(st,mic_gain);
else
else
audio_stream_set_mic_gain(st,0);
recv_gain = lc->sound_conf.soft_play_lev;
......@@ -900,11 +900,11 @@ static RtpProfile *make_profile(LinphoneCall *call, const SalMediaDescription *m
LinphoneCore *lc=call->core;
int up_ptime=0;
*used_pt=-1;
for(elem=desc->payloads;elem!=NULL;elem=elem->next){
PayloadType *pt=(PayloadType*)elem->data;
int number;
if ((pt->flags & PAYLOAD_TYPE_FLAG_CAN_SEND) && first) {
if (desc->type==SalAudio){
linphone_core_update_allocated_audio_bandwidth_in_call(call,pt);
......@@ -921,8 +921,8 @@ static RtpProfile *make_profile(LinphoneCall *call, const SalMediaDescription *m
remote_bw=get_video_bandwidth(remote_bw,call->audio_bw);
}
}
if (desc->type==SalAudio){
if (desc->type==SalAudio){
bw=get_min_bandwidth(call->audio_bw,remote_bw);
}else bw=get_min_bandwidth(get_video_bandwidth(linphone_core_get_upload_bandwidth (lc),call->audio_bw),remote_bw);
if (bw>0) pt->normal_bitrate=bw*1000;
......@@ -965,7 +965,7 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut
SalProtoRtpAvp,SalVideo);
#endif
bool_t use_arc=linphone_core_adaptive_rate_control_enabled(lc);
if(call->audiostream == NULL)
{
ms_fatal("start_media_stream() called without prior init !");
......@@ -982,7 +982,7 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut
const SalStreamDescription *stream=sal_media_description_find_stream(call->resultdesc,
SalProtoRtpAvp,SalAudio);
if (stream && stream->dir!=SalStreamInactive && stream->port!=0){
MSSndCard *playcard=lc->sound_conf.lsd_card ?
MSSndCard *playcard=lc->sound_conf.lsd_card ?
lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard;
MSSndCard *captcard=lc->sound_conf.capt_sndcard;
const char *playfile=lc->play_file;
......@@ -1061,7 +1061,7 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut
}
#ifdef VIDEO_ENABLED
{
used_pt=-1;
/* shutdown preview */
if (lc->previewstream!=NULL) {
......@@ -1078,7 +1078,7 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut
bool_t is_inactive=FALSE;
call->current_params.has_video=TRUE;
video_stream_set_sent_video_size(call->videostream,linphone_core_get_preferred_video_size(lc));
video_stream_enable_self_view(call->videostream,lc->video_conf.selfview);
if (lc->video_window_id!=0)
......@@ -1086,7 +1086,7 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut
if (lc->preview_window_id!=0)
video_stream_set_native_preview_window_id (call->videostream,lc->preview_window_id);
video_stream_use_preview_video_window (call->videostream,lc->use_preview_window);
if (vstream->dir==SalStreamSendOnly && lc->video_conf.capture ){
cam=get_nowebcam_device();
dir=VideoStreamSendOnly;
......@@ -1109,6 +1109,8 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut
}
if (!is_inactive){
video_stream_set_direction (call->videostream, dir);
ms_message("%s lc rotation:%d\n", __FUNCTION__, lc->device_rotation);
video_stream_set_device_rotation(call->videostream, lc->device_rotation);
video_stream_start(call->videostream,
call->video_profile, addr, vstream->port,
vstream->port+1,
......@@ -1124,7 +1126,7 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut
call->all_muted=all_inputs_muted;
call->playing_ringbacktone=send_ringbacktone;
call->up_bw=linphone_core_get_upload_bandwidth(lc);
if (ortp_zrtp_available()) {
OrtpZrtpParams params;
params.zid=get_hexa_zrtp_identifier(lc);
......@@ -1172,7 +1174,7 @@ void linphone_call_stop_media_streams(LinphoneCall *call){
call->videostream=NULL;
}
ms_event_queue_skip(call->core->msevq);
#endif
if (call->audio_profile){
rtp_profile_clear_all(call->audio_profile);
......@@ -1229,11 +1231,11 @@ bool_t linphone_call_echo_limiter_enabled(const LinphoneCall *call){
/**
* @addtogroup call_misc
* @{
**/
**/
/**
* Returns the measured sound volume played locally (received from remote)
* It is expressed in dbm0.
* It is expressed in dbm0.
**/
float linphone_call_get_play_volume(LinphoneCall *call){
AudioStream *st=call->audiostream;
......@@ -1241,14 +1243,14 @@ float linphone_call_get_play_volume(LinphoneCall *call){
float vol=0;
ms_filter_call_method(st->volsend,MS_VOLUME_GET,&vol);
return vol;
}
return LINPHONE_VOLUME_DB_LOWEST;
}
/**
* Returns the measured sound volume recorded locally (sent to remote)
* It is expressed in dbm0.
* It is expressed in dbm0.
**/
float linphone_call_get_record_volume(LinphoneCall *call){
AudioStream *st=call->audiostream;
......@@ -1256,7 +1258,7 @@ float linphone_call_get_record_volume(LinphoneCall *call){
float vol=0;
ms_filter_call_method(st->volrecv,MS_VOLUME_GET,&vol);
return vol;
}
return LINPHONE_VOLUME_DB_LOWEST;
}
......@@ -1275,7 +1277,7 @@ float linphone_call_get_record_volume(LinphoneCall *call){
* 1-2 = very poor quality <br>
* 0-1 = can't be worse, mostly unusable <br>
*
* @returns The function returns -1 if no quality measurement is available, for example if no
* @returns The function returns -1 if no quality measurement is available, for example if no
* active audio stream exist. Otherwise it returns the quality rating.
**/
float linphone_call_get_current_quality(LinphoneCall *call){
......@@ -1318,7 +1320,7 @@ static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){
{
snprintf(temp,sizeof(temp),"Remote end %s seems to have disconnected, the call is going to be closed.",from);
free(from);
}
}
else
{
snprintf(temp,sizeof(temp),"Remote end seems to have disconnected, the call is going to be closed.");
......@@ -1331,7 +1333,7 @@ static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){
void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapsed){
int disconnect_timeout = linphone_core_get_nortp_timeout(call->core);
bool_t disconnected=FALSE;
if (call->state==LinphoneCallStreamsRunning && one_second_elapsed){
RtpSession *as=NULL,*vs=NULL;
float audio_load=0, video_load=0;
......@@ -1395,9 +1397,9 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
void linphone_call_log_completed(LinphoneCall *call){
LinphoneCore *lc=call->core;
call->log->duration=time(NULL)-call->start_time;
if (call->log->status==LinphoneCallMissed){
char *info;
lc->missed_calls++;
......@@ -1424,5 +1426,3 @@ void linphone_call_log_completed(LinphoneCall *call){
}
call_logs_write_to_config_file(lc);
}
This diff is collapsed.
......@@ -68,7 +68,7 @@ typedef struct _LCSipTransports LCSipTransports;
* The LinphoneAddress has methods to extract and manipulate all parts of the address.
* When some part of the address (for example the username) is empty, the accessor methods
* return NULL.
*
*
* @ingroup linphone_address
* @var LinphoneAddress
*/
......@@ -128,7 +128,7 @@ typedef enum _LinphoneCallDir LinphoneCallDir;
* Enum representing the status of a call
* @ingroup call_logs
**/
typedef enum _LinphoneCallStatus {
typedef enum _LinphoneCallStatus {
LinphoneCallSuccess, /**< The call was sucessful*/
LinphoneCallAborted, /**< The call was aborted */
LinphoneCallMissed, /**< The call was missed (unanswered)*/
......@@ -139,7 +139,7 @@ typedef enum _LinphoneCallStatus {
* Structure representing a call log.
*
* @ingroup call_logs
*
*
**/
typedef struct _LinphoneCallLog{
LinphoneCallDir dir; /**< The direction of the call*/
......@@ -170,7 +170,7 @@ char * linphone_call_log_to_str(LinphoneCallLog *cl);
/**
* The LinphoneCallParams is an object containing various call related parameters.
* It can be used to retrieve parameters from a currently running call or modify the call's characteristics
* It can be used to retrieve parameters from a currently running call or modify the call's characteristics
* dynamically.
**/
struct _LinphoneCallParams;
......@@ -430,15 +430,15 @@ struct _LinphoneAuthInfo;
* different SIP domains.
*
* Once created and filled, a LinphoneAuthInfo must be added to the LinphoneCore in
* order to become known and used automatically when needed.
* order to become known and used automatically when needed.
* Use linphone_core_add_auth_info() for that purpose.
*
* The LinphoneCore object can take the initiative to request authentication information
* when needed to the application through the auth_info_requested callback of the
* LinphoneCoreVTable structure.
*
* The application can respond to this information request later using
* linphone_core_add_auth_info(). This will unblock all pending authentication
* The application can respond to this information request later using
* linphone_core_add_auth_info(). This will unblock all pending authentication
* transactions and retry them with authentication headers.
*
**/
......@@ -833,7 +833,7 @@ const char * linphone_core_get_relay_addr(const LinphoneCore *lc);
int linphone_core_set_relay_addr(LinphoneCore *lc, const char *addr);
/* sound functions */
/* returns a null terminated static array of string describing the sound devices */
/* returns a null terminated static array of string describing the sound devices */
const char** linphone_core_get_sound_devices(LinphoneCore *lc);
bool_t linphone_core_sound_device_can_capture(LinphoneCore *lc, const char *device);
bool_t linphone_core_sound_device_can_playback(LinphoneCore *lc, const char *device);
......@@ -914,7 +914,7 @@ void linphone_core_enable_self_view(LinphoneCore *lc, bool_t val);
bool_t linphone_core_self_view_enabled(const LinphoneCore *lc);
/* returns a null terminated static array of string describing the webcams */
/* returns a null terminated static array of string describing the webcams */
const char** linphone_core_get_video_devices(const LinphoneCore *lc);
int linphone_core_set_video_device(LinphoneCore *lc, const char *id);
const char *linphone_core_get_video_device(const LinphoneCore *lc);
......@@ -934,6 +934,7 @@ unsigned long linphone_core_get_native_preview_window_id(const LinphoneCore *lc)
void linphone_core_set_native_preview_window_id(LinphoneCore *lc, unsigned long id);
void linphone_core_use_preview_window(LinphoneCore *lc, bool_t yesno);
void linphone_core_set_device_rotation(LinphoneCore *lc, int rotation);
/*play/record support: use files instead of soundcard*/
void linphone_core_use_files(LinphoneCore *lc, bool_t yesno);
......@@ -1011,7 +1012,7 @@ LinphoneGlobalState linphone_core_get_global_state(const LinphoneCore *lc);
* force registration refresh to be initiated upon next iterate
* @ingroup proxies
*/
void linphone_core_refresh_registers(LinphoneCore* lc);
void linphone_core_refresh_registers(LinphoneCore* lc);
void linphone_call_send_vfu_request(LinphoneCall *call);
......
......@@ -20,8 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "linphonecore_utils.h"
#include <ortp/zrtp.h>
extern "C" {
#include "mediastreamer2/mediastream.h"
}
#include "mediastreamer2/msjava.h"
#include "private.h"
#include <cpu-features.h>
#ifdef ANDROID
......@@ -1164,6 +1167,20 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv*
linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
,jobject thiz
,jlong lc
,jobject obj) {
linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
,jobject thiz
,jlong lc
,jint rotation) {
linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
......@@ -1267,7 +1284,7 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv
extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
linphone_call_get_duration((LinphoneCall *) ptr);
}
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
LCSipTransports tr;
linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
......@@ -1289,7 +1306,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPor
tr.udp_port = udp;
tr.tcp_port = tcp;
tr.tls_port = tls;
linphone_core_set_sip_transports(lc, &tr); // tr will be copied
}
......@@ -1334,6 +1351,25 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIE
}
}
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
LinphoneCore* lc = (LinphoneCore *) pCore;
const char** devices = linphone_core_get_video_devices(lc);
if (devices == NULL) {
ms_error("No existing video devices\n");
return -1;
}
int i;
for(i=0; i<=id; i++) {
if (devices[i] == NULL)
break;
ms_message("Existing device %d : %s\n", i, devices[i]);
if (i==id) {
return linphone_core_set_video_device(lc, devices[i]);
}
}
return -1;
}
extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
LinphoneCall *call = (LinphoneCall *) ptr;
const char* token = linphone_call_get_authentication_token(call);
......@@ -1356,4 +1392,3 @@ extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,
msandroid_hack_speaker_state(speakerOn);
// End Galaxy S hack functions
}
......@@ -21,7 +21,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _PRIVATE_H
#define _PRIVATE_H
......@@ -34,11 +34,11 @@
#endif
#include "mediastreamer2/mediastream.h"
#ifndef LIBLINPHONE_VERSION
#ifndef LIBLINPHONE_VERSION
#define LIBLINPHONE_VERSION LINPHONE_VERSION
#endif
#ifndef PACKAGE_SOUND_DIR
#ifndef PACKAGE_SOUND_DIR
#define PACKAGE_SOUND_DIR "."
#endif
......@@ -247,7 +247,7 @@ struct _LinphoneProxyConfig
LinphoneReason error;
};
struct _LinphoneAuthInfo
struct _LinphoneAuthInfo
{
char *username;
char *realm;
......@@ -280,7 +280,7 @@ struct _LinphoneFriend{
bool_t subscribe_active;
bool_t inc_subscribe_pending;
bool_t commit;
};
};
typedef struct sip_config
......@@ -310,7 +310,7 @@ typedef struct rtp_config
int audio_jitt_comp; /*jitter compensation*/
int video_jitt_comp; /*jitter compensation*/
int nortp_timeout;
bool_t rtp_no_xmit_on_audio_mute;
bool_t rtp_no_xmit_on_audio_mute;
/* stop rtp xmit when audio muted */
}rtp_config_t;
......@@ -447,6 +447,7 @@ struct _LinphoneCore
bool_t auto_net_state_mon;
bool_t network_reachable;
bool_t use_preview_window;
int device_rotation;
bool_t ringstream_autorelease;
char* zrtp_secrets_cache;
};
......
......@@ -39,7 +39,7 @@ public interface LinphoneCall {
*/
IncomingReceived(1, "IncomingReceived"),
/**
* Outgoing call initialiazed.
* Outgoing call initialized.
*/
OutgoingInit(2, "OutgoingInit"),
/**
......
......@@ -474,6 +474,10 @@ public interface LinphoneCore {
void setVideoWindow(Object w);
void setPreviewWindow(Object w);
void setDeviceRotation(int rotation);
void setVideoDevice(int id);
/**
* Enables video globally.
*
......
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