Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions dogfooding/lib/di/injector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import '../core/repos/custom_environment_loader.dart';
import '../core/repos/token_service.dart';
import '../core/repos/user_auth_repository.dart';
import '../log_config.dart';
import '../utils/consts.dart';

GetIt locator = GetIt.instance;

Expand Down Expand Up @@ -178,9 +177,8 @@ StreamVideo _initStreamVideo(
androidPushProvider: const StreamVideoPushProvider.firebase(
name: 'flutter-firebase',
),
pushParams: const StreamVideoPushParams(
appName: kAppName,
ios: IOSParams(iconName: 'IconMask'),
pushConfiguration: const StreamVideoPushConfiguration(
ios: IOSPushConfiguration(iconName: 'IconMask'),
),
registerApnDeviceToken: true,
),
Expand Down
13 changes: 0 additions & 13 deletions packages/stream_video/lib/src/call/session/call_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'package:synchronized/synchronized.dart';
import 'package:system_info2/system_info2.dart';

import '../../../globals.dart';
import '../../../open_api/video/coordinator/api.dart';
import '../../../protobuf/video/sfu/event/events.pb.dart' as sfu_events;
import '../../../protobuf/video/sfu/models/models.pb.dart' as sfu_models;
import '../../../protobuf/video/sfu/models/models.pbenum.dart';
Expand All @@ -19,37 +18,25 @@ import '../../../stream_video.dart';
import '../../disposable.dart';
import '../../errors/video_error.dart';
import '../../errors/video_error_composer.dart';
import '../../logger/impl/tagged_logger.dart';
import '../../models/models.dart';
import '../../platform_detector/platform_detector.dart';
import '../../sfu/data/events/sfu_events.dart';
import '../../sfu/data/models/sfu_call_state.dart';
import '../../sfu/data/models/sfu_error.dart';
import '../../sfu/data/models/sfu_model_mapper_extensions.dart';
import '../../sfu/data/models/sfu_subscription_details.dart';
import '../../sfu/data/models/sfu_track_type.dart';
import '../../sfu/sfu_client.dart';
import '../../sfu/sfu_extensions.dart';
import '../../sfu/ws/sfu_ws.dart';
import '../../shared_emitter.dart';
import '../../utils/debounce_buffer.dart';
import '../../utils/none.dart';
import '../../utils/result.dart';
import '../../webrtc/media/media_constraints.dart';
import '../../webrtc/model/rtc_model_mapper_extensions.dart';
import '../../webrtc/model/rtc_tracks_info.dart';
import '../../webrtc/peer_connection.dart';
import '../../webrtc/peer_type.dart';
import '../../webrtc/rtc_manager.dart';
import '../../webrtc/rtc_manager_factory.dart';
import '../../webrtc/rtc_media_device/rtc_media_device.dart';
import '../../webrtc/rtc_track/rtc_track.dart';
import '../../webrtc/sdp/editor/sdp_editor.dart';
import '../../ws/ws.dart';
import '../state/call_state_notifier.dart';
import '../stats/tracer.dart';
import 'call_session_config.dart';
import 'dynascale_manager.dart';

const _tag = 'SV:CallSession';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import 'package:internet_connection_checker_plus/internet_connection_checker_plus.dart';
import 'package:uuid/uuid.dart';

import '../../../open_api/video/coordinator/api.dart';
import '../../../stream_video.dart';
import '../../core/utils.dart';
import '../../logger/impl/tagged_logger.dart';
import '../../models/call_cid.dart';
import '../../models/call_client_publish_options.dart';
import '../../models/call_credentials.dart';
import '../../types/other.dart';
import '../../webrtc/peer_connection.dart';
import '../../webrtc/sdp/editor/sdp_editor.dart';
import '../state/call_state_notifier.dart';
import '../stats/tracer.dart';
import 'call_session.dart';
import 'call_session_config.dart';
import 'dynascale_manager.dart';

class CallSessionFactory {
CallSessionFactory({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class CallData with EquatableMixin {
this.callCid,
this.avatar,
this.handle,
this.nameCaller,
this.callerName,
this.hasVideo,
this.extraData,
});
Expand All @@ -283,7 +283,7 @@ class CallData with EquatableMixin {
final String? handle;

/// Name of the caller.
final String? nameCaller;
final String? callerName;

/// Indicates whether the call has video.
final bool? hasVideo;
Expand All @@ -300,7 +300,7 @@ class CallData with EquatableMixin {
callCid,
avatar,
handle,
nameCaller,
callerName,
hasVideo,
extraData,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ abstract class PushNotificationManager {
/// [callCid] is the call's unique identifier.
/// [avatar] is the avatar of the caller.
/// [handle] is the handle of the caller.
/// [nameCaller] is the name of the caller.
/// [callerName] is the name of the caller.
/// [hasVideo] indicates whether the call has video (default is true).
Future<void> showIncomingCall({
required String uuid,
required String callCid,
String? avatar,
String? handle,
String? nameCaller,
String? callerName,
bool hasVideo = true,
});

Expand All @@ -49,14 +49,14 @@ abstract class PushNotificationManager {
/// [callCid] is the call's unique identifier.
/// [avatar] is the avatar of the caller.
/// [handle] is the handle of the caller.
/// [nameCaller] is the name of the caller.
/// [callerName] is the name of the caller.
/// [hasVideo] indicates whether the call has video (default is true).
Future<void> showMissedCall({
required String uuid,
required String callCid,
String? avatar,
String? handle,
String? nameCaller,
String? callerName,
bool hasVideo = true,
});

Expand All @@ -66,14 +66,14 @@ abstract class PushNotificationManager {
/// [callCid] is the call's unique identifier.
/// [avatar] is the avatar of the caller.
/// [handle] is the handle of the caller.
/// [nameCaller] is the name of the caller.
/// [callerName] is the name of the caller.
/// [hasVideo] indicates whether the call has video (default is true).
Future<void> startOutgoingCall({
required String uuid,
required String callCid,
String? avatar,
String? handle,
String? nameCaller,
String? callerName,
bool hasVideo = true,
});

Expand Down
4 changes: 2 additions & 2 deletions packages/stream_video/lib/src/stream_video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ class StreamVideo extends Disposable {
manager.showMissedCall(
uuid: callUUID,
handle: createdById,
nameCaller: (callDisplayName?.isNotEmpty ?? false)
callerName: (callDisplayName?.isNotEmpty ?? false)
? callDisplayName
: createdByName,
callCid: callCid,
Expand All @@ -954,7 +954,7 @@ class StreamVideo extends Disposable {
manager.showIncomingCall(
uuid: callUUID,
handle: createdById,
nameCaller: (callDisplayName?.isNotEmpty ?? false)
callerName: (callDisplayName?.isNotEmpty ?? false)
? callDisplayName
: createdByName,
callCid: callCid,
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_video_flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ android {
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.mockito:mockito-core:5.0.0'
implementation 'io.getstream:stream-log:1.1.3'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation "io.coil-kt:coil:1.4.0"
implementation 'androidx.core:core:1.3.0'
implementation 'androidx.media:media:1.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import android.view.View
import android.widget.RemoteViews
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import com.squareup.picasso.OkHttp3Downloader
import com.squareup.picasso.Picasso
import coil.ImageLoader
import coil.request.ImageRequest
import io.getstream.log.StreamLog
import io.getstream.log.taggedLogger
import io.getstream.video.flutter.stream_video_flutter.R
Expand All @@ -39,7 +39,6 @@ import io.getstream.video.flutter.stream_video_flutter.service.notification.imag
import io.getstream.video.flutter.stream_video_flutter.service.utils.applicationName
import io.getstream.video.flutter.stream_video_flutter.service.utils.notificationManager
import kotlinx.coroutines.CoroutineScope
import okhttp3.Headers
import okhttp3.OkHttpClient

private const val TAG = "StreamNtfBuilder"
Expand Down Expand Up @@ -163,10 +162,7 @@ internal class StreamNotificationBuilderImpl(
if (!avatarUrl.isNullOrEmpty()) {
logger.i { "[loadAvatar] avatarUrl: $avatarUrl" }
val headers = payload.options.avatar.httpHeaders
context.getPicassoInstance(headers)
.load(avatarUrl)
.transform(CircleTransform())
.into(defaultTarget(builder = this))
context.loadImageWithCoil(avatarUrl, headers, defaultTarget(builder = this))
}
}

Expand Down Expand Up @@ -213,16 +209,15 @@ internal class StreamNotificationBuilderImpl(
if (!avatarUrl.isNullOrEmpty()) {
logger.i { "[loadAvatar] avatarUrl: $avatarUrl" }
val headers = payload.options.avatar.httpHeaders
context.getPicassoInstance(headers)
.load(avatarUrl)
.transform(CircleTransform())
.into(
customTarget(
builder = this,
notificationLargeLayout = notificationLargeLayout,
notificationSmallLayout = notificationSmallLayout
)
context.loadImageWithCoil(
avatarUrl,
headers,
customTarget(
builder = this,
notificationLargeLayout = notificationLargeLayout,
notificationSmallLayout = notificationSmallLayout
)
)
}
}

Expand Down Expand Up @@ -274,9 +269,7 @@ internal class StreamNotificationBuilderImpl(
val avatarUrl = payload.options?.avatar?.url
if (!avatarUrl.isNullOrEmpty()) {
val headers = payload.options.avatar.httpHeaders
context.getPicassoInstance(headers).load(avatarUrl)
.transform(CircleTransform())
.into(customTarget)
context.loadImageWithCoil(avatarUrl, headers, customTarget)
}

return this
Expand All @@ -292,21 +285,31 @@ private fun useSmallExLayout(): Boolean {
) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S || isCustomSmallExNotification
}

private fun Context.getPicassoInstance(headers: Map<String, String>): Picasso {
StreamLog.d(TAG) { "[interceptRequest] headers: $headers" }
private fun Context.loadImageWithCoil(url: String, headers: Map<String, String>, target: coil.target.Target) {
StreamLog.d(TAG) { "[loadImageWithCoil] headers: $headers" }
val client = OkHttpClient.Builder()
.addInterceptor { chain ->
StreamLog.v(TAG) { "[interceptRequest] request: ${chain.request()}" }
val newRequest = chain.request()
.newBuilder()
.headers(Headers.of(headers))
.build()
chain.proceed(newRequest)
headers.forEach { (key, value) ->
newRequest.addHeader(key, value)
}
chain.proceed(newRequest.build())
}
.build()
return Picasso.Builder(this)
.downloader(OkHttp3Downloader(client))

val imageLoader = ImageLoader.Builder(this)
.okHttpClient(client)
.build()

val request = ImageRequest.Builder(this)
.data(url)
.transformations(CircleTransform())
.target(target)
.build()

imageLoader.enqueue(request)
}

class NotificationLayout(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
package io.getstream.video.flutter.stream_video_flutter.service.notification.image

import android.graphics.Bitmap
import android.graphics.BitmapShader
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Shader
import com.squareup.picasso.Transformation
import android.graphics.*
import coil.bitmap.BitmapPool
import coil.size.Size
import coil.transform.Transformation
import kotlin.math.min


class CircleTransform : Transformation {
override fun transform(source: Bitmap): Bitmap {
val size = minOf(source.width, source.height)
val x = (source.width - size) / 2
val y = (source.height - size) / 2
val squaredBitmap = Bitmap.createBitmap(source, x, y, size, size)
if (squaredBitmap != source) {
source.recycle()

override fun key(): String {
return "circle"
}

override suspend fun transform(pool: BitmapPool, input: Bitmap, size: Size): Bitmap {
val sizeImage = min(input.width, input.height)
val x = (input.width - sizeImage) / 2
val y = (input.height - sizeImage) / 2
val squaredBitmap = Bitmap.createBitmap(input, x, y, sizeImage, sizeImage)
if (squaredBitmap != input) {
input.recycle()
}
val config = source.config ?: Bitmap.Config.ARGB_8888
val bitmap = Bitmap.createBitmap(size, size, config)
val config = input.config ?: Bitmap.Config.ARGB_8888
val bitmap = Bitmap.createBitmap(sizeImage, sizeImage, config)
val canvas = Canvas(bitmap)
val paint = Paint()
val shader = BitmapShader(
Expand All @@ -26,13 +31,9 @@ class CircleTransform : Transformation {
)
paint.shader = shader
paint.isAntiAlias = true
val r = size / 2f
val r = sizeImage / 2f
canvas.drawCircle(r, r, r, paint)
squaredBitmap.recycle()
return bitmap
}

override fun key(): String {
return "circle"
}
}
Loading
Loading