zby-live-sdk 1.0.49-beta20221223 → 1.0.49-beta20230306
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +107 -9
- package/dist/zby-live-sdk.cjs.js +3 -3
- package/dist/zby-live-sdk.esm.js +3 -3
- package/dist/zby-live-sdk.umd.js +4 -3
- package/package.json +1 -1
- package/src/config/config.js +12 -1
- package/src/network/api.js +10 -1
- package/src/network/dataReport.js +7 -0
- package/src/notice.js +14 -0
- package/src/zby-av-sdk/zby-av-sdk.js +49 -5
- package/src/zby-av-sdk/zego-sdk.js +296 -7
- package/src/zby-live-sdk.js +27 -1
package/package.json
CHANGED
package/src/config/config.js
CHANGED
|
@@ -13,7 +13,7 @@ const urls = {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
// export const version = require('../../package.json').version;
|
|
16
|
-
export const version = '1.0.49-
|
|
16
|
+
export const version = '1.0.49-beta20230306';
|
|
17
17
|
|
|
18
18
|
export const liveExt = {
|
|
19
19
|
name: 'live',
|
|
@@ -108,11 +108,22 @@ const apiChangeSdkUrl = {
|
|
|
108
108
|
online: 'https://cloud-platform-live.speiyou.com/cloud-platform'
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
+
//开启混流
|
|
112
|
+
const apiMixStreams = {
|
|
113
|
+
test: 'https://tf-classroom-test.vdyoo.com',
|
|
114
|
+
online: 'https://tf-classroom-online.vdyoo.com'
|
|
115
|
+
};
|
|
116
|
+
|
|
111
117
|
export const getApiCloudBaseUrl = () => {
|
|
112
118
|
const {env} = config;
|
|
113
119
|
return apiCloudUrl[env];
|
|
114
120
|
};
|
|
115
121
|
|
|
122
|
+
export const getApiMixStreams = () => {
|
|
123
|
+
const {env} = config;
|
|
124
|
+
return apiMixStreams[env];
|
|
125
|
+
}
|
|
126
|
+
|
|
116
127
|
export const getApiChangeSdkUrl = () => {
|
|
117
128
|
const {env} = config;
|
|
118
129
|
return apiChangeSdkUrl[env];
|
package/src/network/api.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @FilePath: \1705\zby_live_sdk\src\network\api.js
|
|
8
8
|
*/
|
|
9
9
|
import commonFetch from './commonFetch.js';
|
|
10
|
-
import {getReportBaseUrl, getApiCloudBaseUrl, getCloudApiDomain, getApiChangeSdkUrl, timestampUrl} from '../config/config.js';
|
|
10
|
+
import {getReportBaseUrl, getApiCloudBaseUrl, getCloudApiDomain, getApiChangeSdkUrl, timestampUrl, getApiMixStreams} from '../config/config.js';
|
|
11
11
|
import util from '../util/util';
|
|
12
12
|
|
|
13
13
|
//获取信道服务器地址
|
|
@@ -48,3 +48,12 @@ export function dabanDataReport(param){
|
|
|
48
48
|
export function changeSdkInRoom(param){
|
|
49
49
|
return commonFetch(`${getApiChangeSdkUrl()}/rtccloud/sdk/set/lecture/client`, param, 'FROMDATA');
|
|
50
50
|
}
|
|
51
|
+
|
|
52
|
+
//开始混流
|
|
53
|
+
export function mixStreamsStart(param) {
|
|
54
|
+
return commonFetch(`${getApiMixStreams()}/rtc-backend/mix/stream/start`, param, 'POST');
|
|
55
|
+
}
|
|
56
|
+
//结束混流
|
|
57
|
+
export function mixStreamsStop(param) {
|
|
58
|
+
return commonFetch(`${getApiMixStreams()}/rtc-backend/mix/stream/end`, param, 'POST');
|
|
59
|
+
}
|
package/src/notice.js
CHANGED
|
@@ -168,6 +168,20 @@ export default {
|
|
|
168
168
|
data
|
|
169
169
|
});
|
|
170
170
|
},
|
|
171
|
+
// SDK自动重试推流成功
|
|
172
|
+
retryPushFlowSuccess(data) {
|
|
173
|
+
notice({
|
|
174
|
+
type:'retryPushFlowSuccess',
|
|
175
|
+
data
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
// SDK自动重试拉流成功
|
|
179
|
+
retryPullFlowSuccess(data) {
|
|
180
|
+
notice({
|
|
181
|
+
type:'retryPullFlowSuccess',
|
|
182
|
+
data
|
|
183
|
+
});
|
|
184
|
+
},
|
|
171
185
|
pullFlowResult(data) {
|
|
172
186
|
notice({
|
|
173
187
|
type:'pullFlowResult',
|
|
@@ -21,8 +21,8 @@ const rtcReportUrl = {
|
|
|
21
21
|
online: 'r.weclassroom.com'
|
|
22
22
|
};
|
|
23
23
|
const sdkVale = {
|
|
24
|
-
zego:
|
|
25
|
-
talrtc: 101,
|
|
24
|
+
zego: 4, //4代表zego采集麦克风+扬声器+拉流声音+外部混音
|
|
25
|
+
talrtc: 101, //101代表talrtc采集声音
|
|
26
26
|
trtc: 102, //102代表trtc采集声音
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -83,7 +83,7 @@ export const deviceCheckerInit = async (extension, env) => {
|
|
|
83
83
|
});
|
|
84
84
|
window.zbyAVSDK_init_sdk_type = 'zego';
|
|
85
85
|
}
|
|
86
|
-
defaultApi.writeLog('change zbyAVSDK_init_sdk_type to
|
|
86
|
+
defaultApi.writeLog('change zbyAVSDK_init_sdk_type to zego , from avsdk device check init');
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
/**
|
|
@@ -1782,6 +1782,21 @@ export const startAudioExCapture = () => {
|
|
|
1782
1782
|
}
|
|
1783
1783
|
};
|
|
1784
1784
|
|
|
1785
|
+
/**
|
|
1786
|
+
* @function 设置授课嘉宾头像流id
|
|
1787
|
+
* @return: Promise
|
|
1788
|
+
*/
|
|
1789
|
+
export const setCustomHeadStreamId = (headStreamID) => {
|
|
1790
|
+
switch (window.zbyAVSDK_init_sdk_type) {
|
|
1791
|
+
case RTC:
|
|
1792
|
+
break;
|
|
1793
|
+
case ZEGO:
|
|
1794
|
+
return zegosdk.setCustomHeadStreamId(headStreamID);
|
|
1795
|
+
default:
|
|
1796
|
+
break;
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1785
1800
|
/**
|
|
1786
1801
|
* @function 开启音频外部采集
|
|
1787
1802
|
* @return: Promise
|
|
@@ -1797,6 +1812,21 @@ export const setAUXAudioType = (type) => {
|
|
|
1797
1812
|
}
|
|
1798
1813
|
};
|
|
1799
1814
|
|
|
1815
|
+
/**
|
|
1816
|
+
* @function 开启音频外部采集
|
|
1817
|
+
* @return: Promise
|
|
1818
|
+
*/
|
|
1819
|
+
export const setThirdAudioType = (type) => {
|
|
1820
|
+
switch (window.zbyAVSDK_init_sdk_type) {
|
|
1821
|
+
case RTC:
|
|
1822
|
+
break;
|
|
1823
|
+
case ZEGO:
|
|
1824
|
+
return zegosdk.setThirdAudioType(type);
|
|
1825
|
+
default:
|
|
1826
|
+
break;
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
|
|
1800
1830
|
/**
|
|
1801
1831
|
* @function 判断推流类型
|
|
1802
1832
|
* @return: Promise
|
|
@@ -1815,7 +1845,17 @@ export const getStreamType_zego = () => {
|
|
|
1815
1845
|
const setThirdAudioCallbackType = (sdkType) => {
|
|
1816
1846
|
let type = sdkVale[sdkType];
|
|
1817
1847
|
return zegosdk.setThirdAudioType(type);
|
|
1818
|
-
}
|
|
1848
|
+
};
|
|
1849
|
+
|
|
1850
|
+
const startMixStreams = (mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId, extraStreamIds=[], coursewareWidth = 1280) => {
|
|
1851
|
+
console.log('zego startmixStreams');
|
|
1852
|
+
return zegosdk.startmixStreams(mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId, extraStreamIds, coursewareWidth);
|
|
1853
|
+
};
|
|
1854
|
+
|
|
1855
|
+
const stopMixtStreams = (mixTaskId, targetUrls) => {
|
|
1856
|
+
console.log('zego stopMixtStreams');
|
|
1857
|
+
return zegosdk.stopMixtStreams(mixTaskId, targetUrls);
|
|
1858
|
+
};
|
|
1819
1859
|
|
|
1820
1860
|
|
|
1821
1861
|
export default {
|
|
@@ -1894,8 +1934,12 @@ export default {
|
|
|
1894
1934
|
startSoundLevelMonitor,
|
|
1895
1935
|
sendMediaSideInfo,
|
|
1896
1936
|
enableHighlight,
|
|
1937
|
+
setCustomHeadStreamId,
|
|
1897
1938
|
setAUXAudioType,
|
|
1939
|
+
setThirdAudioType,
|
|
1898
1940
|
mixedstuVideo,
|
|
1899
|
-
setThirdAudioCallbackType
|
|
1941
|
+
setThirdAudioCallbackType,
|
|
1942
|
+
startMixStreams,
|
|
1943
|
+
stopMixtStreams
|
|
1900
1944
|
// getDeviceState
|
|
1901
1945
|
};
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
**/
|
|
7
7
|
import {dabanDataReport} from '../network/api.js';
|
|
8
8
|
import dataReport from '../network/dataReport.js';
|
|
9
|
+
import { mixStreamsStart,mixStreamsStop } from '../network/api';
|
|
9
10
|
import {
|
|
10
11
|
getS,
|
|
11
12
|
setS,
|
|
@@ -55,6 +56,8 @@ let hasNetWrong = false;
|
|
|
55
56
|
const classType = 0;
|
|
56
57
|
// 监听id
|
|
57
58
|
let EMListenerId = 0;
|
|
59
|
+
// 缓存上层传入的AppId
|
|
60
|
+
let cacheAppId = 0;
|
|
58
61
|
|
|
59
62
|
//静音推流时,音量值是否上抛上层标志 false=没有声音不往上层通知/true=有声音有上层通知
|
|
60
63
|
let isNoticeMicVolumeZego = false;
|
|
@@ -69,6 +72,7 @@ let currStreamIdRtcPlayerInfo ;
|
|
|
69
72
|
|
|
70
73
|
//记录底层推流回调的值
|
|
71
74
|
let dataZegoCapture = {};
|
|
75
|
+
|
|
72
76
|
/**
|
|
73
77
|
* @function 调用端提供的回调方法
|
|
74
78
|
* @param name:String 回调方法名
|
|
@@ -190,7 +194,10 @@ const addListener = (userId, userName, confId, nNetType, devices) => {
|
|
|
190
194
|
afterInitSDK(userId, userName, confId, nNetType, devices);
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
|
-
|
|
197
|
+
break;
|
|
198
|
+
case 'OnMixStreamEx':
|
|
199
|
+
console.log('OnMixStreamEx',data)
|
|
200
|
+
break;
|
|
194
201
|
case 'OnLoginChannel':
|
|
195
202
|
var status = JSON.parse(data).uiErrorCode;
|
|
196
203
|
defaultApi.writeLog(`ZEGO::addListener-- OnLoginChannel: ${status}`);
|
|
@@ -265,6 +272,39 @@ const addListener = (userId, userName, confId, nNetType, devices) => {
|
|
|
265
272
|
}
|
|
266
273
|
}
|
|
267
274
|
break;
|
|
275
|
+
case 'OnStreamEvent':
|
|
276
|
+
{
|
|
277
|
+
let res = JSON.parse(data);
|
|
278
|
+
let keys = Object.keys(res);
|
|
279
|
+
if (keys.indexOf('event') > -1) {
|
|
280
|
+
switch (res.event) {
|
|
281
|
+
case 104:
|
|
282
|
+
try {
|
|
283
|
+
NOTICE.retryPushFlowSuccess({code:0,publish_streamid: _data.pszStreamID});
|
|
284
|
+
} catch (e) {};
|
|
285
|
+
break;
|
|
286
|
+
case 204:
|
|
287
|
+
try {
|
|
288
|
+
NOTICE.retryPullFlowSuccess({code:0,publish_streamid: _data.pszStreamID});
|
|
289
|
+
} catch (e) {};
|
|
290
|
+
break;
|
|
291
|
+
default:
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
// 103开始重试推流, 104重试推流成功,105重试推流失败,203开始重试拉流,204重试拉流成功,205重试拉流失败
|
|
295
|
+
try {
|
|
296
|
+
let ReportArgs = {};
|
|
297
|
+
ReportArgs.streamevent = res.event;
|
|
298
|
+
if(_data.pszStreamID.split('_').length == 5 ){
|
|
299
|
+
ReportArgs.streamid = _data.pszStreamID;
|
|
300
|
+
}
|
|
301
|
+
dataReport.streamEvent({
|
|
302
|
+
code: '0',
|
|
303
|
+
...ReportArgs
|
|
304
|
+
});
|
|
305
|
+
} catch (e) {};
|
|
306
|
+
}
|
|
307
|
+
}
|
|
268
308
|
case 'OnPublishQualityUpdate':
|
|
269
309
|
if (_data.hasOwnProperty('pq') && (_data.pszStreamID).split('_').length != 5) {
|
|
270
310
|
// 主辅两路质量回调,丢包延时只上抛一次,过滤掉辅路数据
|
|
@@ -599,6 +639,7 @@ export const startEngine = (appId, appSignature, businessType) => {
|
|
|
599
639
|
if (typeof businessType === 'undefined') {
|
|
600
640
|
businessType = 0;
|
|
601
641
|
}
|
|
642
|
+
cacheAppId = appId;
|
|
602
643
|
defaultApi.writeLog('avsdk ZEGO::StartEngine');
|
|
603
644
|
return callMethod('StartEngine', {
|
|
604
645
|
appId,
|
|
@@ -745,7 +786,7 @@ export const stopCheckDevice = async() => {
|
|
|
745
786
|
removerListener();
|
|
746
787
|
await stopSoundLevelMonitor();
|
|
747
788
|
await stopPreview();
|
|
748
|
-
defaultApi.writeLog('
|
|
789
|
+
defaultApi.writeLog('zego stopCheckDevice and removerListener and captureDestroy');
|
|
749
790
|
return callMethod('DestroyEngine', {});
|
|
750
791
|
};
|
|
751
792
|
|
|
@@ -1791,11 +1832,14 @@ export const setDefaultDevice = async (devices, operationType) => {
|
|
|
1791
1832
|
*/
|
|
1792
1833
|
export const startPublish2 = async (streamid, idx, title, flag, seq) => {
|
|
1793
1834
|
const streamId = streamid || window.zbyAVSDK_init_params.zego.streamId;
|
|
1835
|
+
if (idx === 1) {
|
|
1836
|
+
await callMethod("StartCapture", { publish_channel: idx });
|
|
1837
|
+
}
|
|
1794
1838
|
if (typeof title === 'undefined') {
|
|
1795
1839
|
title = 'none';
|
|
1796
1840
|
}
|
|
1797
1841
|
if (typeof flag === 'undefined') {
|
|
1798
|
-
flag =
|
|
1842
|
+
flag = 1;
|
|
1799
1843
|
}
|
|
1800
1844
|
if (typeof seq === 'undefined') {
|
|
1801
1845
|
seq = 0;
|
|
@@ -1852,6 +1896,9 @@ export const stopPublish = (idx, msg, flag) => {
|
|
|
1852
1896
|
if (typeof idx === 'undefined') {
|
|
1853
1897
|
idx = 0;
|
|
1854
1898
|
}
|
|
1899
|
+
if (idx === 1) {
|
|
1900
|
+
callMethod('StopCapture',{publish_channel:idx});
|
|
1901
|
+
}
|
|
1855
1902
|
// try {
|
|
1856
1903
|
// dataReport.stopPublish({publish_streamid:window.zbyAVSDK_init_params.zego.streamId});
|
|
1857
1904
|
// } catch (error) {}
|
|
@@ -1962,7 +2009,7 @@ export const playStream = (streamId, uiChnIndex, pInfo) => {
|
|
|
1962
2009
|
export const stopPlayStream = async (streamId, recovery) => {
|
|
1963
2010
|
const id = streamIdToPreviewId[streamId];
|
|
1964
2011
|
delete streamIdRtcPlayerInfo[streamId];
|
|
1965
|
-
if (recovery && id
|
|
2012
|
+
if (recovery && id && !uiChnIndexs.includes(id)) {
|
|
1966
2013
|
uiChnIndexs.push(id);
|
|
1967
2014
|
defaultApi.writeLog(`avsdk ZEGO::stopPlayStream streamId: ${streamId} id: ${id} uiChnIndexs: ${uiChnIndexs}`);
|
|
1968
2015
|
delete streamIdToPreviewId[streamId];
|
|
@@ -1982,7 +2029,7 @@ export const stopAllPlayStream = () => {
|
|
|
1982
2029
|
for (let streamId in streamIdToPreviewId) {
|
|
1983
2030
|
if (streamIdToPreviewId.hasOwnProperty(streamId)) {
|
|
1984
2031
|
const id = streamIdToPreviewId[streamId];
|
|
1985
|
-
if (id
|
|
2032
|
+
if (id && !uiChnIndexs.includes(id)) {
|
|
1986
2033
|
uiChnIndexs.push(id);
|
|
1987
2034
|
toRecoveryArr.push(callMethod('StopPlayStream', {
|
|
1988
2035
|
pszStreamID: streamId
|
|
@@ -2069,6 +2116,237 @@ export const mixStream = (type, args, seq) => {
|
|
|
2069
2116
|
|
|
2070
2117
|
};
|
|
2071
2118
|
|
|
2119
|
+
/**
|
|
2120
|
+
* @function 切换播放流
|
|
2121
|
+
* @param mixTaskId:String 任务ID,混流任务唯一标识 必选
|
|
2122
|
+
* @param mixType:Int 0-web, 1-record, 2-Chat, 3-H5 必选
|
|
2123
|
+
* @param srcStreamIds:Array 课件+老师头像流ID ['stream_1','stream_2'] 必选
|
|
2124
|
+
* @param extraStreamIds:Array 非(课件+老师头像流)流ID [{contentControl:2,streamId:'stream_1',left:10,top:10,right:170,bottom:100},{contentControl:0,streamId:'stream_2',left:10,top:110,right:170,bottom:200}]
|
|
2125
|
+
* @param targetRtcStreamId:String 混流输出流ID,必选
|
|
2126
|
+
* @param targetUrls:Array 转推RTMP流地址,必选
|
|
2127
|
+
* @param backgroundImageId:Int 0默认,1上台,2关闭摄像头,3嘉宾未签到,4嘉宾离线
|
|
2128
|
+
* @param coursewareWidth: Int 课件区真实宽
|
|
2129
|
+
* @return Promise | void
|
|
2130
|
+
*/
|
|
2131
|
+
export const startmixStreams = async (mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId = 0, extraStreamIds=[], coursewareWidth = 1280) => {
|
|
2132
|
+
let srcStreamInfos = [];
|
|
2133
|
+
let bkImage='preset-id://'+cacheAppId+'_live_closeCamera.png';
|
|
2134
|
+
defaultApi.writeLog(`avsdk ZEGO::startmixStreams default bkImage: ${bkImage}`);
|
|
2135
|
+
if (mixType === 0 || mixType === 1) {
|
|
2136
|
+
for (let i = 0, len = srcStreamIds.length; i < len; i++) {
|
|
2137
|
+
if (srcStreamIds[i].contentControl === 1) {
|
|
2138
|
+
srcStreamInfos.push({
|
|
2139
|
+
streamId: srcStreamIds[i].streamId,
|
|
2140
|
+
left: null,
|
|
2141
|
+
top: null,
|
|
2142
|
+
right: null,
|
|
2143
|
+
bottom: null,
|
|
2144
|
+
contentControl: srcStreamIds[i].contentControl
|
|
2145
|
+
});
|
|
2146
|
+
} else {
|
|
2147
|
+
if (i === 0) {
|
|
2148
|
+
srcStreamInfos.push({
|
|
2149
|
+
streamId: srcStreamIds[i].streamId,
|
|
2150
|
+
left: 0,
|
|
2151
|
+
top: 0,
|
|
2152
|
+
right: 1280,
|
|
2153
|
+
bottom: 720,
|
|
2154
|
+
contentControl: srcStreamIds[i].contentControl
|
|
2155
|
+
});
|
|
2156
|
+
} else if (i === 1) {
|
|
2157
|
+
srcStreamInfos.push({
|
|
2158
|
+
streamId: srcStreamIds[i].streamId,
|
|
2159
|
+
left: 1344,
|
|
2160
|
+
top: 0,
|
|
2161
|
+
right: 1536,
|
|
2162
|
+
bottom: 144,
|
|
2163
|
+
contentControl: srcStreamIds[i].contentControl
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
let srcStreamInfos2 = [];
|
|
2170
|
+
Object.assign(srcStreamInfos2, extraStreamIds);
|
|
2171
|
+
if(srcStreamInfos2.length > 0) {
|
|
2172
|
+
let factor = 1280 / coursewareWidth;
|
|
2173
|
+
srcStreamInfos2.forEach( item => {
|
|
2174
|
+
item.left = parseInt(item.left * factor);
|
|
2175
|
+
item.top = parseInt(item.top * factor);
|
|
2176
|
+
item.right = parseInt(item.right * factor);
|
|
2177
|
+
item.bottom = parseInt(item.bottom * factor);
|
|
2178
|
+
if (((item.right - item.left) % 2) != 0) {
|
|
2179
|
+
item.right = item.right - 1;
|
|
2180
|
+
}
|
|
2181
|
+
if (((item.bottom - item.top) % 2) != 0) {
|
|
2182
|
+
item.bottom = item.bottom - 1;
|
|
2183
|
+
}
|
|
2184
|
+
});
|
|
2185
|
+
|
|
2186
|
+
srcStreamInfos = srcStreamInfos.concat(srcStreamInfos2);
|
|
2187
|
+
|
|
2188
|
+
defaultApi.writeLog(`srcStreamInfos---------- params:${JSON.stringify(srcStreamInfos)}`);
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
switch (backgroundImageId) {
|
|
2192
|
+
case 0:
|
|
2193
|
+
break;
|
|
2194
|
+
case 1:
|
|
2195
|
+
bkImage = 'preset-id://'+cacheAppId+'_live_TeacherOnStage.png';
|
|
2196
|
+
break;
|
|
2197
|
+
case 2:
|
|
2198
|
+
bkImage = 'preset-id://'+cacheAppId+'_live_closeCamera.png';
|
|
2199
|
+
break;
|
|
2200
|
+
case 3:
|
|
2201
|
+
bkImage = 'preset-id://'+cacheAppId+'_live_2022112202.png';
|
|
2202
|
+
break;
|
|
2203
|
+
case 4:
|
|
2204
|
+
bkImage = 'preset-id://'+cacheAppId+'_live_2022112201.png';
|
|
2205
|
+
break;
|
|
2206
|
+
case 5:
|
|
2207
|
+
bkImage = 'preset-id://'+cacheAppId+'_live_167210592069086983.png';
|
|
2208
|
+
break;
|
|
2209
|
+
default:
|
|
2210
|
+
break;
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
const zego = window.zbyAVSDK_init_params.zego;
|
|
2215
|
+
let param = {
|
|
2216
|
+
institutionId: window.zby_sdk_init_params.institutionId,
|
|
2217
|
+
taskId: mixTaskId,
|
|
2218
|
+
userId: zego.userId,
|
|
2219
|
+
streamInfos: srcStreamInfos,
|
|
2220
|
+
rtcStreamId: targetRtcStreamId,
|
|
2221
|
+
pushUrls: targetUrls, //数组
|
|
2222
|
+
backgroundImage: bkImage,
|
|
2223
|
+
streamOutPut:{width:1600,height:720,videoBitrate:1500000,fps:20}
|
|
2224
|
+
};
|
|
2225
|
+
|
|
2226
|
+
defaultApi.writeLog(`startMixStreams params:${JSON.stringify(param)}`);
|
|
2227
|
+
|
|
2228
|
+
let res = await mixStreamsStart(param);
|
|
2229
|
+
if (res.code == 0) {
|
|
2230
|
+
console.log('混流成功:', JSON.stringify(res));
|
|
2231
|
+
} else {
|
|
2232
|
+
console.log('混流失败:', JSON.stringify(res));
|
|
2233
|
+
}
|
|
2234
|
+
// else {
|
|
2235
|
+
// console.log('startmixStream local start……');
|
|
2236
|
+
// return callMethod('MixStreamEx', {
|
|
2237
|
+
// mixstreamid: mixTaskId,
|
|
2238
|
+
// config: {
|
|
2239
|
+
// nOutputFps: 15,
|
|
2240
|
+
// nOutputBitrate: 512000,
|
|
2241
|
+
// nOutputAudioBitrate: 48000,
|
|
2242
|
+
// nOutputWidth: 1200,
|
|
2243
|
+
// nOutputHeight: 540,
|
|
2244
|
+
// nOutputAudioConfig: 0,
|
|
2245
|
+
// pUserData: '',
|
|
2246
|
+
// nLenOfUserData: 0,
|
|
2247
|
+
// pInputStreamList: [
|
|
2248
|
+
// {
|
|
2249
|
+
// szStreamID: streamIdList[1],//截屏窗
|
|
2250
|
+
// layout: { left: 0, top: 0, right: 960, bottom: 540 },
|
|
2251
|
+
// uSoundLevelID: 1234,
|
|
2252
|
+
// nContentControl: 0,
|
|
2253
|
+
// nVolume: 100,
|
|
2254
|
+
// bAudioFocus: false,
|
|
2255
|
+
// nAudioDirection: -1,
|
|
2256
|
+
// renderMode: 0
|
|
2257
|
+
// },
|
|
2258
|
+
// {
|
|
2259
|
+
// szStreamID: streamIdList[0],//头像
|
|
2260
|
+
// layout: { left: 1008, top: 0, right: 1152, bottom: 108 },
|
|
2261
|
+
// uSoundLevelID: 3232,
|
|
2262
|
+
// nContentControl: 0,
|
|
2263
|
+
// nVolume: 100,
|
|
2264
|
+
// bAudioFocus: false,
|
|
2265
|
+
// nAudioDirection: -1,
|
|
2266
|
+
// renderMode: 0
|
|
2267
|
+
// }
|
|
2268
|
+
// ],
|
|
2269
|
+
// nInputStreamCount: 2,
|
|
2270
|
+
// pOutputList: [
|
|
2271
|
+
// {
|
|
2272
|
+
// isUrl: true, // 输出是否为流名或URL
|
|
2273
|
+
// target: targetUrls[0], //isUrl=ture完整的RTMP URL,false是流名
|
|
2274
|
+
// videoCodec: 0,
|
|
2275
|
+
// videoBitrate: 0,
|
|
2276
|
+
// encodeProfile: 1,
|
|
2277
|
+
// encodeLatency: 0
|
|
2278
|
+
// }
|
|
2279
|
+
// // {
|
|
2280
|
+
// // isUrl: false,
|
|
2281
|
+
// // target: "streamId",
|
|
2282
|
+
// // videoCodec: 0,
|
|
2283
|
+
// // videoBitrate: 0,
|
|
2284
|
+
// // encodeProfile: 1,
|
|
2285
|
+
// // encodeLatency: 0
|
|
2286
|
+
// // }
|
|
2287
|
+
// ],
|
|
2288
|
+
// nOutputStreamCount: 1,
|
|
2289
|
+
// pOutputBackgroundImage: bkImage,
|
|
2290
|
+
// }
|
|
2291
|
+
// });
|
|
2292
|
+
// }
|
|
2293
|
+
|
|
2294
|
+
return res;
|
|
2295
|
+
};
|
|
2296
|
+
|
|
2297
|
+
export const stopMixtStreams = async (mixTaskId, targetUrls) => {
|
|
2298
|
+
const zego = window.zbyAVSDK_init_params.zego;
|
|
2299
|
+
let param = {
|
|
2300
|
+
taskId: mixTaskId,
|
|
2301
|
+
userId: zego.userId
|
|
2302
|
+
};
|
|
2303
|
+
let res = await mixStreamsStop(param);
|
|
2304
|
+
if (res.code == 0) {
|
|
2305
|
+
console.log('停止混流成功:', JSON.stringify(res));
|
|
2306
|
+
} else {
|
|
2307
|
+
console.log('停止混流失败:', JSON.stringify(res));
|
|
2308
|
+
}
|
|
2309
|
+
// else {
|
|
2310
|
+
// return callMethod('MixStreamEx', {
|
|
2311
|
+
// mixstreamid: mixTaskId,
|
|
2312
|
+
// config: {
|
|
2313
|
+
// nOutputFps: 15,
|
|
2314
|
+
// nOutputBitrate: 512000,
|
|
2315
|
+
// nOutputAudioBitrate: 48000,
|
|
2316
|
+
// nOutputWidth: 1280,
|
|
2317
|
+
// nOutputHeight: 720,
|
|
2318
|
+
// nOutputAudioConfig: 0,
|
|
2319
|
+
// pUserData: '',
|
|
2320
|
+
// nLenOfUserData: 0,
|
|
2321
|
+
// pInputStreamList: [],
|
|
2322
|
+
// nInputStreamCount: 2,
|
|
2323
|
+
// pOutputList: [
|
|
2324
|
+
// {
|
|
2325
|
+
// isUrl: true, // 输出是否为流名或URL
|
|
2326
|
+
// target: targetUrls[0], //isUrl=ture完整的RTMP URL,false是流名
|
|
2327
|
+
// videoCodec: 0,
|
|
2328
|
+
// videoBitrate: 0,
|
|
2329
|
+
// encodeProfile: 1,
|
|
2330
|
+
// encodeLatency: 0
|
|
2331
|
+
// }
|
|
2332
|
+
// // {
|
|
2333
|
+
// // isUrl: false,
|
|
2334
|
+
// // target: "streamId",
|
|
2335
|
+
// // videoCodec: 0,
|
|
2336
|
+
// // videoBitrate: 0,
|
|
2337
|
+
// // encodeProfile: 1,
|
|
2338
|
+
// // encodeLatency: 0
|
|
2339
|
+
// // }
|
|
2340
|
+
// ],
|
|
2341
|
+
// nOutputStreamCount: 1,
|
|
2342
|
+
// pOutputBackgroundImage: '',
|
|
2343
|
+
// }
|
|
2344
|
+
// });
|
|
2345
|
+
// }
|
|
2346
|
+
return res;
|
|
2347
|
+
};
|
|
2348
|
+
|
|
2349
|
+
|
|
2072
2350
|
/**
|
|
2073
2351
|
* @function 是否拉取音频流--通过流id控制
|
|
2074
2352
|
* @param streamId:String 被拉取的流的 id,必选
|
|
@@ -2410,7 +2688,15 @@ const setAudioAuxSource = (source) => {
|
|
|
2410
2688
|
});
|
|
2411
2689
|
}
|
|
2412
2690
|
|
|
2413
|
-
|
|
2691
|
+
//设置嘉宾头像流id,headStreamID 空字符串代表无嘉宾
|
|
2692
|
+
const setCustomHeadStreamId = (headStreamID) => {
|
|
2693
|
+
defaultApi.writeLog('info', 'avsdk ZEGO::setCustomHeadStreamId');
|
|
2694
|
+
return callMethod('SetCustomHeadStreamId', {
|
|
2695
|
+
headStreamID
|
|
2696
|
+
});
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
//RTC同屏 辅助通道音频类型 0:静音 / 1:麦克风 / 2:拉流的声音 / 3:1+2 / 4:麦克风+扬声器+外部混音 /:8麦克风+扬声器(含拉流,没有外部混音) /:16扬声器(音乐)(没有拉流,没有外部混音没有调用,没有麦克风)
|
|
2414
2700
|
const setAUXAudioType = (type) => {
|
|
2415
2701
|
defaultApi.writeLog('info', 'avsdk ZEGO::SetAUXAudioType');
|
|
2416
2702
|
return callMethod('SetAUXAudioType', {
|
|
@@ -2986,11 +3272,14 @@ export default {
|
|
|
2986
3272
|
getAllChannelIndex,
|
|
2987
3273
|
startAudioExCapture,
|
|
2988
3274
|
sendMediaSideInfo,
|
|
3275
|
+
setCustomHeadStreamId,
|
|
2989
3276
|
setAUXAudioType,
|
|
2990
3277
|
loadCollectionInputEntry2,
|
|
2991
3278
|
addListener,
|
|
2992
3279
|
stopCheckDevice,
|
|
2993
3280
|
getDeviceCheckInitStatus,
|
|
2994
3281
|
setDeviceCheckInitStatus,
|
|
2995
|
-
setThirdAudioType
|
|
3282
|
+
setThirdAudioType,
|
|
3283
|
+
startmixStreams,
|
|
3284
|
+
stopMixtStreams
|
|
2996
3285
|
};
|
package/src/zby-live-sdk.js
CHANGED
|
@@ -282,6 +282,10 @@ const zbysdk = {
|
|
|
282
282
|
|
|
283
283
|
// 结束设备检测
|
|
284
284
|
stopCheckDevice() {
|
|
285
|
+
if (deviceCheckerInitStatus === -1) {
|
|
286
|
+
defaultApi.writeLog('please start check device first');
|
|
287
|
+
return 'please start check device first';
|
|
288
|
+
}
|
|
285
289
|
deviceCheckerInitStatus = -1;
|
|
286
290
|
defaultApi.writeLog('sdk stop check device');
|
|
287
291
|
return zbyAVSDK.stopCheckDevice();
|
|
@@ -1508,18 +1512,40 @@ const zbysdk = {
|
|
|
1508
1512
|
return zbyAVSDK.startAudioExCapture();
|
|
1509
1513
|
},
|
|
1510
1514
|
|
|
1515
|
+
//设置授课嘉宾头像流id
|
|
1516
|
+
setCustomHeadStreamId (headStreamID) {
|
|
1517
|
+
defaultApi.writeLog(`sdk action: setCustomHeadStreamId headStreamID:${headStreamID}`);
|
|
1518
|
+
return zbyAVSDK.setCustomHeadStreamId(headStreamID);
|
|
1519
|
+
},
|
|
1520
|
+
|
|
1511
1521
|
//RTC同屏 辅助通道音频类型
|
|
1512
1522
|
setAUXAudioType(type) {
|
|
1513
|
-
defaultApi.writeLog(
|
|
1523
|
+
defaultApi.writeLog(`sdk action: setAUXAudioType type:${type}`);
|
|
1514
1524
|
return zbyAVSDK.setAUXAudioType(type);
|
|
1515
1525
|
},
|
|
1516
1526
|
|
|
1527
|
+
//RTC同屏 辅助通道音频类型
|
|
1528
|
+
setThirdAudioType(type) {
|
|
1529
|
+
defaultApi.writeLog(`sdk action: setThirdAudioType type:${type}`);
|
|
1530
|
+
return zbyAVSDK.setThirdAudioType(type);
|
|
1531
|
+
},
|
|
1532
|
+
|
|
1517
1533
|
//发送sei
|
|
1518
1534
|
sendMediaSideInfo(info) {
|
|
1519
1535
|
defaultApi.writeLog('sdk action: sendMediaSideInfo');
|
|
1520
1536
|
return zbyAVSDK.sendMediaSideInfo(info);
|
|
1521
1537
|
},
|
|
1522
1538
|
|
|
1539
|
+
startMixStreams(mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId=0, extraStreamIds=[], coursewareWidth = 1280) {
|
|
1540
|
+
defaultApi.writeLog(`sdk action: startMixStreams mixTaskId:${mixTaskId} mixType:${mixType} srcStreamIds:${JSON.stringify(srcStreamIds)} targetRtcStreamId:${targetRtcStreamId} targetUrls:${JSON.stringify(targetUrls)} backgroundImageId:${backgroundImageId} extraStreamIds:${JSON.stringify(extraStreamIds)} coursewareWidth:${coursewareWidth}`);
|
|
1541
|
+
return zbyAVSDK.startMixStreams(mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId, extraStreamIds, coursewareWidth);
|
|
1542
|
+
},
|
|
1543
|
+
|
|
1544
|
+
stopMixtStreams(mixTaskId, targetUrls) {
|
|
1545
|
+
defaultApi.writeLog(`sdk action: stopMixtStreams mixTaskId:${mixTaskId} targetUrls:${targetUrls}`);
|
|
1546
|
+
return zbyAVSDK.stopMixtStreams(mixTaskId, targetUrls);
|
|
1547
|
+
},
|
|
1548
|
+
|
|
1523
1549
|
/**
|
|
1524
1550
|
* @function 切换sdk类型
|
|
1525
1551
|
* @return: Promise
|