react_hsbc_teller 1.9.34 → 1.9.36

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": "react_hsbc_teller",
3
- "version": "1.9.34",
3
+ "version": "1.9.36",
4
4
  "description": "React",
5
5
  "private": false,
6
6
  "main": "lib/hsbc.js",
@@ -47,7 +47,7 @@ import Step from '../components/step/step.jsx'
47
47
  import axios from 'axios';
48
48
  import CryptoJS from "crypto-js";
49
49
 
50
- const SDK_VERISON = '1.9.34'
50
+ const SDK_VERISON = '1.9.36'
51
51
  const IDtypeFront = '请客户在其设备后置摄像头下展示证件正面(如:身份证照片页面)'
52
52
  const IDtypeBack = '请在后置摄像头下展示证件反面(如:身份证国徽页)'
53
53
  const { Option } = Select;
@@ -72,6 +72,8 @@ let isSuccuseHs = false
72
72
  let isGraffiti = false
73
73
  let strokeColor = '#333'
74
74
  let clearTime
75
+ let beautyMode = 'none'
76
+ let hsMode = 'none'
75
77
  let CanvasHome = styled.div`
76
78
  position: fixed;
77
79
  z-index: ${props => props.zIndexNum};
@@ -117,7 +119,7 @@ function clearStreamRemain() {
117
119
  };
118
120
  async function startBeauty(stream) {
119
121
  await beautyInit();
120
- beautyStart(stream, "none");
122
+ beautyStart(stream, beautyMode);
121
123
  }
122
124
  async function startMix(stream, onState) {
123
125
  var drawCanvas = document.getElementById('canvas');
@@ -133,21 +135,25 @@ async function startHs(stream) {
133
135
 
134
136
  await hsInit();
135
137
 
136
- hsStart(stream, 'none');
138
+ hsStart(stream, hsMode);
137
139
 
138
140
  }
139
141
 
140
142
  async function stopHs() {
141
- var stop_stream = true;//控制是否内部来进行关闭流
142
- var stream = hsStop(stop_stream);
143
- if (stream != null && stream != undefined) {
144
- stream.getTracks().forEach((track) => {
145
- track.stop();
146
- });
147
- stream = null;
143
+ try {
144
+ var stop_stream = true;//控制是否内部来进行关闭流
145
+ var stream = hsStop(stop_stream);
146
+ if (stream != null && stream != undefined) {
147
+ stream.getTracks().forEach((track) => {
148
+ track.stop();
149
+ });
150
+ stream = null;
151
+ }
152
+ isSuccuseHs = false
153
+ } catch (err) {
154
+ console.log('stopHs Error')
155
+ console.log(err)
148
156
  }
149
- isSuccuseHs = false
150
-
151
157
  }
152
158
  async function mixStopClick() {
153
159
  var stop_stream = true;//控制是否内部来进行关闭流
@@ -965,6 +971,100 @@ class Video extends Component {
965
971
  this.selectCustomer('facial')
966
972
  }
967
973
  };
974
+ generateMediaInfo = (sid) => {
975
+ let that = this
976
+ console.log(that.test_controller, sid)
977
+ console.log(that.test_controller.GetMediaInfo(sid))
978
+ let originalMediaInfo = that.test_controller.GetMediaInfo(sid);
979
+ let mediaInfo = {
980
+ peer_connection_: originalMediaInfo.peer_connection_,
981
+ local_video_width: originalMediaInfo.local_video_width,
982
+ local_video_height: originalMediaInfo.local_video_height,
983
+ local_video_frame: originalMediaInfo.local_video_frame,
984
+ local_video_bitrate: originalMediaInfo.local_video_bitrate,
985
+ stream_type: originalMediaInfo.stream_type,
986
+ stat_interval_: 3,
987
+ video_send_packets_base_: 0,
988
+ video_recv_packets_base_: 0,
989
+ video_send_lost_pack_base_: 0,
990
+ video_recv_lost_pack_base_: 0,
991
+ audio_send_packets_base_: 0,
992
+ audio_recv_packets_base_: 0,
993
+ audio_send_lost_pack_base_: 0,
994
+ audio_recv_lost_pack_base_: 0,
995
+ video_send_qpsum_base: 0,
996
+ video_send_frame_encoded_base: 0,
997
+ video_recv_qpsum_base: 0,
998
+ video_recv_frame_decoded_base: 0,
999
+ video_send_bitrate_base_: 0,
1000
+ video_recv_bitrate_base_: 0,
1001
+ audio_send_bitrate_base_: 0,
1002
+ audio_recv_bitrate_base_: 0,
1003
+ };
1004
+ return mediaInfo;
1005
+ }
1006
+ detectNetworkWeak = () => {
1007
+ return new Promise((resolve, reject) => {
1008
+ let detectionsNumber = 3
1009
+ let finalResult = true
1010
+ let setTimer = () => {
1011
+ setTimeout(() => {
1012
+ this.test_controller.GetStats(this.mediaInfo).then(media_stat => {
1013
+ if (detectionsNumber>2) {
1014
+ // 不考虑第一次的评估结果,重新计算码率
1015
+ detectionsNumber--;
1016
+ setTimer()
1017
+ return
1018
+ }
1019
+ console.log('media_stat:')
1020
+ console.log(media_stat)
1021
+ // 分辨率、帧率
1022
+ let googAvailableSendBandwidth = (media_stat["VideoBwe"]["googAvailableSendBandwidth"] / 1000).toFixed(2);
1023
+ let googTransmitBitrate = (media_stat["VideoBwe"]["googTransmitBitrate"] / 1000).toFixed(2);
1024
+ let ssrcVideoSendLostRate = media_stat["ssrcVideoSend"]["lostRate"];
1025
+ let ssrcAudioSendLostRate = media_stat["ssrcAudioSend"]["lostRate"];
1026
+ let weak_googAvailableSendBandwidth = 200;
1027
+ let weak_ssrcVideoSendLostRate = 20;
1028
+ let weak_ssrcAudioSendLostRate = 20;
1029
+ let weak_str = "网络正常";
1030
+ if (googAvailableSendBandwidth < weak_googAvailableSendBandwidth) {
1031
+ weak_str = "当前网络不佳";
1032
+ }
1033
+ let bpsSend = (media_stat.ssrcVideoSend["bpsSend"] / 1000).toFixed(2)
1034
+ let fps = media_stat["ssrcVideoSend"].googFrameRateSent
1035
+ let str =
1036
+ "带宽评估:" + (googAvailableSendBandwidth == undefined ? "none" : googAvailableSendBandwidth + "kbps") + "; "
1037
+ + "视频码率:" + bpsSend + "kb" + "; "
1038
+ + "音频码率:" + (media_stat.ssrcAudioSend["bpsSend"] / 1000).toFixed(2) + "kb" + "; "
1039
+ + "视频丢包率:" + (ssrcVideoSendLostRate == undefined ? "none" : ssrcVideoSendLostRate + "%") + "; "
1040
+ + "音频丢包率:" + (ssrcAudioSendLostRate == undefined ? "none" : ssrcAudioSendLostRate + "%") + "; "
1041
+ + weak_str + "; "
1042
+ + "当前编码格式:" + media_stat["ssrcVideoSend"].googCodecName + "; "
1043
+ + "分辨率:" + media_stat["ssrcVideoSend"].resolution + "; "
1044
+ + "帧率:" + media_stat["ssrcVideoSend"].googFrameRateSent;
1045
+ console.log('弱网', str)
1046
+ // document.getElementById("publish_media_stat1").innerText = str;
1047
+ let result = (bpsSend < 200 ) && googAvailableSendBandwidth < weak_googAvailableSendBandwidth
1048
+ if (result) {
1049
+ console.log('[!]弱网单次评估' + result);
1050
+ } else {
1051
+ finalResult = false
1052
+ console.log('弱网单次评估' + result);
1053
+ }
1054
+ if (detectionsNumber > 0 && finalResult) {
1055
+ detectionsNumber -= 1
1056
+ setTimer();
1057
+ } else {
1058
+ console.log('弱网综合检测结果:' + finalResult)
1059
+ resolve(finalResult)
1060
+ }
1061
+ });
1062
+
1063
+ }, 3000)
1064
+ }
1065
+ setTimer()
1066
+ })
1067
+ }
968
1068
  ocrClick = () => {
969
1069
  if (this.isFileSuccuse()) {
970
1070
  this.state.faceCustomerType = 2
@@ -1779,10 +1879,12 @@ class Video extends Component {
1779
1879
  console.log('tag1', stream)
1780
1880
  let newStream = stream;
1781
1881
  if (stream.getVideoTracks()[0]) {
1782
- await startBeauty(newStream);
1783
- newStream = beautyCaptureStream();
1784
- await startHs(newStream);
1785
- newStream = hsCaptureStream();
1882
+ if (this.state.beautyType || isSuccuseHs){
1883
+ await startBeauty(newStream);
1884
+ newStream = beautyCaptureStream();
1885
+ await startHs(newStream);
1886
+ newStream = hsCaptureStream();
1887
+ }
1786
1888
  // 清理原始流
1787
1889
  newStream.oninactive = function () {
1788
1890
  clearOriginStream(stream);
@@ -1915,6 +2017,8 @@ class Video extends Component {
1915
2017
  },
1916
2018
  1000
1917
2019
  );
2020
+ this.mediaInfo = this.generateMediaInfo(document.getElementById("publish_video1").name);
2021
+
1918
2022
  } else {
1919
2023
  var box = document.getElementById("whiteboardDIV");
1920
2024
  var box1 = document.getElementById("operate")
@@ -2342,21 +2446,26 @@ class Video extends Component {
2342
2446
  this.test_controller.OnNetworkWeak = (bpsSend, bpsRecv, sid) => {
2343
2447
  console.log('弱网回调', bpsSend, bpsRecv, sid)
2344
2448
  if (sid == document.getElementById('publish_video1').name) {
2345
- this.messageClick('当前网络环境较差', 'error')
2346
- this.saveLog('mrtc OnNetworkWeak')
2347
-
2348
- if (this.props.isWeakSound && this.state.ablePlayNetweakAudio) {
2349
- this.state.ablePlayNetweakAudio = false;
2350
- let src = networkWeakAudio
2351
- let audio = new Audio(src)
2352
- audio.play()
2353
- setTimeout(() => {
2354
- this.state.ablePlayNetweakAudio = true;
2355
- }, 30000);
2356
- }
2357
- if (this.props.OnNetworkWeak) {
2358
- this.props.OnNetworkWeak(bpsSend, bpsRecv, sid)
2359
- }
2449
+
2450
+ this.detectNetworkWeak().then((isWeak) => {
2451
+ console.log('弱网结果:' + isWeak)
2452
+ if (isWeak) {
2453
+ this.messageClick('当前网络环境较差', 'error')
2454
+ this.saveLog('mrtc OnNetworkWeak')
2455
+ if (this.props.isWeakSound && this.state.ablePlayNetweakAudio) {
2456
+ this.state.ablePlayNetweakAudio = false;
2457
+ let src = networkWeakAudio
2458
+ let audio = new Audio(src)
2459
+ audio.play()
2460
+ setTimeout(() => {
2461
+ this.state.ablePlayNetweakAudio = true;
2462
+ }, 30000);
2463
+ }
2464
+ if (this.props.OnNetworkWeak) {
2465
+ this.props.OnNetworkWeak(bpsSend, bpsRecv, sid)
2466
+ }
2467
+ }
2468
+ })
2360
2469
 
2361
2470
  }
2362
2471
  };
@@ -4633,16 +4742,39 @@ class Video extends Component {
4633
4742
  this.setState({
4634
4743
  beautyName: '开启美颜'
4635
4744
  })
4745
+ beautyMode = 'none'
4636
4746
  beautySetMode('none')
4747
+ beautyStop()
4748
+ if(!isSuccuseHs) {
4749
+ stopHs()
4750
+ }
4637
4751
  } else {
4638
4752
  this.state.beautyType = true
4753
+ beautyMode = 'beauty'
4639
4754
  beautySetMode('beauty')
4640
4755
  this.setState({
4641
4756
  beautyName: '关闭美颜'
4642
4757
  })
4643
4758
  }
4759
+ this.changeMediaStream();
4644
4760
 
4645
4761
  }
4762
+ changeMediaStream = () => {
4763
+ let publish_config = {}
4764
+ publish_config.sid = document.getElementById('publish_video1').name
4765
+ publish_config.media_type = 1
4766
+ publish_config.publish_device = 1
4767
+ // publish_config.videoSource = this.state.cameraValue
4768
+ // publish_config.audioSource = this.state.microphoneValue
4769
+ publish_config.need_volume_analyser = true
4770
+ publish_config.video_profile_type = 100
4771
+ publish_config.video_profile_diy = { width: 640, height: 360, frameRate: 15, bitrate: 400 }
4772
+ // publish_config.publish_video_id = 'publish_video1'
4773
+ // publish_config.publish_streamId_id = 'publish_streamId1'
4774
+ // publish_config.publish_tag = 'tag1'
4775
+ this.test_controller.ChangeMediaStream(publish_config)
4776
+ }
4777
+
4646
4778
  componentDidMount() {
4647
4779
  var box = document.getElementById("whiteboardDIV");
4648
4780
  var box1 = document.getElementById("operate")
@@ -4794,11 +4926,18 @@ class Video extends Component {
4794
4926
  if (!isSuccuseHs) {
4795
4927
 
4796
4928
  hsSetMode('blur')
4929
+ hsMode = 'blur'
4797
4930
  isSuccuseHs = true
4798
4931
  } else {
4799
4932
  hsSetMode('none')
4933
+ hsMode = 'none'
4800
4934
  isSuccuseHs = false
4935
+ stopHs()
4936
+ if(!this.state.beautyType) {
4937
+ beautyStop()
4938
+ }
4801
4939
  }
4940
+ this.changeMediaStream();
4802
4941
  }
4803
4942
  virtualization = () => {
4804
4943
  this.virtualizationClick()
@@ -419,7 +419,7 @@
419
419
  border-spacing: 20px!important;
420
420
  }
421
421
  .modelButtonFaceOkColorFile{
422
- width: 170px!important;
422
+ min-width: 170px!important;
423
423
  height: 40px!important;
424
424
  font-size: 16px!important;
425
425
  color: #5C5C5C!important;