• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bcpearce / hass-motion-detection-addon / 21126887229

19 Jan 2026 05:54AM UTC coverage: 17.99% (-32.0%) from 49.971%
21126887229

Pull #26

github

web-flow
Merge c98d1d60e into 0206cb867
Pull Request #26: Additional test coverage

292 of 1865 branches covered (15.66%)

Branch coverage included in aggregate %.

8 of 22 new or added lines in 3 files covered. (36.36%)

827 existing lines in 29 files now uncovered.

347 of 1687 relevant lines covered (20.57%)

28.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/include/Gui/WebHandler.h
1
#pragma once
2

3
#include "Gui/Payload.h"
4

5
#include <boost/url.hpp>
6
#include <gsl/gsl>
7
#include <mongoose.h>
8
#include <opencv2/core.hpp>
9

10
#include <filesystem>
11
#include <shared_mutex>
12
#include <string_view>
13
#include <thread>
14
#include <vector>
15

16
namespace gui {
17

18
class WebHandler {
19
public:
20
  static void EventHandler(mg_connection *c, int ev, void *ev_data);
21
  static void
22
  SetSavedFilesServePath(std::string_view slug,
23
                         const std::filesystem::path &savedFilesPath);
24

25
  explicit WebHandler(int port, std::string_view host = "0.0.0.0");
26
  WebHandler(const WebHandler &) = delete;
27
  WebHandler &operator=(const WebHandler &) = delete;
28
  WebHandler(WebHandler &&) = delete;
29
  WebHandler &operator=(WebHandler &&) = delete;
30

31
  void Start();
32
  void Stop();
33

34
  const boost::url &GetUrl() const noexcept;
35

UNCOV
36
  ~WebHandler() noexcept = default;
×
37

38
  void operator()(Payload data);
39

40
private:
41
  mg_mgr mgr_;
42

43
  boost::url url_;
44

45
  struct BroadcastImageData {
46
    gsl::not_null<mg_mgr *> mgr;
47
    std::vector<uint8_t> jpgBuf;
48
    gsl::not_null<std::shared_mutex *> mtx;
49
    std::array<char, 2> marker{'\0', char(-1)};
50
  };
51

52
  struct FeedImageData {
53
    cv::Mat imageBgr_;
54
    cv::Mat modelBgr_;
55

56
    std::shared_mutex imageMtx_;
57
    std::vector<uint8_t> imageJpeg_;
58
    BroadcastImageData imageBroadcastData_;
59

60
    std::shared_mutex modelMtx_;
61
    std::vector<uint8_t> modelJpeg_;
62
    BroadcastImageData modelBroadcastData_;
63

UNCOV
64
    explicit FeedImageData(mg_mgr *mgr)
×
UNCOV
65
        : imageBroadcastData_{.mgr = mgr,
×
66
                              .mtx = &modelMtx_,
67
                              .marker = {'L', char(-1)}},
UNCOV
68
          modelBroadcastData_{
×
UNCOV
69
              .mgr = mgr, .mtx = &imageMtx_, .marker = {'M', char(-1)}} {}
×
70
  };
71

72
  using BroadcastMap =
73
      std::unordered_map<std::string_view, std::unique_ptr<FeedImageData>>;
74
  BroadcastMap feedImageDataMap_;
75

76
  static void BroadcastMjpegFrame(gui::WebHandler::BroadcastMap *broadcastData);
77
  static void BroadcastImage_TimerCallback(void *arg);
78

79
  std::jthread listenerThread_;
80
};
81

82
} // namespace gui
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc