基于qt,msvc2017-64bits,ffmpeg.opengl的播放器
zhangmeng
2021-03-03 4a6d9312cc1c9d62d66c4def71246d9faae29edb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#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;
}