-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
121 lines (100 loc) · 3.48 KB
/
main.cpp
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "XPlay2.h"
#include <QApplication>
#include <iostream>
using namespace std;
#include "XDemux.h"
#include "XDecode.h"
#include "ui_XPlay2.h"
#include <QThread>
#include "XPlayVideoWidget.h"
#include "XResample.h"
#include "XAudioPlay.h"
#include "XAudioThread.h"
#include "XVideoThread.h"
#include "XDemuxThread.h"
//class TestThread : public QThread
//{
//public:
// XDemux demux;
//// XDecode vdecode;
//// XDecode adecode;
// XPlayVideoWidget *video;
//// XResample resample;
//// XAudioThread at;
//// XVideoThread vt;
// void init() {
// // 测试XDemux
//// char *pathUrl = "/Users/amglfk/Desktop/killer.mp4";
// // pathUrl = "rtmp://live.hkstv.hk.lxdns.com/live/hks";
//// cout << "demux.open = " << demux.open(pathUrl) << endl;
// //cout << "demux.copyVParam = " << demux.copyVParam() << endl;
// //cout << "demux.copyAParam = " << demux.copyAParam() << endl;
//// cout << "demux.seek = " << demux.seek(0.95) << endl;
// ////////////////////////////////////////
// // 解码测试
// // cout << "vdecode.open = " << vdecode.open(demux.copyVParam()) << endl;
//// cout << "adecode.open = " << adecode.open(demux.copyAParam()) << endl;
//// cout << "resample.open = " << resample.open(demux.copyAParam()) << endl;
//// XAudioPlay::get()->channels = demux.channels;
//// XAudioPlay::get()->sampleRate = demux.sampleRate;
//// cout << "XAudioPlay::get()->open() = " << XAudioPlay::get()->open() << endl;
//// cout << "at.open = " << at.open(demux.copyAParam(), demux.sampleRate, demux.channels) << endl;
//// cout << "vt.open = " << vt.open(demux.copyVParam(), video, demux.width, demux.height) << endl;
//// at.start();
//// vt.start();
// }
// unsigned char *pcm = new unsigned char[1024 * 1024];
// void run() {
// for (;;) {
// AVPacket *pkt = demux.read();
// if ( !pkt ) {
// break;
// }
// if ( demux.isAudio(pkt) ) {
// // 音频
//// at.push(pkt);
// /*
// adecode.send(pkt);
// AVFrame *frame = adecode.recv();
// int len = resample.resample(frame, pcm);
// cout << "resample.resample = " << resample.resample(frame, pcm) << endl;
// while (len > 0) {
// if (XAudioPlay::get()->getFree() >= len ) {
// XAudioPlay::get()->write(pcm, len);
// break;
// }
// msleep(1);
// }*/
// } else {
// // 视频
//// vdecode.send(pkt);
//// AVFrame *frame = vdecode.recv();
//// cout << "Video: " << frame << endl;
//// video->repaint(frame);
//// msleep(40);
//// vt.push(pkt);
// }
// }
// }
//};
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
// 初始化显示
/*
*/
// TestThread tt;
QApplication a(argc, argv);
Widget w;
w.show();
// Ui_Widget *temp = (Ui_Widget *)w.ui;
// temp->video->init(tt.demux.width, tt.demux.height);
// tt.video = temp->video;
// tt.init();
// tt.start();
// char *pathUrl = "/Users/amglfk/Desktop/killer.mp4";
// XDemuxThread dt;
// dt.open(pathUrl, temp->video);
// dt.start();
return a.exec();
}