-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
124 lines (102 loc) · 3.34 KB
/
main.cpp
File metadata and controls
124 lines (102 loc) · 3.34 KB
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
122
123
124
#include "mainwindow.h"
#include <QApplication>
#include <QAudioFormat>
#include <QAudioSink>
#include <QMediaDevices>
#include <QAudioDevice>
#include <QThread>
#include "ui_mainwindow.h"
#include "XDemux.h"
#include "XAudioThread.h"
#include "XVideoThread.h"
#include "XDemuxThread.h"
class TestThread: public QThread
{
public:
void Init()
{
const char* url = "E:/rainSun.mp4";
demux.Open(url);
demux.Read();
demux.Clear();
demux.Close();
demux.Open(url);
// cout << "CopyVPara = " << demux.CopyVPara() << endl;
// cout << "CopyAPara = " << demux.CopyAPara() << endl;
// cout << "seek = " << demux.Seek(0.95) << endl;
// cout << "vdecode.Open() = " << vdecode.Open(demux.CopyVPara()) << endl;
// vdecode.Clear();
// vdecode.Close();
// cout << "adecode.Open() = " << adecode.Open(demux.CopyAPara()) << endl;
// cout << "resample.Open() = " << resample.Open(demux.CopyAPara()) << endl;
// XAudioPlay::Get()->sampleRate = demux.sampleRate;
// XAudioPlay::Get()->channels = demux.channels;
// cout << "XAudioPlay::Get()->Open() = " << XAudioPlay::Get()->Open() << endl;
cout << "at.Open() = " << at.Open(demux.CopyAPara()) << endl;
cout << "vt.Open() = " << vt.Open(demux.CopyVPara(), video, demux.width, demux.height);
at.start();
vt.start();
}
unsigned char *pcm = new unsigned char[1024 * 1024];
void run()
{
for(;;)
{
AVPacket *pkt = demux.Read();
if(demux.IsAudio(pkt))
{
at.Push(pkt);
/*
adecode.Send(pkt);
AVFrame *frame = adecode.Recv();
int len = resample.Resample(frame, pcm);
cout << "Resample = " << len << endl;
while(len > 0)
{
if(XAudioPlay::Get()->GetFree() >= len)
{
XAudioPlay::Get()->Write(pcm, len);
break;
}
msleep(1);
}
*/
}
else
{
vt.Push(pkt);
// vdecode.Send(pkt);
// AVFrame* frame = vdecode.Recv();
// video->Repaint(frame);
msleep(1);
}
if(!pkt)
break;
}
}
// 测试demux
XDemux demux;
// 解码测试
// XDecode adecode;
// XDecode vdecode;
// XResample resample;
XVideoWidget *video = 0;
XAudioThread at;
XVideoThread vt;
};
int main(int argc, char *argv[])
{
// TestThread tt;
QApplication a(argc, argv);
MainWindow w;
w.show();
//tt.video = w.ui->video;
//tt.Init();
//tt.start();
//XDemuxThread dt;
// dt.Open("E:/loneyRock.mp4", w.ui->video);
// dt.Open("rtmp://ns8.indexforce.com/home/mystream", w.ui->video);
// dt.Open("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4", w.ui->video);
//dt.Start();
return a.exec();
}