zby-live-sdk 1.0.49-beta20221223 → 1.0.49-beta20230302
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 +102 -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/zby-av-sdk/zby-av-sdk.js +49 -5
- package/src/zby-av-sdk/zego-sdk.js +263 -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-beta20230302';
|
|
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
|
+
}
|
|
@@ -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}`);
|
|
@@ -599,6 +606,7 @@ export const startEngine = (appId, appSignature, businessType) => {
|
|
|
599
606
|
if (typeof businessType === 'undefined') {
|
|
600
607
|
businessType = 0;
|
|
601
608
|
}
|
|
609
|
+
cacheAppId = appId;
|
|
602
610
|
defaultApi.writeLog('avsdk ZEGO::StartEngine');
|
|
603
611
|
return callMethod('StartEngine', {
|
|
604
612
|
appId,
|
|
@@ -745,7 +753,7 @@ export const stopCheckDevice = async() => {
|
|
|
745
753
|
removerListener();
|
|
746
754
|
await stopSoundLevelMonitor();
|
|
747
755
|
await stopPreview();
|
|
748
|
-
defaultApi.writeLog('
|
|
756
|
+
defaultApi.writeLog('zego stopCheckDevice and removerListener and captureDestroy');
|
|
749
757
|
return callMethod('DestroyEngine', {});
|
|
750
758
|
};
|
|
751
759
|
|
|
@@ -1791,11 +1799,14 @@ export const setDefaultDevice = async (devices, operationType) => {
|
|
|
1791
1799
|
*/
|
|
1792
1800
|
export const startPublish2 = async (streamid, idx, title, flag, seq) => {
|
|
1793
1801
|
const streamId = streamid || window.zbyAVSDK_init_params.zego.streamId;
|
|
1802
|
+
if (idx === 1) {
|
|
1803
|
+
await callMethod("StartCapture", { publish_channel: idx });
|
|
1804
|
+
}
|
|
1794
1805
|
if (typeof title === 'undefined') {
|
|
1795
1806
|
title = 'none';
|
|
1796
1807
|
}
|
|
1797
1808
|
if (typeof flag === 'undefined') {
|
|
1798
|
-
flag =
|
|
1809
|
+
flag = 1;
|
|
1799
1810
|
}
|
|
1800
1811
|
if (typeof seq === 'undefined') {
|
|
1801
1812
|
seq = 0;
|
|
@@ -1852,6 +1863,9 @@ export const stopPublish = (idx, msg, flag) => {
|
|
|
1852
1863
|
if (typeof idx === 'undefined') {
|
|
1853
1864
|
idx = 0;
|
|
1854
1865
|
}
|
|
1866
|
+
if (idx === 1) {
|
|
1867
|
+
callMethod('StopCapture',{publish_channel:idx});
|
|
1868
|
+
}
|
|
1855
1869
|
// try {
|
|
1856
1870
|
// dataReport.stopPublish({publish_streamid:window.zbyAVSDK_init_params.zego.streamId});
|
|
1857
1871
|
// } catch (error) {}
|
|
@@ -1962,7 +1976,7 @@ export const playStream = (streamId, uiChnIndex, pInfo) => {
|
|
|
1962
1976
|
export const stopPlayStream = async (streamId, recovery) => {
|
|
1963
1977
|
const id = streamIdToPreviewId[streamId];
|
|
1964
1978
|
delete streamIdRtcPlayerInfo[streamId];
|
|
1965
|
-
if (recovery && id
|
|
1979
|
+
if (recovery && id && !uiChnIndexs.includes(id)) {
|
|
1966
1980
|
uiChnIndexs.push(id);
|
|
1967
1981
|
defaultApi.writeLog(`avsdk ZEGO::stopPlayStream streamId: ${streamId} id: ${id} uiChnIndexs: ${uiChnIndexs}`);
|
|
1968
1982
|
delete streamIdToPreviewId[streamId];
|
|
@@ -1982,7 +1996,7 @@ export const stopAllPlayStream = () => {
|
|
|
1982
1996
|
for (let streamId in streamIdToPreviewId) {
|
|
1983
1997
|
if (streamIdToPreviewId.hasOwnProperty(streamId)) {
|
|
1984
1998
|
const id = streamIdToPreviewId[streamId];
|
|
1985
|
-
if (id
|
|
1999
|
+
if (id && !uiChnIndexs.includes(id)) {
|
|
1986
2000
|
uiChnIndexs.push(id);
|
|
1987
2001
|
toRecoveryArr.push(callMethod('StopPlayStream', {
|
|
1988
2002
|
pszStreamID: streamId
|
|
@@ -2069,6 +2083,237 @@ export const mixStream = (type, args, seq) => {
|
|
|
2069
2083
|
|
|
2070
2084
|
};
|
|
2071
2085
|
|
|
2086
|
+
/**
|
|
2087
|
+
* @function 切换播放流
|
|
2088
|
+
* @param mixTaskId:String 任务ID,混流任务唯一标识 必选
|
|
2089
|
+
* @param mixType:Int 0-web, 1-record, 2-Chat, 3-H5 必选
|
|
2090
|
+
* @param srcStreamIds:Array 课件+老师头像流ID ['stream_1','stream_2'] 必选
|
|
2091
|
+
* @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}]
|
|
2092
|
+
* @param targetRtcStreamId:String 混流输出流ID,必选
|
|
2093
|
+
* @param targetUrls:Array 转推RTMP流地址,必选
|
|
2094
|
+
* @param backgroundImageId:Int 0默认,1上台,2关闭摄像头,3嘉宾未签到,4嘉宾离线
|
|
2095
|
+
* @param coursewareWidth: Int 课件区真实宽
|
|
2096
|
+
* @return Promise | void
|
|
2097
|
+
*/
|
|
2098
|
+
export const startmixStreams = async (mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId = 0, extraStreamIds=[], coursewareWidth = 1280) => {
|
|
2099
|
+
let srcStreamInfos = [];
|
|
2100
|
+
let bkImage='preset-id://'+cacheAppId+'_live_closeCamera.png';
|
|
2101
|
+
defaultApi.writeLog(`avsdk ZEGO::startmixStreams default bkImage: ${bkImage}`);
|
|
2102
|
+
if (mixType === 0 || mixType === 1) {
|
|
2103
|
+
for (let i = 0, len = srcStreamIds.length; i < len; i++) {
|
|
2104
|
+
if (srcStreamIds[i].contentControl === 1) {
|
|
2105
|
+
srcStreamInfos.push({
|
|
2106
|
+
streamId: srcStreamIds[i].streamId,
|
|
2107
|
+
left: null,
|
|
2108
|
+
top: null,
|
|
2109
|
+
right: null,
|
|
2110
|
+
bottom: null,
|
|
2111
|
+
contentControl: srcStreamIds[i].contentControl
|
|
2112
|
+
});
|
|
2113
|
+
} else {
|
|
2114
|
+
if (i === 0) {
|
|
2115
|
+
srcStreamInfos.push({
|
|
2116
|
+
streamId: srcStreamIds[i].streamId,
|
|
2117
|
+
left: 0,
|
|
2118
|
+
top: 0,
|
|
2119
|
+
right: 1280,
|
|
2120
|
+
bottom: 720,
|
|
2121
|
+
contentControl: srcStreamIds[i].contentControl
|
|
2122
|
+
});
|
|
2123
|
+
} else if (i === 1) {
|
|
2124
|
+
srcStreamInfos.push({
|
|
2125
|
+
streamId: srcStreamIds[i].streamId,
|
|
2126
|
+
left: 1344,
|
|
2127
|
+
top: 0,
|
|
2128
|
+
right: 1536,
|
|
2129
|
+
bottom: 144,
|
|
2130
|
+
contentControl: srcStreamIds[i].contentControl
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
let srcStreamInfos2 = [];
|
|
2137
|
+
Object.assign(srcStreamInfos2, extraStreamIds);
|
|
2138
|
+
if(srcStreamInfos2.length > 0) {
|
|
2139
|
+
let factor = 1280 / coursewareWidth;
|
|
2140
|
+
srcStreamInfos2.forEach( item => {
|
|
2141
|
+
item.left = parseInt(item.left * factor);
|
|
2142
|
+
item.top = parseInt(item.top * factor);
|
|
2143
|
+
item.right = parseInt(item.right * factor);
|
|
2144
|
+
item.bottom = parseInt(item.bottom * factor);
|
|
2145
|
+
if (((item.right - item.left) % 2) != 0) {
|
|
2146
|
+
item.right = item.right - 1;
|
|
2147
|
+
}
|
|
2148
|
+
if (((item.bottom - item.top) % 2) != 0) {
|
|
2149
|
+
item.bottom = item.bottom - 1;
|
|
2150
|
+
}
|
|
2151
|
+
});
|
|
2152
|
+
|
|
2153
|
+
srcStreamInfos = srcStreamInfos.concat(srcStreamInfos2);
|
|
2154
|
+
|
|
2155
|
+
defaultApi.writeLog(`srcStreamInfos---------- params:${JSON.stringify(srcStreamInfos)}`);
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
switch (backgroundImageId) {
|
|
2159
|
+
case 0:
|
|
2160
|
+
break;
|
|
2161
|
+
case 1:
|
|
2162
|
+
bkImage = 'preset-id://'+cacheAppId+'_live_TeacherOnStage.png';
|
|
2163
|
+
break;
|
|
2164
|
+
case 2:
|
|
2165
|
+
bkImage = 'preset-id://'+cacheAppId+'_live_closeCamera.png';
|
|
2166
|
+
break;
|
|
2167
|
+
case 3:
|
|
2168
|
+
bkImage = 'preset-id://'+cacheAppId+'_live_2022112202.png';
|
|
2169
|
+
break;
|
|
2170
|
+
case 4:
|
|
2171
|
+
bkImage = 'preset-id://'+cacheAppId+'_live_2022112201.png';
|
|
2172
|
+
break;
|
|
2173
|
+
case 5:
|
|
2174
|
+
bkImage = 'preset-id://'+cacheAppId+'_live_167210592069086983.png';
|
|
2175
|
+
break;
|
|
2176
|
+
default:
|
|
2177
|
+
break;
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
const zego = window.zbyAVSDK_init_params.zego;
|
|
2182
|
+
let param = {
|
|
2183
|
+
institutionId: window.zby_sdk_init_params.institutionId,
|
|
2184
|
+
taskId: mixTaskId,
|
|
2185
|
+
userId: zego.userId,
|
|
2186
|
+
streamInfos: srcStreamInfos,
|
|
2187
|
+
rtcStreamId: targetRtcStreamId,
|
|
2188
|
+
pushUrls: targetUrls, //数组
|
|
2189
|
+
backgroundImage: bkImage,
|
|
2190
|
+
streamOutPut:{width:1600,height:720,videoBitrate:1500000,fps:20}
|
|
2191
|
+
};
|
|
2192
|
+
|
|
2193
|
+
defaultApi.writeLog(`startMixStreams params:${JSON.stringify(param)}`);
|
|
2194
|
+
|
|
2195
|
+
let res = await mixStreamsStart(param);
|
|
2196
|
+
if (res.code == 0) {
|
|
2197
|
+
console.log('混流成功:', JSON.stringify(res));
|
|
2198
|
+
} else {
|
|
2199
|
+
console.log('混流失败:', JSON.stringify(res));
|
|
2200
|
+
}
|
|
2201
|
+
// else {
|
|
2202
|
+
// console.log('startmixStream local start……');
|
|
2203
|
+
// return callMethod('MixStreamEx', {
|
|
2204
|
+
// mixstreamid: mixTaskId,
|
|
2205
|
+
// config: {
|
|
2206
|
+
// nOutputFps: 15,
|
|
2207
|
+
// nOutputBitrate: 512000,
|
|
2208
|
+
// nOutputAudioBitrate: 48000,
|
|
2209
|
+
// nOutputWidth: 1200,
|
|
2210
|
+
// nOutputHeight: 540,
|
|
2211
|
+
// nOutputAudioConfig: 0,
|
|
2212
|
+
// pUserData: '',
|
|
2213
|
+
// nLenOfUserData: 0,
|
|
2214
|
+
// pInputStreamList: [
|
|
2215
|
+
// {
|
|
2216
|
+
// szStreamID: streamIdList[1],//截屏窗
|
|
2217
|
+
// layout: { left: 0, top: 0, right: 960, bottom: 540 },
|
|
2218
|
+
// uSoundLevelID: 1234,
|
|
2219
|
+
// nContentControl: 0,
|
|
2220
|
+
// nVolume: 100,
|
|
2221
|
+
// bAudioFocus: false,
|
|
2222
|
+
// nAudioDirection: -1,
|
|
2223
|
+
// renderMode: 0
|
|
2224
|
+
// },
|
|
2225
|
+
// {
|
|
2226
|
+
// szStreamID: streamIdList[0],//头像
|
|
2227
|
+
// layout: { left: 1008, top: 0, right: 1152, bottom: 108 },
|
|
2228
|
+
// uSoundLevelID: 3232,
|
|
2229
|
+
// nContentControl: 0,
|
|
2230
|
+
// nVolume: 100,
|
|
2231
|
+
// bAudioFocus: false,
|
|
2232
|
+
// nAudioDirection: -1,
|
|
2233
|
+
// renderMode: 0
|
|
2234
|
+
// }
|
|
2235
|
+
// ],
|
|
2236
|
+
// nInputStreamCount: 2,
|
|
2237
|
+
// pOutputList: [
|
|
2238
|
+
// {
|
|
2239
|
+
// isUrl: true, // 输出是否为流名或URL
|
|
2240
|
+
// target: targetUrls[0], //isUrl=ture完整的RTMP URL,false是流名
|
|
2241
|
+
// videoCodec: 0,
|
|
2242
|
+
// videoBitrate: 0,
|
|
2243
|
+
// encodeProfile: 1,
|
|
2244
|
+
// encodeLatency: 0
|
|
2245
|
+
// }
|
|
2246
|
+
// // {
|
|
2247
|
+
// // isUrl: false,
|
|
2248
|
+
// // target: "streamId",
|
|
2249
|
+
// // videoCodec: 0,
|
|
2250
|
+
// // videoBitrate: 0,
|
|
2251
|
+
// // encodeProfile: 1,
|
|
2252
|
+
// // encodeLatency: 0
|
|
2253
|
+
// // }
|
|
2254
|
+
// ],
|
|
2255
|
+
// nOutputStreamCount: 1,
|
|
2256
|
+
// pOutputBackgroundImage: bkImage,
|
|
2257
|
+
// }
|
|
2258
|
+
// });
|
|
2259
|
+
// }
|
|
2260
|
+
|
|
2261
|
+
return res;
|
|
2262
|
+
};
|
|
2263
|
+
|
|
2264
|
+
export const stopMixtStreams = async (mixTaskId, targetUrls) => {
|
|
2265
|
+
const zego = window.zbyAVSDK_init_params.zego;
|
|
2266
|
+
let param = {
|
|
2267
|
+
taskId: mixTaskId,
|
|
2268
|
+
userId: zego.userId
|
|
2269
|
+
};
|
|
2270
|
+
let res = await mixStreamsStop(param);
|
|
2271
|
+
if (res.code == 0) {
|
|
2272
|
+
console.log('停止混流成功:', JSON.stringify(res));
|
|
2273
|
+
} else {
|
|
2274
|
+
console.log('停止混流失败:', JSON.stringify(res));
|
|
2275
|
+
}
|
|
2276
|
+
// else {
|
|
2277
|
+
// return callMethod('MixStreamEx', {
|
|
2278
|
+
// mixstreamid: mixTaskId,
|
|
2279
|
+
// config: {
|
|
2280
|
+
// nOutputFps: 15,
|
|
2281
|
+
// nOutputBitrate: 512000,
|
|
2282
|
+
// nOutputAudioBitrate: 48000,
|
|
2283
|
+
// nOutputWidth: 1280,
|
|
2284
|
+
// nOutputHeight: 720,
|
|
2285
|
+
// nOutputAudioConfig: 0,
|
|
2286
|
+
// pUserData: '',
|
|
2287
|
+
// nLenOfUserData: 0,
|
|
2288
|
+
// pInputStreamList: [],
|
|
2289
|
+
// nInputStreamCount: 2,
|
|
2290
|
+
// pOutputList: [
|
|
2291
|
+
// {
|
|
2292
|
+
// isUrl: true, // 输出是否为流名或URL
|
|
2293
|
+
// target: targetUrls[0], //isUrl=ture完整的RTMP URL,false是流名
|
|
2294
|
+
// videoCodec: 0,
|
|
2295
|
+
// videoBitrate: 0,
|
|
2296
|
+
// encodeProfile: 1,
|
|
2297
|
+
// encodeLatency: 0
|
|
2298
|
+
// }
|
|
2299
|
+
// // {
|
|
2300
|
+
// // isUrl: false,
|
|
2301
|
+
// // target: "streamId",
|
|
2302
|
+
// // videoCodec: 0,
|
|
2303
|
+
// // videoBitrate: 0,
|
|
2304
|
+
// // encodeProfile: 1,
|
|
2305
|
+
// // encodeLatency: 0
|
|
2306
|
+
// // }
|
|
2307
|
+
// ],
|
|
2308
|
+
// nOutputStreamCount: 1,
|
|
2309
|
+
// pOutputBackgroundImage: '',
|
|
2310
|
+
// }
|
|
2311
|
+
// });
|
|
2312
|
+
// }
|
|
2313
|
+
return res;
|
|
2314
|
+
};
|
|
2315
|
+
|
|
2316
|
+
|
|
2072
2317
|
/**
|
|
2073
2318
|
* @function 是否拉取音频流--通过流id控制
|
|
2074
2319
|
* @param streamId:String 被拉取的流的 id,必选
|
|
@@ -2410,7 +2655,15 @@ const setAudioAuxSource = (source) => {
|
|
|
2410
2655
|
});
|
|
2411
2656
|
}
|
|
2412
2657
|
|
|
2413
|
-
|
|
2658
|
+
//设置嘉宾头像流id,headStreamID 空字符串代表无嘉宾
|
|
2659
|
+
const setCustomHeadStreamId = (headStreamID) => {
|
|
2660
|
+
defaultApi.writeLog('info', 'avsdk ZEGO::setCustomHeadStreamId');
|
|
2661
|
+
return callMethod('SetCustomHeadStreamId', {
|
|
2662
|
+
headStreamID
|
|
2663
|
+
});
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
//RTC同屏 辅助通道音频类型 0:静音 / 1:麦克风 / 2:拉流的声音 / 3:1+2 / 4:麦克风+扬声器+外部混音 /:8麦克风+扬声器(含拉流,没有外部混音) /:16扬声器(音乐)(没有拉流,没有外部混音没有调用,没有麦克风)
|
|
2414
2667
|
const setAUXAudioType = (type) => {
|
|
2415
2668
|
defaultApi.writeLog('info', 'avsdk ZEGO::SetAUXAudioType');
|
|
2416
2669
|
return callMethod('SetAUXAudioType', {
|
|
@@ -2986,11 +3239,14 @@ export default {
|
|
|
2986
3239
|
getAllChannelIndex,
|
|
2987
3240
|
startAudioExCapture,
|
|
2988
3241
|
sendMediaSideInfo,
|
|
3242
|
+
setCustomHeadStreamId,
|
|
2989
3243
|
setAUXAudioType,
|
|
2990
3244
|
loadCollectionInputEntry2,
|
|
2991
3245
|
addListener,
|
|
2992
3246
|
stopCheckDevice,
|
|
2993
3247
|
getDeviceCheckInitStatus,
|
|
2994
3248
|
setDeviceCheckInitStatus,
|
|
2995
|
-
setThirdAudioType
|
|
3249
|
+
setThirdAudioType,
|
|
3250
|
+
startmixStreams,
|
|
3251
|
+
stopMixtStreams
|
|
2996
3252
|
};
|
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
|