Skip to content

Commit

Permalink
Camera: Add TCP transport for RTSP stream (#2150)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles authored Oct 31, 2024
1 parent 01e7779 commit df91742
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/services/rtsp-camera/lib/getImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ async function getImage(device) {

const args = ['-i', cameraUrlParam.value, '-f', 'image2', '-vframes', '1', '-qscale:v', '15'];

// For rtsp protocol, add tcp transport to avoid green band of pixels)
if (cameraUrlParam.value.includes('rtsp')) {
args.push('-rtsp_transport');
args.push('tcp');
}

args.push('-vf');
switch (cameraRotationParam.value) {
case DEVICE_ROTATION.DEGREES_90:
Expand Down
19 changes: 19 additions & 0 deletions server/test/services/rtsp-camera/rtspCamera.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ const device = {
],
};

const deviceWithRtspImage = {
id: 'a6fb4cb8-ccc2-4234-a752-b25d1eb5ab6b',
selector: 'my-camera',
params: [
{
name: 'CAMERA_URL',
value: 'rtsp://test.fr/test',
},
{
name: 'CAMERA_ROTATION',
value: '0',
},
],
};

const gladys = {
config: {
tempFolder: '/tmp/gladys',
Expand Down Expand Up @@ -141,6 +156,10 @@ describe('RtspCameraManager commands', () => {
const image = await rtspCameraManager.getImage(device);
expect(image).to.equal('image/jpg;base64,aW1hZ2U=');
});
it('should getImage with RTSP url', async () => {
const image = await rtspCameraManager.getImage(deviceWithRtspImage);
expect(image).to.equal('image/jpg;base64,aW1hZ2U=');
});
it('should getImage 90°', async () => {
const image = await rtspCameraManager.getImage(deviceRotation90);
expect(image).to.equal('image/jpg;base64,aW1hZ2U=');
Expand Down

0 comments on commit df91742

Please sign in to comment.