您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

vcon.js 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. clog("VCON")
  2. // glob_react.video_layout.calcTileGrid
  3. glob_mx.h_scope = glob_mx.h_scope || {}
  4. glob_mx.filmstrip_handlers["fs_h"] = function function_name(o) {
  5. // clog("fs_h FN HANDLER.")
  6. if (o.length == 1){
  7. $(".fs_container")[0].dataset.c_len = 1
  8. } else if (o.length == 2){
  9. $(".fs_container")[0].dataset.c_len = 2
  10. } else if (o.length == 3){
  11. $(".fs_container")[0].dataset.c_len = 3
  12. } else if (o.length > 3){
  13. $(".fs_container")[0].dataset.c_len = "3g"
  14. }
  15. // clog("fs_h FN HANDLER",arguments)
  16. return
  17. // console.trace("fs_h FN ")
  18. glob_mx.h_scope = {}
  19. glob_mx.h_scope.width =1000
  20. glob_mx.h_scope.height =1000
  21. // console.trace("fs_h")
  22. // setTimeout(fh2,0)
  23. }
  24. function fh2(){
  25. clog("fs_h FH2")
  26. }
  27. function rs_cb(j_){
  28. // clog("d3_i","rs_cb",j_)
  29. // clog("d3_","rs_cb")
  30. var i,k,v,j
  31. j = $(j_)
  32. for (v of j){
  33. // clog("mv_cb////.")
  34. if (v.mv_cb){
  35. // clog("mv_cb////",v.mv_cb)
  36. v.mv_cb.resolve("RS_CB")
  37. }
  38. }
  39. }
  40. glob_mx.filmstrip_handlers_post["fs_h"] = function function_name(o) {
  41. // clog("fs_h FN HANDLER_POST",arguments)
  42. // $(".fs_container").css()
  43. return
  44. if (o.length == 1){
  45. $(".fs_container")[0].dataset.c_len = 1
  46. } else if (o.length == 2){
  47. $(".fs_container")[0].dataset.c_len = 2
  48. } else if (o.length == 3){
  49. $(".fs_container")[0].dataset.c_len = 3
  50. } else if (o.length > 3){
  51. $(".fs_container")[0].dataset.c_len = "3g"
  52. }
  53. return
  54. var t_height = glob_mx.h_scope.height
  55. var t_width = glob_mx.h_scope.width
  56. var css_obj = {
  57. "min-width":t_width,
  58. "min-height":t_height,
  59. width:t_width,
  60. height:t_height,
  61. "--vdim2": `"${Math.round(t_width * 10)/10} x ${Math.round(t_height * 10)/10}"`,
  62. }
  63. // "--vdim2": `"${t_width} x ${t_height}"`,
  64. //
  65. // Math.round(num * 10) / 10
  66. // $(".vspace").find(".small_vid")
  67. $(".vspace").find(".small_vid").css(css_obj)
  68. // console.trace("fs_h")
  69. // setTimeout(fh2,0)
  70. }
  71. // fs_handlers_post
  72. glob_mx.filmstrip_tile_handlers["fs_h"] = function function_name(vc) {
  73. // clog("fs_h FN TILE HANDLER",vc,{that:this,args:[...arguments]})
  74. // console.trace("FSHT")
  75. // clog("d3_z","filmstrip_tile_handlers","fs_h",jc(vc.dataset))
  76. // clog("d3_","filmstrip_tile_handlers","fs_h",vc)
  77. //
  78. /*
  79. bottom: 570
  80. height: 285
  81. left: 659
  82. right: 1318
  83. top: 285
  84. width: 659
  85. x: 659
  86. y: 285*/
  87. // var bottom,height,left,right,top,width,x,y
  88. var bcr,bcr_
  89. var bcr0
  90. var jvc = $(vc)
  91. bcr0 = vc.getBoundingClientRect()
  92. bcr_ = vc.parentNode.getBoundingClientRect()
  93. bcr = jc(bcr_)
  94. // bcr.height -= 50
  95. if (bcr.width){
  96. // bcr_ = bcr
  97. // clog("d3_z",bcr_,vc ,vc.parentNode)
  98. }
  99. //
  100. // jvc.css({width:bcr.width,height:bcr.height - 50})
  101. // RC I think I set css this way so it dosen't resize weird
  102. // this is awkward TODO refactor
  103. // glob_mx.override_fns.iapx_hdec? glob_mx.override_fns.iapx_hdec(n):0
  104. if (glob_mx.override_fns.fth_vc_css){
  105. // clog("vcx",jc({vc,bcr0,bcr,bcr_,jvc}))
  106. let dc = vc.dataset.corner
  107. // clog("vcx_"+dc,jc({vc,bcr0,bcr,bcr_,jvc}))
  108. // clog("vcx_"+dc,jc(bcr),bcr)
  109. // clog("vcx_"+dc,jc(bcr),bcr,bcr_)
  110. glob_mx.override_fns.fth_vc_css({bcr0,bcr,bcr_,jvc})
  111. // clog("vcx_"+dc,bcr,bcr_)
  112. // clog("vcx_"+dc,bcr,bcr_,vc.parentNode.getBoundingClientRect())
  113. } else {
  114. jvc.css({width:bcr.width,height:bcr.height})
  115. }
  116. // jvc.css({width:bcr.width,height:bcr.height,"--findme":"findme", })
  117. // clog("dbg_ jvc",jvc)
  118. let {bottom,height,left,right,top,width,x,y} = bcr
  119. var vids = $(vc).find(".small_vid")
  120. const numberOfParticipants = $(vc).find(".small_vid").length
  121. const TILE_ASPECT_RATIO = 16 / 9;
  122. const viewAspectRatio = width / height;
  123. const ratioOfRatios = TILE_ASPECT_RATIO / viewAspectRatio;
  124. // clog("RA",ratioOfRatios,numberOfParticipants)
  125. if (numberOfParticipants < 1){
  126. return
  127. }
  128. // console.trace("QX2z")
  129. // return
  130. const tileGrid = calcTileGrid_x(1/ratioOfRatios, numberOfParticipants);
  131. var t_height,t_width
  132. var t_height_2,t_width_2
  133. // var
  134. // t_height = Math.floor(height/tileGrid.rows)
  135. // if (tileGrid.constraint){
  136. t_width = Math.floor(width/tileGrid.rows)
  137. t_width = t_width - 10
  138. t_height = t_width / TILE_ASPECT_RATIO
  139. // } else {
  140. t_height_2 = Math.floor(height/tileGrid.columns)
  141. t_height_2 = t_height_2 - 10
  142. t_width_2 = t_height_2 * TILE_ASPECT_RATIO
  143. // }
  144. if (t_width > t_width_2){
  145. t_width = t_width_2
  146. t_height = t_height_2
  147. }
  148. // t_width =
  149. // t_width = Math.floor(height/tileGrid.rows)
  150. // t_height = t_width / TILE_ASPECT_RATIO
  151. // t_width = t_width - 52
  152. // t_height = t_height - 52
  153. // vids
  154. var css_obj = {
  155. "min-width":window.mfl?"":t_width,
  156. "min-height":window.mfl?"":t_height,
  157. width:t_width,
  158. // "--findme":"findme2",
  159. // "--fnd_me":"13",
  160. // "--fnd_me":"",
  161. // height:t_height - 50,
  162. height:t_height ,
  163. }
  164. // glob_mx.h_scope.height ?
  165. // if (!glob_mx.h_scope.height || glob_mx.h_scope.height < t_height){
  166. // if (glob_mx.h_scope.height < t_height){
  167. if (glob_mx.h_scope.height > t_height){
  168. glob_mx.h_scope.height = t_height
  169. glob_mx.h_scope.width = t_width
  170. }
  171. resize_thumbs_proto(vids,css_obj)
  172. rs_cb(vids)
  173. fix_avatar(vids)
  174. // let {bottom,height,left,right,top,width,x,y} = vc.getBoundingClientRect()
  175. // clog("fs_h FN TILE HANDLER",vc.className,$(vc).find(".small_vid").length,tileGrid,{height,width,t_height,t_width})
  176. // vid_container
  177. }
  178. glob_mx.filmstrip_handlers["fsx"] = function function_name(argument) {
  179. clog("fsx FN HANDLER")
  180. }
  181. glob_mx.filmstrip_tile_handlers["fsx"] = function function_name(argument) {
  182. clog("fsx FN TILE HANDLER")
  183. }
  184. glob_mx.filmstrip_handlers["fsx2"] = function function_name(argument) {
  185. clog("fsx2 FN HANDLER")
  186. }
  187. glob_mx.filmstrip_tile_handlers["fsx2"] = function function_name(argument) {
  188. clog("fsx2 FN TILE HANDLER")
  189. }
  190. function fix_avatar(vid){
  191. var k,v,bcr
  192. for (v of $(vid).filter(".remote_vid,.local_vid")){
  193. bcr = v.getBoundingClientRect()
  194. var avi_dim = Math.ceil(bcr.height * .55)
  195. $(v).find(".avatar-container").css({
  196. width:avi_dim,
  197. height:avi_dim,
  198. })
  199. }
  200. }
  201. function fix_avatar_lv(vid){
  202. var k,v,bcr
  203. // $("#dominantSpeakerAvatar")
  204. v = $("#largeVideoContainer")[0]
  205. // for (v of $(vid).filter(".remote_vid,.local_vid")){
  206. bcr = v.getBoundingClientRect()
  207. // $(v).find(".avatar-container").css({
  208. // $(v).find("#dominantSpeakerAvatar").css({
  209. // $(v).find("#dominantSpeakerAvatarContainer").css({
  210. var zx = bcr.height * .75
  211. // bcr.height
  212. var zoom =1
  213. if (zx < 300){
  214. zoom = zx/300
  215. } else {
  216. zoom =1
  217. }
  218. $(v).find("#dominantSpeaker").css({zoom
  219. // width:Math.ceil(bcr.height * .75),
  220. // height:Math.ceil(bcr.height * .75),
  221. })
  222. // }
  223. }
  224. dflt_css_proto = {
  225. 'padding-top': '',
  226. "max-height": ``,
  227. "min-height": ``,
  228. "max-width": ``,
  229. "min-width": ``,
  230. width: ``,
  231. height: ``,
  232. top: ``,
  233. left: ``,
  234. bottom: ``,
  235. right: ``,
  236. position:``,
  237. tramsform:``,
  238. // right: ``,
  239. // right: ``,
  240. }
  241. function resize_thumbs_proto(thumbs,css_arg){
  242. var k,v
  243. let css
  244. if (Array.isArray(css_arg)){
  245. css = Object.assign({},dflt_css_proto,...css_arg)
  246. } else {
  247. css = Object.assign({},dflt_css_proto,css_arg)
  248. }
  249. if (typeof(css.data) == "object"){
  250. try{
  251. Object.assign($(thumbs)[0].dataset,css.data)
  252. } catch(err) {
  253. clog("dataset err",err)
  254. }
  255. }
  256. css["--vdim"] = `"${css.width} x ${css.height}"`
  257. $(thumbs).css(css)
  258. }
  259. function calcTileGrid_x(ratio, tilesParam) {
  260. let rows = 1;
  261. let columns = 1;
  262. let availableTiles = 1;
  263. let tiles = tilesParam;
  264. let constraint = 0;
  265. let all = []
  266. // Someone could give you ratio = 0 and/or tiles = Infinity
  267. if (tiles > 65536 || tiles < 1 || isNaN(tiles)) {
  268. tiles = 1;
  269. }
  270. if ( ratio <= 0 || isNaN(ratio)) {
  271. ratio = 1;
  272. }
  273. while (availableTiles < tiles) {
  274. if ((columns + 1) * ratio < rows + 1) {
  275. columns++;
  276. constraint = false
  277. } else {
  278. rows++;
  279. constraint = true
  280. }
  281. all.push({r:rows,c:columns,b:constraint})
  282. availableTiles = rows * columns;
  283. }
  284. let r2 = rows
  285. let c2 = columns
  286. if (constraint){
  287. while ((c2 + 1) * ratio < r2 + 1){
  288. c2+=1
  289. }
  290. } else {
  291. while (!((c2 + 1) * ratio < r2 + 1)){
  292. r2+=1
  293. }
  294. }
  295. return {
  296. rows,
  297. columns,
  298. availableTiles,
  299. tiles,
  300. constraint,
  301. all,
  302. r2,
  303. c2,
  304. };
  305. }
  306. dispatch_resize()
  307. // glob_mx.filmstrip_tile_handlers["fsx"] = glob_mx.filmstrip_tile_handlers["fsx2"]
  308. // glob_mx.filmstrip_handlers["fsx"] = glob_mx.filmstrip_handlers["fsx2"]