/** * @RDE_HEADER@ * ChooseStream * $Id$ * $HeadURL$ * $Author$ * Created by Christian Fröbel, SLSE, 2017-06-29 */ #pragma once #include #include #include #include #include namespace AudioVideoManagement { class IAvaComm; class IAvaCommandDoneObserver; namespace AvaCommands { /** * Example protocol for chooseStream: * @code * ==> b'chooseStream "av_0045" 1 "CTCVideo-1"\n' * <== b'200 OK\r\n' * <== b'221 "av_0040" "CTCVideo-1" 1523026547.94 STREAMPOS\r\n' -- for each previously active stream * <== b'221 "av_0053" "CTCVideo-1" 1523026547.94 STREAMPOS\r\n' * <== b'221 "av_0045" "CTCVideo-1" 1523026547.94 STREAMPOS\r\n' * <== b'221 "av_0036" "CTCVideo-1" 1523026547.94 STREAMPOS\r\n' * <== b'223 "av_0036" "CTCVideo-1" 3 STREAMSTATE\r\n' -- for each previously active video *and* audio stream * <== b'223 "av_0040" "CTCVideo-1" 3 STREAMSTATE\r\n' * <== b'223 "av_0045" "CTCVideo-1" 3 STREAMSTATE\r\n' * <== b'223 "av_0053" "CTCVideo-1" 3 STREAMSTATE\r\n' * <== b'223 "av_0040" "CTCVideo-1" 3 STREAMSTATE\r\n' * <== b'223 "av_0053" "CTCVideo-1" 3 STREAMSTATE\r\n' * <== b'223 "av_0045" "CTCVideo-1" 3 STREAMSTATE\r\n' * <== b'223 "av_0036" "CTCVideo-1" 3 STREAMSTATE\r\n' * <== b'220 "av_0045" "CTCVideo-1" 1523026548.00 1523026548.00 0.00 STREAMINFO\r\n' -- for the newly chosen stream * <== b'221 "av_0045" "CTCVideo-1" 1523026548.00 STREAMPOS\r\n' * <== b'222 "av_0045" "CTCVideo-1" 100 STREAMSPEED\r\n' * <== b'223 "av_0045" "CTCVideo-1" 0 STREAMSTATE\r\n' * <== b'224 "av_0045" "CTCVideo-1" 1 0 STREAMMODE\r\n' * <== b'225 "av_0045" "CTCVideo-1" 1 STREAMAUDIOMUTE\r\n' -- optional, in case the stream has an audio part * <== b'228 "av_0045" "CTCVideo-1" 1 STREAMVOLUMECHANGED\r\n' * <== b'225 "av_0045" "CTCVideo-1" 1 STREAMAUDIOMUTE\r\n' * <== b'223 "av_0045" "CTCVideo-1" 1 STREAMSTATE\r\n' * @endcode * * The order of those responses is deterministic. * See AVS-Software src/app/AVS_Workstation/app/presentationgroup.cpp: * int PresentationGroup::sendInfo(QString stream, int type) * * So we synchronize on the StreamMode response as everything thereafter is optional. * * @author Christian Fröbel */ class AVM_COMMON_EXPORT ChooseStream final : public ICommand { Q_OBJECT public: ChooseStream(IAvaComm *comm, IAvaCommandDoneObserver *doneObserver, const QString &dialogId, const QString &streamName); void send() override; QString debug() const override { return QLatin1String("ChooseStream: ") + m_streamName; } /** * May only be called after the command has successfully completed. */ ///{@ AvaStreamInfo streamInfo() const { return *m_streamInfo; } AvaStreamState streamState() const { return *m_streamState; } ///@} private slots: void onStreamInfoReceived(const QString &dialogId, const QString &streamName, const AvaStreamInfo &streamInfo); void onStreamStateReceived(const QString &dialogId, const QString &streamName, AvaStreamState streamState); void onStreamModeReceived(const QString &dialogId, const QString &streamName, bool pint, bool autoStop); private: void done(); const QString m_dialogId; const QString m_streamName; boost::optional m_streamInfo; boost::optional m_streamState; IAvaComm *m_comm; IAvaCommandDoneObserver *m_observer; }; }} // namespace AudioVideoManagement::AvaCommands