| 621 | } |
| 622 | |
| 623 | void compositor::encoder_work(std::stop_token tok) |
| 624 | { |
| 625 | while (not tok.stop_requested()) |
| 626 | { |
| 627 | auto req = encode_request.exchange(-1); |
| 628 | if (req < 0) |
| 629 | { |
| 630 | encode_request.wait(req); |
| 631 | continue; |
| 632 | } |
| 633 | |
| 634 | assert(req < images.size()); |
| 635 | auto & image = images[req]; |
| 636 | |
| 637 | try |
| 638 | { |
| 639 | for (auto & encoder: encoders) |
| 640 | { |
| 641 | if (encoder->stream_idx < 2 or image.view_info.alpha) |
| 642 | encoder->encode(session, image.view_info, image.frame_index); |
| 643 | } |
| 644 | } |
| 645 | catch (std::exception & e) |
| 646 | { |
| 647 | U_LOG_W("encode error: %s", e.what()); |
| 648 | } |
| 649 | image.busy = false; |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | void compositor::send_video_stream_description() |
| 654 | |