मुख्य कंटेंट तक स्किप करें

Flutter live streaming plugin

aibuds_live_stream_flutter native AIBudsLiveStream middleware को Flutter से जोड़ता है। यह playback के लिए iOS platform view और RTSP input को RTMP destination तक relay करने के लिए अलग controller देता है।

यह पेज Flutter/native ownership समझाता है। Device capability checks, hotspot setup और RTSP URL प्राप्त करने का तरीका RTSP Live Streaming में है।

Animated flow map

Device stream और Flutter consumers

एक device RTSP session ऐसा address देता है जिसे एक host lifecycle owner के तहत native preview, optional relay या दोनों उपयोग कर सकते हैं।

Device session

RTSP session शुरू करें

Capability और hotspot coordination पूरा करें।

Shared input

RTSP URL पाएँ

इस session का authoritative address सुरक्षित रखें।

Platform view

Native player

Playback commands देने से पहले controller attach करें।

Flutter UI

Preview दिखाएँ

Native events को mounted presentation state में map करें।

Optional branch

RTMP relay

अलग owned streamer lifecycle से publish करें।

  • RTSP session शुरू करेंcontinues toRTSP URL पाएँ
  • RTSP URL पाएँpreviewNative player
  • Native playercontinues toPreview दिखाएँ
  • RTSP URL पाएँoptional relayRTMP relay
Player state, streamer state और device session अलग हैं; हर owned resource को स्पष्ट रूप से stop और dispose करें।

Platform और packaging की सीमा

  • iOS supported है; Android implemented नहीं है।
  • Dart 3.3+, Flutter 3.19+ और iOS 13+ आवश्यक हैं।
  • Plugin AIBudsLiveStreamFlutterPlugin.xcframework wrap करता है और AIBudsSDK/LiveStream पर depend करता है।
  • RTSP और RTMP को physical iOS device पर validate करें।

Supplied XCFrameworks और resources को plugin target के iOS packaging flow में रखें। Runner target में conflicting copies जोड़ने के बजाय linkage वहीं resolve करें।

Runtime architecture

एक player controller एक native platform view को represent करता है। AIBudsLiveStreamPlayerView create और attach होने तक commands unavailable रहती हैं। Streamer controller का अलग native relay lifecycle होता है।

View, events और controller साथ manage करें

DART
class LivePreviewState extends State<LivePreview> {
  final player = AIBudsLiveStreamPlayerController();
  StreamSubscription<AIBudsLiveStreamPlayerEvent>? events;

  @override
  void initState() {
    super.initState();
    events = player.events.listen((event) {
      if (!mounted) return;
      setState(() { /* map native event to presentation state */ });
    });
  }

  @override
  Widget build(BuildContext context) => AIBudsLiveStreamPlayerView(
    controller: player,
    options: const AIBudsLiveStreamPlayerOptions(
      format: AIBudsLiveStreamFormat.rtsp,
      gravityMode: AIBudsLiveStreamGravityMode.resizeAspect,
    ),
  );

  @override
  void dispose() {
    events?.cancel();
    player.disposePlayer();
    super.dispose();
  }
}

Platform view और device RTSP URL दोनों ready होने दें; कोई भी पहले आ सकता है। एक controller को एक साथ mounted कई views में reuse न करें।

Device और player state अलग रखें

LiveStreamingAPI device/hotspot session संभालता है। Flutter player native rendering संभालता है। Player success device-session health साबित नहीं करता और device start frame render होने की पुष्टि नहीं है। Device session, network route, player और UI state अलग track करें।

Stop या page छोड़ते समय नए actions रोकें, player/streamer और device session बंद करें, Dart subscriptions cancel करें, native controllers dispose करें और retained URL clear करें। एक side interruption से पहले ही बंद हो तो भी cleanup सुरक्षित रहे।

RTSP से RTMP relay

AIBudsLiveStreamStreamerController को independent operational feature मानें:

  • Destination authorization को callback path के बाहर validate करें;
  • शुरू करने से पहले events subscribe करें;
  • Target network के अनुसार bitrate, dimensions, frame rate, audio, timeout, adaptive bitrate और reconnect policy चुनें;
  • Preview success से publication success का अनुमान न लगाएँ;
  • Device session समाप्त होने पर streamer stop और dispose करें;
  • Publishing credentials को Dart source या diagnostics में embed न करें।

Preview और relay एक RTSP source share करते हों तो सबसे कम क्षमता वाले supported device पर resources और reconnect behavior test करें।

Performance और recovery

  • सामान्य status changes पर platform view rebuild न करें।
  • setState से पहले high-frequency events throttle करें।
  • Backgrounding, hotspot loss, disconnect और view disposal को अलग interruptions मानें।
  • Automatic reconnect सीमित रखें और user-controlled retry दें।
  • पुराना session authoritative न रहे तो पूरी device-to-player pipeline फिर बनाएँ।

समस्या निवारण

समस्यासंभावित कारण
Playback से पहले command fail होती हैPlatform view अभी attach नहीं हुआ।
Non-iOS placeholderPlugin अभी केवल iOS implement करता है।
URL है पर video नहींPlayer events, hotspot route और physical-device reachability जाँचें।
RTMP destination पर stream नहींStreamer events को preview state से अलग diagnose करें।
Page छोड़ने के बाद events आते हैंSubscription cancel करें और native controller dispose करें।
Duplicate symbolsConflicting native dependency copies हटाएँ।