| 731 | } |
| 732 | |
| 733 | void AppStreamList::LoadStreamItems() { |
| 734 | context_->PostUITask([=, this]() { |
| 735 | { |
| 736 | auto db_mgr = context_->GetStreamDBManager(); |
| 737 | std::lock_guard<std::mutex> guard(streams_mtx_); |
| 738 | streams_ = db_mgr->GetAllStreamsSortByCreatedTime(); |
| 739 | |
| 740 | // bench test |
| 741 | // auto fn_rand_a_upper_char = []() -> char { |
| 742 | // char c = 'A' + rand() % 26; |
| 743 | // return c; |
| 744 | // }; |
| 745 | // for (int i = 0; i < 100; i++) { |
| 746 | // auto st = std::make_shared<spvr::SpvrStream>(); |
| 747 | // st->stream_name_ = std::format("Desktop: {}", i+1); |
| 748 | // st->stream_host_ = std::format("192.168.1.{}", i+5); |
| 749 | // st->desktop_name_ = StringUtil::ToUpperCpy(std::format("DESKTOP-{}{}{}{}{}", fn_rand_a_upper_char(), fn_rand_a_upper_char(), fn_rand_a_upper_char(), fn_rand_a_upper_char(), fn_rand_a_upper_char())); |
| 750 | // streams_.push_back(st); |
| 751 | // } |
| 752 | |
| 753 | int count = stream_list_->count(); |
| 754 | for (int i = 0; i < count; i++) { |
| 755 | auto item = stream_list_->takeItem(0); |
| 756 | delete item; |
| 757 | } |
| 758 | |
| 759 | int index = 0; |
| 760 | for (auto& stream : streams_) { |
| 761 | stream->device_id_ = settings_->GetDeviceId(); |
| 762 | AddItem(stream, index++); |
| 763 | } |
| 764 | |
| 765 | if (!streams_.empty()) { |
| 766 | stream_content_->HideEmptyTip(); |
| 767 | } |
| 768 | else { |
| 769 | stream_content_->ShowEmptyTip(); |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | // update to stream state checker |
| 774 | cat streams = CopyStreams(); |
| 775 | state_checker_->UpdateCurrentStreamItems(streams); |
| 776 | }); |
| 777 | } |
| 778 | |
| 779 | void AppStreamList::RequestBindDevices() { |
| 780 | auto user_mgr = grApp->GetUserManager(); |
no test coverage detected