-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Video filters * tweak * fix * custom filter added * fix * tweaks * typo fixed * changelog added
- Loading branch information
Showing
66 changed files
with
1,850 additions
and
256 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
dogfooding/android/app/src/main/kotlin/io/getstream/video/flutter/dogfooding/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,64 @@ | ||
package io.getstream.video.flutter.dogfooding | ||
|
||
import android.graphics.Bitmap | ||
import android.graphics.Canvas | ||
import android.graphics.ColorMatrix | ||
import android.graphics.ColorMatrixColorFilter | ||
import android.graphics.Paint | ||
|
||
import io.flutter.embedding.android.FlutterActivity | ||
import io.flutter.embedding.engine.FlutterEngine | ||
import io.flutter.embedding.engine.plugins.FlutterPlugin | ||
import io.flutter.embedding.engine.plugins.activity.ActivityAware | ||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding | ||
import io.flutter.plugin.common.MethodChannel | ||
import io.flutter.plugin.common.PluginRegistry | ||
|
||
import io.getstream.video.flutter.stream_video_flutter.service.PictureInPictureHelper | ||
import io.getstream.video.flutter.stream_video_flutter.videoFilters.common.VideoFrameProcessorWithBitmapFilter | ||
import io.getstream.video.flutter.stream_video_flutter.videoFilters.common.BitmapVideoFilter | ||
import io.getstream.webrtc.flutter.videoEffects.ProcessorProvider | ||
import io.getstream.webrtc.flutter.videoEffects.VideoFrameProcessor | ||
import io.getstream.webrtc.flutter.videoEffects.VideoFrameProcessorFactoryInterface | ||
|
||
class MainActivity: FlutterActivity() { | ||
private val CHANNEL = "io.getstream.video.flutter.dogfooding.channel" | ||
|
||
override fun onUserLeaveHint() { | ||
super.onUserLeaveHint() | ||
PictureInPictureHelper.enterPictureInPictureIfInCall(this) | ||
} | ||
|
||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) { | ||
super.configureFlutterEngine(flutterEngine) | ||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result -> | ||
if (call.method == "registerGreyscaleEffect") { | ||
ProcessorProvider.addProcessor("grayscale", GrayScaleVideoFilterFactory()) | ||
result.success(null) | ||
} else { | ||
result.notImplemented() | ||
} | ||
} | ||
} | ||
} | ||
|
||
class GrayScaleVideoFilterFactory : VideoFrameProcessorFactoryInterface { | ||
override fun build(): VideoFrameProcessor { | ||
return VideoFrameProcessorWithBitmapFilter { | ||
GrayScaleFilter() | ||
} | ||
} | ||
} | ||
private class GrayScaleFilter : BitmapVideoFilter() { | ||
override fun applyFilter(videoFrameBitmap: Bitmap) { | ||
val canvas = Canvas(videoFrameBitmap) | ||
val paint = Paint().apply { | ||
val colorMatrix = ColorMatrix().apply { | ||
// map the saturation of the color to grayscale | ||
setSaturation(0f) | ||
} | ||
colorFilter = ColorMatrixColorFilter(colorMatrix) | ||
} | ||
canvas.drawBitmap(videoFrameBitmap, 0f, 0f, paint) | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,75 @@ | ||
import UIKit | ||
import Flutter | ||
import UIKit | ||
import stream_video_flutter | ||
import stream_video_push_notification | ||
import stream_webrtc_flutter | ||
|
||
@UIApplicationMain | ||
@main | ||
@objc class AppDelegate: FlutterAppDelegate { | ||
|
||
private let CHANNEL = "io.getstream.video.flutter.dogfooding.channel" | ||
|
||
override func application( | ||
_ application: UIApplication, | ||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | ||
) -> Bool { | ||
GeneratedPluginRegistrant.register(with: self) | ||
|
||
// Register for push notifications. | ||
StreamVideoPKDelegateManager.shared.registerForPushNotifications() | ||
UNUserNotificationCenter.current().delegate = self | ||
|
||
|
||
let controller = window?.rootViewController as! FlutterViewController | ||
let channel = FlutterMethodChannel( | ||
name: CHANNEL, binaryMessenger: controller.binaryMessenger) | ||
channel.setMethodCallHandler { [weak self] (call, result) in | ||
self?.handleMethodCall(call: call, result: result) | ||
} | ||
|
||
return super.application(application, didFinishLaunchingWithOptions: launchOptions) | ||
} | ||
|
||
// This method will be called when notification is received | ||
override func userNotificationCenter(_ center: UNUserNotificationCenter, | ||
willPresent notification: UNNotification, | ||
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { | ||
override func userNotificationCenter( | ||
_ center: UNUserNotificationCenter, | ||
willPresent notification: UNNotification, | ||
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> | ||
Void | ||
) { | ||
let streamDict = notification.request.content.userInfo["stream"] as? [String: Any] | ||
if(streamDict?["sender"] as? String != "stream.video") { | ||
if streamDict?["sender"] as? String != "stream.video" { | ||
return completionHandler([]) | ||
} | ||
|
||
if #available(iOS 14.0, *) { | ||
completionHandler([.list, .banner, .sound]) | ||
} else { | ||
completionHandler([.alert]) | ||
} | ||
} | ||
|
||
|
||
|
||
func handleMethodCall(call: FlutterMethodCall, result: @escaping FlutterResult) { | ||
if call.method == "registerGreyscaleEffect" { | ||
ProcessorProvider.addProcessor(GrayScaleVideoFrameProcessor(), forName: "grayscale") | ||
result(nil) | ||
} else { | ||
result(FlutterMethodNotImplemented) | ||
} | ||
} | ||
} | ||
|
||
final class GrayScaleVideoFrameProcessor: VideoFilter { | ||
@available(*, unavailable) | ||
override public init( | ||
filter: @escaping (Input) -> CIImage | ||
) { fatalError() } | ||
init() { | ||
super.init( | ||
filter: { input in | ||
let filter = CIFilter(name: "CIPhotoEffectMono") | ||
filter?.setValue(input.originalImage, forKey: kCIInputImageKey) | ||
let outputImage: CIImage = filter?.outputImage ?? input.originalImage | ||
return outputImage | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:flutter/services.dart'; | ||
|
||
class DogfoodingAppChannel { | ||
static const platform = | ||
MethodChannel('io.getstream.video.flutter.dogfooding.channel'); | ||
|
||
Future<void> registerGreyscaleEffect() async { | ||
await platform.invokeMethod('registerGreyscaleEffect'); | ||
} | ||
} |
Oops, something went wrong.