diff --git a/BackgroundBlur/.bundle/config b/BackgroundBlur/.bundle/config new file mode 100644 index 0000000..848943b --- /dev/null +++ b/BackgroundBlur/.bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/BackgroundBlur/.eslintrc.js b/BackgroundBlur/.eslintrc.js new file mode 100644 index 0000000..187894b --- /dev/null +++ b/BackgroundBlur/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: '@react-native', +}; diff --git a/BackgroundBlur/.gitignore b/BackgroundBlur/.gitignore new file mode 100644 index 0000000..e6d934c --- /dev/null +++ b/BackgroundBlur/.gitignore @@ -0,0 +1,69 @@ +# OSX +# +.DS_Store + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +ios/.xcode.env.local + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml +*.hprof +.cxx/ + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + +# BUCK +buck-out/ +\.buckd/ +*.keystore +!debug.keystore + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +**/fastlane/report.xml +**/fastlane/Preview.html +**/fastlane/screenshots +**/fastlane/test_output + +# Bundle artifact +*.jsbundle + +# Ruby / CocoaPods +/ios/Pods/ +/vendor/bundle/ + +Gemfile.lock + +# testing +/coverage diff --git a/BackgroundBlur/.prettierrc.js b/BackgroundBlur/.prettierrc.js new file mode 100644 index 0000000..2b54074 --- /dev/null +++ b/BackgroundBlur/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + arrowParens: 'avoid', + bracketSameLine: true, + bracketSpacing: false, + singleQuote: true, + trailingComma: 'all', +}; diff --git a/BackgroundBlur/.ruby-version b/BackgroundBlur/.ruby-version new file mode 100644 index 0000000..a603bb5 --- /dev/null +++ b/BackgroundBlur/.ruby-version @@ -0,0 +1 @@ +2.7.5 diff --git a/BackgroundBlur/.watchmanconfig b/BackgroundBlur/.watchmanconfig new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/BackgroundBlur/.watchmanconfig @@ -0,0 +1 @@ +{} diff --git a/BackgroundBlur/App.js b/BackgroundBlur/App.js new file mode 100644 index 0000000..b1bc228 --- /dev/null +++ b/BackgroundBlur/App.js @@ -0,0 +1,63 @@ +/* eslint-disable react-native/no-inline-styles */ +import React, {Component, createRef} from 'react'; +import {View, Button} from 'react-native'; +import {OTSession, OTPublisher, OTSubscriber} from 'opentok-react-native'; + +class App extends Component { + constructor(props) { + super(props); + this.apiKey = ''; + this.sessionId = ''; + this.token = ''; + this.useBackgroundBlur = false; + this.publisher = createRef(); + this.publsiherEventHandlers = { + streamCreated: async (event: StreamCreatedEvent) => { + this.toggleBackgroundBlur(); + }, + }; + this.toggleBackgroundBlur = () => { + if (this.publisher.current) { + const blurFilter = { + name: 'BackgroundBlur', + properties: JSON.stringify({ + radius: 'High', + }), + }; + const filters = []; + this.useBackgroundBlur = !this.useBackgroundBlur; + if (this.useBackgroundBlur) { + filters.push(blurFilter); + } + this.publisher.current.setVideoTransformers(filters); + } + }; + } + + render() { + return ( + + + + + +