@@ -65,7 +65,7 @@ void WfbngLink::initAgg() {
6565 video_channel_id_be = htobe32 (video_channel_id_f);
6666 auto udsName = std::string (" my_socket" );
6767
68- video_aggregator = std::make_unique<AggregatorUNIX>(udsName , keyPath, epoch, video_channel_id_f, 0 );
68+ video_aggregator = std::make_unique<AggregatorUDPv4>(client_addr, 5600 , keyPath, epoch, video_channel_id_f, 0 );
6969
7070 int mavlink_client_port = 14550 ;
7171 uint8_t mavlink_radio_port = 0x10 ;
@@ -392,76 +392,6 @@ extern "C" JNIEXPORT void JNICALL Java_com_openipc_wfbngrtl8812_WfbNgLink_native
392392 native (wfbngLinkN)->initAgg ();
393393}
394394
395-
396- class FecChangeController
397- {
398- public:
399- // / \brief Query the current (possibly decayed) fec_change value.
400- // / Call this as often as you like; the class handles its own timing.
401- int value ()
402- {
403- if (!mEnabled )
404- return 0 ;
405-
406- std::lock_guard<std::mutex> lock (mx_);
407- decayLocked_ ();
408- return val_;
409- }
410-
411- // / \brief Raise fec_change. If newValue <= current, the call is ignored.
412- // / A successful bump resets the 5-second “hold” timer.
413- void bump (int newValue)
414- {
415- std::lock_guard<std::mutex> lock (mx_);
416- if (newValue > val_) {
417- __android_log_print (ANDROID_LOG_ERROR, TAG, " bumping FEC: %d" , newValue);
418-
419- val_ = newValue;
420- lastChange_ = Clock::now ();
421- }
422- }
423-
424- void setEnabled (bool use){
425- mEnabled = use;
426- }
427-
428- private:
429- using Clock = std::chrono::steady_clock;
430- static constexpr std::chrono::seconds kTick {1 }; // length of one hold/decay window
431-
432- void decayLocked_ ()
433- {
434- if (val_ == 0 ) return ;
435-
436- auto now = Clock::now ();
437- auto elapsed = now - lastChange_;
438-
439- // Still inside the mandatory 5-second hold? Do nothing.
440- if (elapsed < kTick ) return ;
441-
442- // How many *full* ticks have passed since lastChange_?
443- auto ticks = std::chrono::duration_cast<std::chrono::seconds>(elapsed).count () / kTick .count ();
444- if (ticks == 0 ) return ; // safety net (shouldn’t hit)
445-
446- int decayed = val_ - static_cast <int >(ticks);
447- if (decayed < 0 ) decayed = 0 ;
448-
449- // Commit the decay and anchor lastChange_ on the most recent tick boundary
450- if (decayed != val_) {
451- val_ = decayed;
452- lastChange_ += kTick * ticks;
453- }
454- }
455-
456- int val_ {0 };
457- Clock::time_point lastChange_ {Clock::now ()};
458- std::mutex mx_;
459- bool mEnabled = true ;
460- };
461-
462-
463- FecChangeController fec;
464-
465395// Modified start_link_quality_thread: use adaptive_link_enabled and adaptive_tx_power
466396void WfbngLink::start_link_quality_thread (int fd) {
467397 auto thread_func = [this , fd]() {
@@ -567,7 +497,7 @@ void WfbngLink::start_link_quality_thread(int fd) {
567497 len = strlen (message + sizeof (len));
568498 len = htonl (len);
569499 memcpy (message, &len, sizeof (len));
570- __android_log_print (ANDROID_LOG_ERROR, TAG, " message %s" , message + 4 );
500+ __android_log_print (ANDROID_LOG_ERROR, TAG, " message %s" , message + 4 );
571501 ssize_t sent = sendto (sockfd,
572502 message,
573503 strlen (message + sizeof (len)) + sizeof (len),
@@ -633,5 +563,6 @@ extern "C" JNIEXPORT void JNICALL Java_com_openipc_wfbngrtl8812_WfbNgLink_native
633563 jclass clazz,
634564 jlong wfbngLinkN,
635565 jint use) {
636- fec.setEnabled (use);
566+ WfbngLink *link = native (wfbngLinkN);
567+ link->fec .setEnabled (use);
637568}
0 commit comments