Skip to content

Commit 0b48a2a

Browse files
authored
chore: add video filters 16kb page size support (#1956)
1 parent 95e5654 commit 0b48a2a

File tree

2 files changed

+18
-28
lines changed

2 files changed

+18
-28
lines changed

packages/video-filters-react-native/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ dependencies {
102102
implementation project(':stream-io_react-native-webrtc')
103103
implementation "io.github.crow-misia.libyuv:libyuv-android:0.36.0"
104104
implementation "androidx.annotation:annotation:1.8.0"
105-
implementation 'com.google.mlkit:segmentation-selfie:16.0.0-beta5'
106-
implementation "com.github.android:renderscript-intrinsics-replacement-toolkit:344be3f"
105+
implementation 'com.google.mlkit:segmentation-selfie:16.0.0-beta6'
106+
implementation 'io.getstream:stream-video-renderscript-android:0.0.1'
107107
}
108108

packages/video-filters-react-native/android/src/main/java/com/streamio/videofiltersreactnative/factories/VideoBlurFactory.kt

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,11 @@ package com.streamio.videofiltersreactnative.factories
22

33
import android.graphics.Bitmap
44
import android.graphics.Canvas
5-
import com.google.android.gms.tasks.Tasks
65
import com.google.android.renderscript.Toolkit
7-
import com.google.mlkit.vision.common.InputImage
8-
import com.google.mlkit.vision.segmentation.Segmentation
9-
import com.google.mlkit.vision.segmentation.SegmentationMask
10-
import com.google.mlkit.vision.segmentation.selfie.SelfieSegmenterOptions
116
import com.oney.WebRTCModule.videoEffects.VideoFrameProcessor
127
import com.oney.WebRTCModule.videoEffects.VideoFrameProcessorFactoryInterface
138
import com.streamio.videofiltersreactnative.common.BitmapVideoFilter
14-
import com.streamio.videofiltersreactnative.common.Segment
159
import com.streamio.videofiltersreactnative.common.VideoFrameProcessorWithBitmapFilter
16-
import com.streamio.videofiltersreactnative.common.copySegment
17-
import com.streamio.videofiltersreactnative.common.newSegmentationMaskMatrix
1810

1911

2012
/**
@@ -23,35 +15,33 @@ import com.streamio.videofiltersreactnative.common.newSegmentationMaskMatrix
2315
* @param blurIntensity The intensity of the blur effect. See [VideoBlurIntensity] for options. Defaults to [BlurIntensity.MEDIUM].
2416
*/
2517
class VideoBlurFactory(
26-
private val blurIntensity: VideoBlurIntensity = VideoBlurIntensity.MEDIUM
18+
private val blurIntensity: VideoBlurIntensity = VideoBlurIntensity.MEDIUM
2719
) : VideoFrameProcessorFactoryInterface {
28-
override fun build(): VideoFrameProcessor {
29-
return VideoFrameProcessorWithBitmapFilter {
30-
BlurredVideoFilter(blurIntensity)
20+
override fun build(): VideoFrameProcessor {
21+
return VideoFrameProcessorWithBitmapFilter {
22+
BlurredVideoFilter(blurIntensity)
23+
}
3124
}
32-
}
3325
}
3426

3527
private class BlurredVideoFilter(
36-
private val blurIntensity: VideoBlurIntensity
28+
private val blurIntensity: VideoBlurIntensity
3729
) : BitmapVideoFilter() {
3830

39-
override fun applyFilter(videoFrameBitmap: Bitmap) {
40-
val blurred = Toolkit.blur(videoFrameBitmap, blurIntensity.radius)
41-
val canvas = Canvas(videoFrameBitmap)
42-
// Draw the blurred bitmap at the top-left corner (0f, 0f) of the original bitmap.
43-
// 0f, 0f: x and y coordinates (top-left corner)
44-
// null: use default Paint (no special effects)
45-
canvas.drawBitmap(blurred, 0f, 0f, null)
46-
}
31+
override fun applyFilter(videoFrameBitmap: Bitmap) {
32+
val blurred = Toolkit.blur(videoFrameBitmap, blurIntensity.radius)
33+
val canvas = Canvas(videoFrameBitmap)
34+
// Draw the blurred bitmap at the top-left corner (0f, 0f) of the original bitmap.
35+
// 0f, 0f: x and y coordinates (top-left corner)
36+
// null: use default Paint (no special effects)
37+
canvas.drawBitmap(blurred, 0f, 0f, null)
38+
}
4739
}
4840

4941
/**
5042
* The intensity of the background blur effect. Used in [BlurredBackgroundVideoFilter].
5143
* Range is 1 to 25
5244
*/
5345
enum class VideoBlurIntensity(val radius: Int) {
54-
LIGHT(8),
55-
MEDIUM(17),
56-
HEAVY(25),
57-
}
46+
LIGHT(8), MEDIUM(17), HEAVY(25),
47+
}

0 commit comments

Comments
 (0)