17#ifndef CYBER_TRANSPORT_TRANSMITTER_RTPS_TRANSMITTER_H_
18#define CYBER_TRANSPORT_TRANSMITTER_RTPS_TRANSMITTER_H_
30#include "fastrtps/Domain.h"
31#include "fastrtps/attributes/PublisherAttributes.h"
32#include "fastrtps/participant/Participant.h"
33#include "fastrtps/publisher/Publisher.h"
62 eprosima::fastrtps::Publisher* publisher_;
73 :
Transmitter<M>(attr), participant_(participant), publisher_(nullptr) {}
100 eprosima::fastrtps::PublisherAttributes pub_attr;
102 this->attr_.channel_name(), this->attr_.qos_profile(), &pub_attr));
103 publisher_ = eprosima::fastrtps::Domain::createPublisher(
104 participant_->fastrtps_participant(), pub_attr);
106 this->enabled_ =
true;
111 if (this->enabled_) {
112 publisher_ =
nullptr;
113 this->enabled_ =
false;
120 return Transmit(*msg, msg_info);
125 if (!this->enabled_) {
133 uint64_t send_time = msg_info.
send_time();
135 m.timestamp(0x0fffffff & send_time);
138 eprosima::fastrtps::rtps::WriteParams wparams;
141 reinterpret_cast<char*
>(&wparams.related_sample_identity().writer_guid());
146 wparams.related_sample_identity().sequence_number().high =
147 (int32_t)((msg_info.
seq_num() & 0xFFFFFFFF00000000) >> 32);
148 wparams.related_sample_identity().sequence_number().low =
149 (int32_t)(msg_info.
seq_num() & 0xFFFFFFFF);
151 if (participant_->is_shutdown()) {
154 return publisher_->write(
reinterpret_cast<void*
>(&m), wparams);
static bool FillInPubAttr(const std::string &channel_name, const QosProfile &qos, eprosima::fastrtps::PublisherAttributes *pub_attr)
const char * data() const
const Identity & sender_id() const
int32_t msg_seq_num() const
uint64_t send_time() const
const Identity & spare_id() const
bool Transmit(const MessagePtr &msg, const MessageInfo &msg_info) override
RtpsTransmitter(const RoleAttributes &attr, const ParticipantPtr &participant)
bool AcquireMessage(std::shared_ptr< M > &msg)
std::shared_ptr< M > MessagePtr
virtual ~RtpsTransmitter()
#define RETURN_IF_NULL(ptr)
#define RETURN_VAL_IF(condition, val)
#define RETURN_IF(condition)
std::enable_if< HasSerializeToString< T >::value, bool >::type SerializeToString(const T &message, std::string *str)
std::shared_ptr< Participant > ParticipantPtr
constexpr uint8_t ID_SIZE