Babel
Epitech's C++ VoIP project
AudioPacket.hpp
Go to the documentation of this file.
1 //
2 // Created by mgl on 10/13/21.
3 //
4 
5 #ifndef BABEL_PACKET_HPP
6 #define BABEL_PACKET_HPP
7 
8 #include <array>
9 
10 namespace Babel {
11  using namespace std::chrono;
12 #pragma pack(push, 1)
13 
14  struct AudioPacket {
15 
16  explicit AudioPacket(std::array<unsigned char, 4000> &payloadArray, std::int32_t receivedSize) {
17  std::memcpy(this->data, payloadArray.data(), receivedSize);
18  milliseconds ms = duration_cast<milliseconds>(
19  system_clock::now().time_since_epoch()
20  );
21  this->timestamp = ms.count() % 1000;
22  this->size = receivedSize;
23  }
24 
25  std::uint64_t timestamp;
26  std::int32_t size;
27  unsigned char data[4000]{0};
28  };
29 
30 #pragma pack(pop)
31 
32 }
33 
34 #endif //BABEL_PACKET_HPP
Babel::AudioPacket::timestamp
std::uint64_t timestamp
Definition: AudioPacket.hpp:25
Babel::AudioPacket
Definition: AudioPacket.hpp:14
Babel
Definition: IAudioManager.hpp:13
Babel::AudioPacket::size
std::int32_t size
Definition: AudioPacket.hpp:26
Babel::AudioPacket::AudioPacket
AudioPacket(std::array< unsigned char, 4000 > &payloadArray, std::int32_t receivedSize)
Definition: AudioPacket.hpp:16