use new contact events to attach tox av voip to new contacts
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
cc9af3e3a3
commit
746b567040
@ -1,7 +1,7 @@
|
||||
#include "./tox_av_voip_model.hpp"
|
||||
|
||||
#include <solanaceae/object_store/object_store.hpp>
|
||||
#include <solanaceae/contact/contact_store_i.hpp>
|
||||
#include <solanaceae/contact/contact_store_events.hpp>
|
||||
#include <solanaceae/tox_contacts/components.hpp>
|
||||
#include <solanaceae/util/time.hpp>
|
||||
|
||||
@ -431,23 +431,9 @@ void ToxAVVoIPModel::video_thread_tick(void) {
|
||||
|
||||
if (time_since_last <= interval_ms) {
|
||||
time_until_next_frame = std::min(time_until_next_frame, interval_ms - time_since_last);
|
||||
//} else if (time_since_last <= interval_ms + interval_ms/4) {
|
||||
// // we probably overshot, but we give it a 5ms grace time
|
||||
// time_until_next_frame = 0; // is min
|
||||
#if 0 // this mostly works, but might be too aggressive
|
||||
} else if (time_since_last <= interval_ms*3) {
|
||||
// we probably overshot, but we give a 3 interval grace period
|
||||
time_until_next_frame = 0; // is min
|
||||
#endif
|
||||
#if 1 // good enough and safe
|
||||
} else if (time_since_last <= interval_ms*10) {
|
||||
// we might be dropping here, but we still report interval time, just in case
|
||||
time_until_next_frame = std::min(time_until_next_frame, interval_ms);
|
||||
#endif
|
||||
//} else {
|
||||
//// ... fallback to normal interval?
|
||||
// no, dont actually, if this sink stops receiving frames, we should ignore it
|
||||
//time_until_next_frame = vsink->_interval;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -537,7 +523,7 @@ void ToxAVVoIPModel::handleEvent(const Events::FriendCallState& e) {
|
||||
}
|
||||
|
||||
ToxAVVoIPModel::ToxAVVoIPModel(ObjectStore2& os, ToxAVI& av, ContactStore4I& cs, ToxContactModel2& tcm) :
|
||||
_os(os), _av(av), _av_sr(_av.newSubRef(this)), _cs(cs), _tcm(tcm)
|
||||
_os(os), _av(av), _av_sr(_av.newSubRef(this)), _cs(cs), _cs_sr(_cs.newSubRef(this)), _tcm(tcm)
|
||||
{
|
||||
_av_sr
|
||||
.subscribe(ToxAV_Event::friend_call)
|
||||
@ -550,14 +536,18 @@ ToxAVVoIPModel::ToxAVVoIPModel(ObjectStore2& os, ToxAVI& av, ContactStore4I& cs,
|
||||
.subscribe(ToxAV_Event::iterate_video)
|
||||
;
|
||||
|
||||
// attach to all tox friend contacts
|
||||
{ // attach to all tox friend contacts
|
||||
auto& cr = _cs.registry();
|
||||
|
||||
auto& cr = _cs.registry();
|
||||
|
||||
for (const auto& [cv, _] : cr.view<Contact::Components::ToxFriendPersistent>().each()) {
|
||||
cr.emplace<VoIPModelI*>(cv, this);
|
||||
for (const auto& [cv, _] : cr.view<Contact::Components::ToxFriendPersistent>().each()) {
|
||||
cr.emplace_or_replace<VoIPModelI*>(cv, this);
|
||||
}
|
||||
}
|
||||
// TODO: events
|
||||
|
||||
_cs_sr
|
||||
.subscribe(ContactStore4_Event::contact_construct)
|
||||
.subscribe(ContactStore4_Event::contact_update)
|
||||
;
|
||||
}
|
||||
|
||||
ToxAVVoIPModel::~ToxAVVoIPModel(void) {
|
||||
@ -848,3 +838,34 @@ bool ToxAVVoIPModel::onEvent(const Events::IterateVideo&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ToxAVVoIPModel::onEvent(const ContactStore::Events::Contact4Construct& e) {
|
||||
if (!e.e.all_of<Contact::Components::ToxFriendPersistent>()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(!e.e.any_of<VoIPModelI*>());
|
||||
|
||||
e.e.emplace_or_replace<VoIPModelI*>(this);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ToxAVVoIPModel::onEvent(const ContactStore::Events::Contact4Update& e) {
|
||||
if (!e.e.all_of<Contact::Components::ToxFriendPersistent>()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (e.e.all_of<VoIPModelI*>()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
e.e.emplace<VoIPModelI*>(this);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ToxAVVoIPModel::onEvent(const ContactStore::Events::Contact4Destory&) {
|
||||
// tox already notifies us via a coll state
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <solanaceae/object_store/fwd.hpp>
|
||||
#include <solanaceae/contact/fwd.hpp>
|
||||
#include <solanaceae/contact/contact_store_i.hpp>
|
||||
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
|
||||
#include "./frame_streams/voip_model.hpp"
|
||||
#include "./tox_av.hpp"
|
||||
@ -16,11 +16,12 @@
|
||||
struct ToxAVCallAudioSink;
|
||||
struct ToxAVCallVideoSink;
|
||||
|
||||
class ToxAVVoIPModel : protected ToxAVEventI, public VoIPModelI {
|
||||
class ToxAVVoIPModel : protected ToxAVEventI, protected ContactStore4EventI, public VoIPModelI {
|
||||
ObjectStore2& _os;
|
||||
ToxAVI& _av;
|
||||
ToxAVI::SubscriptionReference _av_sr;
|
||||
ContactStore4I& _cs;
|
||||
ContactStore4I::SubscriptionReference _cs_sr;
|
||||
ToxContactModel2& _tcm;
|
||||
|
||||
uint64_t _pad0;
|
||||
@ -87,5 +88,10 @@ class ToxAVVoIPModel : protected ToxAVEventI, public VoIPModelI {
|
||||
bool onEvent(const Events::FriendVideoFrame&) override;
|
||||
bool onEvent(const Events::IterateAudio&) override;
|
||||
bool onEvent(const Events::IterateVideo&) override;
|
||||
|
||||
protected: // contact events
|
||||
bool onEvent(const ContactStore::Events::Contact4Construct&) override;
|
||||
bool onEvent(const ContactStore::Events::Contact4Update&) override;
|
||||
bool onEvent(const ContactStore::Events::Contact4Destory&) override;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user