Skip to content

Commit

Permalink
Supporting HTTP/2-FLV allows for concurrent playback of more than 6 s…
Browse files Browse the repository at this point in the history
…treams without using WebSocket-flv in one page.
  • Loading branch information
illuspas committed May 23, 2024
1 parent d4ef51d commit d2d43ac
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 9 deletions.
91 changes: 90 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"basic-auth-connect": "^1.0.0",
"chalk": "^4.1.0",
"dateformat": "^4.6.3",
"express": "^4.18.2",
"express": "^4.19.2",
"http2-express-bridge": "^1.0.7",
"lodash": "^4.17.21",
"minimist": "^1.2.8",
"mkdirp": "^2.1.5",
Expand Down
2 changes: 0 additions & 2 deletions src/node_flv_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ class NodeFlvSession {
}
Logger.log(`[${this.TAG} play] Close stream. id=${this.id} streamPath=${this.playStreamPath}`);
Logger.log(`[${this.TAG} disconnect] id=${this.id}`);
this.connectCmdObj.bytesWritten = this.res.socket.bytesWritten;
this.connectCmdObj.bytesRead = this.res.socket.bytesRead;
context.nodeEvent.emit('doneConnect', this.id, this.connectCmdObj);
this.res.end();
context.idlePlayers.delete(this.id);
Expand Down
7 changes: 4 additions & 3 deletions src/node_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
const Fs = require('fs');
const path = require('path');
const Http = require('http');
const Https = require('https');
const Http2 = require('http2');
const WebSocket = require('ws');
const Express = require('express');
const H2EBridge = require('http2-express-bridge');
const bodyParser = require('body-parser');
const basicAuth = require('basic-auth-connect');
const NodeFlvSession = require('./node_flv_session');
Expand All @@ -30,7 +31,7 @@ class NodeHttpServer {
this.mediaroot = config.http.mediaroot || HTTP_MEDIAROOT;
this.config = config;

let app = Express();
let app = H2EBridge(Express);
app.use(bodyParser.json());

app.use(bodyParser.urlencoded({ extended: true }));
Expand Down Expand Up @@ -81,7 +82,7 @@ class NodeHttpServer {
Object.assign(options, { passphrase: this.config.https.passphrase });
}
this.sport = config.https.port ? config.https.port : HTTPS_PORT;
this.httpsServer = Https.createServer(options, app);
this.httpsServer = Http2.createSecureServer(options, app);
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/node_rtmp_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ class NodeRtmpSession {

Logger.log(`[rtmp disconnect] id=${this.id}`);

this.connectCmdObj.bytesWritten = this.socket.bytesWritten;
this.connectCmdObj.bytesRead = this.socket.bytesRead;
context.nodeEvent.emit('doneConnect', this.id, this.connectCmdObj);

context.sessions.delete(this.id);
Expand Down

0 comments on commit d2d43ac

Please sign in to comment.