Skip to content

Commit

Permalink
v1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyoshiaki committed Jul 10, 2023
1 parent 2e506b6 commit 82f0e3c
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 61 deletions.
10 changes: 5 additions & 5 deletions THIRD_PARTY_LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SOFTWARE.

---

@skyway-sdk/core@1.4.1
@skyway-sdk/core@1.5.0

MIT

Expand Down Expand Up @@ -68,7 +68,7 @@ MIT

---

@skyway-sdk/room@1.4.1
@skyway-sdk/room@1.5.0

MIT

Expand Down Expand Up @@ -192,7 +192,7 @@ SOFTWARE.

---

@skyway-sdk/sfu-bot@1.4.1
@skyway-sdk/sfu-bot@1.5.0

MIT

Expand Down Expand Up @@ -809,7 +809,7 @@ SOFTWARE.

---

node-fetch@2.6.11
node-fetch@2.6.12

MIT

Expand Down Expand Up @@ -903,7 +903,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---

supports-color@9.3.1
supports-color@9.4.0

MIT

Expand Down
4 changes: 2 additions & 2 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,12 @@ const data: LocalDataStream = await SkyWayStreamFactory.createDataStream();
```ts
const displayStream = await navigator.mediaDevices.getDisplayMedia();
const [displayTrack] = displayStream.getVideoTracks();
const stream = new LocalVideoStream('label', displayTrack);
const stream = new LocalVideoStream(displayTrack);

const [audioTrack] = (
await navigator.mediaDevices.getUserMedia({ audio: true })
).getTracks();
const stream = new LocalAudioStream('label', audioTrack);
const stream = new LocalAudioStream(audioTrack);
```

### AudioStream / VideoStream の再生方法
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@skyway-sdk/core",
"version": "1.4.1",
"version": "1.5.0",
"description": "The official Next Generation JavaScript SDK for SkyWay",
"homepage": "https://skyway.ntt.com/",
"repository": {
Expand Down
39 changes: 15 additions & 24 deletions packages/core/src/channel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
} from './event';
import { SkyWayContext } from '../context';

import { MemberKeepAliveConfig } from '../config';
import { MemberInternalConfig, MemberKeepAliveConfig } from '../config';
import { createLogPayload, createError } from '../util';
import {
LocalPerson,
Expand Down Expand Up @@ -486,12 +486,7 @@ export class SkyWayChannelImpl implements Channel {
this.onPublicationUnsubscribed.emit({ subscription });
}

async join(
options: {
name?: MemberInit['name'];
metadata?: MemberInit['metadata'];
} & Partial<MemberKeepAliveConfig> = {}
) {
async join(options: PersonInit = {}) {
const timestamp = log.info(
'[start] join',
await createLogPayload({
Expand Down Expand Up @@ -524,10 +519,8 @@ export class SkyWayChannelImpl implements Channel {
}
}

options.keepaliveIntervalSec =
options.keepaliveIntervalSec ?? this.config.member.keepaliveIntervalSec;
options.keepaliveIntervalGapSec =
options.keepaliveIntervalGapSec ??
options.keepaliveIntervalSec ??= this.config.member.keepaliveIntervalSec;
options.keepaliveIntervalGapSec ??=
this.config.member.keepaliveIntervalGapSec;

const init: MemberInit = {
Expand All @@ -549,10 +542,7 @@ export class SkyWayChannelImpl implements Channel {
member,
});

const person = await this._createLocalPerson(member, {
keepaliveIntervalSec: options.keepaliveIntervalSec,
keepaliveIntervalGapSec: options.keepaliveIntervalGapSec,
});
const person = await this._createLocalPerson(member, options);
const adapter = new LocalPersonAdapter(person);
log.elapsed(timestamp, '[end] join', { person });

Expand Down Expand Up @@ -609,22 +599,17 @@ export class SkyWayChannelImpl implements Channel {
const member = await this._channelImpl.joinChannel(init);
const person = await this._createLocalPerson(member, {
keepaliveIntervalSec: adapter.keepaliveIntervalSec,
keepaliveIntervalGapSec: adapter.keepaliveIntervalSec,
keepaliveIntervalGapSec: adapter.keepaliveIntervalGapSec,
disableSignaling: adapter.disableSignaling,
});
adapter.apply(person);
}

private async _createLocalPerson(
member: model.Member,
{
keepaliveIntervalSec,
keepaliveIntervalGapSec,
}: Partial<MemberKeepAliveConfig>
config: PersonInit
): Promise<LocalPersonImpl> {
const person = await createLocalPerson(this._context, this, member, {
keepaliveIntervalSec,
keepaliveIntervalGapSec,
});
const person = await createLocalPerson(this._context, this, member, config);
this._localPerson = person;

return person;
Expand Down Expand Up @@ -859,3 +844,9 @@ export class SkyWayChannel {
}

export type ChannelState = 'opened' | 'closed';

export type PersonInit = {
name?: MemberInit['name'];
metadata?: MemberInit['metadata'];
} & Partial<MemberKeepAliveConfig> &
MemberInternalConfig;
9 changes: 7 additions & 2 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type SkyWayConfigOptions = {
token: { updateReminderSec?: number };
log: Partial<{ level: LogLevel; format: LogFormat }>;
/**@internal */
internal: { disableDPlane?: boolean; disableSignaling?: boolean };
internal: { disableDPlane?: boolean };
member: Partial<MemberKeepAliveConfig>;
};

Expand All @@ -48,6 +48,12 @@ export type MemberKeepAliveConfig = {
keepaliveIntervalGapSec: number;
};

/**@internal */
export type MemberInternalConfig = {
/**@internal */
disableSignaling?: boolean;
};

export type TurnPolicy = 'enable' | 'disable' | 'turnOnly';

export type TurnProtocol = 'all' | 'udp' | 'tcp' | 'tls';
Expand Down Expand Up @@ -88,7 +94,6 @@ export class ContextConfig implements SkyWayConfigOptions {
/**@internal */
internal: Required<SkyWayConfigOptions['internal']> = {
disableDPlane: false,
disableSignaling: false,
};
member: Required<SkyWayConfigOptions['member']> = {
keepaliveIntervalGapSec: 30,
Expand Down
28 changes: 27 additions & 1 deletion packages/core/src/media/stream/local/media.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Event } from '@skyway-sdk/common';
import { Event, EventDisposer, Logger } from '@skyway-sdk/common';

import {
AudioMediaTrackConstraints,
Expand All @@ -9,11 +9,23 @@ import {
import { ContentType, attachElement, detachElement } from '../base';
import { LocalStreamBase } from './base';

const logger = new Logger('packages/core/src/media/stream/local/media.ts');

export abstract class LocalMediaStreamBase extends LocalStreamBase {
/**@description [japanese] PublicationのDisable/EnableなどでStreamのtrackが更新された時に発火するイベント */
onTrackUpdated = new Event<MediaStreamTrack>();
/**
* @description [japanese] streamが破棄された時に発火するイベント (例. 画面共有が終了したときなど)
* @example [japanese] ハンドリング例
* const publication = await member.publish(audio);
audio.onDestroyed.once(async () => {
await member.unpublish(publication);
});
* */
onDestroyed = new Event<void>();
private _element?: HTMLVideoElement | HTMLAudioElement;
private _track: MediaStreamTrack;
private _disposer = new EventDisposer();
/**@internal */
protected _oldTrack?: MediaStreamTrack;
private _trackConstraints: MediaTrackConstraints = {};
Expand Down Expand Up @@ -52,6 +64,7 @@ export abstract class LocalMediaStreamBase extends LocalStreamBase {
super(contentType);

this._track = track;
this._listenTrackEvent();
this._options = options;

// iOS safari 15はgetConstraintsがバグってるのでここで入れておく
Expand Down Expand Up @@ -110,13 +123,26 @@ export abstract class LocalMediaStreamBase extends LocalStreamBase {
this.attach(this._element);
}
this.onTrackUpdated.emit(track);
this._listenTrackEvent();
}

private _listenTrackEvent() {
const onended = () => {
logger.info('onDestroyed', this.toJSON());
this.onDestroyed.emit();
};
this._track.addEventListener('ended', onended);
this._disposer.push(() =>
this._track.removeEventListener('ended', onended)
);
}

/**
* @description [japanese] Streamを解放します。
* カメラやマイクなどのデバイスを解放するためにはそのデバイスに関連するすべてのStreamを解放する必要があります
*/
release() {
this._disposer.dispose();
this._track.stop();
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/member/localPerson/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export class LocalPersonAdapter implements LocalPerson {
get keepaliveIntervalGapSec() {
return this._impl.keepaliveIntervalGapSec;
}
get disableSignaling() {
return this._impl.disableSignaling;
}
get type() {
return this._impl.type;
}
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/member/localPerson/factory.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Logger } from '@skyway-sdk/common';
import model from '@skyway-sdk/model';

import { SkyWayChannelImpl } from '../../channel';
import { PersonInit, SkyWayChannelImpl } from '../../channel';
import { MaxIceParamServerTTL } from '../../const';
import { SkyWayContext } from '../../context';
import { errors } from '../../errors';
import { setupSignalingSession } from '../../external/signaling';
import { LocalPersonImpl } from '.';
import { MemberKeepAliveConfig } from '../../config';
import { IceManager } from '../../external/ice';
import { createError } from '../../util';

Expand All @@ -21,7 +20,8 @@ export async function createLocalPerson(
{
keepaliveIntervalSec,
keepaliveIntervalGapSec,
}: Partial<MemberKeepAliveConfig> = {}
disableSignaling,
}: PersonInit = {}
) {
log.debug('createLocalPerson', {
channel,
Expand All @@ -33,7 +33,7 @@ export async function createLocalPerson(
const { iceParamServer } = context.config;

const signalingSession =
context.config.internal.disableSignaling === true
disableSignaling === true
? undefined
: await setupSignalingSession(context, channel, memberDto);

Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/member/localPerson/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { Encoding } from '@skyway-sdk/model';
import { PublicationInit } from '@skyway-sdk/rtc-api-client';

import { SkyWayChannelImpl } from '../../channel';
import { PersonInit, SkyWayChannelImpl } from '../../channel';
import { errors } from '../../errors';
import { SignalingSession } from '../../external/signaling';
import { Codec, EncodingParameters } from '../../media';
Expand All @@ -26,7 +26,6 @@ import { Person } from '../person';
import { isRemoteMember } from '../remoteMember';
import { PublishingAgent, SubscribingAgent } from './agent';
import { SkyWayContext } from '../../context';
import { MemberKeepAliveConfig } from '../../config';
import { IceManager } from '../../external/ice';
import {
RemoteAudioStream,
Expand Down Expand Up @@ -105,6 +104,7 @@ export class LocalPersonImpl extends MemberImpl implements LocalPerson {
ttlSec?: number;
readonly keepaliveIntervalSec = this.args.keepaliveIntervalSec;
readonly keepaliveIntervalGapSec = this.args.keepaliveIntervalGapSec;
readonly disableSignaling = this.args.disableSignaling;
readonly config = this.context.config;

readonly onStreamPublished = this._events.make<{
Expand Down Expand Up @@ -167,7 +167,7 @@ export class LocalPersonImpl extends MemberImpl implements LocalPerson {
metadata?: string;
iceManager: IceManager;
context: SkyWayContext;
} & Partial<MemberKeepAliveConfig>
} & PersonInit
) {
super(args);

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const PACKAGE_VERSION = '1.4.1';
export const PACKAGE_VERSION = '1.5.0';
4 changes: 2 additions & 2 deletions packages/room/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,12 @@ const data = await SkyWayStreamFactory.createDataStream();
```ts
const displayStream = await navigator.mediaDevices.getDisplayMedia();
const [displayTrack] = displayStream.getVideoTracks();
const stream = new LocalVideoStream('label', displayTrack);
const stream = new LocalVideoStream(displayTrack);

const [audioTrack] = (
await navigator.mediaDevices.getUserMedia({ audio: true })
).getTracks();
const stream = new LocalAudioStream('label', audioTrack);
const stream = new LocalAudioStream(audioTrack);
```

### AudioStream / VideoStream の再生方法
Expand Down
6 changes: 3 additions & 3 deletions packages/room/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@skyway-sdk/room",
"version": "1.4.1",
"version": "1.5.0",
"description": "The official Next Generation JavaScript SDK for SkyWay",
"homepage": "https://skyway.ntt.com/",
"repository": {
Expand Down Expand Up @@ -45,8 +45,8 @@
"watch:tsc": "tsc -p tsconfig.build.json -w"
},
"dependencies": {
"@skyway-sdk/core": "^1.4.1",
"@skyway-sdk/sfu-bot": "^1.4.1",
"@skyway-sdk/core": "^1.5.0",
"@skyway-sdk/sfu-bot": "^1.5.0",
"uuid": "^9.0.0"
},
"devDependencies": {
Expand Down
7 changes: 2 additions & 5 deletions packages/room/src/room/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ChannelState,
LocalStream,
MemberMetadataUpdatedEvent,
PersonInit,
Publication,
SkyWayChannelImpl,
SubscriptionImpl,
Expand Down Expand Up @@ -336,8 +337,4 @@ export abstract class RoomImpl implements Room {
}
}

export type RoomMemberInit = {
name?: string;
metadata?: string;
keepaliveIntervalSec?: number;
};
export type RoomMemberInit = PersonInit;

0 comments on commit 82f0e3c

Please sign in to comment.