wip toxav voip model (only asink and outgoing call and missing reframer)
This commit is contained in:
42
src/frame_streams/locked_frame_stream.hpp
Normal file
42
src/frame_streams/locked_frame_stream.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include "./frame_stream2.hpp"
|
||||
|
||||
#include <mutex>
|
||||
#include <deque>
|
||||
|
||||
// threadsafe queue frame stream
|
||||
// protected by a simple mutex lock
|
||||
// prefer lockless queue implementations, when available
|
||||
template<typename FrameType>
|
||||
struct LockedFrameStream2 : public FrameStream2I<FrameType> {
|
||||
std::mutex _lock;
|
||||
|
||||
std::deque<FrameType> _frames;
|
||||
|
||||
~LockedFrameStream2(void) {}
|
||||
|
||||
int32_t size(void) { return -1; }
|
||||
|
||||
std::optional<FrameType> pop(void) {
|
||||
std::lock_guard lg{_lock};
|
||||
|
||||
if (_frames.empty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
FrameType new_frame = std::move(_frames.front());
|
||||
_frames.pop_front();
|
||||
|
||||
return std::move(new_frame);
|
||||
}
|
||||
|
||||
bool push(const FrameType& value) {
|
||||
std::lock_guard lg{_lock};
|
||||
|
||||
_frames.push_back(value);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -10,9 +10,9 @@ namespace Components::VoIP {
|
||||
struct TagVoIPSession {};
|
||||
|
||||
// to talk to the model handling this session
|
||||
struct VoIPModel {
|
||||
VoIPModelI* ptr {nullptr};
|
||||
};
|
||||
//struct VoIPModel {
|
||||
//VoIPModelI* ptr {nullptr};
|
||||
//};
|
||||
|
||||
struct SessionState {
|
||||
// ????
|
||||
@ -59,13 +59,13 @@ struct VoIPModelI {
|
||||
bool outgoing_audio {true};
|
||||
bool outgoing_video {true};
|
||||
};
|
||||
virtual ObjectHandle enter(const Contact3 c, const DefaultConfig& defaults = {});
|
||||
virtual ObjectHandle enter(const Contact3 c, const DefaultConfig& defaults = {true, true, true, true}) { return {}; }
|
||||
|
||||
// accept/join an invite to a session
|
||||
virtual bool accept(ObjectHandle session);
|
||||
virtual bool accept(ObjectHandle session) { return false; }
|
||||
|
||||
// leaves a call
|
||||
// - VoIP session object
|
||||
virtual bool leave(ObjectHandle session);
|
||||
virtual bool leave(ObjectHandle session) { return false; }
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user