Prevent data copy in SCTP transport

This commit is contained in:
Paul-Louis Ageneau
2020-07-22 18:02:00 +02:00
parent 726b4c4c33
commit b6ffa13b72
3 changed files with 34 additions and 39 deletions

View File

@ -37,6 +37,8 @@ struct Message : binary {
Message(Iterator begin_, Iterator end_, Type type_ = Binary)
: binary(begin_, end_), type(type_) {}
Message(binary &&data, Type type_ = Binary) : binary(std::move(data)), type(type_) {}
Type type;
unsigned int stream = 0;
std::shared_ptr<Reliability> reliability;
@ -68,6 +70,15 @@ inline message_ptr make_message(size_t size, Message::Type type = Message::Binar
return message;
}
inline message_ptr make_message(binary &&data, Message::Type type = Message::Binary,
unsigned int stream = 0,
std::shared_ptr<Reliability> reliability = nullptr) {
auto message = std::make_shared<Message>(std::move(data), type);
message->stream = stream;
message->reliability = reliability;
return message;
}
} // namespace rtc
#endif