Description
Describe the bug
I am trying to seek to different times without tearing down and setting up RTSP sessions, and instead reuse the existing one. In theory the RTSP protocol should allow this (as far as I know), and I can almost do it with this library. The problem is that calling .update
on RtspSession
does not update _sessionControlURL
, which is what is used to send SDP commands.
To Reproduce
- Apply the following git patch on this repo:
--- a/streams/tests/rtsp-session.test.ts
+++ b/streams/tests/rtsp-session.test.ts
@@ -78,10 +78,12 @@ describe('rtsp-session send method', (test) => {
test('should use the supplied URI', async (ctx) => {
const uri = 'rtsp://whatever/path'
+ const uri2 = 'rtsp://new/path'
const s = new RtspSession({ uri })
+ s.update(uri2)
const done = new Promise((resolve) => (ctx.resolve = resolve))
s.outgoing.once('data', (req) => {
- assert.is(req.uri, uri)
+ assert.is(req.uri, uri2)
ctx.resolve()
})
s.send({ method: RTSP_METHOD.DESCRIBE })
- Run
just test
This outputs:
FAIL rtsp-session send method "should use the supplied URI"
Expected values to be strictly equal: (is)
++rtsp://new/path (Expected)
--rtsp://whatever/path (Actual)
Environment:
- OS: Linux
- Browser: Firefox
- Version: 13.1.1
Possible solution
I was able to reuse an RTSP session by doing something like this in my code:
// this._pipeline is a `Html5VideoPipeline`
this._pipeline.rtsp.stop();
const uriNew = ...;
this._pipeline.rtsp.update(uriNew);
this._pipeline.rtsp._sessionControlURL = uriNew;
this._pipeline.rtsp.play();
I'm not 100% sure what .update
should be used for since it's not used anywhere in this repo, but AFAIK this can be fixed by simply adding the following at the end of the .update
implementation:
this._sessionControlURL = this.uri;
It's probably only safe to do this if the _state = STATE.IDLE
though?
I'm happy to work on a PR for this.