简体   繁体   English

如何使用 flutter Bloc 模式实现 WEBRTC

[英]How implement WEBRTC with flutter Bloc pattern

I have a flutter app and I need to get the video stream from a smart device the device actually returns this data我有一个 flutter 应用程序,我需要从智能设备获取视频 stream 该设备实际返回此数据

{
     
  moto_id: 'moto_usprod001',
  auth: 'XX/XL?EF?OL/XXX',   
  icesServers: [
    { urls: 'stun:44.240.73.31:3478' },
    { urls: 'stun:aws5stun.tuyaus.com:3478' },
    { urls: 'nat:aws3nat.tuyaus.com:3478' },
    { urls: 'nat:aws4nat.tuyaus.com:3478' },
    {
      credential: 'XXXX',
      ttl: 3600,
      urls: 'turn:55.55.55.55:3478',
      username: 'XXXXXX:XXXXXX:XXXXX'
    },
    {
      credential: 'XXXXX',
      ttl: 3600,
      urls: 'turn:XCDS.tuyaus.com:3478',
      username: 'XXXXXXX:XXXXXX'
    }
  ]
}

How do I use this returned data to get the video streamed from device on mobile !!我如何使用此返回的数据从移动设备上流式传输视频!! the way I have structured my app is using the Bloc Pattern我构建我的应用程序的方式是使用 Bloc 模式

Thank you谢谢

Well... if you didn't make your mind on a webrtc library - I recommend Flutter-WebRTC .好吧......如果你没有考虑过webrtc图书馆 - 我推荐Flutter-WebRTC This library support any platform (including mobile + ios + android) and also has a very nice demo app to start with.这个库支持任何平台(包括移动 + ios + android)并且还有一个非常好的演示应用程序可以开始使用。

Please note that in order to sync your devices you should have a sync server and as the sample app states, you can use you own instance (using the WebRTC Flutter Server ) or just use the publicly accessible stun server (please note it is NOT properly secured)请注意,为了同步您的设备,您应该有一个同步服务器,并且如示例应用程序所述,您可以使用您自己的实例(使用WebRTC Flutter 服务器)或仅使用可公开访问的眩晕服务器(请注意它不正确安全)

To answer your use case - please refer to this portion of the app demo to help you get started fast (a video call implementation, including video stream)回答您的用例 - 请参考应用程序演示的这一部分,以帮助您快速入门(视频通话实现,包括视频流)

And.. if (by chance) this is your first time using WebRTC and you are not entirely confident about your understating the entire process (I, for instance, still learning and getting amazed by WebRTC - no shame in that) - please refer to this excellent document which helps to get the core concepts and how WebRTC component are co-operating with each other并且.. 如果(偶然)这是你第一次使用 WebRTC 并且你对自己低估了整个过程并不完全自信(例如,我仍在学习并为 WebRTC 感到惊讶 - 对此并不感到羞耻) - 请参阅这份优秀的文档有助于了解核心概念以及 WebRTC 组件如何相互协作

Hope you will find your way with that project of your, ad of course - feel free to share here and educate us all when you get interesting results.希望您能在您的广告项目中找到自己的方式 - 当然,当您获得有趣的结果时,请随时在这里分享并教育我们所有人。 Cheers干杯

This JSON presents the ICE Servers that you can use for WebRTC handshake.此 JSON 介绍了可用于 WebRTC 握手的 ICE 服务器。

For details, you should learn the documentation for your device, at Tuya IoT Development Platform .详情请前往 涂鸦物联网开发平台了解您设备的文档。 To establish a connection, you can follow the procedure of sendOfferSdp in their Android Java example.要建立连接,您可以按照 Android Java示例中的 sendOfferSdp 过程进行操作。 Unfortunately, they have not yet published an example in Dart.不幸的是,他们尚未在 Dart 中发布示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM