| 47 | { |
| 48 | |
| 49 | video_encoder::sender::sender() : |
| 50 | thread([this](std::stop_token t) { |
| 51 | while (not t.stop_requested()) |
| 52 | { |
| 53 | data * d = nullptr; |
| 54 | { |
| 55 | std::unique_lock lock(mutex); |
| 56 | if (pending.empty()) |
| 57 | cv.wait_for(lock, std::chrono::milliseconds(100)); |
| 58 | else |
| 59 | d = &pending.front(); |
| 60 | } |
| 61 | if (d and not d->span.empty()) |
| 62 | { |
| 63 | d->encoder->SendData(d->span, true, d->prefer_control); |
| 64 | std::unique_lock lock(mutex); |
| 65 | pending.pop_front(); |
| 66 | cv.notify_all(); |
| 67 | } |
| 68 | } |
| 69 | std::unique_lock lock(mutex); |
| 70 | pending.clear(); |
| 71 | cv.notify_all(); |
| 72 | }) |
| 73 | { |
| 74 | } |
| 75 | |
| 76 | void video_encoder::sender::push(data && d) |
| 77 | { |