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.
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.