Skip to content
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

feat. support ios & android 2.9.1 #102

Merged
merged 2 commits into from
Oct 14, 2019
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 CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## THE CHANGELOG

#### 2.9.1-alpha.1
- support 2.9.1 native sdk

#### 2.9.0-alpha.3
- hotfix ios compile error

Expand Down
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.9.0"
implementation "io.agora.rtc:full-sdk:2.9.1"
// from node_modules
implementation "com.facebook.react:react-native:+"
}
Expand Down
6 changes: 4 additions & 2 deletions android/src/main/java/com/syan/agora/AgoraManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.agora.rtc.IMetadataObserver;
import io.agora.rtc.IRtcEngineEventHandler;
import io.agora.rtc.RtcEngine;
import io.agora.rtc.RtcEngineEx;
import io.agora.rtc.video.BeautyOptions;
import io.agora.rtc.video.VideoCanvas;
import io.agora.rtc.video.VideoEncoderConfiguration;
Expand All @@ -31,7 +32,7 @@ public class AgoraManager {

public static AgoraManager sAgoraManager;

public RtcEngine mRtcEngine;
public RtcEngineEx mRtcEngine;

private Context context;

Expand Down Expand Up @@ -102,7 +103,8 @@ public int init(Context context, IRtcEngineEventHandler mRtcEventHandler, Readab
//create rtcEngine instance and setup rtcEngine eventHandler
try {
this.context = context;
this.mRtcEngine = RtcEngine.create(context, options.getString("appid"), mRtcEventHandler);
this.mRtcEngine = (RtcEngineEx) RtcEngineEx.create(context, options.getString("appid"), mRtcEventHandler);
this.mRtcEngine.setAppType(8);
if (options.hasKey("secret") && null != options.getString("secret")) {
mRtcEngine.setEncryptionSecret(options.getString("secret"));
if (options.hasKey("secretMode") && null != options.getString("secretMode")) {
Expand Down
67 changes: 63 additions & 4 deletions android/src/main/java/com/syan/agora/AgoraModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.agora.rtc.IMetadataObserver;
import io.agora.rtc.IRtcEngineEventHandler;
import io.agora.rtc.RtcEngine;
import io.agora.rtc.RtcEngineEx;
import io.agora.rtc.internal.LastmileProbeConfig;
import io.agora.rtc.live.LiveInjectStreamConfig;
import io.agora.rtc.live.LiveTranscoding;
Expand All @@ -38,6 +39,7 @@
import io.agora.rtc.video.ChannelMediaInfo;
import io.agora.rtc.video.ChannelMediaRelayConfiguration;
import io.agora.rtc.video.VideoEncoderConfiguration;
import io.agora.rtc.video.WatermarkOptions;

import static com.facebook.react.bridge.UiThreadUtil.runOnUiThread;
import static com.syan.agora.AgoraConst.*;
Expand Down Expand Up @@ -506,6 +508,7 @@ public void run() {
WritableMap obj = Arguments.createMap();
obj.putInt("uid", speakers[i].uid);
obj.putInt("volume", speakers[i].volume);
obj.putInt("vad", speakers[i].vad);
arr.pushMap(obj);
}

Expand Down Expand Up @@ -1105,11 +1108,16 @@ public void run() {
}
};

public void setAppType(RtcEngineEx engineEx) {
engineEx.setAppType(8);
}

@ReactMethod
public void init(ReadableMap options) {
AgoraManager.getInstance().init(getReactApplicationContext(), mRtcEventHandler, options);
appId = options.getString("appid");
rtcEngine = AgoraManager.getInstance().mRtcEngine;
setAppType((RtcEngineEx) rtcEngine);
}

@ReactMethod
Expand Down Expand Up @@ -1658,8 +1666,8 @@ public void adjustPlaybackSignalVolume(int volume, Promise promise) {
}

@ReactMethod
public void enableAudioVolumeIndication(int interval, int smooth, Promise promise) {
Integer res = AgoraManager.getInstance().mRtcEngine.enableAudioVolumeIndication(interval, smooth);
public void enableAudioVolumeIndication(int interval, int smooth, boolean vad, Promise promise) {
Integer res = AgoraManager.getInstance().mRtcEngine.enableAudioVolumeIndication(interval, smooth, vad);
if (res == 0) {
promise.resolve(null);
} else {
Expand Down Expand Up @@ -1888,6 +1896,7 @@ public void startAudioRecording(ReadableMap options, Promise promise) {
Integer res = AgoraManager.getInstance().mRtcEngine
.startAudioRecording(
options.getString("filepath"),
options.getInt("sampleRate"),
options.getInt("quality")
);
if (res == 0) {
Expand Down Expand Up @@ -1999,8 +2008,28 @@ public AgoraImage createAgoraImage(ReadableMap options) {

@ReactMethod
public void addVideoWatermark(ReadableMap options, Promise promise) {
String url = options.getString("url");
ReadableMap watermarkOptions = options.getMap("options");
ReadableMap positionLandscapeOptions = watermarkOptions.getMap("positionInPortraitMode");
WatermarkOptions watermarkOpts = new WatermarkOptions();
WatermarkOptions.Rectangle landscapePosition = new WatermarkOptions.Rectangle();
landscapePosition.height = positionLandscapeOptions.getInt("height");
landscapePosition.width = positionLandscapeOptions.getInt("width");
landscapePosition.x = positionLandscapeOptions.getInt("x");
landscapePosition.y = positionLandscapeOptions.getInt("y");

ReadableMap positionPortraitOptions = watermarkOptions.getMap("positionInPortraitMode");
WatermarkOptions.Rectangle portraitPosition = new WatermarkOptions.Rectangle();
portraitPosition.height = positionPortraitOptions.getInt("height");
portraitPosition.width = positionPortraitOptions.getInt("width");
portraitPosition.x = positionPortraitOptions.getInt("x");
portraitPosition.y = positionPortraitOptions.getInt("y");

watermarkOpts.positionInLandscapeMode = landscapePosition;
watermarkOpts.visibleInPreview = watermarkOptions.getBoolean("visibleInPreview");
watermarkOpts.positionInPortraitMode = portraitPosition;
Integer res = AgoraManager.getInstance().mRtcEngine
.addVideoWatermark(createAgoraImage(options));
.addVideoWatermark(url, watermarkOpts);
if (res == 0) {
promise.resolve(null);
} else {
Expand Down Expand Up @@ -2642,7 +2671,18 @@ public void setCameraCapturerConfiguration(ReadableMap options, Promise promise)
break;
}
}
CameraCapturerConfiguration config = new CameraCapturerConfiguration(preference);
CameraCapturerConfiguration.CAMERA_DIRECTION cameraDirection = CameraCapturerConfiguration.CAMERA_DIRECTION.CAMERA_REAR;
switch (options.getInt("cameraDirection")) {
case 0: {
cameraDirection = CameraCapturerConfiguration.CAMERA_DIRECTION.CAMERA_REAR;
break;
}
case 1: {
cameraDirection = CameraCapturerConfiguration.CAMERA_DIRECTION.CAMERA_FRONT;
break;
}
}
CameraCapturerConfiguration config = new CameraCapturerConfiguration(preference, cameraDirection);
Integer res = AgoraManager.getInstance().mRtcEngine.setCameraCapturerConfiguration(config);
if (res == 0) {
promise.resolve(null);
Expand All @@ -2651,8 +2691,27 @@ public void setCameraCapturerConfiguration(ReadableMap options, Promise promise)
}
}

@ReactMethod
public void setParameters(String paramStr, Promise promise) {
Integer res = AgoraManager.getInstance().mRtcEngine.setParameters(paramStr);
if (res == 0) {
promise.resolve(null);
} else {
promise.reject("-1", res.toString());
}
}

@ReactMethod
public void getParameter(String paramStr, String args, Promise promise) {
String res = AgoraManager.getInstance().mRtcEngine.getParameter(paramStr, args);
promise.resolve(res);
}

@ReactMethod
public void getParameters(String str, Promise promise) {
String res = AgoraManager.getInstance().mRtcEngine.getParameters(str);
promise.resolve(res);
}

private void sendEvent(ReactContext reactContext,
String eventName,
Expand Down
101 changes: 101 additions & 0 deletions ios/RCTAgora/AgoraConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,107 @@

#import <AgoraRtcEngineKit/AgoraRtcEngineKit.h>

typedef NS_ENUM(NSUInteger, AgoraRtcQualityReportFormat) {
AgoraRtc_QualityReportFormat_Json = 0,
AgoraRtc_QualityReportFormat_Html = 1,
};

typedef NS_ENUM(NSUInteger, AgoraRtcAppType) {
AgoraRtc_APP_TYPE_NATIVE = 0,
AgoraRtc_APP_TYPE_COCOS = 1,
AgoraRtc_APP_TYPE_UNITY = 2,
AgoraRtc_APP_TYPE_ELECTRON = 3,
AgoraRtc_APP_TYPE_FLUTTER = 4,
AgoraRtc_APP_TYPE_UNREAL = 5,
AgoraRtc_APP_TYPE_XAMARIN = 6,
AgoraRtc_APP_TYPE_APICLOUD = 7,
AgoraRtc_APP_TYPE_REACTNATIVE = 8
};


@protocol AgoraRtcEngineExtensionDelegate <AgoraRtcEngineDelegate>
@optional
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine audioTransportQualityOfUid:(NSUInteger)uid delay:(NSUInteger)delay lost:(NSUInteger)lost;
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine videoTransportQualityOfUid:(NSUInteger)uid delay:(NSUInteger)delay lost:(NSUInteger)lost;
@end


@interface AgoraRtcEngineKit (AgoraExtension)

+ (instancetype _Nonnull)sharedEngineWithAppId:(NSString * _Nonnull)appId
extensionDelegate:(id<AgoraRtcEngineExtensionDelegate> _Nullable)delegate;

/** Sets the profile to control the RTC engine.
*
* @param profile SDK profile in JSON format.
* @param merge Whether to merge the profile data with the original value.
*/
- (int)setProfile:(NSString * _Nonnull)profile
merge:(BOOL)merge;

/** Set wrapper frame type by language wrapper.
*
* @param appType wrapper frame type.
*/
- (int)setAppType:(AgoraRtcAppType)appType;

/** END OF COMMON METHODS */

/** BEGIN OF AUDIO METHODS */


/**
* Enable recap
*
* @param interval &le; 0: Disabled, > 0: Interval in ms.
*/
- (int)enableRecap:(NSInteger)interval;

/**
* Start playing recap conversation
*
*/
- (int)playRecap;

- (int)enableAudioQualityIndication:(BOOL)enabled;
- (int)enableTransportQualityIndication:(BOOL)enabled;

- (int)setVideoProfileEx:(NSInteger)width
andHeight:(NSInteger)height
andFrameRate:(NSInteger)frameRate
andBitrate:(NSInteger)andBitrate;

- (int)sendReportData:(NSData * _Nonnull)data
type:(NSInteger)type;
/** END OF AUDIO METHODS */

/** Queries internal states
* @param parameters
* json string, array type
* @return a json string
*/
- (NSString * _Nullable)getParameters:(NSString * _Nonnull)parameters;

/**
* Generates a URL linking to the call quality reports. @param channel The channel name specified in the joinChannel method.
* @param listenerUid The uid of the listener.
* @param speakerUid The uid of the speaker.
* @param reportFormat The format of the report.
AgoraRtc_QualityReportFormat_Json (0): JSON.: Returns the quality report data in Json.
AgoraRtc_QualityReportFormat_Html (1): HTML.: Returns a report in HTML format, displayed on a web browser or WebVIEW components.
*
* @return 0 when executed successfully. return minus value when failed. return AgoraRtc_Error_Invalid_Argument (-2):Invalid argument. return AgoraRtc_Error_Buffer_Too_Small (-6):The buffer length is too small.
*/
- (NSString * _Nullable)makeQualityReportUrl:(NSString * _Nonnull) channel
listenerUid:(NSUInteger)listenerUid
speakerrUid:(NSUInteger)speakerUid
reportFormat:(AgoraRtcQualityReportFormat)reportFormat;

/*********************************************************
* Large group conference call (experiment) - END
*********************************************************/
@end

static NSString *AG_PREFIX = @"ag_rtc";

static NSString *RCTAgoraErrorDomain = @"RCTAgoraErrorDomain";
Expand Down
Loading