zby-live-sdk 1.0.49-beta1008-1 → 1.0.49-beta1014-1
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 +7 -0
- 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 +1 -1
- package/src/zby-av-sdk/zby-av-sdk.js +7 -7
- package/src/zby-av-sdk/zego-sdk.js +201 -118
- package/src/zby-live-sdk.js +8 -8
package/package.json
CHANGED
package/src/config/config.js
CHANGED
|
@@ -1830,17 +1830,17 @@ export const getStreamType_zego = () => {
|
|
|
1830
1830
|
const setThirdAudioCallbackType = (sdkType) => {
|
|
1831
1831
|
let type = sdkVale[sdkType];
|
|
1832
1832
|
return zegosdk.setThirdAudioType(type);
|
|
1833
|
-
}
|
|
1833
|
+
};
|
|
1834
1834
|
|
|
1835
|
-
const startMixStreams = (srcStreamIds,
|
|
1835
|
+
const startMixStreams = (mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId, extraStreamIds=[], coursewareWidth = 960) => {
|
|
1836
1836
|
console.log('zego startmixStreams');
|
|
1837
|
-
return zegosdk.startmixStreams(srcStreamIds,
|
|
1838
|
-
}
|
|
1837
|
+
return zegosdk.startmixStreams(mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId, extraStreamIds, coursewareWidth);
|
|
1838
|
+
};
|
|
1839
1839
|
|
|
1840
|
-
const stopMixtStreams = (
|
|
1840
|
+
const stopMixtStreams = (mixTaskId, targetUrls) => {
|
|
1841
1841
|
console.log('zego stopMixtStreams');
|
|
1842
|
-
return zegosdk.stopMixtStreams(
|
|
1843
|
-
}
|
|
1842
|
+
return zegosdk.stopMixtStreams(mixTaskId, targetUrls);
|
|
1843
|
+
};
|
|
1844
1844
|
|
|
1845
1845
|
|
|
1846
1846
|
export default {
|
|
@@ -71,8 +71,6 @@ let currStreamIdRtcPlayerInfo ;
|
|
|
71
71
|
//记录底层推流回调的值
|
|
72
72
|
let dataZegoCapture = {};
|
|
73
73
|
|
|
74
|
-
//记录推流id
|
|
75
|
-
let streamIdList = [];
|
|
76
74
|
/**
|
|
77
75
|
* @function 调用端提供的回调方法
|
|
78
76
|
* @param name:String 回调方法名
|
|
@@ -1798,15 +1796,8 @@ export const setDefaultDevice = async (devices, operationType) => {
|
|
|
1798
1796
|
*/
|
|
1799
1797
|
export const startPublish2 = async (streamid, idx, title, flag, seq) => {
|
|
1800
1798
|
const streamId = streamid || window.zbyAVSDK_init_params.zego.streamId;
|
|
1801
|
-
if (
|
|
1802
|
-
|
|
1803
|
-
} else {
|
|
1804
|
-
if (idx === 1) {
|
|
1805
|
-
await callMethod('StartCapture',{publish_channel:idx});
|
|
1806
|
-
streamIdList.unshift(streamId);
|
|
1807
|
-
} else {
|
|
1808
|
-
streamIdList.push(streamId);
|
|
1809
|
-
}
|
|
1799
|
+
if (idx === 1) {
|
|
1800
|
+
await callMethod("StartCapture", { publish_channel: idx });
|
|
1810
1801
|
}
|
|
1811
1802
|
if (typeof title === 'undefined') {
|
|
1812
1803
|
title = 'none';
|
|
@@ -2089,130 +2080,222 @@ export const mixStream = (type, args, seq) => {
|
|
|
2089
2080
|
|
|
2090
2081
|
};
|
|
2091
2082
|
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2083
|
+
/**
|
|
2084
|
+
* @function 切换播放流
|
|
2085
|
+
* @param mixTaskId:String 任务ID,混流任务唯一标识 必选
|
|
2086
|
+
* @param mixType:Int 0-web, 1-record, 2-Chat, 3-H5 必选
|
|
2087
|
+
* @param srcStreamIds:Array 课件+老师头像流ID ['stream_1','stream_2'] 必选
|
|
2088
|
+
* @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}]
|
|
2089
|
+
* @param targetRtcStreamId:String 混流输出流ID,必选
|
|
2090
|
+
* @param targetUrls:Array 转推RTMP流地址,必选
|
|
2091
|
+
* @param backgroundImageId:Int 0默认,1上台,2关闭摄像头
|
|
2092
|
+
* @param coursewareWidth: Int 课件区真实宽
|
|
2093
|
+
* @return Promise | void
|
|
2094
|
+
*/
|
|
2095
|
+
export const startmixStreams = async (mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId = 0, extraStreamIds=[], coursewareWidth = 960) => {
|
|
2096
|
+
let srcStreamInfos = [];
|
|
2097
|
+
let bkImage='preset-id://262148633_live_closeCamera.png';
|
|
2098
|
+
if (mixType === 0 || mixType === 1) {
|
|
2099
|
+
for (let i = 0, len = srcStreamIds.length; i < len; i++) {
|
|
2100
|
+
if (srcStreamIds[i].contentControl === 1) {
|
|
2101
|
+
srcStreamInfos.push({
|
|
2102
|
+
streamId: srcStreamIds[i].streamId,
|
|
2103
|
+
left: null,
|
|
2104
|
+
top: null,
|
|
2105
|
+
right: null,
|
|
2106
|
+
bottom: null,
|
|
2107
|
+
contentControl: srcStreamIds[i].contentControl
|
|
2108
|
+
});
|
|
2109
|
+
} else {
|
|
2110
|
+
if (i === 0) {
|
|
2111
|
+
srcStreamInfos.push({
|
|
2112
|
+
streamId: srcStreamIds[i].streamId,
|
|
2113
|
+
left: 0,
|
|
2114
|
+
top: 0,
|
|
2115
|
+
right: 960,
|
|
2116
|
+
bottom: 540,
|
|
2117
|
+
contentControl: srcStreamIds[i].contentControl
|
|
2118
|
+
});
|
|
2119
|
+
} else if (i === 1) {
|
|
2120
|
+
srcStreamInfos.push({
|
|
2121
|
+
streamId: srcStreamIds[i].streamId,
|
|
2122
|
+
left: 1008,
|
|
2123
|
+
top: 0,
|
|
2124
|
+
right: 1152,
|
|
2125
|
+
bottom: 108,
|
|
2126
|
+
contentControl: srcStreamIds[i].contentControl
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
let srcStreamInfos2 = [];
|
|
2133
|
+
Object.assign(srcStreamInfos2, extraStreamIds);
|
|
2134
|
+
if(srcStreamInfos2.length > 0) {
|
|
2135
|
+
let factor = 960 / coursewareWidth;
|
|
2136
|
+
srcStreamInfos2.forEach( item => {
|
|
2137
|
+
item.left = parseInt(item.left * factor);
|
|
2138
|
+
item.top = parseInt(item.top * factor);
|
|
2139
|
+
item.right = parseInt(item.right * factor);
|
|
2140
|
+
item.bottom = parseInt(item.bottom * factor);
|
|
2141
|
+
if (((item.right - item.left) % 2) != 0) {
|
|
2142
|
+
item.right = item.right - 1;
|
|
2143
|
+
}
|
|
2144
|
+
if (((item.bottom - item.top) % 2) != 0) {
|
|
2145
|
+
item.bottom = item.bottom - 1;
|
|
2146
|
+
}
|
|
2147
|
+
});
|
|
2148
|
+
|
|
2149
|
+
srcStreamInfos = srcStreamInfos.concat(srcStreamInfos2);
|
|
2150
|
+
|
|
2151
|
+
defaultApi.writeLog(`srcStreamInfos---------- params:${JSON.stringify(srcStreamInfos)}`);
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
switch (backgroundImageId) {
|
|
2155
|
+
case 0:
|
|
2156
|
+
break;
|
|
2157
|
+
case 1:
|
|
2158
|
+
bkImage = 'preset-id://262148633_live_TeacherOnStage.png';
|
|
2159
|
+
break;
|
|
2160
|
+
case 2:
|
|
2161
|
+
bkImage = 'preset-id://262148633_live_closeCamera.png';
|
|
2162
|
+
break;
|
|
2163
|
+
default:
|
|
2164
|
+
break;
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
const zego = window.zbyAVSDK_init_params.zego;
|
|
2096
2169
|
let param = {
|
|
2097
2170
|
institutionId: window.zby_sdk_init_params.institutionId,
|
|
2098
|
-
taskId:
|
|
2171
|
+
taskId: mixTaskId,
|
|
2099
2172
|
userId: zego.userId,
|
|
2100
|
-
|
|
2101
|
-
rtcStreamId,
|
|
2102
|
-
pushUrls:
|
|
2103
|
-
|
|
2173
|
+
streamInfos: srcStreamInfos,
|
|
2174
|
+
rtcStreamId: targetRtcStreamId,
|
|
2175
|
+
pushUrls: targetUrls, //数组
|
|
2176
|
+
backgroundImage: bkImage
|
|
2177
|
+
};
|
|
2178
|
+
|
|
2179
|
+
defaultApi.writeLog(`startMixStreams params:${JSON.stringify(param)}`);
|
|
2180
|
+
|
|
2104
2181
|
let res = await mixStreamsStart(param);
|
|
2105
2182
|
if (res.code == 0) {
|
|
2106
2183
|
console.log('混流成功:', res);
|
|
2107
|
-
}
|
|
2108
|
-
console.log('
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2184
|
+
} else {
|
|
2185
|
+
console.log('混流失败:', res);
|
|
2186
|
+
}
|
|
2187
|
+
// else {
|
|
2188
|
+
// console.log('startmixStream local start……');
|
|
2189
|
+
// return callMethod('MixStreamEx', {
|
|
2190
|
+
// mixstreamid: mixTaskId,
|
|
2191
|
+
// config: {
|
|
2192
|
+
// nOutputFps: 15,
|
|
2193
|
+
// nOutputBitrate: 512000,
|
|
2194
|
+
// nOutputAudioBitrate: 48000,
|
|
2195
|
+
// nOutputWidth: 1200,
|
|
2196
|
+
// nOutputHeight: 540,
|
|
2197
|
+
// nOutputAudioConfig: 0,
|
|
2198
|
+
// pUserData: '',
|
|
2199
|
+
// nLenOfUserData: 0,
|
|
2200
|
+
// pInputStreamList: [
|
|
2201
|
+
// {
|
|
2202
|
+
// szStreamID: streamIdList[1],//截屏窗
|
|
2203
|
+
// layout: { left: 0, top: 0, right: 960, bottom: 540 },
|
|
2204
|
+
// uSoundLevelID: 1234,
|
|
2205
|
+
// nContentControl: 0,
|
|
2206
|
+
// nVolume: 100,
|
|
2207
|
+
// bAudioFocus: false,
|
|
2208
|
+
// nAudioDirection: -1,
|
|
2209
|
+
// renderMode: 0
|
|
2210
|
+
// },
|
|
2211
|
+
// {
|
|
2212
|
+
// szStreamID: streamIdList[0],//头像
|
|
2213
|
+
// layout: { left: 1008, top: 0, right: 1152, bottom: 108 },
|
|
2214
|
+
// uSoundLevelID: 3232,
|
|
2215
|
+
// nContentControl: 0,
|
|
2216
|
+
// nVolume: 100,
|
|
2217
|
+
// bAudioFocus: false,
|
|
2218
|
+
// nAudioDirection: -1,
|
|
2219
|
+
// renderMode: 0
|
|
2220
|
+
// }
|
|
2221
|
+
// ],
|
|
2222
|
+
// nInputStreamCount: 2,
|
|
2223
|
+
// pOutputList: [
|
|
2224
|
+
// {
|
|
2225
|
+
// isUrl: true, // 输出是否为流名或URL
|
|
2226
|
+
// target: targetUrls[0], //isUrl=ture完整的RTMP URL,false是流名
|
|
2227
|
+
// videoCodec: 0,
|
|
2228
|
+
// videoBitrate: 0,
|
|
2229
|
+
// encodeProfile: 1,
|
|
2230
|
+
// encodeLatency: 0
|
|
2231
|
+
// }
|
|
2232
|
+
// // {
|
|
2233
|
+
// // isUrl: false,
|
|
2234
|
+
// // target: "streamId",
|
|
2235
|
+
// // videoCodec: 0,
|
|
2236
|
+
// // videoBitrate: 0,
|
|
2237
|
+
// // encodeProfile: 1,
|
|
2238
|
+
// // encodeLatency: 0
|
|
2239
|
+
// // }
|
|
2240
|
+
// ],
|
|
2241
|
+
// nOutputStreamCount: 1,
|
|
2242
|
+
// pOutputBackgroundImage: bkImage,
|
|
2243
|
+
// }
|
|
2244
|
+
// });
|
|
2245
|
+
// }
|
|
2166
2246
|
|
|
2167
2247
|
|
|
2168
2248
|
};
|
|
2169
2249
|
|
|
2170
|
-
export const stopMixtStreams = async (
|
|
2250
|
+
export const stopMixtStreams = async (mixTaskId, targetUrls) => {
|
|
2171
2251
|
const zego = window.zbyAVSDK_init_params.zego;
|
|
2172
2252
|
let param = {
|
|
2173
|
-
taskId:
|
|
2253
|
+
taskId: mixTaskId,
|
|
2174
2254
|
userId: zego.userId
|
|
2175
|
-
}
|
|
2255
|
+
};
|
|
2176
2256
|
let res = await mixStreamsStop(param);
|
|
2177
2257
|
if (res.code == 0) {
|
|
2178
2258
|
console.log('停止混流成功:', res);
|
|
2179
2259
|
} else {
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2260
|
+
console.log('停止混流失败:', res);
|
|
2261
|
+
}
|
|
2262
|
+
// else {
|
|
2263
|
+
// return callMethod('MixStreamEx', {
|
|
2264
|
+
// mixstreamid: mixTaskId,
|
|
2265
|
+
// config: {
|
|
2266
|
+
// nOutputFps: 15,
|
|
2267
|
+
// nOutputBitrate: 512000,
|
|
2268
|
+
// nOutputAudioBitrate: 48000,
|
|
2269
|
+
// nOutputWidth: 1280,
|
|
2270
|
+
// nOutputHeight: 720,
|
|
2271
|
+
// nOutputAudioConfig: 0,
|
|
2272
|
+
// pUserData: '',
|
|
2273
|
+
// nLenOfUserData: 0,
|
|
2274
|
+
// pInputStreamList: [],
|
|
2275
|
+
// nInputStreamCount: 2,
|
|
2276
|
+
// pOutputList: [
|
|
2277
|
+
// {
|
|
2278
|
+
// isUrl: true, // 输出是否为流名或URL
|
|
2279
|
+
// target: targetUrls[0], //isUrl=ture完整的RTMP URL,false是流名
|
|
2280
|
+
// videoCodec: 0,
|
|
2281
|
+
// videoBitrate: 0,
|
|
2282
|
+
// encodeProfile: 1,
|
|
2283
|
+
// encodeLatency: 0
|
|
2284
|
+
// }
|
|
2285
|
+
// // {
|
|
2286
|
+
// // isUrl: false,
|
|
2287
|
+
// // target: "streamId",
|
|
2288
|
+
// // videoCodec: 0,
|
|
2289
|
+
// // videoBitrate: 0,
|
|
2290
|
+
// // encodeProfile: 1,
|
|
2291
|
+
// // encodeLatency: 0
|
|
2292
|
+
// // }
|
|
2293
|
+
// ],
|
|
2294
|
+
// nOutputStreamCount: 1,
|
|
2295
|
+
// pOutputBackgroundImage: '',
|
|
2296
|
+
// }
|
|
2297
|
+
// });
|
|
2298
|
+
// }
|
|
2216
2299
|
};
|
|
2217
2300
|
|
|
2218
2301
|
|
package/src/zby-live-sdk.js
CHANGED
|
@@ -1514,13 +1514,13 @@ const zbysdk = {
|
|
|
1514
1514
|
|
|
1515
1515
|
//RTC同屏 辅助通道音频类型
|
|
1516
1516
|
setAUXAudioType(type) {
|
|
1517
|
-
defaultApi.writeLog(
|
|
1517
|
+
defaultApi.writeLog(`sdk action: setAUXAudioType type:${type}`);
|
|
1518
1518
|
return zbyAVSDK.setAUXAudioType(type);
|
|
1519
1519
|
},
|
|
1520
1520
|
|
|
1521
1521
|
//RTC同屏 辅助通道音频类型
|
|
1522
1522
|
setThirdAudioType(type) {
|
|
1523
|
-
defaultApi.writeLog(
|
|
1523
|
+
defaultApi.writeLog(`sdk action: setThirdAudioType type:${type}`);
|
|
1524
1524
|
return zbyAVSDK.setThirdAudioType(type);
|
|
1525
1525
|
},
|
|
1526
1526
|
|
|
@@ -1530,14 +1530,14 @@ const zbysdk = {
|
|
|
1530
1530
|
return zbyAVSDK.sendMediaSideInfo(info);
|
|
1531
1531
|
},
|
|
1532
1532
|
|
|
1533
|
-
startMixStreams(srcStreamIds,
|
|
1534
|
-
defaultApi.writeLog(
|
|
1535
|
-
return zbyAVSDK.startMixStreams(srcStreamIds,
|
|
1533
|
+
startMixStreams(mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId=0, extraStreamIds=[], coursewareWidth = 960) {
|
|
1534
|
+
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}`);
|
|
1535
|
+
return zbyAVSDK.startMixStreams(mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId, extraStreamIds, coursewareWidth);
|
|
1536
1536
|
},
|
|
1537
1537
|
|
|
1538
|
-
stopMixtStreams(
|
|
1539
|
-
defaultApi.writeLog(
|
|
1540
|
-
return zbyAVSDK.stopMixtStreams(
|
|
1538
|
+
stopMixtStreams(mixTaskId, targetUrls) {
|
|
1539
|
+
defaultApi.writeLog(`sdk action: stopMixtStreams mixTaskId:${mixTaskId} targetUrls:${targetUrls}`);
|
|
1540
|
+
return zbyAVSDK.stopMixtStreams(mixTaskId, targetUrls);
|
|
1541
1541
|
},
|
|
1542
1542
|
|
|
1543
1543
|
/**
|