-
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 13 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,126 @@ | ||
# 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 | ||
- pjsip v2.14.1 | ||
|
||
- 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 | ||
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. Add note: |
||
|
||
``` | ||
|
||
- Create the following variable: | ||
|
||
```bash | ||
|
||
export ANDROID_NDK_ROOT=/path/to/ndk/root/installation | ||
|
||
``` | ||
|
||
- Then build pjsip | ||
|
||
```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 | ||
|
||
``` | ||
|
||
|
||
|
||
### 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 | ||
- pjsip v2.14.1 | ||
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. same as above. add "or later" |
||
|
||
- PREPARING: | ||
|
||
Create the following variable: | ||
|
||
```bash | ||
|
||
export DEVPATH="`xcrun -sdk iphonesimulator --show-sdk-platform-path`/Developer" | ||
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. Move this below |
||
|
||
``` | ||
|
||
|
||
- Building pj stack: | ||
|
||
Create the following ``` config_site.h ``` : | ||
|
||
```c | ||
|
||
#define PJ_CONFIG_IPHONE 1 | ||
|
||
// disable background VoIP socket, use PushKit | ||
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. These two defines below should not be needed. The setting to disable background voip is: |
||
#undef PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT | ||
#define PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT 0 | ||
|
||
#ifndef __IPHONE_OS_VERSION_MIN_REQUIRED | ||
#define __IPHONE_OS_VERSION_MIN_REQUIRED 122000 | ||
#endif | ||
|
||
#include <pj/config_site_sample.h> | ||
|
||
``` | ||
|
||
|
||
|
||
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: |
||
|
||
``` | ||
|
||
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: | ||
|
||
```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.
|
||
|
||
``` |
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) | ||
{ | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using CommunityToolkit.Mvvm.Messaging.Messages; | ||
using pjsua2maui.Models; | ||
|
||
namespace pjsua2maui.Messages; | ||
|
||
public class SaveAccountConfigMessage : ValueChangedMessage<SoftAccountConfigModel> | ||
{ | ||
public SaveAccountConfigMessage(SoftAccountConfigModel softAccountConfigModel) : base(softAccountConfigModel) | ||
{ | ||
} | ||
} |
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.
Change this to:
Here I'm using NDK r28 and 2.15.1, and it seems ok