1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker #ifndef NET_DCSCTP_PUBLIC_DCSCTP_MESSAGE_H_ 11*d9f75844SAndroid Build Coastguard Worker #define NET_DCSCTP_PUBLIC_DCSCTP_MESSAGE_H_ 12*d9f75844SAndroid Build Coastguard Worker 13*d9f75844SAndroid Build Coastguard Worker #include <cstdint> 14*d9f75844SAndroid Build Coastguard Worker #include <utility> 15*d9f75844SAndroid Build Coastguard Worker #include <vector> 16*d9f75844SAndroid Build Coastguard Worker 17*d9f75844SAndroid Build Coastguard Worker #include "api/array_view.h" 18*d9f75844SAndroid Build Coastguard Worker #include "net/dcsctp/public/types.h" 19*d9f75844SAndroid Build Coastguard Worker 20*d9f75844SAndroid Build Coastguard Worker namespace dcsctp { 21*d9f75844SAndroid Build Coastguard Worker 22*d9f75844SAndroid Build Coastguard Worker // An SCTP message is a group of bytes sent and received as a whole on a 23*d9f75844SAndroid Build Coastguard Worker // specified stream identifier (`stream_id`), and with a payload protocol 24*d9f75844SAndroid Build Coastguard Worker // identifier (`ppid`). 25*d9f75844SAndroid Build Coastguard Worker class DcSctpMessage { 26*d9f75844SAndroid Build Coastguard Worker public: DcSctpMessage(StreamID stream_id,PPID ppid,std::vector<uint8_t> payload)27*d9f75844SAndroid Build Coastguard Worker DcSctpMessage(StreamID stream_id, PPID ppid, std::vector<uint8_t> payload) 28*d9f75844SAndroid Build Coastguard Worker : stream_id_(stream_id), ppid_(ppid), payload_(std::move(payload)) {} 29*d9f75844SAndroid Build Coastguard Worker 30*d9f75844SAndroid Build Coastguard Worker DcSctpMessage(DcSctpMessage&& other) = default; 31*d9f75844SAndroid Build Coastguard Worker DcSctpMessage& operator=(DcSctpMessage&& other) = default; 32*d9f75844SAndroid Build Coastguard Worker DcSctpMessage(const DcSctpMessage&) = delete; 33*d9f75844SAndroid Build Coastguard Worker DcSctpMessage& operator=(const DcSctpMessage&) = delete; 34*d9f75844SAndroid Build Coastguard Worker 35*d9f75844SAndroid Build Coastguard Worker // The stream identifier to which the message is sent. stream_id()36*d9f75844SAndroid Build Coastguard Worker StreamID stream_id() const { return stream_id_; } 37*d9f75844SAndroid Build Coastguard Worker 38*d9f75844SAndroid Build Coastguard Worker // The payload protocol identifier (ppid) associated with the message. ppid()39*d9f75844SAndroid Build Coastguard Worker PPID ppid() const { return ppid_; } 40*d9f75844SAndroid Build Coastguard Worker 41*d9f75844SAndroid Build Coastguard Worker // The payload of the message. payload()42*d9f75844SAndroid Build Coastguard Worker rtc::ArrayView<const uint8_t> payload() const { return payload_; } 43*d9f75844SAndroid Build Coastguard Worker 44*d9f75844SAndroid Build Coastguard Worker // When destructing the message, extracts the payload. ReleasePayload()45*d9f75844SAndroid Build Coastguard Worker std::vector<uint8_t> ReleasePayload() && { return std::move(payload_); } 46*d9f75844SAndroid Build Coastguard Worker 47*d9f75844SAndroid Build Coastguard Worker private: 48*d9f75844SAndroid Build Coastguard Worker StreamID stream_id_; 49*d9f75844SAndroid Build Coastguard Worker PPID ppid_; 50*d9f75844SAndroid Build Coastguard Worker std::vector<uint8_t> payload_; 51*d9f75844SAndroid Build Coastguard Worker }; 52*d9f75844SAndroid Build Coastguard Worker } // namespace dcsctp 53*d9f75844SAndroid Build Coastguard Worker 54*d9f75844SAndroid Build Coastguard Worker #endif // NET_DCSCTP_PUBLIC_DCSCTP_MESSAGE_H_ 55