#include "media_player.h"
|
|
#include <string>
|
#include <thread>
|
#include <functional>
|
|
#include "minivideo/minivideo.h"
|
#include "minivideo/minivideo_mediafile.h"
|
#include "minivideo/minivideo_typedef.h"
|
#include "minivideo/bitstream.h"
|
|
#include "demuxer/hik_ps/hik_ps.h"
|
#include "demuxer/h2645/h2645_parser.h"
|
#include "demuxer/csrw/csrw.h"
|
#include "demuxer/cdyd_ps/cdyd_ps.h"
|
|
#include "parser/parser_callback.h"
|
|
using namespace std;
|
|
//static string open_file(HWND hwnd) {
|
// OPENFILENAMEA ofn;
|
|
// char szFile[MAX_PATH] = { 0 };
|
|
// ZeroMemory(&ofn, sizeof(ofn));
|
// ofn.lStructSize = sizeof(ofn);
|
// ofn.hwndOwner = hwnd;
|
// ofn.lpstrFile = szFile;
|
// ofn.lpstrFile[0] = '\0';
|
// ofn.nMaxFile = sizeof(szFile);
|
// ofn.lpstrFilter = "All\0*.*\0Video\0*.mp4\0";
|
// ofn.nFilterIndex = 1;
|
// ofn.lpstrFileTitle = NULL;
|
// ofn.nMaxFileTitle = 0;
|
// ofn.lpstrInitialDir = NULL;
|
// ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
|
// if (TRUE == GetOpenFileNameA(&ofn))
|
// return szFile;
|
|
// return "";
|
//}
|
|
static int demux_thread(const char *file, int videoType, DataCallback* dct) {
|
|
int minivideo_retcode = 0;
|
|
minivideo_print_infos();
|
minivideo_print_features();
|
minivideo_endianness();
|
|
MediaFile_t* input_video = nullptr;
|
minivideo_retcode = minivideo_open(file, &input_video);
|
if (minivideo_retcode == 1)
|
{
|
if (CONTAINER_MPEG_PS == input_video->container) {
|
minivideo_retcode = hik_PS_fileParse(input_video, dct);
|
}
|
else {
|
if ((strstr(file, ".csrw")) || (videoType == RUNWEIVIDEO)) {
|
minivideo_retcode = csrw_fileParse(input_video, dct);
|
}
|
else {
|
minivideo_retcode = cdyd_PS_fileParse(input_video, dct);
|
}
|
}
|
|
}
|
|
minivideo_close(&input_video);
|
|
return minivideo_retcode;
|
}
|
|
int run_player(std::string file, int videoType, DataCallback* dct) {
|
int ret = 0;
|
|
// auto file = open_file(hwnd);
|
printf("open file %s\n", file.c_str());
|
|
std::string name("");
|
auto pos = file.rfind("\\");
|
if (pos != std::string::npos) {
|
name = file.substr(pos + 1);
|
}
|
if (name.empty()) name = "test";
|
|
// parser_callback* dct = new parser_callback();
|
ret = 2;
|
|
std::thread t([=] {demux_thread(file.c_str(), videoType, dct); });
|
|
t.detach();
|
|
// delete dct;
|
|
return ret;
|
}
|