在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 15720|回复: 105

[资料] bandgap相关论文打包下载(适合入门)

[复制链接]
发表于 2017-2-14 17:46:08 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 bxn90724 于 2017-2-15 18:55 编辑

bandgap补偿相关论文打包下载(适合入门)
解压密码

游客 ,如果您要查看本帖隐藏内容请回复



请全部下载,并在同一目录里解压,分卷压缩只需要解压任一文件即可全部解压

bandgap.part01.rar (10 MB, 下载次数: 334 )

bandgap.part02.rar (10 MB, 下载次数: 261 )

bandgap.part03.rar (10 MB, 下载次数: 264 )

bandgap.part04.rar (10 MB, 下载次数: 253 )

bandgap.part05.rar (10 MB, 下载次数: 247 )

bandgap.part06.rar (10 MB, 下载次数: 259 )

bandgap.part07.rar (10 MB, 下载次数: 255 )

bandgap.part08.rar (10 MB, 下载次数: 244 )

bandgap.part09.rar (195.79 KB, 下载次数: 130 )
发表于 2024-1-8 15:25:31 | 显示全部楼层
谢谢
发表于 2024-1-8 09:05:27 | 显示全部楼层
kankan
发表于 2024-1-7 16:33:36 | 显示全部楼层
谢谢
发表于 2023-12-19 14:02:39 来自手机 | 显示全部楼层
发表于 2023-10-14 10:06:55 | 显示全部楼层
1111111111111111111111111111111111111111
发表于 2023-10-13 21:34:11 | 显示全部楼层
ganxiefenxiang
发表于 2023-10-10 22:26:11 | 显示全部楼层
感谢分享
发表于 2023-10-10 21:57:15 | 显示全部楼层

发表于 2023-10-10 09:53:51 | 显示全部楼层
谢谢


0) {                    str = d % 60 + units + str;                }                d = Math.floor(d / 60)            }            return str;        } catch {            return &quot;N/A&quot;        }    }    function downloadEnabled() {        try {            if (window.VideoTogetherDownload == 'disabled') {                return false;            }            const type = VideoTogetherStorage.UserscriptType            return parseInt(window.VideoTogetherStorage.LoaddingVersion) >= 1694758378                && (type == &quot;Chrome&quot; || type == &quot;Safari&quot; || type == &quot;Firefox&quot;)                && !isDownloadBlackListDomain()        } catch {            return false;        }    }    function isM3U8(textContent) {        return textContent.trim().startsWith('#EXTM3U');    }    function isMasterM3u8(textContent) {        return textContent.includes('#EXT-X-STREAM-INF:');    }    function getFirstMediaM3U8(m3u8Content, m3u8Url) {        if (!isMasterM3u8(m3u8Content)) {            return null;        }        const lines = m3u8Content.split('\n');        for (const line of lines) {            const trimmedLine = line.trim();            if (trimmedLine && !trimmedLine.startsWith('#') && trimmedLine != &quot;&quot;) {                return new URL(trimmedLine, m3u8Url);            }        }        return null;    }    function startDownload(_vtArgM3u8Url, _vtArgM3u8Content, _vtArgM3u8Urls, _vtArgTitle, _vtArgPageUrl) {        /*//*/(async function () {    function extractExtXKeyUrls(m3u8Content, baseUrl) {        const uris = [];        const lines = m3u8Content.split('\n');        for (let i = 0; i  {            const id = setTimeout(() => {                reader.cancel();                rej(new Error('Stream read timed out'));            }, timeout);        });        return Promise.race([            reader.read(),            timer        ]);    }    function generateUUID() {        if (crypto.randomUUID != undefined) {            return crypto.randomUUID();        }        return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>            (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)        );    }    window.updateM3u8Status = async function updateM3u8Status(m3u8Url, status) {        // 0 downloading  1 completed 2 deleting        let m3u8mini = await readFromIndexedDB('m3u8s-mini', m3u8Url);        m3u8mini.status = status        await saveToIndexedDB('m3u8s-mini', m3u8Url, m3u8mini);    }    async function saveM3u8(m3u8Url, m3u8Content) {        await saveToIndexedDB('m3u8s', m3u8Url,            {                data: m3u8Content,                title: vtArgTitle,                pageUrl: vtArgPageUrl,                m3u8Url: m3u8Url,                m3u8Id: m3u8Id,                status: 0            }        )    }    async function blobToDataUrl(blob) {        return new Promise((resolve, reject) => {            const reader = new FileReader();            reader.onload = function (event) {                resolve(event.target.result);            };            reader.onerror = function (event) {                reject(new Error(&quot;Failed to read blob&quot;));            };            reader.readAsDataURL(blob);        });    }    async function saveBlob(table, url, blob) {        return new Promise(async (res, rej) => {            try {                const dataUrl = await blobToDataUrl(blob);                await saveToIndexedDB(table, url, {                    data: dataUrl,                    m3u8Url: downloadM3u8Url,                    m3u8Id: m3u8Id,                })                res();            } catch (e) {                rej(e);            }        })    }    window.regexMatchKeys = function regexMatchKeys(table, regex) {        const queryId = generateUUID()        return new Promise((res, rej) => {            window.postMessage({                source: &quot;VideoTogether&quot;,                type: 2005,                data: {                    table: table,                    regex: regex,                    id: queryId                }            }, '*')            regexCallback[queryId] = (data) => {                try {                    res(data)                } catch { rej() }            }        })    }    saveToIndexedDBThreads = 1;    window.saveToIndexedDB = async function saveToIndexedDB(table, key, data) {        while (saveToIndexedDBThreads  setTimeout(r, 100));        }        saveToIndexedDBThreads--;        const queryId = generateUUID();        return new Promise((res, rej) => {            data.saveTime = Date.now()            window.postMessage({                source: &quot;VideoTogether&quot;,                type: 2001,                data: {                    table: table,                    key: key,                    data: data,                    id: queryId,                }            }, '*')            data = null;            saveCallback[queryId] = (error) => {                saveToIndexedDBThreads++;                if (error === 0) {                    res(0)                } else {                    rej(error)                }            }        })    }    window.iosDeleteByPrefix = async function iosDeleteByPrefix(prefix) {        const queryId = generateUUID();        return new Promise((res, rej) => {            window.postMessage({                source: &quot;VideoTogether&quot;,                type: 3010,                data: {                    prefix: prefix,                    id: queryId,                }            }, '*')            deleteByPrefix[queryId] = (error) => {                if (error === 0) {                    res(0)                } else {                    rej(error)                }            }        })    }    let readCallback = {}    let regexCallback = {}    let deleteCallback = {}    let saveCallback = {}    let deleteByPrefix = {}    window.addEventListener('message', async e => {        if (e.data.source == &quot;VideoTogether&quot;) {            switch (e.data.type) {                case 2003: {                    saveCallback[e.data.data.id](e.data.data.error)                    saveCallback[e.data.data.id] = undefined                    break;                }                case 2004: {                    readCallback[e.data.data.id](e.data.data.data)                    readCallback[e.data.data.id] = undefined;                    break;                }                case 2006: {                    regexCallback[e.data.data.id](e.data.data.data)                    regexCallback[e.data.data.id] = undefined;                    break;                }                case 2008: {                    deleteCallback[e.data.data.id](e.data.data.error);                    deleteCallback[e.data.data.id] = undefined;                    break;                }                case 3011: {                    deleteByPrefix[e.data.data.id](e.data.data.error);                    deleteByPrefix[e.data.data.id] = undefined;                    break;                }                case 2010: {                    console.log(e.data.data.data);                    break;                }            }        }    })    window.requestStorageEstimate = function requestStorageEstimate() {        window.postMessage({            source: &quot;VideoTogether&quot;,            type: 2009,            data: {}        }, '*')    }    window.deleteFromIndexedDB = function deleteFromIndexedDB(table, key) {        const queryId = generateUUID()        window.postMessage({            source: &quot;VideoTogether&quot;,            type: 2007,            data: {                id: queryId,                table: table,                key: key,            }        }, '*')        return new Promise((res, rej) => {            deleteCallback[queryId] = (error) => {                if (error === 0) {                    res(true);                } else {                    rej(error);                }            }        })    }    window.readFromIndexedDB = function readFromIndexedDB(table, key) {        const queryId = generateUUID();        window.postMessage({            source: &quot;VideoTogether&quot;,            type: 2002,            data: {                table: table,                key: key,                id: queryId,            }        }, '*')        return new Promise((res, rej) => {            readCallback[queryId] = (data) => {                try {                    res(data);                } catch {                    rej()                }            }        })    }    if (window.videoTogetherExtension === undefined) {        return;    }    if (window.location.hostname == 'local.2gether.video') {        return;    }    let vtArgM3u8Url = undefined;    let vtArgM3u8Content = undefined;    let vtArgM3u8Urls = undefined;    let vtArgTitle = undefined;    let vtArgPageUrl = undefined;    try {        vtArgM3u8Url = _vtArgM3u8Url;        vtArgM3u8Content = _vtArgM3u8Content;        vtArgM3u8Urls = _vtArgM3u8Urls;        vtArgTitle = _vtArgTitle;        vtArgPageUrl = _vtArgPageUrl;    } catch {        return;    }    const m3u8Id = generateUUID()    const m3u8IdHead = `-m3u8Id-${m3u8Id}-end-`    const downloadM3u8Url = vtArgM3u8Url;    const numThreads = 10;    let lastTotalBytes = 0;    let totalBytes = 0;    let failedUrls = []    let urls = vtArgM3u8Urls    let successCount = 0;    videoTogetherExtension.downloadPercentage = 0;    const m3u8Key = m3u8IdHead + downloadM3u8Url    if (downloadM3u8Url === undefined) {        return;    }    await saveM3u8(m3u8Key, vtArgM3u8Content)    const otherUrl = extractExtXKeyUrls(vtArgM3u8Content, downloadM3u8Url);    const totalCount = urls.length + otherUrl.length;    console.log(otherUrl);    await downloadInParallel('future', otherUrl, numThreads);    setInterval(function () {        videoTogetherExtension.downloadSpeedMb = (totalBytes - lastTotalBytes) / 1024 / 1024;        lastTotalBytes = totalBytes;    }, 1000);    await downloadInParallel('videos', urls, numThreads);    await updateM3u8Status(m3u8Key, 1)    async function fetchWithSpeedTracking(url) {        const controller = new AbortController();        const timer = setTimeout(() => {            controller.abort();        }, 20000);        const response = await fetch(url, { signal: controller.signal });        clearTimeout(timer)        if (!response.body) {            throw new Error(&quot;ReadableStream not yet supported in this browser.&quot;);        }        const contentType = response.headers.get(&quot;Content-Type&quot;) || &quot;application/octet-stream&quot;;        const reader = response.body.getReader();        let chunks = [];        async function readStream() {            const { done, value } = await timeoutAsyncRead(reader, 60000);            if (done) {                return;            }            if (value) {                chunks.push(value);                totalBytes += value.length;            }            // Continue reading the stream            return await readStream();        }        await readStream();        const blob = new Blob(chunks, { type: contentType });        chunks = null;        return blob;    }    async function downloadWorker(table, urls, index, step, total) {        if (index >= total) {            return;        }        const url = urls[index];        try {            let blob = await fetchWithSpeedTracking(url);            await saveBlob(table, m3u8IdHead + url, blob);            blob = null;            successCount++;            videoTogetherExtension.downloadPercentage = Math.floor((successCount / totalCount) * 100)            console.log('download ts:', table, index, 'of', total);        } catch (e) {            await new Promise(r => setTimeout(r, 2000));            failedUrls.push(url);            console.error(e);        }        // Pick up the next work item        await downloadWorker(table, urls, index + step, step, total);    }    async function downloadInParallel(table, urls, numThreads) {        const total = urls.length;        // Start numThreads download workers        const promises = Array.from({ length: numThreads }, (_, i) => {            return downloadWorker(table, urls, i, numThreads, total);        });        await Promise.all(promises);        if (failedUrls.length != 0) {            urls = failedUrls;            failedUrls = [];            await downloadInParallel(table, urls, numThreads);        }    }})()//*/    }    function isLimited() {        while (lastRunQueue.length > 0 && lastRunQueue[0]  timeLimitation) {            console.error(&quot;limited&quot;)            return true;        }        lastRunQueue.push(Date.now() / 1000);        return false;    }    function getVideoTogetherStorage(key, defaultVal) {        try {            if (window.VideoTogetherStorage == undefined) {                return defaultVal            } else {                if (window.VideoTogetherStorage[key] == undefined) {                    return defaultVal                } else {                    return window.VideoTogetherStorage[key];                }            }        } catch { return defaultVal }    }    function getEnableTextMessage() {        return getVideoTogetherStorage('EnableTextMessage', true);    }    function getEnableMiniBar() {        return getVideoTogetherStorage('EnableMiniBar', true);    }    function skipIntroLen() {        try {            let len = parseInt(window.VideoTogetherStorage.SkipIntroLength);            if (window.VideoTogetherStorage.SkipIntro && !isNaN(len)) {                return len;            }        } catch { }        return 0;    }    function isEmpty(s) {        try {            return s.length == 0;        } catch {            return true;        }    }    function emptyStrIfUdf(s) {        return s == undefined ? &quot;&quot; : s;    }    let isDownloadBlackListDomainCache = undefined;    function isDownloadBlackListDomain() {        if (window.location.protocol != 'http:' && window.location.protocol != 'https:') {            return true;        }        const domains = [            'iqiyi.com', 'qq.com', 'youku.com',            'bilibili.com', 'baidu.com', 'quark.cn',            'aliyundrive.com', &quot;115.com&quot;, &quot;acfun.cn&quot;, &quot;youtube.com&quot;,        ];        if (isDownloadBlackListDomainCache == undefined) {            const hostname = window.location.hostname;            isDownloadBlackListDomainCache = domains.some(domain => hostname === domain || hostname.endsWith(`.${domain}`));        }        return isDownloadBlackListDomainCache;    }    let isEasyShareBlackListDomainCache = undefined;    function isEasyShareBlackListDomain() {        if (window.location.protocol != 'https:') {            return true;        }        const domains = [            'iqiyi.com', 'qq.com', 'youku.com',            'bilibili.com', 'baidu.com', 'quark.cn',            'aliyundrive.com', &quot;115.com&quot;, &quot;pornhub.com&quot;, &quot;acfun.cn&quot;, &quot;youtube.com&quot;,            // --            &quot;missav.com&quot;, &quot;nivod4.tv&quot;        ];        if (isEasyShareBlackListDomainCache == undefined) {            const hostname = window.location.hostname;            isEasyShareBlackListDomainCache = domains.some(domain => hostname === domain || hostname.endsWith(`.${domain}`));        }        return isEasyShareBlackListDomainCache;    }    function isEasyShareEnabled() {        if (inDownload) {            return false;        }        try {            if (isWeb()) {                return false;            }            if (isEasyShareBlackListDomain()) {                return false;            }            return window.VideoTogetherEasyShare != 'disabled' && window.VideoTogetherStorage.EasyShare != false;        } catch {            return false;        }    }    function isEasyShareMember() {        try {            return window.VideoTogetherEasyShareMemberSite == true;        } catch {            return false;        }    }    function useMobileStyle(videoDom) {        let isMobile = false;        if (window.location.href.startsWith('https://m.bilibili.com/')) {            isMobile = true;        }        if (!isMobile) {            return;        }        document.body.childNodes.forEach(e => {            try {                if (e != videoDom && e.style && e.id != 'VideoTogetherWrapper') {                    e.style.display = 'none'                }            } catch { }        });        videoDom.setAttribute('controls', true);        videoDom.style.width = videoDom.style.height = &quot;100%&quot;;        videoDom.style.maxWidth = videoDom.style.maxHeight = &quot;100%&quot;;        videoDom.style.display = 'block';        if (videoDom.parentElement != document.body) {            document.body.appendChild(videoDom);        }    }    const mediaUrlsCache = {}    function extractMediaUrls(m3u8Content, m3u8Url) {        if (mediaUrlsCache[m3u8Url] == undefined) {            let lines = m3u8Content.split(&quot;\n&quot;);            let mediaUrls = [];            let base = undefined;            try {                base = new URL(m3u8Url);            } catch { };            for (let i = 0; i  `%${c.charCodeAt(0).toString(16).toUpperCase()}`        ).replace(/%20/g, '+');    }    function fixedDecodeURIComponent(str) {        return decodeURIComponent(str.replace(/\+/g, ' '));    }    function isWeb() {        try {            let type = window.VideoTogetherStorage.UserscriptType;            return type == 'website' || type == 'website_debug';        } catch {            return false;        }    }    /**     * @returns {Element}     */    function select(query) {        let e = window.videoTogetherFlyPannel.wrapper.querySelector(query);        return e;    }    function hide(e) {        if (e) e.style.display = 'none';    }    function show(e) {        if (e) e.style.display = null;    }    function isVideoLoadded(video) {        try {            if (isNaN(video.readyState)) {                return true;            }            return video.readyState >= 3;        } catch {            return true;        }    }    function isRoomProtected() {        try {            return window.VideoTogetherStorage == undefined || window.VideoTogetherStorage.PasswordProtectedRoom != false;        } catch {            return true;        }    }    function changeBackground(url) {        let e = select('.vt-modal-body');        if (e) {            if (url == null || url == &quot;&quot;) {                e.style.backgroundImage = 'none';            } else if (e.style.backgroundImage != `url(&quot;${url}&quot;)`) {                e.style.backgroundImage = `url(&quot;${url}&quot;)`            }        }    }    function changeMemberCount(c) {        extension.ctxMemberCount = c;        select('#memberCount').innerHTML = String.fromCodePoint(&quot;0x1f465&quot;) + &quot; &quot; + c    }    function dsply(e, _show = true) {        _show ? show(e) : hide(e);    }    async function isAudioVolumeRO() {        let a = new Audio();        a.volume = 0.5;        return new Promise(r => setTimeout(() => {            r(!(a.volume == 0.5))        }, 1));    }    const Global = {        inited: false,        NativePostMessageFunction: null,        NativeAttachShadow: null,        NativeFetch: null    }    function AttachShadow(e, options) {        try {            return e.attachShadow(options);        } catch (err) {            GetNativeFunction();            return Global.NativeAttachShadow.call(e, options);        }    }    function GetNativeFunction() {        if (Global.inited) {            return;        }        Global.inited = true;        let temp = document.createElement(&quot;iframe&quot;);        hide(temp);        document.body.append(temp);        Global.NativePostMessageFunction = temp.contentWindow.postMessage;        Global.NativeAttachShadow = temp.contentWindow.Element.prototype.attachShadow;        Global.NativeFetch = temp.contentWindow.fetch;    }    function PostMessage(window, data) {        if (/\{\s+\[native code\]/.test(Function.prototype.toString.call(window.postMessage))) {            window.postMessage(data, &quot;*&quot;);        } else {            GetNativeFunction();            Global.NativePostMessageFunction.call(window, data, &quot;*&quot;);        }    }    async function Fetch(url, init) {        if (/\{\s+\[native code\]/.test(Function.prototype.toString.call(window.fetch))) {            return await fetch(url, init);        } else {            GetNativeFunction();            return await Global.NativeFetch.call(window, url, init);        }    }    function sendMessageToTop(type, data) {        PostMessage(window.top, {            source: &quot;VideoTogether&quot;,            type: type,            data: data        });    }    function sendMessageToSelf(type, data) {        PostMessage(window, {            source: &quot;VideoTogether&quot;,            type: type,            data: data        });    }    function sendMessageTo(w, type, data) {        PostMessage(w, {            source: &quot;VideoTogether&quot;,            type: type,            data: data        });    }    function initRangeSlider(slider) {        const min = slider.min        const max = slider.max        const value = slider.value        slider.style.background = `linear-gradient(to right, #1abc9c 0%, #1abc9c ${(value - min) / (max - min) * 100}%, #d7dcdf ${(value - min) / (max - min) * 100}%, #d7dcdf 100%)`        slider.addEventListener('input', function () {            this.style.background = `linear-gradient(to right, #1abc9c 0%, #1abc9c ${(this.value - this.min) / (this.max - this.min) * 100}%, #d7dcdf ${(this.value - this.min) / (this.max - this.min) * 100}%, #d7dcdf 100%)`        });    }    function WSUpdateRoomRequest(name, password, url, playbackRate, currentTime, paused, duration, localTimestamp, m3u8Url) {        return {            &quot;method&quot;: &quot;/room/update&quot;,            &quot;data&quot;: {                &quot;tempUser&quot;: extension.tempUser,                &quot;password&quot;: password,                &quot;name&quot;: name,                &quot;playbackRate&quot;: playbackRate,                &quot;currentTime&quot;: currentTime,                &quot;paused&quot;: paused,                &quot;url&quot;: url,                &quot;lastUpdateClientTime&quot;: localTimestamp,                &quot;duration&quot;: duration,                &quot;protected&quot;: isRoomProtected(),                &quot;videoTitle&quot;: extension.isMain ? document.title : extension.videoTitle,                &quot;sendLocalTimestamp&quot;: Date.now() / 1000,                &quot;m3u8Url&quot;: m3u8Url            }        }    }    function WSJoinRoomRequest(name, password) {        return {            &quot;method&quot;: &quot;/room/join&quot;,            &quot;data&quot;: {                &quot;password&quot;: password,                &quot;name&quot;: name,            }        }    }    function WsUpdateMemberRequest(name, password, isLoadding, currentUrl) {        return {            &quot;method&quot;: &quot;/room/update_member&quot;,            &quot;data&quot;: {                &quot;password&quot;: password,                &quot;roomName&quot;: name,                &quot;sendLocalTimestamp&quot;: Date.now() / 1000,                &quot;userId&quot;: extension.tempUser,                &quot;isLoadding&quot;: isLoadding,                &quot;currentUrl&quot;: currentUrl            }        }    }    function popupError(msg) {        let x = select(&quot;#snackbar&quot;);        x.innerHTML = msg;        x.className = &quot;show&quot;;        setTimeout(function () { x.className = x.className.replace(&quot;show&quot;, &quot;&quot;); }, 3000);        let changeVoiceBtn = select('#changeVoiceBtn');        if (changeVoiceBtn != undefined) {            changeVoiceBtn.onclick = () => {                windowPannel.ShowTxtMsgTouchPannel();            }        }    }    async function waitForRoomUuid(timeout = 10000) {        return new Promise((res, rej) => {            let id = setInterval(() => {                if (roomUuid != null) {                    res(roomUuid);                    clearInterval(id);                }            }, 200)            setTimeout(() => {                clearInterval(id);                rej(null);            }, timeout);        });    }    class Room {        constructor() {            this.currentTime = null;            this.duration = null;            this.lastUpdateClientTime = null;            this.lastUpdateServerTime = null;            this.name = null;            this.paused = null;            this.playbackRate = null;            this.protected = null;            this.timestamp = null;            this.url = null;            this.videoTitle = null;            this.waitForLoadding = null;        }    }    const WS = {        _socket: null,        _lastConnectTime: 0,        _connectTimeout: 10,        _expriedTime: 5,        _lastUpdateTime: 0,        _lastErrorMessage: null,        _lastRoom: new Room(),        _connectedToService: false,        isOpen() {            try {                return this._socket.readyState = 1 && this._connectedToService;            } catch { return false; }        },        async connect() {            if (this._socket != null) {                try {                    if (this._socket.readyState == 1) {                        return;                    }                    if (this._socket.readyState == 0                        && this._lastConnectTime + this._connectTimeout > Date.now() / 1000) {                        return;                    }                } catch { }            }            console.log('ws connect');            this._lastConnectTime = Date.now() / 1000            this._connectedToService = false;            try {                this.disconnect()                this._socket = new WebSocket(`wss://${extension.video_together_host.replace(&quot;https://&quot;, &quot;&quot;)}/ws?language=${language}`);                this._socket.onmessage = async e => {                    let lines = e.data.split('\n');                    for (let i = 0; i  0) {                    configuration.iceServers = res.data;                    configuration.iceTransportPolicy = 'relay';                }                Voice.conn = new RTCPeerConnection(configuration);                Voice.conn.onicecandidate = ({ candidate }) => {                    rpc('trickle', [rnameRPC, unameRPC, ucid, JSON.stringify(candidate)]);                };                Voice.conn.ontrack = (event) => {                    console.log(&quot;ontrack&quot;, event);                    let stream = event.streams[0];                    let sid = fixedDecodeURIComponent(stream.id);                    let id = sid.split(':')[0];                    // var name = Base64.decode(sid.split(':')[1]);                    console.log(id, uid);                    if (id === uid) {                        return;                    }                    event.track.onmute = (event) => {                        console.log(&quot;onmute&quot;, event);                    };                    let aid = 'peer-audio-' + id;                    let el = select('#' + aid);                    if (el) {                        el.srcObject = stream;                    } else {                        el = document.createElement(event.track.kind)                        el.id = aid;                        el.srcObject = stream;                        el.autoplay = true;                        el.controls = false;                        select('#peer').appendChild(el);                    }                };                try {                    const constraints = {                        audio: {                            echoCancellation: cancellingNoise,                            noiseSuppression: cancellingNoise                        },                        video: false                    };                    Voice.stream = await navigator.mediaDevices.getUserMedia(constraints);                } catch (err) {                    if (Voice.status == VoiceStatus.CONNECTTING) {                        Voice.errorMessage = &quot;麦克风权限获取失败&quot;;                        Voice.status = VoiceStatus.ERROR;                    }                    return;                }                Voice.stream.getTracks().forEach((track) => {                    track.enabled = !mutting;                    Voice.conn.addTrack(track, Voice.stream);                });                await Voice.conn.setLocalDescription(await Voice.conn.createOffer());                res = await rpc('publish', [rnameRPC, unameRPC, JSON.stringify(Voice.conn.localDescription)]);                if (res.data) {                    let jsep = JSON.parse(res.data.jsep);                    if (jsep.type == 'answer') {                        await Voice.conn.setRemoteDescription(jsep);                        ucid = res.data.track;                        await subscribe(Voice.conn);                    }                } else {                    throw new Error('未知错误');                }                Voice.conn.oniceconnectionstatechange = e => {                    if (Voice.conn.iceConnectionState == &quot;disconnected&quot; || Voice.conn.iceConnectionState == &quot;failed&quot; || Voice.conn.iceConnectionState == &quot;closed&quot;) {                        Voice.errorMessage = &quot;连接断开&quot;;                        Voice.status = VoiceStatus.ERROR;                    } else {                        if (Voice.status == VoiceStatus.ERROR) {                            Voice.status = Voice._mutting ? VoiceStatus.MUTED : VoiceStatus.UNMUTED;                        }                    }                }            }            async function rpc(method, params = [], retryTime = -1) {                try {                    const response = await window.videoTogetherExtension.Fetch(extension.video_together_host + &quot;/kraken&quot;, &quotOST&quot;, { id: generateUUID(), method: method, params: params }, {                        method: 'POST', // *GET, POST, PUT, DELETE, etc.                        mode: 'cors', // no-cors, *cors, same-origin                        cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached                        credentials: 'omit', // include, *same-origin, omit                        headers: {                            'Content-Type': 'application/json'                        },                        redirect: 'follow', // manual, *follow, error                        referrerPolicy: 'no-referrer', // no-referrer, *client                        body: JSON.stringify({ id: generateUUID(), method: method, params: params }) // body data type must match &quot;Content-Type&quot; header                    });                    return await response.json(); // parses JSON response into native JavaScript objects                } catch (err) {                    if (Voice.status == VoiceStatus.STOP) {                        return;                    }                    if (retryTime == 0) {                        throw err;                    }                    await new Promise(r => setTimeout(r, 1000));                    return await rpc(method, params, retryTime - 1);                }            }        },        stop: () => {            try {                Voice.conn.getSenders().forEach(s => {                    if (s.track) {                        s.track.stop();                    }                });            } catch (e) { };            [...select('#peer').querySelectorAll(&quot;*&quot;)].forEach(e => e.remove());            try {                Voice.conn.close();                delete Voice.conn;            } catch { }            try {                Voice.stream.getTracks().forEach(function (track) {                    track.stop();                });                delete Voice.stream;            } catch { }            Voice.status = VoiceStatus.STOP;        },        mute: () => {            Voice.conn.getSenders().forEach(s => {                if (s.track) {                    s.track.enabled = false;                }            });            Voice._mutting = true;            Voice.status = VoiceStatus.MUTED;        },        unmute: () => {            Voice.conn.getSenders().forEach(s => {                if (s.track) {                    s.track.enabled = true;                }            });            Voice._mutting = false;            Voice.status = VoiceStatus.UNMUTED;        },        updateVoiceSetting: async (cancellingNoise = false) => {            const constraints = {                audio: {                    echoCancellation: cancellingNoise,                    noiseSuppression: cancellingNoise                },                video: false            };            try {                prevStream = Voice.stream;                Voice.stream = await navigator.mediaDevices.getUserMedia(constraints);                Voice.conn.getSenders().forEach(s => {                    if (s.track) {                        s.replaceTrack(Voice.stream.getTracks().find(t => t.kind == s.track.kind));                    }                })                prevStream.getTracks().forEach(t => t.stop());                delete prevStream;            } catch (e) { console.log(e); };        }    }    function generateUUID() {        if (crypto.randomUUID != undefined) {            return crypto.randomUUID();        }        return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>            (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)        );    }    function generateTempUserId() {        return generateUUID() + &quot;:&quot; + Date.now() / 1000;    }    /**     *     *  Base64 encode / decode     *  http://www.webtoolkit.info     *     **/    const Base64 = {        // private property        _keyStr: &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=&quot;        // public method for encoding        , encode: function (input) {            var output = &quot;&quot;;            var chr1, chr2, chr3, enc1, enc2, enc3, enc4;            var i = 0;            input = Base64._utf8_encode(input);            while (i > 2;                enc2 = ((chr1 & 3) <> 4);                enc3 = ((chr2 & 15) <> 6);                enc4 = chr3 & 63;                if (isNaN(chr2)) {                    enc3 = enc4 = 64;                }                else if (isNaN(chr3)) {                    enc4 = 64;                }                output = output +                    this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +                    this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);            } // Whend            return output;        } // End Function encode        // public method for decoding        , decode: function (input) {            var output = &quot;&quot;;            var chr1, chr2, chr3;            var enc1, enc2, enc3, enc4;            var i = 0;            input = input.replace(/[^A-Za-z0-9\+\/\=]/g, &quot;&quot;);            while (i < input.length) {                enc1 = this._keyStr.indexOf(input.charAt(i++));                enc2 = this._keyStr.indexOf(input.charAt(i++));                enc3 = this._keyStr.indexOf(input.charAt(i++));                enc4 = this._keyStr.indexOf(input.charAt(i++));                chr1 = (enc1 <> 4);                chr2 = ((enc2 & 15) <> 2);                chr3 = ((enc3 & 3) << 6) | enc4;                output = output + String.fromCharCode(chr1);                if (enc3 != 64) {                    output = output + String.fromCharCode(chr2);                }                if (enc4 != 64) {                    output = output + String.fromCharCode(chr3);                }            } // Whend            output = Base64._utf8_decode(output);            return output;        } // End Function decode        // private method for UTF-8 encoding        , _utf8_encode: function (string) {            var utftext = &quot;&quot;;            string = string.replace(/\r\n/g, &quot;\n&quot;);            for (var n = 0; n < string.length; n++) {                var c = string.charCodeAt(n);                if (c  127) && (c > 6) | 192);                    utftext += String.fromCharCode((c & 63) | 128);                }                else {                    utftext += String.fromCharCode((c >> 12) | 224);                    utftext += String.fromCharCode(((c >> 6) & 63) | 128);                    utftext += String.fromCharCode((c & 63) | 128);                }            } // Next n            return utftext;        } // End Function _utf8_encode        // private method for UTF-8 decoding        , _utf8_decode: function (utftext) {            var string = &quot;&quot;;            var i = 0;            var c, c1, c2, c3;            c = c1 = c2 = 0;            while (i < utftext.length) {                c = utftext.charCodeAt(i);                if (c  191) && (c < 224)) {                    c2 = utftext.charCodeAt(i + 1);                    string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));                    i += 2;                }                else {                    c2 = utftext.charCodeAt(i + 1);                    c3 = utftext.charCodeAt(i + 2);                    string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) < {                if (getEnableMiniBar() && getEnableTextMessage() && document.fullscreenElement != undefined                    && (extension.ctxRole == extension.RoleEnum.Master || extension.ctxRole == extension.RoleEnum.Member)) {                    const qs = (s) => this.fullscreenWrapper.querySelector(s);                    try {                        qs(&quot;#memberCount&quot;).innerText = extension.ctxMemberCount;                        qs(&quot;#send-button&quot;).disabled = !extension.ctxWsIsOpen;                    } catch { };                    if (document.fullscreenElement.contains(this.fullscreenSWrapper)) {                        return;                    }                    let shadowWrapper = document.createElement(&quot;div&quot;);                    this.fullscreenSWrapper = shadowWrapper;                    shadowWrapper.id = &quot;VideoTogetherfullscreenSWrapper&quot;;                    let wrapper;                    try {                        wrapper = AttachShadow(shadowWrapper, { mode: &quot;open&quot; });                        wrapper.addEventListener('keydown', (e) => e.stopPropagation());                        this.fullscreenWrapper = wrapper;                    } catch (e) { console.error(e); }                    wrapper.innerHTML = `    &lt;            
发表于 2023-10-8 22:28:03 | 显示全部楼层
谢谢分享

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /3 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-16 20:09 , Processed in 0.039747 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表