Skip to content

Commit

Permalink
Merge pull request #46 from disoul/release/2.2.0
Browse files Browse the repository at this point in the history
2.2.0
  • Loading branch information
geeklok authored Apr 30, 2019
2 parents e93ffb4 + c6aa433 commit d306b1a
Show file tree
Hide file tree
Showing 10 changed files with 17,591 additions and 68 deletions.
48 changes: 26 additions & 22 deletions Demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@
"@types/seedrandom": "^2.4.27",
"@types/store": "^2.0.1",
"clipboard": "^2.0.4",
"core-js": "^2.6.3",
"flv.js": "^1.5.0",
"lodash": "^4.17.11",
"mobx": "^5.8.0",
"mobx-react": "^5.4.3",
"mobx-react-router": "^4.0.5",
"pili-rtc-web": "^2.1.0-patch.0",
"pili-rtc-web": "2.2.0",
"qs": "^6.6.0",
"react": "^16.6.3",
"react-app-polyfill": "^0.2.0",
"react-avatar": "^3.5.0",
"react-dom": "^16.6.3",
"react-router": "^4.3.1",
Expand Down
4 changes: 3 additions & 1 deletion Demo/src/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ export const PublishRecordOptions: PublishRecordOption<keyof publishRecordConfig
{
key: 'buffer_audio',
label: '音频(外部数据导入)',
/**
* 将采集参数留空,等待使用音频模块来导入外部音频
*/
config: {
audio: { enabled: true, tag: "audio", buffer: true },
},
},
{
Expand Down
14 changes: 1 addition & 13 deletions Demo/src/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { decodeAudioData, TrackBaseInfo } from 'pili-rtc-web';
import { TrackBaseInfo } from 'pili-rtc-web';
import seedrandom from 'seedrandom';

export function randomNumberGen(): number {
Expand All @@ -13,18 +13,6 @@ export const verifyUserId = (str: string): boolean =>
export const verifyRoomId = (str: string): boolean =>
/^[a-zA-Z0-9_-]{3,64}$/.test(str);

export function decodeAudioFileToBuffer(file: File): Promise<AudioBuffer> {
return new Promise(resolve => {
const reader = new FileReader();
reader.onload = (e: any) => {
const data = e.target.result;
decodeAudioData(data).then(resolve);
};

reader.readAsArrayBuffer(file);
});
}

export function getTrackNmae(track: TrackBaseInfo): string {
switch (track.tag) {
case "screen":
Expand Down
4 changes: 4 additions & 0 deletions Demo/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import 'react-app-polyfill/ie9';
import 'core-js/fn/string/pad-start';
import 'core-js/fn/promise/finally';

import * as React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
Expand Down
14 changes: 9 additions & 5 deletions Demo/src/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { observer, inject } from 'mobx-react';
import { UserStore } from '../stores/userStore';
import { RoomStore } from '../stores/roomStore';
import { RouterStore } from 'mobx-react-router';
import { verifyRoomId, verifyUserId, decodeAudioFileToBuffer, getColorFromUserId } from '../common/utils';
import { verifyRoomId, verifyUserId, getColorFromUserId } from '../common/utils';
import { MessageStore } from '../stores/messageStore';
import { PublishRecordOptions } from '../common/config';
import { Link } from 'react-router-dom';
Expand Down Expand Up @@ -144,8 +144,10 @@ class Home extends Component<Props, State> {
});
}
});
const buffer = await decodeAudioFileToBuffer(file);
(config.audio as any).audioBuffer = buffer;
config.audio = {
enabled: true,
source: file,
};
}
}
if (index < 1) {
Expand Down Expand Up @@ -189,8 +191,10 @@ class Home extends Component<Props, State> {
});
}
});
const buffer = await decodeAudioFileToBuffer(file);
(config.audio as any).audioBuffer = buffer;
config.audio = {
enabled: true,
source: file,
};
}
}
// 配置文件置入已选择
Expand Down
21 changes: 11 additions & 10 deletions Demo/src/stores/roomStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
deviceManager,
AudioTrack,
TrackStatsReport,
AudioUtils,
} from 'pili-rtc-web';
import userStore from './userStore';
import { RTC_APP_ID } from '../common/api';
Expand Down Expand Up @@ -329,18 +330,18 @@ export class RoomStore {
Object.assign(config.video, (videoConfig.find(v => v.key === this.selectVideoConfig) || videoConfig[0]).config.video)
}
return deviceManager.getLocalTracks(config)
.then((tracks: RTCTrack[]) => {
.then(async (tracks: RTCTrack[]) => {
for (const track of tracks) {
if (track.info.kind === "audio" && config.audio && config.audio.source) {
track.setLoop(true);
track.startAudioSource();
}
if (track.info.tag === 'camera') {
track.setMaster(true);
}
if (track.info.kind === 'audio') {
track.setMaster(true);
}
if (config.audio && config.audio.buffer) {
track.setAudioBuffer((config.audio as any).audioBuffer as AudioBuffer);
track.playAudioBuffer(true);
}
this.localTracks.push(track);
}
return tracks;
Expand All @@ -356,7 +357,11 @@ export class RoomStore {
}
// 每次只采集了一路流
return deviceManager.getLocalTracks(config)
.then(([ track ]: RTCTrack[] ) => {
.then(async ([ track ]: RTCTrack[] ) => {
if (config.audio && config.audio.source) {
track.setLoop(true);
track.startAudioSource();
}
// 只能发布 一个 video master 和 一个 audio master
if (track.info.kind === 'video' && videoCount === 0) {
track.setMaster(true);
Expand All @@ -366,10 +371,6 @@ export class RoomStore {
track.setMaster(true);
audioCount++;
}
if (config.audio && config.audio.buffer) {
track.setAudioBuffer((config.audio as any).audioBuffer as AudioBuffer);
track.playAudioBuffer(true);
}
this.localTracks.push(track);
return track;
});
Expand Down
22 changes: 13 additions & 9 deletions Demo/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2414,6 +2414,10 @@ core-js@^2.5.7:
version "2.6.3"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.3.tgz#4b70938bdffdaf64931e66e2db158f0892289c49"

core-js@^2.6.3:
version "2.6.5"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.5.tgz#44bc8d249e7fb2ff5d00e0341a7ffb94fbf67895"

[email protected], core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
Expand Down Expand Up @@ -6504,9 +6508,9 @@ pify@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"

pili-rtc-web@^2.1.0-patch.0:
version "2.1.0-patch.0"
resolved "https://registry.yarnpkg.com/pili-rtc-web/-/pili-rtc-web-2.1.0-patch.0.tgz#dec9bbae52c3f08646d1426245f5573eeee416a1"
pili-rtc-web@2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/pili-rtc-web/-/pili-rtc-web-2.2.0.tgz#fef390c31a16938fa3fdf14d0182a14e34d5d0ca"
dependencies:
"@babel/runtime" "^7.3.1"
"@types/detect-browser" "^2.0.1"
Expand All @@ -6522,7 +6526,7 @@ pili-rtc-web@^2.1.0-patch.0:
lodash.uniqby "^4.7.0"
sdp-transform "^2.4.1"
semver "^5.6.0"
webrtc-adapter "^6.4.4"
webrtc-adapter "^7.2.0"
wolfy87-eventemitter "^5.2.5"

pinkie-promise@^2.0.0:
Expand Down Expand Up @@ -7878,7 +7882,7 @@ rsvp@^3.3.3:
version "3.6.2"
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-3.6.2.tgz#2e96491599a96cde1b515d5674a8f7a91452926a"

rtcpeerconnection-shim@^1.2.14:
rtcpeerconnection-shim@^1.2.15:
version "1.2.15"
resolved "https://registry.yarnpkg.com/rtcpeerconnection-shim/-/rtcpeerconnection-shim-1.2.15.tgz#e7cc189a81b435324c4949aa3dfb51888684b243"
dependencies:
Expand Down Expand Up @@ -9108,11 +9112,11 @@ [email protected]:
watchpack "^1.5.0"
webpack-sources "^1.2.0"

webrtc-adapter@^6.4.4:
version "6.4.8"
resolved "https://registry.yarnpkg.com/webrtc-adapter/-/webrtc-adapter-6.4.8.tgz#eeca3f0d5b40c0e629b865ef2a936a0b658274de"
webrtc-adapter@^7.2.0:
version "7.2.3"
resolved "https://registry.yarnpkg.com/webrtc-adapter/-/webrtc-adapter-7.2.3.tgz#2b9b60cf34a6d2a38d247fd1d9a6c495aed85a02"
dependencies:
rtcpeerconnection-shim "^1.2.14"
rtcpeerconnection-shim "^1.2.15"
sdp "^2.9.0"

websocket-driver@>=0.5.1:
Expand Down
17,499 changes: 17,492 additions & 7 deletions Release/pili-rtc-web.js

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions ReleaseNotes/release-note-2.2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# QNRTCWeb v2.2.0

## 简介
QNRTCWeb 是七牛云推出的一款适用于 Web 平台的实时音视频 SDK,提供了包括音视频通话、静音、发布、订阅多种功能,提供灵活的接口,支持高度定制以及二次开发。

## 缺陷修复
- 修复弱网时可能会出现的重新发布/订阅失败
- 修复 WebAudio 因为 AutoPlay Policy 导致阻塞的情况
- 修复屏幕共享 enabled 参数无效的问题

## 优化
- 批量订阅 Track 时不会因为其中一个失败而导致整体失败
- 当远端 Track 异常终止时,现在会自动重新订阅

## 功能
- 添加了混音模块
- 重新设计了外部音频导入的 API
- Chrome 72 现在支持无插件屏幕共享了
- 支持配置通过 TCP 来传输音视频数据
- 增加实时音量等级获取的 API

关于新功能的细节,可以参考文档站中的 [ReleaseNote](https://doc.qnsdk.com/rtn/web/blog/2019/04/30/v2.2.0-release)

## 问题反馈

当你遇到任何问题时,可以通过在 GitHub 的 repo 提交 `issues` 来反馈问题,请尽可能的描述清楚遇到的问题,如果有错误信息也一同附带,并且在 ```Labels``` 中指明类型为 bug 或者其他。

[通过这里查看已有的 issues 和提交 bug](https://github.com/pili-engineering/QNRTC-Web/issues)

0 comments on commit d306b1a

Please sign in to comment.