tgortcflutter 1.0.5
tgortcflutter: ^1.0.5 copied to clipboard
A Flutter SDK for audio and video calling based on LiveKit. Provides easy-to-use APIs for room management, participant tracking, and media control.
tgortcflutter #
A Flutter SDK for audio and video calling based on LiveKit. Provides easy-to-use APIs for room management, participant tracking, and media control.
Features #
- π₯ Video/Audio calling support
- π₯ Participant management (local & remote)
- π€ Microphone/Camera control
- π Speaker/Earpiece switching
- π‘ Real-time event listeners
- π Easy integration with LiveKit backend
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
tgortcflutter: ^<latest-version>
π‘ Replace
<latest-version>with the version shown in the badge above, or run:flutter pub add tgortcflutter
Then run:
flutter pub get
Platform Setup #
Since this package is based on LiveKit and WebRTC, you need to configure platform-specific permissions:
iOS #
Add the following to your ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera access is required for video calls</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone access is required for audio calls</string>
Android #
Add the following permissions to your android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
Quick Start #
Initialize SDK #
import 'package:tgortcflutter/tgortc.dart';
// Initialize with options
TgoRTC.instance.init(Options());
Join a Room #
final roomInfo = RoomInfo(
'room-name',
'your-access-token',
'wss://your-livekit-server.com',
'your-user-id',
'creator-user-id',
);
await TgoRTC.instance.roomManager.joinRoom(roomInfo);
Get Participants #
// Get local participant
final local = TgoRTC.instance.participantManager.getLocalParticipant();
// Get remote participants
final remotes = TgoRTC.instance.participantManager.getRemoteParticipants();
Listen to Events #
// Join/Leave events
local.addJoinedListener(() => print('Joined room'));
local.addLeaveListener(() => print('Left room'));
// Media state changes
local.addMicrophoneStatusListener((enabled) => print('Microphone: $enabled'));
local.addCameraStatusListener((enabled) => print('Camera: $enabled'));
local.addSpeakingListener((speaking) => print('Speaking: $speaking'));
Control Media #
// Toggle camera/microphone
await local.setCameraEnabled(true);
await local.setMicrophoneEnabled(true);
// Switch camera
await local.switchCamera();
// Switch audio output
await TgoRTC.instance.audioManager.setSpeakerphoneOn(true);
Render Video #
final renderer = TgoTrackRenderer();
renderer.setParticipant(participant);
// In your widget tree
return renderer.build();
Leave Room #
await TgoRTC.instance.roomManager.leaveRoom();
Architecture #
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β RoomManager β
β (Listens to LiveKit RoomEvent) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β RoomConnectedEvent β Local join β
β RoomDisconnectedEvent β Local leave β
β ParticipantConnectedEvent β Remote join β
β ParticipantDisconnectedEvent β Remote leave β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ParticipantManager β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β setParticipantJoin() β Create/Update TgoParticipant β
β setParticipantLeave() β Notify leave and cleanup β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TgoParticipant β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β notifyJoined() β Notify _joinedListeners β
β notifyLeave() β Notify _leaveListeners β dispose() β
β (Listens to ParticipantEvent: mic/camera/speaking) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Core Modules #
| Module | Description |
|---|---|
TgoRTC |
Main SDK entry point (singleton) |
TgoRoomManager |
Room connection and event handling |
TgoParticipantManager |
Local/remote participant management |
TgoParticipant |
Participant wrapper with state listeners |
TgoTrackRenderer |
Video track rendering widget |
TgoAudioManager |
Audio output management |
Example #
Check the example directory for a complete working example.
Release #
This repository supports automated publishing to pub.flutter-io.cn with GitHub Actions.
One-time Setup #
Enable automated publishing for tgortcflutter in pub.flutter-io.cn:
- Open the package admin page:
https://pub.flutter-io.cn/packages/tgortcflutter/admin - Enable
GitHub Actionsautomated publishing - Set repository to
TgoRTC/TgoRTCFlutter - Set tag pattern to
v{{version}}
Branch Policy #
- CI runs on every push to
main - Publishing is only triggered by pushing a version tag
- The tag must point to a commit already merged into
main
Release Steps #
- Ensure the release commit is already merged into
main - Run the release script
Example:
./scripts/release.sh
This script will:
- auto-increment the patch version in
pubspec.yaml - switch to
main - pull the latest changes
- commit the version bump to
main - push the commit to
main - create a matching version tag such as
v1.0.2 - push the tag to GitHub
If you want to release a specific version manually, you can still pass it:
./scripts/release.sh 1.0.2
After the tag is pushed, .github/workflows/publish.yml will publish the package automatically.
Workflows #
-
.github/workflows/ci.yml- runs
flutter pub get - runs
flutter analyze - runs
dart pub publish --dry-run
- runs
-
.github/workflows/publish.yml- runs on
v*tags - verifies tag version matches
pubspec.yaml - runs
dart pub publish --force
- runs on
License #
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.