Skip to content

Commit ba9327e

Browse files
authored
Merge pull request #19 from GetStream/chore/sync_0.13.0
chore: sync with flutter_webrtc v0.13.0 + bump StreamWebRTC
2 parents 996821e + 2763994 commit ba9327e

36 files changed

+423
-79
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11

22
# Changelog
33

4+
[1.0.0] - 2025-03-31
5+
* Bumped StreamWebRTC version to 125.6422.065
6+
* Synced flutter-webrtc v0.13.0
7+
* [All] feat: add getBufferedAmount for DataChannel.
8+
* [Windows] fix: fixed non-platform thread call error.
9+
410
[1.0.0-dev.1] - 2025-03-14
511
* Switched native webrtc dependencies for iOS and Android to Stream's internal builds
612
* Replaced deprecated `onSurfaceDestroyed` with `onSurfaceCleanup` in `SurfaceTextureRenderer`

android/src/main/java/io/getstream/webrtc/flutter/MethodCallHandlerImpl.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,12 @@ public void onMethodCall(MethodCall call, @NonNull Result notSafeResult) {
495495
createDataChannel(peerConnectionId, label, new ConstraintsMap(dataChannelDict), result);
496496
break;
497497
}
498+
case "dataChannelGetBufferedAmount": {
499+
String peerConnectionId = call.argument("peerConnectionId");
500+
String dataChannelId = call.argument("dataChannelId");
501+
dataChannelGetBufferedAmount(peerConnectionId, dataChannelId, result);
502+
break;
503+
}
498504
case "dataChannelSend": {
499505
String peerConnectionId = call.argument("peerConnectionId");
500506
String dataChannelId = call.argument("dataChannelId");
@@ -2062,6 +2068,17 @@ public void dataChannelSend(String peerConnectionId, String dataChannelId, ByteB
20622068
}
20632069
}
20642070

2071+
public void dataChannelGetBufferedAmount(String peerConnectionId, String dataChannelId, Result result) {
2072+
PeerConnectionObserver pco
2073+
= mPeerConnectionObservers.get(peerConnectionId);
2074+
if (pco == null || pco.getPeerConnection() == null) {
2075+
Log.d(TAG, "dataChannelGetBufferedAmount() peerConnection is null");
2076+
resultError("dataChannelGetBufferedAmount", "peerConnection is null", result);
2077+
} else {
2078+
pco.dataChannelGetBufferedAmount(dataChannelId, result);
2079+
}
2080+
}
2081+
20652082
public void dataChannelClose(String peerConnectionId, String dataChannelId) {
20662083
// Forward to PeerConnectionObserver which deals with DataChannels
20672084
// because DataChannel is owned by PeerConnection.

android/src/main/java/io/getstream/webrtc/flutter/PeerConnectionObserver.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ void dataChannelSend(String dataChannelId, ByteBuffer byteBuffer, Boolean isBina
168168
}
169169
}
170170

171+
void dataChannelGetBufferedAmount(String dataChannelId, Result result) {
172+
DataChannel dataChannel = dataChannels.get(dataChannelId);
173+
if (dataChannel != null) {
174+
ConstraintsMap params = new ConstraintsMap();
175+
params.putLong("bufferedAmount", dataChannel.bufferedAmount());
176+
result.success(params.toMap());
177+
} else {
178+
Log.d(TAG, "dataChannelGetBufferedAmount() dataChannel is null");
179+
resultError("dataChannelGetBufferedAmount", "DataChannel is null", result);
180+
}
181+
}
182+
171183
RtpTransceiver getRtpTransceiverById(String id) {
172184
RtpTransceiver transceiver = transceivers.get(id);
173185
if (null == transceiver) {

common/cpp/include/flutter_common.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212

1313
#include <list>
1414
#include <memory>
15-
#include <string>
15+
#include <mutex>
1616
#include <optional>
17+
#include <queue>
18+
#include <string>
1719

1820
typedef flutter::EncodableValue EncodableValue;
1921
typedef flutter::EncodableMap EncodableMap;
@@ -27,6 +29,8 @@ typedef flutter::EventSink<EncodableValue> EventSink;
2729
typedef flutter::MethodCall<EncodableValue> MethodCall;
2830
typedef flutter::MethodResult<EncodableValue> MethodResult;
2931

32+
class TaskRunner;
33+
3034
// foo.StringValue() becomes std::get<std::string>(foo)
3135
// foo.IsString() becomes std::holds_alternative<std::string>(foo)
3236

@@ -90,7 +94,8 @@ inline double findDouble(const EncodableMap& map, const std::string& key) {
9094
return 0.0;
9195
}
9296

93-
inline std::optional<double> maybeFindDouble(const EncodableMap& map, const std::string& key) {
97+
inline std::optional<double> maybeFindDouble(const EncodableMap& map,
98+
const std::string& key) {
9499
auto it = map.find(EncodableValue(key));
95100
if (it != map.end() && TypeIs<double>(it->second))
96101
return GetValue<double>(it->second);
@@ -171,6 +176,7 @@ class EventChannelProxy {
171176
public:
172177
static std::unique_ptr<EventChannelProxy> Create(
173178
BinaryMessenger* messenger,
179+
TaskRunner* task_runner,
174180
const std::string& channelName);
175181

176182
virtual ~EventChannelProxy() = default;

common/cpp/include/flutter_data_channel.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class FlutterRTCDataChannelObserver : public RTCDataChannelObserver {
1010
public:
1111
FlutterRTCDataChannelObserver(scoped_refptr<RTCDataChannel> data_channel,
1212
BinaryMessenger* messenger,
13+
TaskRunner* task_runner,
1314
const std::string& channel_name);
1415
virtual ~FlutterRTCDataChannelObserver();
1516

@@ -39,6 +40,9 @@ class FlutterDataChannel {
3940
const EncodableValue& data,
4041
std::unique_ptr<MethodResultProxy>);
4142

43+
void DataChannelGetBufferedAmount(RTCDataChannel* data_channel,
44+
std::unique_ptr<MethodResultProxy> result);
45+
4246
void DataChannelClose(RTCDataChannel* data_channel,
4347
const std::string& data_channel_uuid,
4448
std::unique_ptr<MethodResultProxy>);

common/cpp/include/flutter_frame_cryptor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace stream_webrtc_flutter_plugin {
1010

1111
class FlutterFrameCryptorObserver : public libwebrtc::RTCFrameCryptorObserver {
1212
public:
13-
FlutterFrameCryptorObserver(BinaryMessenger* messenger,const std::string& channelName)
14-
: event_channel_(EventChannelProxy::Create(messenger, channelName)) {}
13+
FlutterFrameCryptorObserver(BinaryMessenger* messenger, TaskRunner* task_runner, const std::string& channelName)
14+
: event_channel_(EventChannelProxy::Create(messenger, task_runner, channelName)) {}
1515
void OnFrameCryptionStateChanged(
1616
const string participant_id,
1717
libwebrtc::RTCFrameCryptionState state);

common/cpp/include/flutter_peerconnection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class FlutterPeerConnectionObserver : public RTCPeerConnectionObserver {
1111
FlutterPeerConnectionObserver(FlutterWebRTCBase* base,
1212
scoped_refptr<RTCPeerConnection> peerconnection,
1313
BinaryMessenger* messenger,
14+
TaskRunner* task_runner,
1415
const std::string& channel_name,
1516
std::string& peerConnectionId);
1617

common/cpp/include/flutter_video_renderer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class FlutterVideoRenderer
2222

2323
void initialize(TextureRegistrar* registrar,
2424
BinaryMessenger* messenger,
25+
TaskRunner* task_runner,
2526
std::unique_ptr<flutter::TextureVariant> texture,
2627
int64_t texture_id);
2728

common/cpp/include/flutter_webrtc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class FlutterWebRTCPlugin : public flutter::Plugin {
2121
virtual BinaryMessenger* messenger() = 0;
2222

2323
virtual TextureRegistrar* textures() = 0;
24+
25+
virtual TaskRunner* task_runner() = 0;
2426
};
2527

2628
class FlutterWebRTC : public FlutterWebRTCBase,

common/cpp/include/flutter_webrtc_base.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class FlutterWebRTCBase {
4343
enum ParseConstraintType { kMandatory, kOptional };
4444

4545
public:
46-
FlutterWebRTCBase(BinaryMessenger* messenger, TextureRegistrar* textures);
46+
FlutterWebRTCBase(BinaryMessenger* messenger, TextureRegistrar* textures, TaskRunner* task_runner);
4747
~FlutterWebRTCBase();
4848

4949
std::string GenerateUUID();
@@ -122,6 +122,7 @@ class FlutterWebRTCBase {
122122

123123
protected:
124124
BinaryMessenger* messenger_;
125+
TaskRunner *task_runner_;
125126
TextureRegistrar* textures_;
126127
std::unique_ptr<EventChannelProxy> event_channel_;
127128
};

0 commit comments

Comments
 (0)