Add FPS and byte count telemetry measurement for sources. (#125)

* Add FPS and byte count telemetry measurement for sources.

* Add new error code for telemetry not enabled.
This commit is contained in:
Peter Johnson
2018-03-04 21:01:55 -08:00
committed by GitHub
parent 698feff2ff
commit 040731447f
18 changed files with 414 additions and 5 deletions

View File

@@ -16,10 +16,18 @@ int main() {
llvm::outs() << "IPv4 network addresses:\n";
for (const auto& addr : cs::GetNetworkInterfaces())
llvm::outs() << " " << addr << '\n';
cs::UsbCamera camera{"usbcam", 1};
cs::UsbCamera camera{"usbcam", 0};
camera.SetVideoMode(cs::VideoMode::kMJPEG, 320, 240, 30);
cs::MjpegServer mjpegServer{"httpserver", 8081};
mjpegServer.SetSource(camera);
CS_Status status = 0;
cs::AddListener([&](const cs::RawEvent& event) {
llvm::outs() << "FPS=" << camera.GetActualFPS()
<< " MBPS=" << (camera.GetActualDataRate() /
1000000.0) << '\n';
}, cs::RawEvent::kTelemetryUpdated, false, &status);
cs::SetTelemetryPeriod(1.0);
std::getchar();
}