Skip to content

Commit

Permalink
fix: Fix some callbacks not fired (#2033)
Browse files Browse the repository at this point in the history
Fix `onFirstLocalVideoFramePublished` not fired, the one with
`connection` is fired by Native SDK.
Fix `onLocalVideoStats` not fired, the one with `connection` is fired by
Native SDK.
  • Loading branch information
littleGnAl authored Sep 24, 2024
1 parent cc72351 commit 47ac794
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 47 deletions.
4 changes: 2 additions & 2 deletions lib/src/agora_rtc_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1877,7 +1877,7 @@ class RtcEngineEventHandler {
///
/// * [connection] The connection information. See RtcConnection.
/// * [elapsed] Time elapsed (ms) from the local user calling joinChannel until this callback is triggered.
final void Function(VideoSourceType source, int elapsed)?
final void Function(RtcConnection connection, int elapsed)?
onFirstLocalVideoFramePublished;

/// Occurs when the first remote video frame is received and decoded.
Expand Down Expand Up @@ -2038,7 +2038,7 @@ class RtcEngineEventHandler {
///
/// * [connection] The connection information. See RtcConnection.
/// * [stats] The statistics of the local video stream. See LocalVideoStats.
final void Function(VideoSourceType source, LocalVideoStats stats)?
final void Function(RtcConnection connection, LocalVideoStats stats)?
onLocalVideoStats;

/// Reports the statistics of the video stream sent by each remote users.
Expand Down
20 changes: 11 additions & 9 deletions lib/src/binding/agora_rtc_engine_event_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ class RtcEngineEventHandlerWrapper implements EventLoopEventHandler {
source, width, height, elapsed);
return true;

case 'onFirstLocalVideoFramePublished_2ad83d8':
case 'onFirstLocalVideoFramePublished_263e4cd':
if (rtcEngineEventHandler.onFirstLocalVideoFramePublished == null) {
return true;
}
Expand All @@ -409,13 +409,14 @@ class RtcEngineEventHandlerWrapper implements EventLoopEventHandler {
RtcEngineEventHandlerOnFirstLocalVideoFramePublishedJson.fromJson(
jsonMap);
paramJson = paramJson.fillBuffers(buffers);
VideoSourceType? source = paramJson.source;
RtcConnection? connection = paramJson.connection;
int? elapsed = paramJson.elapsed;
if (source == null || elapsed == null) {
if (connection == null || elapsed == null) {
return true;
}

rtcEngineEventHandler.onFirstLocalVideoFramePublished!(source, elapsed);
connection = connection.fillBuffers(buffers);
rtcEngineEventHandler.onFirstLocalVideoFramePublished!(
connection, elapsed);
return true;

case 'onFirstRemoteVideoDecoded_a68170a':
Expand Down Expand Up @@ -704,21 +705,22 @@ class RtcEngineEventHandlerWrapper implements EventLoopEventHandler {
rtcEngineEventHandler.onLocalAudioStats!(connection, stats);
return true;

case 'onLocalVideoStats_baa96c8':
case 'onLocalVideoStats_3ac0eb4':
if (rtcEngineEventHandler.onLocalVideoStats == null) {
return true;
}
final jsonMap = jsonDecode(eventData);
RtcEngineEventHandlerOnLocalVideoStatsJson paramJson =
RtcEngineEventHandlerOnLocalVideoStatsJson.fromJson(jsonMap);
paramJson = paramJson.fillBuffers(buffers);
VideoSourceType? source = paramJson.source;
RtcConnection? connection = paramJson.connection;
LocalVideoStats? stats = paramJson.stats;
if (source == null || stats == null) {
if (connection == null || stats == null) {
return true;
}
connection = connection.fillBuffers(buffers);
stats = stats.fillBuffers(buffers);
rtcEngineEventHandler.onLocalVideoStats!(source, stats);
rtcEngineEventHandler.onLocalVideoStats!(connection, stats);
return true;

case 'onRemoteVideoStats_2f43a70':
Expand Down
13 changes: 7 additions & 6 deletions lib/src/binding/event_handler_param_json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2106,10 +2106,10 @@ extension RtcEngineEventHandlerOnFirstLocalVideoFrameJsonBufferExt
@JsonSerializable(explicitToJson: true, includeIfNull: false)
class RtcEngineEventHandlerOnFirstLocalVideoFramePublishedJson {
const RtcEngineEventHandlerOnFirstLocalVideoFramePublishedJson(
{this.source, this.elapsed});
{this.connection, this.elapsed});

@JsonKey(name: 'source')
final VideoSourceType? source;
@JsonKey(name: 'connection')
final RtcConnection? connection;

@JsonKey(name: 'elapsed')
final int? elapsed;
Expand Down Expand Up @@ -2668,10 +2668,11 @@ extension RtcEngineEventHandlerOnLocalAudioStatsJsonBufferExt

@JsonSerializable(explicitToJson: true, includeIfNull: false)
class RtcEngineEventHandlerOnLocalVideoStatsJson {
const RtcEngineEventHandlerOnLocalVideoStatsJson({this.source, this.stats});
const RtcEngineEventHandlerOnLocalVideoStatsJson(
{this.connection, this.stats});

@JsonKey(name: 'source')
final VideoSourceType? source;
@JsonKey(name: 'connection')
final RtcConnection? connection;

@JsonKey(name: 'stats')
final LocalVideoStats? stats;
Expand Down
14 changes: 10 additions & 4 deletions lib/src/binding/event_handler_param_json.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const eventIdsMapping = {
"RtcEngineEventHandler_onFirstLocalVideoFrame_ebdfd19"
],
"RtcEngineEventHandler_onFirstLocalVideoFramePublished": [
"RtcEngineEventHandler_onFirstLocalVideoFramePublished_2ad83d8"
"RtcEngineEventHandler_onFirstLocalVideoFramePublished_263e4cd"
],
"RtcEngineEventHandler_onFirstRemoteVideoDecoded": [
"RtcEngineEventHandler_onFirstRemoteVideoDecoded_a68170a"
Expand Down Expand Up @@ -223,7 +223,7 @@ const eventIdsMapping = {
"RtcEngineEventHandler_onLocalAudioStats_5657f05"
],
"RtcEngineEventHandler_onLocalVideoStats": [
"RtcEngineEventHandler_onLocalVideoStats_baa96c8"
"RtcEngineEventHandler_onLocalVideoStats_3ac0eb4"
],
"RtcEngineEventHandler_onRemoteVideoStats": [
"RtcEngineEventHandler_onRemoteVideoStats_2f43a70"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8009,7 +8009,7 @@ void rtcEngineSmokeTestCases() {
onFirstLocalVideoFrame:
(VideoSourceType source, int width, int height, int elapsed) {},
onFirstLocalVideoFramePublished:
(VideoSourceType source, int elapsed) {},
(RtcConnection connection, int elapsed) {},
onFirstRemoteVideoDecoded: (RtcConnection connection, int remoteUid,
int width, int height, int elapsed) {},
onVideoSizeChanged: (RtcConnection connection,
Expand Down Expand Up @@ -8045,7 +8045,8 @@ void rtcEngineSmokeTestCases() {
(RtcConnection connection, RemoteAudioStats stats) {},
onLocalAudioStats:
(RtcConnection connection, LocalAudioStats stats) {},
onLocalVideoStats: (VideoSourceType source, LocalVideoStats stats) {},
onLocalVideoStats:
(RtcConnection connection, LocalVideoStats stats) {},
onRemoteVideoStats:
(RtcConnection connection, RemoteVideoStats stats) {},
onCameraReady: () {},
Expand Down Expand Up @@ -8225,7 +8226,7 @@ void rtcEngineSmokeTestCases() {
onFirstLocalVideoFrame:
(VideoSourceType source, int width, int height, int elapsed) {},
onFirstLocalVideoFramePublished:
(VideoSourceType source, int elapsed) {},
(RtcConnection connection, int elapsed) {},
onFirstRemoteVideoDecoded: (RtcConnection connection, int remoteUid,
int width, int height, int elapsed) {},
onVideoSizeChanged: (RtcConnection connection,
Expand Down Expand Up @@ -8261,7 +8262,8 @@ void rtcEngineSmokeTestCases() {
(RtcConnection connection, RemoteAudioStats stats) {},
onLocalAudioStats:
(RtcConnection connection, LocalAudioStats stats) {},
onLocalVideoStats: (VideoSourceType source, LocalVideoStats stats) {},
onLocalVideoStats:
(RtcConnection connection, LocalVideoStats stats) {},
onRemoteVideoStats:
(RtcConnection connection, RemoteVideoStats stats) {},
onCameraReady: () {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,8 @@ void generatedTestCases(ValueGetter<IrisTester> irisTester) {

final onFirstLocalVideoFramePublishedCompleter = Completer<bool>();
final theRtcEngineEventHandler = RtcEngineEventHandler(
onFirstLocalVideoFramePublished: (VideoSourceType source, int elapsed) {
onFirstLocalVideoFramePublished:
(RtcConnection connection, int elapsed) {
onFirstLocalVideoFramePublishedCompleter.complete(true);
},
);
Expand All @@ -1515,11 +1516,16 @@ void generatedTestCases(ValueGetter<IrisTester> irisTester) {
await Future.delayed(const Duration(milliseconds: 500));

{
VideoSourceType source = VideoSourceType.videoSourceCameraPrimary;
String connectionChannelId = "hello";
int connectionLocalUid = 5;
RtcConnection connection = RtcConnection(
channelId: connectionChannelId,
localUid: connectionLocalUid,
);
int elapsed = 5;

final eventJson = {
'source': source.value(),
'connection': connection.toJson(),
'elapsed': elapsed,
};

Expand Down Expand Up @@ -2652,7 +2658,7 @@ void generatedTestCases(ValueGetter<IrisTester> irisTester) {

final onLocalVideoStatsCompleter = Completer<bool>();
final theRtcEngineEventHandler = RtcEngineEventHandler(
onLocalVideoStats: (VideoSourceType source, LocalVideoStats stats) {
onLocalVideoStats: (RtcConnection connection, LocalVideoStats stats) {
onLocalVideoStatsCompleter.complete(true);
},
);
Expand All @@ -2665,7 +2671,12 @@ void generatedTestCases(ValueGetter<IrisTester> irisTester) {
await Future.delayed(const Duration(milliseconds: 500));

{
VideoSourceType source = VideoSourceType.videoSourceCameraPrimary;
String connectionChannelId = "hello";
int connectionLocalUid = 5;
RtcConnection connection = RtcConnection(
channelId: connectionChannelId,
localUid: connectionLocalUid,
);
QualityAdaptIndication statsQualityAdaptIndication =
QualityAdaptIndication.adaptNone;
VideoCodecType statsCodecType = VideoCodecType.videoCodecNone;
Expand Down Expand Up @@ -2718,7 +2729,7 @@ void generatedTestCases(ValueGetter<IrisTester> irisTester) {
);

final eventJson = {
'source': source.value(),
'connection': connection.toJson(),
'stats': stats.toJson(),
};

Expand Down
14 changes: 0 additions & 14 deletions tool/terra/configs/cud_node_parser.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,13 @@ const deleteNodes = [
namespaces: ["agora", "rtc"],
parent_name: "IRtcEngineEventHandlerEx",
},
{
// onFirstLocalVideoFramePublished
__TYPE: CXXTYPE.MemberFunction,
name: "onFirstLocalVideoFramePublished",
namespaces: ["agora", "rtc"],
parent_name: "IRtcEngineEventHandlerEx",
},
{
// onLocalVideoStateChanged
__TYPE: CXXTYPE.MemberFunction,
name: "onLocalVideoStateChanged",
namespaces: ["agora", "rtc"],
parent_name: "IRtcEngineEventHandlerEx",
},
{
// onLocalVideoStats
__TYPE: CXXTYPE.MemberFunction,
name: "onLocalVideoStats",
namespaces: ["agora", "rtc"],
parent_name: "IRtcEngineEventHandlerEx",
},
{
// agora::base::IEngineBase
__TYPE: CXXTYPE.Clazz,
Expand Down

0 comments on commit 47ac794

Please sign in to comment.