Ion
23rd September 2014, 11:54
In my code I launch two mplayer clients to process two RTSP streams. However when I launch the program most of the time, only one of the process will work the other either disappears or never appears in the first place.
Below is my constructor for this process
mplayer::mplayer(QString rtsp_path, QWidget *parent) :
QWidget(parent)
{
QPalette p(palette());
p.setColor(QPalette::Background, Qt::black);
this->setAutoFillBackground(true);
this->setPalette(p);
this->setMinimumSize(720,576);
qDebug("\nCreating Process = Mplayer");
arguments << rtsp_path << " -vo gl:yuv=2:force-pbo:ati-hack -fps 25 ";
this->m_process = new QProcess();
this->m_process->setProgram(program);
this->m_process->setArguments(arguments);
this->m_process->start();
if(this->m_process->state()==QProcess::Running)
{
qDebug("\nSuccess in starting Process = Mplayer");
}
if(!this->m_process->waitForStarted())
{
qDebug("\nFailed To start Process = Mplayer");
}
}
Below is the wrapper that holds these QProcesses.
mplayer_wrapper::mplayer_wrapper(QWidget *parent) :
QWidget(parent)
{
QPalette p(palette());
p.setColor(QPalette::Background, Qt::black);
this->setAutoFillBackground(true);
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
this->setPalette(p);
this->setMinimumSize(720,576);
this->setMaximumSize(1440,576);
hlayout = new QHBoxLayout();
this->setLayout(hlayout);
if ((rtsp_path_cam_1 != nullptr)&&(rtsp_path_cam_2 != nullptr))
{
this->setFixedSize(1440,576);
}
else if((rtsp_path_cam_1 != nullptr)&&(rtsp_path_cam_2 == nullptr))
{
this->setFixedSize(720,576);
}
else if((rtsp_path_cam_1 == nullptr)&&(rtsp_path_cam_2 != nullptr))
{
this->setFixedSize(720,576);
}
else
{
qDebug("Error no camera's");
}
}
mplayer_wrapper::~mplayer_wrapper()
{
qDebug("\nDeleting Process = mplayer_wrapper");
}
void mplayer_wrapper::start_mplayer()
{
if ((!player)&&(rtsp_path_cam_1 != nullptr)) // Only allow one instance of the pointer to be generated.
{
player = new mplayer(rtsp_path_cam_1);
hlayout->addWidget(player);
count += 1;
}
if ((!player2)&&(rtsp_path_cam_2 != nullptr)) // Only allow one instance of the pointer to be generated.
{
player2 = new mplayer(rtsp_path_cam_2);
hlayout->addWidget(player2);
count += 1;
}
}
If anyone has any idea why this is failing to launch the second mplayer client that would be great.As currently a bit lost really, as the code seems fine but I just cant see why it is failing.
Below is my constructor for this process
mplayer::mplayer(QString rtsp_path, QWidget *parent) :
QWidget(parent)
{
QPalette p(palette());
p.setColor(QPalette::Background, Qt::black);
this->setAutoFillBackground(true);
this->setPalette(p);
this->setMinimumSize(720,576);
qDebug("\nCreating Process = Mplayer");
arguments << rtsp_path << " -vo gl:yuv=2:force-pbo:ati-hack -fps 25 ";
this->m_process = new QProcess();
this->m_process->setProgram(program);
this->m_process->setArguments(arguments);
this->m_process->start();
if(this->m_process->state()==QProcess::Running)
{
qDebug("\nSuccess in starting Process = Mplayer");
}
if(!this->m_process->waitForStarted())
{
qDebug("\nFailed To start Process = Mplayer");
}
}
Below is the wrapper that holds these QProcesses.
mplayer_wrapper::mplayer_wrapper(QWidget *parent) :
QWidget(parent)
{
QPalette p(palette());
p.setColor(QPalette::Background, Qt::black);
this->setAutoFillBackground(true);
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
this->setPalette(p);
this->setMinimumSize(720,576);
this->setMaximumSize(1440,576);
hlayout = new QHBoxLayout();
this->setLayout(hlayout);
if ((rtsp_path_cam_1 != nullptr)&&(rtsp_path_cam_2 != nullptr))
{
this->setFixedSize(1440,576);
}
else if((rtsp_path_cam_1 != nullptr)&&(rtsp_path_cam_2 == nullptr))
{
this->setFixedSize(720,576);
}
else if((rtsp_path_cam_1 == nullptr)&&(rtsp_path_cam_2 != nullptr))
{
this->setFixedSize(720,576);
}
else
{
qDebug("Error no camera's");
}
}
mplayer_wrapper::~mplayer_wrapper()
{
qDebug("\nDeleting Process = mplayer_wrapper");
}
void mplayer_wrapper::start_mplayer()
{
if ((!player)&&(rtsp_path_cam_1 != nullptr)) // Only allow one instance of the pointer to be generated.
{
player = new mplayer(rtsp_path_cam_1);
hlayout->addWidget(player);
count += 1;
}
if ((!player2)&&(rtsp_path_cam_2 != nullptr)) // Only allow one instance of the pointer to be generated.
{
player2 = new mplayer(rtsp_path_cam_2);
hlayout->addWidget(player2);
count += 1;
}
}
If anyone has any idea why this is failing to launch the second mplayer client that would be great.As currently a bit lost really, as the code seems fine but I just cant see why it is failing.