QTfrontend/net/recorder.cpp
changeset 7507 3032a5739fe1
parent 7376 48b79b3ca592
child 7633 d4251e519062
equal deleted inserted replaced
7503:deaeac102355 7507:3032a5739fe1
    24 #include "gameuiconfig.h"
    24 #include "gameuiconfig.h"
    25 #include "hwconsts.h"
    25 #include "hwconsts.h"
    26 #include "game.h"
    26 #include "game.h"
    27 #include "libav_iteraction.h"
    27 #include "libav_iteraction.h"
    28 
    28 
       
    29 // Encoding is memory expensive process, so we need to limit maximum number
       
    30 // of simultaneous encoders.
       
    31 static const int maxRecorders = 3;
       
    32 static int numRecorders = 0;
       
    33 
       
    34 static QList<HWRecorder*> queue;
       
    35 
    29 HWRecorder::HWRecorder(GameUIConfig * config, const QString &prefix) :
    36 HWRecorder::HWRecorder(GameUIConfig * config, const QString &prefix) :
    30     TCPBase(false)
    37     TCPBase(false)
    31 {
    38 {
    32     this->config = config;
    39     this->config = config;
    33     this->prefix = prefix;
    40     this->prefix = prefix;
    36 }
    43 }
    37 
    44 
    38 HWRecorder::~HWRecorder()
    45 HWRecorder::~HWRecorder()
    39 {
    46 {
    40     emit encodingFinished(finished);
    47     emit encodingFinished(finished);
       
    48     if (queue.empty())
       
    49         numRecorders--;
       
    50     else
       
    51         queue.takeFirst()->Start();
    41 }
    52 }
    42 
    53 
    43 void HWRecorder::onClientDisconnect()
    54 void HWRecorder::onClientDisconnect()
    44 {
    55 {
    45 }
    56 }
    74     toSendBuf.replace(QByteArray("\x02TD"), QByteArray("\x02TV"));
    85     toSendBuf.replace(QByteArray("\x02TD"), QByteArray("\x02TV"));
    75     toSendBuf.replace(QByteArray("\x02TL"), QByteArray("\x02TV"));
    86     toSendBuf.replace(QByteArray("\x02TL"), QByteArray("\x02TV"));
    76     toSendBuf.replace(QByteArray("\x02TN"), QByteArray("\x02TV"));
    87     toSendBuf.replace(QByteArray("\x02TN"), QByteArray("\x02TV"));
    77     toSendBuf.replace(QByteArray("\x02TS"), QByteArray("\x02TV"));
    88     toSendBuf.replace(QByteArray("\x02TS"), QByteArray("\x02TV"));
    78 
    89 
    79     // run engine
    90     if (numRecorders < maxRecorders)
    80     Start();
    91     {
       
    92         numRecorders++;
       
    93         Start(); // run engine
       
    94     }
       
    95     else
       
    96         queue.push_back(this);
    81 }
    97 }
    82 
    98 
    83 QStringList HWRecorder::getArguments()
    99 QStringList HWRecorder::getArguments()
    84 {
   100 {
    85     QStringList arguments;
   101     QStringList arguments;