-
Notifications
You must be signed in to change notification settings - Fork 845
Add MAUI example app to csharp samples #4078
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
base: master
Are you sure you want to change the base?
Changes from all commits
894c17b
761137a
0be88ec
3ec61fb
9eced91
7a4e178
1321e83
0fb330f
e971c5c
7b88941
552f8f1
9e74896
7dea438
b3b4d4c
649f958
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,3 +87,5 @@ tests/fuzz/*.o | |
cov-int/ | ||
getversion.mak | ||
configure.out | ||
*/Platforms/iOS/pjsua2/* | ||
*/Platforms/iOS/lib/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.dll | ||
.java | ||
.class | ||
.jar | ||
.so | ||
/*/obj/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
# pjsua2maui - pjsip on .net maui | ||
|
||
## STEPS FOR BUILDING: | ||
|
||
### Android | ||
|
||
- SETUP: | ||
- Visual Studio Code & .NET MAUI - [Install steps](https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation?view=net-maui-11.0&tabs=visual-studio-code) | ||
- Java 17 | ||
- Android NDK r21d or later | ||
- pjsip v2.14.1 or later | ||
|
||
- Run the following commands: | ||
|
||
```bash | ||
export ANDROID_SDK_ROOT=/somewhere/there/is/installed/the/sdk/ | ||
sdkmanager --install "ndk;28.0.12674087" --channel=3 --sdk_root=$ANDROID_SDK_ROOT | ||
sdkmanager --install "cmake;3.31.0" --sdk_root=$ANDROID_SDK_ROOT | ||
sdkmanager --install "build-tools;35.0.0" "platform-tools" "platforms;android-35" --sdk_root=$ANDROID_SDK_ROOT | ||
echo yes | sdkmanager --licenses --sdk_root=$ANDROID_SDK_ROOT | ||
``` | ||
note: | ||
If you are sharing the Android SDK location with Android Studio, the recommended way to install/update the SDK and accept licenses is by using Android Studio. | ||
|
||
- Create the following variable: | ||
|
||
```bash | ||
|
||
export ANDROID_NDK_ROOT=/path/to/ndk/root/installation | ||
|
||
``` | ||
|
||
- Then build pjsip | ||
|
||
For device: | ||
```bash | ||
./configure-android | ||
``` | ||
|
||
For simulator: | ||
```bash | ||
|
||
TARGET_ABI=x86_64 ./configure-android | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need instruction for device too, i.e.: |
||
make dep && make clean && make | ||
|
||
``` | ||
|
||
|
||
after run make dep and make, run the make on ``` pjsip-apps/src/swig/csharp ``` folder | ||
|
||
```bash | ||
|
||
make | ||
|
||
``` | ||
|
||
then start the android emulator, go to ``` pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui ``` and run: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also needs instruction for device. Here's what I did:
|
||
|
||
```bash | ||
|
||
dotnet workload restore | ||
dotnet restore | ||
dotnet build -t:Run -c Debug -f net9.0-android | ||
|
||
``` | ||
or, for run in device: | ||
|
||
Open Android Studio and connect an Android device, such as by using "Pair Devices Using Wifi" | ||
(Optional) Start Logcat in VS Code, for obtaining Android log. | ||
Install Logcat: View-Extensions. Install Logcat extension. | ||
Start Logcat: View-Command Pallette. | ||
|
||
### iOS | ||
|
||
- SETUP: | ||
- Visual Studio Code & .NET MAUI - [Install steps](https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation?view=net-maui-11.0&tabs=visual-studio-code) | ||
- Xcode 16.1 or later | ||
- pjsip v2.14.1 or later | ||
|
||
- PREPARING: | ||
|
||
- Building pj stack: | ||
|
||
Create the following ``` config_site.h ``` : | ||
|
||
```c | ||
|
||
#define PJ_CONFIG_IPHONE 1 | ||
|
||
#include <pj/config_site_sample.h> | ||
|
||
``` | ||
Create the following variable: | ||
|
||
```bash | ||
|
||
export DEVPATH="`xcrun -sdk iphonesimulator --show-sdk-platform-path`/Developer" | ||
|
||
``` | ||
Run configure with the following flags to build the lib to run on simulator: | ||
|
||
```bash | ||
|
||
MIN_IOS="-miphoneos-version-min=12.2" ARCH="-arch x86_64" CFLAGS="-O2 -m32 -mios-simulator-version-min=12.2 -fembed-bitcode" LDFLAGS="-O2 -m32 -mios-simulator-version-min=12.2 -fembed-bitcode" ./configure-iphone | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need instruction for device as well. For device: |
||
|
||
``` | ||
For run on device: | ||
|
||
```bash | ||
./configure-iphone | ||
``` | ||
|
||
after run make dep and make, run the make on ``` pjsip-apps/src/swig/csharp ``` folder | ||
|
||
```bash | ||
|
||
make | ||
|
||
``` | ||
|
||
then go to ``` pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui ``` and run: | ||
|
||
For simulator: | ||
|
||
```bash | ||
dotnet workload restore | ||
dotnet restore | ||
dotnet build -t:Run -c Debug -f net9.0-ios -p:_DeviceName=:v2:udid=UDID_OF_YOUR_EMULATOR | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need instruction for device as well.
|
||
``` | ||
|
||
For device: | ||
|
||
```bash | ||
dotnet workload restore | ||
dotnet restore | ||
dotnet build -t:Run -c Debug -f net9.0-ios -p:_DeviceName=:v2:udid=UDID_OF_YOUR_DEVICE | ||
``` | ||
|
||
For the codesign, here are the steps: | ||
|
||
```bash | ||
dotnet publish -c Debug -f net9.0-ios -p:RuntimeIdentifier=ios-arm64 | ||
``` | ||
Open the resulting .ipa file in Xcode: ``` pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/bin/Debug/net9.0-ios/ios-arm64/publish/pjsua2maui.ipa ``` | ||
|
||
Drag it to your connected device under "Devices and Simulators." | ||
Xcode will handle the signing and deployment. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
| ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pjsua2maui", "pjsua2maui\pjsua2maui.csproj", "{C9D0190E-58BC-417B-9810-335D234D5002}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{C9D0190E-58BC-417B-9810-335D234D5002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C9D0190E-58BC-417B-9810-335D234D5002}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C9D0190E-58BC-417B-9810-335D234D5002}.Debug|Any CPU.Deploy.0 = Debug|Any CPU | ||
{C9D0190E-58BC-417B-9810-335D234D5002}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C9D0190E-58BC-417B-9810-335D234D5002}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.dll | ||
.java | ||
.class | ||
.jar | ||
.so | ||
/*/obj/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version = "1.0" encoding = "UTF-8" ?> | ||
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:pjsua2maui" | ||
x:Class="pjsua2maui.App"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="Resources/Styles/Colors.xaml" /> | ||
<ResourceDictionary Source="Resources/Styles/Styles.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace pjsua2maui; | ||
|
||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
|
||
MainPage = new AppShell(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Shell | ||
x:Class="pjsua2maui.AppShell" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:pjsua2maui.Views" | ||
Shell.FlyoutBehavior="Disabled"> | ||
|
||
<ShellContent | ||
Title="Home" | ||
ContentTemplate="{DataTemplate local:BuddyPage}" | ||
Route="BuddyPage" /> | ||
|
||
</Shell> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace pjsua2maui; | ||
|
||
public partial class AppShell : Shell | ||
{ | ||
public AppShell() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace pjsua2maui.Controls; | ||
|
||
public class CallView : ContentView | ||
{ | ||
public CallView() | ||
{ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Microsoft.Extensions.Logging; | ||
using pjsua2maui.Controls; | ||
#if ANDROID | ||
using pjsua2maui.Platforms.Android; | ||
#endif | ||
#if IOS | ||
using pjsua2maui.Platforms.iOS; | ||
#endif | ||
|
||
namespace pjsua2maui; | ||
|
||
public static class MauiProgram | ||
{ | ||
public static MauiApp CreateMauiApp() | ||
{ | ||
var builder = MauiApp.CreateBuilder(); | ||
builder | ||
.UseMauiApp<App>() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); | ||
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); | ||
}); | ||
|
||
#if DEBUG | ||
builder.Logging.AddDebug(); | ||
#endif | ||
#if __ANDROID__ | ||
builder.ConfigureMauiHandlers((x) => { | ||
x.AddHandler(typeof(CallView), typeof(CallPageRenderer)); | ||
}); | ||
#endif | ||
#if __IOS__ | ||
builder.ConfigureMauiHandlers((x) => { | ||
x.AddHandler(typeof(CallView), typeof(CallPageRenderer)); | ||
}); | ||
#endif | ||
return builder.Build(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using CommunityToolkit.Mvvm.Messaging.Messages; | ||
using libpjsua2.maui; | ||
|
||
namespace pjsua2maui.Messages; | ||
|
||
public class AddBuddyMessage : ValueChangedMessage<BuddyConfig> | ||
{ | ||
public AddBuddyMessage(BuddyConfig buddyConfig) : base(buddyConfig) | ||
{ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using CommunityToolkit.Mvvm.Messaging.Messages; | ||
using libpjsua2.maui; | ||
|
||
namespace pjsua2maui.Messages; | ||
|
||
public class EditBuddyMessage : ValueChangedMessage<BuddyConfig> | ||
{ | ||
public EditBuddyMessage(BuddyConfig buddyConfig) : base(buddyConfig) | ||
{ | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add note:
If you are sharing the Android SDK location with Android Studio, the recommended way to install/update the SDK and accept licenses is by using Android Studio.