also port all the av to contact4
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / dumpsyms (push) Blocked by required conditions
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / dumpsyms (push) Blocked by required conditions
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
This commit is contained in:
parent
c29aa523dc
commit
e618732f43
@ -1,6 +1,7 @@
|
||||
#include "./tox_av_voip_model.hpp"
|
||||
|
||||
#include <solanaceae/object_store/object_store.hpp>
|
||||
#include <solanaceae/contact/contact_store_i.hpp>
|
||||
#include <solanaceae/tox_contacts/components.hpp>
|
||||
#include <solanaceae/util/time.hpp>
|
||||
|
||||
@ -410,7 +411,7 @@ void ToxAVVoIPModel::handleEvent(const Events::FriendCall& e) {
|
||||
// (or rejected...)
|
||||
|
||||
const auto session_contact = _tcm.getContactFriend(e.friend_number);
|
||||
if (!_cr.valid(session_contact)) {
|
||||
if (!static_cast<bool>(session_contact)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -428,7 +429,7 @@ void ToxAVVoIPModel::handleEvent(const Events::FriendCall& e) {
|
||||
|
||||
void ToxAVVoIPModel::handleEvent(const Events::FriendCallState& e) {
|
||||
const auto session_contact = _tcm.getContactFriend(e.friend_number);
|
||||
if (!_cr.valid(session_contact)) {
|
||||
if (!static_cast<bool>(session_contact)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -486,8 +487,8 @@ void ToxAVVoIPModel::handleEvent(const Events::FriendCallState& e) {
|
||||
}
|
||||
}
|
||||
|
||||
ToxAVVoIPModel::ToxAVVoIPModel(ObjectStore2& os, ToxAVI& av, Contact3Registry& cr, ToxContactModel2& tcm) :
|
||||
_os(os), _av(av), _av_sr(_av.newSubRef(this)), _cr(cr), _tcm(tcm)
|
||||
ToxAVVoIPModel::ToxAVVoIPModel(ObjectStore2& os, ToxAVI& av, ContactStore4I& cs, ToxContactModel2& tcm) :
|
||||
_os(os), _av(av), _av_sr(_av.newSubRef(this)), _cs(cs), _tcm(tcm)
|
||||
{
|
||||
_av_sr
|
||||
.subscribe(ToxAV_Event::friend_call)
|
||||
@ -502,8 +503,10 @@ ToxAVVoIPModel::ToxAVVoIPModel(ObjectStore2& os, ToxAVI& av, Contact3Registry& c
|
||||
|
||||
// attach to all tox friend contacts
|
||||
|
||||
for (const auto& [cv, _] : _cr.view<Contact::Components::ToxFriendPersistent>().each()) {
|
||||
_cr.emplace<VoIPModelI*>(cv, this);
|
||||
auto& cr = _cs.registry();
|
||||
|
||||
for (const auto& [cv, _] : cr.view<Contact::Components::ToxFriendPersistent>().each()) {
|
||||
cr.emplace<VoIPModelI*>(cv, this);
|
||||
}
|
||||
// TODO: events
|
||||
}
|
||||
@ -535,12 +538,14 @@ void ToxAVVoIPModel::tick(void) {
|
||||
}
|
||||
}
|
||||
|
||||
ObjectHandle ToxAVVoIPModel::enter(const Contact3 c, const Components::VoIP::DefaultConfig& defaults) {
|
||||
if (!_cr.all_of<Contact::Components::ToxFriendEphemeral>(c)) {
|
||||
ObjectHandle ToxAVVoIPModel::enter(const Contact4 c, const Components::VoIP::DefaultConfig& defaults) {
|
||||
const auto& cr = _cs.registry();
|
||||
|
||||
if (!cr.all_of<Contact::Components::ToxFriendEphemeral>(c)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto friend_number = _cr.get<Contact::Components::ToxFriendEphemeral>(c).friend_number;
|
||||
const auto friend_number = cr.get<Contact::Components::ToxFriendEphemeral>(c).friend_number;
|
||||
|
||||
const auto err = _av.toxavCall(friend_number, 0, 0);
|
||||
if (err != TOXAV_ERR_CALL_OK) {
|
||||
@ -579,12 +584,14 @@ bool ToxAVVoIPModel::accept(ObjectHandle session, const Components::VoIP::Defaul
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& cr = _cs.registry();
|
||||
|
||||
const auto session_contact = session.get<Components::VoIP::SessionContact>().c;
|
||||
if (!_cr.all_of<Contact::Components::ToxFriendEphemeral>(session_contact)) {
|
||||
if (!cr.all_of<Contact::Components::ToxFriendEphemeral>(session_contact)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto friend_number = _cr.get<Contact::Components::ToxFriendEphemeral>(session_contact).friend_number;
|
||||
const auto friend_number = cr.get<Contact::Components::ToxFriendEphemeral>(session_contact).friend_number;
|
||||
auto err = _av.toxavAnswer(friend_number, 0, 0);
|
||||
if (err != TOXAV_ERR_ANSWER_OK) {
|
||||
std::cerr << "TOXAVVOIP error: ansering call failed: " << err << "\n";
|
||||
@ -649,12 +656,14 @@ bool ToxAVVoIPModel::leave(ObjectHandle session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& cr = _cs.registry();
|
||||
|
||||
const auto session_contact = session.get<Components::VoIP::SessionContact>().c;
|
||||
if (!_cr.all_of<Contact::Components::ToxFriendEphemeral>(session_contact)) {
|
||||
if (!cr.all_of<Contact::Components::ToxFriendEphemeral>(session_contact)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto friend_number = _cr.get<Contact::Components::ToxFriendEphemeral>(session_contact).friend_number;
|
||||
const auto friend_number = cr.get<Contact::Components::ToxFriendEphemeral>(session_contact).friend_number;
|
||||
// check error? (we delete anyway)
|
||||
_av.toxavCallControl(friend_number, Toxav_Call_Control::TOXAV_CALL_CONTROL_CANCEL);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <solanaceae/object_store/fwd.hpp>
|
||||
#include <solanaceae/contact/contact_model3.hpp>
|
||||
#include <solanaceae/contact/fwd.hpp>
|
||||
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
|
||||
#include "./frame_streams/voip_model.hpp"
|
||||
#include "./tox_av.hpp"
|
||||
@ -19,7 +19,7 @@ class ToxAVVoIPModel : protected ToxAVEventI, public VoIPModelI {
|
||||
ObjectStore2& _os;
|
||||
ToxAVI& _av;
|
||||
ToxAVI::SubscriptionReference _av_sr;
|
||||
Contact3Registry& _cr;
|
||||
ContactStore4I& _cs;
|
||||
ToxContactModel2& _tcm;
|
||||
|
||||
uint64_t _pad0;
|
||||
@ -63,14 +63,14 @@ class ToxAVVoIPModel : protected ToxAVEventI, public VoIPModelI {
|
||||
void handleEvent(const Events::FriendCallState&);
|
||||
|
||||
public:
|
||||
ToxAVVoIPModel(ObjectStore2& os, ToxAVI& av, Contact3Registry& cr, ToxContactModel2& tcm);
|
||||
ToxAVVoIPModel(ObjectStore2& os, ToxAVI& av, ContactStore4I& cs, ToxContactModel2& tcm);
|
||||
~ToxAVVoIPModel(void);
|
||||
|
||||
// handle events coming from toxav thread(s)
|
||||
void tick(void);
|
||||
|
||||
public: // voip model
|
||||
ObjectHandle enter(const Contact3 c, const Components::VoIP::DefaultConfig& defaults) override;
|
||||
ObjectHandle enter(const Contact4 c, const Components::VoIP::DefaultConfig& defaults) override;
|
||||
bool accept(ObjectHandle session, const Components::VoIP::DefaultConfig& defaults) override;
|
||||
bool leave(ObjectHandle session) override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user