Stop using local stream after hangup
This commit is contained in:
parent
c89886bbfa
commit
ff5a20e13f
@ -3,13 +3,22 @@ export const createObjectURL = jest.fn()
|
|||||||
export const revokeObjectURL = jest.fn()
|
export const revokeObjectURL = jest.fn()
|
||||||
|
|
||||||
export class MediaStream {
|
export class MediaStream {
|
||||||
|
getTracks() {
|
||||||
|
return [{
|
||||||
|
stop: jest.fn(),
|
||||||
|
}, {
|
||||||
|
stop: jest.fn(),
|
||||||
|
}]
|
||||||
|
}
|
||||||
getVideoTracks () {
|
getVideoTracks () {
|
||||||
return [{
|
return [{
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
stop: jest.fn(),
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
getAudioTracks () {
|
getAudioTracks () {
|
||||||
return [{
|
return [{
|
||||||
|
stop: jest.fn(),
|
||||||
enabled: true,
|
enabled: true,
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import { EventEmitter } from 'events'
|
|||||||
import { createStore, Store, GetState } from '../store'
|
import { createStore, Store, GetState } from '../store'
|
||||||
import { ClientSocket } from '../socket'
|
import { ClientSocket } from '../socket'
|
||||||
import { Dispatch } from 'redux'
|
import { Dispatch } from 'redux'
|
||||||
|
import { MediaStream } from '../window'
|
||||||
|
|
||||||
describe('SocketActions', () => {
|
describe('SocketActions', () => {
|
||||||
const roomName = 'bla'
|
const roomName = 'bla'
|
||||||
@ -128,7 +129,13 @@ describe('SocketActions', () => {
|
|||||||
|
|
||||||
describe('stream', () => {
|
describe('stream', () => {
|
||||||
it('adds a stream to streamStore', () => {
|
it('adds a stream to streamStore', () => {
|
||||||
const stream = {}
|
const stream = {
|
||||||
|
getTracks() {
|
||||||
|
return [{
|
||||||
|
stop: jest.fn(),
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
}
|
||||||
peer.emit(constants.PEER_EVENT_STREAM, stream)
|
peer.emit(constants.PEER_EVENT_STREAM, stream)
|
||||||
|
|
||||||
expect(store.getState().streams).toEqual({
|
expect(store.getState().streams).toEqual({
|
||||||
@ -143,7 +150,7 @@ describe('SocketActions', () => {
|
|||||||
|
|
||||||
describe('close', () => {
|
describe('close', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const stream = {}
|
const stream = new MediaStream()
|
||||||
peer.emit(constants.PEER_EVENT_STREAM, stream)
|
peer.emit(constants.PEER_EVENT_STREAM, stream)
|
||||||
expect(store.getState().streams).toEqual({
|
expect(store.getState().streams).toEqual({
|
||||||
b: {
|
b: {
|
||||||
|
|||||||
@ -23,14 +23,7 @@ export interface NotificationProps {
|
|||||||
|
|
||||||
const Notification = React.memo(
|
const Notification = React.memo(
|
||||||
function Notification(props: NotificationProps) {
|
function Notification(props: NotificationProps) {
|
||||||
const { dismiss, notification } = props
|
const { notification } = props
|
||||||
// React.useEffect(() => {
|
|
||||||
// const timeout = setTimeout(dismiss, props.timeout, notification.id)
|
|
||||||
// return () => {
|
|
||||||
// clearTimeout(timeout)
|
|
||||||
// dismiss(notification.id)
|
|
||||||
// }
|
|
||||||
// }, [])
|
|
||||||
return (
|
return (
|
||||||
<div className={classnames(notification.type, 'notification')}>
|
<div className={classnames(notification.type, 'notification')}>
|
||||||
{notification.message}
|
{notification.message}
|
||||||
|
|||||||
@ -43,6 +43,9 @@ function removeStream (
|
|||||||
): StreamsState {
|
): StreamsState {
|
||||||
const { userId } = payload
|
const { userId } = payload
|
||||||
const stream = state[userId]
|
const stream = state[userId]
|
||||||
|
if (stream && stream.stream) {
|
||||||
|
stream.stream.getTracks().forEach(track => track.stop())
|
||||||
|
}
|
||||||
if (stream && stream.url) {
|
if (stream && stream.url) {
|
||||||
revokeObjectURL(stream.url)
|
revokeObjectURL(stream.url)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user