Skip to content

Commit

Permalink
iOS完善
Browse files Browse the repository at this point in the history
  • Loading branch information
邓博 authored and 邓博 committed Jun 30, 2017
1 parent 8c054bf commit 8223e17
Show file tree
Hide file tree
Showing 23 changed files with 451 additions and 132 deletions.
28 changes: 28 additions & 0 deletions RTCEngine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {
NativeModules,
findNodeHandle,
NativeAppEventEmitter
} from 'react-native';

const { Agora } = NativeModules

export default {
...Agora,
init(options = {}) {
this.listener && this.listener.remove();
Agora.init(options);
},
joinChannel(channelName = '001'){
Agora.joinChannel(channelName)
},
eventEmitter(fnConf) {
//there are no `removeListener` for NativeAppEventEmitter & DeviceEventEmitter
this.listener && this.listener.remove();
this.listener = NativeAppEventEmitter.addListener('agoraEvent', event => {
fnConf[event['type']] && fnConf[event['type']](event);
});
},
removeEmitter() {
this.listener && this.listener.remove();
}
};
Binary file modified android/libs/agora-rtc-sdk.jar
Binary file not shown.
21 changes: 18 additions & 3 deletions android/src/main/java/com/syan/agora/AgoraModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,30 @@ public void run() {
*/
@Override
public void onLeaveChannel(RtcStats stats) {

runOnUiThread(new Runnable() {
@Override
public void run() {
WritableMap map = Arguments.createMap();
map.putString("type", "onLeaveChannel");
commonEvent(map);
}
});
}

/**
* 用户uid离线时的回调
*/
@Override
public void onUserOffline(int uid, int reason) {

public void onUserOffline(final int uid, int reason) {
runOnUiThread(new Runnable() {
@Override
public void run() {
WritableMap map = Arguments.createMap();
map.putString("type", "onUserOffline");
map.putInt("uid", uid);
commonEvent(map);
}
});
}
};

Expand Down
Binary file removed android/src/main/jniLibs/arm64-v8a/libHDACEngine.so
Binary file not shown.
Binary file modified android/src/main/jniLibs/arm64-v8a/libagora-rtc-sdk-jni.so
Binary file not shown.
Binary file not shown.
Binary file modified android/src/main/jniLibs/armeabi-v7a/libagora-rtc-sdk-jni.so
Binary file not shown.
90 changes: 68 additions & 22 deletions android/src/main/jniLibs/include/IAgoraRtcEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ enum WARN_CODE_TYPE
WARN_ADM_RECORD_AUDIO_SILENCE = 1019,
WARN_ADM_PLAYOUT_MALFUNCTION = 1020,
WARN_ADM_RECORD_MALFUNCTION = 1021,
WARN_ADM_RECORD_AUDIO_LOWLEVEL = 1031,
WARN_APM_HOWLING = 1051,

// sdk: 100~1000
Expand Down Expand Up @@ -213,7 +214,7 @@ enum LOG_FILTER_TYPE

enum MAX_DEVICE_ID_LENGTH_TYPE
{
MAX_DEVICE_ID_LENGTH = 128
MAX_DEVICE_ID_LENGTH = 512
};

enum QUALITY_REPORT_FORMAT_TYPE
Expand All @@ -237,7 +238,7 @@ enum MEDIA_ENGINE_EVENT_CODE_TYPE
MEDIA_ENGINE_ROLE_COMM_PEER = 23,
MEDIA_ENGINE_ROLE_GAME_PEER = 24,
// iOS adm sample rate changed
MEDIA_ENGINE_AUDIO_ADM_SAMPLE_RATE_CHANGE = 110
MEDIA_ENGINE_AUDIO_ADM_REQUIRE_RESTART = 110
};

enum MEDIA_DEVICE_STATE_TYPE
Expand Down Expand Up @@ -434,6 +435,41 @@ struct VideoCompositingLayout
{}
};

#if defined(_WIN32)

enum RTMP_STREAM_LIFE_CYCLE_TYPE
{
RTMP_STREAM_LIFE_CYCLE_BIND2CHANNEL = 1,
RTMP_STREAM_LIFE_CYCLE_BIND2OWNER = 2,
};

struct PublisherConfiguration {
int width;
int height;
int framerate;
int bitrate;
int defaultLayout;
int lifecycle;
bool owner;
const char* publishUrl;
const char* rawStreamUrl;
const char* extraInfo;

PublisherConfiguration()
: width(640)
, height(360)
, framerate(15)
, bitrate(500)
, defaultLayout(1)
, lifecycle(RTMP_STREAM_LIFE_CYCLE_BIND2CHANNEL)
, owner(true)
, publishUrl(NULL)
, rawStreamUrl(NULL)
, extraInfo(NULL)
{}

};
#endif
#if !defined(__ANDROID__)
struct VideoCanvas
{
Expand Down Expand Up @@ -570,7 +606,7 @@ class IRtcEngineEventHandler
* @param [in] uid
* the uid of the peer
* @param [in] quality
* the quality of the user 0~5 the higher the better
* the quality of the user, see QUALITY_TYPE for value definition
* @param [in] delay
* the average time of the audio packages delayed
* @param [in] lost
Expand Down Expand Up @@ -900,6 +936,28 @@ class IRtcEngineEventHandler
*/
virtual void onRequestChannelKey() {
}

/**
* when the first local audio frame generated, the function will be called
* @param [in] elapsed
* the time elapsed from remote user called joinChannel in ms
*/
virtual void onFirstLocalAudioFrame(int elapsed) {
(void)elapsed;
}

/**
* when the first remote audio frame arrived, the function will be called
* @param [in] uid
* the UID of the remote user
* @param [in] elapsed
* the time elapsed from remote user called joinChannel in ms
*/
virtual void onFirstRemoteAudioFrame(uid_t uid, int elapsed) {
(void)uid;
(void)elapsed;
}

};

/**
Expand Down Expand Up @@ -1339,6 +1397,10 @@ class IRtcEngine

virtual int setVideoCompositingLayout(const VideoCompositingLayout& sei) = 0;
virtual int clearVideoCompositingLayout() = 0;

#if defined(_WIN32)
virtual int configPublisher(const PublisherConfiguration& config) = 0;
#endif
};


Expand Down Expand Up @@ -1616,25 +1678,6 @@ class RtcEngineParameters
return setObject("rtc.video.set_remote_video_stream", "{\"uid\":%u,\"stream\":%d}", uid, streamType);
}


/**
* play the video stream from network
* @param [in] uri the link of video source
* @return return 0 if success or an error code
*/
int startPlayingStream(const char* uri) {
return m_parameter ? m_parameter->setString("rtc.api.video.start_play_stream", uri) : -ERR_NOT_INITIALIZED;
}

/**
* stop playing the video stream from network
*
* @return return 0 if success or an error code
*/
int stopPlayingStream() {
return m_parameter ? m_parameter->setBool("rtc.api.video.stop_play_stream", true) : -ERR_NOT_INITIALIZED;
}

/**
* set play sound volume
* @param [in] volume
Expand Down Expand Up @@ -1752,6 +1795,9 @@ class RtcEngineParameters
r = pos;
return r;
}
int setAudioMixingPosition(int pos /*in ms*/) {
return m_parameter ? m_parameter->setInt("che.audio.mixing.file.position", pos) : -ERR_NOT_INITIALIZED;
}
#if defined(__APPLE__)
/**
* start screen capture
Expand Down
Binary file removed android/src/main/jniLibs/x86/libHDACEngine.so
Binary file not shown.
Binary file modified android/src/main/jniLibs/x86/libagora-rtc-sdk-jni.so
Binary file not shown.
40 changes: 4 additions & 36 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
import {
NativeModules,
findNodeHandle,
NativeAppEventEmitter
} from 'react-native';

const { Agora } = NativeModules
import _AgoraView from './AgoraView'
import _RTCEngine from './RTCEngine'

export default {

init(options = {}) {
this.listener && this.listener.remove();
Agora.init(options);
},
joinChannel(channelName = '001'){
Agora.joinChannel(channelName)
},
eventEmitter(fnConf) {
// const {
// onFirstRemoteVideoDecoded = () => {},
// onJoinChannelSuccess = () => {},
// onUserJoined = () => {},
// onError = () => {},
// onWarning = () => {}
// } = options;

// let fnConf = {...options};
//there are no `removeListener` for NativeAppEventEmitter & DeviceEventEmitter
this.listener && this.listener.remove();
this.listener = NativeAppEventEmitter.addListener('agoraEvent', event => {
fnConf[event['type']] && fnConf[event['type']](event);
});
},
removeEmitter() {
this.listener && this.listener.remove();
}

};
export const AgoraView = _AgoraView;
export const RTCEngine = _RTCEngine;
17 changes: 17 additions & 0 deletions ios/RCTAgora/AgoraConst.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// MyAgoraRtcEngineKit.h
// RCTAgora
//
// Created by 邓博 on 2017/6/30.
// Copyright © 2017年 Syan. All rights reserved.
//

#import <AgoraRtcEngineKit/AgoraRtcEngineKit.h>

@interface AgoraConst : NSObject

@property (nonatomic, copy) NSString *appid;

+ (instancetype)share;

@end
36 changes: 36 additions & 0 deletions ios/RCTAgora/AgoraConst.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// MyAgoraRtcEngineKit.m
// RCTAgora
//
// Created by 邓博 on 2017/6/30.
// Copyright © 2017年 Syan. All rights reserved.
//

#import "AgoraConst.h"

@implementation AgoraConst

static AgoraConst *_person;
+ (instancetype)allocWithZone:(struct _NSZone *)zone{
static dispatch_once_t predicate;
dispatch_once(&predicate, ^{
_person = [super allocWithZone:zone];
});
return _person;
}

+ (instancetype)share {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_person = [[self alloc]init];
});
return _person;
}

- (id)copyWithZone:(NSZone *)zone {
return _person;
}



@end
Loading

0 comments on commit 8223e17

Please sign in to comment.