玉兔远程控制 0.0.31
载入中...
搜索中...
未找到
ConnecterPlayer.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include <QLoggingCategory>
4#include "ConnecterPlayer.h"
5#include "ConnectPlayer.h"
6#include "DlgPlayer.h"
7#include "PluginClient.h"
8
9static Q_LOGGING_CATEGORY(log, "Player.Connecter")
10
12 : CConnecterThread(plugin)
13{
14 qDebug(log) << Q_FUNC_INFO;
15}
16
17CConnecterPlayer::~CConnecterPlayer()
18{
19 qDebug(log) << Q_FUNC_INFO;
20}
21
23{
24 return 0;
25}
26
28{
29 qDebug(log) << Q_FUNC_INFO;
30 bool check = false;
31 int nRet = 0;
33 if(nRet) return nRet;
34
35 nRet = SetParameter(&m_Parameters);
36 if(nRet) return nRet;
37
38 m_Menu.clear();
39#ifdef HAVE_QVideoWidget
40 m_Menu.addAction(m_Player.m_paStart);
41 m_Menu.addAction(m_Player.m_paPause);
42#if HAVE_QT6_RECORD
43 m_Menu.addAction(m_Player.m_paRecord);
44 m_Menu.addAction(m_Player.m_paRecordPause);
45#endif
46 m_Menu.addAction(m_Player.m_paScreenShot);
47 m_Menu.addSeparator();
48 m_Menu.addAction(m_Player.m_paSettings);
49 check = connect(this, &CConnecterPlayer::sigConnected,
50 m_Player.m_paStart, &QAction::toggle);
51 Q_ASSERT(check);
52 check = connect(m_Player.m_paStart, SIGNAL(toggled(bool)),
53 this, SIGNAL(sigStart(bool)));
54 Q_ASSERT(check);
55 check = connect(m_Player.m_paPause, SIGNAL(toggled(bool)),
56 this, SIGNAL(sigPause(bool)));
57 Q_ASSERT(check);
58#if HAVE_QT6_RECORD
59 check = connect(m_Player.m_paRecord, SIGNAL(toggled(bool)),
60 m_pRecord ,SIGNAL(toggled(bool)));
61 Q_ASSERT(check);
62 check = connect(m_Player.m_paRecordPause, SIGNAL(toggled(bool)),
63 m_pRecordPause, SIGNAL(toggled(bool)));
64 Q_ASSERT(check);
65#endif
66 check = connect(m_Player.m_paScreenShot, &QAction::triggered,
67 m_pScreenShot, &QAction::triggered);
68 Q_ASSERT(check);
69 check = connect(m_Player.m_paSettings, &QAction::triggered,
70 m_pSettings, &QAction::trigger);
71 Q_ASSERT(check);
72 check = connect(this, &CConnecterPlayer::sigConnected,
73 this, [&](){
74 m_Player.SetParameter(&m_Parameters);
75 });
76 Q_ASSERT(check);
77 check = connect(&m_Player, SIGNAL(sigChangePosition(qint64)),
78 this, SIGNAL(sigChangePosition(qint64)));
79 Q_ASSERT(check);
80#else
81 QAction* pStart = m_Menu.addAction(
82 QIcon::fromTheme("media-playback-start"), tr("Start"));
83 pStart->setCheckable(true);
84 check = connect(this, &CConnecterPlayer::sigConnected,
85 pStart, &QAction::toggle);
86 Q_ASSERT(check);
87 check = connect(pStart, &QAction::toggled,
88 this, [&](bool checked){
89 QAction* p = qobject_cast<QAction*>(sender());
90 if(!p) return;
91 if(p->isChecked()) {
92 p->setIcon(QIcon::fromTheme("media-playback-stop"));
93 p->setText(tr("Stop"));
94 m_pPause->setEnabled(true);
95 m_pPause->setChecked(false);
96 m_pScreenShot->setEnabled(true);
97#if HAVE_QT6_RECORD
98 m_pRecord->setEnabled(true);
99 m_pRecord->setChecked(false);
100 m_pRecordPause->setEnabled(true);
101 m_pRecordPause->setChecked(false);
102#endif
103 } else {
104 p->setIcon(QIcon::fromTheme("media-playback-start"));
105 p->setText(tr("Start"));
106 m_pPause->setEnabled(false);
107 m_pPause->setChecked(false);
108 m_pScreenShot->setEnabled(false);
109#if HAVE_QT6_RECORD
110 m_pRecord->setEnabled(false);
111 m_pRecord->setChecked(false);
112 m_pRecordPause->setEnabled(false);
113 m_pRecordPause->setChecked(false);
114#endif
115 }
116 emit sigStart(checked);
117 });
118 Q_ASSERT(check);
119 m_pPause = m_Menu.addAction(
120 QIcon::fromTheme("media-playback-pause"), tr("pause"));
121 m_pPause->setCheckable(true);
122 check = connect(m_pPause, SIGNAL(toggled(bool)),
123 this, SIGNAL(sigPause(bool)));
124 Q_ASSERT(check);
125#if HAVE_QT6_RECORD
126 m_Menu.addAction(m_pRecord);
127 m_Menu.addAction(m_pRecordPause);
128#endif
129 m_Menu.addAction(m_pScreenShot);
130 m_Menu.addSeparator();
131 m_Menu.addAction(m_pSettings);
132#endif
133 return nRet;
134}
135
137{
138 qDebug(log) << Q_FUNC_INFO;
139 int nRet = 0;
141 return nRet;
142}
143
145{
146 QDialog* pDlg = new CDlgPlayer(&m_Parameters, parent);
147 return pDlg;
148}
149
151{
152 CConnect* p = new CConnectPlayer(this);
153 return p;
154}
155
156void CConnecterPlayer::slotScreenShot()
157{
158 emit sigScreenShot();
159}
160
161#if HAVE_QVideoWidget
163{
164 return &m_Player;
165}
166
167QVideoSink *CConnecterPlayer::GetVideoSink()
168{
169 return m_Player.videoSink();
170}
171
172void CConnecterPlayer::slotPositionChanged(qint64 pos, qint64 duration)
173{
174 m_Player.slotPositionChanged(pos, duration);
175}
176
177void CConnecterPlayer::slotPlaybackError(
178 QMediaPlayer::Error error, const QString &errorString)
179{
180 if(m_Player.m_paStart->isChecked())
181 m_Player.m_paStart->setChecked(false);
182}
183
184void CConnecterPlayer::slotPlaybackStateChanged(QMediaPlayer::PlaybackState state)
185{
186 if(QMediaPlayer::StoppedState == state
187 && m_Player.m_paStart->isChecked())
188 m_Player.m_paStart->setChecked(false);
189}
190
191#if HAVE_QT6_RECORD
192void CConnecterPlayer::slotRecordStateChanged(QMediaRecorder::RecorderState state)
193{
194 if(QMediaRecorder::StoppedState == state
195 && m_Player.m_paRecord->isCheckable())
196 m_Player.m_paRecord->setChecked(false);
197}
198#endif
199
200#endif
连接接口。它由协议插件实现。 它默认启动一个定时器来开启一个非 Qt 事件循环(就是普通的循环处理)。 详见: Connect()、 slotTimeOut()、 OnProcess() 。 当然,它仍...
Definition Connect.h:45
virtual qint16 Version() override
Version
virtual int Clean() override
Clean parameters and resource
virtual CConnect * InstanceConnect() override
新建 CConnect 对象。它的所有者是调用者, 如果调用者不再使用它,调用者必须负责释放它。
virtual QDialog * OnOpenDialogSettings(QWidget *parent) override
得到设置对话框
virtual int Initial() override
Initial parameters and resource
默认启动一个后台线程。实现一个后台线程处理一个连接。 可与插件接口从 CPluginClient 派生的插件一起使用,用于连接是阻塞模型的。
virtual int Initial() override
Initial parameters and resource
virtual int Clean() override
Clean parameters and resource
void sigConnected()
连接成功信号。仅由插件触发。 应用程序需要在此时设置视图属性 Enabled 为 true 。允许接收键盘和鼠标事件
virtual QWidget * GetViewer()=0
得到显示视图
客户端插件接口。用于建立 CConnecter 实例,它由协议插件实现。