package com.geehe.fpvue;
import android.Manifest;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.provider.MediaStore;
import android.util.Base64;
import android.util.Log;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import com.geehe.fpvue.databinding.ActivityVideoBinding;
import com.geehe.fpvue.osd.OSDElement;
import com.geehe.fpvue.osd.OSDManager;
import com.geehe.mavlink.MavlinkData;
import com.geehe.mavlink.MavlinkNative;
import com.geehe.mavlink.MavlinkUpdate;
import com.geehe.videonative.DecodingInfo;
import com.geehe.videonative.IVideoParamsChanged;
import com.geehe.videonative.VideoPlayer;
import com.geehe.wfbngrtl8812.WfbNGStats;
import com.geehe.wfbngrtl8812.WfbNGStatsChanged;
import com.geehe.wfbngrtl8812.WfbNgLink;
import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.data.PieData;
import com.github.mikephil.charting.data.PieDataSet;
import com.github.mikephil.charting.data.PieEntry;
import com.github.mikephil.charting.formatter.PercentFormatter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import me.saket.cascade.CascadePopupMenuCheckable;
// Most basic implementation of an activity that uses VideoNative to stream a video
// Into an Android Surface View
public class VideoActivity extends AppCompatActivity implements IVideoParamsChanged, WfbNGStatsChanged, MavlinkUpdate, SettingsChanged {
private static final int PICK_DOCUMENT_REQUEST_CODE = 1;
private static final int REQUEST_WRITE_PERMISSION = 2;
private ActivityVideoBinding binding;
protected DecodingInfo mDecodingInfo;
int lastVideoW=0,lastVideoH=0;
private OSDManager osdManager;
private static final String TAG = "VideoActivity";
UsbManager usbManager;
BroadcastReceiver batteryReceiver;
WfbNgLink wfbLink;
VideoPlayer videoPlayerH264;
VideoPlayer videoPlayerH265;
private String activeCodec;
private ParcelFileDescriptor dvrFd = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityVideoBinding.inflate(getLayoutInflater());
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// Init wfb ng.
setDefaultGsKey();
copyGSKey();
wfbLink = new WfbNgLink(VideoActivity.this);
wfbLink.SetWfbNGStatsChanged(VideoActivity.this);
usbManager = new UsbManager(this, binding, wfbLink);
usbManager.initWifiAdapters();
// Setup video players
setContentView(binding.getRoot());
videoPlayerH264 = new VideoPlayer(this);
videoPlayerH264.setIVideoParamsChanged(this);
binding.svH264.getHolder().addCallback(videoPlayerH264.configure1());
videoPlayerH265 = new VideoPlayer(this);
videoPlayerH265.setIVideoParamsChanged(this);
binding.svH265.getHolder().addCallback(videoPlayerH265.configure1());
osdManager = new OSDManager(this, binding);
osdManager.setUp();
PieChart chart = binding.pcLinkStat;
chart.getLegend().setEnabled(false);
chart.getDescription().setEnabled(false);
chart.setDrawHoleEnabled(true);
chart.setHoleColor(Color.WHITE);
chart.setTransparentCircleColor(Color.WHITE);
chart.setTransparentCircleAlpha(110);
chart.setHoleRadius(58f);
chart.setTransparentCircleRadius(61f);
chart.setHighlightPerTapEnabled(false);
chart.setRotationEnabled(false);
chart.setClickable(false);
chart.setTouchEnabled(false);
PieData noData = new PieData(new PieDataSet(new ArrayList<>(), ""));
chart.setData(noData);
binding.btnSettings.setOnClickListener(v -> {
CascadePopupMenuCheckable popup = new CascadePopupMenuCheckable(VideoActivity.this, v);
SubMenu chnMenu = popup.getMenu().addSubMenu("Channel");
int channelPref = getChannel(this);
chnMenu.setHeaderTitle("Current: " + channelPref);
String[] channels = getResources().getStringArray(R.array.channels);
for (String chnStr : channels) {
if (channelPref==Integer.parseInt(chnStr)){
continue;
}
chnMenu.add(chnStr).setOnMenuItemClickListener(item -> {
onChannelSettingChanged(Integer.parseInt(chnStr));
return true;
});
}
// Codecs
String codecPref = getCodec(this);
SubMenu codecMenu = popup.getMenu().addSubMenu("Codec");
codecMenu.setHeaderTitle("Current: " + codecPref);
String[] codecs = getResources().getStringArray(R.array.codecs);
for (String codecStr : codecs) {
if (codecPref.equals(codecStr)){
continue;
}
codecMenu.add(codecStr).setOnMenuItemClickListener(item -> {
onCodecSettingChanged(codecStr);
return true;
});
}
// OSD
SubMenu osd = popup.getMenu().addSubMenu("OSD");
String lockLabel = osdManager.isOSDLocked() ? "Unlock OSD" : "Lock OSD";
MenuItem lock = osd.add(lockLabel);
lock.setOnMenuItemClickListener(item -> {
osdManager.lockOSD(!osdManager.isOSDLocked());
return true;
});
for (OSDElement element: osdManager.listOSDItems) {
MenuItem itm = osd.add(element.name);
itm.setCheckable(true);
itm.setChecked(osdManager.isElementEnabled(element));
itm.setOnMenuItemClickListener(item -> {
item.setChecked(!item.isChecked());
osdManager.onOSDItemCheckChanged(element, item.isChecked());
return true;
});
}
// WFB
SubMenu wfb = popup.getMenu().addSubMenu("WFB-NG");
MenuItem keyBtn = wfb.add("gs.key");
keyBtn.setOnMenuItemClickListener(item -> {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
startActivityForResult(intent, PICK_DOCUMENT_REQUEST_CODE);
return true;
});
// recording
MenuItem dvrBtn = popup.getMenu().add(dvrFd == null ? "Start recording" : "Stop recording");
dvrBtn.setOnMenuItemClickListener(item -> {
if (dvrFd == null) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
ActivityCompat.requestPermissions(this,
没有合适的资源?快使用搜索试试~ 我知道了~
WFB-ng android client, running rtl8812au driver in userspace, an
共659个文件
h:498个
png:31个
xml:28个
需积分: 1 1 下载量 175 浏览量
2024-06-29
10:46:17
上传
评论
收藏 3.79MB ZIP 举报
温馨提示
WFB-ng android client, running rtl8812au driver in userspace, and a low latency videodecoder.
资源推荐
资源详情
资源评论
收起资源包目录
WFB-ng android client, running rtl8812au driver in userspace, an (659个子文件)
libpcap.so.1 933KB
libusb1.0.so.1 198KB
libusb1.0.so.2 198KB
libpcap.a 1.21MB
libpcap.a 470KB
gradlew.bat 3KB
ParseRTP.cpp 16KB
mavlink.cpp 16KB
VideoDecoder.cpp 14KB
VideoPlayer.cpp 12KB
WfbngLink.cpp 9KB
UdpReceiver.cpp 5KB
H26XParser.cpp 2KB
RxFrame.cpp 63B
.gitignore 273B
.gitignore 6B
.gitignore 6B
.gitignore 6B
.gitignore 6B
.gitmodules 329B
gradlew 6KB
testsuite.h 563KB
testsuite.h 185KB
common.h 132KB
minimp4.h 122KB
testsuite.h 99KB
ardupilotmega.h 98KB
mavlink_msg_serial_udb_extra_f2_b.h 82KB
libusb.h 81KB
slugs.h 65KB
matrixpilot.h 65KB
autoquad.h 64KB
ASLUAV.h 62KB
testsuite.h 57KB
testsuite.h 55KB
dlt.h 52KB
pcap.h 48KB
mavlink_msg_onboard_computer_status.h 47KB
mavlink_msg_serial_udb_extra_f2_a.h 44KB
mavlink_msg_open_drone_id_location.h 40KB
mavlink_msg_high_latency2.h 39KB
mavlink_msg_rc_channels_override.h 37KB
mavlink_msg_fw_soaring_data.h 36KB
mavlink_msg_smart_battery_info.h 36KB
mavlink_msg_high_latency.h 36KB
mavlink_helpers.h 36KB
mavlink_msg_gimbal_device_information.h 34KB
mavlink_msg_rc_channels.h 32KB
mavlink_msg_efi_status.h 32KB
mavlink_msg_open_drone_id_system.h 32KB
mavlink_msg_aslctrl_data.h 32KB
mavlink_msg_uavionix_adsb_out_dynamic.h 31KB
mavlink_msg_trajectory_representation_waypoints.h 31KB
mavlink_msg_set_position_target_global_int.h 31KB
mavlink_msg_test_types.h 30KB
mavlink_msg_servo_output_raw.h 30KB
mavlink_msg_autopilot_state_for_gimbal_device.h 30KB
mavlink_msg_gimbal_device_attitude_status.h 30KB
mavlink_msg_set_position_target_local_ned.h 29KB
mavlink_msg_utm_global_position.h 29KB
mavlink_msg_serial_udb_extra_f20.h 29KB
mavlink_msg_control_system_state.h 29KB
mavlink_msg_sim_state.h 29KB
mavlink_msg_mag_cal_report.h 28KB
mavlink_msg_gps_input.h 28KB
mavlink_msg_autopilot_version.h 28KB
mavlink_msg_sys_status.h 28KB
mavlink_msg_aq_telemetry_f.h 28KB
mavlink_msg_set_home_position.h 28KB
mavlink_msg_hil_state_quaternion.h 27KB
mavlink_msg_position_target_global_int.h 27KB
mavlink_msg_mag_cal_report.h 27KB
mavlink_msg_ais_vessel.h 27KB
mavlink_msg_hil_optical_flow.h 26KB
mavlink_msg_camera_information.h 26KB
mavlink_msg_optical_flow_rad.h 26KB
mavlink_msg_command_int_stamped.h 26KB
mavlink_msg_gps_raw_int.h 26KB
mavlink_msg_generator_status.h 26KB
mavlink_msg_serial_udb_extra_f4.h 26KB
mavlink_msg_sens_batmon.h 26KB
mavlink_msg_home_position.h 26KB
mavlink_msg_position_target_local_ned.h 26KB
mavlink_msg_icarous_kinematic_bands.h 25KB
mavlink_msg_odometry.h 25KB
mavlink_msg_mission_item_int.h 25KB
mavlink_msg_open_drone_id_authentication.h 25KB
mavlink_msg_hil_rc_inputs_raw.h 25KB
mavlink_msg_landing_target.h 25KB
mavlink_msg_camera_tracking_image_status.h 25KB
mavlink_msg_command_long_stamped.h 24KB
mavlink_msg_distance_sensor.h 24KB
mavlink_msg_hil_sensor.h 24KB
mavlink_msg_sens_power_board.h 24KB
mavlink_msg_camera_tracking_geo_status.h 24KB
mavlink_msg_highres_imu.h 24KB
mavlink_msg_serial_udb_extra_f14.h 23KB
mavlink_msg_battery_status.h 23KB
mavlink_msg_mission_item.h 23KB
mavlink_msg_video_stream_information.h 23KB
共 659 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
普通网友
- 粉丝: 3456
- 资源: 506
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功