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