mirror of https://github.com/tp4a/teleport
处理关键帧,未完成.
parent
a4b0fec814
commit
ad5534fd94
|
@ -28,6 +28,7 @@ bool rdpimg2QImage(QImage& out, int w, int h, int bitsPerPixel, bool isCompresse
|
|||
break;
|
||||
case 16:
|
||||
if(isCompressed) {
|
||||
|
||||
uint8_t* _dat = (uint8_t*)calloc(1, w*h*2);
|
||||
if(!bitmap_decompress2(_dat, w, h, dat, len)) {
|
||||
free(_dat);
|
||||
|
@ -35,6 +36,8 @@ bool rdpimg2QImage(QImage& out, int w, int h, int bitsPerPixel, bool isCompresse
|
|||
}
|
||||
|
||||
// TODO: 这里需要进一步优化,直接操作QImage的buffer。
|
||||
// QTime t1;
|
||||
// t1.start();
|
||||
|
||||
out = QImage(w, h, QImage::Format_RGB16);
|
||||
for(int y = 0; y < h; y++) {
|
||||
|
@ -46,6 +49,7 @@ bool rdpimg2QImage(QImage& out, int w, int h, int bitsPerPixel, bool isCompresse
|
|||
out.setPixelColor(x, y, QColor(r,g,b));
|
||||
}
|
||||
}
|
||||
// qDebug("parse: %dB, %dms", len, t1.elapsed());
|
||||
|
||||
free(_dat);
|
||||
}
|
||||
|
@ -381,6 +385,7 @@ void MainWindow::_do_update_data(update_data* dat) {
|
|||
else if(dat->data_type() == TYPE_END) {
|
||||
m_bar.end();
|
||||
m_play_state = PLAY_STATE_STOP;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "thr_play.h"
|
||||
#include "update_data.h"
|
||||
#include "record_format.h"
|
||||
#include "util.h"
|
||||
|
||||
#define PLAY_STATE_UNKNOWN 0
|
||||
#define PLAY_STATE_RUNNING 1
|
||||
|
@ -77,6 +78,11 @@ private:
|
|||
|
||||
QPixmap m_img_message;
|
||||
QRect m_rc_message;
|
||||
|
||||
|
||||
// for test
|
||||
TimeUseTest m_time_imgconvert_normal;
|
||||
TimeUseTest m_time_imgconvert_compressed;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#define TS_RECORD_TYPE_RDP_POINTER 0x12 // 鼠标坐标位置改变,用于绘制虚拟鼠标
|
||||
#define TS_RECORD_TYPE_RDP_IMAGE 0x13 // 服务端返回的图像,用于展示
|
||||
#define TS_RECORD_TYPE_RDP_KEYFRAME 0x14 //
|
||||
|
||||
#define TS_RDP_BTN_FREE 0
|
||||
#define TS_RDP_BTN_PRESSED 1
|
||||
|
@ -17,10 +18,11 @@
|
|||
typedef struct TS_RECORD_HEADER_INFO {
|
||||
uint32_t magic; // "TPPR" 标志 TelePort Protocol Record
|
||||
uint16_t ver; // 录像文件版本,从3.5.0开始,为4
|
||||
uint16_t type; //
|
||||
uint32_t packages; // 总包数
|
||||
uint32_t time_ms; // 总耗时(毫秒)
|
||||
uint32_t dat_file_count; // 数据文件数量
|
||||
uint8_t _reserve[64-4-2-4-4-4];
|
||||
uint8_t _reserve[64-4-2-2-4-4-4];
|
||||
}TS_RECORD_HEADER_INFO;
|
||||
#define ts_record_header_info_size sizeof(TS_RECORD_HEADER_INFO)
|
||||
|
||||
|
|
|
@ -216,7 +216,9 @@ void ThreadPlay::run() {
|
|||
QFile f_dat(tpd_filename);
|
||||
if(!f_dat.open(QFile::ReadOnly)) {
|
||||
qDebug() << "Can not open " << tpd_filename << " for read.";
|
||||
msg.sprintf("无法打开录像数据文件!\n\n%s", tpd_filename.toStdString().c_str());
|
||||
// msg.sprintf("无法打开录像数据文件!\n\n%s", tpd_filename.toStdString().c_str());
|
||||
msg = QString::fromLocal8Bit("无法打开录像数据文件!\n\n");
|
||||
msg += tpd_filename.toStdString().c_str();
|
||||
_notify_error(msg);
|
||||
return;
|
||||
}
|
||||
|
@ -239,10 +241,15 @@ void ThreadPlay::run() {
|
|||
break;
|
||||
if(read_len != sizeof(TS_RECORD_PKG)) {
|
||||
qDebug() << "invaid .tpd file (1).";
|
||||
msg.sprintf("错误的录像数据文件!\n\n%s", tpd_filename.toStdString().c_str());
|
||||
// msg.sprintf("错误的录像数据文件!\n\n%s", tpd_filename.toStdString().c_str());
|
||||
msg = QString::fromLocal8Bit("错误的录像数据文件!\n\n");
|
||||
msg += tpd_filename.toStdString().c_str();
|
||||
_notify_error(msg);
|
||||
return;
|
||||
}
|
||||
if(pkg.type == TS_RECORD_TYPE_RDP_KEYFRAME) {
|
||||
qDebug("----key frame: %d", pkg.time_ms);
|
||||
}
|
||||
|
||||
update_data* dat = new update_data(TYPE_DATA);
|
||||
dat->alloc_data(sizeof(TS_RECORD_PKG) + pkg.size);
|
||||
|
@ -251,7 +258,9 @@ void ThreadPlay::run() {
|
|||
if(read_len != pkg.size) {
|
||||
delete dat;
|
||||
qDebug() << "invaid .tpd file.";
|
||||
msg.sprintf("错误的录像数据文件!\n\n%s", tpd_filename.toStdString().c_str());
|
||||
// msg.sprintf("错误的录像数据文件!\n\n%s", tpd_filename.toStdString().c_str());
|
||||
msg = QString::fromLocal8Bit("错误的录像数据文件!\n\n");
|
||||
msg += tpd_filename.toStdString().c_str();
|
||||
_notify_error(msg);
|
||||
return;
|
||||
}
|
||||
|
@ -316,7 +325,8 @@ void ThreadPlay::run() {
|
|||
|
||||
if(pkg_count < total_pkg) {
|
||||
qDebug() << "total-pkg:" << total_pkg << ", played:" << pkg_count;
|
||||
msg.sprintf("录像数据文件有误!\n\n部分录像数据缺失!");
|
||||
// msg.sprintf("录像数据文件有误!\n\n部分录像数据缺失!");
|
||||
msg = QString::fromLocal8Bit("录像数据文件有误!\n\n部分录像数据缺失!");
|
||||
_notify_message(msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ HEADERS += \
|
|||
thr_play.h \
|
||||
update_data.h \
|
||||
record_format.h \
|
||||
rle.h
|
||||
rle.h \
|
||||
util.h
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
|
@ -19,7 +20,8 @@ SOURCES += \
|
|||
thr_download.cpp \
|
||||
thr_play.cpp \
|
||||
update_data.cpp \
|
||||
rle.c
|
||||
rle.c \
|
||||
util.cpp
|
||||
|
||||
RESOURCES += \
|
||||
tp-player.qrc
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// #define MAX_SIZE_PER_FILE 4194304 // 4M = 1024*1024*4
|
||||
// for test.
|
||||
#define MAX_CACHE_SIZE 524288 // 512KB = 512*1024
|
||||
#define MAX_SIZE_PER_FILE 1048576 // 4M = 1024*1024*1
|
||||
#define MAX_SIZE_PER_FILE 1048576 // 1M = 1024*1024*1
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
|
@ -27,15 +27,19 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define TS_TPPR_TYPE_UNKNOWN 0x0000
|
||||
#define TS_TPPR_TYPE_SSH 0x0001
|
||||
#define TS_TPPR_TYPE_RDP 0x0101
|
||||
|
||||
// 录像文件头(随着录像数据写入,会改变的部分)
|
||||
typedef struct TS_RECORD_HEADER_INFO {
|
||||
ex_u32 magic; // "TPPR" 标志 TelePort Protocol Record
|
||||
ex_u16 ver; // 录像文件版本,v3.5.0开始为4
|
||||
ex_u16 type; // 录像内容,SSH or RDP
|
||||
ex_u32 packages; // 总包数
|
||||
ex_u32 time_ms; // 总耗时(毫秒)
|
||||
ex_u32 dat_file_count; // 数据文件数量
|
||||
ex_u8 _reserve[64-4-2-4-4-4];
|
||||
ex_u8 _reserve[64-4-2-2-4-4-4];
|
||||
}TS_RECORD_HEADER_INFO;
|
||||
#define ts_record_header_info_size sizeof(TS_RECORD_HEADER_INFO)
|
||||
|
||||
|
@ -58,7 +62,7 @@ typedef struct TS_RECORD_HEADER_BASIC {
|
|||
// // RDP专有 - v3.5.0废弃并移除
|
||||
// ex_u8 rdp_security; // 0 = RDP, 1 = TLS
|
||||
|
||||
ex_u8 _reserve[512 - 2 - 2 - 8 - 2 - 2 - 64 - 64 - 40 - 40 - 2 - 40 - ts_record_header_info_size];
|
||||
ex_u8 _reserve[512 - ts_record_header_info_size - 2 - 2 - 8 - 2 - 2 - 64 - 64 - 40 - 40 - 2 - 40];
|
||||
}TS_RECORD_HEADER_BASIC;
|
||||
#define ts_record_header_basic_size sizeof(TS_RECORD_HEADER_BASIC)
|
||||
|
||||
|
@ -70,7 +74,6 @@ typedef struct TS_RECORD_HEADER {
|
|||
// header部分(header-info + header-basic) = 512B
|
||||
#define ts_record_header_size sizeof(TS_RECORD_HEADER)
|
||||
|
||||
|
||||
// 一个数据包的头
|
||||
typedef struct TS_RECORD_PKG {
|
||||
ex_u8 type; // 包的数据类型
|
||||
|
|
Loading…
Reference in New Issue