Skip to content

Commit

Permalink
Minor modifications to Android build and samples to match new documen…
Browse files Browse the repository at this point in the history
…tation (#4271)

* To streamline the command, also clean swig and pjsua jni output directories when make distclean and realclean is called

* Kotlin sample: add account, modify video size and bandwidth, and audio codec priorities to use AMR-WB

* Android CLI app: fix armeabi hardcoded arch and also copy stdc++.so
  • Loading branch information
bennylp authored Jan 28, 2025
1 parent bab33d6 commit c36ed2c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ all clean dep depend print:
done

distclean realclean:
for dir in $(DIRS); do \
for dir in $(DIRS) pjsip-apps/src/swig pjsip-apps/src/pjsua/android/jni; do \
if $(MAKE) $(MAKE_FLAGS) -C $$dir $@; then \
true; \
else \
Expand Down
13 changes: 10 additions & 3 deletions pjsip-apps/src/pjsua/android/jni/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MY_MODULES := $(MY_MODULE_PATH)/pjsua_app.o \
$(MY_MODULE_PATH)/pjsua_app_legacy.o

OUT_DIR := ../build/jni
LIBPJSUA_SO := ../app/src/main/jniLibs/armeabi/libpjsua.so
LIBPJSUA_SO := ../app/src/main/jniLibs/$(TARGET_ARCH)/libpjsua.so

# Env settings, e.g: path to SWIG, JDK, java(.exe), javac(.exe)
MY_SWIG := swig
Expand All @@ -23,10 +23,12 @@ MY_LDFLAGS := $(PJ_LDXXFLAGS) $(PJ_LDXXLIBS) $(MY_JNI_LDFLAGS) $(LDFLAGS)
MY_PACKAGE_NAME := org.pjsip.pjsua
MY_PACKAGE_PATH := ../app/src/main/java/$(subst .,/,$(MY_PACKAGE_NAME))

all: $(LIBPJSUA_SO) java
MY_STD_CPP := ../app/src/main/jniLibs/$(TARGET_ARCH)/libc++_shared.so

all: $(LIBPJSUA_SO) java $(MY_STD_CPP)

$(LIBPJSUA_SO): $(OUT_DIR)/pjsua_wrap.o
mkdir -p ../app/src/main/jniLibs/armeabi
mkdir -p ../app/src/main/jniLibs/$(TARGET_ARCH)
$(PJ_CXX) -shared -o $(LIBPJSUA_SO) \
$(OUT_DIR)/pjsua_wrap.o $(OUT_DIR)/pjsua_app_callback.o \
$(MY_MODULES) \
Expand Down Expand Up @@ -54,3 +56,8 @@ ifneq (,$(findstring PJMEDIA_VIDEO_DEV_HAS_ANDROID=1,$(ANDROID_CFLAGS)))
@echo "Copying Android camera helper components..."
cp $(PJDIR)/pjmedia/src/pjmedia-videodev/android/PjCamera*.java $(MY_PACKAGE_PATH)/..
endif

$(MY_STD_CPP): $(STD_CPP_LIB)
cp -v $< $@


Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ import java.lang.ref.WeakReference
/* Configs */

// Account ID
const val ACC_ID_URI = "sip:localhost"
const val ACC_DOMAIN = "pjsip.org"
const val ACC_USER = "101"
const val ACC_PASSWD = ""
const val ACC_ID_URI = "Kotlin <sip:" + ACC_USER + "@" + ACC_DOMAIN + ">"
const val ACC_REGISTRAR = "sip:sip.pjsip.org;transport=tls"
const val ACC_PROXY = "sip:sip.pjsip.org;lr;transport=tls"

// Peer to call
const val CALL_DST_URI = "sip:192.168.1.9:6000"
const val CALL_DST_URI = "MicroSIP <sip:[email protected]>"

// Camera ID used for video call.
// Use VidDevManager::enumDev2() to get available cameras & IDs.
Expand Down Expand Up @@ -273,8 +278,18 @@ class MainActivity : AppCompatActivity(), android.os.Handler.Callback {
g.ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP,
sipTpConfig)

g.ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_TLS,
TransportConfig())

val accCfg = AccountConfig()
accCfg.idUri = ACC_ID_URI
accCfg.regConfig.registrarUri = ACC_REGISTRAR
accCfg.sipConfig.authCreds.add(
AuthCredInfo("Digest", "*", ACC_USER, 0,
ACC_PASSWD)
)
accCfg.sipConfig.proxies.add( ACC_PROXY )

accCfg.videoConfig.autoShowIncoming = true
accCfg.videoConfig.autoTransmitOutgoing = true
accCfg.videoConfig.defaultCaptureDevice = VIDEO_CAPTURE_DEVICE_ID
Expand All @@ -291,6 +306,14 @@ class MainActivity : AppCompatActivity(), android.os.Handler.Callback {
}
findViewById<TextView>(R.id.text_info).text = "Library started"

/* Prioritize AMR-WB */
try {
g.ep.codecSetPriority("AMR-WB", 255)
g.ep.codecSetPriority("AMR/8000", 254)
} catch (e: Exception) {
println(e)
}

/* Fix camera orientation to portrait mode (for front camera) */
try {
g.ep.vidDevManager().setCaptureOrient(VIDEO_CAPTURE_DEVICE_ID,
Expand All @@ -306,8 +329,10 @@ class MainActivity : AppCompatActivity(), android.os.Handler.Callback {
}
}
var vcp = g.ep.getVideoCodecParam(codecId)
vcp.encFmt.width = 240
vcp.encFmt.height = 320
vcp.encFmt.width = 480
vcp.encFmt.height = 640
vcp.encFmt.avgBps = 1024000
vcp.encFmt.maxBps = 5000000
g.ep.setVideoCodecParam(codecId, vcp)
} catch (e: Exception) {
println(e)
Expand Down

0 comments on commit c36ed2c

Please sign in to comment.