expo-realtime-ivs-broadcast 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -53,7 +53,7 @@ class ExpoIVSStagePreviewView(context: Context, appContext: AppContext) : ExpoVi
|
|
|
53
53
|
for (i in 0 until count) {
|
|
54
54
|
val child = getChildAt(i) ?: continue // Skip null children
|
|
55
55
|
try {
|
|
56
|
-
|
|
56
|
+
child.layout(0, 0, childWidth, childHeight)
|
|
57
57
|
} catch (e: Exception) {
|
|
58
58
|
Log.w("ExpoIVSStagePreviewView", "Error laying out child $i: ${e.message}")
|
|
59
59
|
}
|
|
@@ -78,7 +78,7 @@ class ExpoIVSStagePreviewView(context: Context, appContext: AppContext) : ExpoVi
|
|
|
78
78
|
for (i in 0 until count) {
|
|
79
79
|
val child = getChildAt(i) ?: continue // Skip null children
|
|
80
80
|
try {
|
|
81
|
-
|
|
81
|
+
child.measure(childWidthSpec, childHeightSpec)
|
|
82
82
|
} catch (e: Exception) {
|
|
83
83
|
Log.w("ExpoIVSStagePreviewView", "Error measuring child $i: ${e.message}")
|
|
84
84
|
}
|
|
@@ -259,9 +259,9 @@ class ExpoIVSStagePreviewView(context: Context, appContext: AppContext) : ExpoVi
|
|
|
259
259
|
val wSpec = MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY)
|
|
260
260
|
val hSpec = MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY)
|
|
261
261
|
try {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
262
|
+
preview.measure(wSpec, hSpec)
|
|
263
|
+
preview.layout(0, 0, w, h)
|
|
264
|
+
Log.i("ExpoIVSStagePreviewView", "📐 Deferred layout: preview now ${preview.measuredWidth}x${preview.measuredHeight}")
|
|
265
265
|
} catch (e: Exception) {
|
|
266
266
|
Log.w("ExpoIVSStagePreviewView", "📐 Deferred layout error: ${e.message}")
|
|
267
267
|
}
|
|
@@ -328,8 +328,8 @@ class ExpoIVSStagePreviewView(context: Context, appContext: AppContext) : ExpoVi
|
|
|
328
328
|
mainHandler.postDelayed({
|
|
329
329
|
// Double-check we're still attached before trying to attach stream
|
|
330
330
|
if (isViewAttached) {
|
|
331
|
-
|
|
332
|
-
|
|
331
|
+
Log.i("ExpoIVSStagePreviewView", "🔄 Now attaching new preview after delay")
|
|
332
|
+
attachStreamWithRetry()
|
|
333
333
|
} else {
|
|
334
334
|
Log.w("ExpoIVSStagePreviewView", "🔄 Skipping attach - view no longer attached")
|
|
335
335
|
}
|
|
@@ -337,13 +337,39 @@ class ExpoIVSStagePreviewView(context: Context, appContext: AppContext) : ExpoVi
|
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
private fun applyProps() {
|
|
340
|
-
|
|
340
|
+
applyMirror()
|
|
341
341
|
setScaleMode(this.scaleMode)
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Apply mirroring based on camera position and user preference.
|
|
346
|
+
*
|
|
347
|
+
* Front camera: By default, Android shows a "selfie" view (mirrored like a mirror).
|
|
348
|
+
* We apply setMirrored(true) to show the "true" view (as others see you).
|
|
349
|
+
* The user's mirror prop can override this behavior.
|
|
350
|
+
*
|
|
351
|
+
* Back camera: No automatic mirroring applied, only user's mirror prop if set.
|
|
352
|
+
*/
|
|
353
|
+
private fun applyMirror() {
|
|
354
|
+
val isFrontCamera = stageManager?.isFrontCameraActive() ?: false
|
|
355
|
+
|
|
356
|
+
// For front camera: apply mirror to counter the natural selfie mirroring
|
|
357
|
+
// This makes it so moving left shows you moving left (true view)
|
|
358
|
+
// If user sets mirror=true on a front camera, it will show selfie view
|
|
359
|
+
// For back camera: just use the mirror prop as-is
|
|
360
|
+
val shouldMirror = if (isFrontCamera) {
|
|
361
|
+
!this.mirror // Invert: default (false) becomes true to counter selfie view
|
|
362
|
+
} else {
|
|
363
|
+
this.mirror // Back camera: use mirror prop directly
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
Log.d("ExpoIVSStagePreviewView", "📷 applyMirror: isFrontCamera=$isFrontCamera, mirrorProp=${this.mirror}, shouldMirror=$shouldMirror")
|
|
367
|
+
(ivsImagePreviewView as? ImagePreviewView)?.setMirrored(shouldMirror)
|
|
368
|
+
}
|
|
369
|
+
|
|
344
370
|
fun setMirror(mirror: Boolean) {
|
|
345
371
|
this.mirror = mirror
|
|
346
|
-
(
|
|
372
|
+
applyMirror()
|
|
347
373
|
}
|
|
348
374
|
|
|
349
375
|
fun setScaleMode(mode: String) {
|
|
@@ -77,6 +77,10 @@ class IVSStageManager(private val context: Context) : Stage.Strategy, StageRende
|
|
|
77
77
|
return localCamera
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
fun isFrontCameraActive(): Boolean {
|
|
81
|
+
return localCamera?.descriptor?.position == Device.Descriptor.Position.FRONT
|
|
82
|
+
}
|
|
83
|
+
|
|
80
84
|
fun initializeLocalStreams() {
|
|
81
85
|
discoverDevices()
|
|
82
86
|
|