├── .github └── workflows │ ├── release.yml │ └── run_test.yml ├── .gitignore ├── .metadata ├── .run ├── Conference.run.xml ├── DataChannel.run.xml ├── Example.run.xml ├── Peer.run.xml ├── Play.run.xml └── Publish.run.xml ├── .vscode └── launch.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── com │ ├── example │ └── ant_media_flutter │ │ └── AntMediaFlutterPlugin.kt │ └── feloh │ └── ant_media_flutter │ └── AntMediaFlutterPlugin.kt ├── example └── SampleProject │ ├── .gitignore │ ├── .metadata │ ├── README.md │ ├── analysis_options.yaml │ ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── ant_media_flutter_example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle │ ├── integration_test │ ├── test_conference.dart │ ├── test_data_channel.dart │ ├── test_helper.dart │ ├── test_p2p.dart │ ├── test_play.dart │ └── test_publish.dart │ ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h │ └── RunnerTests │ │ └── RunnerTests.swift │ ├── lib │ ├── conference.dart │ ├── datachannel.dart │ ├── main.dart │ ├── peer.dart │ ├── play.dart │ └── publish.dart │ ├── linux │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ │ ├── CMakeLists.txt │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ └── generated_plugins.cmake │ └── runner │ │ ├── CMakeLists.txt │ │ ├── main.cc │ │ ├── my_application.cc │ │ └── my_application.h │ ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── app_icon_1024.png │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ └── app_icon_64.png │ │ ├── Base.lproj │ │ │ └── MainMenu.xib │ │ ├── Configs │ │ │ ├── AppInfo.xcconfig │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ └── Warnings.xcconfig │ │ ├── DebugProfile.entitlements │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements │ └── RunnerTests │ │ └── RunnerTests.swift │ ├── pubspec.lock │ ├── pubspec.yaml │ ├── test │ ├── test_play.dart │ ├── test_publish.dart │ └── widget_test.dart │ ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json │ └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h ├── images ├── README.md ├── flutter_sdk_inapp_0.jpeg ├── flutter_sdk_inapp_1.jpeg └── flutter_sdk_inapp_2.jpg ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── AntMediaFlutterPlugin.h │ ├── AntMediaFlutterPlugin.m │ └── SwiftAntMediaFlutterPlugin.swift └── ant_media_flutter.podspec ├── lib ├── ant_media_flutter.dart ├── ant_media_flutter_web.dart └── src │ ├── helpers │ └── helper.dart │ └── utils │ ├── conference_widget │ └── playwidget.dart │ ├── websocket.dart │ └── websocket_web.dart ├── pub_login.sh ├── pubspec.yaml └── test └── permission_test.dart /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Publish Package 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | if: contains(github.event.head_commit.message, 'release') 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | - name: Set up JDK 17 15 | uses: actions/setup-java@v3 16 | with: 17 | distribution: 'zulu' 18 | java-version: '17' 19 | 20 | - name: Install Flutter 21 | uses: subosito/flutter-action@v2 22 | with: 23 | channel: 'stable' 24 | 25 | - name: Setup Pub Credentials 26 | shell: bash 27 | env: 28 | PUB_DEV_PUBLISH_ACCESS_TOKEN: ${{ secrets.PUB_DEV_PUBLISH_ACCESS_TOKEN }} 29 | PUB_DEV_PUBLISH_REFRESH_TOKEN: ${{ secrets.PUB_DEV_PUBLISH_REFRESH_TOKEN }} 30 | PUB_DEV_PUBLISH_TOKEN_ENDPOINT: ${{ secrets.PUB_DEV_PUBLISH_TOKEN_ENDPOINT }} 31 | PUB_DEV_PUBLISH_EXPIRATION: ${{ secrets.PUB_DEV_PUBLISH_EXPIRATION }} 32 | run: | 33 | sh ./pub_login.sh 34 | 35 | - name: Check Publish Warnings 36 | run: | 37 | sudo cat /$HOME/.config/dart/pub-credentials.json 38 | flutter pub publish --dry-run 39 | 40 | - name: Publish Package 41 | run: | 42 | yes | flutter pub publish -------------------------------------------------------------------------------- /.github/workflows/run_test.yml: -------------------------------------------------------------------------------- 1 | 2 | name: Run Test Cases 3 | 4 | on: [pull_request] 5 | 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v3 13 | 14 | - name: Set up JDK 17 15 | uses: actions/setup-java@v3 16 | with: 17 | distribution: 'zulu' 18 | java-version: '17' 19 | 20 | - name: Install Flutter 21 | uses: subosito/flutter-action@v2 22 | with: 23 | channel: 'stable' 24 | 25 | - name: Enable KVM group perms 26 | run: | 27 | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules 28 | sudo udevadm control --reload-rules 29 | sudo udevadm trigger --name-match=kvm 30 | sudo apt-get -y install android-tools-adb 31 | 32 | 33 | - name: Run sample application integration tests 34 | uses: reactivecircus/android-emulator-runner@v2 35 | with: 36 | api-level: 29 37 | script: | 38 | cd example/SampleProject && flutter test integration_test/test_play.dart 39 | cd example/SampleProject && flutter test integration_test/test_conference.dart 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 25 | /pubspec.lock 26 | **/doc/api/ 27 | .dart_tool/ 28 | .packages 29 | build/ 30 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 097d3313d8e2c7f901932d63e537c1acefb87800 8 | channel: stable 9 | 10 | project_type: plugin 11 | -------------------------------------------------------------------------------- /.run/Conference.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.run/DataChannel.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.run/Example.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.run/Peer.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.run/Play.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.run/Publish.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | 9 | { 10 | "name": "Example", 11 | "cwd": "example", 12 | "request": "launch", 13 | "type": "dart" 14 | }, 15 | { 16 | "name": "Example (profile mode)", 17 | "cwd": "example", 18 | "request": "launch", 19 | "type": "dart", 20 | "flutterMode": "profile" 21 | }, 22 | { 23 | "name": "Example (release mode)", 24 | "cwd": "example", 25 | "request": "launch", 26 | "type": "dart", 27 | "flutterMode": "release" 28 | }, 29 | { 30 | "name": "Conference", 31 | "cwd": "samples/Conference", 32 | "request": "launch", 33 | "type": "dart" 34 | }, 35 | { 36 | "name": "Conference (profile mode)", 37 | "cwd": "samples/Conference", 38 | "request": "launch", 39 | "type": "dart", 40 | "flutterMode": "profile" 41 | }, 42 | { 43 | "name": "Conference (release mode)", 44 | "cwd": "samples/Conference", 45 | "request": "launch", 46 | "type": "dart", 47 | "flutterMode": "release" 48 | }, 49 | { 50 | "name": "Peer", 51 | "cwd": "samples/Peer", 52 | "request": "launch", 53 | "type": "dart" 54 | }, 55 | { 56 | "name": "Peer (profile mode)", 57 | "cwd": "samples/Peer", 58 | "request": "launch", 59 | "type": "dart", 60 | "flutterMode": "profile" 61 | }, 62 | { 63 | "name": "Peer (release mode)", 64 | "cwd": "samples/Peer", 65 | "request": "launch", 66 | "type": "dart", 67 | "flutterMode": "release" 68 | }, 69 | { 70 | "name": "Play", 71 | "cwd": "samples/Play", 72 | "request": "launch", 73 | "type": "dart" 74 | }, 75 | { 76 | "name": "Play (profile mode)", 77 | "cwd": "samples/Play", 78 | "request": "launch", 79 | "type": "dart", 80 | "flutterMode": "profile" 81 | }, 82 | { 83 | "name": "Play (release mode)", 84 | "cwd": "samples/Play", 85 | "request": "launch", 86 | "type": "dart", 87 | "flutterMode": "release" 88 | }, 89 | { 90 | "name": "Publish", 91 | "cwd": "samples/Publish", 92 | "request": "launch", 93 | "type": "dart" 94 | }, 95 | { 96 | "name": "Publish (profile mode)", 97 | "cwd": "samples/Publish", 98 | "request": "launch", 99 | "type": "dart", 100 | "flutterMode": "profile" 101 | }, 102 | { 103 | "name": "Publish (release mode)", 104 | "cwd": "samples/Publish", 105 | "request": "launch", 106 | "type": "dart", 107 | "flutterMode": "release" 108 | }, 109 | 110 | { 111 | "name": "DataChannel", 112 | "cwd": "samples/DataChannel", 113 | "request": "launch", 114 | "type": "dart" 115 | }, 116 | { 117 | "name": "DataChannel (profile mode)", 118 | "cwd": "samples/DataChannel", 119 | "request": "launch", 120 | "type": "dart", 121 | "flutterMode": "profile" 122 | }, 123 | { 124 | "name": "DataChannel (release mode)", 125 | "cwd": "samples/DataChannel", 126 | "request": "launch", 127 | "type": "dart", 128 | "flutterMode": "release" 129 | } 130 | ] 131 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.5.3 2 | - **FIX**: update WebRTC library add abr 3 | 4 | ## 1.5.2 5 | - **FIX**: Add namespace to plugin as required by gradle. 6 | 7 | ## 1.5.1 8 | - **FIX**: Update WebRTC library version. 9 | 10 | ## 1.5.0 11 | - **ENHAN**: Add manuel publish option. 12 | 13 | ## 1.4.4 14 | - **FIX**: Fix the data channel connectivity issue. 15 | 16 | ## 1.4.3 17 | - **FIX**: Fix the C++ onTrack failed error on Android Devices. 18 | 19 | ## 1.4.2 20 | - **ENHAN**: Cleanup duplicated samples. 21 | 22 | ## 1.4.1 23 | - **FIX**: Update WebRTC library version. 24 | 25 | ## 1.4.0 26 | - **FEAT**: Migrate to the unified plan and implement multitrack conference 27 | - **FIX**: Fix the playback issue. 28 | 29 | ## 1.3.2 30 | - **FIX**: Fix the token cannot pass issue. 31 | 32 | ## 1.3.1 33 | - **FIX**: Fix the websocket connection closed issue in case of there is no participant in the room. 34 | 35 | ## 1.3.0 36 | - **ENHAN**: Add multitrack conference solution. 37 | - **NOTE**: Minimum compatible Ant Media Server version is 2.8.0 38 | 39 | ## 1.2.1 40 | - **FIX**: Make samples compatible with web and fix push notification type error. 41 | 42 | ## 1.2.0 43 | - **FEAT**: Add sending push notification from sdk. 44 | 45 | ## 1.0.10 46 | - **FIX**: Fix broken images in README.md. 47 | 48 | ## 1.0.9 49 | - **ENHAN**: Update README.md file with complate function list. 50 | 51 | ## 1.0.8 52 | - **FIX**: Fix an issue which prevents the sdk from working on the mobile devices 53 | 54 | ## 1.0.7 55 | - **FIX**: Fix the issue of not being able to use sdk on the web 56 | 57 | ## 1.0.6 58 | - **ENHAN**: Update dependencies 59 | 60 | ## 1.0.5 61 | - **FEAT**: Webrtc client lib updated added option to : force stream quality , fix IOS screen rotation and audio issues 62 | 63 | ## 1.0.4 64 | 65 | - **ENHAN**: Update WebRTC stack 66 | 67 | ## 1.0.3 68 | 69 | - **FIX**: Fix conference widget issue and Bring back dart 3 compatibility 70 | 71 | ## 1.0.2 72 | 73 | - **FIX**: Fix DataChannel and make ice servers configurable 74 | 75 | ## 1.0.1 76 | 77 | - **FIX**: CI problems 78 | 79 | ## 1.0.0 80 | 81 | - **FEAT**: Increase flutter_webrtc version, add web support 82 | 83 | ## 0.0.8 84 | 85 | - **ENHAN**: Updated sample's code 86 | 87 | ## 0.0.7 88 | 89 | - **REFAC**: Removed unnecessary code 90 | 91 | ## 0.0.6 92 | 93 | - **REFAC**: Updated readme.md file , removed signaling class 94 | 95 | ## 0.0.5 96 | 97 | - **FEAT**: Data Channel implemented, Updated the sdk usability, Call screen's UI can be customised. 98 | 99 | ## 0.0.4 100 | 101 | - **ENHA**: Update sdk-code structure and optimize a code, And create a common helper class for all functions 102 | 103 | ## 0.0.3 104 | 105 | - **FIX**: Resolve Switch Camera and Mic issue in SDK & Samples 106 | 107 | ## 0.0.2 108 | 109 | - **ENHA**: Correction in Samples 110 | 111 | ## 0.0.1 112 | 113 | - **INIT**: Initial Release 114 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options 5 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.example.ant_media_flutter' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.6.10' 6 | repositories { 7 | google() 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:4.1.0' 13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 | } 15 | } 16 | 17 | rootProject.allprojects { 18 | repositories { 19 | google() 20 | mavenCentral() 21 | } 22 | } 23 | 24 | apply plugin: 'com.android.library' 25 | apply plugin: 'kotlin-android' 26 | 27 | android { 28 | compileSdkVersion 31 29 | namespace "com.example.ant_media_flutter" 30 | 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | 36 | kotlinOptions { 37 | jvmTarget = '1.8' 38 | } 39 | 40 | sourceSets { 41 | main.java.srcDirs += 'src/main/kotlin' 42 | } 43 | 44 | defaultConfig { 45 | minSdkVersion 16 46 | } 47 | } 48 | 49 | dependencies { 50 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 51 | } 52 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MSYS* | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'ant_media_flutter' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/example/ant_media_flutter/AntMediaFlutterPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.example.ant_media_flutter 2 | 3 | import androidx.annotation.NonNull 4 | 5 | import io.flutter.embedding.engine.plugins.FlutterPlugin 6 | import io.flutter.plugin.common.MethodCall 7 | import io.flutter.plugin.common.MethodChannel 8 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler 9 | import io.flutter.plugin.common.MethodChannel.Result 10 | 11 | /** AntMediaFlutterPlugin */ 12 | class AntMediaFlutterPlugin: FlutterPlugin, MethodCallHandler { 13 | /// The MethodChannel that will the communication between Flutter and native Android 14 | /// 15 | /// This local reference serves to register the plugin with the Flutter Engine and unregister it 16 | /// when the Flutter Engine is detached from the Activity 17 | private lateinit var channel : MethodChannel 18 | 19 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { 20 | channel = MethodChannel(flutterPluginBinding.binaryMessenger, "ant_media_flutter") 21 | channel.setMethodCallHandler(this) 22 | } 23 | 24 | override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { 25 | if (call.method == "getPlatformVersion") { 26 | result.success("Android ${android.os.Build.VERSION.RELEASE}") 27 | } else { 28 | result.notImplemented() 29 | } 30 | } 31 | 32 | override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { 33 | channel.setMethodCallHandler(null) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/feloh/ant_media_flutter/AntMediaFlutterPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.feloh.ant_media_flutter 2 | 3 | import androidx.annotation.NonNull 4 | 5 | import io.flutter.embedding.engine.plugins.FlutterPlugin 6 | import io.flutter.plugin.common.MethodCall 7 | import io.flutter.plugin.common.MethodChannel 8 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler 9 | import io.flutter.plugin.common.MethodChannel.Result 10 | 11 | /** AntMediaFlutterPlugin */ 12 | class AntMediaFlutterPlugin: FlutterPlugin, MethodCallHandler { 13 | /// The MethodChannel that will the communication between Flutter and native Android 14 | /// 15 | /// This local reference serves to register the plugin with the Flutter Engine and unregister it 16 | /// when the Flutter Engine is detached from the Activity 17 | private lateinit var channel : MethodChannel 18 | 19 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { 20 | channel = MethodChannel(flutterPluginBinding.binaryMessenger, "ant_media_flutter") 21 | channel.setMethodCallHandler(this) 22 | } 23 | 24 | override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { 25 | if (call.method == "getPlatformVersion") { 26 | result.success("Android ${android.os.Build.VERSION.RELEASE}") 27 | } else { 28 | result.notImplemented() 29 | } 30 | } 31 | 32 | override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { 33 | channel.setMethodCallHandler(null) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example/SampleProject/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .build/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | .swiftpm/ 13 | migrate_working_dir/ 14 | 15 | # IntelliJ related 16 | *.iml 17 | *.ipr 18 | *.iws 19 | .idea/ 20 | 21 | # The .vscode folder contains launch configuration and tasks you configure in 22 | # VS Code which you may wish to be included in version control, so this line 23 | # is commented out by default. 24 | #.vscode/ 25 | 26 | # Flutter/Dart/Pub related 27 | **/doc/api/ 28 | **/ios/Flutter/.last_build_id 29 | .dart_tool/ 30 | .flutter-plugins 31 | .flutter-plugins-dependencies 32 | .pub-cache/ 33 | .pub/ 34 | /build/ 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Android Studio will place build artifacts here 43 | /android/app/debug 44 | /android/app/profile 45 | /android/app/release 46 | -------------------------------------------------------------------------------- /example/SampleProject/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "17025dd88227cd9532c33fa78f5250d548d87e9a" 8 | channel: "stable" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 17 | base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 18 | - platform: android 19 | create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 20 | base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 21 | - platform: ios 22 | create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 23 | base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 24 | - platform: linux 25 | create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 26 | base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 27 | - platform: macos 28 | create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 29 | base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 30 | - platform: web 31 | create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 32 | base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 33 | - platform: windows 34 | create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 35 | base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /example/SampleProject/README.md: -------------------------------------------------------------------------------- 1 | # ant_media_flutter_example 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/SampleProject/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /example/SampleProject/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/to/reference-keystore 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /example/SampleProject/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id "dev.flutter.flutter-gradle-plugin" 6 | } 7 | 8 | android { 9 | namespace = "com.example.ant_media_flutter_example" 10 | compileSdk = flutter.compileSdkVersion 11 | ndkVersion = flutter.ndkVersion 12 | 13 | compileOptions { 14 | sourceCompatibility = JavaVersion.VERSION_1_8 15 | targetCompatibility = JavaVersion.VERSION_1_8 16 | } 17 | 18 | kotlinOptions { 19 | jvmTarget = JavaVersion.VERSION_1_8 20 | } 21 | 22 | defaultConfig { 23 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 24 | applicationId = "com.example.ant_media_flutter_example" 25 | // You can update the following values to match your application needs. 26 | // For more information, see: https://flutter.dev/to/review-gradle-config. 27 | minSdk = flutter.minSdkVersion 28 | targetSdk = flutter.targetSdkVersion 29 | versionCode = flutter.versionCode 30 | versionName = flutter.versionName 31 | } 32 | 33 | buildTypes { 34 | release { 35 | // TODO: Add your own signing config for the release build. 36 | // Signing with the debug keys for now, so `flutter run --release` works. 37 | signingConfig = signingConfigs.debug 38 | } 39 | } 40 | } 41 | 42 | flutter { 43 | source = "../.." 44 | } 45 | -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 32 | 40 | 44 | 48 | 49 | 50 | 51 | 52 | 53 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/main/kotlin/com/example/ant_media_flutter_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.ant_media_flutter_example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() 6 | -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/SampleProject/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/SampleProject/android/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | rootProject.buildDir = "../build" 9 | subprojects { 10 | project.buildDir = "${rootProject.buildDir}/${project.name}" 11 | } 12 | subprojects { 13 | project.evaluationDependsOn(":app") 14 | } 15 | 16 | tasks.register("clean", Delete) { 17 | delete rootProject.buildDir 18 | } 19 | -------------------------------------------------------------------------------- /example/SampleProject/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/SampleProject/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip 6 | 7 | -------------------------------------------------------------------------------- /example/SampleProject/android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | }() 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 21 | id "com.android.application" version "8.1.0" apply false 22 | id "org.jetbrains.kotlin.android" version "1.8.22" apply false 23 | } 24 | 25 | include ":app" 26 | -------------------------------------------------------------------------------- /example/SampleProject/integration_test/test_conference.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:integration_test/integration_test.dart'; 4 | import 'test_helper.dart'; 5 | 6 | void main() { 7 | // Initialize the integration test bindings. 8 | IntegrationTestWidgetsFlutterBinding.ensureInitialized(); 9 | 10 | testWidgets('Runs the app, taps on the settings icon, enters the URL, and runs the Conference example', (WidgetTester tester) async { 11 | // Launch the app. 12 | await launchApp(tester); 13 | 14 | // Enter the server URL. 15 | await enterServerUrl(tester, 'wss://test.antmedia.io:5443/FlutterCICDtest/websocket'); 16 | 17 | // Tap the 'Conference' button. 18 | await tester.tap(find.text('Conference')); 19 | await tester.pumpAndSettle(const Duration(seconds: 1)); 20 | 21 | // Find the first text field and enter 'test'. 22 | await tester.enterText(find.byType(TextField).at(0), 'test'); 23 | await tester.pumpAndSettle(); 24 | 25 | // Find the second text field and enter 'room'. 26 | await tester.enterText(find.byType(TextField).at(1), 'room'); 27 | await tester.pumpAndSettle(); 28 | 29 | // Tap the 'Connect' button. 30 | await tester.tap(find.text('Connect')); 31 | await tester.pumpAndSettle(const Duration(seconds: 20)); 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /example/SampleProject/integration_test/test_data_channel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:shared_preferences/shared_preferences.dart'; 4 | import 'package:example/main.dart'; 5 | import 'package:integration_test/integration_test.dart'; 6 | 7 | void main() { 8 | // Initialize the integration test bindings. 9 | IntegrationTestWidgetsFlutterBinding.ensureInitialized(); 10 | 11 | testWidgets('Runs the app, taps on the settings icon, enters the URL, and runs the Data Channel example', (WidgetTester tester) async { 12 | // Mock initial values for shared preferences. 13 | SharedPreferences.setMockInitialValues({}); 14 | 15 | // Launch the app. 16 | await tester.pumpWidget(const MaterialApp( 17 | home: Scaffold( 18 | body: MyApp(), 19 | ))); 20 | 21 | // Ensure the app has built. 22 | await tester.pumpAndSettle(); 23 | 24 | // Verify the settings icon is present. 25 | expect(find.byIcon(Icons.settings), findsOneWidget); 26 | 27 | // Tap the settings icon. 28 | await tester.tap(find.byIcon(Icons.settings)); 29 | await tester.pumpAndSettle(); 30 | 31 | // Check if the AlertDialog appears after tapping settings. 32 | expect(find.byType(AlertDialog), findsOneWidget); 33 | 34 | // Enter the server URL in the TextField inside the dialog. 35 | await tester.enterText(find.byType(TextField), 'wss://test.antmedia.io:5443/FlutterCICDtest/websocket'); 36 | await tester.pumpAndSettle(); 37 | 38 | // Ensure the "Set Server Ip" button is present and enabled. 39 | final setServerIpButton = find.widgetWithText(MaterialButton, 'Set Server Ip'); 40 | expect(setServerIpButton, findsOneWidget); 41 | 42 | // Tap the "Set Server Ip" button. 43 | await tester.tap(setServerIpButton); 44 | await tester.pumpAndSettle(); 45 | 46 | // Verify that a SnackBar appears after setting the server IP. 47 | expect(find.byType(SnackBar), findsOneWidget); 48 | 49 | // Tap the 'Conference' button. 50 | await tester.tap(find.text('Data Channel')); 51 | await tester.pumpAndSettle(); 52 | 53 | // Enter Room ID and tap OK. 54 | await tester.enterText(find.byType(TextField), '24x7test'); 55 | await tester.tap(find.text('OK')); 56 | await tester.pumpAndSettle(const Duration(seconds: 5)); 57 | }); 58 | } 59 | -------------------------------------------------------------------------------- /example/SampleProject/integration_test/test_helper.dart: -------------------------------------------------------------------------------- 1 | // test_helper.dart 2 | 3 | import 'dart:io'; 4 | 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_test/flutter_test.dart'; 7 | import 'package:shared_preferences/shared_preferences.dart'; 8 | import 'package:example/main.dart'; 9 | 10 | // A helper method to launch the app. 11 | Future launchApp(WidgetTester tester) async { 12 | 13 | // Mock initial values for shared preferences. 14 | SharedPreferences.setMockInitialValues({}); 15 | 16 | // Launch the app. 17 | await tester.pumpWidget(const MaterialApp( 18 | home: Scaffold( 19 | body: MyApp(), 20 | ), 21 | )); 22 | await tester.pumpAndSettle(); 23 | } 24 | 25 | // A helper method to open settings and enter a server URL. 26 | Future enterServerUrl(WidgetTester tester, String url) async { 27 | // Verify the settings icon is present. 28 | expect(find.byIcon(Icons.settings), findsOneWidget); 29 | 30 | // Tap the settings icon. 31 | await tester.tap(find.byIcon(Icons.settings)); 32 | await tester.pumpAndSettle(); 33 | 34 | // Check if the AlertDialog appears after tapping settings. 35 | expect(find.byType(AlertDialog), findsOneWidget); 36 | 37 | // Enter the server URL in the TextField inside the dialog. 38 | await tester.enterText(find.byType(TextField), url); 39 | await tester.pumpAndSettle(); 40 | 41 | // Tap the "Set Server Ip" button. 42 | final setServerIpButton = find.widgetWithText(MaterialButton, 'Set Server Ip'); 43 | expect(setServerIpButton, findsOneWidget); 44 | await tester.tap(setServerIpButton); 45 | await tester.pumpAndSettle(); 46 | 47 | // Verify that a SnackBar appears after setting the server IP. 48 | expect(find.byType(SnackBar), findsOneWidget); 49 | } 50 | 51 | // A helper method to enter a Room ID and tap OK. 52 | Future enterRoomId(WidgetTester tester, String roomId) async { 53 | await tester.enterText(find.byType(TextField), roomId); 54 | await tester.tap(find.text('OK')); 55 | await tester.pumpAndSettle(); 56 | } -------------------------------------------------------------------------------- /example/SampleProject/integration_test/test_p2p.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:integration_test/integration_test.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:shared_preferences/shared_preferences.dart'; 5 | import 'package:example/main.dart'; 6 | 7 | void main() { 8 | // Initialize the integration test bindings. 9 | IntegrationTestWidgetsFlutterBinding.ensureInitialized(); 10 | 11 | testWidgets('Runs the app, taps on the settings icon, enters the URL, and runs the Peer to Peer example', (WidgetTester tester) async { 12 | // Mock initial values for shared preferences. 13 | SharedPreferences.setMockInitialValues({}); 14 | 15 | // Launch the app. 16 | await tester.pumpWidget(const MaterialApp( 17 | home: Scaffold( 18 | body: MyApp(), 19 | ))); 20 | 21 | // Ensure the app has built. 22 | await tester.pumpAndSettle(); 23 | 24 | // Verify the settings icon is present. 25 | expect(find.byIcon(Icons.settings), findsOneWidget); 26 | 27 | // Tap the settings icon. 28 | await tester.tap(find.byIcon(Icons.settings)); 29 | await tester.pumpAndSettle(); 30 | 31 | // Check if the AlertDialog appears after tapping settings. 32 | expect(find.byType(AlertDialog), findsOneWidget); 33 | 34 | // Enter the server URL in the TextField inside the dialog. 35 | await tester.enterText(find.byType(TextField), 'wss://test.antmedia.io:5443/FlutterCICDtest/websocket'); 36 | await tester.pumpAndSettle(); 37 | 38 | // Ensure the "Set Server Ip" button is present and enabled. 39 | final setServerIpButton = find.widgetWithText(MaterialButton, 'Set Server Ip'); 40 | expect(setServerIpButton, findsOneWidget); 41 | 42 | // Tap the "Set Server Ip" button. 43 | await tester.tap(setServerIpButton); 44 | await tester.pumpAndSettle(); 45 | 46 | // Verify that a SnackBar appears after setting the server IP. 47 | expect(find.byType(SnackBar), findsOneWidget); 48 | 49 | // Tap the 'Conference' button. 50 | await tester.tap(find.text('Peer to Peer')); 51 | await tester.pumpAndSettle(); 52 | 53 | // Enter Room ID and tap OK. 54 | await tester.enterText(find.byType(TextField), 'p2pTest'); 55 | await tester.tap(find.text('OK')); 56 | await tester.pumpAndSettle(const Duration(seconds: 5)); 57 | }); 58 | } 59 | -------------------------------------------------------------------------------- /example/SampleProject/integration_test/test_play.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:flutter_webrtc/flutter_webrtc.dart'; 4 | import 'package:integration_test/integration_test.dart'; 5 | import 'test_helper.dart'; 6 | 7 | void main() { 8 | // Initialize the integration test bindings. 9 | IntegrationTestWidgetsFlutterBinding.ensureInitialized(); 10 | 11 | testWidgets('Runs the app, taps on the settings icon, enters the URL, and runs the play example', (WidgetTester tester) async { 12 | // Launch the app. 13 | await launchApp(tester); 14 | 15 | await tester.pumpAndSettle(); 16 | 17 | // Enter the server URL. 18 | await enterServerUrl(tester, 'wss://test.antmedia.io:5443/24x7test/websocket'); 19 | 20 | await tester.pumpAndSettle(); 21 | 22 | // Tap the 'Play' button. 23 | await tester.tap(find.text('Play')); 24 | await tester.pumpAndSettle(); 25 | 26 | // Enter Room ID and tap OK. 27 | await enterRoomId(tester, '24x7test'); 28 | await tester.pumpAndSettle(); 29 | 30 | const maxWaitTime = Duration(seconds: 120); 31 | final stopwatch = Stopwatch()..start(); 32 | 33 | while (true) { 34 | if (stopwatch.elapsed > maxWaitTime) { 35 | fail('play did not start'); 36 | } 37 | final callEndIcon = find.byIcon(Icons.call_end); 38 | 39 | if(tester.any(callEndIcon)) { 40 | await tester.tap(callEndIcon); 41 | await tester.pumpAndSettle(); 42 | print("test: play started"); 43 | break; 44 | } 45 | await tester.pumpAndSettle(const Duration(seconds: 10)); 46 | } 47 | }); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /example/SampleProject/integration_test/test_publish.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'dart:io'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_test/flutter_test.dart'; 5 | import 'package:integration_test/integration_test.dart'; 6 | import 'package:example/publish.dart'; 7 | import 'test_helper.dart'; 8 | 9 | void main() { 10 | 11 | // Initialize the integration test bindings. 12 | IntegrationTestWidgetsFlutterBinding.ensureInitialized(); 13 | 14 | testWidgets('Runs the app, taps on the settings icon, enters the URL, and runs the Publish example', (WidgetTester tester) async { 15 | // Launch the app. 16 | await launchApp(tester); 17 | 18 | // Enter the server URL. 19 | await enterServerUrl(tester, 'wss://test.antmedia.io:5443/FlutterCICDtest/websocket'); 20 | 21 | // Tap the 'Publish' button. 22 | await tester.tap(find.text('Publish')); 23 | await tester.pumpAndSettle(const Duration(seconds: 2)); 24 | 25 | 26 | // Enter Room ID and tap OK. 27 | await enterRoomId(tester, 'publishTest'); 28 | 29 | // Verify the AlertDialog to choose the publishing source appears. 30 | expect(find.byType(AlertDialog), findsOneWidget); 31 | 32 | // Tap the "Camera" button. 33 | await tester.tap(find.widgetWithText(MaterialButton, 'Camera')); 34 | await tester.pumpAndSettle(const Duration(seconds: 15)); 35 | 36 | // Verify that the Publish screen is loaded. 37 | expect(find.byType(Publish), findsOneWidget); 38 | 39 | // Check if the call_end icon is present and tap it if it appears. 40 | final callEndIcon = find.byIcon(Icons.call_end); 41 | await tester.tap(callEndIcon); 42 | await tester.pumpAndSettle(); 43 | }); 44 | } 45 | -------------------------------------------------------------------------------- /example/SampleProject/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | platform :ios, '13.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | target 'RunnerTests' do 36 | inherit! :search_paths 37 | end 38 | end 39 | 40 | post_install do |installer| 41 | installer.pods_project.targets.each do |target| 42 | flutter_additional_ios_build_settings(target) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | @main 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSMicrophoneUsageDescription 6 | Need microphone access for uploading audio 7 | NSCameraUsageDescription 8 | Need camera access for uploading images 9 | NSBluetoothAlwaysUsageDescription 10 | Our app uses bluetooth to find, connect and transfer data between different devices 11 | CFBundleDevelopmentRegion 12 | $(DEVELOPMENT_LANGUAGE) 13 | CFBundleDisplayName 14 | Ant Media Flutter Example 15 | CFBundleExecutable 16 | $(EXECUTABLE_NAME) 17 | CFBundleIdentifier 18 | $(PRODUCT_BUNDLE_IDENTIFIER) 19 | CFBundleInfoDictionaryVersion 20 | 6.0 21 | CFBundleName 22 | ant_media_flutter_example 23 | CFBundlePackageType 24 | APPL 25 | CFBundleShortVersionString 26 | $(FLUTTER_BUILD_NAME) 27 | CFBundleSignature 28 | ???? 29 | CFBundleVersion 30 | $(FLUTTER_BUILD_NUMBER) 31 | LSRequiresIPhoneOS 32 | 33 | UILaunchStoryboardName 34 | LaunchScreen 35 | UIMainStoryboardFile 36 | Main 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | UISupportedInterfaceOrientations~ipad 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | CADisableMinimumFrameDurationOnPhone 51 | 52 | UIApplicationSupportsIndirectInputEvents 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /example/SampleProject/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/SampleProject/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/SampleProject/lib/conference.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: must_be_immutable, implementation_imports 2 | 3 | import 'dart:convert'; 4 | import 'dart:core'; 5 | 6 | import 'package:ant_media_flutter/ant_media_flutter.dart'; 7 | import 'package:ant_media_flutter/src/utils/conference_widget/playwidget.dart'; 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_webrtc/flutter_webrtc.dart'; 10 | 11 | class Conference extends StatefulWidget { 12 | static String tag = 'call'; 13 | 14 | String ip; 15 | String id; 16 | List> iceServers = [ 17 | {'url': 'stun:stun.l.google.com:19302'}, 18 | ]; 19 | String roomId; 20 | bool userscreen; 21 | 22 | Conference( 23 | {Key? key, 24 | required this.ip, 25 | required this.id, 26 | required this.roomId, 27 | required this.userscreen}) 28 | : super(key: key); 29 | 30 | @override 31 | _ConferenceState createState() => _ConferenceState(); 32 | } 33 | 34 | class _ConferenceState extends State { 35 | final RTCVideoRenderer _localRenderer = RTCVideoRenderer(); 36 | List widgets = []; 37 | bool _inCalling = false; 38 | 39 | _ConferenceState(); 40 | 41 | @override 42 | initState() { 43 | super.initState(); 44 | initRenderers(); 45 | _connect(); 46 | } 47 | 48 | initRenderers() async { 49 | await _localRenderer.initialize(); 50 | } 51 | 52 | @override 53 | deactivate() { 54 | super.deactivate(); 55 | if (AntMediaFlutter.anthelper != null) AntMediaFlutter.anthelper?.close(); 56 | _localRenderer.dispose(); 57 | } 58 | 59 | void _connect() async { 60 | AntMediaFlutter.connect( 61 | //host 62 | widget.ip, 63 | //streamID 64 | widget.id, 65 | //roomID 66 | widget.roomId, 67 | //token 68 | "", 69 | AntMediaType.Conference, 70 | widget.userscreen, 71 | 72 | //onStateChange 73 | (HelperState state) { 74 | switch (state) { 75 | case HelperState.CallStateNew: 76 | setState(() { 77 | _inCalling = true; 78 | }); 79 | break; 80 | case HelperState.CallStateBye: 81 | setState(() { 82 | _localRenderer.srcObject = null; 83 | _inCalling = false; 84 | Navigator.pop(context); 85 | }); 86 | break; 87 | case HelperState.ConnectionOpen: 88 | break; 89 | case HelperState.ConnectionClosed: 90 | break; 91 | case HelperState.ConnectionError: 92 | break; 93 | } 94 | }, 95 | 96 | //onLocalStream 97 | ((stream) { 98 | setState(() { 99 | _localRenderer.srcObject = stream; 100 | }); 101 | }), 102 | 103 | //onAddRemoteStream 104 | ((stream) { 105 | setState(() {}); 106 | }), 107 | 108 | // onDataChannel 109 | (dc) {}, 110 | (dc, message, isReceived) { 111 | try { 112 | JsonDecoder decoder = const JsonDecoder(); 113 | Map map = decoder.convert(message.text); 114 | if (map['eventType'] != "UPDATE_AUDIO_LEVEL") { 115 | print("DataChannelMessage: $map"); 116 | } 117 | } catch (e) { 118 | ScaffoldMessenger.of(context).showSnackBar(SnackBar( 119 | content: Text( 120 | "${isReceived ? "Received:" : "Sent:"} ${message.text}", 121 | style: const TextStyle(color: Colors.white), 122 | ), 123 | backgroundColor: Colors.blue, 124 | )); 125 | } 126 | }, 127 | 128 | //onUpdateConferenceUser 129 | (streams) async { 130 | List widgetlist = []; 131 | 132 | streams.getVideoTracks().forEach((element) async { 133 | MediaStream localStream = 134 | await createLocalMediaStream("${element.hashCode}"); 135 | localStream.addTrack(element); 136 | 137 | widgetlist.add(PlayWidget( 138 | roomMediaStream: localStream, 139 | roomId: widget.roomId, 140 | )); 141 | 142 | setState(() { 143 | widgets = widgetlist; 144 | }); 145 | }); 146 | }, 147 | 148 | //onRemoveRemoteStream 149 | ((stream) { 150 | setState(() {}); 151 | }), 152 | widget.iceServers, 153 | (command, mapData) { 154 | print("Inside conference.dart"); 155 | print("Command: $command"); 156 | print("Data: $mapData"); 157 | }); 158 | } 159 | 160 | _hangUp() { 161 | if (AntMediaFlutter.anthelper != null) { 162 | AntMediaFlutter.anthelper?.bye(); 163 | } 164 | } 165 | 166 | @override 167 | Widget build(BuildContext context) { 168 | return Scaffold( 169 | appBar: AppBar( 170 | title: const Text('Conferencing'), 171 | actions: const [], 172 | ), 173 | floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, 174 | floatingActionButton: _inCalling 175 | ? SizedBox( 176 | width: 200.0, 177 | child: Row( 178 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 179 | children: [ 180 | FloatingActionButton( 181 | heroTag: "btn2", 182 | onPressed: _hangUp, 183 | tooltip: 'Hangup', 184 | child: const Icon(Icons.call_end), 185 | backgroundColor: Colors.pink, 186 | ), 187 | ])) 188 | : null, 189 | body: OrientationBuilder(builder: (context, orientation) { 190 | Widget local = SizedBox( 191 | child: RTCVideoView(_localRenderer), 192 | ); 193 | 194 | List widgetlist = [local] + widgets; 195 | 196 | return GridView( 197 | gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( 198 | crossAxisCount: 2), 199 | children: widgetlist, 200 | ); 201 | })); 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /example/SampleProject/lib/datachannel.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: must_be_immutable, avoid_print 2 | 3 | import 'dart:core'; 4 | import 'package:ant_media_flutter/ant_media_flutter.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_webrtc/flutter_webrtc.dart'; 7 | 8 | class DataChannel extends StatefulWidget { 9 | String ip; 10 | String id; 11 | bool userscreen; 12 | List> iceServers = [ 13 | {'url': 'stun:stun.l.google.com:19302'}, 14 | ]; 15 | 16 | DataChannel( 17 | {Key? key, required this.ip, required this.id, required this.userscreen}) 18 | : super(key: key); 19 | 20 | @override 21 | _DataChannelState createState() => _DataChannelState(); 22 | } 23 | 24 | class _DataChannelState extends State { 25 | final RTCVideoRenderer _localRenderer = RTCVideoRenderer(); 26 | final RTCVideoRenderer _remoteRenderer = RTCVideoRenderer(); 27 | 28 | List messages = []; 29 | 30 | _DataChannelState(); 31 | 32 | @override 33 | initState() { 34 | super.initState(); 35 | initRenderers(); 36 | _connect(); 37 | } 38 | 39 | initRenderers() async { 40 | await _localRenderer.initialize(); 41 | await _remoteRenderer.initialize(); 42 | } 43 | 44 | @override 45 | deactivate() { 46 | super.deactivate(); 47 | if (AntMediaFlutter.anthelper != null) AntMediaFlutter.anthelper?.close(); 48 | _localRenderer.dispose(); 49 | _remoteRenderer.dispose(); 50 | } 51 | 52 | void _connect() async { 53 | AntMediaFlutter.connect( 54 | //host 55 | widget.ip, 56 | 57 | //streamID 58 | widget.id, 59 | 60 | //roomID 61 | '', 62 | 63 | //token 64 | '', 65 | 66 | //type 67 | AntMediaType.DataChannelOnly, 68 | 69 | //userScreen 70 | false, 71 | 72 | //onStateChange 73 | (HelperState state) { 74 | switch (state) { 75 | case HelperState.CallStateNew: 76 | setState(() {}); 77 | break; 78 | case HelperState.CallStateBye: 79 | setState(() { 80 | _localRenderer.srcObject = null; 81 | _remoteRenderer.srcObject = null; 82 | Navigator.pop(context); 83 | }); 84 | break; 85 | 86 | case HelperState.ConnectionClosed: 87 | case HelperState.ConnectionError: 88 | case HelperState.ConnectionOpen: 89 | break; 90 | } 91 | }, 92 | 93 | //onLocalStream 94 | ((stream) { 95 | setState(() { 96 | _remoteRenderer.srcObject = stream; 97 | }); 98 | }), 99 | 100 | //onAddRemoteStream 101 | ((stream) { 102 | setState(() { 103 | _remoteRenderer.srcObject = stream; 104 | }); 105 | }), 106 | 107 | // onDataChannel 108 | (datachannel) { 109 | print(''); 110 | }, 111 | 112 | // onDataChannelMessage 113 | (channel, message, isRecieved) { 114 | messages.add(DataChannelMessage(isRecieved, channel, message)); 115 | setState(() {}); 116 | }, 117 | 118 | // onupdateConferencePerson 119 | (stream) {}, 120 | 121 | //onRemoveRemoteStream 122 | ((stream) { 123 | setState(() { 124 | _remoteRenderer.srcObject = null; 125 | }); 126 | }), 127 | widget.iceServers, 128 | (command, mapData) {}); 129 | } 130 | 131 | @override 132 | Widget build(BuildContext context) { 133 | return Scaffold( 134 | appBar: AppBar( 135 | title: const Text('Data Channel'), 136 | actions: const [], 137 | ), 138 | body: OrientationBuilder( 139 | builder: (context, orientation) { 140 | List textmessages = []; 141 | 142 | for (DataChannelMessage datachannelmessage in messages) { 143 | textmessages.add(Text( 144 | (datachannelmessage.isRecieved ? 'Received: ' : 'Sent: ') + 145 | datachannelmessage.message.text + 146 | ' ', 147 | textAlign: TextAlign.left, 148 | style: const TextStyle( 149 | color: (Colors.black), 150 | fontSize: 22, 151 | ), 152 | )); 153 | } 154 | 155 | return Stack(children: [ 156 | Positioned( 157 | left: 20.0, 158 | bottom: 100.0, 159 | right: 20.0, 160 | top: 20, 161 | child: ListView(children: textmessages)), 162 | Positioned( 163 | left: 20.0, 164 | bottom: 20.0, 165 | child: Container( 166 | margin: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0), 167 | width: MediaQuery.of(context).size.width - 100, 168 | height: 50, 169 | child: textfield, 170 | )), 171 | Positioned( 172 | right: 20.0, 173 | bottom: 20.0, 174 | child: Container( 175 | margin: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0), 176 | width: 50, 177 | height: 50, 178 | child: IconButton( 179 | onPressed: () async { 180 | RTCDataChannelMessage message = RTCDataChannelMessage( 181 | textfield.controller?.text ?? ''); 182 | await AntMediaFlutter.anthelper?.sendMessage(message); 183 | textfield.controller?.clear(); 184 | FocusManager.instance.primaryFocus?.unfocus(); 185 | }, 186 | icon: const Icon(Icons.send), 187 | ), 188 | ), 189 | ) 190 | ]); 191 | }, 192 | )); 193 | } 194 | 195 | TextField textfield = TextField( 196 | controller: TextEditingController(), 197 | decoration: const InputDecoration( 198 | border: OutlineInputBorder(), 199 | hintText: 'Type here....', 200 | fillColor: Colors.white, 201 | ), 202 | ); 203 | } 204 | -------------------------------------------------------------------------------- /example/SampleProject/lib/peer.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: must_be_immutable, non_constant_identifier_names 2 | 3 | import 'dart:core'; 4 | import 'package:ant_media_flutter/ant_media_flutter.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_webrtc/flutter_webrtc.dart'; 7 | 8 | class Peer extends StatefulWidget { 9 | String ip; 10 | String id; 11 | bool userscreen; 12 | List> iceServers = [ 13 | {'url': 'stun:stun.l.google.com:19302'}, 14 | ]; 15 | 16 | Peer({Key? key, required this.ip, required this.id, required this.userscreen}) 17 | : super(key: key); 18 | 19 | @override 20 | _PeerState createState() => _PeerState(); 21 | } 22 | 23 | class _PeerState extends State { 24 | final RTCVideoRenderer _localRenderer = RTCVideoRenderer(); 25 | final RTCVideoRenderer _remoteRenderer = RTCVideoRenderer(); 26 | bool _inCalling = false; 27 | bool _micOn = true; 28 | 29 | MediaStream? local_input_stream; 30 | 31 | _PeerState(); 32 | 33 | @override 34 | initState() { 35 | super.initState(); 36 | initRenderers(); 37 | _connect(); 38 | } 39 | 40 | initRenderers() async { 41 | await _localRenderer.initialize(); 42 | await _remoteRenderer.initialize(); 43 | } 44 | 45 | @override 46 | deactivate() { 47 | super.deactivate(); 48 | if (AntMediaFlutter.anthelper != null) AntMediaFlutter.anthelper?.close(); 49 | _localRenderer.dispose(); 50 | _remoteRenderer.dispose(); 51 | } 52 | 53 | void _connect() async { 54 | AntMediaFlutter.connect( 55 | //host 56 | widget.ip, 57 | //streamID 58 | widget.id, 59 | //roomID 60 | '', 61 | //token 62 | '', 63 | AntMediaType.Peer, 64 | widget.userscreen, 65 | //onStateChange 66 | (HelperState state) { 67 | switch (state) { 68 | case HelperState.CallStateNew: 69 | setState(() { 70 | _inCalling = true; 71 | }); 72 | break; 73 | case HelperState.CallStateBye: 74 | setState(() { 75 | _localRenderer.srcObject = null; 76 | _remoteRenderer.srcObject = null; 77 | _inCalling = false; 78 | Navigator.pop(context); 79 | }); 80 | break; 81 | 82 | case HelperState.ConnectionClosed: 83 | case HelperState.ConnectionError: 84 | case HelperState.ConnectionOpen: 85 | break; 86 | } 87 | }, 88 | 89 | //onLocalStream 90 | ((stream) { 91 | setState(() { 92 | _localRenderer.srcObject = stream; 93 | local_input_stream = stream; 94 | }); 95 | }), 96 | 97 | //onAddRemoteStream 98 | ((stream) { 99 | setState(() { 100 | _remoteRenderer.srcObject = stream; 101 | }); 102 | }), 103 | 104 | // onDataChannel 105 | (dc) {}, 106 | 107 | //onDataChannelMessage 108 | 109 | (dc, message, isReceived) { 110 | ScaffoldMessenger.of(context).showSnackBar(SnackBar( 111 | content: Text( 112 | (isReceived ? "Received:" : "Sent:") + " " + message.text, 113 | style: const TextStyle(color: Colors.white), 114 | ), 115 | backgroundColor: Colors.blue, 116 | )); 117 | }, 118 | 119 | // onupdateConferencePerson 120 | 121 | (Streams) {}, 122 | 123 | //onRemoveRemoteStream 124 | (stream) { 125 | setState(() { 126 | _remoteRenderer.srcObject = null; 127 | }); 128 | }, 129 | widget.iceServers, 130 | (command, mapData) {}); 131 | } 132 | 133 | _hangUp() { 134 | AntMediaFlutter.anthelper?.disconnectPeer(); 135 | } 136 | 137 | _switchCamera() { 138 | AntMediaFlutter.anthelper?.switchCamera(); 139 | } 140 | 141 | _muteMic(bool state) { 142 | if (_micOn) { 143 | setState(() { 144 | AntMediaFlutter.anthelper?.muteMic(true); 145 | _micOn = false; 146 | }); 147 | } else { 148 | setState(() { 149 | AntMediaFlutter.anthelper?.muteMic(false); 150 | _micOn = true; 151 | }); 152 | } 153 | } 154 | 155 | @override 156 | Widget build(BuildContext context) { 157 | return Scaffold( 158 | appBar: AppBar( 159 | title: const Text('Peer to Peer'), 160 | actions: const [], 161 | ), 162 | floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, 163 | floatingActionButton: _inCalling 164 | ? SizedBox( 165 | width: 200.0, 166 | child: Row( 167 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 168 | children: [ 169 | FloatingActionButton( 170 | heroTag: "btn1", 171 | child: const Icon(Icons.switch_camera), 172 | onPressed: _switchCamera, 173 | ), 174 | FloatingActionButton( 175 | heroTag: "btn2", 176 | onPressed: _hangUp, 177 | tooltip: 'Hangup', 178 | child: const Icon(Icons.call_end), 179 | backgroundColor: Colors.pink, 180 | ), 181 | FloatingActionButton( 182 | heroTag: "btn3", 183 | // backgroundColor: _micOn ? null : Theme.of(context).disabledColor, 184 | tooltip: _micOn == true ? 'Stop mic' : 'Start mic', 185 | //onPressed: _micOn==true ? _muteMic(false) : _muteMic(true), 186 | onPressed: () => _muteMic(_micOn), 187 | child: Icon( 188 | _micOn == false ? Icons.mic : Icons.mic_off)), 189 | ])) 190 | : null, 191 | body: OrientationBuilder(builder: (context, orientation) { 192 | return _inCalling 193 | ? Stack(children: [ 194 | Positioned( 195 | left: 0.0, 196 | right: 0.0, 197 | top: 0.0, 198 | bottom: 0.0, 199 | child: Container( 200 | margin: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0), 201 | width: MediaQuery.of(context).size.width, 202 | height: MediaQuery.of(context).size.height, 203 | child: RTCVideoView(_remoteRenderer), 204 | decoration: const BoxDecoration(color: Colors.black54), 205 | )), 206 | Positioned( 207 | right: 20.0, 208 | top: 20.0, 209 | child: Container( 210 | margin: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0), 211 | width: 50, 212 | height: 100, 213 | child: RTCVideoView(_localRenderer), 214 | decoration: const BoxDecoration(color: Colors.black54), 215 | )), 216 | ]) 217 | : Container(); 218 | })); 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /example/SampleProject/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /example/SampleProject/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.13) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "ant_media_flutter_example") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.ant_media_flutter_example") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | # Application build; see runner/CMakeLists.txt. 58 | add_subdirectory("runner") 59 | 60 | # Run the Flutter tool portions of the build. This must not be removed. 61 | add_dependencies(${BINARY_NAME} flutter_assemble) 62 | 63 | # Only the install-generated bundle's copy of the executable will launch 64 | # correctly, since the resources must in the right relative locations. To avoid 65 | # people trying to run the unbundled copy, put it in a subdirectory instead of 66 | # the default top-level location. 67 | set_target_properties(${BINARY_NAME} 68 | PROPERTIES 69 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 70 | ) 71 | 72 | 73 | # Generated plugin build rules, which manage building the plugins and adding 74 | # them to the application. 75 | include(flutter/generated_plugins.cmake) 76 | 77 | 78 | # === Installation === 79 | # By default, "installing" just makes a relocatable bundle in the build 80 | # directory. 81 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 82 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 83 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 84 | endif() 85 | 86 | # Start with a clean build bundle directory every time. 87 | install(CODE " 88 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 89 | " COMPONENT Runtime) 90 | 91 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 92 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 93 | 94 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 95 | COMPONENT Runtime) 96 | 97 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 98 | COMPONENT Runtime) 99 | 100 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 101 | COMPONENT Runtime) 102 | 103 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 104 | install(FILES "${bundled_library}" 105 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 106 | COMPONENT Runtime) 107 | endforeach(bundled_library) 108 | 109 | # Copy the native assets provided by the build.dart from all packages. 110 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") 111 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 112 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 113 | COMPONENT Runtime) 114 | 115 | # Fully re-copy the assets directory on each build to avoid having stale files 116 | # from a previous install. 117 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 118 | install(CODE " 119 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 120 | " COMPONENT Runtime) 121 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 122 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 123 | 124 | # Install the AOT library on non-Debug builds only. 125 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 126 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 127 | COMPONENT Runtime) 128 | endif() 129 | -------------------------------------------------------------------------------- /example/SampleProject/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /example/SampleProject/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) flutter_webrtc_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterWebRTCPlugin"); 14 | flutter_web_r_t_c_plugin_register_with_registrar(flutter_webrtc_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /example/SampleProject/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/SampleProject/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | flutter_webrtc 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /example/SampleProject/linux/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} 10 | "main.cc" 11 | "my_application.cc" 12 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 13 | ) 14 | 15 | # Apply the standard set of build settings. This can be removed for applications 16 | # that need different build settings. 17 | apply_standard_settings(${BINARY_NAME}) 18 | 19 | # Add preprocessor definitions for the application ID. 20 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 21 | 22 | # Add dependency libraries. Add any application-specific dependencies here. 23 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 24 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 25 | 26 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 27 | -------------------------------------------------------------------------------- /example/SampleProject/linux/runner/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /example/SampleProject/linux/runner/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "ant_media_flutter_example"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "ant_media_flutter_example"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GApplication::startup. 85 | static void my_application_startup(GApplication* application) { 86 | //MyApplication* self = MY_APPLICATION(object); 87 | 88 | // Perform any actions required at application startup. 89 | 90 | G_APPLICATION_CLASS(my_application_parent_class)->startup(application); 91 | } 92 | 93 | // Implements GApplication::shutdown. 94 | static void my_application_shutdown(GApplication* application) { 95 | //MyApplication* self = MY_APPLICATION(object); 96 | 97 | // Perform any actions required at application shutdown. 98 | 99 | G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); 100 | } 101 | 102 | // Implements GObject::dispose. 103 | static void my_application_dispose(GObject* object) { 104 | MyApplication* self = MY_APPLICATION(object); 105 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 106 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 107 | } 108 | 109 | static void my_application_class_init(MyApplicationClass* klass) { 110 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 111 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 112 | G_APPLICATION_CLASS(klass)->startup = my_application_startup; 113 | G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; 114 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 115 | } 116 | 117 | static void my_application_init(MyApplication* self) {} 118 | 119 | MyApplication* my_application_new() { 120 | // Set the program name to the application ID, which helps various systems 121 | // like GTK and desktop environments map this running application to its 122 | // corresponding .desktop file. This ensures better integration by allowing 123 | // the application to be recognized beyond its binary name. 124 | g_set_prgname(APPLICATION_ID); 125 | 126 | return MY_APPLICATION(g_object_new(my_application_get_type(), 127 | "application-id", APPLICATION_ID, 128 | "flags", G_APPLICATION_NON_UNIQUE, 129 | nullptr)); 130 | } 131 | -------------------------------------------------------------------------------- /example/SampleProject/linux/runner/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /example/SampleProject/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import flutter_webrtc 9 | import path_provider_macos 10 | import patrol 11 | import shared_preferences_macos 12 | 13 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 14 | FlutterWebRTCPlugin.register(with: registry.registrar(forPlugin: "FlutterWebRTCPlugin")) 15 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 16 | PatrolPlugin.register(with: registry.registrar(forPlugin: "PatrolPlugin")) 17 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 18 | } 19 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @main 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | 10 | override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { 11 | return true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = ant_media_flutter_example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.antMediaFlutterExample 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2025 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/SampleProject/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/SampleProject/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/SampleProject/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: Demonstrates how to use the ant_media_flutter plugin. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | # In Windows, build-name is used as the major, minor, and patch parts 19 | # of the product and file versions while build-number is used as the build suffix. 20 | version: 1.0.0+1 21 | 22 | environment: 23 | sdk: '>=3.0.6 <4.0.0' 24 | 25 | # Dependencies specify other packages that your package needs in order to work. 26 | # To automatically upgrade your package dependencies to the latest versions 27 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 28 | # dependencies can be manually updated by changing the version numbers below to 29 | # the latest version available on pub.dev. To see which dependencies have newer 30 | # versions available, run `flutter pub outdated`. 31 | dependencies: 32 | flutter: 33 | sdk: flutter 34 | 35 | file: ^7.0.0 36 | get: ^4.6.1 37 | flutter_webrtc: ^0.12.9 38 | permission_handler: ^11.0.0 39 | shared_preferences: ^2.0.15 40 | shared_preferences_macos: ^2.0.4 41 | shared_preferences_web: ^2.0.4 42 | http: ^1.1.2 43 | path_provider: ^2.0.11 44 | path_provider_macos: ^2.0.6 45 | flutter_background: ^1.1.0 46 | 47 | ant_media_flutter: 48 | # When depending on this package from a real application you should use: 49 | # ant_media_flutter: ^x.y.z 50 | # See https://dart.dev/tools/pub/dependencies#version-constraints 51 | # The example app is bundled with the plugin so we use a path dependency on 52 | # the parent directory to use the current plugin's version. 53 | path: ../../ 54 | 55 | # The following adds the Cupertino Icons font to your application. 56 | # Use with the CupertinoIcons class for iOS style icons. 57 | cupertino_icons: ^1.0.2 58 | universal_io: ^2.2.0 59 | fluttertoast: ^8.2.8 60 | 61 | dev_dependencies: 62 | flutter_test: 63 | sdk: flutter 64 | 65 | flutter_lints: ^2.0.0 66 | patrol: ^3.11.0 67 | 68 | 69 | flutter: 70 | uses-material-design: true 71 | 72 | patrol: 73 | app_name: My App 74 | android: 75 | package_name: com.example.ant_media_flutter_example 76 | ios: 77 | bundle_id: com.example.antMediaFlutterExample 78 | macos: 79 | bundle_id: com.example.macos.antMediaFlutterExample 80 | -------------------------------------------------------------------------------- /example/SampleProject/test/test_play.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/main.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_test/flutter_test.dart'; 4 | import 'package:shared_preferences/shared_preferences.dart'; 5 | 6 | void main() { 7 | testWidgets('Runs the app, taps on the settings icon, and enters the URL, then runs the play example', 8 | (WidgetTester tester) async { 9 | 10 | // Mock initial values for shared preferences. 11 | SharedPreferences.setMockInitialValues({}); 12 | 13 | // Pump the MyApp widget inside a MaterialApp and Scaffold. 14 | await tester.pumpWidget(const MaterialApp( 15 | home: Scaffold( 16 | body: MyApp(), 17 | ))); 18 | 19 | // Verify the settings icon is present on the screen. 20 | expect(find.byIcon(Icons.settings), findsOneWidget); 21 | 22 | // Log the number of settings icons found in the UI. 23 | print("Number of settings icons found: ${find.byIcon(Icons.settings).evaluate().length}"); 24 | 25 | // Tap the settings icon and wait for the app to settle. 26 | await tester.tap(find.byIcon(Icons.settings)); 27 | await tester.pumpAndSettle(); 28 | 29 | // Verify that an AlertDialog appears after tapping the settings icon. 30 | expect(find.byType(AlertDialog), findsOneWidget); 31 | 32 | // Find the TextField inside the dialog and enter the server URL. 33 | final Finder textFieldFinder = find.byType(TextField); 34 | await tester.enterText( 35 | textFieldFinder, 'wss://test.antmedia.io:5443/24x7test/websocket'); 36 | 37 | // Verify that the "Set Server Ip" button is present and enabled. 38 | expect( 39 | find.widgetWithText(MaterialButton, 'Set Server Ip'), findsOneWidget); 40 | expect( 41 | find 42 | .widgetWithText(MaterialButton, 'Set Server Ip') 43 | .evaluate() 44 | .first 45 | .widget, 46 | isA().having((b) => b.enabled, 'enabled', true)); 47 | 48 | // Locate the "Set Server Ip" button and tap it. 49 | final Finder setServerIpButtonFinder = 50 | find.widgetWithText(MaterialButton, 'Set Server Ip'); 51 | expect(setServerIpButtonFinder, findsOneWidget); 52 | await tester.pumpAndSettle(); 53 | 54 | // Tap the button and wait for the app to settle. 55 | await tester.runAsync(() async => tester.tap(setServerIpButtonFinder)); 56 | await tester.runAsync(() async => tester.pumpAndSettle()); 57 | 58 | // Verify that a SnackBar appears after setting the server IP. 59 | expect(find.byType(SnackBar), findsOneWidget); 60 | 61 | // Ensure the 'Play' text is in the widget tree. 62 | expect(find.text('Play'), findsOneWidget); 63 | 64 | // Tap the 'Play' button. 65 | await tester.tap(find.text('Play')); 66 | 67 | // Log that the Play button was tapped. 68 | print("Tapped Play button"); 69 | 70 | // Rebuild the widget after the tap. 71 | await tester.pumpAndSettle(); 72 | 73 | // Check if the Room ID dialog is displayed (this is part of the navigation flow). 74 | expect(find.text("Enter Room ID"), findsOneWidget); 75 | 76 | // Enter a Room ID in the TextField. 77 | await tester.enterText(find.byType(TextField), '24x7test'); 78 | 79 | // Tap the 'OK' button to confirm the Room ID. 80 | await tester.tap(find.text('OK')); 81 | 82 | // Rebuild the widget after the dialog is closed. 83 | await tester.pumpAndSettle(); 84 | }); 85 | } 86 | -------------------------------------------------------------------------------- /example/SampleProject/test/test_publish.dart: -------------------------------------------------------------------------------- 1 | import 'package:example/publish.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:shared_preferences/shared_preferences.dart'; 5 | import 'package:example/main.dart'; 6 | 7 | void main() { 8 | testWidgets('Runs the app, taps on the settings icon, enters the URL, and runs the Publish example', (WidgetTester tester) async { 9 | // Mock initial values for shared preferences. 10 | SharedPreferences.setMockInitialValues({}); 11 | 12 | // Launch the app. 13 | await tester.pumpWidget(const MaterialApp( 14 | home: Scaffold( 15 | body: MyApp(), 16 | ))); 17 | 18 | // Ensure the app has built. 19 | await tester.pumpAndSettle(); 20 | 21 | // Verify the settings icon is present. 22 | expect(find.byIcon(Icons.settings), findsOneWidget); 23 | 24 | // Tap the settings icon. 25 | await tester.tap(find.byIcon(Icons.settings)); 26 | await tester.pumpAndSettle(); 27 | 28 | // Check if the AlertDialog appears after tapping settings. 29 | expect(find.byType(AlertDialog), findsOneWidget); 30 | 31 | // Enter the server URL in the TextField inside the dialog. 32 | await tester.enterText(find.byType(TextField), 'wss://test.antmedia.io:5443/24x7test/websocket'); 33 | await tester.pumpAndSettle(); 34 | 35 | // Ensure the "Set Server Ip" button is present and enabled. 36 | final setServerIpButton = find.widgetWithText(MaterialButton, 'Set Server Ip'); 37 | expect(setServerIpButton, findsOneWidget); 38 | 39 | // Tap the "Set Server Ip" button. 40 | await tester.tap(setServerIpButton); 41 | await tester.pumpAndSettle(const Duration(seconds: 1)); 42 | 43 | // Verify that a SnackBar appears after setting the server IP. 44 | expect(find.byType(SnackBar), findsOneWidget); 45 | 46 | // Tap the 'Publish' button. 47 | await tester.tap(find.text('Publish')); 48 | await tester.pumpAndSettle(const Duration(seconds: 1)); 49 | 50 | // Enter Room ID and tap OK. 51 | await tester.enterText(find.byType(TextField), 'publishTest'); 52 | await tester.tap(find.text('OK')); 53 | await tester.pumpAndSettle(const Duration(seconds: 1)); 54 | 55 | // Check if the AlertDialog to choose the publishing source appears. 56 | expect(find.byType(AlertDialog), findsOneWidget); 57 | 58 | // Tap the "Camera" button. 59 | await tester.tap(find.widgetWithText(MaterialButton, 'Camera')); 60 | await tester.pumpAndSettle(const Duration(seconds: 4)); 61 | 62 | // Verify that the Publish screen is loaded. 63 | expect(find.byType(Publish), findsOneWidget); 64 | 65 | await tester.pumpAndSettle(); 66 | }); 67 | } -------------------------------------------------------------------------------- /example/SampleProject/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:ant_media_flutter_example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /example/SampleProject/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/web/favicon.png -------------------------------------------------------------------------------- /example/SampleProject/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/SampleProject/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/SampleProject/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/SampleProject/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/SampleProject/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | ant_media_flutter_example 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /example/SampleProject/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ant_media_flutter_example", 3 | "short_name": "ant_media_flutter_example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /example/SampleProject/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /example/SampleProject/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(ant_media_flutter_example LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "ant_media_flutter_example") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(VERSION 3.14...3.25) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Copy the native assets provided by the build.dart from all packages. 91 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") 92 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 93 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 94 | COMPONENT Runtime) 95 | 96 | # Fully re-copy the assets directory on each build to avoid having stale files 97 | # from a previous install. 98 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 99 | install(CODE " 100 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 101 | " COMPONENT Runtime) 102 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 103 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 104 | 105 | # Install the AOT library on non-Debug builds only. 106 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 107 | CONFIGURATIONS Profile;Release 108 | COMPONENT Runtime) 109 | -------------------------------------------------------------------------------- /example/SampleProject/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # Set fallback configurations for older versions of the flutter tool. 14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 16 | endif() 17 | 18 | # === Flutter Library === 19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 | 21 | # Published to parent scope for install step. 22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 | 27 | list(APPEND FLUTTER_LIBRARY_HEADERS 28 | "flutter_export.h" 29 | "flutter_windows.h" 30 | "flutter_messenger.h" 31 | "flutter_plugin_registrar.h" 32 | "flutter_texture_registrar.h" 33 | ) 34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35 | add_library(flutter INTERFACE) 36 | target_include_directories(flutter INTERFACE 37 | "${EPHEMERAL_DIR}" 38 | ) 39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40 | add_dependencies(flutter flutter_assemble) 41 | 42 | # === Wrapper === 43 | list(APPEND CPP_WRAPPER_SOURCES_CORE 44 | "core_implementations.cc" 45 | "standard_codec.cc" 46 | ) 47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 | "plugin_registrar.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52 | list(APPEND CPP_WRAPPER_SOURCES_APP 53 | "flutter_engine.cc" 54 | "flutter_view_controller.cc" 55 | ) 56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 | 58 | # Wrapper sources needed for a plugin. 59 | add_library(flutter_wrapper_plugin STATIC 60 | ${CPP_WRAPPER_SOURCES_CORE} 61 | ${CPP_WRAPPER_SOURCES_PLUGIN} 62 | ) 63 | apply_standard_settings(flutter_wrapper_plugin) 64 | set_target_properties(flutter_wrapper_plugin PROPERTIES 65 | POSITION_INDEPENDENT_CODE ON) 66 | set_target_properties(flutter_wrapper_plugin PROPERTIES 67 | CXX_VISIBILITY_PRESET hidden) 68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69 | target_include_directories(flutter_wrapper_plugin PUBLIC 70 | "${WRAPPER_ROOT}/include" 71 | ) 72 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 | 74 | # Wrapper sources needed for the runner. 75 | add_library(flutter_wrapper_app STATIC 76 | ${CPP_WRAPPER_SOURCES_CORE} 77 | ${CPP_WRAPPER_SOURCES_APP} 78 | ) 79 | apply_standard_settings(flutter_wrapper_app) 80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81 | target_include_directories(flutter_wrapper_app PUBLIC 82 | "${WRAPPER_ROOT}/include" 83 | ) 84 | add_dependencies(flutter_wrapper_app flutter_assemble) 85 | 86 | # === Flutter tool backend === 87 | # _phony_ is a non-existent file to force this command to run every time, 88 | # since currently there's no way to get a full input/output list from the 89 | # flutter tool. 90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92 | add_custom_command( 93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 95 | ${CPP_WRAPPER_SOURCES_APP} 96 | ${PHONY_OUTPUT} 97 | COMMAND ${CMAKE_COMMAND} -E env 98 | ${FLUTTER_TOOL_ENVIRONMENT} 99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 100 | ${FLUTTER_TARGET_PLATFORM} $ 101 | VERBATIM 102 | ) 103 | add_custom_target(flutter_assemble DEPENDS 104 | "${FLUTTER_LIBRARY}" 105 | ${FLUTTER_LIBRARY_HEADERS} 106 | ${CPP_WRAPPER_SOURCES_CORE} 107 | ${CPP_WRAPPER_SOURCES_PLUGIN} 108 | ${CPP_WRAPPER_SOURCES_APP} 109 | ) 110 | -------------------------------------------------------------------------------- /example/SampleProject/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void RegisterPlugins(flutter::PluginRegistry* registry) { 13 | FlutterWebRTCPluginRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("FlutterWebRTCPlugin")); 15 | PermissionHandlerWindowsPluginRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); 17 | } 18 | -------------------------------------------------------------------------------- /example/SampleProject/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/SampleProject/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | flutter_webrtc 7 | permission_handler_windows 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /example/SampleProject/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /example/SampleProject/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "ant_media_flutter_example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "ant_media_flutter_example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2025 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "ant_media_flutter_example.exe" "\0" 98 | VALUE "ProductName", "ant_media_flutter_example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /example/SampleProject/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /example/SampleProject/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /example/SampleProject/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"ant_media_flutter_example", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /example/SampleProject/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /example/SampleProject/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/example/SampleProject/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/SampleProject/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example/SampleProject/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | unsigned int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length == 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /example/SampleProject/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /example/SampleProject/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | -------------------------------------------------------------------------------- /images/README.md: -------------------------------------------------------------------------------- 1 | In App pictures of the WebRTC Flutter SDK 2 | -------------------------------------------------------------------------------- /images/flutter_sdk_inapp_0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/images/flutter_sdk_inapp_0.jpeg -------------------------------------------------------------------------------- /images/flutter_sdk_inapp_1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/images/flutter_sdk_inapp_1.jpeg -------------------------------------------------------------------------------- /images/flutter_sdk_inapp_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/images/flutter_sdk_inapp_2.jpg -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | /Flutter/ephemeral/ 38 | /Flutter/flutter_export_environment.sh -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-media/WebRTC-Flutter-SDK/02e0967d87e19b9945f6d3f6a114b788c1490b49/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/AntMediaFlutterPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface AntMediaFlutterPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /ios/Classes/AntMediaFlutterPlugin.m: -------------------------------------------------------------------------------- 1 | #import "AntMediaFlutterPlugin.h" 2 | #if __has_include() 3 | #import 4 | #else 5 | // Support project import fallback if the generated compatibility header 6 | // is not copied when this plugin is created as a library. 7 | // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 8 | #import "ant_media_flutter-Swift.h" 9 | #endif 10 | 11 | @implementation AntMediaFlutterPlugin 12 | + (void)registerWithRegistrar:(NSObject*)registrar { 13 | [SwiftAntMediaFlutterPlugin registerWithRegistrar:registrar]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /ios/Classes/SwiftAntMediaFlutterPlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | public class SwiftAntMediaFlutterPlugin: NSObject, FlutterPlugin { 5 | public static func register(with registrar: FlutterPluginRegistrar) { 6 | let channel = FlutterMethodChannel(name: "ant_media_flutter", binaryMessenger: registrar.messenger()) 7 | let instance = SwiftAntMediaFlutterPlugin() 8 | registrar.addMethodCallDelegate(instance, channel: channel) 9 | } 10 | 11 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 12 | result("iOS " + UIDevice.current.systemVersion) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ios/ant_media_flutter.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint ant_media_flutter.podspec` to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'ant_media_flutter' 7 | s.version = '0.0.1' 8 | s.summary = 'A new flutter plugin project.' 9 | s.description = <<-DESC 10 | A new flutter plugin project. 11 | DESC 12 | s.homepage = 'http://example.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Your Company' => 'email@example.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'Classes/**/*' 17 | s.dependency 'Flutter' 18 | s.platform = :ios, '9.0' 19 | 20 | # Flutter.framework does not contain a i386 slice. 21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } 22 | s.swift_version = '5.0' 23 | end 24 | -------------------------------------------------------------------------------- /lib/ant_media_flutter.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: prefer_generic_function_type_aliases, constant_identifier_names 2 | 3 | import 'dart:async'; 4 | 5 | import 'package:ant_media_flutter/src/helpers/helper.dart'; 6 | import 'package:flutter/foundation.dart'; 7 | import 'package:flutter_background/flutter_background.dart'; 8 | import 'package:flutter_webrtc/flutter_webrtc.dart'; 9 | import 'package:permission_handler/permission_handler.dart'; 10 | 11 | // HelperState is used to determine the state of the websocket connection between the device and the Ant Media Server 12 | enum HelperState { 13 | CallStateNew, 14 | CallStateBye, 15 | ConnectionOpen, 16 | ConnectionClosed, 17 | ConnectionError, 18 | } 19 | 20 | // AntMedia Media Types is used to determine different modes of Ant Media Server 21 | enum AntMediaType { Default, Publish, Play, Peer, Conference, DataChannelOnly } 22 | 23 | typedef void HelperStateCallback(HelperState state); 24 | typedef void StreamStateCallback(MediaStream stream); 25 | typedef void OtherEventCallback(dynamic event); 26 | typedef void DataChannelMessageCallback( 27 | RTCDataChannel dc, RTCDataChannelMessage data, bool isReceived); 28 | typedef void DataChannelCallback(RTCDataChannel dc); 29 | typedef void ConferenceUpdateCallback(dynamic streams); 30 | typedef void Callbacks(String command, Map mapData); 31 | 32 | class DataChannelMessage extends Object { 33 | RTCDataChannelMessage message; 34 | bool isRecieved; 35 | RTCDataChannel channel; 36 | DataChannelMessage(this.isRecieved, this.channel, this.message); 37 | } 38 | 39 | class AntMediaFlutter { 40 | static AntHelper? anthelper; 41 | 42 | // requestPermissions is used to request permissions for camera, microphone and bluetoothConnect 43 | static void requestPermissions() { 44 | Permission.camera 45 | .request() 46 | .then((value) => Permission.microphone.request().then((value) => { 47 | if (value.isGranted && !kIsWeb) 48 | {Permission.bluetoothConnect.request().then((value) => null)} 49 | })); 50 | } 51 | 52 | // startForegroundService is used to start the background service for the app 53 | // it should be called on the Android platform 54 | static Future startForegroundService() async { 55 | const androidConfig = FlutterBackgroundAndroidConfig( 56 | notificationTitle: 'Title of the notification', 57 | notificationText: 'Text of the notification', 58 | notificationIcon: 59 | AndroidResource(name: 'background_icon', defType: 'drawable'), 60 | ); 61 | try { 62 | await FlutterBackground.initialize(androidConfig: androidConfig); 63 | try { 64 | await FlutterBackground.enableBackgroundExecution(); 65 | } catch (e) { 66 | } 67 | 68 | bool initialized = await FlutterBackground.initialize(androidConfig: androidConfig); 69 | if (initialized) { 70 | await FlutterBackground.enableBackgroundExecution(); 71 | return true; 72 | } else { 73 | print('Error: FlutterBackground not initialized'); 74 | return false; 75 | } 76 | } catch (e) { 77 | print('Error initializing FlutterBackground: $e'); 78 | return false; 79 | } 80 | } 81 | 82 | // connect is the entry point for the plugin 83 | // it is used to connect to the Ant Media Server 84 | static void connect( 85 | String ip, 86 | String streamId, 87 | String roomId, 88 | String token, 89 | AntMediaType type, 90 | bool userScreen, 91 | HelperStateCallback onStateChange, 92 | StreamStateCallback onLocalStream, 93 | StreamStateCallback onAddRemoteStream, 94 | DataChannelCallback onDataChannel, 95 | DataChannelMessageCallback onDataChannelMessage, 96 | ConferenceUpdateCallback onupdateConferencePerson, 97 | StreamStateCallback onRemoveRemoteStream, 98 | List> iceServers, 99 | Callbacks callbacks) async { 100 | anthelper = null; 101 | anthelper ??= AntHelper( 102 | // automatically start the service 103 | true, 104 | 105 | //host 106 | ip, 107 | 108 | //streamID 109 | streamId, 110 | 111 | //roomID 112 | roomId, 113 | 114 | //token 115 | token, 116 | 117 | //onStateChange 118 | onStateChange, 119 | 120 | //onAddRemoteStream 121 | onAddRemoteStream, 122 | 123 | //onDataChannel 124 | onDataChannel, 125 | 126 | //onDataChannelMessage 127 | onDataChannelMessage, 128 | 129 | //onLocalStream 130 | onLocalStream, 131 | 132 | //onRemoveRemoteStream 133 | onRemoveRemoteStream, 134 | 135 | //ScreenSharing 136 | userScreen, 137 | 138 | // onupdateConferencePerson 139 | onupdateConferencePerson, 140 | 141 | //iceServers 142 | iceServers, 143 | 144 | //callbacks 145 | callbacks) 146 | ..connect(type); 147 | } 148 | 149 | // prepare is the entry point for the plugin 150 | static void prepare( 151 | String ip, 152 | String streamId, 153 | String roomId, 154 | String token, 155 | AntMediaType type, 156 | bool userScreen, 157 | HelperStateCallback onStateChange, 158 | StreamStateCallback onLocalStream, 159 | StreamStateCallback onAddRemoteStream, 160 | DataChannelCallback onDataChannel, 161 | DataChannelMessageCallback onDataChannelMessage, 162 | ConferenceUpdateCallback onupdateConferencePerson, 163 | StreamStateCallback onRemoveRemoteStream, 164 | List> iceServers, 165 | Callbacks callbacks) async { 166 | anthelper = null; 167 | anthelper ??= AntHelper( 168 | // automatically start the service 169 | false, 170 | 171 | //host 172 | ip, 173 | 174 | //streamID 175 | streamId, 176 | 177 | //roomID 178 | roomId, 179 | 180 | //token 181 | token, 182 | 183 | //onStateChange 184 | onStateChange, 185 | 186 | //onAddRemoteStream 187 | onAddRemoteStream, 188 | 189 | //onDataChannel 190 | onDataChannel, 191 | 192 | //onDataChannelMessage 193 | onDataChannelMessage, 194 | 195 | //onLocalStream 196 | onLocalStream, 197 | 198 | //onRemoveRemoteStream 199 | onRemoveRemoteStream, 200 | 201 | //ScreenSharing 202 | userScreen, 203 | 204 | // onupdateConferencePerson 205 | onupdateConferencePerson, 206 | 207 | //iceServers 208 | iceServers, 209 | 210 | //callbacks 211 | callbacks) 212 | ..connect(type); 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /lib/ant_media_flutter_web.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: prefer_generic_function_type_aliases, constant_identifier_names 2 | 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter_web_plugins/flutter_web_plugins.dart'; 5 | 6 | import 'ant_media_flutter.dart'; 7 | 8 | /// A web implementation of the AntMediaFlutter plugin. 9 | class AntMediaFlutterWebPlugin { 10 | static void registerWith(Registrar registrar) { 11 | // ignore: unused_local_variable 12 | final MethodChannel channel = MethodChannel( 13 | 'com.ant_media_flutter/ant_media_flutter', 14 | const StandardMethodCodec(), 15 | registrar, // the registrar is used as the BinaryMessenger 16 | ); 17 | // ignore: unused_local_variable 18 | final AntMediaFlutter instance = AntMediaFlutter(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/src/utils/conference_widget/playwidget.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: must_be_immutable non_constant_identifier_names, unnecessary_this, curly_braces_in_flow_control_structures, unnecessary_new, avoid_print, prefer_const_constructors, constant_identifier_names, prefer_collection_literals, prefer_generic_function_type_aliases, prefer_final_fields, unnecessary_string_interpolations, prefer_interpolation_to_compose_strings 2 | 3 | import 'dart:core'; 4 | 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_webrtc/flutter_webrtc.dart'; 7 | 8 | class PlayWidget extends StatefulWidget { 9 | final MediaStream roomMediaStream; 10 | final String roomId; 11 | 12 | const PlayWidget( 13 | {Key? key, required this.roomMediaStream, required this.roomId}) 14 | : super(key: key); 15 | 16 | @override 17 | PlayWidgetState createState() => PlayWidgetState(); 18 | } 19 | 20 | class PlayWidgetState extends State { 21 | final RTCVideoRenderer _remoteRenderer = RTCVideoRenderer(); 22 | 23 | @override 24 | void initState() { 25 | super.initState(); 26 | initRenderer(); 27 | } 28 | 29 | Future initRenderer() async { 30 | await _remoteRenderer.initialize(); 31 | print('initRenderer'); 32 | print(widget.roomMediaStream); 33 | _remoteRenderer.srcObject = widget.roomMediaStream; 34 | setState(() {}); 35 | } 36 | 37 | @override 38 | void deactivate() { 39 | _remoteRenderer.dispose(); 40 | super.deactivate(); 41 | } 42 | 43 | @override 44 | Widget build(BuildContext context) { 45 | return Positioned( 46 | child: Container( 47 | margin: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0), 48 | width: MediaQuery.of(context).size.width, 49 | height: MediaQuery.of(context).size.height, 50 | decoration: const BoxDecoration( 51 | color: Colors.blue, 52 | ), 53 | child: RTCVideoView( 54 | _remoteRenderer, 55 | objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover, 56 | placeholderBuilder: (BuildContext context) { 57 | return const Center( 58 | child: CircularProgressIndicator(), 59 | ); 60 | }, 61 | ), 62 | ), 63 | ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /lib/src/utils/websocket.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: unnecessary_this 2 | 3 | import 'dart:io'; 4 | import 'package:flutter/foundation.dart'; 5 | 6 | typedef OnMessageCallback = void Function(dynamic msg); 7 | typedef OnCloseCallback = void Function(int code, String reason); 8 | typedef OnOpenCallback = void Function(); 9 | 10 | class SimpleWebSocket { 11 | final String _url; 12 | WebSocket? _socket; 13 | OnOpenCallback? onOpen; 14 | OnMessageCallback? onMessage; 15 | OnCloseCallback? onClose; 16 | 17 | SimpleWebSocket(this._url); 18 | 19 | connect() async { 20 | try { 21 | _socket = await WebSocket.connect(_url); 22 | //_socket = await _connectForSelfSignedCert(_url); 23 | 24 | if (this.onOpen != null) { 25 | this.onOpen!(); 26 | } 27 | 28 | _socket!.listen((data) { 29 | if (this.onMessage != null) { 30 | this.onMessage!(data); 31 | } 32 | }, onDone: () { 33 | if (this.onClose != null) { 34 | this.onClose!(_socket!.closeCode!, _socket!.closeReason!); 35 | } 36 | }); 37 | } catch (e) { 38 | if (this.onClose != null) { 39 | this.onClose!(500, e.toString()); 40 | } 41 | } 42 | } 43 | 44 | void send(data) { 45 | if (_socket != null) { 46 | _socket!.add(data); 47 | if (kDebugMode) { 48 | print('send: $data'); 49 | } 50 | } 51 | } 52 | 53 | close() { 54 | if (_socket != null) _socket!.close(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/src/utils/websocket_web.dart: -------------------------------------------------------------------------------- 1 | // ignore: avoid_web_libraries_in_flutter 2 | import 'dart:html'; 3 | import 'package:flutter/foundation.dart'; 4 | 5 | class SimpleWebSocket { 6 | String _url; 7 | WebSocket? _socket; 8 | Function()? onOpen; 9 | Function(dynamic msg)? onMessage; 10 | Function(int code, String reason)? onClose; 11 | 12 | SimpleWebSocket(this._url) { 13 | _url = _url.replaceAll('https:', 'wss:'); 14 | } 15 | 16 | connect() async { 17 | try { 18 | _socket = WebSocket(_url); 19 | _socket!.onOpen.listen((e) { 20 | onOpen?.call(); 21 | }); 22 | 23 | _socket!.onMessage.listen((e) { 24 | onMessage?.call(e.data); 25 | }); 26 | 27 | _socket!.onClose.listen((e) { 28 | onClose?.call(e.code!, e.reason!); 29 | }); 30 | } catch (e) { 31 | onClose?.call(500, e.toString()); 32 | } 33 | } 34 | 35 | send(data) { 36 | if (_socket != null && _socket!.readyState == WebSocket.OPEN) { 37 | _socket!.send(data); 38 | if (kDebugMode) { 39 | print('send: $data'); 40 | } 41 | } else { 42 | if (kDebugMode) { 43 | print('WebSocket not connected, message $data not sent'); 44 | } 45 | } 46 | } 47 | 48 | close() { 49 | if (_socket != null) { 50 | _socket!.close(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /pub_login.sh: -------------------------------------------------------------------------------- 1 | # This script creates/updates credentials.json file which is used 2 | # to authorize publisher when publishing packages to pub.dev 3 | 4 | # Checking whether the secrets are available as environment 5 | # variables or not. 6 | if [ -z "${PUB_DEV_PUBLISH_ACCESS_TOKEN}" ]; then 7 | echo "Missing PUB_DEV_PUBLISH_ACCESS_TOKEN environment variable" 8 | exit 1 9 | fi 10 | 11 | if [ -z "${PUB_DEV_PUBLISH_REFRESH_TOKEN}" ]; then 12 | echo "Missing PUB_DEV_PUBLISH_REFRESH_TOKEN environment variable" 13 | exit 1 14 | fi 15 | 16 | if [ -z "${PUB_DEV_PUBLISH_TOKEN_ENDPOINT}" ]; then 17 | echo "Missing PUB_DEV_PUBLISH_TOKEN_ENDPOINT environment variable" 18 | exit 1 19 | fi 20 | 21 | if [ -z "${PUB_DEV_PUBLISH_EXPIRATION}" ]; then 22 | echo "Missing PUB_DEV_PUBLISH_EXPIRATION environment variable" 23 | exit 1 24 | fi 25 | 26 | # Create credentials.json file. 27 | echo "Copy credentials" 28 | mkdir -p $HOME/.config/dart/ 29 | # chmod 777 $HOME/.config/dart/ 30 | # echo "$CREDENTIAL_JSON" > ~/.pub-cache/credentials.json 31 | # CREDENTIAL_JSON="secrets.CREDENTIAL_JSON" 32 | cat < $HOME/.config/dart/pub-credentials.json 33 | { 34 | "accessToken":"${PUB_DEV_PUBLISH_ACCESS_TOKEN}", 35 | "refreshToken":"${PUB_DEV_PUBLISH_REFRESH_TOKEN}", 36 | "tokenEndpoint":"${PUB_DEV_PUBLISH_TOKEN_ENDPOINT}", 37 | "scopes":["https://www.googleapis.com/auth/userinfo.email","openid"], 38 | "expiration":${PUB_DEV_PUBLISH_EXPIRATION} 39 | } 40 | EOF 41 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: ant_media_flutter 2 | description: Flutter Package to use Ant Media Server Enterprise Edition Streaming Engine on Android, iOS, Web and Desktop 3 | version: 1.5.3 4 | homepage: https://github.com/ant-media/WebRTC-Flutter-SDK 5 | 6 | environment: 7 | sdk: '>=2.12.0 <4.0.0' 8 | flutter: '>=1.22.0' 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | flutter_web_plugins: 15 | sdk: flutter 16 | 17 | get: ^4.6.6 18 | collection: ^1.18.0 19 | flutter_webrtc: ^0.12.9 20 | permission_handler: ^11.1.0 21 | shared_preferences: ^2.2.2 22 | http: ^1.1.2 23 | path_provider: ^2.0.11 24 | path_provider_macos: ^2.0.7 25 | flutter_background: ^1.2.0 26 | mockito: ^5.4.4 27 | integration_test: 28 | sdk: flutter 29 | 30 | dev_dependencies: 31 | flutter_test: 32 | sdk: flutter 33 | flutter_lints: ^3.0.1 34 | 35 | # For information on the generic Dart part of this file, see the 36 | # following page: https://dart.dev/tools/pub/pubspec 37 | 38 | # The following section is specific to Flutter. 39 | flutter: 40 | # This section identifies this Flutter project as a plugin project. 41 | # The 'pluginClass' and Android 'package' identifiers should not ordinarily 42 | # be modified. They are used by the tooling to maintain consistency when 43 | # adding or updating assets for this project. 44 | plugin: 45 | platforms: 46 | android: 47 | package: com.example.ant_media_flutter 48 | pluginClass: AntMediaFlutterPlugin 49 | ios: 50 | pluginClass: AntMediaFlutterPlugin 51 | web: 52 | pluginClass: AntMediaFlutterWebPlugin 53 | fileName: ant_media_flutter_web.dart 54 | 55 | # To add assets to your plugin package, add an assets section, like this: 56 | # assets: 57 | # - images/a_dot_burr.jpeg 58 | # - images/a_dot_ham.jpeg 59 | # 60 | # For details regarding assets in packages, see 61 | # https://flutter.dev/assets-and-images/#from-packages 62 | # 63 | # An image asset can refer to one or more resolution-specific "variants", see 64 | # https://flutter.dev/assets-and-images/#resolution-aware. 65 | 66 | # To add custom fonts to your plugin package, add a fonts section here, 67 | # in this "flutter" section. Each entry in this list should have a 68 | # "family" key with the font family name, and a "fonts" key with a 69 | # list giving the asset and other descriptors for the font. For 70 | # example: 71 | # fonts: 72 | # - family: Schyler 73 | # fonts: 74 | # - asset: fonts/Schyler-Regular.ttf 75 | # - asset: fonts/Schyler-Italic.ttf 76 | # style: italic 77 | # - family: Trajan Pro 78 | # fonts: 79 | # - asset: fonts/TrajanPro.ttf 80 | # - asset: fonts/TrajanPro_Bold.ttf 81 | # weight: 700 82 | # 83 | # For details regarding fonts in packages, see 84 | # https://flutter.dev/custom-fonts/#from-packages 85 | -------------------------------------------------------------------------------- /test/permission_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:permission_handler/permission_handler.dart'; 4 | 5 | void main() { 6 | const MethodChannel channel = MethodChannel('flutter.baseflow.com/permissions/methods'); 7 | 8 | setUp(() { 9 | // Ensure Flutter bindings are initialized before the tests 10 | TestWidgetsFlutterBinding.ensureInitialized(); 11 | 12 | // Set up a mock response to handle method calls 13 | TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, (MethodCall methodCall) async { 14 | if (methodCall.method == 'requestPermissions') { 15 | // Return mock permission statuses 16 | return { 17 | Permission.camera.value: PermissionStatus.granted.index, 18 | Permission.microphone.value: PermissionStatus.granted.index, 19 | Permission.bluetooth.value: PermissionStatus.granted.index, 20 | }; 21 | } 22 | return null; 23 | }); 24 | }); 25 | 26 | tearDown(() { 27 | // Reset the mock handler after each test 28 | TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, null); 29 | }); 30 | 31 | test('should request permissions for camera, microphone, and bluetooth', () async { 32 | // Call the method that requests permissions 33 | final statusCamera = await Permission.camera.request(); 34 | final statusMicrophone = await Permission.microphone.request(); 35 | final statusBluetooth = await Permission.bluetooth.request(); 36 | 37 | // Verify that permissions were granted 38 | expect(statusCamera, PermissionStatus.granted); 39 | expect(statusMicrophone, PermissionStatus.granted); 40 | expect(statusBluetooth, PermissionStatus.granted); 41 | }); 42 | } 43 | --------------------------------------------------------------------------------