satdump/src-testing/main.cpp

57 lines
2.1 KiB
C++
Raw Normal View History

/**********************************************************************
2022-03-20 20:56:32 +01:00
* This file is used for testing random stuff without running the
* whole of SatDump, which comes in handy for debugging individual
* elements before putting them all together in modules...
2022-03-20 20:56:32 +01:00
*
* If you are an user, ignore this file which will not be built by
* default, and if you're a developper in need of doing stuff here...
* Go ahead!
2022-03-20 20:56:32 +01:00
*
* Don't judge the code you might see in there! :)
**********************************************************************/
2022-03-28 11:51:13 +02:00
#include "logger.h"
2022-07-22 22:52:07 +02:00
#include <fstream>
2022-07-25 21:04:58 +02:00
#include "common/mpeg_ts/ts_header.h"
#include "common/mpeg_ts/ts_demux.h"
#include "common/mpeg_ts/dvb_mpe.h"
2022-05-30 14:25:41 +02:00
2022-05-11 23:46:39 +02:00
int main(int argc, char *argv[])
{
initLogger();
2022-06-08 21:50:47 +02:00
2022-07-25 21:04:58 +02:00
std::ifstream eumetcast_ts("/home/alan/Downloads/0.0E_11262.568_H_32999_(2022-07-11 21.30.11)_dump.ts");
std::ofstream eumetcast_ttttt("eumetcast_frm.bin");
2022-07-22 22:52:07 +02:00
2022-07-25 21:04:58 +02:00
uint8_t ts_frame[188];
mpeg_ts::TSHeader tsheader;
mpeg_ts::TSDemux tsdemux;
2022-07-22 22:52:07 +02:00
2022-07-25 21:04:58 +02:00
mpeg_ts::MPEHeader mpeheader;
mpeg_ts::IPv4Header ipv4header;
2022-07-22 22:52:07 +02:00
2022-07-25 21:04:58 +02:00
while (!eumetcast_ts.eof())
{
eumetcast_ts.read((char *)ts_frame, 188);
2022-07-22 22:52:07 +02:00
2022-07-25 21:04:58 +02:00
std::vector<std::vector<uint8_t>> framesss = tsdemux.demux(ts_frame, 500);
for (std::vector<uint8_t> &frm : framesss)
{
// uint32_t marker = frm[40] << 24 | frm[41] << 16 | frm[42] << 8 | frm[43];
2022-07-22 22:52:07 +02:00
2022-07-25 21:04:58 +02:00
// logger->info(marker);
2022-07-22 22:52:07 +02:00
2022-07-25 21:04:58 +02:00
mpeheader.parse(&frm[0]);
ipv4header.parse(&frm[12]);
2022-07-22 23:02:46 +02:00
2022-07-25 21:04:58 +02:00
frm.resize(4000 + 40);
2022-07-22 22:52:07 +02:00
2022-07-25 21:04:58 +02:00
if (ipv4header.target_ip_1 == 224 && ipv4header.target_ip_2 == 223 && ipv4header.target_ip_3 == 222 && ipv4header.target_ip_4 == 27 /*&& frm[42] == 0xa1 && frm[43] == 0x5a*/)
2022-07-22 22:52:07 +02:00
{
2022-07-25 21:04:58 +02:00
logger->critical("{:d} {:d} {:d} TARGET IP {:d}.{:d}.{:d}.{:d}", mpeheader.section_length, frm.size(), ipv4header.ihl, ipv4header.target_ip_1, ipv4header.target_ip_2, ipv4header.target_ip_3, ipv4header.target_ip_4);
// logger->critical(frm.size());
eumetcast_ttttt.write((char *)&frm[40], 4000);
2022-07-22 22:52:07 +02:00
}
}
}
2022-07-11 02:17:20 +02:00
}