Add support for frame resizing. Handle old stream frame type in encoder.

m17 v2.3.0
Rob Riggs 2021-07-01 20:11:31 -05:00
rodzic 70a6ab22f6
commit f35e38a92f
3 zmienionych plików z 24 dodań i 0 usunięć

Wyświetl plik

@ -101,6 +101,7 @@ public:
}
uint16_t size() const {return data_.size();}
bool resize(uint16_t size) {return data_.resize(size);}
uint16_t crc() const {return crc_;}
uint16_t fcs() const {return fcs_;}

Wyświetl plik

@ -225,6 +225,12 @@ void M17Encoder::process_stream(tnc::hdlc::IoFrame* frame, FrameType type)
{
send_stream(frame, type); // Consumes frame.
}
else if (frame->size() == 26)
{
// Old-style frame with trailing CRC.
frame->resize(24);
send_stream(frame, type);
}
else
{
WARN("Unexpected AUDIO frame size = %u", frame->size());

Wyświetl plik

@ -81,6 +81,23 @@ struct SegmentedBuffer {
uint16_t size() const {return size_;}
bool resize(uint16_t size)
{
if (size <= size_)
{
size_ = size;
}
else
{
for (;size_ != size;)
{
if (!push_back(value_type()))
return false;
}
}
return true;
}
bool push_back(value_type value) {
uint16_t offset = size_ & 0xFF;
if (offset == 0) { // Must allocate.