Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,6 @@ _build

# flutter web
lib/generated_plugin_registrant.dart

# Test files - ignore any binary files in testfiles directory
testfiles/*.bin
2 changes: 2 additions & 0 deletions lib/src/data_stream/stream_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import '../types/data_stream.dart';
import '../types/other.dart';
import '../utils.dart';


class BaseStreamWriter<T, InfoType extends BaseStreamInfo> {
final StreamWriter<T> writableStream;
Function()? onClose;
Expand Down Expand Up @@ -48,6 +49,7 @@ class WritableStream<T> implements StreamWriter<T> {
int chunkId = 0;
List<String>? destinationIdentities;
Engine engine;

WritableStream({
required this.streamId,
required this.engine,
Expand Down
25 changes: 21 additions & 4 deletions lib/src/participant/local.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,22 @@ extension RPCMethods on LocalParticipant {
}
}

/// Helper function to convert string operation type to enum
lk_models.DataStream_OperationType _stringToOperationType(String? type) {
switch (type?.toLowerCase()) {
case 'create':
return lk_models.DataStream_OperationType.CREATE;
case 'update':
return lk_models.DataStream_OperationType.UPDATE;
case 'delete':
return lk_models.DataStream_OperationType.DELETE;
case 'reaction':
return lk_models.DataStream_OperationType.REACTION;
default:
return lk_models.DataStream_OperationType.CREATE;
}
}

extension DataStreamParticipantMethods on LocalParticipant {
Future<TextStreamInfo> sendText(String text,
{SendTextOptions? options}) async {
Expand Down Expand Up @@ -1181,6 +1197,7 @@ extension DataStreamParticipantMethods on LocalParticipant {
destinationIdentities: options?.destinationIdentities ?? [],
topic: options?.topic,
attachedStreamIds: fileIds ?? [],
attributes: options?.attributes ?? {},
));

await writer.write(text);
Expand Down Expand Up @@ -1230,13 +1247,13 @@ extension DataStreamParticipantMethods on LocalParticipant {
topic: info.topic,
timestamp: Int64(info.timestamp),
totalLength: Int64(options?.totalSize ?? 0),
attributes: options?.attributes.entries,
textHeader: lk_models.DataStream_TextHeader(
version: options?.version,
attachedStreamIds: options?.attachedStreamIds,
replyToStreamId: options?.replyToStreamId,
operationType: options?.type == 'update'
? lk_models.DataStream_OperationType.UPDATE
: lk_models.DataStream_OperationType.CREATE,
generated: options?.generated ?? false,
operationType: _stringToOperationType(options?.type),
),
);
final destinationIdentities = options?.destinationIdentities;
Expand Down Expand Up @@ -1307,7 +1324,6 @@ extension DataStreamParticipantMethods on LocalParticipant {
options.onProgress?.call((i + 1) / totalChunks);
}
await writer.close();
writer.info;
}

Future<ByteStreamWriter> streamBytes(StreamBytesOptions? options) async {
Expand All @@ -1333,6 +1349,7 @@ extension DataStreamParticipantMethods on LocalParticipant {
byteHeader: lk_models.DataStream_ByteHeader(
name: info.name,
),
attributes: options?.attributes.entries,
);

final destinationIdentities = options?.destinationIdentities;
Expand Down
14 changes: 13 additions & 1 deletion lib/src/types/data_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ class SendTextOptions {

Function(double)? onProgress;

/// user defined attributes map that can carry additional info
Map<String, String> attributes;

SendTextOptions({
this.topic,
this.destinationIdentities = const [],
this.attachments = const [],
this.onProgress,
this.attributes = const {},
});
}

Expand Down Expand Up @@ -48,9 +52,15 @@ class StreamTextOptions {
String? replyToStreamId;
int? totalSize;

/// 'create' | 'update'
/// 'create' | 'update' | 'delete' | 'reaction'
String? type;

/// true if the text has been generated by an agent from a participant's audio transcription
bool generated;

/// user defined attributes map that can carry additional info
Map<String, String> attributes;

StreamTextOptions({
this.topic,
this.destinationIdentities = const [],
Expand All @@ -60,6 +70,8 @@ class StreamTextOptions {
this.replyToStreamId,
this.totalSize,
this.type,
this.generated = false,
this.attributes = const {},
});
}

Expand Down
12 changes: 10 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ packages:
dependency: "direct main"
description:
name: flutter_webrtc
sha256: "69095ba39b83da3de48286dfc0769aa8e9f10491f70058dc8d8ecc960ef7a260"
sha256: "945d0a38b90fbca8257eadb167d8fb9fa7075d9a1939fd2953c10054454d1de2"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
version: "1.1.0"
frontend_server_client:
dependency: transitive
description:
Expand Down Expand Up @@ -384,6 +384,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.0"
logger:
dependency: transitive
description:
name: logger
sha256: "55d6c23a6c15db14920e037fe7e0dc32e7cdaf3b64b4b25df2d541b5b6b81c0c"
url: "https://pub.dev"
source: hosted
version: "2.6.1"
logging:
dependency: "direct main"
description:
Expand Down
Loading
Loading