aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-10-27 17:56:32 -0700
committerAnton Tananaev <anton@traccar.org>2022-10-27 17:56:32 -0700
commitc59ba066b1437e98af10a413b9e0c29f0e443b26 (patch)
treeb4567cc17fb940134b49f98ba66426b0e9ad5e02 /src/main/java
parentab10e710a9c57ef761ea9955198273db5f473581 (diff)
downloadtrackermap-server-c59ba066b1437e98af10a413b9e0c29f0e443b26.tar.gz
trackermap-server-c59ba066b1437e98af10a413b9e0c29f0e443b26.tar.bz2
trackermap-server-c59ba066b1437e98af10a413b9e0c29f0e443b26.zip
Support Teltonika DualCam video
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/DualcamProtocolDecoder.java36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/protocol/DualcamProtocolDecoder.java b/src/main/java/org/traccar/protocol/DualcamProtocolDecoder.java
index c5835bc7d..e646c4e4a 100644
--- a/src/main/java/org/traccar/protocol/DualcamProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/DualcamProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2021 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,8 @@ public class DualcamProtocolDecoder extends BaseProtocolDecoder {
private String uniqueId;
private int packetCount;
private int currentPacket;
- private ByteBuf photo;
+ private boolean video;
+ private ByteBuf media;
@Override
protected Object decode(
@@ -64,9 +65,22 @@ public class DualcamProtocolDecoder extends BaseProtocolDecoder {
long settings = buf.readUnsignedInt();
if (channel != null && deviceSession != null) {
ByteBuf response = Unpooled.buffer();
- if (BitUtil.between(settings, 26, 28) > 0) {
+ if (BitUtil.between(settings, 26, 30) > 0) {
response.writeShort(MSG_FILE_REQUEST);
- String file = BitUtil.check(settings, 26) ? "%photof" : "%photor";
+ String file;
+ if (BitUtil.check(settings, 26)) {
+ video = false;
+ file = "%photof";
+ } else if (BitUtil.check(settings, 27)) {
+ video = false;
+ file = "%photor";
+ } else if (BitUtil.check(settings, 28)) {
+ video = true;
+ file = "%videof";
+ } else {
+ video = true;
+ file = "%videor";
+ }
response.writeShort(file.length());
response.writeCharSequence(file, StandardCharsets.US_ASCII);
} else {
@@ -79,7 +93,7 @@ public class DualcamProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // length
packetCount = buf.readInt();
currentPacket = 1;
- photo = Unpooled.buffer();
+ media = Unpooled.buffer();
if (channel != null) {
ByteBuf response = Unpooled.buffer();
response.writeShort(MSG_RESUME);
@@ -90,17 +104,21 @@ public class DualcamProtocolDecoder extends BaseProtocolDecoder {
break;
case MSG_DATA:
buf.readUnsignedShort(); // length
- photo.writeBytes(buf, buf.readableBytes() - 2);
+ media.writeBytes(buf, buf.readableBytes() - 2);
if (currentPacket == packetCount) {
deviceSession = getDeviceSession(channel, remoteAddress);
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
getLastLocation(position, null);
try {
- position.set(Position.KEY_IMAGE, writeMediaFile(uniqueId, photo, "jpg"));
+ if (video) {
+ position.set(Position.KEY_VIDEO, writeMediaFile(uniqueId, media, "h265"));
+ } else {
+ position.set(Position.KEY_IMAGE, writeMediaFile(uniqueId, media, "jpg"));
+ }
} finally {
- photo.release();
- photo = null;
+ media.release();
+ media = null;
}
if (channel != null) {
ByteBuf response = Unpooled.buffer();