Skip to content

Commit

Permalink
feat: Some of the suggestions made in the PR are resolved.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmatau79 committed Jan 8, 2025
1 parent e75ad74 commit 8123823
Show file tree
Hide file tree
Showing 15 changed files with 675 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout message-pickup-repository
- name: Checkout webrtc-server
uses: actions/checkout@v4

- name: Setup node v22
Expand Down
79 changes: 79 additions & 0 deletions docker-compose-lb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: '3.7'
services:
mediasoup1:
build: .
image: webrtc-server:test
container_name: mediasoup1
networks:
mediasoup_net:
ipv4_address: 192.168.10.11
environment:
- LOG_LEVEL=3
- MEDIASOUP_ANNOUNCED_IP=192.168.10.11
- PROTOO_LISTEN_PORT=4443
- MEDIASOUP_MIN_PORT=40000
- MEDIASOUP_MAX_PORT=41000
- HTTPS_CERT_FULLCHAIN=/config/certs/fullchain.pem
- HTTPS_CERT_PRIVKEY=/config/certs/privkey.pem
- REDIS_URL=redis://redis:6379
- MEDIASOUP_CLIENT_ENABLE_ICESERVER=no
- MEDIASOUP_CLIENT_ICESERVER_HOST=192.168.10.11
- MEDIASOUP_CLIENT_ICESERVER_PROTO=udp
- MEDIASOUP_CLIENT_ICESERVER_PORT=3478
- MEDIASOUP_CLIENT_ICESERVER_USER=test
- MEDIASOUP_CLIENT_ICESERVER_PASS=test123
- MEDIASOUP_CLIENT_PROTOOPORT=4443
- MEDIASOUP_INGRESS_HOST=webrtc.prueba1.2060.io
ports:
- '4443:4443'
volumes:
- ./certs/fullchain.pem:/config/certs/fullchain.pem
- ./certs/privkey.pem:/config/certs/privkey.pem

mediasoup2:
build: .
image: webrtc-server:test
container_name: mediasoup2
networks:
mediasoup_net:
ipv4_address: 192.168.10.12
environment:
- LOG_LEVEL=3
- MEDIASOUP_ANNOUNCED_IP=192.168.10.12
- PROTOO_LISTEN_PORT=4444
- MEDIASOUP_MIN_PORT=41001
- MEDIASOUP_MAX_PORT=42000
- HTTPS_CERT_FULLCHAIN=/config/certs/fullchain.pem
- HTTPS_CERT_PRIVKEY=/config/certs/privkey.pem
- REDIS_URL=redis://redis:6379
- MEDIASOUP_CLIENT_ENABLE_ICESERVER=no
- MEDIASOUP_CLIENT_ICESERVER_HOST=192.168.10.11
- MEDIASOUP_CLIENT_ICESERVER_PROTO=udp
- MEDIASOUP_CLIENT_ICESERVER_PORT=3478
- MEDIASOUP_CLIENT_ICESERVER_USER=test
- MEDIASOUP_CLIENT_ICESERVER_PASS=test123
- MEDIASOUP_CLIENT_PROTOOPORT=4443
- MEDIASOUP_INGRESS_HOST=webrtc.prueba2.2060.io
ports:
- '4444:4444'
volumes:
- ./certs/fullchain.pem:/config/certs/fullchain.pem
- ./certs/privkey.pem:/config/certs/privkey.pem

redis:
image: redis:alpine
container_name: redis
restart: always
networks:
mediasoup_net:
ipv4_address: 192.168.10.10
ports:
- '6379:6379'
command: redis-server --maxmemory 64mb --maxmemory-policy allkeys-lru

networks:
mediasoup_net:
driver: bridge
ipam:
config:
- subnet: 192.168.10.0/24
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
- MEDIASOUP_CLIENT_ICESERVER_PASS=test123
- MEDIASOUP_CLIENT_PROTOOPORT=4443
- MEDIASOUP_INGRESS_HOST=webrtc.prueba.2060.io
- REDIS_URL=redis://redis:6379
ports:
- '4443:4443'
volumes:
Expand All @@ -33,3 +34,11 @@ services:
ports:
- '3478:3478'
- '3478:3478/udp'

redis:
container_name: redis
image: redis:alpine
restart: always
ports:
- 6379:6379
command: redis-server --maxmemory 64mb --maxmemory-policy allkeys-lru
16 changes: 16 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Config } from 'jest'

const config: Config = {
moduleFileExtensions: ['js', 'json', 'ts'],
rootDir: 'src',
testRegex: '.*\\.spec\\.ts$',
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
},
collectCoverageFrom: ['**/*.(t|j)s'],
coverageDirectory: '../coverage',
testEnvironment: 'node',
}

export default config

27 changes: 6 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test": "jest --config jest.config.ts",
"test:watch": "jest --watch --config jest.config.ts",
"test:cov": "jest --coverage --config jest.config.ts",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand --config jest.config.ts",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs-modules/ioredis": "^2.0.2",
"@nestjs/axios": "^3.1.2",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.3.0",
Expand All @@ -33,6 +34,7 @@
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"inquirer": "^12.1.0",
"ioredis": "^5.4.1",
"mediasoup": "^3.15.2",
"protoo-client": "^4.0.6",
"protoo-server": "^4.0.6",
Expand Down Expand Up @@ -67,22 +69,5 @@
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
5 changes: 4 additions & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import appConfig from './config/app.config'
import { NotificationService } from './lib/notification.service'
import { HttpModule } from '@nestjs/axios'
import { RoomsModule } from './rooms/rooms.module'
import { HandledRedisModule } from './modules/redis.module'
import { RoomFactory } from './lib/RoomFactory'

@Module({
imports: [
Expand All @@ -14,9 +16,10 @@ import { RoomsModule } from './rooms/rooms.module'
isGlobal: true,
}),
RoomsModule,
HandledRedisModule,
],
controllers: [],
providers: [NotificationService],
providers: [NotificationService, HandledRedisModule, RoomFactory],
exports: [NotificationService],
})
export class AppModule {}
5 changes: 5 additions & 0 deletions src/config/config.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,10 @@ export const config = {
},
maxSctpMessageSize: 262144,
},
pipeTransportOptions: {
listenIp: { ip: '0.0.0.0', announcedIp: process.env.MEDIASOUP_ANNOUNCED_IP || '127.0.0.1' },
enableSrtp: true,
enableRtx: true,
},
},
}
Loading

0 comments on commit 8123823

Please sign in to comment.