author | Stepan777 <stepik-777@mail.ru> |
Fri, 08 Jun 2012 02:52:35 +0400 | |
changeset 7198 | 5debd5fe526e |
parent 7180 | 53ffc8853008 |
child 7235 | baa69bd025d9 |
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 |
} |
|
40 |
||
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; |
|
72 |
QRect resolution = config->vid_Resolution(); |
|
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"); |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
90 |
arguments << "30"; // framerate num |
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; |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
93 |
arguments << "mp4"; |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
94 |
arguments << "mpeg4"; // arguments << "libx264"; |
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"; |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
97 |
arguments << "libmp3lame"; |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
98 |
arguments << "5"; // audio quality |
7180 | 99 |
|
100 |
return arguments; |
|
101 |
} |