80 lines
2.0 KiB
C++
Executable File
80 lines
2.0 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* ChooseStream
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Christian Fröbel, SLSE, 2017-06-29
|
|
*/
|
|
|
|
#include "choose_stream.h"
|
|
#include "iava_comm.h"
|
|
#include "iava_command_done_observer.h"
|
|
|
|
|
|
namespace AudioVideoManagement
|
|
{
|
|
|
|
namespace AvaCommands
|
|
{
|
|
|
|
ChooseStream::ChooseStream(IAvaComm *comm, IAvaCommandDoneObserver *doneObserver, const QString &dialogId, const QString &streamName)
|
|
: m_dialogId(dialogId)
|
|
, m_streamName(streamName)
|
|
, m_comm(comm)
|
|
, m_observer(doneObserver)
|
|
{
|
|
Q_ASSERT(comm);
|
|
Q_ASSERT(doneObserver);
|
|
}
|
|
|
|
void ChooseStream::send()
|
|
{
|
|
connect(m_comm, &IAvaComm::streamInfoReceived, this, &ChooseStream::onStreamInfoReceived);
|
|
connect(m_comm, &IAvaComm::streamStateReceived, this, &ChooseStream::onStreamStateReceived);
|
|
connect(m_comm, &IAvaComm::streamModeReceived, this, &ChooseStream::onStreamModeReceived);
|
|
bool muted = true;
|
|
m_comm->chooseStream(m_dialogId, m_streamName, muted);
|
|
}
|
|
|
|
void ChooseStream::onStreamInfoReceived(const QString &dialogId, const QString &streamName, const AvaStreamInfo &streamInfo)
|
|
{
|
|
Q_ASSERT(dialogId == m_dialogId);
|
|
Q_ASSERT(streamName == m_streamName);
|
|
Q_ASSERT(!m_streamInfo);
|
|
m_streamInfo = streamInfo;
|
|
}
|
|
|
|
void ChooseStream::onStreamStateReceived(const QString &dialogId, const QString &streamName, AvaStreamState streamState)
|
|
{
|
|
Q_ASSERT(dialogId == m_dialogId);
|
|
|
|
// There can be multiple StreamStates for every stream that was active.
|
|
// But all come prior to StreamInfo
|
|
if (!m_streamInfo)
|
|
return;
|
|
|
|
Q_ASSERT(streamName == m_streamName);
|
|
Q_ASSERT(!m_streamState);
|
|
m_streamState = streamState;
|
|
}
|
|
|
|
void ChooseStream::onStreamModeReceived(const QString &dialogId, const QString &streamName, bool pint, bool autoStop)
|
|
{
|
|
Q_UNUSED(pint);
|
|
Q_UNUSED(autoStop);
|
|
Q_ASSERT(dialogId == m_dialogId);
|
|
Q_ASSERT(streamName == m_streamName);
|
|
Q_ASSERT(m_streamInfo);
|
|
Q_ASSERT(m_streamState);
|
|
done();
|
|
}
|
|
|
|
void ChooseStream::done()
|
|
{
|
|
m_comm->disconnect(this);
|
|
m_observer->done(this);
|
|
}
|
|
|
|
}} // namespace AudioVideoManagement::AvaCommands
|