@bits-innovate/react-native-vstarcam 1.0.54 → 1.0.56
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.
|
@@ -46,6 +46,8 @@ public class VStarCamVideoView extends FrameLayout
|
|
|
46
46
|
private long playerPtr = 0;
|
|
47
47
|
private boolean isStreaming = false;
|
|
48
48
|
private boolean playerInitialized = false;
|
|
49
|
+
private boolean pendingStartStream = false;
|
|
50
|
+
private boolean streamingRequested = false; // Tracks if JS set streaming=true
|
|
49
51
|
|
|
50
52
|
// Player class (from AAR)
|
|
51
53
|
private Class<?> appPlayerClass;
|
|
@@ -150,7 +152,13 @@ public class VStarCamVideoView extends FrameLayout
|
|
|
150
152
|
Log.d(TAG, "SDK client pointer: " + sdkClientPtr);
|
|
151
153
|
|
|
152
154
|
if (sdkClientPtr != 0) {
|
|
153
|
-
|
|
155
|
+
// If streaming was already requested (prop order race), start now
|
|
156
|
+
if (streamingRequested && !isStreaming) {
|
|
157
|
+
Log.d(TAG, "clientPtr arrived after streaming requested — starting stream");
|
|
158
|
+
startStream();
|
|
159
|
+
} else {
|
|
160
|
+
statusView.setText("Ready to stream");
|
|
161
|
+
}
|
|
154
162
|
} else {
|
|
155
163
|
statusView.setText("Waiting for connection...");
|
|
156
164
|
}
|
|
@@ -173,6 +181,8 @@ public class VStarCamVideoView extends FrameLayout
|
|
|
173
181
|
* - start(long) -> boolean
|
|
174
182
|
*/
|
|
175
183
|
public void startStream() {
|
|
184
|
+
streamingRequested = true;
|
|
185
|
+
|
|
176
186
|
if (sdkClientPtr == 0) {
|
|
177
187
|
// Try to get SDK pointer again in case it was set after setClientPtr
|
|
178
188
|
this.sdkClientPtr = VStarCamModule.getSdkClientPtr((int) clientPtr);
|
|
@@ -184,8 +194,9 @@ public class VStarCamVideoView extends FrameLayout
|
|
|
184
194
|
}
|
|
185
195
|
|
|
186
196
|
if (surface == null) {
|
|
187
|
-
Log.
|
|
188
|
-
statusView.setText("
|
|
197
|
+
Log.d(TAG, "Surface not yet available — deferring stream start");
|
|
198
|
+
statusView.setText("Preparing...");
|
|
199
|
+
pendingStartStream = true;
|
|
189
200
|
return;
|
|
190
201
|
}
|
|
191
202
|
|
|
@@ -249,6 +260,7 @@ public class VStarCamVideoView extends FrameLayout
|
|
|
249
260
|
* Stop video streaming.
|
|
250
261
|
*/
|
|
251
262
|
public void stopStream() {
|
|
263
|
+
streamingRequested = false;
|
|
252
264
|
if (!isStreaming || playerPtr == 0) return;
|
|
253
265
|
|
|
254
266
|
Log.d(TAG, "Stopping stream...");
|
|
@@ -344,7 +356,15 @@ public class VStarCamVideoView extends FrameLayout
|
|
|
344
356
|
Log.d(TAG, "Surface available: " + width + "x" + height);
|
|
345
357
|
this.surface = new Surface(surfaceTexture);
|
|
346
358
|
|
|
347
|
-
// If
|
|
359
|
+
// If startStream() was called before surface was ready, start now
|
|
360
|
+
if (pendingStartStream) {
|
|
361
|
+
Log.d(TAG, "Deferred stream start — surface now available");
|
|
362
|
+
pendingStartStream = false;
|
|
363
|
+
startStream();
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// If already streaming, update the surface on the existing player
|
|
348
368
|
if (isStreaming && playerPtr != 0 && appPlayerClass != null) {
|
|
349
369
|
try {
|
|
350
370
|
Method setSurfaceMethod = appPlayerClass.getMethod(
|