Corregge avvio RTMP bloccato dopo errore o cambio sessione.
Il motore Android ignorava startStream in CONNECTING/RECONNECTING; la camera ora resetta prima di pubblicare. YouTube relay parte solo con overlay attivo. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -57,6 +57,7 @@ module Streams
|
|||||||
return unless session.platform == "youtube"
|
return unless session.platform == "youtube"
|
||||||
return if session.terminal?
|
return if session.terminal?
|
||||||
return if session.stream_key.blank?
|
return if session.stream_key.blank?
|
||||||
|
return unless Streams::OverlayRelay.running?(session.id)
|
||||||
|
|
||||||
return if running?(session.id)
|
return if running?(session.id)
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ module Youtube
|
|||||||
rtmp_url: broadcast[:rtmp_url]
|
rtmp_url: broadcast[:rtmp_url]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Relay solo quando _air pubblica (overlay pronto); altrimenti ffmpeg esce subito.
|
||||||
|
if Streams::OverlayRelay.running?(@session.id)
|
||||||
Streams::YoutubeRelay.start(@session)
|
Streams::YoutubeRelay.start(@session)
|
||||||
|
end
|
||||||
@session.stream_events.create!(
|
@session.stream_events.create!(
|
||||||
event_type: "youtube_ready",
|
event_type: "youtube_ready",
|
||||||
metadata: { broadcast_id: broadcast[:broadcast_id] },
|
metadata: { broadcast_id: broadcast[:broadcast_id] },
|
||||||
|
|||||||
@@ -231,12 +231,17 @@ class StreamingEngine(
|
|||||||
notifyError("StreamingEngine rilasciato")
|
notifyError("StreamingEngine rilasciato")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (state == StreamingState.STREAMING ||
|
// Già in onda sullo stesso endpoint RTMP.
|
||||||
state == StreamingState.CONNECTING ||
|
if (state == StreamingState.STREAMING &&
|
||||||
state == StreamingState.RECONNECTING
|
config?.rtmpUrl == streamConfig.rtmpUrl &&
|
||||||
|
genericStream?.isStreaming == true
|
||||||
) {
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// Nuova sessione o retry dopo errore: reset completo (evita startStream ignorato).
|
||||||
|
if (state != StreamingState.IDLE && state != StreamingState.PREVIEWING) {
|
||||||
|
stopStream()
|
||||||
|
}
|
||||||
|
|
||||||
config = streamConfig
|
config = streamConfig
|
||||||
lastError = null
|
lastError = null
|
||||||
|
|||||||
@@ -165,7 +165,11 @@ class _CameraScreenState extends ConsumerState<CameraScreen> {
|
|||||||
fresh.status == 'live' ||
|
fresh.status == 'live' ||
|
||||||
fresh.status == 'reconnecting');
|
fresh.status == 'reconnecting');
|
||||||
if (shouldAutoPublish) {
|
if (shouldAutoPublish) {
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 500));
|
// Reset motore nativo (sessione precedente / RECONNECTING blocca startStream).
|
||||||
|
try {
|
||||||
|
await StreamingChannel.stopStream();
|
||||||
|
} catch (_) {}
|
||||||
|
await Future<void>.delayed(const Duration(milliseconds: 400));
|
||||||
final useFreshStart =
|
final useFreshStart =
|
||||||
justStartedSession || fresh.status == 'connecting';
|
justStartedSession || fresh.status == 'connecting';
|
||||||
if (useFreshStart) {
|
if (useFreshStart) {
|
||||||
@@ -497,6 +501,7 @@ class _CameraScreenState extends ConsumerState<CameraScreen> {
|
|||||||
_statsTimer?.cancel();
|
_statsTimer?.cancel();
|
||||||
_scorePullTimer?.cancel();
|
_scorePullTimer?.cancel();
|
||||||
_metricsSub?.cancel();
|
_metricsSub?.cancel();
|
||||||
|
unawaited(StreamingChannel.stopStream());
|
||||||
WakelockPlus.disable();
|
WakelockPlus.disable();
|
||||||
_unlockOrientation();
|
_unlockOrientation();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final ws = ref.read(websocketServiceProvider);
|
final ws = ref.read(websocketServiceProvider);
|
||||||
await ws.connect(sessionId: started.id, deviceRole: 'camera');
|
await ws.connect(sessionId: started.id, deviceRole: 'controller');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
|||||||
Reference in New Issue
Block a user