add zox ngc audio packet parsing and events

This commit is contained in:
2023-12-09 12:25:10 +01:00
parent 5759c15716
commit 0db92dd70c
2 changed files with 115 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#include <solanaceae/toxcore/tox_event_interface.hpp>
#include <solanaceae/util/event_provider.hpp>
@@ -10,8 +11,12 @@
// fwd
//struct ToxI;
// zoff ngc history sync (draft1?)
// https://gist.github.com/zoff99/81917ddb2e55b2ce602cac4772a7b68c
// zoff ngc history sync
// https://github.com/zoff99/c-toxcore/blob/zoff99/zoxcore_local_fork/docs/ngc_group_history_sync.md
// (old) https://gist.github.com/zoff99/81917ddb2e55b2ce602cac4772a7b68c
// zoff ngc audio
// https://github.com/zoff99/c-toxcore/blob/zoff99/zoxcore_local_fork/docs/ngc_audio.md
namespace Events {
@@ -38,6 +43,17 @@ namespace Events {
std::string_view message_text;
};
struct ZoxNGC_ngca {
uint32_t group_number {0u};
uint32_t peer_number {0u};
bool _private {true};
uint8_t audio_channels {1u};
uint8_t sampling_freq {48u}; // for 48kHz
std::vector<uint8_t> data; // 1-1362 bytes of opus encoded audio
};
} // Events
enum class ZoxNGC_Event : uint32_t {
@@ -70,6 +86,11 @@ enum class ZoxNGC_Event : uint32_t {
// ...
v0x01_id0x31,
ngca = v0x01_id0x31,
// ...
// v0x02_id0x01
MAX
@@ -81,6 +102,7 @@ struct ZoxNGCEventI {
using enumType = ZoxNGC_Event;
virtual bool onEvent(const Events::ZoxNGC_ngch_request&) { return false; }
virtual bool onEvent(const Events::ZoxNGC_ngch_syncmsg&) { return false; }
virtual bool onEvent(const Events::ZoxNGC_ngca&) { return false; }
};
using ZoxNGCEventProviderI = EventProviderI<ZoxNGCEventI>;
@@ -114,6 +136,12 @@ class ZoxNGCEventProvider : public ToxEventI, public ZoxNGCEventProviderI {
bool _private
);
bool parse_ngca(
uint32_t group_number, uint32_t peer_number,
const uint8_t* data, size_t data_size,
bool _private
);
protected:
bool onToxEvent(const Tox_Event_Group_Custom_Packet* e) override;
bool onToxEvent(const Tox_Event_Group_Custom_Private_Packet* e) override;