Files
voice-cat/core/src/protocol/protocol.h
T

34 lines
1.2 KiB
C++
Raw Normal View History

/*
* protocol/protocol.h — control-plane (de)serialization + routing.
*
* Design: docs/protocol.md. Wire format is a length-prefixed protobuf `Envelope`
* (core/proto/voicecat.proto). This layer parses frames into Envelopes, correlates
* request_id ↔ response, and dispatches to handlers. Media frames do NOT come through here
* (they use the fixed binary header in voice.md §2).
*
* STATUS: M0 stub — protobuf codegen is wired in CMake (commented) and turned on in M1.
*/
#ifndef VOICECAT_PROTOCOL_PROTOCOL_H
#define VOICECAT_PROTOCOL_PROTOCOL_H
#include <cstddef>
#include <cstdint>
#include <vector>
namespace voicecat::protocol {
constexpr uint32_t kProtocolVersion = 1; // docs/protocol.md §4
constexpr uint32_t kMaxFrameBytes = 16u * 1024 * 1024; // §1 oversized-frame guard
// Reads/writes [u32 length][payload] frames from a byte stream. TODO(M1).
class FrameCodec {
public:
// Append received bytes; pop complete frame payloads. Returns false on protocol error
// (e.g. length > kMaxFrameBytes).
bool feed(const uint8_t* data, size_t len, std::vector<std::vector<uint8_t>>& out_frames);
};
} // namespace voicecat::protocol
#endif // VOICECAT_PROTOCOL_PROTOCOL_H