Skip to content

Commit

Permalink
ADD key select
Browse files Browse the repository at this point in the history
  • Loading branch information
TalusL committed Jun 12, 2024
1 parent b638883 commit 3613971
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 10 deletions.
37 changes: 36 additions & 1 deletion qml/main.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import realTimePlayer 1.0
import Qt.labs.platform 1.1


ApplicationWindow {
visible: true
Expand Down Expand Up @@ -157,6 +159,39 @@ ApplicationWindow {
height: actionText.height + 10
color: "#1c80c9"

Text {
id: keyText
x: 5
anchors.verticalCenter: parent.verticalCenter
text: "Key"
font.pixelSize: 16
color: "#ffffff"
}
}
Column {
FileDialog {
id: fileDialog
title: "Select key File"
nameFilters: ["Key Files (*.key)"]

onAccepted: {
keySelector.text = file;
keySelector.text = keySelector.text.replace('file:///','')
}
}
Button {
width: 190
id:keySelector
text: "gs.key"
onClicked: fileDialog.open()
}
}
Rectangle {
// Size of the background adapts to the text size plus some padding
width: 190
height: actionText.height + 10
color: "#1c80c9"

Text {
id: actionText
x: 5
Expand Down Expand Up @@ -194,7 +229,7 @@ ApplicationWindow {
}
onClicked: function(){
if(!actionStartText.started){
actionStartText.started = NativeApi.Start(selectDev.currentText,Number(selectChannel.currentText),Number(selectBw.currentIndex));
actionStartText.started = NativeApi.Start(selectDev.currentText,Number(selectChannel.currentText),Number(selectBw.currentIndex),keySelector.text);
}else{
NativeApi.Stop();
}
Expand Down
4 changes: 2 additions & 2 deletions src/QmlNativeAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class QmlNativeAPI : public QObject {
return l;
};
Q_INVOKABLE static bool Start(const QString &vidPid, int channel,
int channelWidth) {
return WFBReceiver::Start(vidPid.toStdString(), channel, channelWidth);
int channelWidth,const QString &keyPath) {
return WFBReceiver::Start(vidPid.toStdString(), channel, channelWidth,keyPath.toStdString());
}
Q_INVOKABLE static bool Stop() {
return WFBReceiver::Stop();
Expand Down
18 changes: 12 additions & 6 deletions src/WFBReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ libusb_context *WFBReceiver::ctx{};
libusb_device_handle *WFBReceiver::dev_handle{};
std::shared_ptr<std::thread> WFBReceiver::usbThread{};
std::unique_ptr<Rtl8812aDevice> WFBReceiver::rtlDevice;
std::string WFBReceiver::keyPath;

std::vector<std::string> WFBReceiver::GetDongleList() {
std::vector<std::string> list;
Expand Down Expand Up @@ -56,8 +57,8 @@ std::vector<std::string> WFBReceiver::GetDongleList() {
return list;
}
bool WFBReceiver::Start(const std::string &vidPid, uint8_t channel,
int channelWidth) {

int channelWidth,const std::string& kPath) {
keyPath = kPath;
if(usbThread){
return false;
}
Expand Down Expand Up @@ -110,8 +111,9 @@ bool WFBReceiver::Start(const std::string &vidPid, uint8_t channel,
.ChannelOffset = 0,
.ChannelWidth = static_cast<ChannelWidth_t>(channelWidth),
});
}catch (...){
}
}catch (const std::runtime_error& e){
logger->error(e.what());
}catch (...){}
auto rc = libusb_release_interface(dev_handle, 0);
if (rc < 0) {
// error
Expand Down Expand Up @@ -147,15 +149,19 @@ void WFBReceiver::handle80211Frame(const Packet &packet) {

static std::mutex agg_mutex;
static std::unique_ptr<Aggregator> video_aggregator = std::make_unique<Aggregator>(
"gs.key",epoch,video_channel_id_f,[](uint8_t *payload,uint16_t packet_size) {

keyPath.c_str(),epoch,video_channel_id_f,[](uint8_t *payload,uint16_t packet_size) {
handleRtp(payload,packet_size);
});

std::lock_guard<std::mutex> lock(agg_mutex);
if (frame.MatchesChannelID(video_channel_id_be8)) {
video_aggregator->process_packet(packet.Data.data() + sizeof(ieee80211_header), packet.Data.size() - sizeof(ieee80211_header) - 4, 0, antenna, rssi);
}
}

void WFBReceiver::handleRtp(uint8_t *payload, uint16_t packet_size) {
}

bool WFBReceiver::Stop() {
if(rtlDevice){
rtlDevice->should_stop = true;
Expand Down
4 changes: 3 additions & 1 deletion src/WFBReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ class WFBReceiver {
~WFBReceiver();
static std::vector<std::string> GetDongleList();
static bool Start(const std::string &vidPid, uint8_t channel,
int channelWidth);
int channelWidth,const std::string& keyPath);
static bool Stop();
static void handle80211Frame(const Packet &pkt);
static void handleRtp(uint8_t *payload,uint16_t packet_size);
protected:
static libusb_context *ctx;
static libusb_device_handle *dev_handle;
static std::shared_ptr<std::thread> usbThread;
static std::unique_ptr<Rtl8812aDevice> rtlDevice;
static std::string keyPath;
};

#endif // WFBRECEIVER_H

0 comments on commit 3613971

Please sign in to comment.