zby-live-sdk 1.0.49-beta0927-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zby-live-sdk",
3
- "version": "1.0.49-beta0927-1",
3
+ "version": "1.0.49-beta1014-1",
4
4
  "main": "dist/zby-live-sdk.cjs.js",
5
5
  "module": "dist/zby-live-sdk.esm.js",
6
6
  "browsers": "dist/zby-live-sdk.umd.js",
@@ -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-beta0927-1';
16
+ export const version = '1.0.49-beta1014-1';
17
17
 
18
18
  export const liveExt = {
19
19
  name: 'live',
@@ -110,8 +110,8 @@ const apiChangeSdkUrl = {
110
110
 
111
111
  //开启混流
112
112
  const apiMixStreams = {
113
- test: 'https://tf-classroom-api-test.vdyoo.com',
114
- online: 'https://tf-classroom-api-online.vdyoo.com'
113
+ test: 'https://tf-classroom-test.vdyoo.com',
114
+ online: 'https://tf-classroom-online.vdyoo.com'
115
115
  };
116
116
 
117
117
  export const getApiCloudBaseUrl = () => {
@@ -21,8 +21,8 @@ const rtcReportUrl = {
21
21
  online: 'r.weclassroom.com'
22
22
  };
23
23
  const sdkVale = {
24
- zego: 8, //8代表zego采集麦克风+扬声器
25
- talrtc: 101, //101代表talrtc采集声音
24
+ zego: 4, //4代表zego采集麦克风+扬声器+拉流声音+外部混音
25
+ talrtc: 101, //101代表talrtc采集声音
26
26
  trtc: 102, //102代表trtc采集声音
27
27
  }
28
28
 
@@ -1797,6 +1797,21 @@ export const setAUXAudioType = (type) => {
1797
1797
  }
1798
1798
  };
1799
1799
 
1800
+ /**
1801
+ * @function 开启音频外部采集
1802
+ * @return: Promise
1803
+ */
1804
+ export const setThirdAudioType = (type) => {
1805
+ switch (window.zbyAVSDK_init_sdk_type) {
1806
+ case RTC:
1807
+ break;
1808
+ case ZEGO:
1809
+ return zegosdk.setThirdAudioType(type);
1810
+ default:
1811
+ break;
1812
+ }
1813
+ };
1814
+
1800
1815
  /**
1801
1816
  * @function 判断推流类型
1802
1817
  * @return: Promise
@@ -1815,17 +1830,17 @@ export const getStreamType_zego = () => {
1815
1830
  const setThirdAudioCallbackType = (sdkType) => {
1816
1831
  let type = sdkVale[sdkType];
1817
1832
  return zegosdk.setThirdAudioType(type);
1818
- }
1833
+ };
1819
1834
 
1820
- const startMixStreams = (urls) => {
1835
+ const startMixStreams = (mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId, extraStreamIds=[], coursewareWidth = 960) => {
1821
1836
  console.log('zego startmixStreams');
1822
- return zegosdk.startmixStreams(urls);
1823
- }
1837
+ return zegosdk.startmixStreams(mixTaskId, mixType, srcStreamIds, targetRtcStreamId, targetUrls, backgroundImageId, extraStreamIds, coursewareWidth);
1838
+ };
1824
1839
 
1825
- const stopMixtStreams = (urls) => {
1840
+ const stopMixtStreams = (mixTaskId, targetUrls) => {
1826
1841
  console.log('zego stopMixtStreams');
1827
- return zegosdk.stopMixtStreams(urls);
1828
- }
1842
+ return zegosdk.stopMixtStreams(mixTaskId, targetUrls);
1843
+ };
1829
1844
 
1830
1845
 
1831
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,10 +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 (streamIdList.includes(streamId)) {
1802
- console.log('streamIdList is including this streamid', streamIdList, streamId);
1803
- } else {
1804
- streamIdList.push(streamId);
1799
+ if (idx === 1) {
1800
+ await callMethod("StartCapture", { publish_channel: idx });
1805
1801
  }
1806
1802
  if (typeof title === 'undefined') {
1807
1803
  title = 'none';
@@ -1864,6 +1860,9 @@ export const stopPublish = (idx, msg, flag) => {
1864
1860
  if (typeof idx === 'undefined') {
1865
1861
  idx = 0;
1866
1862
  }
1863
+ if (idx === 1) {
1864
+ callMethod('StopCapture',{publish_channel:idx});
1865
+ }
1867
1866
  // try {
1868
1867
  // dataReport.stopPublish({publish_streamid:window.zbyAVSDK_init_params.zego.streamId});
1869
1868
  // } catch (error) {}
@@ -2081,130 +2080,222 @@ export const mixStream = (type, args, seq) => {
2081
2080
 
2082
2081
  };
2083
2082
 
2084
- export const startmixStreams = async (targetUrl) => {
2085
- const zego = window.zbyAVSDK_init_params.zego;
2086
-
2087
- let rtcStreamId = `${zego.sid.slice(0,zego.sid.length-1)+2}` //'4000_345_123_2'
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;
2088
2169
  let param = {
2089
- institutionId: zego.institutionId,
2090
- taskId: zego.sid,
2170
+ institutionId: window.zby_sdk_init_params.institutionId,
2171
+ taskId: mixTaskId,
2091
2172
  userId: zego.userId,
2092
- streamIds: streamIdList,
2093
- rtcStreamId,
2094
- pushUrls: targetUrl //数组
2095
- }
2173
+ streamInfos: srcStreamInfos,
2174
+ rtcStreamId: targetRtcStreamId,
2175
+ pushUrls: targetUrls, //数组
2176
+ backgroundImage: bkImage
2177
+ };
2178
+
2179
+ defaultApi.writeLog(`startMixStreams params:${JSON.stringify(param)}`);
2180
+
2096
2181
  let res = await mixStreamsStart(param);
2097
2182
  if (res.code == 0) {
2098
2183
  console.log('混流成功:', res);
2099
- } else {
2100
- console.log('startmixStream local start……');
2101
- return callMethod('MixStreamEx', {
2102
- mixstreamid: zego.sid,
2103
- config: {
2104
- nOutputFps: 15,
2105
- nOutputBitrate: 512000,
2106
- nOutputAudioBitrate: 48000,
2107
- nOutputWidth: 1280,
2108
- nOutputHeight: 720,
2109
- nOutputAudioConfig: 0,
2110
- pUserData: '',
2111
- nLenOfUserData: 0,
2112
- pInputStreamList: [
2113
- {
2114
- szStreamID: streamIdList[1],//截屏窗
2115
- layout: { left: 0, top: 0, right: 1040, bottom: 720 },
2116
- uSoundLevelID: 1234,
2117
- nContentControl: 0,
2118
- nVolume: 100,
2119
- bAudioFocus: false,
2120
- nAudioDirection: -1,
2121
- renderMode: 0
2122
- },
2123
- {
2124
- szStreamID: streamIdList[0],//头像
2125
- layout: { left: 1040, top: 0, right: 1280, bottom: 180 },
2126
- uSoundLevelID: 3232,
2127
- nContentControl: 0,
2128
- nVolume: 100,
2129
- bAudioFocus: false,
2130
- nAudioDirection: -1,
2131
- renderMode: 0
2132
- }
2133
- ],
2134
- nInputStreamCount: 2,
2135
- pOutputList: [
2136
- {
2137
- isUrl: true, // 输出是否为流名或URL
2138
- target: targetUrl[0], //isUrl=ture完整的RTMP URL,false是流名
2139
- videoCodec: 0,
2140
- videoBitrate: 0,
2141
- encodeProfile: 1,
2142
- encodeLatency: 0
2143
- }
2144
- // {
2145
- // isUrl: false,
2146
- // target: "streamId",
2147
- // videoCodec: 0,
2148
- // videoBitrate: 0,
2149
- // encodeProfile: 1,
2150
- // encodeLatency: 0
2151
- // }
2152
- ],
2153
- nOutputStreamCount: 1,
2154
- pOutputBackgroundImage: '',
2155
- }
2156
- })
2157
- }
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
+ // }
2158
2246
 
2159
2247
 
2160
2248
  };
2161
2249
 
2162
- export const stopMixtStreams = async (targetUrl) => {
2250
+ export const stopMixtStreams = async (mixTaskId, targetUrls) => {
2163
2251
  const zego = window.zbyAVSDK_init_params.zego;
2164
2252
  let param = {
2165
- taskId: zego.sid,
2253
+ taskId: mixTaskId,
2166
2254
  userId: zego.userId
2167
- }
2255
+ };
2168
2256
  let res = await mixStreamsStop(param);
2169
2257
  if (res.code == 0) {
2170
2258
  console.log('停止混流成功:', res);
2171
2259
  } else {
2172
- return callMethod('MixStreamEx', {
2173
- mixstreamid: zego.sid,
2174
- config: {
2175
- nOutputFps: 15,
2176
- nOutputBitrate: 512000,
2177
- nOutputAudioBitrate: 48000,
2178
- nOutputWidth: 1280,
2179
- nOutputHeight: 720,
2180
- nOutputAudioConfig: 0,
2181
- pUserData: '',
2182
- nLenOfUserData: 0,
2183
- pInputStreamList: [],
2184
- nInputStreamCount: 2,
2185
- pOutputList: [
2186
- {
2187
- isUrl: true, // 输出是否为流名或URL
2188
- target: targetUrl[0], //isUrl=ture完整的RTMP URL,false是流名
2189
- videoCodec: 0,
2190
- videoBitrate: 0,
2191
- encodeProfile: 1,
2192
- encodeLatency: 0
2193
- }
2194
- // {
2195
- // isUrl: false,
2196
- // target: "streamId",
2197
- // videoCodec: 0,
2198
- // videoBitrate: 0,
2199
- // encodeProfile: 1,
2200
- // encodeLatency: 0
2201
- // }
2202
- ],
2203
- nOutputStreamCount: 1,
2204
- pOutputBackgroundImage: '',
2205
- }
2206
- })
2207
- }
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
+ // }
2208
2299
  };
2209
2300
 
2210
2301
 
@@ -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();
@@ -1510,24 +1514,30 @@ const zbysdk = {
1510
1514
 
1511
1515
  //RTC同屏 辅助通道音频类型
1512
1516
  setAUXAudioType(type) {
1513
- defaultApi.writeLog('sdk action: setAUXAudioType');
1517
+ defaultApi.writeLog(`sdk action: setAUXAudioType type:${type}`);
1514
1518
  return zbyAVSDK.setAUXAudioType(type);
1515
1519
  },
1516
1520
 
1521
+ //RTC同屏 辅助通道音频类型
1522
+ setThirdAudioType(type) {
1523
+ defaultApi.writeLog(`sdk action: setThirdAudioType type:${type}`);
1524
+ return zbyAVSDK.setThirdAudioType(type);
1525
+ },
1526
+
1517
1527
  //发送sei
1518
1528
  sendMediaSideInfo(info) {
1519
1529
  defaultApi.writeLog('sdk action: sendMediaSideInfo');
1520
1530
  return zbyAVSDK.sendMediaSideInfo(info);
1521
1531
  },
1522
1532
 
1523
- startMixStreams(urls) {
1524
- defaultApi.writeLog('sdk action: startMixStream');
1525
- return zbyAVSDK.startMixStreams(urls);
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);
1526
1536
  },
1527
1537
 
1528
- stopMixtStreams(urls) {
1529
- defaultApi.writeLog('sdk action: stopMixtStreams');
1530
- return zbyAVSDK.stopMixtStreams(urls);
1538
+ stopMixtStreams(mixTaskId, targetUrls) {
1539
+ defaultApi.writeLog(`sdk action: stopMixtStreams mixTaskId:${mixTaskId} targetUrls:${targetUrls}`);
1540
+ return zbyAVSDK.stopMixtStreams(mixTaskId, targetUrls);
1531
1541
  },
1532
1542
 
1533
1543
  /**