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.dev with GitHub Actions.
One-time Setup #
Enable automated publishing for tgortcflutter in pub.dev:
- Open the package admin page:
https://pub.dev/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.