fix:增加视频分辨率判断
This commit is contained in:
parent
f887bd37c4
commit
06fc544f1a
@ -43,7 +43,9 @@ class UdpTalkExpectHandler extends ScpMessageBaseHandle
|
|||||||
startChartManage.stopCallRequestMessageTimer();
|
startChartManage.stopCallRequestMessageTimer();
|
||||||
// talkViewState.rotateAngle.value = talkExpectResp.rotate ?? 0;
|
// talkViewState.rotateAngle.value = talkExpectResp.rotate ?? 0;
|
||||||
startChartManage.rotateAngle = talkExpectResp.rotate;
|
startChartManage.rotateAngle = talkExpectResp.rotate;
|
||||||
AppLog.log('视频画面需要旋转:${talkExpectResp.rotate}');
|
startChartManage.videoWidth = talkExpectResp.width;
|
||||||
|
startChartManage.videoHeight = talkExpectResp.height;
|
||||||
|
AppLog.log('视频画面需要旋转:${talkExpectResp.rotate},画面宽高:${talkExpectResp.width}-${talkExpectResp.height}');
|
||||||
// 收到预期数据的应答后,代表建立了连接,启动通话保持的监听
|
// 收到预期数据的应答后,代表建立了连接,启动通话保持的监听
|
||||||
// 启动通话保持监听定时器(用来判断如果x秒内没有收到通话保持则执行的操作);
|
// 启动通话保持监听定时器(用来判断如果x秒内没有收到通话保持则执行的操作);
|
||||||
talkePingOverTimeTimerManager.start();
|
talkePingOverTimeTimerManager.start();
|
||||||
|
|||||||
@ -114,6 +114,8 @@ class StartChartManage {
|
|||||||
final int _maxPayloadSize = 8 * 1024; // 分包大小
|
final int _maxPayloadSize = 8 * 1024; // 分包大小
|
||||||
|
|
||||||
int rotateAngle = 0; // 视频旋转角度
|
int rotateAngle = 0; // 视频旋转角度
|
||||||
|
int videoWidth = 0; // 视频宽度
|
||||||
|
int videoHeight = 0; // 视频高度
|
||||||
|
|
||||||
// 默认通话的期望数据格式
|
// 默认通话的期望数据格式
|
||||||
TalkExpectReq _defaultTalkExpect = TalkConstant.H264Expect;
|
TalkExpectReq _defaultTalkExpect = TalkConstant.H264Expect;
|
||||||
|
|||||||
@ -98,56 +98,55 @@ class _TalkViewPageState extends State<TalkViewPage>
|
|||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Obx(
|
// 全屏背景图片或渐变色背景
|
||||||
() {
|
Obx(() {
|
||||||
final double screenWidth = MediaQuery.of(context).size.width;
|
if (state.listData.value.isEmpty) {
|
||||||
final double screenHeight = MediaQuery.of(context).size.height;
|
return SizedBox.expand(
|
||||||
|
child: Image.asset(
|
||||||
final double logicalWidth = MediaQuery.of(context).size.width;
|
'images/main/monitorBg.png',
|
||||||
final double logicalHeight = MediaQuery.of(context).size.height;
|
fit: BoxFit.cover,
|
||||||
final double devicePixelRatio =
|
),
|
||||||
MediaQuery.of(context).devicePixelRatio;
|
);
|
||||||
|
}
|
||||||
// 计算物理像素值
|
final int videoW = startChartManage.videoWidth;
|
||||||
final double physicalWidth = logicalWidth * devicePixelRatio;
|
final int videoH = startChartManage.videoHeight;
|
||||||
final double physicalHeight = logicalHeight * devicePixelRatio;
|
if (videoW == 320 && videoH == 240) {
|
||||||
|
return SizedBox.expand(
|
||||||
// 旋转后的图片尺寸
|
child: Container(
|
||||||
const int rotatedImageWidth = 480; // 原始高度
|
decoration: const BoxDecoration(
|
||||||
const int rotatedImageHeight = 864; // 原始宽度
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
// 计算缩放比例
|
end: Alignment.bottomCenter,
|
||||||
final double scaleWidth = physicalWidth / rotatedImageWidth;
|
colors: [
|
||||||
final double scaleHeight = physicalHeight / rotatedImageHeight;
|
Color(0xFF232526),
|
||||||
max(scaleWidth, scaleHeight); // 选择较大的缩放比例
|
Color(0xFF414345),
|
||||||
|
],
|
||||||
return state.listData.value.isEmpty
|
),
|
||||||
? Image.asset(
|
),
|
||||||
'images/main/monitorBg.png',
|
),
|
||||||
width: screenWidth,
|
);
|
||||||
height: screenHeight,
|
}
|
||||||
fit: BoxFit.cover,
|
return const SizedBox.shrink();
|
||||||
)
|
}),
|
||||||
: PopScope(
|
// 视频窗口,分辨率判断
|
||||||
canPop: false,
|
Obx(() {
|
||||||
child: RepaintBoundary(
|
if (state.listData.value.isEmpty) {
|
||||||
key: state.globalKey,
|
return const SizedBox.shrink();
|
||||||
child: SizedBox.expand(
|
}
|
||||||
child: RotatedBox(
|
final int videoW = startChartManage.videoWidth;
|
||||||
quarterTurns: startChartManage.rotateAngle ~/ 90,
|
final int videoH = startChartManage.videoHeight;
|
||||||
child: RawImage(
|
if (videoW == 320 && videoH == 240) {
|
||||||
image: state.currentImage.value,
|
return Positioned(
|
||||||
width: ScreenUtil().scaleWidth,
|
top: 150.h,
|
||||||
height: ScreenUtil().scaleHeight,
|
left: 0,
|
||||||
fit: BoxFit.cover,
|
right: 0,
|
||||||
filterQuality: FilterQuality.high,
|
child: _buildVideoWidget(),
|
||||||
),
|
);
|
||||||
),
|
} else {
|
||||||
),
|
// 直接全屏显示
|
||||||
),
|
return _buildVideoWidget();
|
||||||
);
|
}
|
||||||
},
|
}),
|
||||||
),
|
|
||||||
Obx(() => state.listData.value.isEmpty
|
Obx(() => state.listData.value.isEmpty
|
||||||
? Positioned(
|
? Positioned(
|
||||||
bottom: 310.h,
|
bottom: 310.h,
|
||||||
@ -183,6 +182,8 @@ class _TalkViewPageState extends State<TalkViewPage>
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Container()),
|
: Container()),
|
||||||
|
|
||||||
|
/// 工具栏
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 10.w,
|
bottom: 10.w,
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -614,4 +615,68 @@ class _TalkViewPageState extends State<TalkViewPage>
|
|||||||
// UdpTalkDataHandler().resetDataRates();
|
// UdpTalkDataHandler().resetDataRates();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildVideoWidget() {
|
||||||
|
// 工具栏宽度
|
||||||
|
double barWidth = 1.sw - 30.w * 2;
|
||||||
|
int videoW = startChartManage.videoWidth;
|
||||||
|
int videoH = startChartManage.videoHeight;
|
||||||
|
int quarterTurns = startChartManage.rotateAngle ~/ 90;
|
||||||
|
bool isRotated = quarterTurns % 2 == 1;
|
||||||
|
// 旋转后宽高互换
|
||||||
|
double videoAspect = isRotated ? videoW / videoH : videoH / videoW;
|
||||||
|
double containerHeight =
|
||||||
|
barWidth * (isRotated ? videoW / videoH : videoH / videoW);
|
||||||
|
|
||||||
|
if (videoW == 320 && videoH == 240) {
|
||||||
|
return Center(
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(20.h),
|
||||||
|
child: Container(
|
||||||
|
width: barWidth,
|
||||||
|
height: containerHeight,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [
|
||||||
|
Color(0xFF232526),
|
||||||
|
Color(0xFF414345),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: RotatedBox(
|
||||||
|
quarterTurns: quarterTurns,
|
||||||
|
child: RawImage(
|
||||||
|
image: state.currentImage.value,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
filterQuality: FilterQuality.high,
|
||||||
|
width: barWidth,
|
||||||
|
height: containerHeight,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return PopScope(
|
||||||
|
canPop: false,
|
||||||
|
child: RepaintBoundary(
|
||||||
|
key: state.globalKey,
|
||||||
|
child: SizedBox.expand(
|
||||||
|
child: RotatedBox(
|
||||||
|
quarterTurns: startChartManage.rotateAngle ~/ 90,
|
||||||
|
child: RawImage(
|
||||||
|
image: state.currentImage.value,
|
||||||
|
width: ScreenUtil().scaleWidth,
|
||||||
|
height: ScreenUtil().scaleHeight,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
filterQuality: FilterQuality.high,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user