...
 
Commits (13)
......@@ -348,6 +348,7 @@ LinphoneAuthInfo *linphone_auth_info_new_from_config_file(LpConfig * config, int
ret = linphone_auth_info_new(username, userid, passwd, ha1, realm, domain);
linphone_auth_info_set_tls_cert_path(ret, tls_cert_path);
linphone_auth_info_set_tls_key_path(ret, tls_key_path);
linphone_auth_info_set_algorithm(ret, lp_config_get_string(config, key, "algorithm", "MD5"));
return ret;
}
......
......@@ -477,6 +477,7 @@ static void sdp_parse_payload_types(belle_sdp_media_description_t *media_desc, S
payload_type_set_avpf_params(pt, avpf_params);
stream->payloads=bctbx_list_append ( stream->payloads,pt );
stream->ptime=belle_sdp_mime_parameter_get_ptime ( mime_param );
stream->maxptime=belle_sdp_mime_parameter_get_max_ptime ( mime_param );
ms_message ( "Found payload %s/%i fmtp=%s",pt->mime_type,pt->clock_rate,
pt->send_fmtp ? pt->send_fmtp : "" );
}
......
......@@ -18,6 +18,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <sstream>
#include "linphone/api/c-content.h"
#include "linphone/core_utils.h"
#include "linphone/core.h"
......@@ -3058,11 +3060,11 @@ static char _ua_name[64]="Linphone";
static char _ua_version[64]=LIBLINPHONE_VERSION;
void linphone_core_set_user_agent(LinphoneCore *lc, const char *name, const char *ver){
char ua_string[256];
snprintf(ua_string, sizeof(ua_string) - 1, "%s/%s", name?name:"", ver?ver:"");
ostringstream ua_string;
ua_string << (name ? name : "");
if (ver) ua_string << "/" << ver;
if (lc->sal) {
lc->sal->setUserAgent(ua_string);
lc->sal->appendStackStringToUserAgent();
lc->sal->setUserAgent(ua_string.str());
}
}
const char *linphone_core_get_user_agent(LinphoneCore *lc){
......
......@@ -420,6 +420,7 @@ static void initiate_outgoing(MSFactory* factory, const SalStreamDescription *lo
result->rtcp_port=remote_answer->rtcp_port;
result->bandwidth=remote_answer->bandwidth;
result->ptime=remote_answer->ptime;
result->maxptime=remote_answer->maxptime;
}else{
result->rtp_port=0;
}
......@@ -475,6 +476,7 @@ static void initiate_incoming(MSFactory *factory, const SalStreamDescription *lo
result->rtcp_port=0; /* rtcp not supported yet*/
result->bandwidth=remote_offer->bandwidth;
result->ptime=remote_offer->ptime;
result->maxptime=remote_offer->maxptime;
result->ttl=remote_offer->ttl;
result->multicast_role = SalMulticastReceiver;
} else {
......@@ -484,6 +486,7 @@ static void initiate_incoming(MSFactory *factory, const SalStreamDescription *lo
result->rtcp_port=local_cap->rtcp_port;
result->bandwidth=local_cap->bandwidth;
result->ptime=local_cap->ptime;
result->maxptime=local_cap->maxptime;
}
if (sal_stream_description_has_srtp(result) == TRUE) {
......
......@@ -1093,10 +1093,15 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_remove_listener(LinphoneC
LINPHONE_PUBLIC void linphone_core_remove_callbacks(LinphoneCore *lc, const LinphoneCoreCbs *cbs);
/**
* Sets the user agent string used in SIP messages, ideally called just after linphone_core_new() or linphone_core_init().
* @param[in] lc #LinphoneCore object
* @param[in] ua_name The user agent name
* @param[in] version The user agent version
* @brief Set the user agent string used in SIP messages.
*
* Set the user agent string used in SIP messages as "[ua_name]/[version]". No slash character will be printed if NULL is given to "version".
* If NULL is given to "ua_name" and "version" both, the User-agent header will be empty.
*
* This function should be called just after linphone_factory_create_core() ideally.
* @param[in] lc The core.
* @param[in] ua_name Name of the user agent.
* @param[in] version Version of the user agent.
* @ingroup misc
**/
LINPHONE_PUBLIC void linphone_core_set_user_agent(LinphoneCore *lc, const char *ua_name, const char *version);
......
......@@ -259,6 +259,7 @@ typedef struct SalStreamDescription{
MSList *already_assigned_payloads; /**<list of PayloadType offered in the past, used for correct allocation of payload type numbers*/
int bandwidth;
int ptime;
int maxptime;
SalStreamDir dir;
SalSrtpCryptoAlgo crypto[SAL_CRYPTO_ALGO_MAX];
unsigned int crypto_local_tag;
......
......@@ -2080,6 +2080,11 @@ RtpProfile * MediaSessionPrivate::makeProfile (const SalMediaDescription *md, co
pt->normal_bitrate = PayloadTypeHandler::getMinBandwidth(pt->normal_bitrate, bandwidth * 1000);
} else
pt->normal_bitrate = bandwidth * 1000;
if (desc->maxptime > 0) {// follow the same schema for maxptime as for ptime. (I.E add it to fmtp)
ostringstream os;
os << "maxptime=" << desc->maxptime;
payload_type_append_send_fmtp(pt, os.str().c_str());
}
if (desc->ptime > 0)
upPtime = desc->ptime;
if (upPtime > 0) {
......
......@@ -95,7 +95,7 @@ void CorePrivate::iterateCalls (time_t currentRealTime, bool oneSecondElapsed) c
void CorePrivate::notifySoundcardUsage (bool used) {
L_Q();
MSSndCard *card = q->getCCore()->sound_conf.capt_sndcard;
if (card && (ms_snd_card_get_capabilities(card) & MS_SND_CARD_CAP_IS_SLOW))
if (!!lp_config_get_int(linphone_core_get_config(q->getCCore()),"sound","usage_hint",1) && card && (ms_snd_card_get_capabilities(card) & MS_SND_CARD_CAP_IS_SLOW))
ms_snd_card_set_usage_hint(card, used);
}
......
......@@ -225,6 +225,15 @@ void Core::enterBackground () {
void Core::enterForeground () {
L_D();
d->notifyEnteringForeground();
LinphoneProxyConfig *proxy_config = linphone_core_get_default_proxy_config(getCCore());
if (proxy_config) {
LinphoneRegistrationState state = linphone_proxy_config_get_state(proxy_config);
if (state == LinphoneRegistrationState::LinphoneRegistrationFailed) {
lWarning() << "Default proxy config state is failed when entering foreground, refreshing registers";
linphone_core_refresh_registers(getCCore());
}
}
}
bool Core::isInBackground () {
......
......@@ -255,7 +255,7 @@ void AndroidPlatformHelpers::setVideoPreviewWindow (void *windowId) {
JNIEnv *env = ms_get_jni_env();
if (env && mJavaHelper) {
string displayFilter = L_C_TO_STRING(linphone_core_get_video_display_filter(getCore()->getCCore()));
if (windowId && (displayFilter.empty() || displayFilter == "MSAndroidTextureDisplay")) {
if ((displayFilter.empty() || displayFilter == "MSAndroidTextureDisplay")) {
env->CallVoidMethod(mJavaHelper, mSetNativePreviewVideoWindowId, (jobject)windowId);
} else {
_setPreviewVideoWindow((jobject)windowId);
......@@ -267,7 +267,7 @@ void AndroidPlatformHelpers::setVideoWindow (void *windowId) {
JNIEnv *env = ms_get_jni_env();
if (env && mJavaHelper) {
string displayFilter = L_C_TO_STRING(linphone_core_get_video_display_filter(getCore()->getCCore()));
if (windowId && (displayFilter.empty() || displayFilter == "MSAndroidTextureDisplay")) {
if ((displayFilter.empty() || displayFilter == "MSAndroidTextureDisplay")) {
env->CallVoidMethod(mJavaHelper, mSetNativeVideoWindowId, (jobject)windowId);
} else {
_setVideoWindow((jobject)windowId);
......
......@@ -558,9 +558,8 @@ void IceAgent::createIceCheckListsAndParseIceAttributes (const SalMediaDescripti
if (remoteCandidate->addr[0] == '\0') break;
getIceDefaultAddrAndPort(static_cast<uint16_t>(componentID), md, stream, &addr, &port);
// If we receive a re-invite and we finished ICE processing on our side, use the candidates given by the remote.
if (j == 0)
ice_check_list_unselect_valid_pairs(cl);
// If we receive a re-invite with remote-candidates, supply these pairs to the ice check list.
// They might be valid pairs already selected, or losing pairs.
int remoteFamily = AF_INET;
if (strchr(remoteCandidate->addr, ':'))
......
......@@ -307,6 +307,7 @@ void SalCallOp::sdpProcess () {
if (mResult->streams[i].rtp_port != 0) { // If the stream was accepted
strcpy(mResult->streams[i].rtp_addr, mRemoteMedia->streams[i].rtp_addr);
mResult->streams[i].ptime = mRemoteMedia->streams[i].ptime;
mResult->streams[i].maxptime = mRemoteMedia->streams[i].maxptime;
mResult->streams[i].bandwidth = mRemoteMedia->streams[i].bandwidth;
mResult->streams[i].rtp_port = mRemoteMedia->streams[i].rtp_port;
strcpy(mResult->streams[i].rtcp_addr, mRemoteMedia->streams[i].rtcp_addr);
......
......@@ -163,7 +163,7 @@ char *Utils::utf8ToChar (uint32_t ic) {
result[1] = static_cast<char>(0x80 + ((ic & 0x3F)));
result[0] = static_cast<char>(0xC0 + ((ic >> 6) & 0x1F));
size = 2;
} else if (ic < 0x100000) {
} else if (ic < 0x10000) {
result[2] = static_cast<char>(0x80 + (ic & 0x3F));
result[1] = static_cast<char>(0x80 + ((ic >> 6) & 0x3F));
result[0] = static_cast<char>(0xE0 + ((ic >> 12) & 0xF));
......
......@@ -212,16 +212,22 @@ static void simple_call_with_no_sip_transport(void){
LinphoneCoreManager* marie;
LinphoneCoreManager* pauline;
LinphoneSipTransports tr={0};
LinphoneSipTransports oldTr;
LinphoneCall *call;
marie = linphone_core_manager_new( "marie_rc");
pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
/*disable all transports so that the call will fail synchronously*/
linphone_core_get_sip_transports(marie->lc, &oldTr);
linphone_core_set_sip_transports(marie->lc, &tr);
call = linphone_core_invite_address(marie->lc, pauline->identity);
BC_ASSERT_PTR_NULL(call);
/* restore initial transports for Marie's core in order it be able to unregister */
linphone_core_set_sip_transports(marie->lc, &oldTr);
linphone_core_manager_destroy(pauline);
linphone_core_manager_destroy(marie);
}
......@@ -564,7 +570,53 @@ end:
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void call_with_maxptime(void) {
LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_create(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
bool_t call_ok;
//to make sure bandwidth for ptime 20 is 80kbits/s
linphone_core_enable_ipv6(marie->lc,FALSE);
linphone_core_enable_ipv6(pauline->lc,FALSE);
linphone_core_manager_start(marie, TRUE);
linphone_core_manager_start(pauline, TRUE);
/*Force marie to play from file: if soundcard is used and it is silient, then vbr mode will drop down the bitrate
Note that a play file is already set by linphone_core_manager_new() (but not used)*/
linphone_core_set_use_files(marie->lc, TRUE);
disable_all_audio_codecs_except_one(marie->lc, "PCMA", 8000);
disable_all_audio_codecs_except_one(pauline->lc, "PCMA", 8000);
LinphoneCallParams *marie_params = linphone_core_create_call_params(marie->lc, NULL);
linphone_call_params_add_custom_sdp_media_attribute(marie_params,LinphoneStreamTypeAudio, "maxptime","40");
LinphoneCallParams *pauline_params = linphone_core_create_call_params(marie->lc, NULL);
linphone_call_params_add_custom_sdp_media_attribute(pauline_params,LinphoneStreamTypeAudio, "maxptime","40");
linphone_core_set_upload_ptime(pauline->lc, 100);
linphone_core_set_upload_ptime(marie->lc, 100);
BC_ASSERT_TRUE((call_ok=call_with_params(pauline,marie,pauline_params,marie_params)));
linphone_call_params_unref(marie_params);
linphone_call_params_unref(pauline_params);
if (!call_ok) goto end;
liblinphone_tester_check_rtcp(marie,pauline);
/*wait a bit that bitstreams are stabilized*/
wait_for_until(marie->lc, pauline->lc, NULL, 0, 2000);
//network-birate = ((codec-birate*ptime/8) + RTP header + UDP header + IP header)*8/ptime;
BC_ASSERT_LOWER(linphone_core_manager_get_mean_audio_up_bw(pauline), 80, int, "%i");
BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_up_bw(pauline), 70, int, "%i"); //without maxptime=40, it should be 67
BC_ASSERT_LOWER(linphone_core_manager_get_mean_audio_up_bw(marie), 80, int, "%i");
BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_up_bw(marie), 70, int, "%i"); //without maxptime=40, it should be 67
end_call(pauline, marie);
end:
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
void disable_all_codecs(const bctbx_list_t* elem, LinphoneCoreManager* call){
......@@ -4947,6 +4999,7 @@ test_t call_tests[] = {
TEST_NO_TAG("Call established with rejected info during re-invite", call_established_with_rejected_info_during_reinvite),
TEST_NO_TAG("Call redirected by callee", call_redirect),
TEST_NO_TAG("Call with specified codec bitrate", call_with_specified_codec_bitrate),
TEST_NO_TAG("Call with maxptime", call_with_maxptime),
TEST_NO_TAG("Call with no audio codec", call_with_no_audio_codec),
TEST_NO_TAG("Call with in-dialog UPDATE request", call_with_in_dialog_update),
TEST_NO_TAG("Call with in-dialog very early call request", call_with_very_early_call_update),
......
......@@ -26,7 +26,7 @@ static FILE * log_file = NULL;
static const char* liblinphone_helper =
"\t\t\t--domain <test sip domain>\n"
"\t\t\t--auth-domain <test auth domain>\n"
"\t\t\t--dns-hosts </etc/hosts -like file to used to override DNS names (default: tester_hosts)>\n"
"\t\t\t--dns-hosts </etc/hosts -like file to used to override DNS names or 'none' for no overriding (default: tester_hosts)>\n"
"\t\t\t--keep-recorded-files\n"
"\t\t\t--disable-leak-detector\n"
"\t\t\t--disable-tls-support\n"
......
......@@ -1982,18 +1982,9 @@ static void real_time_text_message_accented_chars(void) {
BC_ASSERT_PTR_NOT_NULL(marie_chat_room);
if (pauline_chat_room && marie_chat_room) {
LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL);
uint32_t message[] = {0xe3/*ã*/, 0xe6/*æ*/, 0xe7/*ç*/, 0xe9/*é*/, 0xee/*î*/, 0xf8/*ø*/, 0xf9/*ù*/, 0xff/*ÿ*/, 0x2a7d/*⩽*/, 0x1f600/*😀*/};
const int message_len = sizeof(message) / sizeof(uint32_t);
int i;
uint32_t message[8];
int message_len = 8;
message[0] = 0xE3; // ã
message[1] = 0xE6; // æ
message[2] = 0xE7; // ç
message[3] = 0xE9; // é
message[4] = 0xEE; // î
message[5] = 0xF8; // ø
message[6] = 0xF9; // ù
message[7] = 0xFF; // ÿ
for (i = 0; i < message_len; i++) {
linphone_chat_message_put_char(rtt_message, message[i]);
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000));
......@@ -2007,7 +1998,7 @@ static void real_time_text_message_accented_chars(void) {
const char *text = linphone_chat_message_get_text(marie->stat.last_received_chat_message);
BC_ASSERT_PTR_NOT_NULL(text);
if (text)
BC_ASSERT_STRING_EQUAL(text, "ãæçéîøùÿ");
BC_ASSERT_STRING_EQUAL(text, "ãæçéîøùÿ⩽😀");
}
linphone_chat_message_unref(rtt_message);
}
......
......@@ -705,6 +705,7 @@ static void transport_dont_bind(void){
linphone_core_manager_destroy(pauline);
}
#if 0
static void transport_busy(void){
LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc");
LCSipTransports tr;
......@@ -729,6 +730,7 @@ static void transport_busy(void){
linphone_core_manager_destroy(pauline);
}
#endif
static void proxy_transport_change(void){
LinphoneCoreManager* lcm = create_lcm();
......@@ -1479,7 +1481,7 @@ test_t register_tests[] = {
TEST_NO_TAG("Multi account", multiple_proxy),
TEST_NO_TAG("Transport changes", transport_change),
TEST_NO_TAG("Transport configured with dontbind option", transport_dont_bind),
TEST_NO_TAG("Transport busy", transport_busy),
// TEST_NO_TAG("Transport busy", transport_busy),
TEST_NO_TAG("Proxy transport changes", proxy_transport_change),
TEST_NO_TAG("Proxy transport changes with wrong address at first", proxy_transport_change_with_wrong_port),
TEST_NO_TAG("Proxy transport changes with wrong address, giving up",proxy_transport_change_with_wrong_port_givin_up),
......
......@@ -125,17 +125,19 @@ void reset_counters( stats* counters) {
}
void configure_lc(LinphoneCore *lc, const char *path, void *user_data) {
char *dnsuserhostspath = NULL;
dnsuserhostspath = userhostsfile[0]=='/' ? ms_strdup(userhostsfile) : ms_strdup_printf("%s/%s", path, userhostsfile);
linphone_core_set_user_data(lc, user_data);
linphone_core_enable_ipv6(lc, liblinphonetester_ipv6);
linphone_core_set_sip_transport_timeout(lc, liblinphonetester_transport_timeout);
linphone_core_set_user_data(lc, user_data);
sal_enable_test_features(linphone_core_get_sal(lc),TRUE);
sal_set_dns_user_hosts_file(linphone_core_get_sal(lc), dnsuserhostspath);
ms_free(dnsuserhostspath);
sal_enable_test_features(linphone_core_get_sal(lc), TRUE);
if (strcmp(userhostsfile, "none") != 0) {
char *dnsuserhostspath = strchr(userhostsfile, '/') ? ms_strdup(userhostsfile) : ms_strdup_printf("%s/%s", path, userhostsfile);
sal_set_dns_user_hosts_file(linphone_core_get_sal(lc), dnsuserhostspath);
ms_free(dnsuserhostspath);
} else {
bctbx_message("no dns-hosts file used");
}
}
LinphoneCore *configure_lc_from(LinphoneCoreCbs *cbs, const char *path, LinphoneConfig *config, void *user_data) {
......@@ -340,7 +342,7 @@ static void avoid_pulseaudio_hack(LinphoneCoreManager *mgr){
void linphone_core_manager_configure (LinphoneCoreManager *mgr) {
LinphoneImNotifPolicy *im_notif_policy;
char *hellopath = bc_tester_res("sounds/hello8000.wav");
const char * filepath = mgr->rc_path?bctbx_strdup_printf("%s/%s", bc_tester_get_resource_dir_prefix() ,mgr->rc_path):NULL;
char *filepath = mgr->rc_path ? bctbx_strdup_printf("%s/%s", bc_tester_get_resource_dir_prefix(), mgr->rc_path) : NULL;
if (filepath && bctbx_file_exist(filepath) != 0) {
ms_fatal("Could not find file %s in path %s, did you configured resources directory correctly?", mgr->rc_path, bc_tester_get_resource_dir_prefix());
}
......@@ -406,6 +408,8 @@ void linphone_core_manager_configure (LinphoneCoreManager *mgr) {
/*for now, we need the periodical updates facility to compute bandwidth measurements correctly during tests*/
linphone_core_enable_send_call_stats_periodical_updates(mgr->lc, TRUE);
// clean
if (filepath) bctbx_free(filepath);
}
static void generate_random_database_path (LinphoneCoreManager *mgr) {
......
......@@ -284,7 +284,7 @@ class CsharpTranslator(object):
else:
listenerDict['delegate']['params'] += "MarshalBctbxList<" + self.get_class_array_type(normalType) + ">(" + argName + ")"
else:
print 'Not supported yet: ' + delegate_name_public
print('Not supported yet: ' + delegate_name_public)
return {}
else:
listenerDict['delegate']['first_param'] = argName
......
......@@ -83,6 +83,7 @@ public class AndroidPlatformHelper {
private String mUserCertificatePath;
private Surface mSurface;
private SurfaceTexture mSurfaceTexture;
private TextureView mPreviewTextureView, mVideoTextureView;
private boolean mDozeModeEnabled;
private BroadcastReceiver mDozeReceiver;
private IntentFilter mDozeIntentFilter;
......@@ -352,14 +353,30 @@ public class AndroidPlatformHelper {
}
public synchronized void setVideoPreviewView(Object view) {
if (view == null) {
setNativePreviewWindowId(mNativePtr, null);
if (mPreviewTextureView != null) {
mPreviewTextureView.setSurfaceTextureListener(null);
mPreviewTextureView = null;
}
return;
}
if (view instanceof Surface) {
Surface surface = (Surface) view;
setNativePreviewWindowId(mNativePtr, surface);
return;
}
if (!(view instanceof TextureView)) {
throw new RuntimeException("[Platform Helper] Preview window id is not an instance of TextureView. " +
"Please update your UI layer so that the preview video view is a TextureView (or an instance of it)" +
"or enable compatibility mode by setting displaytype=MSAndroidOpenGLDisplay in the [video] section your linphonerc factory configuration file" +
"so you can keep using your existing application code for managing video views.");
}
TextureView textureView = (TextureView)view;
textureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
mPreviewTextureView = (TextureView)view;
mPreviewTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
Log.i("[Platform Helper] Preview window surface is available");
......@@ -374,7 +391,10 @@ public class AndroidPlatformHelper {
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
Log.i("[Platform Helper] Preview window surface is no longer available");
setNativePreviewWindowId(mNativePtr, null);
if (mPreviewTextureView != null) {
setNativePreviewWindowId(mNativePtr, null);
mPreviewTextureView = null;
}
return false;
}
......@@ -383,21 +403,37 @@ public class AndroidPlatformHelper {
}
});
if (textureView.isAvailable()) {
if (mPreviewTextureView.isAvailable()) {
Log.i("[Platform Helper] Preview window surface is available");
setNativePreviewWindowId(mNativePtr, textureView.getSurfaceTexture());
setNativePreviewWindowId(mNativePtr, mPreviewTextureView.getSurfaceTexture());
}
}
public synchronized void setVideoRenderingView(Object view) {
if (view == null) {
setNativeVideoWindowId(mNativePtr, null);
if (mVideoTextureView != null) {
mVideoTextureView.setSurfaceTextureListener(null);
mVideoTextureView = null;
}
return;
}
if (view instanceof Surface) {
Surface surface = (Surface) view;
setNativeVideoWindowId(mNativePtr, surface);
return;
}
if (!(view instanceof TextureView)) {
throw new RuntimeException("[Platform Helper] Rendering window id is not an instance of TextureView." +
"Please update your UI layer so that the video rendering view is a TextureView (or an instance of it)" +
"or enable compatibility mode by setting displaytype=MSAndroidOpenGLDisplay in the [video] section your linphonerc factory configuration file" +
"so you can keep using your existing application code for managing video views.");
}
TextureView textureView = (TextureView)view;
textureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
mVideoTextureView = (TextureView)view;
mVideoTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
Log.i("[Platform Helper] Rendering window surface is available");
......@@ -415,8 +451,11 @@ public class AndroidPlatformHelper {
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
if (mSurfaceTexture == surface) {
Log.i("[Platform Helper] Rendering window surface is no longer available");
setNativeVideoWindowId(mNativePtr, null);
mSurfaceTexture = null;
if (mVideoTextureView != null) {
setNativeVideoWindowId(mNativePtr, null);
mSurfaceTexture = null;
mVideoTextureView = null;
}
}
return false;
}
......@@ -426,9 +465,10 @@ public class AndroidPlatformHelper {
}
});
if (textureView.isAvailable()) {
if (mVideoTextureView.isAvailable()) {
Log.i("[Platform Helper] Rendering window surface is available");
mSurfaceTexture = textureView.getSurfaceTexture();
mSurfaceTexture = mVideoTextureView.getSurfaceTexture();
mSurface = new Surface(mSurfaceTexture);
setNativeVideoWindowId(mNativePtr, mSurface);
}
......
......@@ -266,8 +266,8 @@ class JavaTranslator(object):
methodDict['hasNormalReturn'] = not methodDict['hasListReturn'] and not methodDict['hasStringReturn'] and not methodDict['hasByteArrayReturn']
methodDict['name'] = 'Java_' + self.jni_package + className + 'Impl_' + _method.name.translate(self.nameTranslator)
methodDict['notStatic'] = not static
methodDict['isConstList'] = _method.returnType.isconst
methodDict['isNotConstList'] = not _method.returnType.isconst
methodDict['isConst'] = _method.returnType.isconst
methodDict['isNotConst'] = not _method.returnType.isconst
if _method.name.to_c()[-1].isdigit():
methodDict['name'] += _method.name.to_c()[-1]
......@@ -416,6 +416,7 @@ class JavaTranslator(object):
methodDict['jniUpcallMethod'] = 'CallVoidMethod'
methodDict['isJniUpcallBasicType'] = False
methodDict['isJniUpcallObject'] = False
if isinstance(_method.returnType, AbsApi.ClassType):
methodDict['jniUpcallMethod'] = 'CallObjectMethod'
methodDict['isJniUpcallObject'] = True
......@@ -666,6 +667,8 @@ class Jni(object):
'cPrefix': jniInterface.cPrefix,
'jniPackage': self.jni_package,
'factoryName': javaClass.factoryName,
'isCore': jniInterface.cPrefix == 'linphone_core',
'isNotCore': not jniInterface.cPrefix == 'linphone_core',
'callbacksList': []
}
for callback in jniInterface.callbacks:
......
......@@ -510,7 +510,7 @@ JNIEXPORT void JNICALL Java_{{jniPackage}}{{className}}Impl_removeListener(JNIEn
bctbx_error("Java_{{jniPackage}}{{className}}Impl_removeListener's {{classCName}} C ptr is null!");
return;
}
const bctbx_list_t *cbs_list = {{cPrefix}}_get_callbacks_list(cptr);
{{#isNotCore}}const {{/isNotCore}}bctbx_list_t *cbs_list = {{cPrefix}}_get_callbacks_list(cptr);
bctbx_list_t *it;
for (it = (bctbx_list_t *)cbs_list; it != nullptr; it = it->next) {
{{classCName}}Cbs *cbs = ({{classCName}}Cbs *)it->data;
......@@ -522,6 +522,7 @@ JNIEXPORT void JNICALL Java_{{jniPackage}}{{className}}Impl_removeListener(JNIEn
break;
}
}
{{#isCore}}bctbx_list_free(cbs_list);{{/isCore}}
}
{{/isMultiListener}}
{{/interfaces}}
......@@ -575,7 +576,7 @@ JNIEXPORT {{return}} JNICALL {{name}}({{params}}) {
{{/isObjList}}
}
{{/lists}}{{#hasListReturn}}
{{#isConstList}}const {{/isConstList}}bctbx_list_t *list = {{c_name}}({{#notStatic}}cptr{{/notStatic}}{{params_impl}});
{{#isConst}}const {{/isConst}}bctbx_list_t *list = {{c_name}}({{#notStatic}}cptr{{/notStatic}}{{params_impl}});
bctbx_list_t *list_it = (bctbx_list_t *)list;
size_t count = bctbx_list_size(list);
{{#isRealObjectArray}}
......@@ -597,7 +598,7 @@ JNIEXPORT {{return}} JNICALL {{name}}({{params}}) {
list_it = bctbx_list_next(list_it);
i += 1;
}
{{#isNotConstList}}bctbx_list_free(list);{{/isNotConstList}}
{{#isNotConst}}bctbx_list_free(list);{{/isNotConst}}
{{/hasListReturn}}{{#hasByteArrayReturn}}
{{c_type_return}} jni_result = {{c_name}}({{#notStatic}}cptr{{/notStatic}}{{params_impl}});
if (!jni_result) return nullptr;
......@@ -606,8 +607,9 @@ JNIEXPORT {{return}} JNICALL {{name}}({{params}}) {
env->SetByteArrayRegion(array, 0, (int)jni_result_length, (const jbyte*)jni_result);
return array;
{{/hasByteArrayReturn}}{{#hasStringReturn}}
const char *c_string = {{c_name}}({{#notStatic}}cptr{{/notStatic}}{{params_impl}}){{#returnObject}}){{/returnObject}};
{{#isConst}}const {{/isConst}}char *c_string = {{c_name}}({{#notStatic}}cptr{{/notStatic}}{{params_impl}}){{#returnObject}}){{/returnObject}};
jstring jni_result = (c_string != nullptr) ? get_jstring_from_char(env, c_string) : nullptr;
{{#isNotConst}}bctbx_free(c_string);{{/isNotConst}}
{{/hasStringReturn}}{{#hasNormalReturn}}
{{#hasReturn}}{{return}} jni_result = ({{return}}){{#returnObject}}get{{returnClassName}}(env, (Linphone{{returnClassName}} *){{/returnObject}}{{/hasReturn}}{{c_name}}({{#notStatic}}cptr{{/notStatic}}{{params_impl}}){{#returnObject}}, {{takeRefOnReturnedObject}}){{/returnObject}};
{{/hasNormalReturn}}{{#strings}}
......