Skip to content

Commit

Permalink
Merge branch 'master-windows-changes' into windows-changes-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
LAGonauta committed Feb 25, 2022
2 parents d225760 + 90bd9df commit d35171f
Show file tree
Hide file tree
Showing 149 changed files with 1,551 additions and 1,059 deletions.
42 changes: 42 additions & 0 deletions dino.doap
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,23 @@
<xmpp:note>Only for viewing avatars</xmpp:note>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0059.html"/>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0060.html"/>
<xmpp:status>partial</xmpp:status>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0065.html"/>
<xmpp:note>For use with XEP-0260</xmpp:note>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0066.html"/>
Expand Down Expand Up @@ -378,6 +389,11 @@
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0222.html"/>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0223.html"/>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0234.html"/>
Expand Down Expand Up @@ -422,6 +438,11 @@
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0294.html"/>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0297.html"/>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0308.html"/>
Expand Down Expand Up @@ -492,16 +513,37 @@
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0391.html"/>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0393.html"/>
<xmpp:status>partial</xmpp:status>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0396.html"/>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0398.html"/>
<xmpp:status>complete</xmpp:status>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0402.html"/>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0410.html"/>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0454.html"/>
</xmpp:SupportedXep>
</implements>
</Project>
</rdf:RDF>
42 changes: 42 additions & 0 deletions dino.doap.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,23 @@
<xmpp:note>Only for viewing avatars</xmpp:note>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0059.html" />
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0060.html" />
<xmpp:status>partial</xmpp:status>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0065.html" />
<xmpp:note>For use with XEP-0260</xmpp:note>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0066.html" />
Expand Down Expand Up @@ -198,6 +209,11 @@
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0222.html" />
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0223.html" />
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0234.html" />
Expand Down Expand Up @@ -242,6 +258,11 @@
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0294.html" />
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0297.html" />
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0308.html" />
Expand Down Expand Up @@ -312,16 +333,37 @@
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0391.html" />
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0393.html" />
<xmpp:status>partial</xmpp:status>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0396.html" />
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0398.html" />
<xmpp:status>complete</xmpp:status>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0402.html" />
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0410.html" />
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0454.html" />
</xmpp:SupportedXep>
</implements>
</Project>
</rdf:RDF>
14 changes: 9 additions & 5 deletions libdino/src/plugin/interfaces.vala
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,28 @@ public abstract interface VideoCallPlugin : Object {
// Devices
public signal void devices_changed(string media, bool incoming);
public abstract Gee.List<MediaDevice> get_devices(string media, bool incoming);
public abstract MediaDevice? get_device(Xmpp.Xep.JingleRtp.Stream stream, bool incoming);
public abstract void set_pause(Xmpp.Xep.JingleRtp.Stream stream, bool pause);
public abstract void set_device(Xmpp.Xep.JingleRtp.Stream stream, MediaDevice? device);
public abstract MediaDevice? get_preferred_device(string media, bool incoming);
public abstract MediaDevice? get_device(Xmpp.Xep.JingleRtp.Stream? stream, bool incoming);
public abstract void set_pause(Xmpp.Xep.JingleRtp.Stream? stream, bool pause);
public abstract void set_device(Xmpp.Xep.JingleRtp.Stream? stream, MediaDevice? device);

public abstract void dump_dot();
}

public abstract interface VideoCallWidget : Object {
public signal void resolution_changed(uint width, uint height);
public abstract void display_stream(Xmpp.Xep.JingleRtp.Stream stream, Jid jid);
public abstract void display_stream(Xmpp.Xep.JingleRtp.Stream? stream, Jid jid);
public abstract void display_device(MediaDevice device);
public abstract void detach();
}

public abstract interface MediaDevice : Object {
public abstract string id { owned get; }
public abstract string display_name { owned get; }
public abstract string detail_name { owned get; }
public abstract string? detail_name { owned get; }

public abstract string? media { owned get; }
public abstract bool incoming { get; }
}

public abstract interface NotificationPopulator : Object {
Expand Down
26 changes: 24 additions & 2 deletions libdino/src/service/call_peer_state.vala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Dino.PeerState : Object {
public signal void encryption_updated(Xep.Jingle.ContentEncryption? audio_encryption, Xep.Jingle.ContentEncryption? video_encryption, bool same);

public StreamInteractor stream_interactor;
CallState call_state;
public CallState call_state;
public Calls calls;
public Call call;
public Jid jid;
Expand Down Expand Up @@ -90,7 +90,10 @@ public class Dino.PeerState : Object {
}

stream.get_module(Xmpp.Xep.JingleMessageInitiation.Module.IDENTITY).send_session_propose_to_peer(stream, jid, sid, descriptions);
// call_state.cim_call_id = stream.get_module(Xmpp.Xep.CallInvites.Module.IDENTITY).send_jingle_propose(stream, jid, sid, we_should_send_video);

// Uncomment this use CIM instead of JMI
// call_state.cim_call_id = sid;
// stream.get_module(Xmpp.Xep.CallInvites.Module.IDENTITY).send_jingle_propose(stream, call_state.cim_call_id, jid, sid, we_should_send_video);
} else if (jid_for_direct != null) {
yield call_resource(jid_for_direct);
}
Expand All @@ -111,8 +114,27 @@ public class Dino.PeerState : Object {
}

public void accept() {
if (!call_state.accepted) {
critical("Tried to accept peer in unaccepted call?! Something's fishy. Abort.");
return;
}

if (session != null) {
foreach (Xep.Jingle.Content content in session.contents) {
Xep.JingleRtp.Parameters? rtp_content_parameter = content.content_params as Xep.JingleRtp.Parameters;
if (rtp_content_parameter != null && rtp_content_parameter.media == "video") {
// We didn't accept video but our peer wants to negotiate that content
if (!we_should_send_video && session.senders_include_us(content.senders)) {
if (session.senders_include_counterpart(content.senders)) {
// If our peer wants to send, let them
content.modify(session.we_initiated ? Xep.Jingle.Senders.RESPONDER : Xep.Jingle.Senders.INITIATOR);
} else {
// If only we're supposed to send, reject
content.reject();
continue;
}
}
}
content.accept();
}
} else {
Expand Down
75 changes: 63 additions & 12 deletions libdino/src/service/call_state.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ public class Dino.CallState : Object {

public HashMap<Jid, PeerState> peers = new HashMap<Jid, PeerState>(Jid.hash_func, Jid.equals_func);

private Plugins.MediaDevice selected_microphone_device;
private Plugins.MediaDevice selected_speaker_device;
private Plugins.MediaDevice selected_video_device;

public CallState(Call call, StreamInteractor stream_interactor) {
this.call = call;
this.stream_interactor = stream_interactor;

if (call.direction == Call.DIRECTION_OUTGOING) {
if (call.direction == Call.DIRECTION_OUTGOING && call.state != Call.State.OTHER_DEVICE) {
accepted = true;

Timeout.add_seconds(30, () => {
Expand Down Expand Up @@ -80,14 +84,33 @@ public class Dino.CallState : Object {
peer_joined(peer.jid, peer);
}

internal void on_peer_stream_created(PeerState peer, string media) {
if (media == "audio") {
call_plugin.set_device(peer.get_audio_stream(), get_microphone_device());
call_plugin.set_device(peer.get_audio_stream(), get_speaker_device());
} else if (media == "video") {
call_plugin.set_device(peer.get_video_stream(), get_video_device());
}
}

public void accept() {
accepted = true;
call.state = Call.State.ESTABLISHING;

if (use_cim) {
XmppStream stream = stream_interactor.get_stream(call.account);
if (stream == null) return;
stream.get_module(Xep.CallInvites.Module.IDENTITY).send_accept(stream, cim_counterpart, cim_call_id, cim_message_type);
StanzaNode? inner_node = null;
if (group_call != null) {
inner_node = new StanzaNode.build("muji", Xep.Muji.NS_URI).add_self_xmlns()
.put_attribute("room", group_call.muc_jid.to_string());
} else if (peers.size == 1) {
foreach (PeerState peer in peers.values) {
inner_node = new StanzaNode.build("jingle", Xep.CallInvites.NS_URI)
.put_attribute("sid", peer.sid);
}
}
stream.get_module(Xep.CallInvites.Module.IDENTITY).send_accept(stream, cim_counterpart, cim_call_id, inner_node, cim_message_type);
} else {
foreach (PeerState peer in peers.values) {
peer.accept();
Expand Down Expand Up @@ -206,30 +229,57 @@ public class Dino.CallState : Object {
}

public Plugins.MediaDevice? get_microphone_device() {
if (peers.is_empty) return null;
var audio_stream = peers.values.to_array()[0].get_audio_stream();
return call_plugin.get_device(audio_stream, false);
if (selected_microphone_device == null) {
if (!peers.is_empty) {
var audio_stream = peers.values.to_array()[0].get_audio_stream();
selected_microphone_device = call_plugin.get_device(audio_stream, false);
}
if (selected_microphone_device == null) {
selected_microphone_device = call_plugin.get_preferred_device("audio", false);
}
}
return selected_microphone_device;
}

public Plugins.MediaDevice? get_speaker_device() {
if (peers.is_empty) return null;
var audio_stream = peers.values.to_array()[0].get_audio_stream();
return call_plugin.get_device(audio_stream, true);
if (selected_speaker_device == null) {
if (!peers.is_empty) {
var audio_stream = peers.values.to_array()[0].get_audio_stream();
selected_speaker_device = call_plugin.get_device(audio_stream, true);
}
if (selected_speaker_device == null) {
selected_speaker_device = call_plugin.get_preferred_device("audio", true);
}
}
return selected_speaker_device;
}

public Plugins.MediaDevice? get_video_device() {
if (peers.is_empty) return null;
var video_stream = peers.values.to_array()[0].get_video_stream();
return call_plugin.get_device(video_stream, false);
if (selected_video_device == null) {
if (!peers.is_empty) {
var video_stream = peers.values.to_array()[0].get_video_stream();
selected_video_device = call_plugin.get_device(video_stream, false);
}
if (selected_video_device == null) {
selected_video_device = call_plugin.get_preferred_device("video", false);
}
}
return selected_video_device;
}

public void set_audio_device(Plugins.MediaDevice? device) {
if (device.incoming) {
selected_speaker_device = device;
} else {
selected_microphone_device = device;
}
foreach (PeerState peer_state in peers.values) {
call_plugin.set_device(peer_state.get_audio_stream(), device);
}
}

public void set_video_device(Plugins.MediaDevice? device) {
selected_video_device = device;
foreach (PeerState peer_state in peers.values) {
call_plugin.set_device(peer_state.get_video_stream(), device);
}
Expand Down Expand Up @@ -270,6 +320,7 @@ public class Dino.CallState : Object {
this.bind_property("we-should-send-video", peer_state, "we-should-send-video", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
this.bind_property("group-call", peer_state, "group-call", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);

peer_state.stream_created.connect((peer, media) => { on_peer_stream_created(peer, media); });
peer_state.session_terminated.connect((we_terminated, reason_name, reason_text) => {
debug("[%s] Peer left %s: %s %s (%i peers remaining)", call.account.bare_jid.to_string(), reason_text ?? "", reason_name ?? "", peer_state.jid.to_string(), peers.size);
handle_peer_left(peer_state, we_terminated, reason_name, reason_text);
Expand Down Expand Up @@ -373,7 +424,7 @@ public class Dino.CallState : Object {
handle_peer_left(peer_state, false, Xep.Jingle.ReasonElement.CANCEL, "Peer left the MUJI MUC");
});

if (group_call.peers_to_connect_to.size > 3) {
if (group_call.peers_to_connect_to.size > 4) {
end("Call too full - P2p calls don't work well with many participants");
return;
}
Expand Down
Loading

0 comments on commit d35171f

Please sign in to comment.