Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor modifications to Android build and samples to match new documentation #4271

Merged
merged 4 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually we use test account here ("test"), also for the destination

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used three accounts for the doc, hence I thought using 102-103 has better symmetry to it.

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
Loading