Skip to content

ci: formatting check #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 9, 2025
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
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,20 @@ jobs:
- name: Check if the git repository is clean
run: $(exit $(git status --porcelain --untracked-files=no | head -255 | wc -l)) || (echo "Dirty git tree"; git diff; exit 1)
- run: npm run lint
clang:
name: Clang-Format Check
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
path:
- 'ios'
- 'android'
steps:
- uses: actions/checkout@v4
- uses: jidicula/[email protected]
with:
clang-format-version: '17'
check-path: ${{ matrix.path }}
include-regex: '^.*(\.h|\.m|\.java)'
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
import androidx.annotation.Nullable;
import androidx.core.util.Consumer;

import androidx.annotation.Nullable;
import androidx.core.util.Consumer;

import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;

Expand Down
8 changes: 4 additions & 4 deletions android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public WebRTCModule(ReactApplicationContext reactContext) {
String fieldTrials = options.fieldTrials;

PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions.builder(reactContext)
.setFieldTrials(fieldTrials)
.setNativeLibraryLoader(new LibraryLoader())
.setInjectableLogger(injectableLogger, loggingSeverity)
.createInitializationOptions());
.setFieldTrials(fieldTrials)
.setNativeLibraryLoader(new LibraryLoader())
.setInjectableLogger(injectableLogger, loggingSeverity)
.createInitializationOptions());

if (injectableLogger == null && loggingSeverity != null) {
Logging.enableLogToDebugOutput(loggingSeverity);
Expand Down
12 changes: 8 additions & 4 deletions ios/RCTWebRTC/WebRTCModule+Permissions.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ - (AVMediaType)avMediaType:(NSString *)mediaType {
}
}

RCT_EXPORT_METHOD(checkPermission : (NSString *)mediaType resolver : (RCTPromiseResolveBlock)
resolve rejecter : (RCTPromiseRejectBlock)reject) {
RCT_EXPORT_METHOD(checkPermission
: (NSString *)mediaType resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject) {
#if TARGET_OS_TV
resolve(@"tvOS is not supported");
return;
Expand Down Expand Up @@ -48,8 +50,10 @@ - (AVMediaType)avMediaType:(NSString *)mediaType {
#endif
}

RCT_EXPORT_METHOD(requestPermission : (NSString *)mediaType resolver : (RCTPromiseResolveBlock)
resolve rejecter : (RCTPromiseRejectBlock)reject) {
RCT_EXPORT_METHOD(requestPermission
: (NSString *)mediaType resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject) {
#if TARGET_OS_TV
resolve(@"tvOS is not supported");
return;
Expand Down
71 changes: 40 additions & 31 deletions ios/RCTWebRTC/WebRTCModule+RTCDataChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ @implementation WebRTCModule (RTCDataChannel)
* Thuis methos is implemented synchronously since we need to create the DataChannel on the spot
* and where is no good way to report an error at creation time.
*/
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(createDataChannel : (nonnull NSNumber *)peerConnectionId label : (NSString *)
label config : (RTCDataChannelConfiguration *)config) {
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(createDataChannel
: (nonnull NSNumber *)peerConnectionId label
: (NSString *)label config
: (RTCDataChannelConfiguration *)config) {
__block id channelInfo;

dispatch_sync(self.workerQueue, ^{
Expand Down Expand Up @@ -57,35 +59,42 @@ @implementation WebRTCModule (RTCDataChannel)
return channelInfo;
}

RCT_EXPORT_METHOD(dataChannelClose : (nonnull NSNumber *)peerConnectionId reactTag : (nonnull NSString *)tag {
RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
DataChannelWrapper *dcw = peerConnection.dataChannels[tag];
if (dcw) {
[dcw.channel close];
}
})

RCT_EXPORT_METHOD(dataChannelDispose : (nonnull NSNumber *)peerConnectionId reactTag : (nonnull NSString *)tag {
RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
DataChannelWrapper *dcw = peerConnection.dataChannels[tag];
if (dcw) {
dcw.delegate = nil;
[peerConnection.dataChannels removeObjectForKey:tag];
}
})

RCT_EXPORT_METHOD(dataChannelSend : (nonnull NSNumber *)peerConnectionId reactTag : (nonnull NSString *)
tag data : (NSString *)data type : (NSString *)type {
RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
DataChannelWrapper *dcw = peerConnection.dataChannels[tag];
if (dcw) {
BOOL isBinary = [type isEqualToString:@"binary"];
NSData *bytes = isBinary ? [[NSData alloc] initWithBase64EncodedString:data options:0]
: [data dataUsingEncoding:NSUTF8StringEncoding];
RTCDataBuffer *buffer = [[RTCDataBuffer alloc] initWithData:bytes isBinary:isBinary];
[dcw.channel sendData:buffer];
}
})
RCT_EXPORT_METHOD(dataChannelClose
: (nonnull NSNumber *)peerConnectionId reactTag
: (nonnull NSString *)tag {
RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
DataChannelWrapper *dcw = peerConnection.dataChannels[tag];
if (dcw) {
[dcw.channel close];
}
})

RCT_EXPORT_METHOD(dataChannelDispose
: (nonnull NSNumber *)peerConnectionId reactTag
: (nonnull NSString *)tag {
RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
DataChannelWrapper *dcw = peerConnection.dataChannels[tag];
if (dcw) {
dcw.delegate = nil;
[peerConnection.dataChannels removeObjectForKey:tag];
}
})

RCT_EXPORT_METHOD(dataChannelSend
: (nonnull NSNumber *)peerConnectionId reactTag
: (nonnull NSString *)tag data
: (NSString *)data type
: (NSString *)type {
RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
DataChannelWrapper *dcw = peerConnection.dataChannels[tag];
if (dcw) {
BOOL isBinary = [type isEqualToString:@"binary"];
NSData *bytes = isBinary ? [[NSData alloc] initWithBase64EncodedString:data options:0]
: [data dataUsingEncoding:NSUTF8StringEncoding];
RTCDataBuffer *buffer = [[RTCDataBuffer alloc] initWithData:bytes isBinary:isBinary];
[dcw.channel sendData:buffer];
}
})

- (NSString *)stringForDataChannelState:(RTCDataChannelState)state {
switch (state) {
Expand Down
30 changes: 20 additions & 10 deletions ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ - (RTCVideoTrack *)createScreenCaptureVideoTrack {
* if audio permission was not granted, there will be no "audio" key in
* the constraints dictionary.
*/
RCT_EXPORT_METHOD(getUserMedia : (NSDictionary *)constraints successCallback : (RCTResponseSenderBlock)
successCallback errorCallback : (RCTResponseSenderBlock)errorCallback) {
RCT_EXPORT_METHOD(getUserMedia
: (NSDictionary *)constraints successCallback
: (RCTResponseSenderBlock)successCallback errorCallback
: (RCTResponseSenderBlock)errorCallback) {
#if TARGET_OS_TV
errorCallback(@[ @"PlatformNotSupported", @"getUserMedia is not supported on tvOS." ]);
return;
Expand Down Expand Up @@ -363,8 +365,10 @@ - (RTCVideoTrack *)createScreenCaptureVideoTrack {
self.localStreams[streamID] = mediaStream;
}

RCT_EXPORT_METHOD(mediaStreamAddTrack : (nonnull NSString *)streamID : (nonnull NSNumber *)pcId : (nonnull NSString *)
trackID) {
RCT_EXPORT_METHOD(mediaStreamAddTrack
: (nonnull NSString *)streamID
: (nonnull NSNumber *)pcId
: (nonnull NSString *)trackID) {
RTCMediaStream *mediaStream = self.localStreams[streamID];
if (mediaStream == nil) {
return;
Expand All @@ -382,8 +386,10 @@ - (RTCVideoTrack *)createScreenCaptureVideoTrack {
}
}

RCT_EXPORT_METHOD(mediaStreamRemoveTrack : (nonnull NSString *)streamID : (nonnull NSNumber *)
pcId : (nonnull NSString *)trackID) {
RCT_EXPORT_METHOD(mediaStreamRemoveTrack
: (nonnull NSString *)streamID
: (nonnull NSNumber *)pcId
: (nonnull NSString *)trackID) {
RTCMediaStream *mediaStream = self.localStreams[streamID];
if (mediaStream == nil) {
return;
Expand Down Expand Up @@ -440,8 +446,11 @@ - (RTCVideoTrack *)createScreenCaptureVideoTrack {
#endif
}

RCT_EXPORT_METHOD(mediaStreamTrackApplyConstraints : (nonnull NSString *)trackID : (NSDictionary *)
constraints : (RCTPromiseResolveBlock)resolve : (RCTPromiseRejectBlock)reject) {
RCT_EXPORT_METHOD(mediaStreamTrackApplyConstraints
: (nonnull NSString *)trackID
: (NSDictionary *)constraints
: (RCTPromiseResolveBlock)resolve
: (RCTPromiseRejectBlock)reject) {
#if TARGET_OS_TV
reject(@"unsupported_platform", @"tvOS is not supported", nil);
return;
Expand Down Expand Up @@ -479,8 +488,9 @@ - (RTCVideoTrack *)createScreenCaptureVideoTrack {
}
}

RCT_EXPORT_METHOD(mediaStreamTrackSetVideoEffects : (nonnull NSString *)trackID names : (nonnull NSArray<NSString *> *)
names) {
RCT_EXPORT_METHOD(mediaStreamTrackSetVideoEffects
: (nonnull NSString *)trackID names
: (nonnull NSArray<NSString *> *)names) {
RTCMediaStreamTrack *track = self.localTracks[trackID];
if (track == nil) {
return;
Expand Down
81 changes: 55 additions & 26 deletions ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ - (nullable RTCRtpTransceiver *)getTransceiverByPeerConnectionId:(nonnull NSNumb
* This method is synchronous and blocking. This is done so we can implement createDataChannel
* in the same way (synchronous) since the peer connection needs to exist before.
*/
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionInit : (RTCConfiguration *)
configuration objectID : (nonnull NSNumber *)objectID) {
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionInit
: (RTCConfiguration *)configuration objectID
: (nonnull NSNumber *)objectID) {
__block BOOL ret = YES;

dispatch_sync(self.workerQueue, ^{
Expand All @@ -154,17 +155,21 @@ - (nullable RTCRtpTransceiver *)getTransceiverByPeerConnectionId:(nonnull NSNumb
return @(ret);
}

RCT_EXPORT_METHOD(peerConnectionSetConfiguration : (RTCConfiguration *)configuration objectID : (nonnull NSNumber *)
objectID) {
RCT_EXPORT_METHOD(peerConnectionSetConfiguration
: (RTCConfiguration *)configuration objectID
: (nonnull NSNumber *)objectID) {
RTCPeerConnection *peerConnection = self.peerConnections[objectID];
if (!peerConnection) {
return;
}
[peerConnection setConfiguration:configuration];
}

RCT_EXPORT_METHOD(peerConnectionCreateOffer : (nonnull NSNumber *)objectID options : (NSDictionary *)
options resolver : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) {
RCT_EXPORT_METHOD(peerConnectionCreateOffer
: (nonnull NSNumber *)objectID options
: (NSDictionary *)options resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject) {
RTCPeerConnection *peerConnection = self.peerConnections[objectID];
if (!peerConnection) {
reject(@"E_INVALID", @"PeerConnection not found", nil);
Expand Down Expand Up @@ -208,8 +213,11 @@ - (nullable RTCRtpTransceiver *)getTransceiverByPeerConnectionId:(nonnull NSNumb
[peerConnection offerForConstraints:constraints completionHandler:handler];
}

RCT_EXPORT_METHOD(peerConnectionCreateAnswer : (nonnull NSNumber *)objectID options : (NSDictionary *)
options resolver : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) {
RCT_EXPORT_METHOD(peerConnectionCreateAnswer
: (nonnull NSNumber *)objectID options
: (NSDictionary *)options resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject) {
RTCPeerConnection *peerConnection = self.peerConnections[objectID];
if (!peerConnection) {
reject(@"E_INVALID", @"PeerConnection not found", nil);
Expand Down Expand Up @@ -237,8 +245,11 @@ - (nullable RTCRtpTransceiver *)getTransceiverByPeerConnectionId:(nonnull NSNumb
[peerConnection answerForConstraints:constraints completionHandler:handler];
}

RCT_EXPORT_METHOD(peerConnectionSetLocalDescription : (nonnull NSNumber *)objectID desc : (RTCSessionDescription *)
desc resolver : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) {
RCT_EXPORT_METHOD(peerConnectionSetLocalDescription
: (nonnull NSNumber *)objectID desc
: (RTCSessionDescription *)desc resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject) {
RTCPeerConnection *peerConnection = self.peerConnections[objectID];
if (!peerConnection) {
reject(@"E_INVALID", @"PeerConnection not found", nil);
Expand Down Expand Up @@ -273,8 +284,11 @@ - (nullable RTCRtpTransceiver *)getTransceiverByPeerConnectionId:(nonnull NSNumb
}
}

RCT_EXPORT_METHOD(peerConnectionSetRemoteDescription : (nonnull NSNumber *)objectID desc : (RTCSessionDescription *)
desc resolver : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) {
RCT_EXPORT_METHOD(peerConnectionSetRemoteDescription
: (nonnull NSNumber *)objectID desc
: (RTCSessionDescription *)desc resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject) {
RTCPeerConnection *peerConnection = self.peerConnections[objectID];
if (!peerConnection) {
reject(@"E_INVALID", @"PeerConnection not found", nil);
Expand Down Expand Up @@ -322,8 +336,11 @@ - (nullable RTCRtpTransceiver *)getTransceiverByPeerConnectionId:(nonnull NSNumb
[peerConnection setRemoteDescription:desc completionHandler:handler];
}

RCT_EXPORT_METHOD(peerConnectionAddICECandidate : (nonnull NSNumber *)objectID candidate : (RTCIceCandidate *)
candidate resolver : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) {
RCT_EXPORT_METHOD(peerConnectionAddICECandidate
: (nonnull NSNumber *)objectID candidate
: (RTCIceCandidate *)candidate resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject) {
RTCPeerConnection *peerConnection = self.peerConnections[objectID];
if (!peerConnection) {
reject(@"E_INVALID", @"PeerConnection not found", nil);
Expand Down Expand Up @@ -384,8 +401,10 @@ - (nullable RTCRtpTransceiver *)getTransceiverByPeerConnectionId:(nonnull NSNumb
[self.peerConnections removeObjectForKey:objectID];
}

RCT_EXPORT_METHOD(peerConnectionGetStats : (nonnull NSNumber *)objectID resolver : (RCTPromiseResolveBlock)
resolve rejecter : (RCTPromiseRejectBlock)reject) {
RCT_EXPORT_METHOD(peerConnectionGetStats
: (nonnull NSNumber *)objectID resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject) {
RTCPeerConnection *peerConnection = self.peerConnections[objectID];
if (!peerConnection) {
RCTLogWarn(@"PeerConnection %@ not found in peerConnectionGetStats()", objectID);
Expand All @@ -398,8 +417,11 @@ - (nullable RTCRtpTransceiver *)getTransceiverByPeerConnectionId:(nonnull NSNumb
}];
}

RCT_EXPORT_METHOD(receiverGetStats : (nonnull NSNumber *)pcId receiverId : (nonnull NSString *)
receiverId resolver : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) {
RCT_EXPORT_METHOD(receiverGetStats
: (nonnull NSNumber *)pcId receiverId
: (nonnull NSString *)receiverId resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject) {
RTCPeerConnection *peerConnection = self.peerConnections[pcId];
if (!peerConnection) {
RCTLogWarn(@"PeerConnection %@ not found in receiverGetStats()", pcId);
Expand Down Expand Up @@ -427,8 +449,11 @@ - (nullable RTCRtpTransceiver *)getTransceiverByPeerConnectionId:(nonnull NSNumb
}];
}

RCT_EXPORT_METHOD(senderGetStats : (nonnull NSNumber *)pcId senderId : (nonnull NSString *)
senderId resolver : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) {
RCT_EXPORT_METHOD(senderGetStats
: (nonnull NSNumber *)pcId senderId
: (nonnull NSString *)senderId resolver
: (RCTPromiseResolveBlock)resolve rejecter
: (RCTPromiseRejectBlock)reject) {
RTCPeerConnection *peerConnection = self.peerConnections[pcId];
if (!peerConnection) {
RCTLogWarn(@"PeerConnection %@ not found in senderGetStats()", pcId);
Expand Down Expand Up @@ -465,8 +490,10 @@ - (nullable RTCRtpTransceiver *)getTransceiverByPeerConnectionId:(nonnull NSNumb
[peerConnection restartIce];
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionAddTrack : (nonnull NSNumber *)objectID trackId : (NSString *)
trackId options : (NSDictionary *)options) {
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionAddTrack
: (nonnull NSNumber *)objectID trackId
: (NSString *)trackId options
: (NSDictionary *)options) {
__block id params = nil;

dispatch_sync(self.workerQueue, ^{
Expand Down Expand Up @@ -504,8 +531,9 @@ - (nullable RTCRtpTransceiver *)getTransceiverByPeerConnectionId:(nonnull NSNumb
return params;
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionAddTransceiver : (nonnull NSNumber *)
objectID options : (NSDictionary *)options) {
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionAddTransceiver
: (nonnull NSNumber *)objectID options
: (NSDictionary *)options) {
__block id params = nil;

dispatch_sync(self.workerQueue, ^{
Expand Down Expand Up @@ -561,8 +589,9 @@ - (nullable RTCRtpTransceiver *)getTransceiverByPeerConnectionId:(nonnull NSNumb
return params;
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionRemoveTrack : (nonnull NSNumber *)
objectID senderId : (nonnull NSString *)senderId) {
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionRemoveTrack
: (nonnull NSNumber *)objectID senderId
: (nonnull NSString *)senderId) {
__block BOOL ret = NO;

dispatch_sync(self.workerQueue, ^{
Expand Down
Loading
Loading