├── .github ├── stale.yml └── workflows │ ├── deploy-web.yaml │ └── flutter.yml ├── .gitignore ├── LICENSE ├── README.md ├── android ├── app │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── cloudwebrtc │ │ │ └── flutterwebrtcdemo │ │ │ └── MainActivity.java │ │ └── res │ │ ├── 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 │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── flutter_webrtc_demo.iml ├── flutter_webrtc_demo_android.iml ├── ios ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ └── contents.xcworkspacedata └── Runner │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── 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 │ └── main.m ├── lib ├── main.dart └── src │ ├── call_sample │ ├── call_sample.dart │ ├── data_channel_sample.dart │ ├── random_string.dart │ ├── settings.dart │ └── signaling.dart │ ├── route_item.dart │ ├── utils │ ├── device_info.dart │ ├── device_info_web.dart │ ├── screen_select_dialog.dart │ ├── turn.dart │ ├── turn_web.dart │ ├── websocket.dart │ └── websocket_web.dart │ └── widgets │ └── screen_select_dialog.dart ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── 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 ├── pubspec.lock ├── pubspec.yaml ├── renovate.json ├── screenshots ├── android-01.png ├── android-02.png ├── flutter-webrtc-android-example.png ├── flutter-webrtc-desktop-01.png ├── flutter-webrtc-desktop-02.png ├── flutter-webrtc-desktop-03.png ├── flutter-webrtc-ios-example.png ├── ios-01.jpeg └── ios-02.jpeg ├── test └── widget_test.dart ├── web └── index.html └── 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 ├── run_loop.cpp ├── run_loop.h ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 60 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - security 9 | # Label to use when marking an issue as stale 10 | staleLabel: wontfix 11 | # Comment to post when marking an issue as stale. Set to `false` to disable 12 | markComment: > 13 | This issue has been automatically marked as stale because it has not had 14 | recent activity. It will be closed if no further activity occurs. Thank you 15 | for your contributions. 16 | # Comment to post when closing a stale issue. Set to `false` to disable 17 | closeComment: false 18 | -------------------------------------------------------------------------------- /.github/workflows/deploy-web.yaml: -------------------------------------------------------------------------------- 1 | name: deploy web on github-page 2 | on: 3 | push: 4 | branches: 5 | - master 6 | jobs: 7 | build: 8 | name: Build Web 9 | env: 10 | my_secret: ${{secrets.commit_secret}} 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v1 14 | - uses: subosito/flutter-action@v1 15 | with: 16 | channel: "stable" 17 | - run: flutter config --enable-web 18 | - run: flutter clean 19 | - run: flutter pub get 20 | - run: flutter build web --release --web-renderer html --base-href /flutter-webrtc-demo/ 21 | - run: | 22 | cd build/web 23 | git init 24 | git config --global user.email duanweiwei1982@gmail.com 25 | git config --global user.name cloudwebrtc 26 | git status 27 | git remote add origin https://${{secrets.commit_secret}}@github.com/flutter-webrtc/flutter-webrtc-demo.git 28 | git checkout -b gh-pages 29 | git add --all 30 | git commit -m "update" 31 | git push origin gh-pages -f 32 | -------------------------------------------------------------------------------- /.github/workflows/flutter.yml: -------------------------------------------------------------------------------- 1 | name: Flutter CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - dev 7 | - master 8 | - action_test 9 | 10 | jobs: 11 | test: 12 | name: Test on ${{ matrix.os }} 13 | runs-on: ${{ matrix.os }} 14 | strategy: 15 | matrix: 16 | os: [ubuntu-latest] 17 | # os: [ubuntu-latest, windows-latest, macos-latest] 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-java@v1 21 | with: 22 | java-version: '12.x' 23 | - uses: subosito/flutter-action@v1 24 | with: 25 | flutter-version: '3.3.2' 26 | channel: 'stable' 27 | - run: flutter packages get 28 | - run: flutter test 29 | - run: flutter build apk --target-platform android-arm,android-arm64 --split-per-abi 30 | 31 | # - run: curl 32 | -------------------------------------------------------------------------------- /.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 | # Visual Studio Code related 19 | .vscode/ 20 | 21 | # Flutter/Dart/Pub related 22 | **/doc/api/ 23 | .dart_tool/ 24 | .flutter-plugins 25 | .packages 26 | .pub-cache/ 27 | .pub/ 28 | /build/ 29 | 30 | # Android related 31 | **/android/**/gradle-wrapper.jar 32 | **/android/.gradle 33 | **/android/captures/ 34 | **/android/gradlew 35 | **/android/gradlew.bat 36 | **/android/local.properties 37 | **/android/**/GeneratedPluginRegistrant.java 38 | 39 | # iOS/XCode related 40 | **/ios/**/*.mode1v3 41 | **/ios/**/*.mode2v3 42 | **/ios/**/*.moved-aside 43 | **/ios/**/*.pbxuser 44 | **/ios/**/*.perspectivev3 45 | **/ios/**/*sync/ 46 | **/ios/**/.sconsign.dblite 47 | **/ios/**/.tags* 48 | **/ios/**/.vagrant/ 49 | **/ios/**/DerivedData/ 50 | **/ios/**/Icon? 51 | **/ios/**/Pods/ 52 | **/ios/**/.symlinks/ 53 | **/ios/**/profile 54 | **/ios/**/xcuserdata 55 | **/ios/.generated/ 56 | **/ios/Flutter/App.framework 57 | **/ios/Flutter/Flutter.framework 58 | **/ios/Flutter/Generated.xcconfig 59 | **/ios/Flutter/app.flx 60 | **/ios/Flutter/app.zip 61 | **/ios/Flutter/flutter_assets/ 62 | **/ios/ServiceDefinitions.json 63 | **/ios/Runner/GeneratedPluginRegistrant.* 64 | 65 | # Exceptions to above rules. 66 | !**/ios/**/default.mode1v3 67 | !**/ios/**/default.mode2v3 68 | !**/ios/**/default.pbxuser 69 | !**/ios/**/default.perspectivev3 70 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 71 | .flutter-plugins-dependencies 72 | 73 | ios/Flutter/flutter_export_environment.sh 74 | lib/generated_plugin_registrant.dart -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 湖北捷智云技术有限公司 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter-webrtc-demo 2 | [![slack](https://img.shields.io/badge/join-us%20on%20slack-gray.svg?longCache=true&logo=slack&colorB=brightgreen)](https://join.slack.com/t/flutterwebrtc/shared_invite/zt-q83o7y1s-FExGLWEvtkPKM8ku_F8cEQ) 3 | 4 | Flutter WebRTC plugin Demo 5 | 6 | Online Demo: https://flutter-webrtc.github.io/flutter-webrtc-demo/ 7 | 8 | ## Usage 9 | - `git clone https://github.com/cloudwebrtc/flutter-webrtc-demo` 10 | - `cd flutter-webrtc-demo` 11 | - `flutter packages get` 12 | - `flutter run` 13 | ## Note 14 | - If you want to test `P2P Call Sample`, please use the [webrtc-flutter-server](https://github.com/cloudwebrtc/flutter-webrtc-server), and enter your server address into the example app. 15 | 16 | ## screenshots 17 | # iOS 18 | 19 | # Android 20 | 21 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | id "dev.flutter.flutter-gradle-plugin" 5 | } 6 | 7 | def localProperties = new Properties() 8 | def localPropertiesFile = rootProject.file('local.properties') 9 | if (localPropertiesFile.exists()) { 10 | localPropertiesFile.withReader('UTF-8') { reader -> 11 | localProperties.load(reader) 12 | } 13 | } 14 | 15 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 16 | if (flutterVersionCode == null) { 17 | flutterVersionCode = '1' 18 | } 19 | 20 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 21 | if (flutterVersionName == null) { 22 | flutterVersionName = '1.0' 23 | } 24 | 25 | android { 26 | namespace "com.cloudwebrtc.flutterwebrtcdemo" 27 | compileSdkVersion flutter.compileSdkVersion 28 | ndkVersion flutter.ndkVersion 29 | 30 | 31 | lintOptions { 32 | disable 'InvalidPackage' 33 | } 34 | 35 | defaultConfig { 36 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 37 | applicationId "com.cloudwebrtc.flutterwebrtcdemo" 38 | minSdkVersion 23 39 | targetSdkVersion flutter.targetSdkVersion 40 | versionCode flutterVersionCode.toInteger() 41 | versionName flutterVersionName 42 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 43 | } 44 | 45 | compileOptions { 46 | sourceCompatibility JavaVersion.VERSION_1_8 47 | targetCompatibility JavaVersion.VERSION_1_8 48 | } 49 | 50 | buildTypes { 51 | release { 52 | // TODO: Add your own signing config for the release build. 53 | // Signing with the debug keys for now, so `flutter run --release` works. 54 | signingConfig signingConfigs.debug 55 | } 56 | } 57 | packagingOptions { 58 | exclude 'META-INF/proguard/androidx-annotations.pro' 59 | } 60 | } 61 | 62 | flutter { 63 | source '../..' 64 | } 65 | 66 | dependencies {} 67 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | ## Flutter WebRTC 2 | -keep class com.cloudwebrtc.webrtc.** { *; } 3 | -keep class org.webrtc.** { *; } -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 27 | 30 | 38 | 42 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/cloudwebrtc/flutterwebrtcdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.cloudwebrtc.flutterwebrtcdemo; 2 | 3 | import io.flutter.embedding.android.FlutterActivity; 4 | 5 | public class MainActivity extends FlutterActivity { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | allprojects { 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | } 8 | 9 | rootProject.buildDir = '../build' 10 | subprojects { 11 | project.buildDir = "${rootProject.buildDir}/${project.name}" 12 | } 13 | subprojects { 14 | project.evaluationDependsOn(':app') 15 | } 16 | 17 | tasks.register("clean", Delete) { 18 | delete rootProject.buildDir 19 | } 20 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Jul 05 17:31:51 EDT 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | 2 | pluginManagement { 3 | def flutterSdkPath = { 4 | def properties = new Properties() 5 | file("local.properties").withInputStream { properties.load(it) } 6 | def flutterSdkPath = properties.getProperty("flutter.sdk") 7 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 8 | return flutterSdkPath 9 | }() 10 | 11 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 12 | 13 | repositories { 14 | google() 15 | mavenCentral() 16 | gradlePluginPortal() 17 | } 18 | } 19 | 20 | plugins { 21 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 22 | id "com.android.application" version '8.1.1' apply false 23 | id "org.jetbrains.kotlin.android" version "2.0.0" apply false 24 | } 25 | 26 | include ":app" 27 | 28 | -------------------------------------------------------------------------------- /flutter_webrtc_demo.iml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /flutter_webrtc_demo_android.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /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 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | platform :ios, '10.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 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 32 | end 33 | 34 | post_install do |installer| 35 | installer.pods_project.targets.each do |target| 36 | flutter_additional_ios_build_settings(target) 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; }; 12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 13 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 14 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 15 | 8EF76F2A20E6D1B6DE7482C7 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15BC1E059AB8D58D6F31A853 /* libPods-Runner.a */; }; 16 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 17 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 18 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 19 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 20 | 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 21 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 22 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 23 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXCopyFilesBuildPhase section */ 27 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 28 | isa = PBXCopyFilesBuildPhase; 29 | buildActionMask = 2147483647; 30 | dstPath = ""; 31 | dstSubfolderSpec = 10; 32 | files = ( 33 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, 34 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, 35 | ); 36 | name = "Embed Frameworks"; 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXCopyFilesBuildPhase section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 43 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 44 | 15BC1E059AB8D58D6F31A853 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; }; 46 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 47 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 48 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 49 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 50 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 51 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 52 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 53 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 54 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 56 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 57 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 58 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 59 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | /* End PBXFileReference section */ 61 | 62 | /* Begin PBXFrameworksBuildPhase section */ 63 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 68 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, 69 | 8EF76F2A20E6D1B6DE7482C7 /* libPods-Runner.a in Frameworks */, 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | /* End PBXFrameworksBuildPhase section */ 74 | 75 | /* Begin PBXGroup section */ 76 | 7FCCAE0EF0328EC3D4877350 /* Frameworks */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 15BC1E059AB8D58D6F31A853 /* libPods-Runner.a */, 80 | ); 81 | name = Frameworks; 82 | sourceTree = ""; 83 | }; 84 | 9740EEB11CF90186004384FC /* Flutter */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */, 88 | 3B80C3931E831B6300D905FE /* App.framework */, 89 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 90 | 9740EEBA1CF902C7004384FC /* Flutter.framework */, 91 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 92 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 93 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 94 | ); 95 | name = Flutter; 96 | sourceTree = ""; 97 | }; 98 | 97C146E51CF9000F007C117D = { 99 | isa = PBXGroup; 100 | children = ( 101 | 9740EEB11CF90186004384FC /* Flutter */, 102 | 97C146F01CF9000F007C117D /* Runner */, 103 | 97C146EF1CF9000F007C117D /* Products */, 104 | D19CFC9EBE768E9F44363DDE /* Pods */, 105 | 7FCCAE0EF0328EC3D4877350 /* Frameworks */, 106 | ); 107 | sourceTree = ""; 108 | }; 109 | 97C146EF1CF9000F007C117D /* Products */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 97C146EE1CF9000F007C117D /* Runner.app */, 113 | ); 114 | name = Products; 115 | sourceTree = ""; 116 | }; 117 | 97C146F01CF9000F007C117D /* Runner */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, 121 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, 122 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 123 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 124 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 125 | 97C147021CF9000F007C117D /* Info.plist */, 126 | 97C146F11CF9000F007C117D /* Supporting Files */, 127 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 128 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 129 | ); 130 | path = Runner; 131 | sourceTree = ""; 132 | }; 133 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 97C146F21CF9000F007C117D /* main.m */, 137 | ); 138 | name = "Supporting Files"; 139 | sourceTree = ""; 140 | }; 141 | D19CFC9EBE768E9F44363DDE /* Pods */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | ); 145 | name = Pods; 146 | sourceTree = ""; 147 | }; 148 | /* End PBXGroup section */ 149 | 150 | /* Begin PBXNativeTarget section */ 151 | 97C146ED1CF9000F007C117D /* Runner */ = { 152 | isa = PBXNativeTarget; 153 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 154 | buildPhases = ( 155 | 79DB657BBAA4C66FD2F9F610 /* [CP] Check Pods Manifest.lock */, 156 | 9740EEB61CF901F6004384FC /* Run Script */, 157 | 97C146EA1CF9000F007C117D /* Sources */, 158 | 97C146EB1CF9000F007C117D /* Frameworks */, 159 | 97C146EC1CF9000F007C117D /* Resources */, 160 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 161 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 162 | 5BC80851079CF347B338D4EE /* [CP] Embed Pods Frameworks */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | ); 168 | name = Runner; 169 | productName = Runner; 170 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 171 | productType = "com.apple.product-type.application"; 172 | }; 173 | /* End PBXNativeTarget section */ 174 | 175 | /* Begin PBXProject section */ 176 | 97C146E61CF9000F007C117D /* Project object */ = { 177 | isa = PBXProject; 178 | attributes = { 179 | LastUpgradeCheck = 0910; 180 | ORGANIZATIONNAME = "The Chromium Authors"; 181 | TargetAttributes = { 182 | 97C146ED1CF9000F007C117D = { 183 | CreatedOnToolsVersion = 7.3.1; 184 | }; 185 | }; 186 | }; 187 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 188 | compatibilityVersion = "Xcode 3.2"; 189 | developmentRegion = English; 190 | hasScannedForEncodings = 0; 191 | knownRegions = ( 192 | en, 193 | Base, 194 | ); 195 | mainGroup = 97C146E51CF9000F007C117D; 196 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 197 | projectDirPath = ""; 198 | projectRoot = ""; 199 | targets = ( 200 | 97C146ED1CF9000F007C117D /* Runner */, 201 | ); 202 | }; 203 | /* End PBXProject section */ 204 | 205 | /* Begin PBXResourcesBuildPhase section */ 206 | 97C146EC1CF9000F007C117D /* Resources */ = { 207 | isa = PBXResourcesBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 211 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 212 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 213 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 214 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */, 215 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXResourcesBuildPhase section */ 220 | 221 | /* Begin PBXShellScriptBuildPhase section */ 222 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 223 | isa = PBXShellScriptBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | ); 227 | inputPaths = ( 228 | ); 229 | name = "Thin Binary"; 230 | outputPaths = ( 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | shellPath = /bin/sh; 234 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; 235 | }; 236 | 5BC80851079CF347B338D4EE /* [CP] Embed Pods Frameworks */ = { 237 | isa = PBXShellScriptBuildPhase; 238 | buildActionMask = 2147483647; 239 | files = ( 240 | ); 241 | inputPaths = ( 242 | "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", 243 | "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", 244 | "${PODS_ROOT}/GoogleWebRTC/Frameworks/frameworks/WebRTC.framework", 245 | ); 246 | name = "[CP] Embed Pods Frameworks"; 247 | outputPaths = ( 248 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", 249 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WebRTC.framework", 250 | ); 251 | runOnlyForDeploymentPostprocessing = 0; 252 | shellPath = /bin/sh; 253 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 254 | showEnvVarsInLog = 0; 255 | }; 256 | 79DB657BBAA4C66FD2F9F610 /* [CP] Check Pods Manifest.lock */ = { 257 | isa = PBXShellScriptBuildPhase; 258 | buildActionMask = 2147483647; 259 | files = ( 260 | ); 261 | inputPaths = ( 262 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 263 | "${PODS_ROOT}/Manifest.lock", 264 | ); 265 | name = "[CP] Check Pods Manifest.lock"; 266 | outputPaths = ( 267 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | shellPath = /bin/sh; 271 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 272 | showEnvVarsInLog = 0; 273 | }; 274 | 9740EEB61CF901F6004384FC /* Run Script */ = { 275 | isa = PBXShellScriptBuildPhase; 276 | buildActionMask = 2147483647; 277 | files = ( 278 | ); 279 | inputPaths = ( 280 | ); 281 | name = "Run Script"; 282 | outputPaths = ( 283 | ); 284 | runOnlyForDeploymentPostprocessing = 0; 285 | shellPath = /bin/sh; 286 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 287 | }; 288 | /* End PBXShellScriptBuildPhase section */ 289 | 290 | /* Begin PBXSourcesBuildPhase section */ 291 | 97C146EA1CF9000F007C117D /* Sources */ = { 292 | isa = PBXSourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, 296 | 97C146F31CF9000F007C117D /* main.m in Sources */, 297 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | /* End PBXSourcesBuildPhase section */ 302 | 303 | /* Begin PBXVariantGroup section */ 304 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 305 | isa = PBXVariantGroup; 306 | children = ( 307 | 97C146FB1CF9000F007C117D /* Base */, 308 | ); 309 | name = Main.storyboard; 310 | sourceTree = ""; 311 | }; 312 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 313 | isa = PBXVariantGroup; 314 | children = ( 315 | 97C147001CF9000F007C117D /* Base */, 316 | ); 317 | name = LaunchScreen.storyboard; 318 | sourceTree = ""; 319 | }; 320 | /* End PBXVariantGroup section */ 321 | 322 | /* Begin XCBuildConfiguration section */ 323 | 97C147031CF9000F007C117D /* Debug */ = { 324 | isa = XCBuildConfiguration; 325 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 326 | buildSettings = { 327 | ALWAYS_SEARCH_USER_PATHS = NO; 328 | CLANG_ANALYZER_NONNULL = YES; 329 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 330 | CLANG_CXX_LIBRARY = "libc++"; 331 | CLANG_ENABLE_MODULES = YES; 332 | CLANG_ENABLE_OBJC_ARC = YES; 333 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 334 | CLANG_WARN_BOOL_CONVERSION = YES; 335 | CLANG_WARN_COMMA = YES; 336 | CLANG_WARN_CONSTANT_CONVERSION = YES; 337 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 338 | CLANG_WARN_EMPTY_BODY = YES; 339 | CLANG_WARN_ENUM_CONVERSION = YES; 340 | CLANG_WARN_INFINITE_RECURSION = YES; 341 | CLANG_WARN_INT_CONVERSION = YES; 342 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 343 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 345 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 346 | CLANG_WARN_STRICT_PROTOTYPES = YES; 347 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 348 | CLANG_WARN_UNREACHABLE_CODE = YES; 349 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 350 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 351 | COPY_PHASE_STRIP = NO; 352 | DEBUG_INFORMATION_FORMAT = dwarf; 353 | ENABLE_STRICT_OBJC_MSGSEND = YES; 354 | ENABLE_TESTABILITY = YES; 355 | GCC_C_LANGUAGE_STANDARD = gnu99; 356 | GCC_DYNAMIC_NO_PIC = NO; 357 | GCC_NO_COMMON_BLOCKS = YES; 358 | GCC_OPTIMIZATION_LEVEL = 0; 359 | GCC_PREPROCESSOR_DEFINITIONS = ( 360 | "DEBUG=1", 361 | "$(inherited)", 362 | ); 363 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 364 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 365 | GCC_WARN_UNDECLARED_SELECTOR = YES; 366 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 367 | GCC_WARN_UNUSED_FUNCTION = YES; 368 | GCC_WARN_UNUSED_VARIABLE = YES; 369 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 370 | MTL_ENABLE_DEBUG_INFO = YES; 371 | ONLY_ACTIVE_ARCH = YES; 372 | SDKROOT = iphoneos; 373 | TARGETED_DEVICE_FAMILY = "1,2"; 374 | }; 375 | name = Debug; 376 | }; 377 | 97C147041CF9000F007C117D /* Release */ = { 378 | isa = XCBuildConfiguration; 379 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 380 | buildSettings = { 381 | ALWAYS_SEARCH_USER_PATHS = NO; 382 | CLANG_ANALYZER_NONNULL = YES; 383 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 384 | CLANG_CXX_LIBRARY = "libc++"; 385 | CLANG_ENABLE_MODULES = YES; 386 | CLANG_ENABLE_OBJC_ARC = YES; 387 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 388 | CLANG_WARN_BOOL_CONVERSION = YES; 389 | CLANG_WARN_COMMA = YES; 390 | CLANG_WARN_CONSTANT_CONVERSION = YES; 391 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 392 | CLANG_WARN_EMPTY_BODY = YES; 393 | CLANG_WARN_ENUM_CONVERSION = YES; 394 | CLANG_WARN_INFINITE_RECURSION = YES; 395 | CLANG_WARN_INT_CONVERSION = YES; 396 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 397 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 398 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 399 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 400 | CLANG_WARN_STRICT_PROTOTYPES = YES; 401 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 402 | CLANG_WARN_UNREACHABLE_CODE = YES; 403 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 404 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 405 | COPY_PHASE_STRIP = NO; 406 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 407 | ENABLE_NS_ASSERTIONS = NO; 408 | ENABLE_STRICT_OBJC_MSGSEND = YES; 409 | GCC_C_LANGUAGE_STANDARD = gnu99; 410 | GCC_NO_COMMON_BLOCKS = YES; 411 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 412 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 413 | GCC_WARN_UNDECLARED_SELECTOR = YES; 414 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 415 | GCC_WARN_UNUSED_FUNCTION = YES; 416 | GCC_WARN_UNUSED_VARIABLE = YES; 417 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 418 | MTL_ENABLE_DEBUG_INFO = NO; 419 | SDKROOT = iphoneos; 420 | TARGETED_DEVICE_FAMILY = "1,2"; 421 | VALIDATE_PRODUCT = YES; 422 | }; 423 | name = Release; 424 | }; 425 | 97C147061CF9000F007C117D /* Debug */ = { 426 | isa = XCBuildConfiguration; 427 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 428 | buildSettings = { 429 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 430 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 431 | ENABLE_BITCODE = NO; 432 | FRAMEWORK_SEARCH_PATHS = ( 433 | "$(inherited)", 434 | "$(PROJECT_DIR)/Flutter", 435 | ); 436 | INFOPLIST_FILE = Runner/Info.plist; 437 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 438 | LIBRARY_SEARCH_PATHS = ( 439 | "$(inherited)", 440 | "$(PROJECT_DIR)/Flutter", 441 | ); 442 | PRODUCT_BUNDLE_IDENTIFIER = com.cloudwebrtc.flutterWebrtcDemo; 443 | PRODUCT_NAME = "$(TARGET_NAME)"; 444 | VERSIONING_SYSTEM = "apple-generic"; 445 | }; 446 | name = Debug; 447 | }; 448 | 97C147071CF9000F007C117D /* Release */ = { 449 | isa = XCBuildConfiguration; 450 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 451 | buildSettings = { 452 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 453 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 454 | ENABLE_BITCODE = NO; 455 | FRAMEWORK_SEARCH_PATHS = ( 456 | "$(inherited)", 457 | "$(PROJECT_DIR)/Flutter", 458 | ); 459 | INFOPLIST_FILE = Runner/Info.plist; 460 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 461 | LIBRARY_SEARCH_PATHS = ( 462 | "$(inherited)", 463 | "$(PROJECT_DIR)/Flutter", 464 | ); 465 | PRODUCT_BUNDLE_IDENTIFIER = com.cloudwebrtc.flutterWebrtcDemo; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | VERSIONING_SYSTEM = "apple-generic"; 468 | }; 469 | name = Release; 470 | }; 471 | /* End XCBuildConfiguration section */ 472 | 473 | /* Begin XCConfigurationList section */ 474 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 475 | isa = XCConfigurationList; 476 | buildConfigurations = ( 477 | 97C147031CF9000F007C117D /* Debug */, 478 | 97C147041CF9000F007C117D /* Release */, 479 | ); 480 | defaultConfigurationIsVisible = 0; 481 | defaultConfigurationName = Release; 482 | }; 483 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 484 | isa = XCConfigurationList; 485 | buildConfigurations = ( 486 | 97C147061CF9000F007C117D /* Debug */, 487 | 97C147071CF9000F007C117D /* Release */, 488 | ); 489 | defaultConfigurationIsVisible = 0; 490 | defaultConfigurationName = Release; 491 | }; 492 | /* End XCConfigurationList section */ 493 | }; 494 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 495 | } 496 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 77 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application 7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 8 | [GeneratedPluginRegistrant registerWithRegistry:self]; 9 | // Override point for customization after application launch. 10 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | flutter_webrtc_demo 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | NSCameraUsageDescription 26 | $(PRODUCT_NAME) Camera Usage! 27 | NSMicrophoneUsageDescription 28 | $(PRODUCT_NAME) Microphone Usage! 29 | NSPhotoLibraryUsageDescription 30 | $(PRODUCT_NAME) PhotoLibrary Usage! 31 | UIBackgroundModes 32 | 33 | fetch 34 | remote-notification 35 | 36 | UILaunchStoryboardName 37 | LaunchScreen 38 | UIMainStoryboardFile 39 | Main 40 | UISupportedInterfaceOrientations 41 | 42 | UIInterfaceOrientationPortrait 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | UISupportedInterfaceOrientations~ipad 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationPortraitUpsideDown 50 | UIInterfaceOrientationLandscapeLeft 51 | UIInterfaceOrientationLandscapeRight 52 | 53 | UIViewControllerBasedStatusBarAppearance 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char* argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:core'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:shared_preferences/shared_preferences.dart'; 5 | 6 | import 'src/call_sample/call_sample.dart'; 7 | import 'src/call_sample/data_channel_sample.dart'; 8 | import 'src/route_item.dart'; 9 | 10 | void main() => runApp(new MyApp()); 11 | 12 | class MyApp extends StatefulWidget { 13 | @override 14 | _MyAppState createState() => new _MyAppState(); 15 | } 16 | 17 | enum DialogDemoAction { 18 | cancel, 19 | connect, 20 | } 21 | 22 | class _MyAppState extends State { 23 | List items = []; 24 | String _server = ''; 25 | late SharedPreferences _prefs; 26 | 27 | bool _datachannel = false; 28 | @override 29 | initState() { 30 | super.initState(); 31 | _initData(); 32 | _initItems(); 33 | } 34 | 35 | _buildRow(context, item) { 36 | return ListBody(children: [ 37 | ListTile( 38 | title: Text(item.title), 39 | onTap: () => item.push(context), 40 | trailing: Icon(Icons.arrow_right), 41 | ), 42 | Divider() 43 | ]); 44 | } 45 | 46 | @override 47 | Widget build(BuildContext context) { 48 | return MaterialApp( 49 | home: Scaffold( 50 | appBar: AppBar( 51 | title: Text('Flutter-WebRTC example'), 52 | ), 53 | body: ListView.builder( 54 | shrinkWrap: true, 55 | padding: const EdgeInsets.all(0.0), 56 | itemCount: items.length, 57 | itemBuilder: (context, i) { 58 | return _buildRow(context, items[i]); 59 | })), 60 | ); 61 | } 62 | 63 | _initData() async { 64 | _prefs = await SharedPreferences.getInstance(); 65 | setState(() { 66 | _server = _prefs.getString('server') ?? 'demo.cloudwebrtc.com'; 67 | }); 68 | } 69 | 70 | void showDemoDialog( 71 | {required BuildContext context, required Widget child}) { 72 | showDialog( 73 | context: context, 74 | builder: (BuildContext context) => child, 75 | ).then((T? value) { 76 | // The value passed to Navigator.pop() or null. 77 | if (value != null) { 78 | if (value == DialogDemoAction.connect) { 79 | _prefs.setString('server', _server); 80 | Navigator.push( 81 | context, 82 | MaterialPageRoute( 83 | builder: (BuildContext context) => _datachannel 84 | ? DataChannelSample(host: _server) 85 | : CallSample(host: _server))); 86 | } 87 | } 88 | }); 89 | } 90 | 91 | _showAddressDialog(context) { 92 | showDemoDialog( 93 | context: context, 94 | child: AlertDialog( 95 | title: const Text('Enter server address:'), 96 | content: TextField( 97 | onChanged: (String text) { 98 | setState(() { 99 | _server = text; 100 | }); 101 | }, 102 | decoration: InputDecoration( 103 | hintText: _server, 104 | ), 105 | textAlign: TextAlign.center, 106 | ), 107 | actions: [ 108 | TextButton( 109 | child: const Text('CANCEL'), 110 | onPressed: () { 111 | Navigator.pop(context, DialogDemoAction.cancel); 112 | }), 113 | TextButton( 114 | child: const Text('CONNECT'), 115 | onPressed: () { 116 | Navigator.pop(context, DialogDemoAction.connect); 117 | }) 118 | ])); 119 | } 120 | 121 | _initItems() { 122 | items = [ 123 | RouteItem( 124 | title: 'P2P Call Sample', 125 | subtitle: 'P2P Call Sample.', 126 | push: (BuildContext context) { 127 | _datachannel = false; 128 | _showAddressDialog(context); 129 | }), 130 | RouteItem( 131 | title: 'Data Channel Sample', 132 | subtitle: 'P2P Data Channel.', 133 | push: (BuildContext context) { 134 | _datachannel = true; 135 | _showAddressDialog(context); 136 | }), 137 | ]; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /lib/src/call_sample/call_sample.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'dart:core'; 3 | import '../widgets/screen_select_dialog.dart'; 4 | import 'signaling.dart'; 5 | import 'package:flutter_webrtc/flutter_webrtc.dart'; 6 | 7 | class CallSample extends StatefulWidget { 8 | static String tag = 'call_sample'; 9 | final String host; 10 | CallSample({required this.host}); 11 | 12 | @override 13 | _CallSampleState createState() => _CallSampleState(); 14 | } 15 | 16 | class _CallSampleState extends State { 17 | Signaling? _signaling; 18 | List _peers = []; 19 | String? _selfId; 20 | RTCVideoRenderer _localRenderer = RTCVideoRenderer(); 21 | RTCVideoRenderer _remoteRenderer = RTCVideoRenderer(); 22 | bool _inCalling = false; 23 | Session? _session; 24 | DesktopCapturerSource? selected_source_; 25 | bool _waitAccept = false; 26 | 27 | // ignore: unused_element 28 | _CallSampleState(); 29 | 30 | @override 31 | initState() { 32 | super.initState(); 33 | initRenderers(); 34 | _connect(context); 35 | } 36 | 37 | initRenderers() async { 38 | await _localRenderer.initialize(); 39 | await _remoteRenderer.initialize(); 40 | } 41 | 42 | @override 43 | deactivate() { 44 | super.deactivate(); 45 | _signaling?.close(); 46 | _localRenderer.dispose(); 47 | _remoteRenderer.dispose(); 48 | } 49 | 50 | void _connect(BuildContext context) async { 51 | _signaling ??= Signaling(widget.host, context)..connect(); 52 | _signaling?.onSignalingStateChange = (SignalingState state) { 53 | switch (state) { 54 | case SignalingState.ConnectionClosed: 55 | case SignalingState.ConnectionError: 56 | case SignalingState.ConnectionOpen: 57 | break; 58 | } 59 | }; 60 | 61 | _signaling?.onCallStateChange = (Session session, CallState state) async { 62 | switch (state) { 63 | case CallState.CallStateNew: 64 | setState(() { 65 | _session = session; 66 | }); 67 | break; 68 | case CallState.CallStateRinging: 69 | bool? accept = await _showAcceptDialog(); 70 | if (accept!) { 71 | _accept(); 72 | setState(() { 73 | _inCalling = true; 74 | }); 75 | } else { 76 | _reject(); 77 | } 78 | break; 79 | case CallState.CallStateBye: 80 | if (_waitAccept) { 81 | print('peer reject'); 82 | _waitAccept = false; 83 | Navigator.of(context).pop(false); 84 | } 85 | setState(() { 86 | _localRenderer.srcObject = null; 87 | _remoteRenderer.srcObject = null; 88 | _inCalling = false; 89 | _session = null; 90 | }); 91 | break; 92 | case CallState.CallStateInvite: 93 | _waitAccept = true; 94 | _showInvateDialog(); 95 | break; 96 | case CallState.CallStateConnected: 97 | if (_waitAccept) { 98 | _waitAccept = false; 99 | Navigator.of(context).pop(false); 100 | } 101 | setState(() { 102 | _inCalling = true; 103 | }); 104 | 105 | break; 106 | case CallState.CallStateRinging: 107 | } 108 | }; 109 | 110 | _signaling?.onPeersUpdate = ((event) { 111 | setState(() { 112 | _selfId = event['self']; 113 | _peers = event['peers']; 114 | }); 115 | }); 116 | 117 | _signaling?.onLocalStream = ((stream) { 118 | _localRenderer.srcObject = stream; 119 | setState(() {}); 120 | }); 121 | 122 | _signaling?.onAddRemoteStream = ((_, stream) { 123 | _remoteRenderer.srcObject = stream; 124 | setState(() {}); 125 | }); 126 | 127 | _signaling?.onRemoveRemoteStream = ((_, stream) { 128 | _remoteRenderer.srcObject = null; 129 | }); 130 | } 131 | 132 | Future _showAcceptDialog() { 133 | return showDialog( 134 | context: context, 135 | builder: (context) { 136 | return AlertDialog( 137 | title: Text("title"), 138 | content: Text("accept?"), 139 | actions: [ 140 | MaterialButton( 141 | child: Text( 142 | 'Reject', 143 | style: TextStyle(color: Colors.red), 144 | ), 145 | onPressed: () => Navigator.of(context).pop(false), 146 | ), 147 | MaterialButton( 148 | child: Text( 149 | 'Accept', 150 | style: TextStyle(color: Colors.green), 151 | ), 152 | onPressed: () => Navigator.of(context).pop(true), 153 | ), 154 | ], 155 | ); 156 | }, 157 | ); 158 | } 159 | 160 | Future _showInvateDialog() { 161 | return showDialog( 162 | context: context, 163 | builder: (context) { 164 | return AlertDialog( 165 | title: Text("title"), 166 | content: Text("waiting"), 167 | actions: [ 168 | TextButton( 169 | child: Text("cancel"), 170 | onPressed: () { 171 | Navigator.of(context).pop(false); 172 | _hangUp(); 173 | }, 174 | ), 175 | ], 176 | ); 177 | }, 178 | ); 179 | } 180 | 181 | _invitePeer(BuildContext context, String peerId, bool useScreen) async { 182 | if (_signaling != null && peerId != _selfId) { 183 | _signaling?.invite(peerId, 'video', useScreen); 184 | } 185 | } 186 | 187 | _accept() { 188 | if (_session != null) { 189 | _signaling?.accept(_session!.sid, 'video'); 190 | } 191 | } 192 | 193 | _reject() { 194 | if (_session != null) { 195 | _signaling?.reject(_session!.sid); 196 | } 197 | } 198 | 199 | _hangUp() { 200 | if (_session != null) { 201 | _signaling?.bye(_session!.sid); 202 | } 203 | } 204 | 205 | _switchCamera() { 206 | _signaling?.switchCamera(); 207 | } 208 | 209 | Future selectScreenSourceDialog(BuildContext context) async { 210 | MediaStream? screenStream; 211 | if (WebRTC.platformIsDesktop) { 212 | final source = await showDialog( 213 | context: context, 214 | builder: (context) => ScreenSelectDialog(), 215 | ); 216 | if (source != null) { 217 | try { 218 | var stream = 219 | await navigator.mediaDevices.getDisplayMedia({ 220 | 'video': { 221 | 'deviceId': {'exact': source.id}, 222 | 'mandatory': {'frameRate': 30.0} 223 | } 224 | }); 225 | stream.getVideoTracks()[0].onEnded = () { 226 | print( 227 | 'By adding a listener on onEnded you can: 1) catch stop video sharing on Web'); 228 | }; 229 | screenStream = stream; 230 | } catch (e) { 231 | print(e); 232 | } 233 | } 234 | } else if (WebRTC.platformIsWeb) { 235 | screenStream = 236 | await navigator.mediaDevices.getDisplayMedia({ 237 | 'audio': false, 238 | 'video': true, 239 | }); 240 | } 241 | if (screenStream != null) _signaling?.switchToScreenSharing(screenStream); 242 | } 243 | 244 | _muteMic() { 245 | _signaling?.muteMic(); 246 | } 247 | 248 | _buildRow(context, peer) { 249 | var self = (peer['id'] == _selfId); 250 | return ListBody(children: [ 251 | ListTile( 252 | title: Text(self 253 | ? peer['name'] + ', ID: ${peer['id']} ' + ' [Your self]' 254 | : peer['name'] + ', ID: ${peer['id']} '), 255 | onTap: null, 256 | trailing: SizedBox( 257 | width: 100.0, 258 | child: Row( 259 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 260 | children: [ 261 | IconButton( 262 | icon: Icon(self ? Icons.close : Icons.videocam, 263 | color: self ? Colors.grey : Colors.black), 264 | onPressed: () => _invitePeer(context, peer['id'], false), 265 | tooltip: 'Video calling', 266 | ), 267 | IconButton( 268 | icon: Icon(self ? Icons.close : Icons.screen_share, 269 | color: self ? Colors.grey : Colors.black), 270 | onPressed: () => _invitePeer(context, peer['id'], true), 271 | tooltip: 'Screen sharing', 272 | ) 273 | ])), 274 | subtitle: Text('[' + peer['user_agent'] + ']'), 275 | ), 276 | Divider() 277 | ]); 278 | } 279 | 280 | @override 281 | Widget build(BuildContext context) { 282 | return Scaffold( 283 | appBar: AppBar( 284 | title: Text('P2P Call Sample' + 285 | (_selfId != null ? ' [Your ID ($_selfId)] ' : '')), 286 | actions: [ 287 | IconButton( 288 | icon: const Icon(Icons.settings), 289 | onPressed: null, 290 | tooltip: 'setup', 291 | ), 292 | ], 293 | ), 294 | floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, 295 | floatingActionButton: _inCalling 296 | ? SizedBox( 297 | width: 240.0, 298 | child: Row( 299 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 300 | children: [ 301 | FloatingActionButton( 302 | child: const Icon(Icons.switch_camera), 303 | tooltip: 'Camera', 304 | onPressed: _switchCamera, 305 | ), 306 | FloatingActionButton( 307 | child: const Icon(Icons.desktop_mac), 308 | tooltip: 'Screen Sharing', 309 | onPressed: () => selectScreenSourceDialog(context), 310 | ), 311 | FloatingActionButton( 312 | onPressed: _hangUp, 313 | tooltip: 'Hangup', 314 | child: Icon(Icons.call_end), 315 | backgroundColor: Colors.pink, 316 | ), 317 | FloatingActionButton( 318 | child: const Icon(Icons.mic_off), 319 | tooltip: 'Mute Mic', 320 | onPressed: _muteMic, 321 | ) 322 | ])) 323 | : null, 324 | body: _inCalling 325 | ? OrientationBuilder(builder: (context, orientation) { 326 | return Container( 327 | child: Stack(children: [ 328 | Positioned( 329 | left: 0.0, 330 | right: 0.0, 331 | top: 0.0, 332 | bottom: 0.0, 333 | child: Container( 334 | margin: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0), 335 | width: MediaQuery.of(context).size.width, 336 | height: MediaQuery.of(context).size.height, 337 | child: RTCVideoView(_remoteRenderer), 338 | decoration: BoxDecoration(color: Colors.black54), 339 | )), 340 | Positioned( 341 | left: 20.0, 342 | top: 20.0, 343 | child: Container( 344 | width: orientation == Orientation.portrait ? 90.0 : 120.0, 345 | height: 346 | orientation == Orientation.portrait ? 120.0 : 90.0, 347 | child: RTCVideoView(_localRenderer, mirror: true), 348 | decoration: BoxDecoration(color: Colors.black54), 349 | ), 350 | ), 351 | ]), 352 | ); 353 | }) 354 | : ListView.builder( 355 | shrinkWrap: true, 356 | padding: const EdgeInsets.all(0.0), 357 | itemCount: (_peers != null ? _peers.length : 0), 358 | itemBuilder: (context, i) { 359 | return _buildRow(context, _peers[i]); 360 | }), 361 | ); 362 | } 363 | } 364 | -------------------------------------------------------------------------------- /lib/src/call_sample/data_channel_sample.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'dart:core'; 3 | import 'dart:async'; 4 | import 'dart:typed_data'; 5 | import 'signaling.dart'; 6 | import 'package:flutter_webrtc/flutter_webrtc.dart'; 7 | 8 | class DataChannelSample extends StatefulWidget { 9 | static String tag = 'call_sample'; 10 | final String host; 11 | DataChannelSample({required this.host}); 12 | 13 | @override 14 | _DataChannelSampleState createState() => _DataChannelSampleState(); 15 | } 16 | 17 | class _DataChannelSampleState extends State { 18 | Signaling? _signaling; 19 | List _peers = []; 20 | String? _selfId; 21 | bool _inCalling = false; 22 | RTCDataChannel? _dataChannel; 23 | Session? _session; 24 | Timer? _timer; 25 | var _text = ''; 26 | // ignore: unused_element 27 | _DataChannelSampleState(); 28 | bool _waitAccept = false; 29 | 30 | @override 31 | initState() { 32 | super.initState(); 33 | _connect(context); 34 | } 35 | 36 | @override 37 | deactivate() { 38 | super.deactivate(); 39 | _signaling?.close(); 40 | _timer?.cancel(); 41 | } 42 | 43 | Future _showAcceptDialog() { 44 | return showDialog( 45 | context: context, 46 | builder: (context) { 47 | return AlertDialog( 48 | title: Text("title"), 49 | content: Text("accept?"), 50 | actions: [ 51 | MaterialButton( 52 | child: Text( 53 | 'Reject', 54 | style: TextStyle(color: Colors.red), 55 | ), 56 | onPressed: () => Navigator.of(context).pop(false), 57 | ), 58 | MaterialButton( 59 | child: Text( 60 | 'Accept', 61 | style: TextStyle(color: Colors.green), 62 | ), 63 | onPressed: () => Navigator.of(context).pop(true), 64 | ), 65 | ], 66 | ); 67 | }, 68 | ); 69 | } 70 | 71 | Future _showInvateDialog() { 72 | return showDialog( 73 | context: context, 74 | builder: (context) { 75 | return AlertDialog( 76 | title: Text("title"), 77 | content: Text("waiting"), 78 | actions: [ 79 | TextButton( 80 | child: Text("cancel"), 81 | onPressed: () { 82 | Navigator.of(context).pop(false); 83 | _hangUp(); 84 | }, 85 | ), 86 | ], 87 | ); 88 | }, 89 | ); 90 | } 91 | 92 | void _connect(BuildContext context) async { 93 | _signaling ??= Signaling(widget.host, context)..connect(); 94 | 95 | _signaling?.onDataChannelMessage = (_, dc, RTCDataChannelMessage data) { 96 | setState(() { 97 | if (data.isBinary) { 98 | print('Got binary [' + data.binary.toString() + ']'); 99 | } else { 100 | _text = data.text; 101 | } 102 | }); 103 | }; 104 | 105 | _signaling?.onDataChannel = (_, channel) { 106 | _dataChannel = channel; 107 | }; 108 | 109 | _signaling?.onSignalingStateChange = (SignalingState state) { 110 | switch (state) { 111 | case SignalingState.ConnectionClosed: 112 | case SignalingState.ConnectionError: 113 | case SignalingState.ConnectionOpen: 114 | break; 115 | } 116 | }; 117 | 118 | _signaling?.onCallStateChange = (Session session, CallState state) async { 119 | switch (state) { 120 | case CallState.CallStateNew: 121 | setState(() { 122 | _session = session; 123 | }); 124 | _timer = Timer.periodic(Duration(seconds: 1), _handleDataChannelTest); 125 | break; 126 | case CallState.CallStateBye: 127 | if (_waitAccept) { 128 | print('peer reject'); 129 | _waitAccept = false; 130 | Navigator.of(context).pop(false); 131 | } 132 | setState(() { 133 | _inCalling = false; 134 | }); 135 | _timer?.cancel(); 136 | _dataChannel = null; 137 | _inCalling = false; 138 | _session = null; 139 | _text = ''; 140 | break; 141 | case CallState.CallStateInvite: 142 | _waitAccept = true; 143 | _showInvateDialog(); 144 | break; 145 | case CallState.CallStateConnected: 146 | if (_waitAccept) { 147 | _waitAccept = false; 148 | Navigator.of(context).pop(false); 149 | } 150 | setState(() { 151 | _inCalling = true; 152 | }); 153 | break; 154 | case CallState.CallStateRinging: 155 | bool? accept = await _showAcceptDialog(); 156 | if (accept!) { 157 | _accept(); 158 | setState(() { 159 | _inCalling = true; 160 | }); 161 | } else { 162 | _reject(); 163 | } 164 | 165 | break; 166 | } 167 | }; 168 | 169 | _signaling?.onPeersUpdate = ((event) { 170 | setState(() { 171 | _selfId = event['self']; 172 | _peers = event['peers']; 173 | }); 174 | }); 175 | } 176 | 177 | _handleDataChannelTest(Timer timer) async { 178 | String text = 179 | 'Say hello ' + timer.tick.toString() + ' times, from [$_selfId]'; 180 | _dataChannel 181 | ?.send(RTCDataChannelMessage.fromBinary(Uint8List(timer.tick + 1))); 182 | _dataChannel?.send(RTCDataChannelMessage(text)); 183 | } 184 | 185 | _invitePeer(context, peerId) async { 186 | if (peerId != _selfId) { 187 | _signaling?.invite(peerId, 'data', false); 188 | } 189 | } 190 | 191 | _accept() { 192 | if (_session != null) { 193 | _signaling?.accept(_session!.sid, 'data'); 194 | } 195 | } 196 | 197 | _reject() { 198 | if (_session != null) { 199 | _signaling?.reject(_session!.sid); 200 | } 201 | } 202 | 203 | _hangUp() { 204 | _signaling?.bye(_session!.sid); 205 | } 206 | 207 | _buildRow(context, peer) { 208 | var self = (peer['id'] == _selfId); 209 | return ListBody(children: [ 210 | ListTile( 211 | title: Text(self 212 | ? peer['name'] + ', ID: ${peer['id']} ' + ' [Your self]' 213 | : peer['name'] + ', ID: ${peer['id']} '), 214 | onTap: () => _invitePeer(context, peer['id']), 215 | trailing: Icon(Icons.sms), 216 | subtitle: Text('[' + peer['user_agent'] + ']'), 217 | ), 218 | Divider() 219 | ]); 220 | } 221 | 222 | @override 223 | Widget build(BuildContext context) { 224 | return Scaffold( 225 | appBar: AppBar( 226 | title: Text('Data Channel Sample' + 227 | (_selfId != null ? ' [Your ID ($_selfId)] ' : '')), 228 | actions: [ 229 | IconButton( 230 | icon: const Icon(Icons.settings), 231 | onPressed: null, 232 | tooltip: 'setup', 233 | ), 234 | ], 235 | ), 236 | floatingActionButton: _inCalling 237 | ? FloatingActionButton( 238 | onPressed: _hangUp, 239 | tooltip: 'Hangup', 240 | child: Icon(Icons.call_end), 241 | ) 242 | : null, 243 | body: _inCalling 244 | ? Center( 245 | child: Container( 246 | child: Text('Recevied => ' + _text), 247 | ), 248 | ) 249 | : ListView.builder( 250 | shrinkWrap: true, 251 | padding: const EdgeInsets.all(0.0), 252 | itemCount: (_peers != null ? _peers.length : 0), 253 | itemBuilder: (context, i) { 254 | return _buildRow(context, _peers[i]); 255 | }), 256 | ); 257 | } 258 | } 259 | -------------------------------------------------------------------------------- /lib/src/call_sample/random_string.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, Damon Douglas. All rights reserved. Use of this source code 2 | // is governed by a BSD-style license that can be found in the LICENSE file. 3 | 4 | /// Simple library for generating random ascii strings. 5 | /// 6 | /// More dartdocs go here. 7 | /// 8 | /// 9 | /// A simple usage example: 10 | /// 11 | /// import 'package:random_string/random_string.dart' as random; 12 | /// main() { 13 | /// print(randomBetween(10,20)); // some integer between 10 and 20 14 | /// print(randomNumeric(4)); // sequence of 4 random numbers i.e. 3259 15 | /// print(randomString(10)); // random sequence of 10 characters i.e. e~f93(4l- 16 | /// print(randomAlpha(5)); // random sequence of 5 alpha characters i.e. aRztC 17 | /// print(randomAlphaNumeric(10)); // random sequence of 10 alpha numeric i.e. aRztC1y32B 18 | /// } 19 | 20 | library random_string; 21 | 22 | import 'dart:math'; 23 | 24 | const ASCII_START = 33; 25 | const ASCII_END = 126; 26 | const NUMERIC_START = 48; 27 | const NUMERIC_END = 57; 28 | const LOWER_ALPHA_START = 97; 29 | const LOWER_ALPHA_END = 122; 30 | const UPPER_ALPHA_START = 65; 31 | const UPPER_ALPHA_END = 90; 32 | 33 | /// Generates a random integer where [from] <= [to]. 34 | int randomBetween(int from, int to) { 35 | if (from > to) throw Exception('$from cannot be > $to'); 36 | var rand = Random(); 37 | return ((to - from) * rand.nextDouble()).toInt() + from; 38 | } 39 | 40 | /// Generates a random string of [length] with characters 41 | /// between ascii [from] to [to]. 42 | /// Defaults to characters of ascii '!' to '~'. 43 | String randomString(int length, {int from: ASCII_START, int to: ASCII_END}) { 44 | return String.fromCharCodes( 45 | List.generate(length, (index) => randomBetween(from, to))); 46 | } 47 | 48 | /// Generates a random string of [length] with only numeric characters. 49 | String randomNumeric(int length) => 50 | randomString(length, from: NUMERIC_START, to: NUMERIC_END); 51 | /* 52 | /// Generates a random string of [length] with only alpha characters. 53 | String randomAlpha(int length) { 54 | var lowerAlphaLength = randomBetween(0, length); 55 | var upperAlphaLength = length - lowerAlphaLength; 56 | var lowerAlpha = randomString(lowerAlphaLength, 57 | from: LOWER_ALPHA_START, to: LOWER_ALPHA_END); 58 | var upperAlpha = randomString(upperAlphaLength, 59 | from: UPPER_ALPHA_START, to: UPPER_ALPHA_END); 60 | return randomMerge(lowerAlpha, upperAlpha); 61 | } 62 | 63 | /// Generates a random string of [length] with alpha-numeric characters. 64 | String randomAlphaNumeric(int length) { 65 | var alphaLength = randomBetween(0, length); 66 | var numericLength = length - alphaLength; 67 | var alpha = randomAlpha(alphaLength); 68 | var numeric = randomNumeric(numericLength); 69 | return randomMerge(alpha, numeric); 70 | } 71 | 72 | /// Merge [a] with [b] and scramble characters. 73 | String randomMerge(String a, String b) { 74 | var mergedCodeUnits = List.from("$a$b".codeUnits); 75 | mergedCodeUnits.shuffle(); 76 | return String.fromCharCodes(mergedCodeUnits); 77 | }*/ 78 | -------------------------------------------------------------------------------- /lib/src/call_sample/settings.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'dart:core'; 3 | 4 | class CallSettings extends StatefulWidget { 5 | static String tag = 'call_settings'; 6 | 7 | @override 8 | _CallSettingsState createState() => _CallSettingsState(); 9 | } 10 | 11 | class _CallSettingsState extends State { 12 | @override 13 | initState() { 14 | super.initState(); 15 | } 16 | 17 | @override 18 | deactivate() { 19 | super.deactivate(); 20 | } 21 | 22 | @override 23 | Widget build(BuildContext context) { 24 | return Scaffold( 25 | appBar: AppBar( 26 | title: Text('Settings'), 27 | ), 28 | body: OrientationBuilder( 29 | builder: (context, orientation) { 30 | return Center(child: Text("settings")); 31 | }, 32 | ), 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/src/call_sample/signaling.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:async'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_webrtc/flutter_webrtc.dart'; 5 | 6 | import '../utils/screen_select_dialog.dart'; 7 | import 'random_string.dart'; 8 | 9 | import '../utils/device_info.dart' 10 | if (dart.library.js) '../utils/device_info_web.dart'; 11 | import '../utils/websocket.dart' 12 | if (dart.library.js) '../utils/websocket_web.dart'; 13 | import '../utils/turn.dart' if (dart.library.js) '../utils/turn_web.dart'; 14 | 15 | enum SignalingState { 16 | ConnectionOpen, 17 | ConnectionClosed, 18 | ConnectionError, 19 | } 20 | 21 | enum CallState { 22 | CallStateNew, 23 | CallStateRinging, 24 | CallStateInvite, 25 | CallStateConnected, 26 | CallStateBye, 27 | } 28 | 29 | enum VideoSource { 30 | Camera, 31 | Screen, 32 | } 33 | 34 | class Session { 35 | Session({required this.sid, required this.pid}); 36 | String pid; 37 | String sid; 38 | RTCPeerConnection? pc; 39 | RTCDataChannel? dc; 40 | List remoteCandidates = []; 41 | } 42 | 43 | class Signaling { 44 | Signaling(this._host, this._context); 45 | 46 | JsonEncoder _encoder = JsonEncoder(); 47 | JsonDecoder _decoder = JsonDecoder(); 48 | String _selfId = randomNumeric(6); 49 | SimpleWebSocket? _socket; 50 | BuildContext? _context; 51 | var _host; 52 | var _port = 8086; 53 | var _turnCredential; 54 | Map _sessions = {}; 55 | MediaStream? _localStream; 56 | List _remoteStreams = []; 57 | List _senders = []; 58 | VideoSource _videoSource = VideoSource.Camera; 59 | 60 | Function(SignalingState state)? onSignalingStateChange; 61 | Function(Session session, CallState state)? onCallStateChange; 62 | Function(MediaStream stream)? onLocalStream; 63 | Function(Session session, MediaStream stream)? onAddRemoteStream; 64 | Function(Session session, MediaStream stream)? onRemoveRemoteStream; 65 | Function(dynamic event)? onPeersUpdate; 66 | Function(Session session, RTCDataChannel dc, RTCDataChannelMessage data)? 67 | onDataChannelMessage; 68 | Function(Session session, RTCDataChannel dc)? onDataChannel; 69 | 70 | String get sdpSemantics => 'unified-plan'; 71 | 72 | Map _iceServers = { 73 | 'iceServers': [ 74 | {'url': 'stun:stun.l.google.com:19302'}, 75 | /* 76 | * turn server configuration example. 77 | { 78 | 'url': 'turn:123.45.67.89:3478', 79 | 'username': 'change_to_real_user', 80 | 'credential': 'change_to_real_secret' 81 | }, 82 | */ 83 | ] 84 | }; 85 | 86 | final Map _config = { 87 | 'mandatory': {}, 88 | 'optional': [ 89 | {'DtlsSrtpKeyAgreement': true}, 90 | ] 91 | }; 92 | 93 | final Map _dcConstraints = { 94 | 'mandatory': { 95 | 'OfferToReceiveAudio': false, 96 | 'OfferToReceiveVideo': false, 97 | }, 98 | 'optional': [], 99 | }; 100 | 101 | close() async { 102 | await _cleanSessions(); 103 | _socket?.close(); 104 | } 105 | 106 | void switchCamera() { 107 | if (_localStream != null) { 108 | if (_videoSource != VideoSource.Camera) { 109 | _senders.forEach((sender) { 110 | if (sender.track!.kind == 'video') { 111 | sender.replaceTrack(_localStream!.getVideoTracks()[0]); 112 | } 113 | }); 114 | _videoSource = VideoSource.Camera; 115 | onLocalStream?.call(_localStream!); 116 | } else { 117 | Helper.switchCamera(_localStream!.getVideoTracks()[0]); 118 | } 119 | } 120 | } 121 | 122 | void switchToScreenSharing(MediaStream stream) { 123 | if (_localStream != null && _videoSource != VideoSource.Screen) { 124 | _senders.forEach((sender) { 125 | if (sender.track!.kind == 'video') { 126 | sender.replaceTrack(stream.getVideoTracks()[0]); 127 | } 128 | }); 129 | onLocalStream?.call(stream); 130 | _videoSource = VideoSource.Screen; 131 | } 132 | } 133 | 134 | void muteMic() { 135 | if (_localStream != null) { 136 | bool enabled = _localStream!.getAudioTracks()[0].enabled; 137 | _localStream!.getAudioTracks()[0].enabled = !enabled; 138 | } 139 | } 140 | 141 | void invite(String peerId, String media, bool useScreen) async { 142 | var sessionId = _selfId + '-' + peerId; 143 | Session session = await _createSession(null, 144 | peerId: peerId, 145 | sessionId: sessionId, 146 | media: media, 147 | screenSharing: useScreen); 148 | _sessions[sessionId] = session; 149 | if (media == 'data') { 150 | _createDataChannel(session); 151 | } 152 | _createOffer(session, media); 153 | onCallStateChange?.call(session, CallState.CallStateNew); 154 | onCallStateChange?.call(session, CallState.CallStateInvite); 155 | } 156 | 157 | void bye(String sessionId) { 158 | _send('bye', { 159 | 'session_id': sessionId, 160 | 'from': _selfId, 161 | }); 162 | var sess = _sessions[sessionId]; 163 | if (sess != null) { 164 | _closeSession(sess); 165 | } 166 | } 167 | 168 | void accept(String sessionId, String media) { 169 | var session = _sessions[sessionId]; 170 | if (session == null) { 171 | return; 172 | } 173 | _createAnswer(session, media); 174 | } 175 | 176 | void reject(String sessionId) { 177 | var session = _sessions[sessionId]; 178 | if (session == null) { 179 | return; 180 | } 181 | bye(session.sid); 182 | } 183 | 184 | void onMessage(message) async { 185 | Map mapData = message; 186 | var data = mapData['data']; 187 | 188 | switch (mapData['type']) { 189 | case 'peers': 190 | { 191 | List peers = data; 192 | if (onPeersUpdate != null) { 193 | Map event = Map(); 194 | event['self'] = _selfId; 195 | event['peers'] = peers; 196 | onPeersUpdate?.call(event); 197 | } 198 | } 199 | break; 200 | case 'offer': 201 | { 202 | var peerId = data['from']; 203 | var description = data['description']; 204 | var media = data['media']; 205 | var sessionId = data['session_id']; 206 | var session = _sessions[sessionId]; 207 | var newSession = await _createSession(session, 208 | peerId: peerId, 209 | sessionId: sessionId, 210 | media: media, 211 | screenSharing: false); 212 | _sessions[sessionId] = newSession; 213 | await newSession.pc?.setRemoteDescription( 214 | RTCSessionDescription(description['sdp'], description['type'])); 215 | // await _createAnswer(newSession, media); 216 | 217 | if (newSession.remoteCandidates.length > 0) { 218 | newSession.remoteCandidates.forEach((candidate) async { 219 | await newSession.pc?.addCandidate(candidate); 220 | }); 221 | newSession.remoteCandidates.clear(); 222 | } 223 | onCallStateChange?.call(newSession, CallState.CallStateNew); 224 | onCallStateChange?.call(newSession, CallState.CallStateRinging); 225 | } 226 | break; 227 | case 'answer': 228 | { 229 | var description = data['description']; 230 | var sessionId = data['session_id']; 231 | var session = _sessions[sessionId]; 232 | session?.pc?.setRemoteDescription( 233 | RTCSessionDescription(description['sdp'], description['type'])); 234 | onCallStateChange?.call(session!, CallState.CallStateConnected); 235 | } 236 | break; 237 | case 'candidate': 238 | { 239 | var peerId = data['from']; 240 | var candidateMap = data['candidate']; 241 | var sessionId = data['session_id']; 242 | var session = _sessions[sessionId]; 243 | RTCIceCandidate candidate = RTCIceCandidate(candidateMap['candidate'], 244 | candidateMap['sdpMid'], candidateMap['sdpMLineIndex']); 245 | 246 | if (session != null) { 247 | if (session.pc != null) { 248 | await session.pc?.addCandidate(candidate); 249 | } else { 250 | session.remoteCandidates.add(candidate); 251 | } 252 | } else { 253 | _sessions[sessionId] = Session(pid: peerId, sid: sessionId) 254 | ..remoteCandidates.add(candidate); 255 | } 256 | } 257 | break; 258 | case 'leave': 259 | { 260 | var peerId = data as String; 261 | _closeSessionByPeerId(peerId); 262 | } 263 | break; 264 | case 'bye': 265 | { 266 | var sessionId = data['session_id']; 267 | print('bye: ' + sessionId); 268 | var session = _sessions.remove(sessionId); 269 | if (session != null) { 270 | onCallStateChange?.call(session, CallState.CallStateBye); 271 | _closeSession(session); 272 | } 273 | } 274 | break; 275 | case 'keepalive': 276 | { 277 | print('keepalive response!'); 278 | } 279 | break; 280 | default: 281 | break; 282 | } 283 | } 284 | 285 | Future connect() async { 286 | var url = 'https://$_host:$_port/ws'; 287 | _socket = SimpleWebSocket(url); 288 | 289 | print('connect to $url'); 290 | 291 | if (_turnCredential == null) { 292 | try { 293 | _turnCredential = await getTurnCredential(_host, _port); 294 | /*{ 295 | "username": "1584195784:mbzrxpgjys", 296 | "password": "isyl6FF6nqMTB9/ig5MrMRUXqZg", 297 | "ttl": 86400, 298 | "uris": ["turn:127.0.0.1:19302?transport=udp"] 299 | } 300 | */ 301 | _iceServers = { 302 | 'iceServers': [ 303 | { 304 | 'urls': _turnCredential['uris'][0], 305 | 'username': _turnCredential['username'], 306 | 'credential': _turnCredential['password'] 307 | }, 308 | ] 309 | }; 310 | } catch (e) {} 311 | } 312 | 313 | _socket?.onOpen = () { 314 | print('onOpen'); 315 | onSignalingStateChange?.call(SignalingState.ConnectionOpen); 316 | _send('new', { 317 | 'name': DeviceInfo.label, 318 | 'id': _selfId, 319 | 'user_agent': DeviceInfo.userAgent 320 | }); 321 | }; 322 | 323 | _socket?.onMessage = (message) { 324 | print('Received data: ' + message); 325 | onMessage(_decoder.convert(message)); 326 | }; 327 | 328 | _socket?.onClose = (int? code, String? reason) { 329 | print('Closed by server [$code => $reason]!'); 330 | onSignalingStateChange?.call(SignalingState.ConnectionClosed); 331 | }; 332 | 333 | await _socket?.connect(); 334 | } 335 | 336 | Future createStream(String media, bool userScreen, 337 | {BuildContext? context}) async { 338 | final Map mediaConstraints = { 339 | 'audio': userScreen ? false : true, 340 | 'video': userScreen 341 | ? true 342 | : { 343 | 'mandatory': { 344 | 'minWidth': 345 | '640', // Provide your own width, height and frame rate here 346 | 'minHeight': '480', 347 | 'minFrameRate': '30', 348 | }, 349 | 'facingMode': 'user', 350 | 'optional': [], 351 | } 352 | }; 353 | late MediaStream stream; 354 | if (userScreen) { 355 | if (WebRTC.platformIsDesktop) { 356 | final source = await showDialog( 357 | context: context!, 358 | builder: (context) => ScreenSelectDialog(), 359 | ); 360 | stream = await navigator.mediaDevices.getDisplayMedia({ 361 | 'video': source == null 362 | ? true 363 | : { 364 | 'deviceId': {'exact': source.id}, 365 | 'mandatory': {'frameRate': 30.0} 366 | } 367 | }); 368 | } else { 369 | stream = await navigator.mediaDevices.getDisplayMedia(mediaConstraints); 370 | } 371 | } else { 372 | stream = await navigator.mediaDevices.getUserMedia(mediaConstraints); 373 | } 374 | 375 | onLocalStream?.call(stream); 376 | return stream; 377 | } 378 | 379 | Future _createSession( 380 | Session? session, { 381 | required String peerId, 382 | required String sessionId, 383 | required String media, 384 | required bool screenSharing, 385 | }) async { 386 | var newSession = session ?? Session(sid: sessionId, pid: peerId); 387 | if (media != 'data') 388 | _localStream = 389 | await createStream(media, screenSharing, context: _context); 390 | print(_iceServers); 391 | RTCPeerConnection pc = await createPeerConnection({ 392 | ..._iceServers, 393 | ...{'sdpSemantics': sdpSemantics} 394 | }, _config); 395 | if (media != 'data') { 396 | switch (sdpSemantics) { 397 | case 'plan-b': 398 | pc.onAddStream = (MediaStream stream) { 399 | onAddRemoteStream?.call(newSession, stream); 400 | _remoteStreams.add(stream); 401 | }; 402 | await pc.addStream(_localStream!); 403 | break; 404 | case 'unified-plan': 405 | // Unified-Plan 406 | pc.onTrack = (event) { 407 | if (event.track.kind == 'video') { 408 | onAddRemoteStream?.call(newSession, event.streams[0]); 409 | } 410 | }; 411 | _localStream!.getTracks().forEach((track) async { 412 | _senders.add(await pc.addTrack(track, _localStream!)); 413 | }); 414 | break; 415 | } 416 | 417 | // Unified-Plan: Simuclast 418 | /* 419 | await pc.addTransceiver( 420 | track: _localStream.getAudioTracks()[0], 421 | init: RTCRtpTransceiverInit( 422 | direction: TransceiverDirection.SendOnly, streams: [_localStream]), 423 | ); 424 | 425 | await pc.addTransceiver( 426 | track: _localStream.getVideoTracks()[0], 427 | init: RTCRtpTransceiverInit( 428 | direction: TransceiverDirection.SendOnly, 429 | streams: [ 430 | _localStream 431 | ], 432 | sendEncodings: [ 433 | RTCRtpEncoding(rid: 'f', active: true), 434 | RTCRtpEncoding( 435 | rid: 'h', 436 | active: true, 437 | scaleResolutionDownBy: 2.0, 438 | maxBitrate: 150000, 439 | ), 440 | RTCRtpEncoding( 441 | rid: 'q', 442 | active: true, 443 | scaleResolutionDownBy: 4.0, 444 | maxBitrate: 100000, 445 | ), 446 | ]), 447 | );*/ 448 | /* 449 | var sender = pc.getSenders().find(s => s.track.kind == "video"); 450 | var parameters = sender.getParameters(); 451 | if(!parameters) 452 | parameters = {}; 453 | parameters.encodings = [ 454 | { rid: "h", active: true, maxBitrate: 900000 }, 455 | { rid: "m", active: true, maxBitrate: 300000, scaleResolutionDownBy: 2 }, 456 | { rid: "l", active: true, maxBitrate: 100000, scaleResolutionDownBy: 4 } 457 | ]; 458 | sender.setParameters(parameters); 459 | */ 460 | } 461 | pc.onIceCandidate = (candidate) async { 462 | if (candidate == null) { 463 | print('onIceCandidate: complete!'); 464 | return; 465 | } 466 | // This delay is needed to allow enough time to try an ICE candidate 467 | // before skipping to the next one. 1 second is just an heuristic value 468 | // and should be thoroughly tested in your own environment. 469 | await Future.delayed( 470 | const Duration(seconds: 1), 471 | () => _send('candidate', { 472 | 'to': peerId, 473 | 'from': _selfId, 474 | 'candidate': { 475 | 'sdpMLineIndex': candidate.sdpMLineIndex, 476 | 'sdpMid': candidate.sdpMid, 477 | 'candidate': candidate.candidate, 478 | }, 479 | 'session_id': sessionId, 480 | })); 481 | }; 482 | 483 | pc.onIceConnectionState = (state) {}; 484 | 485 | pc.onRemoveStream = (stream) { 486 | onRemoveRemoteStream?.call(newSession, stream); 487 | _remoteStreams.removeWhere((it) { 488 | return (it.id == stream.id); 489 | }); 490 | }; 491 | 492 | pc.onDataChannel = (channel) { 493 | _addDataChannel(newSession, channel); 494 | }; 495 | 496 | newSession.pc = pc; 497 | return newSession; 498 | } 499 | 500 | void _addDataChannel(Session session, RTCDataChannel channel) { 501 | channel.onDataChannelState = (e) {}; 502 | channel.onMessage = (RTCDataChannelMessage data) { 503 | onDataChannelMessage?.call(session, channel, data); 504 | }; 505 | session.dc = channel; 506 | onDataChannel?.call(session, channel); 507 | } 508 | 509 | Future _createDataChannel(Session session, 510 | {label: 'fileTransfer'}) async { 511 | RTCDataChannelInit dataChannelDict = RTCDataChannelInit() 512 | ..maxRetransmits = 30; 513 | RTCDataChannel channel = 514 | await session.pc!.createDataChannel(label, dataChannelDict); 515 | _addDataChannel(session, channel); 516 | } 517 | 518 | Future _createOffer(Session session, String media) async { 519 | try { 520 | RTCSessionDescription s = 521 | await session.pc!.createOffer(media == 'data' ? _dcConstraints : {}); 522 | await session.pc!.setLocalDescription(_fixSdp(s)); 523 | _send('offer', { 524 | 'to': session.pid, 525 | 'from': _selfId, 526 | 'description': {'sdp': s.sdp, 'type': s.type}, 527 | 'session_id': session.sid, 528 | 'media': media, 529 | }); 530 | } catch (e) { 531 | print(e.toString()); 532 | } 533 | } 534 | 535 | RTCSessionDescription _fixSdp(RTCSessionDescription s) { 536 | var sdp = s.sdp; 537 | s.sdp = 538 | sdp!.replaceAll('profile-level-id=640c1f', 'profile-level-id=42e032'); 539 | return s; 540 | } 541 | 542 | Future _createAnswer(Session session, String media) async { 543 | try { 544 | RTCSessionDescription s = 545 | await session.pc!.createAnswer(media == 'data' ? _dcConstraints : {}); 546 | await session.pc!.setLocalDescription(_fixSdp(s)); 547 | _send('answer', { 548 | 'to': session.pid, 549 | 'from': _selfId, 550 | 'description': {'sdp': s.sdp, 'type': s.type}, 551 | 'session_id': session.sid, 552 | }); 553 | } catch (e) { 554 | print(e.toString()); 555 | } 556 | } 557 | 558 | _send(event, data) { 559 | var request = Map(); 560 | request["type"] = event; 561 | request["data"] = data; 562 | _socket?.send(_encoder.convert(request)); 563 | } 564 | 565 | Future _cleanSessions() async { 566 | if (_localStream != null) { 567 | _localStream!.getTracks().forEach((element) async { 568 | await element.stop(); 569 | }); 570 | await _localStream!.dispose(); 571 | _localStream = null; 572 | } 573 | _sessions.forEach((key, sess) async { 574 | await sess.pc?.close(); 575 | await sess.dc?.close(); 576 | }); 577 | _sessions.clear(); 578 | } 579 | 580 | void _closeSessionByPeerId(String peerId) { 581 | var session; 582 | _sessions.removeWhere((String key, Session sess) { 583 | var ids = key.split('-'); 584 | session = sess; 585 | return peerId == ids[0] || peerId == ids[1]; 586 | }); 587 | if (session != null) { 588 | _closeSession(session); 589 | onCallStateChange?.call(session, CallState.CallStateBye); 590 | } 591 | } 592 | 593 | Future _closeSession(Session session) async { 594 | _localStream?.getTracks().forEach((element) async { 595 | await element.stop(); 596 | }); 597 | await _localStream?.dispose(); 598 | _localStream = null; 599 | 600 | await session.pc?.close(); 601 | await session.dc?.close(); 602 | _senders.clear(); 603 | _videoSource = VideoSource.Camera; 604 | } 605 | } 606 | -------------------------------------------------------------------------------- /lib/src/route_item.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'dart:core'; 3 | 4 | typedef void RouteCallback(BuildContext context); 5 | 6 | class RouteItem { 7 | RouteItem({ 8 | required this.title, 9 | required this.subtitle, 10 | required this.push, 11 | }); 12 | 13 | final String title; 14 | final String subtitle; 15 | final RouteCallback push; 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/utils/device_info.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | class DeviceInfo { 4 | static String get label { 5 | return 'Flutter ' + 6 | Platform.operatingSystem + 7 | '(' + 8 | Platform.localHostname + 9 | ")"; 10 | } 11 | 12 | static String get userAgent { 13 | return 'flutter-webrtc/' + Platform.operatingSystem + '-plugin 0.0.1'; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/utils/device_info_web.dart: -------------------------------------------------------------------------------- 1 | // ignore: avoid_web_libraries_in_flutter 2 | import 'dart:html' as HTML; 3 | 4 | class DeviceInfo { 5 | static String get label { 6 | return 'Flutter Web'; 7 | } 8 | 9 | static String get userAgent { 10 | return 'flutter-webrtc/web-plugin 0.0.1 ' + 11 | ' ( ' + 12 | HTML.window.navigator.userAgent + 13 | ' )'; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/utils/screen_select_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_webrtc/flutter_webrtc.dart'; 5 | 6 | class ThumbnailWidget extends StatefulWidget { 7 | const ThumbnailWidget( 8 | {Key? key, 9 | required this.source, 10 | required this.selected, 11 | required this.onTap}) 12 | : super(key: key); 13 | final DesktopCapturerSource source; 14 | final bool selected; 15 | final Function(DesktopCapturerSource) onTap; 16 | 17 | @override 18 | _ThumbnailWidgetState createState() => _ThumbnailWidgetState(); 19 | } 20 | 21 | class _ThumbnailWidgetState extends State { 22 | final List _subscriptions = []; 23 | 24 | @override 25 | void initState() { 26 | super.initState(); 27 | _subscriptions.add(widget.source.onThumbnailChanged.stream.listen((event) { 28 | setState(() {}); 29 | })); 30 | _subscriptions.add(widget.source.onNameChanged.stream.listen((event) { 31 | setState(() {}); 32 | })); 33 | } 34 | 35 | @override 36 | void deactivate() { 37 | _subscriptions.forEach((element) { 38 | element.cancel(); 39 | }); 40 | super.deactivate(); 41 | } 42 | 43 | @override 44 | Widget build(BuildContext context) { 45 | return Column( 46 | children: [ 47 | Expanded( 48 | child: Container( 49 | decoration: widget.selected 50 | ? BoxDecoration( 51 | border: Border.all(width: 2, color: Colors.blueAccent)) 52 | : null, 53 | child: InkWell( 54 | onTap: () { 55 | print('Selected source id => ${widget.source.id}'); 56 | widget.onTap(widget.source); 57 | }, 58 | child: widget.source.thumbnail != null 59 | ? Image.memory( 60 | widget.source.thumbnail!, 61 | gaplessPlayback: true, 62 | alignment: Alignment.center, 63 | ) 64 | : Container(), 65 | ), 66 | )), 67 | Text( 68 | widget.source.name, 69 | style: TextStyle( 70 | fontSize: 12, 71 | color: Colors.black87, 72 | fontWeight: 73 | widget.selected ? FontWeight.bold : FontWeight.normal), 74 | ), 75 | ], 76 | ); 77 | } 78 | } 79 | 80 | // ignore: must_be_immutable 81 | class ScreenSelectDialog extends Dialog { 82 | ScreenSelectDialog() { 83 | Future.delayed(Duration(milliseconds: 100), () { 84 | _getSources(); 85 | }); 86 | _subscriptions.add(desktopCapturer.onAdded.stream.listen((source) { 87 | _sources[source.id] = source; 88 | _stateSetter?.call(() {}); 89 | })); 90 | 91 | _subscriptions.add(desktopCapturer.onRemoved.stream.listen((source) { 92 | _sources.remove(source.id); 93 | _stateSetter?.call(() {}); 94 | })); 95 | 96 | _subscriptions 97 | .add(desktopCapturer.onThumbnailChanged.stream.listen((source) { 98 | _stateSetter?.call(() {}); 99 | })); 100 | } 101 | final Map _sources = {}; 102 | SourceType _sourceType = SourceType.Screen; 103 | DesktopCapturerSource? _selected_source; 104 | final List> _subscriptions = []; 105 | StateSetter? _stateSetter; 106 | Timer? _timer; 107 | 108 | void _ok(context) async { 109 | _timer?.cancel(); 110 | _subscriptions.forEach((element) { 111 | element.cancel(); 112 | }); 113 | Navigator.pop(context, _selected_source); 114 | } 115 | 116 | void _cancel(context) async { 117 | _timer?.cancel(); 118 | _subscriptions.forEach((element) { 119 | element.cancel(); 120 | }); 121 | Navigator.pop(context, null); 122 | } 123 | 124 | Future _getSources() async { 125 | try { 126 | var sources = await desktopCapturer.getSources(types: [_sourceType]); 127 | sources.forEach((element) { 128 | print( 129 | 'name: ${element.name}, id: ${element.id}, type: ${element.type}'); 130 | }); 131 | _timer?.cancel(); 132 | _timer = Timer.periodic(Duration(seconds: 3), (timer) { 133 | desktopCapturer.updateSources(types: [_sourceType]); 134 | }); 135 | _sources.clear(); 136 | sources.forEach((element) { 137 | _sources[element.id] = element; 138 | }); 139 | _stateSetter?.call(() {}); 140 | return; 141 | } catch (e) { 142 | print(e.toString()); 143 | } 144 | } 145 | 146 | @override 147 | Widget build(BuildContext context) { 148 | return Material( 149 | type: MaterialType.transparency, 150 | child: Center( 151 | child: Container( 152 | width: 640, 153 | height: 560, 154 | color: Colors.white, 155 | child: Column( 156 | children: [ 157 | Padding( 158 | padding: EdgeInsets.all(10), 159 | child: Stack( 160 | children: [ 161 | Align( 162 | alignment: Alignment.topLeft, 163 | child: Text( 164 | 'Choose what to share', 165 | style: TextStyle(fontSize: 16, color: Colors.black87), 166 | ), 167 | ), 168 | Align( 169 | alignment: Alignment.topRight, 170 | child: InkWell( 171 | child: Icon(Icons.close), 172 | onTap: () => _cancel(context), 173 | ), 174 | ), 175 | ], 176 | ), 177 | ), 178 | Expanded( 179 | flex: 1, 180 | child: Container( 181 | width: double.infinity, 182 | padding: EdgeInsets.all(10), 183 | child: StatefulBuilder( 184 | builder: (context, setState) { 185 | _stateSetter = setState; 186 | return DefaultTabController( 187 | length: 2, 188 | child: Column( 189 | children: [ 190 | Container( 191 | constraints: BoxConstraints.expand(height: 24), 192 | child: TabBar( 193 | onTap: (value) => Future.delayed( 194 | Duration(milliseconds: 300), () { 195 | _sourceType = value == 0 196 | ? SourceType.Screen 197 | : SourceType.Window; 198 | _getSources(); 199 | }), 200 | tabs: [ 201 | Tab( 202 | child: Text( 203 | 'Entire Screen', 204 | style: TextStyle(color: Colors.black54), 205 | )), 206 | Tab( 207 | child: Text( 208 | 'Window', 209 | style: TextStyle(color: Colors.black54), 210 | )), 211 | ]), 212 | ), 213 | SizedBox( 214 | height: 2, 215 | ), 216 | Expanded( 217 | child: Container( 218 | child: TabBarView(children: [ 219 | Align( 220 | alignment: Alignment.center, 221 | child: Container( 222 | child: GridView.count( 223 | crossAxisSpacing: 8, 224 | crossAxisCount: 2, 225 | children: _sources.entries 226 | .where((element) => 227 | element.value.type == 228 | SourceType.Screen) 229 | .map((e) => ThumbnailWidget( 230 | onTap: (source) { 231 | setState(() { 232 | _selected_source = source; 233 | }); 234 | }, 235 | source: e.value, 236 | selected: 237 | _selected_source?.id == 238 | e.value.id, 239 | )) 240 | .toList(), 241 | ), 242 | )), 243 | Align( 244 | alignment: Alignment.center, 245 | child: Container( 246 | child: GridView.count( 247 | crossAxisSpacing: 8, 248 | crossAxisCount: 3, 249 | children: _sources.entries 250 | .where((element) => 251 | element.value.type == 252 | SourceType.Window) 253 | .map((e) => ThumbnailWidget( 254 | onTap: (source) { 255 | setState(() { 256 | _selected_source = source; 257 | }); 258 | }, 259 | source: e.value, 260 | selected: 261 | _selected_source?.id == 262 | e.value.id, 263 | )) 264 | .toList(), 265 | ), 266 | )), 267 | ]), 268 | ), 269 | ) 270 | ], 271 | ), 272 | ); 273 | }, 274 | ), 275 | ), 276 | ), 277 | Container( 278 | width: double.infinity, 279 | child: ButtonBar( 280 | children: [ 281 | MaterialButton( 282 | child: Text( 283 | 'Cancel', 284 | style: TextStyle(color: Colors.black54), 285 | ), 286 | onPressed: () { 287 | _cancel(context); 288 | }, 289 | ), 290 | MaterialButton( 291 | color: Theme.of(context).primaryColor, 292 | child: Text( 293 | 'Share', 294 | ), 295 | onPressed: () { 296 | _ok(context); 297 | }, 298 | ), 299 | ], 300 | ), 301 | ), 302 | ], 303 | ), 304 | )), 305 | ); 306 | } 307 | } 308 | -------------------------------------------------------------------------------- /lib/src/utils/turn.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:async'; 3 | import 'dart:io'; 4 | 5 | Future getTurnCredential(String host, int port) async { 6 | HttpClient client = HttpClient(context: SecurityContext()); 7 | client.badCertificateCallback = 8 | (X509Certificate cert, String host, int port) { 9 | print('getTurnCredential: Allow self-signed certificate => $host:$port. '); 10 | return true; 11 | }; 12 | var url = 'https://$host:$port/api/turn?service=turn&username=flutter-webrtc'; 13 | var request = await client.getUrl(Uri.parse(url)); 14 | var response = await request.close(); 15 | var responseBody = await response.transform(Utf8Decoder()).join(); 16 | print('getTurnCredential:response => $responseBody.'); 17 | Map data = JsonDecoder().convert(responseBody); 18 | return data; 19 | } 20 | -------------------------------------------------------------------------------- /lib/src/utils/turn_web.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'package:http/http.dart' as http; 3 | 4 | Future getTurnCredential(String host, int port) async { 5 | var url = 'https://$host:$port/api/turn?service=turn&username=flutter-webrtc'; 6 | final res = await http.get(Uri.parse(url)); 7 | if (res.statusCode == 200) { 8 | var data = json.decode(res.body); 9 | print('getTurnCredential:response => $data.'); 10 | return data; 11 | } 12 | return {}; 13 | } 14 | -------------------------------------------------------------------------------- /lib/src/utils/websocket.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'dart:math'; 3 | import 'dart:convert'; 4 | import 'dart:async'; 5 | 6 | class SimpleWebSocket { 7 | String _url; 8 | var _socket; 9 | Function()? onOpen; 10 | Function(dynamic msg)? onMessage; 11 | Function(int? code, String? reaso)? onClose; 12 | SimpleWebSocket(this._url); 13 | 14 | connect() async { 15 | try { 16 | //_socket = await WebSocket.connect(_url); 17 | _socket = await _connectForSelfSignedCert(_url); 18 | onOpen?.call(); 19 | _socket.listen((data) { 20 | onMessage?.call(data); 21 | }, onDone: () { 22 | onClose?.call(_socket.closeCode, _socket.closeReason); 23 | }); 24 | } catch (e) { 25 | onClose?.call(500, e.toString()); 26 | } 27 | } 28 | 29 | send(data) { 30 | if (_socket != null) { 31 | _socket.add(data); 32 | print('send: $data'); 33 | } 34 | } 35 | 36 | close() { 37 | if (_socket != null) _socket.close(); 38 | } 39 | 40 | Future _connectForSelfSignedCert(url) async { 41 | try { 42 | Random r = new Random(); 43 | String key = base64.encode(List.generate(8, (_) => r.nextInt(255))); 44 | HttpClient client = HttpClient(context: SecurityContext()); 45 | client.badCertificateCallback = 46 | (X509Certificate cert, String host, int port) { 47 | print( 48 | 'SimpleWebSocket: Allow self-signed certificate => $host:$port. '); 49 | return true; 50 | }; 51 | 52 | HttpClientRequest request = 53 | await client.getUrl(Uri.parse(url)); // form the correct url here 54 | request.headers.add('Connection', 'Upgrade'); 55 | request.headers.add('Upgrade', 'websocket'); 56 | request.headers.add( 57 | 'Sec-WebSocket-Version', '13'); // insert the correct version here 58 | request.headers.add('Sec-WebSocket-Key', key.toLowerCase()); 59 | 60 | HttpClientResponse response = await request.close(); 61 | // ignore: close_sinks 62 | Socket socket = await response.detachSocket(); 63 | var webSocket = WebSocket.fromUpgradedSocket( 64 | socket, 65 | protocol: 'signaling', 66 | serverSide: false, 67 | ); 68 | 69 | return webSocket; 70 | } catch (e) { 71 | throw e; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /lib/src/utils/websocket_web.dart: -------------------------------------------------------------------------------- 1 | // ignore: avoid_web_libraries_in_flutter 2 | import 'dart:html'; 3 | 4 | class SimpleWebSocket { 5 | String _url; 6 | var _socket; 7 | Function()? onOpen; 8 | Function(dynamic msg)? onMessage; 9 | Function(int code, String reason)? onClose; 10 | 11 | SimpleWebSocket(this._url) { 12 | _url = _url.replaceAll('https:', 'wss:'); 13 | } 14 | 15 | connect() async { 16 | try { 17 | _socket = WebSocket(_url); 18 | _socket.onOpen.listen((e) { 19 | onOpen?.call(); 20 | }); 21 | 22 | _socket.onMessage.listen((e) { 23 | onMessage?.call(e.data); 24 | }); 25 | 26 | _socket.onClose.listen((e) { 27 | onClose?.call(e.code, e.reason); 28 | }); 29 | } catch (e) { 30 | onClose?.call(500, e.toString()); 31 | } 32 | } 33 | 34 | send(data) { 35 | if (_socket != null && _socket.readyState == WebSocket.OPEN) { 36 | _socket.send(data); 37 | print('send: $data'); 38 | } else { 39 | print('WebSocket not connected, message $data not sent'); 40 | } 41 | } 42 | 43 | close() { 44 | if (_socket != null) { 45 | _socket.close(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/src/widgets/screen_select_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_webrtc/flutter_webrtc.dart'; 5 | 6 | class ThumbnailWidget extends StatefulWidget { 7 | const ThumbnailWidget( 8 | {Key? key, 9 | required this.source, 10 | required this.selected, 11 | required this.onTap}) 12 | : super(key: key); 13 | final DesktopCapturerSource source; 14 | final bool selected; 15 | final Function(DesktopCapturerSource) onTap; 16 | 17 | @override 18 | _ThumbnailWidgetState createState() => _ThumbnailWidgetState(); 19 | } 20 | 21 | class _ThumbnailWidgetState extends State { 22 | final List _subscriptions = []; 23 | 24 | @override 25 | void initState() { 26 | super.initState(); 27 | _subscriptions.add(widget.source.onThumbnailChanged.stream.listen((event) { 28 | setState(() {}); 29 | })); 30 | _subscriptions.add(widget.source.onNameChanged.stream.listen((event) { 31 | setState(() {}); 32 | })); 33 | } 34 | 35 | @override 36 | void deactivate() { 37 | _subscriptions.forEach((element) { 38 | element.cancel(); 39 | }); 40 | super.deactivate(); 41 | } 42 | 43 | @override 44 | Widget build(BuildContext context) { 45 | return Column( 46 | children: [ 47 | Expanded( 48 | child: Container( 49 | decoration: widget.selected 50 | ? BoxDecoration( 51 | border: Border.all(width: 2, color: Colors.blueAccent)) 52 | : null, 53 | child: InkWell( 54 | onTap: () { 55 | print('Selected source id => ${widget.source.id}'); 56 | widget.onTap(widget.source); 57 | }, 58 | child: widget.source.thumbnail != null 59 | ? Image.memory( 60 | widget.source.thumbnail!, 61 | gaplessPlayback: true, 62 | alignment: Alignment.center, 63 | ) 64 | : Container(), 65 | ), 66 | )), 67 | Text( 68 | widget.source.name, 69 | style: TextStyle( 70 | fontSize: 12, 71 | color: Colors.black87, 72 | fontWeight: 73 | widget.selected ? FontWeight.bold : FontWeight.normal), 74 | ), 75 | ], 76 | ); 77 | } 78 | } 79 | 80 | // ignore: must_be_immutable 81 | class ScreenSelectDialog extends Dialog { 82 | ScreenSelectDialog() { 83 | Future.delayed(Duration(milliseconds: 100), () { 84 | _getSources(); 85 | }); 86 | _subscriptions.add(desktopCapturer.onAdded.stream.listen((source) { 87 | _sources[source.id] = source; 88 | _stateSetter?.call(() {}); 89 | })); 90 | 91 | _subscriptions.add(desktopCapturer.onRemoved.stream.listen((source) { 92 | _sources.remove(source.id); 93 | _stateSetter?.call(() {}); 94 | })); 95 | 96 | _subscriptions 97 | .add(desktopCapturer.onThumbnailChanged.stream.listen((source) { 98 | _stateSetter?.call(() {}); 99 | })); 100 | } 101 | final Map _sources = {}; 102 | SourceType _sourceType = SourceType.Screen; 103 | DesktopCapturerSource? _selected_source; 104 | final List> _subscriptions = []; 105 | StateSetter? _stateSetter; 106 | Timer? _timer; 107 | 108 | void _ok(context) async { 109 | _timer?.cancel(); 110 | _subscriptions.forEach((element) { 111 | element.cancel(); 112 | }); 113 | Navigator.pop(context, _selected_source); 114 | } 115 | 116 | void _cancel(context) async { 117 | _timer?.cancel(); 118 | _subscriptions.forEach((element) { 119 | element.cancel(); 120 | }); 121 | Navigator.pop(context, null); 122 | } 123 | 124 | Future _getSources() async { 125 | try { 126 | var sources = await desktopCapturer.getSources(types: [_sourceType]); 127 | sources.forEach((element) { 128 | print( 129 | 'name: ${element.name}, id: ${element.id}, type: ${element.type}'); 130 | }); 131 | _timer?.cancel(); 132 | _timer = Timer.periodic(Duration(seconds: 3), (timer) { 133 | desktopCapturer.updateSources(types: [_sourceType]); 134 | }); 135 | _sources.clear(); 136 | sources.forEach((element) { 137 | _sources[element.id] = element; 138 | }); 139 | _stateSetter?.call(() {}); 140 | return; 141 | } catch (e) { 142 | print(e.toString()); 143 | } 144 | } 145 | 146 | @override 147 | Widget build(BuildContext context) { 148 | return Material( 149 | type: MaterialType.transparency, 150 | child: Center( 151 | child: Container( 152 | width: 640, 153 | height: 560, 154 | color: Colors.white, 155 | child: Column( 156 | children: [ 157 | Padding( 158 | padding: EdgeInsets.all(10), 159 | child: Stack( 160 | children: [ 161 | Align( 162 | alignment: Alignment.topLeft, 163 | child: Text( 164 | 'Choose what to share', 165 | style: TextStyle(fontSize: 16, color: Colors.black87), 166 | ), 167 | ), 168 | Align( 169 | alignment: Alignment.topRight, 170 | child: InkWell( 171 | child: Icon(Icons.close), 172 | onTap: () => _cancel(context), 173 | ), 174 | ), 175 | ], 176 | ), 177 | ), 178 | Expanded( 179 | flex: 1, 180 | child: Container( 181 | width: double.infinity, 182 | padding: EdgeInsets.all(10), 183 | child: StatefulBuilder( 184 | builder: (context, setState) { 185 | _stateSetter = setState; 186 | return DefaultTabController( 187 | length: 2, 188 | child: Column( 189 | children: [ 190 | Container( 191 | constraints: BoxConstraints.expand(height: 24), 192 | child: TabBar( 193 | onTap: (value) => Future.delayed( 194 | Duration(milliseconds: 300), () { 195 | _sourceType = value == 0 196 | ? SourceType.Screen 197 | : SourceType.Window; 198 | _getSources(); 199 | }), 200 | tabs: [ 201 | Tab( 202 | child: Text( 203 | 'Entire Screen', 204 | style: TextStyle(color: Colors.black54), 205 | )), 206 | Tab( 207 | child: Text( 208 | 'Window', 209 | style: TextStyle(color: Colors.black54), 210 | )), 211 | ]), 212 | ), 213 | SizedBox( 214 | height: 2, 215 | ), 216 | Expanded( 217 | child: Container( 218 | child: TabBarView(children: [ 219 | Align( 220 | alignment: Alignment.center, 221 | child: Container( 222 | child: GridView.count( 223 | crossAxisSpacing: 8, 224 | crossAxisCount: 2, 225 | children: _sources.entries 226 | .where((element) => 227 | element.value.type == 228 | SourceType.Screen) 229 | .map((e) => ThumbnailWidget( 230 | onTap: (source) { 231 | setState(() { 232 | _selected_source = source; 233 | }); 234 | }, 235 | source: e.value, 236 | selected: 237 | _selected_source?.id == 238 | e.value.id, 239 | )) 240 | .toList(), 241 | ), 242 | )), 243 | Align( 244 | alignment: Alignment.center, 245 | child: Container( 246 | child: GridView.count( 247 | crossAxisSpacing: 8, 248 | crossAxisCount: 3, 249 | children: _sources.entries 250 | .where((element) => 251 | element.value.type == 252 | SourceType.Window) 253 | .map((e) => ThumbnailWidget( 254 | onTap: (source) { 255 | setState(() { 256 | _selected_source = source; 257 | }); 258 | }, 259 | source: e.value, 260 | selected: 261 | _selected_source?.id == 262 | e.value.id, 263 | )) 264 | .toList(), 265 | ), 266 | )), 267 | ]), 268 | ), 269 | ) 270 | ], 271 | ), 272 | ); 273 | }, 274 | ), 275 | ), 276 | ), 277 | Container( 278 | width: double.infinity, 279 | child: ButtonBar( 280 | children: [ 281 | MaterialButton( 282 | child: Text( 283 | 'Cancel', 284 | style: TextStyle(color: Colors.black54), 285 | ), 286 | onPressed: () { 287 | _cancel(context); 288 | }, 289 | ), 290 | MaterialButton( 291 | color: Theme.of(context).primaryColor, 292 | child: Text( 293 | 'Share', 294 | ), 295 | onPressed: () { 296 | _ok(context); 297 | }, 298 | ), 299 | ], 300 | ), 301 | ), 302 | ], 303 | ), 304 | )), 305 | ); 306 | } 307 | } 308 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/xcuserdata/ 7 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | 9 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 10 | } 11 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /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 = flutter_webrtc_demo 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterWebrtcDemo 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2019 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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.device.camera 10 | 11 | com.apple.security.device.microphone 12 | 13 | com.apple.security.network.client 14 | 15 | com.apple.security.network.server 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /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 | NSCameraUsageDescription 20 | $(PRODUCT_NAME) Camera Usage! 21 | NSMicrophoneUsageDescription 22 | $(PRODUCT_NAME) Microphone Usage! 23 | CFBundleShortVersionString 24 | $(FLUTTER_BUILD_NAME) 25 | CFBundleVersion 26 | $(FLUTTER_BUILD_NUMBER) 27 | LSMinimumSystemVersion 28 | $(MACOSX_DEPLOYMENT_TARGET) 29 | NSHumanReadableCopyright 30 | $(PRODUCT_COPYRIGHT) 31 | NSMainNibFile 32 | MainMenu 33 | NSPrincipalClass 34 | NSApplication 35 | 36 | 37 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 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 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.device.camera 8 | 9 | com.apple.security.device.microphone 10 | 11 | com.apple.security.network.client 12 | 13 | com.apple.security.network.server 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "2.11.0" 12 | boolean_selector: 13 | dependency: transitive 14 | description: 15 | name: boolean_selector 16 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.1.1" 20 | characters: 21 | dependency: transitive 22 | description: 23 | name: characters 24 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "1.3.0" 28 | clock: 29 | dependency: transitive 30 | description: 31 | name: clock 32 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "1.1.1" 36 | collection: 37 | dependency: transitive 38 | description: 39 | name: collection 40 | sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.19.0" 44 | cupertino_icons: 45 | dependency: "direct main" 46 | description: 47 | name: cupertino_icons 48 | sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 49 | url: "https://pub.dev" 50 | source: hosted 51 | version: "1.0.8" 52 | dart_webrtc: 53 | dependency: transitive 54 | description: 55 | name: dart_webrtc 56 | sha256: e65506edb452148220efab53d8d2f8bb9d827bd8bcd53cf3a3e6df70b27f3d86 57 | url: "https://pub.dev" 58 | source: hosted 59 | version: "1.4.10" 60 | fake_async: 61 | dependency: transitive 62 | description: 63 | name: fake_async 64 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" 65 | url: "https://pub.dev" 66 | source: hosted 67 | version: "1.3.1" 68 | ffi: 69 | dependency: transitive 70 | description: 71 | name: ffi 72 | sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" 73 | url: "https://pub.dev" 74 | source: hosted 75 | version: "2.1.3" 76 | file: 77 | dependency: transitive 78 | description: 79 | name: file 80 | sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 81 | url: "https://pub.dev" 82 | source: hosted 83 | version: "7.0.1" 84 | flutter: 85 | dependency: "direct main" 86 | description: flutter 87 | source: sdk 88 | version: "0.0.0" 89 | flutter_test: 90 | dependency: "direct dev" 91 | description: flutter 92 | source: sdk 93 | version: "0.0.0" 94 | flutter_web_plugins: 95 | dependency: transitive 96 | description: flutter 97 | source: sdk 98 | version: "0.0.0" 99 | flutter_webrtc: 100 | dependency: "direct main" 101 | description: 102 | name: flutter_webrtc 103 | sha256: e917067abeef2400e6a7a03db53a6e1418551e54809f18ab80447ac323eb77e4 104 | url: "https://pub.dev" 105 | source: hosted 106 | version: "0.12.8" 107 | http: 108 | dependency: "direct main" 109 | description: 110 | name: http 111 | sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" 112 | url: "https://pub.dev" 113 | source: hosted 114 | version: "0.13.6" 115 | http_parser: 116 | dependency: transitive 117 | description: 118 | name: http_parser 119 | sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" 120 | url: "https://pub.dev" 121 | source: hosted 122 | version: "4.1.2" 123 | js: 124 | dependency: transitive 125 | description: 126 | name: js 127 | sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf 128 | url: "https://pub.dev" 129 | source: hosted 130 | version: "0.7.1" 131 | leak_tracker: 132 | dependency: transitive 133 | description: 134 | name: leak_tracker 135 | sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" 136 | url: "https://pub.dev" 137 | source: hosted 138 | version: "10.0.7" 139 | leak_tracker_flutter_testing: 140 | dependency: transitive 141 | description: 142 | name: leak_tracker_flutter_testing 143 | sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" 144 | url: "https://pub.dev" 145 | source: hosted 146 | version: "3.0.8" 147 | leak_tracker_testing: 148 | dependency: transitive 149 | description: 150 | name: leak_tracker_testing 151 | sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" 152 | url: "https://pub.dev" 153 | source: hosted 154 | version: "3.0.1" 155 | logging: 156 | dependency: transitive 157 | description: 158 | name: logging 159 | sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 160 | url: "https://pub.dev" 161 | source: hosted 162 | version: "1.3.0" 163 | matcher: 164 | dependency: transitive 165 | description: 166 | name: matcher 167 | sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb 168 | url: "https://pub.dev" 169 | source: hosted 170 | version: "0.12.16+1" 171 | material_color_utilities: 172 | dependency: transitive 173 | description: 174 | name: material_color_utilities 175 | sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec 176 | url: "https://pub.dev" 177 | source: hosted 178 | version: "0.11.1" 179 | meta: 180 | dependency: transitive 181 | description: 182 | name: meta 183 | sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 184 | url: "https://pub.dev" 185 | source: hosted 186 | version: "1.15.0" 187 | path: 188 | dependency: transitive 189 | description: 190 | name: path 191 | sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" 192 | url: "https://pub.dev" 193 | source: hosted 194 | version: "1.9.0" 195 | path_provider: 196 | dependency: "direct main" 197 | description: 198 | name: path_provider 199 | sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" 200 | url: "https://pub.dev" 201 | source: hosted 202 | version: "2.1.5" 203 | path_provider_android: 204 | dependency: transitive 205 | description: 206 | name: path_provider_android 207 | sha256: "4adf4fd5423ec60a29506c76581bc05854c55e3a0b72d35bb28d661c9686edf2" 208 | url: "https://pub.dev" 209 | source: hosted 210 | version: "2.2.15" 211 | path_provider_foundation: 212 | dependency: transitive 213 | description: 214 | name: path_provider_foundation 215 | sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942" 216 | url: "https://pub.dev" 217 | source: hosted 218 | version: "2.4.1" 219 | path_provider_linux: 220 | dependency: transitive 221 | description: 222 | name: path_provider_linux 223 | sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 224 | url: "https://pub.dev" 225 | source: hosted 226 | version: "2.2.1" 227 | path_provider_platform_interface: 228 | dependency: transitive 229 | description: 230 | name: path_provider_platform_interface 231 | sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" 232 | url: "https://pub.dev" 233 | source: hosted 234 | version: "2.1.2" 235 | path_provider_windows: 236 | dependency: transitive 237 | description: 238 | name: path_provider_windows 239 | sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 240 | url: "https://pub.dev" 241 | source: hosted 242 | version: "2.3.0" 243 | platform: 244 | dependency: transitive 245 | description: 246 | name: platform 247 | sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" 248 | url: "https://pub.dev" 249 | source: hosted 250 | version: "3.1.6" 251 | platform_detect: 252 | dependency: transitive 253 | description: 254 | name: platform_detect 255 | sha256: a62f99417fc4fa2d099ce0ccdbb1bd3977920f2a64292c326271f049d4bc3a4f 256 | url: "https://pub.dev" 257 | source: hosted 258 | version: "2.1.0" 259 | plugin_platform_interface: 260 | dependency: transitive 261 | description: 262 | name: plugin_platform_interface 263 | sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" 264 | url: "https://pub.dev" 265 | source: hosted 266 | version: "2.1.8" 267 | pub_semver: 268 | dependency: transitive 269 | description: 270 | name: pub_semver 271 | sha256: "7b3cfbf654f3edd0c6298ecd5be782ce997ddf0e00531b9464b55245185bbbbd" 272 | url: "https://pub.dev" 273 | source: hosted 274 | version: "2.1.5" 275 | shared_preferences: 276 | dependency: "direct main" 277 | description: 278 | name: shared_preferences 279 | sha256: "688ee90fbfb6989c980254a56cb26ebe9bb30a3a2dff439a78894211f73de67a" 280 | url: "https://pub.dev" 281 | source: hosted 282 | version: "2.5.1" 283 | shared_preferences_android: 284 | dependency: transitive 285 | description: 286 | name: shared_preferences_android 287 | sha256: "650584dcc0a39856f369782874e562efd002a9c94aec032412c9eb81419cce1f" 288 | url: "https://pub.dev" 289 | source: hosted 290 | version: "2.4.4" 291 | shared_preferences_foundation: 292 | dependency: transitive 293 | description: 294 | name: shared_preferences_foundation 295 | sha256: "6a52cfcdaeac77cad8c97b539ff688ccfc458c007b4db12be584fbe5c0e49e03" 296 | url: "https://pub.dev" 297 | source: hosted 298 | version: "2.5.4" 299 | shared_preferences_linux: 300 | dependency: transitive 301 | description: 302 | name: shared_preferences_linux 303 | sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f" 304 | url: "https://pub.dev" 305 | source: hosted 306 | version: "2.4.1" 307 | shared_preferences_platform_interface: 308 | dependency: transitive 309 | description: 310 | name: shared_preferences_platform_interface 311 | sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80" 312 | url: "https://pub.dev" 313 | source: hosted 314 | version: "2.4.1" 315 | shared_preferences_web: 316 | dependency: transitive 317 | description: 318 | name: shared_preferences_web 319 | sha256: d2ca4132d3946fec2184261726b355836a82c33d7d5b67af32692aff18a4684e 320 | url: "https://pub.dev" 321 | source: hosted 322 | version: "2.4.2" 323 | shared_preferences_windows: 324 | dependency: transitive 325 | description: 326 | name: shared_preferences_windows 327 | sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1" 328 | url: "https://pub.dev" 329 | source: hosted 330 | version: "2.4.1" 331 | sky_engine: 332 | dependency: transitive 333 | description: flutter 334 | source: sdk 335 | version: "0.0.0" 336 | source_span: 337 | dependency: transitive 338 | description: 339 | name: source_span 340 | sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" 341 | url: "https://pub.dev" 342 | source: hosted 343 | version: "1.10.0" 344 | stack_trace: 345 | dependency: transitive 346 | description: 347 | name: stack_trace 348 | sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" 349 | url: "https://pub.dev" 350 | source: hosted 351 | version: "1.12.0" 352 | stream_channel: 353 | dependency: transitive 354 | description: 355 | name: stream_channel 356 | sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 357 | url: "https://pub.dev" 358 | source: hosted 359 | version: "2.1.2" 360 | string_scanner: 361 | dependency: transitive 362 | description: 363 | name: string_scanner 364 | sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" 365 | url: "https://pub.dev" 366 | source: hosted 367 | version: "1.3.0" 368 | synchronized: 369 | dependency: transitive 370 | description: 371 | name: synchronized 372 | sha256: "69fe30f3a8b04a0be0c15ae6490fc859a78ef4c43ae2dd5e8a623d45bfcf9225" 373 | url: "https://pub.dev" 374 | source: hosted 375 | version: "3.3.0+3" 376 | term_glyph: 377 | dependency: transitive 378 | description: 379 | name: term_glyph 380 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 381 | url: "https://pub.dev" 382 | source: hosted 383 | version: "1.2.1" 384 | test_api: 385 | dependency: transitive 386 | description: 387 | name: test_api 388 | sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" 389 | url: "https://pub.dev" 390 | source: hosted 391 | version: "0.7.3" 392 | typed_data: 393 | dependency: transitive 394 | description: 395 | name: typed_data 396 | sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 397 | url: "https://pub.dev" 398 | source: hosted 399 | version: "1.4.0" 400 | vector_math: 401 | dependency: transitive 402 | description: 403 | name: vector_math 404 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 405 | url: "https://pub.dev" 406 | source: hosted 407 | version: "2.1.4" 408 | vm_service: 409 | dependency: transitive 410 | description: 411 | name: vm_service 412 | sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b 413 | url: "https://pub.dev" 414 | source: hosted 415 | version: "14.3.0" 416 | web: 417 | dependency: transitive 418 | description: 419 | name: web 420 | sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb 421 | url: "https://pub.dev" 422 | source: hosted 423 | version: "1.1.0" 424 | webrtc_interface: 425 | dependency: transitive 426 | description: 427 | name: webrtc_interface 428 | sha256: "10fc6dc0ac16f909f5e434c18902415211d759313c87261f1e4ec5b4f6a04c26" 429 | url: "https://pub.dev" 430 | source: hosted 431 | version: "1.2.1" 432 | xdg_directories: 433 | dependency: transitive 434 | description: 435 | name: xdg_directories 436 | sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" 437 | url: "https://pub.dev" 438 | source: hosted 439 | version: "1.1.0" 440 | sdks: 441 | dart: ">=3.5.0 <4.0.0" 442 | flutter: ">=3.24.0" 443 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_webrtc_demo 2 | description: A new Flutter application. 3 | version: 1.2.0 4 | 5 | environment: 6 | sdk: '>=2.15.0 <3.0.0' 7 | flutter: '>=1.22.0' 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | 13 | cupertino_icons: ^1.0.3 14 | flutter_webrtc: ^0.12.8 15 | shared_preferences: ^2.0.7 16 | http: ^0.13.3 17 | path_provider: ^2.0.2 18 | 19 | dev_dependencies: 20 | flutter_test: 21 | sdk: flutter 22 | 23 | flutter: 24 | uses-material-design: true -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /screenshots/android-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/screenshots/android-01.png -------------------------------------------------------------------------------- /screenshots/android-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/screenshots/android-02.png -------------------------------------------------------------------------------- /screenshots/flutter-webrtc-android-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/screenshots/flutter-webrtc-android-example.png -------------------------------------------------------------------------------- /screenshots/flutter-webrtc-desktop-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/screenshots/flutter-webrtc-desktop-01.png -------------------------------------------------------------------------------- /screenshots/flutter-webrtc-desktop-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/screenshots/flutter-webrtc-desktop-02.png -------------------------------------------------------------------------------- /screenshots/flutter-webrtc-desktop-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/screenshots/flutter-webrtc-desktop-03.png -------------------------------------------------------------------------------- /screenshots/flutter-webrtc-ios-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/screenshots/flutter-webrtc-ios-example.png -------------------------------------------------------------------------------- /screenshots/ios-01.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/screenshots/ios-01.jpeg -------------------------------------------------------------------------------- /screenshots/ios-02.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/screenshots/ios-02.jpeg -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter 3 | // provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to 4 | // find child widgets in the widget tree, read text, and verify that the values of widget properties 5 | // are correct. 6 | 7 | import 'package:flutter_test/flutter_test.dart'; 8 | 9 | import 'package:flutter_webrtc_demo/main.dart'; 10 | 11 | void main() { 12 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 13 | // Build our app and trigger a frame. 14 | await tester.pumpWidget(new MyApp()); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Flutter WebRTC Demo 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(flutter_webrtc_demo LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "flutter_webrtc_demo") 5 | 6 | cmake_policy(SET CMP0063 NEW) 7 | 8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 9 | 10 | # Configure build options. 11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 12 | if(IS_MULTICONFIG) 13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 14 | CACHE STRING "" FORCE) 15 | else() 16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 17 | set(CMAKE_BUILD_TYPE "Debug" CACHE 18 | STRING "Flutter build mode" FORCE) 19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 20 | "Debug" "Profile" "Release") 21 | endif() 22 | endif() 23 | 24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 28 | 29 | # Use Unicode for all projects. 30 | add_definitions(-DUNICODE -D_UNICODE) 31 | 32 | # Compilation settings that should be applied to most targets. 33 | function(APPLY_STANDARD_SETTINGS TARGET) 34 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 36 | target_compile_options(${TARGET} PRIVATE /EHsc) 37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 39 | endfunction() 40 | 41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 42 | 43 | # Flutter library and tool build rules. 44 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 45 | 46 | # Application build 47 | add_subdirectory("runner") 48 | 49 | # Generated plugin build rules, which manage building the plugins and adding 50 | # them to the application. 51 | include(flutter/generated_plugins.cmake) 52 | 53 | 54 | # === Installation === 55 | # Support files are copied into place next to the executable, so that it can 56 | # run in place. This is done instead of making a separate bundle (as on Linux) 57 | # so that building and running from within Visual Studio will work. 58 | set(BUILD_BUNDLE_DIR "$") 59 | # Make the "install" step default, as it's required to run. 60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 63 | endif() 64 | 65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 67 | 68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 69 | COMPONENT Runtime) 70 | 71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 72 | COMPONENT Runtime) 73 | 74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 75 | COMPONENT Runtime) 76 | 77 | if(PLUGIN_BUNDLED_LIBRARIES) 78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 80 | COMPONENT Runtime) 81 | endif() 82 | 83 | # Fully re-copy the assets directory on each build to avoid having stale files 84 | # from a previous install. 85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 86 | install(CODE " 87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 88 | " COMPONENT Runtime) 89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 91 | 92 | # Install the AOT library on non-Debug builds only. 93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 94 | CONFIGURATIONS Profile;Release 95 | COMPONENT Runtime) 96 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # === Flutter Library === 13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 14 | 15 | # Published to parent scope for install step. 16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 20 | 21 | list(APPEND FLUTTER_LIBRARY_HEADERS 22 | "flutter_export.h" 23 | "flutter_windows.h" 24 | "flutter_messenger.h" 25 | "flutter_plugin_registrar.h" 26 | ) 27 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 28 | add_library(flutter INTERFACE) 29 | target_include_directories(flutter INTERFACE 30 | "${EPHEMERAL_DIR}" 31 | ) 32 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 33 | add_dependencies(flutter flutter_assemble) 34 | 35 | # === Wrapper === 36 | list(APPEND CPP_WRAPPER_SOURCES_CORE 37 | "core_implementations.cc" 38 | "standard_codec.cc" 39 | ) 40 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 41 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 42 | "plugin_registrar.cc" 43 | ) 44 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 45 | list(APPEND CPP_WRAPPER_SOURCES_APP 46 | "flutter_engine.cc" 47 | "flutter_view_controller.cc" 48 | ) 49 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 50 | 51 | # Wrapper sources needed for a plugin. 52 | add_library(flutter_wrapper_plugin STATIC 53 | ${CPP_WRAPPER_SOURCES_CORE} 54 | ${CPP_WRAPPER_SOURCES_PLUGIN} 55 | ) 56 | apply_standard_settings(flutter_wrapper_plugin) 57 | set_target_properties(flutter_wrapper_plugin PROPERTIES 58 | POSITION_INDEPENDENT_CODE ON) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | CXX_VISIBILITY_PRESET hidden) 61 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 62 | target_include_directories(flutter_wrapper_plugin PUBLIC 63 | "${WRAPPER_ROOT}/include" 64 | ) 65 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 66 | 67 | # Wrapper sources needed for the runner. 68 | add_library(flutter_wrapper_app STATIC 69 | ${CPP_WRAPPER_SOURCES_CORE} 70 | ${CPP_WRAPPER_SOURCES_APP} 71 | ) 72 | apply_standard_settings(flutter_wrapper_app) 73 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 74 | target_include_directories(flutter_wrapper_app PUBLIC 75 | "${WRAPPER_ROOT}/include" 76 | ) 77 | add_dependencies(flutter_wrapper_app flutter_assemble) 78 | 79 | # === Flutter tool backend === 80 | # _phony_ is a non-existent file to force this command to run every time, 81 | # since currently there's no way to get a full input/output list from the 82 | # flutter tool. 83 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 84 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 85 | add_custom_command( 86 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 87 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 88 | ${CPP_WRAPPER_SOURCES_APP} 89 | ${PHONY_OUTPUT} 90 | COMMAND ${CMAKE_COMMAND} -E env 91 | ${FLUTTER_TOOL_ENVIRONMENT} 92 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 93 | windows-x64 $ 94 | VERBATIM 95 | ) 96 | add_custom_target(flutter_assemble DEPENDS 97 | "${FLUTTER_LIBRARY}" 98 | ${FLUTTER_LIBRARY_HEADERS} 99 | ${CPP_WRAPPER_SOURCES_CORE} 100 | ${CPP_WRAPPER_SOURCES_PLUGIN} 101 | ${CPP_WRAPPER_SOURCES_APP} 102 | ) 103 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | #include "generated_plugin_registrant.h" 6 | 7 | #include 8 | 9 | void RegisterPlugins(flutter::PluginRegistry* registry) { 10 | FlutterWebRTCPluginRegisterWithRegistrar( 11 | registry->GetRegistrarForPlugin("FlutterWebRTCPlugin")); 12 | } 13 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 6 | #define GENERATED_PLUGIN_REGISTRANT_ 7 | 8 | #include 9 | 10 | // Registers Flutter plugins. 11 | void RegisterPlugins(flutter::PluginRegistry* registry); 12 | 13 | #endif // GENERATED_PLUGIN_REGISTRANT_ 14 | -------------------------------------------------------------------------------- /windows/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 | set(PLUGIN_BUNDLED_LIBRARIES) 10 | 11 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 12 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 13 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 14 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 15 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 16 | endforeach(plugin) 17 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "run_loop.cpp" 8 | "utils.cpp" 9 | "win32_window.cpp" 10 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 11 | "Runner.rc" 12 | "runner.exe.manifest" 13 | ) 14 | apply_standard_settings(${BINARY_NAME}) 15 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 16 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 17 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 18 | add_dependencies(${BINARY_NAME} flutter_assemble) 19 | -------------------------------------------------------------------------------- /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 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 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.cloudwebrtc" "\0" 93 | VALUE "FileDescription", "A new Flutter project." "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "flutter_webrtc_demo" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2021 com.cloudwebrtc. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "flutter_webrtc_demo.exe" "\0" 98 | VALUE "ProductName", "flutter_webrtc_demo" "\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 | -------------------------------------------------------------------------------- /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(RunLoop* run_loop, 8 | const flutter::DartProject& project) 9 | : run_loop_(run_loop), project_(project) {} 10 | 11 | FlutterWindow::~FlutterWindow() {} 12 | 13 | bool FlutterWindow::OnCreate() { 14 | if (!Win32Window::OnCreate()) { 15 | return false; 16 | } 17 | 18 | RECT frame = GetClientArea(); 19 | 20 | // The size here must match the window dimensions to avoid unnecessary surface 21 | // creation / destruction in the startup path. 22 | flutter_controller_ = std::make_unique( 23 | frame.right - frame.left, frame.bottom - frame.top, project_); 24 | // Ensure that basic setup of the controller was successful. 25 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 26 | return false; 27 | } 28 | RegisterPlugins(flutter_controller_->engine()); 29 | run_loop_->RegisterFlutterInstance(flutter_controller_->engine()); 30 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 31 | return true; 32 | } 33 | 34 | void FlutterWindow::OnDestroy() { 35 | if (flutter_controller_) { 36 | run_loop_->UnregisterFlutterInstance(flutter_controller_->engine()); 37 | flutter_controller_ = nullptr; 38 | } 39 | 40 | Win32Window::OnDestroy(); 41 | } 42 | 43 | LRESULT 44 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 45 | WPARAM const wparam, 46 | LPARAM const lparam) noexcept { 47 | // Give Flutter, including plugins, an opporutunity to handle window messages. 48 | if (flutter_controller_) { 49 | std::optional result = 50 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 51 | lparam); 52 | if (result) { 53 | return *result; 54 | } 55 | } 56 | 57 | switch (message) { 58 | case WM_FONTCHANGE: 59 | flutter_controller_->engine()->ReloadSystemFonts(); 60 | break; 61 | } 62 | 63 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 64 | } 65 | -------------------------------------------------------------------------------- /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 "run_loop.h" 10 | #include "win32_window.h" 11 | 12 | // A window that does nothing but host a Flutter view. 13 | class FlutterWindow : public Win32Window { 14 | public: 15 | // Creates a new FlutterWindow driven by the |run_loop|, hosting a 16 | // Flutter view running |project|. 17 | explicit FlutterWindow(RunLoop* run_loop, 18 | const flutter::DartProject& project); 19 | virtual ~FlutterWindow(); 20 | 21 | protected: 22 | // Win32Window: 23 | bool OnCreate() override; 24 | void OnDestroy() override; 25 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 26 | LPARAM const lparam) noexcept override; 27 | 28 | private: 29 | // The run loop driving events for this window. 30 | RunLoop* run_loop_; 31 | 32 | // The project to run. 33 | flutter::DartProject project_; 34 | 35 | // The Flutter instance hosted by this window. 36 | std::unique_ptr flutter_controller_; 37 | }; 38 | 39 | #endif // RUNNER_FLUTTER_WINDOW_H_ 40 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "run_loop.h" 7 | #include "utils.h" 8 | 9 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 10 | _In_ wchar_t *command_line, _In_ int show_command) { 11 | // Attach to console when present (e.g., 'flutter run') or create a 12 | // new console when running with a debugger. 13 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 14 | CreateAndAttachConsole(); 15 | } 16 | 17 | // Initialize COM, so that it is available for use in the library and/or 18 | // plugins. 19 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 20 | 21 | RunLoop run_loop; 22 | 23 | flutter::DartProject project(L"data"); 24 | 25 | std::vector command_line_arguments = 26 | GetCommandLineArguments(); 27 | 28 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 29 | 30 | FlutterWindow window(&run_loop, project); 31 | Win32Window::Point origin(10, 10); 32 | Win32Window::Size size(1280, 720); 33 | if (!window.CreateAndShow(L"flutter_webrtc_demo", origin, size)) { 34 | return EXIT_FAILURE; 35 | } 36 | window.SetQuitOnClose(true); 37 | 38 | run_loop.Run(); 39 | 40 | ::CoUninitialize(); 41 | return EXIT_SUCCESS; 42 | } 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flutter-webrtc/flutter-webrtc-demo/7f3b2e5c46eac73b26fdc36cc4d5c06140a6e31a/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/run_loop.cpp: -------------------------------------------------------------------------------- 1 | #include "run_loop.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | RunLoop::RunLoop() {} 8 | 9 | RunLoop::~RunLoop() {} 10 | 11 | void RunLoop::Run() { 12 | bool keep_running = true; 13 | TimePoint next_flutter_event_time = TimePoint::clock::now(); 14 | while (keep_running) { 15 | std::chrono::nanoseconds wait_duration = 16 | std::max(std::chrono::nanoseconds(0), 17 | next_flutter_event_time - TimePoint::clock::now()); 18 | ::MsgWaitForMultipleObjects( 19 | 0, nullptr, FALSE, static_cast(wait_duration.count() / 1000), 20 | QS_ALLINPUT); 21 | bool processed_events = false; 22 | MSG message; 23 | // All pending Windows messages must be processed; MsgWaitForMultipleObjects 24 | // won't return again for items left in the queue after PeekMessage. 25 | while (::PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) { 26 | processed_events = true; 27 | if (message.message == WM_QUIT) { 28 | keep_running = false; 29 | break; 30 | } 31 | ::TranslateMessage(&message); 32 | ::DispatchMessage(&message); 33 | // Allow Flutter to process messages each time a Windows message is 34 | // processed, to prevent starvation. 35 | next_flutter_event_time = 36 | std::min(next_flutter_event_time, ProcessFlutterMessages()); 37 | } 38 | // If the PeekMessage loop didn't run, process Flutter messages. 39 | if (!processed_events) { 40 | next_flutter_event_time = 41 | std::min(next_flutter_event_time, ProcessFlutterMessages()); 42 | } 43 | } 44 | } 45 | 46 | void RunLoop::RegisterFlutterInstance( 47 | flutter::FlutterEngine* flutter_instance) { 48 | flutter_instances_.insert(flutter_instance); 49 | } 50 | 51 | void RunLoop::UnregisterFlutterInstance( 52 | flutter::FlutterEngine* flutter_instance) { 53 | flutter_instances_.erase(flutter_instance); 54 | } 55 | 56 | RunLoop::TimePoint RunLoop::ProcessFlutterMessages() { 57 | TimePoint next_event_time = TimePoint::max(); 58 | for (auto instance : flutter_instances_) { 59 | std::chrono::nanoseconds wait_duration = instance->ProcessMessages(); 60 | if (wait_duration != std::chrono::nanoseconds::max()) { 61 | next_event_time = 62 | std::min(next_event_time, TimePoint::clock::now() + wait_duration); 63 | } 64 | } 65 | return next_event_time; 66 | } 67 | -------------------------------------------------------------------------------- /windows/runner/run_loop.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_RUN_LOOP_H_ 2 | #define RUNNER_RUN_LOOP_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | // A runloop that will service events for Flutter instances as well 10 | // as native messages. 11 | class RunLoop { 12 | public: 13 | RunLoop(); 14 | ~RunLoop(); 15 | 16 | // Prevent copying 17 | RunLoop(RunLoop const&) = delete; 18 | RunLoop& operator=(RunLoop const&) = delete; 19 | 20 | // Runs the run loop until the application quits. 21 | void Run(); 22 | 23 | // Registers the given Flutter instance for event servicing. 24 | void RegisterFlutterInstance( 25 | flutter::FlutterEngine* flutter_instance); 26 | 27 | // Unregisters the given Flutter instance from event servicing. 28 | void UnregisterFlutterInstance( 29 | flutter::FlutterEngine* flutter_instance); 30 | 31 | private: 32 | using TimePoint = std::chrono::steady_clock::time_point; 33 | 34 | // Processes all currently pending messages for registered Flutter instances. 35 | TimePoint ProcessFlutterMessages(); 36 | 37 | std::set flutter_instances_; 38 | }; 39 | 40 | #endif // RUNNER_RUN_LOOP_H_ 41 | -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /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 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /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 and shows a win32 window with |title| and position and size 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 to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | --------------------------------------------------------------------------------