搜索插件、代码仓与 APP 分类

GitHub 代码仓Blancduman/mediasoup-client-flutter

mediasoup-client-flutter

mediasoup-client 库的 Flutter 版本。

mediasoup-client-flutter 项目封面
星标
114
复刻
71
最近推送(UTC)
2023年8月14日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

mediasoup_client_flutter

Android iOS macOS Windows Linux Web
Unified-Plan ✔ ✔ ✔ ✔ ✗ ✔

No datachannels yet;

Usage Example

import 'package:mediasoup_client_flutter/mediasoup_client_flutter.dart';
import 'package:my_project/my_signaling.dart';

// Create a device.
final device = Device();

// Communicate with server app to retrieve router RTP capabilities.
final Map<String, dynamic> routerRtpCapabilities = await mySignaling.request('getRouterCapabilities');

// Load the device with the router RTP capabilities.
final rtpCapabilities = RtpCapabilities.fromMap(routerRtpCapabilities);
await device.load(routerRtpCapabilities: rtpCapabilities);

// Check wheter we can produce video to the router.
if (!device.canProduce(RTCRtpMediaType.RTCRtpMediaTypeVideo)) {
    print('cannot produce video');
    // Abort next steps.
}

// Create a transport in the server for sending our media through it.
final Map transportInfo = await mySignaling.request('createTransport', {
    'forceTcp': false,
    'producing': true,
    'consuming': false,
    'sctpCapabilities': device.sctpCapabilities.toMap(),
});

// Create a callback for producers.
void _producerCallback(Producer producer) {
    /* Your code. */
}

final sendTransport = device.createSendTransportFromMap(
    transportInfo,
    producerCallback: _producerCallback,
);

// Set transport "connect" event handler.
sendTransport.on('connect', (Map data) {
// Here we must communicate our local parameters to our remote transport.
mySignaling.request('transport-connect', {
    'transportId': _sendTransport.id,
    'dtlsParameters': data['dtlsParameters'].toMap(),
})
// Done in the server, tell our transport.
.then(data['callback'])
// Something was wrong in server side.
.catchError(data['errback']);
});

// Set transport "produce" event handler.
_sendTransport.on('produce', (Map data) async {
// Here we must communicate our local parameters to our remote transport.
    try {
        Map response = await mySignaling.request(
            'produce',
            {
                'transportId': sendTransport.id,
                'kind': data['kind'],
                'rtpParameters': data['rtpParameters'].toMap(),
                if (data['appData'] != null)
                'appData': Map<String, dynamic>.from(data['appData'])
            },
        );
        // Done in the server, pass the response to our transport.
        data['callback'](response['id']);
    } catch (error) {
        // Something was wrong in server side.
        data['errback'](error);
    }
});

// Produce our webcam video.
Map<String, dynamic> mediaConstraints = <String, dynamic>{
    'audio': false,
    'video': {
        'mandatory': {
            // Provide your own width, height and frame rate here.
            'minWidth': '1280', 
            'minHeight': '720',
            'minFrameRate': '30',
        },
    },
};

final MediaStream stream = await navigator.mediaDevices.getUserMedia(mediaConstraints);
final MediaStreamTrack track = stream.getVideoTracks().first;
sendTransport.produce(
    stream: stream,
    track: track,
    source: 'webcam',
);
// Producer will return through _producerCallback.

Check example for more information;

Ibragim Abbasov GitHub avatar
GitHub 作者

Ibragim Abbasov ↗

Live life, do code

Russia
语言Dart

分类

此仓库发布的插件

使用的依赖

依赖清单 8 项

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗