keep record from where universe data was sourced

This commit is contained in:
Kevin Matz 2021-01-27 09:49:55 -05:00
parent 240037eb5b
commit d4a24f427c
3 changed files with 71 additions and 13 deletions

View File

@ -132,23 +132,23 @@ void Receiver::dataPacketHandler(std::shared_ptr<DATA::Pdu> frame) {
// header may be inherited. check that one exists
if (!frame->header())
return;
auto header = (DATA::frame_header *)frame->header();
auto source = std::shared_ptr<UniverseSource>(new UniverseSource(frame));
if (universes_.count(header->universe) == 0)
if (universes_.count(source->universe()) == 0)
return;
Universe * universe = universes_.at(header->universe);
Universe * universe = universes_.at(source->universe());
// 6.2.3 E1.31 Data Packet: Priority
// No priority outside the range of 0 to 200 shall be transmitted on
// the network.
if (header->priority > 200)
if (source->priority() > 200)
frame->buffer()->setstate(frame->buffer()->rdstate() |
std::ios_base::failbit);
// 6.2.6 E1.31 Data Packet: Options
// Preview_Data: Bit 7 (most significant bit)
// This bit, when set to 1, indicates that the data in this packet is intended for use in visualization or media server preview applications and shall not be used to generate live output.
if (header->options & DATA::PREVIEW_DATA)
if (source->isPreview())
return;
@ -158,8 +158,8 @@ void Receiver::dataPacketHandler(std::shared_ptr<DATA::Pdu> frame) {
// universe synchronization without waiting for a timeout to occur.
// Any property values in an E1.31 Data Packet containing this bit
// shall be ignored.
if (header->options & DATA::STREAM_TERMINATED) {
unsubscribe(header->universe);
if (source->isTerminated()) {
unsubscribe(source->universe());
return;
}
@ -172,7 +172,7 @@ void Receiver::dataPacketHandler(std::shared_ptr<DATA::Pdu> frame) {
// been lost, components that had been operating in a synchronized state need
// not wait for a new E1.31 Synchronization Packet in order to update to the
// next E1.31 Data Packet.
if (!(header->options & DATA::FORCE_SYNCHRONIZATION) &&
if (!source->isForced() &&
universe->isSyncronized()) {
return; // operate in synchronized state?
}
@ -180,11 +180,11 @@ void Receiver::dataPacketHandler(std::shared_ptr<DATA::Pdu> frame) {
// 6.2.4.1 Synchronization Address Usage in an E1.31 Data Packet
// a value of 0 in the Synchronization Address indicates that the universe
// data is not synchronized.
if (header->sync_address != 0) {
if (source->syncAddress() != 0) {
// TODO: do somthing to engage synchronization
}
// If a receiver is presented with an E1.31 Data Packet containing a Synchronization Address of 0, it shall discard any data waiting to be processed and immediately act on that Data Packet.
if (header->sync_address == 0 && universe->isSyncronized()) {
if (source->syncAddress() == 0 && universe->isSyncronized()) {
// TODO:: do something to break synchronization
}
@ -206,7 +206,7 @@ void Receiver::dataPacketHandler(std::shared_ptr<DATA::Pdu> frame) {
// the packet if the received value is not VECTOR_DMP_SET_PROPERTY.
switch(dmp->vector()) {
case DMP::SET_PROPERTY:
universe->set(dmp);
universe->set(dmp, source);
break;
default:
break;

View File

@ -26,13 +26,37 @@
namespace SACN {
/**
Construct a Universe Source from an sACN frame PDU
*/
UniverseSource::UniverseSource(std::shared_ptr<DATA::Pdu> pdu) {
auto root_header = (RLP::rlp_header*)pdu->header();
cid_ = root_header->cid;
auto frame_header = (DATA::frame_header*)pdu->header();
description_ = std::string((char*)frame_header->source_name);
universe_ = frame_header->universe;
priority_ = frame_header->priority;
sync_address_ = frame_header->sync_address;
options_ = frame_header->options;
};
/**
Construct a new Universe.
*/
Universe::Universe()
: DMX::Universe()
{
synchronized_ = false;
}
void Universe::set(std::shared_ptr<DMP::Pdu> dmp) {
/**
Set universe data from a DMP PDU from a UniverseSource.
*/
void Universe::set(std::shared_ptr<DMP::Pdu> dmp,
std::shared_ptr<UniverseSource> source) {
// 7.3 Address Type and Data Type
// Sources shall set the DMP Layer's Address Type and Data Type to 0xa1.
// Receivers shall discard the packet if the received value is not 0xa1.
@ -75,6 +99,7 @@ void Universe::set(std::shared_ptr<DMP::Pdu> dmp) {
/// The DMP Layer's Property values field is used to encode the
// DMX512-A [DMX] START Code and data.
DMX::Universe::set(pd);
source_ = source;
}
}; // SACN

View File

@ -24,11 +24,43 @@
#pragma once
#include "sacn.h"
#include "data.h"
#include "../dmx/universe.h"
#include "../uuid/uuid.h"
#include <memory>
#include <string>
namespace SACN {
/**
universe metadata
*/
class UniverseSource
{
public:
UniverseSource(std::shared_ptr<DATA::Pdu>);
const UUID::uuid cid() const {return cid_;};
const std::string description() const {return description_;}
const uint16_t universe() const {return universe_;}
const uint8_t priority() const {return priority_;}
const uint16_t syncAddress() const {return sync_address_;}
const bool isTerminated() const {return options_
& DATA::STREAM_TERMINATED;}
const bool isPreview() const {return options_
& DATA::PREVIEW_DATA;}
const bool isForced() const {return options_
& DATA::FORCE_SYNCHRONIZATION;}
private:
UUID::uuid cid_;
std::string description_;
uint16_t universe_;
uint8_t priority_;
uint16_t sync_address_;
uint8_t options_;
};
/**
universe data
*/
@ -39,10 +71,11 @@ public:
Universe();
bool isSyncronized() const {return synchronized_;};
void set(std::shared_ptr<DMP::Pdu>);
void set(std::shared_ptr<DMP::Pdu>, std::shared_ptr<UniverseSource>);
private:
bool synchronized_;
std::shared_ptr<UniverseSource> source_;
};