author | Stepan777 <stepik-777@mail.ru> |
Mon, 11 Jun 2012 18:15:30 +0400 | |
changeset 7235 | baa69bd025d9 |
parent 7198 | 5debd5fe526e |
child 7280 | fd707afbc3a2 |
permissions | -rw-r--r-- |
7180 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#include <QString> |
|
20 |
#include <QByteArray> |
|
21 |
||
22 |
#include "recorder.h" |
|
23 |
#include "gameuiconfig.h" |
|
24 |
#include "hwconsts.h" |
|
25 |
#include "game.h" |
|
26 |
||
27 |
HWRecorder::HWRecorder(GameUIConfig * config) : |
|
28 |
TCPBase(false) |
|
29 |
{ |
|
30 |
this->config = config; |
|
31 |
} |
|
32 |
||
33 |
HWRecorder::~HWRecorder() |
|
34 |
{ |
|
35 |
} |
|
36 |
||
37 |
void HWRecorder::onClientDisconnect() |
|
38 |
{ |
|
39 |
} |
|
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
40 |
|
7180 | 41 |
void HWRecorder::onClientRead() |
42 |
{ |
|
43 |
quint8 msglen; |
|
44 |
quint32 bufsize; |
|
45 |
while (!readbuffer.isEmpty() && ((bufsize = readbuffer.size()) > 0) && |
|
46 |
((msglen = readbuffer.data()[0]) < bufsize)) |
|
47 |
{ |
|
48 |
QByteArray msg = readbuffer.left(msglen + 1); |
|
49 |
readbuffer.remove(0, msglen + 1); |
|
50 |
if (msg.at(1) == '?') |
|
51 |
SendIPC("!"); |
|
52 |
} |
|
53 |
} |
|
54 |
||
55 |
void HWRecorder::EncodeVideo( const QByteArray & record, const QString & prefix ) |
|
56 |
{ |
|
57 |
this->prefix = prefix; |
|
58 |
||
59 |
toSendBuf = record; |
|
60 |
toSendBuf.replace(QByteArray("\x02TD"), QByteArray("\x02TV")); |
|
61 |
toSendBuf.replace(QByteArray("\x02TL"), QByteArray("\x02TV")); |
|
62 |
toSendBuf.replace(QByteArray("\x02TN"), QByteArray("\x02TV")); |
|
63 |
toSendBuf.replace(QByteArray("\x02TS"), QByteArray("\x02TV")); |
|
64 |
||
65 |
// run engine |
|
66 |
Start(); |
|
67 |
} |
|
68 |
||
69 |
QStringList HWRecorder::getArguments() |
|
70 |
{ |
|
71 |
QStringList arguments; |
|
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
72 |
QRect resolution = config->rec_Resolution(); |
7180 | 73 |
arguments << cfgdir->absolutePath(); |
74 |
arguments << QString::number(resolution.width()); |
|
75 |
arguments << QString::number(resolution.height()); |
|
76 |
arguments << QString::number(config->bitDepth()); // bpp |
|
77 |
arguments << QString("%1").arg(ipc_port); |
|
78 |
arguments << "0"; // fullscreen |
|
79 |
arguments << "0"; // sound |
|
80 |
arguments << "0"; // music |
|
81 |
arguments << "0"; // sound volume |
|
82 |
arguments << QString::number(config->timerInterval()); |
|
83 |
arguments << datadir->absolutePath(); |
|
84 |
arguments << (config->isShowFPSEnabled() ? "1" : "0"); |
|
85 |
arguments << (config->isAltDamageEnabled() ? "1" : "0"); |
|
86 |
arguments << config->netNick().toUtf8().toBase64(); |
|
87 |
arguments << QString::number(config->translateQuality()); |
|
88 |
arguments << QString::number(config->stereoMode()); |
|
89 |
arguments << HWGame::tr("en.txt"); |
|
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
90 |
arguments << QString::number(config->rec_Framerate()); // framerate num |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
91 |
arguments << "1"; // framerate den |
7180 | 92 |
arguments << prefix; |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
93 |
arguments << config->AVFormat(); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
94 |
arguments << config->videoCodec(); |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
95 |
arguments << "5"; // video quality |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
96 |
arguments << "medium"; |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
97 |
if (config->recordAudio()) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
98 |
arguments << config->audioCodec(); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
99 |
else |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
7198
diff
changeset
|
100 |
arguments << "no"; |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
101 |
arguments << "5"; // audio quality |
7180 | 102 |
|
103 |
return arguments; |
|
104 |
} |