sign: Refactor StreamStatsTracking methods
Start/StopStreamStatsTracking() methods made private helper functions specific to PcapPort. AbstractPort::setStreamStatsTracking() virtual function should be implemented by subclasses as required
This commit is contained in:
parent
35c56b9181
commit
8f97a69220
@ -182,12 +182,9 @@ void AbstractPort::addNote(QString note)
|
||||
|
||||
bool AbstractPort::setTrackStreamStats(bool enable)
|
||||
{
|
||||
bool val = enable ? startStreamStatsTracking() : stopStreamStatsTracking();
|
||||
data_.set_track_stream_stats(enable);
|
||||
|
||||
if (val)
|
||||
data_.set_track_stream_stats(enable);
|
||||
|
||||
return val;
|
||||
return true;
|
||||
}
|
||||
|
||||
AbstractPort::Accuracy AbstractPort::rateAccuracy()
|
||||
|
@ -116,8 +116,6 @@ public:
|
||||
void stats(PortStats *stats);
|
||||
void resetStats() { epochStats_ = stats_; }
|
||||
|
||||
virtual bool startStreamStatsTracking() = 0;
|
||||
virtual bool stopStreamStatsTracking() = 0;
|
||||
// FIXME: combine single and All calls?
|
||||
void streamStats(uint guid, OstProto::StreamStatsList *stats);
|
||||
void streamStatsAll(OstProto::StreamStatsList *stats);
|
||||
|
@ -121,6 +121,16 @@ void PcapPort::updateNotes()
|
||||
arg(notes).toStdString());
|
||||
}
|
||||
|
||||
bool PcapPort::setTrackStreamStats(bool enable)
|
||||
{
|
||||
bool val = enable ? startStreamStatsTracking() : stopStreamStatsTracking();
|
||||
|
||||
if (val)
|
||||
AbstractPort::setTrackStreamStats(enable);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
bool PcapPort::setRateAccuracy(AbstractPort::Accuracy accuracy)
|
||||
{
|
||||
if (transmitter_->setRateAccuracy(accuracy)) {
|
||||
@ -130,6 +140,21 @@ bool PcapPort::setRateAccuracy(AbstractPort::Accuracy accuracy)
|
||||
return false;
|
||||
}
|
||||
|
||||
void PcapPort::startDeviceEmulation()
|
||||
{
|
||||
emulXcvr_->start();
|
||||
}
|
||||
|
||||
void PcapPort::stopDeviceEmulation()
|
||||
{
|
||||
emulXcvr_->stop();
|
||||
}
|
||||
|
||||
int PcapPort::sendEmulationPacket(PacketBuffer *pktBuf)
|
||||
{
|
||||
return emulXcvr_->transmitPacket(pktBuf);
|
||||
}
|
||||
|
||||
bool PcapPort::startStreamStatsTracking()
|
||||
{
|
||||
if (!transmitter_->setStreamStatsTracking(true))
|
||||
@ -160,21 +185,6 @@ _tx_fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
void PcapPort::startDeviceEmulation()
|
||||
{
|
||||
emulXcvr_->start();
|
||||
}
|
||||
|
||||
void PcapPort::stopDeviceEmulation()
|
||||
{
|
||||
emulXcvr_->stop();
|
||||
}
|
||||
|
||||
int PcapPort::sendEmulationPacket(PacketBuffer *pktBuf)
|
||||
{
|
||||
return emulXcvr_->transmitPacket(pktBuf);
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------------------- *
|
||||
* Port Monitor
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
virtual bool hasExclusiveControl() { return false; }
|
||||
virtual bool setExclusiveControl(bool /*exclusive*/) { return false; }
|
||||
|
||||
virtual bool setTrackStreamStats(bool enable);
|
||||
virtual bool setRateAccuracy(AbstractPort::Accuracy accuracy);
|
||||
|
||||
virtual void clearPacketList() {
|
||||
@ -72,9 +73,6 @@ public:
|
||||
virtual bool isCaptureOn() { return capturer_->isRunning(); }
|
||||
virtual QIODevice* captureData() { return capturer_->captureFile(); }
|
||||
|
||||
virtual bool startStreamStatsTracking();
|
||||
virtual bool stopStreamStatsTracking();
|
||||
|
||||
virtual void startDeviceEmulation();
|
||||
virtual void stopDeviceEmulation();
|
||||
virtual int sendEmulationPacket(PacketBuffer *pktBuf);
|
||||
@ -167,6 +165,9 @@ protected:
|
||||
void updateNotes();
|
||||
|
||||
private:
|
||||
bool startStreamStatsTracking();
|
||||
bool stopStreamStatsTracking();
|
||||
|
||||
PcapTransmitter *transmitter_;
|
||||
PortCapturer *capturer_;
|
||||
EmulationTransceiver *emulXcvr_;
|
||||
|
Loading…
Reference in New Issue
Block a user