]>
nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/json/JsonCallMessage.java
70b1951c98c255d3878abc8d7bb57d7a21d61503
1 package org
.asamk
.signal
.json
;
3 import com
.fasterxml
.jackson
.annotation
.JsonInclude
;
5 import org
.asamk
.signal
.manager
.api
.MessageEnvelope
;
7 import java
.util
.Base64
;
10 record JsonCallMessage(
11 @JsonInclude(JsonInclude
.Include
.NON_NULL
) Offer offerMessage
,
12 @JsonInclude(JsonInclude
.Include
.NON_NULL
) Answer answerMessage
,
13 @JsonInclude(JsonInclude
.Include
.NON_NULL
) Busy busyMessage
,
14 @JsonInclude(JsonInclude
.Include
.NON_NULL
) Hangup hangupMessage
,
15 @JsonInclude(JsonInclude
.Include
.NON_EMPTY
) List
<IceUpdate
> iceUpdateMessages
18 static JsonCallMessage
from(MessageEnvelope
.Call callMessage
) {
19 return new JsonCallMessage(callMessage
.offer().map(Offer
::from
).orElse(null),
20 callMessage
.answer().map(Answer
::from
).orElse(null),
21 callMessage
.busy().map(Busy
::from
).orElse(null),
22 callMessage
.hangup().map(Hangup
::from
).orElse(null),
23 callMessage
.iceUpdate().stream().map(IceUpdate
::from
).toList());
26 record Offer(long id
, String sdp
, String type
, String opaque
) {
28 public static Offer
from(final MessageEnvelope
.Call
.Offer offer
) {
29 return new Offer(offer
.id(),
32 Base64
.getEncoder().encodeToString(offer
.opaque()));
36 public record Answer(long id
, String sdp
, String opaque
) {
38 public static Answer
from(final MessageEnvelope
.Call
.Answer answer
) {
39 return new Answer(answer
.id(), answer
.sdp(), Base64
.getEncoder().encodeToString(answer
.opaque()));
43 public record Busy(long id
) {
45 public static Busy
from(final MessageEnvelope
.Call
.Busy busy
) {
46 return new Busy(busy
.id());
50 public record Hangup(long id
, String type
, int deviceId
, boolean isLegacy
) {
52 public static Hangup
from(final MessageEnvelope
.Call
.Hangup hangup
) {
53 return new Hangup(hangup
.id(), hangup
.type().name(), hangup
.deviceId(), hangup
.isLegacy());
57 public record IceUpdate(long id
, String sdp
, String opaque
) {
59 public static IceUpdate
from(final MessageEnvelope
.Call
.IceUpdate iceUpdate
) {
60 return new IceUpdate(iceUpdate
.id(),
62 Base64
.getEncoder().encodeToString(iceUpdate
.opaque()));