feat: (for now android only!) codec configuration and retrieval methods
This commit is contained in:
parent
32789468a3
commit
90733a3768
6 changed files with 117 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import 'liblinphone_flutter_platform_interface.dart';
|
|||
import 'models/call_stats.dart';
|
||||
import 'models/call_type.dart';
|
||||
import 'models/dscp_values.dart';
|
||||
import 'models/lp_codec.dart';
|
||||
import 'models/registration_state.dart';
|
||||
import 'models/call_state.dart';
|
||||
|
||||
|
|
@ -117,4 +118,10 @@ class LiblinphoneFlutter {
|
|||
|
||||
Future<CallStats?> getCurrentCallStats() async =>
|
||||
LiblinphoneFlutterPlatform.instance.getCurrentCallStats();
|
||||
|
||||
Future<List<LPCodec>> getAvailableAudioCodecs() async =>
|
||||
LiblinphoneFlutterPlatform.instance.getAvailableAudioCodecs();
|
||||
|
||||
Future<bool> setAudioCodec(String mime, int clockRate) async =>
|
||||
LiblinphoneFlutterPlatform.instance.setAudioCodec(mime, clockRate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'liblinphone_flutter_platform_interface.dart';
|
|||
import 'models/call_stats.dart';
|
||||
import 'models/call_type.dart';
|
||||
import 'models/dscp_values.dart';
|
||||
import 'models/lp_codec.dart';
|
||||
|
||||
/// An implementation of [LiblinphoneFlutterPlatform] that uses method channels.
|
||||
class MethodChannelLiblinphoneFlutter extends LiblinphoneFlutterPlatform {
|
||||
|
|
@ -175,4 +176,22 @@ class MethodChannelLiblinphoneFlutter extends LiblinphoneFlutterPlatform {
|
|||
final values = CallStats.fromJson(data);
|
||||
return values;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<LPCodec>> getAvailableAudioCodecs() async {
|
||||
final data = (await methodChannel.invokeMethod<List<Map<dynamic, dynamic>>>(
|
||||
'getAvailableAudioCodecs',
|
||||
))!;
|
||||
|
||||
final values = data.map(LPCodec.fromJson).toList(growable: true);
|
||||
return values;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> setAudioCodec(String mime, int clockRate) async {
|
||||
return (await methodChannel.invokeMethod<bool>(
|
||||
'setAudioCodec',
|
||||
<String, dynamic>{'mime': mime, 'clockRate': clockRate},
|
||||
))!;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
|||
import 'liblinphone_flutter_method_channel.dart';
|
||||
import 'models/call_stats.dart';
|
||||
import 'models/dscp_values.dart';
|
||||
import 'models/lp_codec.dart';
|
||||
|
||||
abstract class LiblinphoneFlutterPlatform extends PlatformInterface {
|
||||
/// Constructs a LiblinphoneFlutterPlatform.
|
||||
|
|
@ -139,4 +140,12 @@ abstract class LiblinphoneFlutterPlatform extends PlatformInterface {
|
|||
Future<CallStats?> getCurrentCallStats() async {
|
||||
throw UnimplementedError('getCurrentCallStats() has not been implemented.');
|
||||
}
|
||||
|
||||
Future<List<LPCodec>> getAvailableAudioCodecs() async {
|
||||
throw UnimplementedError('getCurrentCallStats() has not been implemented.');
|
||||
}
|
||||
|
||||
Future<bool> setAudioCodec(String mime, int clockRate) async {
|
||||
throw UnimplementedError('getCurrentCallStats() has not been implemented.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
10
lib/models/lp_codec.dart
Normal file
10
lib/models/lp_codec.dart
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
final class LPCodec {
|
||||
final String mimeType;
|
||||
final int clockRate;
|
||||
final bool enabled;
|
||||
|
||||
const LPCodec(this.mimeType, this.clockRate, this.enabled);
|
||||
|
||||
factory LPCodec.fromJson(Map<dynamic, dynamic> json) =>
|
||||
LPCodec(json["mimeType"], json["clockRate"], json["enabled"]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue