Skip to content

Commit

Permalink
feat. upgrade to 2.9.0 native sdk android & ios. stage 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrixbirds committed Aug 22, 2019
1 parent 2f6cb4d commit b99c21e
Show file tree
Hide file tree
Showing 7 changed files with 300 additions and 118 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies {
def androidSupportVersion = rootProject.hasProperty("androidSupportVersion") ? rootProject.androidSupportVersion : DEFAULT_ANDROID_SUPPORT_VERSION
// from internet
implementation "com.android.support:appcompat-v7:$androidSupportVersion"
implementation "io.agora.rtc:full-sdk:2.8.2"
implementation "io.agora.rtc:full-sdk:2.9.0"
// from node_modules
implementation "com.facebook.react:react-native:+"
}
Expand Down
11 changes: 5 additions & 6 deletions android/src/main/java/com/syan/agora/AgoraConst.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ public class AgoraConst {
public final static String AGFirstLocalAudioFrame = "firstLocalAudioFrame";
public final static String AGFirstRemoteAudioFrame = "firstRemoteAudioFrame";
public final static String AGFirstLocalVideoFrame = "firstLocalVideoFrame";
public final static String AGFirstRemoteVideoDecoded = "firstRemoteVideoDecoded";
public final static String AGFirstRemoteVideoFrame = "firstRemoteVideoFrame";
public final static String AGUserMuteAudio = "userMuteAudio";
public final static String AGUserMuteVideo = "userMuteVideo";
public final static String AGUserEnableVideo = "userEnableVideo";
public final static String AGUserEnableLocalVideo = "userEnableLocalVideo";
public final static String AGVideoSizeChanged = "videoSizeChanged";
public final static String AGRtmpStreamingStateChanged = "rtmpStreamingStateChanged";
public final static String AGNetworkTypeChanged = "networkTypeChanged";
Expand All @@ -44,15 +40,18 @@ public class AgoraConst {
public final static String AGAudioRouteChanged = "audioRouteChanged";
public final static String AGCameraFocusAreaChanged = "cameraFocusAreaChanged";
public final static String AGCameraExposureAreaChanged = "cameraExposureAreaChanged";
public final static String AGRemoteAudioStateChanged = "remoteAudioStateChanged";
public final static String AGLocalAudioStateChanged = "localAudioStateChanged";
public final static String AGLocalAudioStats = "localAudioStats";
public final static String AGMediaRelayStateChanged = "mediaRelayStateChanged";
public final static String AGReceivedChannelMediaRelay = "receivedChannelMediaRelay";

public final static String AGRtcStats = "rtcStats";
public final static String AGLastmileQuality = "lastmileQuality";
public final static String AGNetworkQuality = "networkQuality";
public final static String AGLocalVideoStats = "localVideoStats";
public final static String AGRemoteVideoStats = "remoteVideoStats";
public final static String AGRemoteAudioStats = "remoteAudioStats";
public final static String AGAudioTransportStatsOfUid = "audioTransportStatsOfUid";
public final static String AGVideoTransportStatsOfUid = "videoTransportStatsOfUid";

public final static String AGRemoteAudioMixingStart = "remoteAudioMixingStart";
public final static String AGRemoteAudioMixingFinish = "remoteAudioMixingFinish";
Expand Down
300 changes: 201 additions & 99 deletions android/src/main/java/com/syan/agora/AgoraModule.java

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion android/src/main/java/com/syan/agora/AgoraVideoView.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public void setZOrderMediaOverlay(boolean zOrderMediaOverlay) {
private Integer renderMode = 1;
private Integer remoteUid;
private boolean zOrderMediaOverlay;
private SurfaceView surfaceView;

public AgoraVideoView(Context context) {
super(context);
Expand Down
3 changes: 3 additions & 0 deletions ios/RCTAgora/AgoraConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ static NSString *AGStreamInjectedStatus = @"streamInjectedStatus";
static NSString *AGReceiveStreamMessage = @"receiveStreamMessage";
static NSString *AGOccurStreamMessageError = @"occurStreamMessageError";

static NSString *AGReceivedChannelMediaRelay = @"receivedChannelMediaRelay";
static NSString *AGMediaRelayStateChanged = @"mediaRelayStateChanged";

static NSString *AGMediaEngineLoaded = @"mediaEngineLoaded";
static NSString *AGMediaEngineStartCall = @"mediaEngineStartCall";

Expand Down
3 changes: 3 additions & 0 deletions ios/RCTAgora/AgoraConst.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ + (instancetype)share {
AGReceiveStreamMessage,
AGOccurStreamMessageError,

AGReceivedChannelMediaRelay,
AGMediaRelayStateChanged,

AGMediaEngineLoaded,
AGMediaEngineStartCall,
AGIntervalTest,
Expand Down
98 changes: 87 additions & 11 deletions ios/RCTAgora/RCTAgora.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ - (NSData *_Nullable)readyToSendMetadataAtTimestamp:(NSTimeInterval)timestamp
return toSend;
}

- (void)receiveMetadata:(NSData *_Nonnull)data fromUser:(NSUInteger)uid atTimestamp:(NSTimeInterval)timestamp {
- (void)receiveMetadata:(NSData *_Nonnull)data fromUser:(NSInteger)uid atTimestamp:(NSTimeInterval)timestamp {
NSString *dataStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
[self sendEvent:AGMediaMetaDataReceived params:@{
@"uid": @(uid),
Expand Down Expand Up @@ -313,6 +313,67 @@ - (NSDictionary *)constantsToExport {
}
}

// startChannelMediaRelay
RCT_EXPORT_METHOD(startChannelMediaRelay:(NSDictionary *)options
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject) {
AgoraChannelMediaRelayConfiguration *config = [[AgoraChannelMediaRelayConfiguration alloc] init];

AgoraChannelMediaRelayInfo *src = [config sourceInfo];
NSDictionary *srcOption = options[@"src"];
src.channelName = srcOption[@"channelName"];
src.uid = [srcOption[@"uid"] integerValue];
src.token = srcOption[@"token"];
AgoraChannelMediaRelayInfo *dst = [[AgoraChannelMediaRelayInfo alloc] init];
NSDictionary *dstOption = options[@"dst"];
dst.channelName = dstOption[@"channelName"];
dst.uid = [dstOption[@"uid"] integerValue];
dst.token = dstOption[@"token"];
[config setDestinationInfo:dst forChannelName:dstOption[@"channelName"]];
NSInteger res = [self.rtcEngine startChannelMediaRelay:config];
if (res == 0) {
resolve(nil);
} else {
reject(@(-1).stringValue, @(res).stringValue, nil);
}
}

// updateChannelMediaRelay
RCT_EXPORT_METHOD(updateChannelMediaRelay:(NSDictionary *)options
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject) {
AgoraChannelMediaRelayConfiguration *config = [[AgoraChannelMediaRelayConfiguration alloc] init];

AgoraChannelMediaRelayInfo *src = [config sourceInfo];
NSDictionary *srcOption = options[@"src"];
src.channelName = srcOption[@"channelName"];
src.uid = [srcOption[@"uid"] integerValue];
src.token = srcOption[@"token"];
AgoraChannelMediaRelayInfo *dst = [[AgoraChannelMediaRelayInfo alloc] init];
NSDictionary *dstOption = options[@"dst"];
dst.channelName = dstOption[@"channelName"];
dst.uid = [dstOption[@"uid"] integerValue];
dst.token = dstOption[@"token"];
[config setDestinationInfo:dst forChannelName:dstOption[@"channelName"]];
NSInteger res = [self.rtcEngine updateChannelMediaRelay:config];
if (res == 0) {
resolve(nil);
} else {
reject(@(-1).stringValue, @(res).stringValue, nil);
}
}

// stopChannelMediaRelay
RCT_EXPORT_METHOD(stopChannelMediaRelay:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject) {
NSInteger res = [self.rtcEngine stopChannelMediaRelay];
if (res == 0) {
resolve(nil);
} else {
reject(@(-1).stringValue, @(res).stringValue, nil);
}
}

// register user account
RCT_EXPORT_METHOD(registerLocalUserAccount:(NSDictionary *)options
resolve:(RCTPromiseResolveBlock)resolve
Expand Down Expand Up @@ -927,7 +988,7 @@ - (NSDictionary *)constantsToExport {

// set volume of effect
RCT_EXPORT_METHOD(setVolumeOfEffect
:(NSInteger) soundId
:(int) soundId
volume:(double)volume
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject) {
Expand Down Expand Up @@ -1717,25 +1778,25 @@ - (void) stopObserving {
#pragma mark - <AgoraRtcEngineDelegate>
// EVENT CALLBACKS
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurWarning:(AgoraWarningCode)warningCode {
[self sendEvent:AGWarning params:@{@"message": @"AgoraWarning", @"code": @(warningCode)}];
[self sendEvent:AGWarning params:@{@"message": @"AgoraWarning", @"errorCode": @(warningCode)}];
}

- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurError:(AgoraErrorCode)errorCode {
[self sendEvent:AGError params:@{@"message": @"AgoraError", @"code": @(errorCode)}];
[self sendEvent:AGError params:@{@"message": @"AgoraError", @"errorCode": @(errorCode)}];
}

- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didApiCallExecute:(NSInteger)error api:(NSString *_Nonnull)api result:(NSString *_Nonnull)result {
if (error != 0) {
[self sendEvent:AGError params:@{
@"api": api,
@"result": result,
@"error": @(error)
@"errorCode": @(error)
}];
} else {
[self sendEvent:AGApiCallExecute params:@{
@"api": api,
@"result": result,
@"error": @(error)
@"errorCode": @(error)
}];
}
}
Expand Down Expand Up @@ -1852,7 +1913,7 @@ - (void)rtcEngineRequestToken:(AgoraRtcEngineKit *_Nonnull)engine {
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localAudioStateChange:(AgoraAudioLocalState)state error:(AgoraAudioLocalError)error {
[self sendEvent:AGLocalAudioStateChanged params:@{
@"state": @(state),
@"error": @(error)
@"errorCode": @(error)
}];
}

Expand Down Expand Up @@ -1945,10 +2006,12 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine videoSizeChangedOfUid:(NSU
}];
}

- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStateChangedOfUid:(NSUInteger)uid state:(AgoraVideoRemoteState)state {
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStateChangedOfUid:(NSUInteger)uid state:(AgoraVideoRemoteState)state reason:(AgoraVideoRemoteStateReason)reason elapsed:(NSInteger)elapsed {
[self sendEvent:AGRemoteVideoStateChanged params:@{
@"uid": @(uid),
@"state": @(state)
@"state": @(state),
@"reason": @(reason),
@"elapsed": @(elapsed)
}];
}

Expand Down Expand Up @@ -2087,7 +2150,7 @@ - (void)rtcEngineDidAudioEffectFinish:(AgoraRtcEngineKit *_Nonnull)engine soundI
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamPublishedWithUrl:(NSString *_Nonnull)url errorCode:(AgoraErrorCode)errorCode {
[self sendEvent:AGStreamPublished params:@{
@"url": url,
@"code": @(errorCode)
@"errorCode": @(errorCode)
}];
}

Expand Down Expand Up @@ -2126,6 +2189,19 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamInjectedStatusOfUrl:
}];
}

- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine channelMediaRelayStateDidChange:(AgoraChannelMediaRelayState)state error:(AgoraChannelMediaRelayError)error {
[self sendEvent:AGMediaRelayStateChanged params:@{
@"state": @(state),
@"errorCode": @(error),
}];
}

- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didReceiveChannelMediaRelayEvent:(AgoraChannelMediaRelayEvent)event {
[self sendEvent:AGReceivedChannelMediaRelay params:@{
@"event": @(event),
}];
}

- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine receiveStreamMessageFromUid:(NSUInteger)uid streamId:(NSInteger)streamId data:(NSData *_Nonnull)data {
NSString *_data = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
[self sendEvent:AGReceiveStreamMessage params:@{
Expand All @@ -2138,7 +2214,7 @@ - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurStreamMessageError
[self sendEvent:AGOccurStreamMessageError params:@{
@"uid": @(uid),
@"streamId": @(streamId),
@"error": @(error),
@"errorCode": @(error),
@"missed": @(missed),
@"cached": @(cached)
}];
Expand Down

0 comments on commit b99c21e

Please sign in to comment.