/** * @RDE_HEADER@ * AvaTestServer * $Id$ * $HeadURL$ * $Author$ * Created by Christian Fröbel, SLSE, 2017-06-19 */ #pragma once #include #include #include #include #include #include namespace AudioVideoManagement { /** * Taken from ZW/ZWPR/ScrEdAV/ScrEdAVStream.{hpp,cpp} */ class ScrEdAVStream { public: /** * Get the stream category * @return return the stream category type. */ int getCategory() const; /** * Get the stream duration. * @return QDateTime object with the stream duration */ double getDuration() const; /** * get the stream end time. * @return QDateTime object with the end time. */ QDateTime getEndTime() const; /** * get the stream name. * @return QString with the name of the stream. */ QString getName() const; /** * get the stream's play time. * @return QDateTime object with the actual stream play time. */ QDateTime getPlayTime() const; /** * get the signal pause handling flag. * @return int with the signla pause handling state. */ int getSignalPauseHandling() const; /** * get the stream speed. * @return int with the stream play speed. */ int getSpeed() const; /** * get the stream's start time. * @return QDateTime object with the stream start time. */ QDateTime getStartTime() const; /** * get the stream play state. * @return in with the stream play state. */ int getState() const; /** * get the stream ply mode. * @return int with the stream play mode */ int getStreamPlayMode() const; /** * get the stream type. * @return int with the stream type. */ int getType() const; /** * denotes the stream mute state. * @return true when the stream is muted, false otherwise. */ bool isMute() const; /** * set the stream category, possible values are: * @li 1 ->interface * @li 2 ->server * @li 4->local * * @param newVal */ void setCategory(int newVal); /** * set the stream's duration. * * @param newVal */ void setDuration(double newVal); /** * set the stream's end time. * * @param newVal */ void setEndTime(const QDateTime &newVal); /** * set the Mute state for the stream. * * @param newVal */ void setMute(bool newVal); /** * set the stream name * * @param newVal */ void setName(const QString &newVal); /** * set the stream's end time. * * @param newVal */ void setPlayTime(const QDateTime &newVal); /** * set the signal pause handling flag. * * @param newVal */ void setSignalPauseHandling(int newVal); /** * set the stream speed. * * @param newVal */ void setSpeed(int newVal); /** * set the stream's start time. * * @param newVal */ void setStartTime(const QDateTime &newVal); /** * set the Stream state. * * @param newVal */ void setState(int newVal); /** * set the stream play mode. * * @param newVal */ void setStreamPlayMode(int newVal); /** * set the stream type, 1 -> Audio, 2 -> Video * * @param newVal */ void setType(int newVal); /** * Set the volume factor */ void setVolumeFactor(double factor) { m_VolumeFactor = factor; } /** * Return the volume factor */ double getVolumeFactor() const { return m_VolumeFactor; } double getVolume() const; void setVolume(double volume); private: /** * Contains the stream category, possible values are: * @li 1 - interface * @li 2 - server * @li 4- local */ int m_Category{1}; /** * Contains the stream duration. */ double m_Duration{0}; /** * Contains the stream end time. */ QDateTime m_EndTime; /** * Contains the Mute state for the stream. */ bool m_Mute{false}; /** * Contains the stream name */ QString m_Name; /** * Contains the stream's actual play position time. */ QDateTime m_PlayTime; /** * Contains the signal pause handling flag. */ int m_SignalPauseHandling{1}; /** * Contains the stream speed. */ int m_Speed{100}; /** * Contains the stream's start time. */ QDateTime m_StartTime; /** * Contains the Stream state. */ int m_State{0}; /** * Contains the stream play mode. */ int m_StreamPlayMode{0}; /** * Contains the stream type * @li 1 - audio * @li 2 - video */ int m_Type{0}; /** * The volume factor for this script */ double m_VolumeFactor{50}; }; //====================================================================================================================== /** * Taken from ZW/ZWPR/ScrEdAV/ScrEdAVScript.{hpp,cpp} */ class ScrEdAVScript { public: /** * Contains the script type. The type is one of the follwoing list: * @li 1 = AUDIO * @li 2 = VIDEO * @li 3 = LOCAL AUDIO * @li 4 = LOCAL VIDEO * @return returns an int with the category type. */ int getCategory() const; /** * Gets the filesplitting parameter * @return returns an int with the filesplitting parameter. */ int getFileSplitting() const; /** * get the name of the current played stream. * @return returns a QString with the name of the current played stream. */ QString getCurrentPlayedStream() const; /** * get the name of export script name. * @return returns a QString with the name of the export script name . */ QString getExportScriptName() const; /** * get the name of the export directory. * @return returns a QString of the export directory. */ QString getExportDirectory() const; /** * Gets the scripts duration. * @return returns a QDateTime object with the script duration. */ double getDuration() const; /** * gets the elapsed time in relation to the script start. * @return returns a QDateTime with the elapsed time in relation to the script * start. */ double getElapsedTime() const; /** * get the scripts end time. * @return returns a QDateTime object with the scripts end time. */ QDateTime getEndTime() const; /** * gets the script's name. * @return returns a QString with the scripts name. */ QString getName() const; /** * gets the scripts start time. * @return returns a QDateTime object with the scripts start time. */ QDateTime getStartTime() const; /** * gets the scripts play state. Possible states are: * @li 0 = STOP * @li 1 = START * @li 2 = PAUSE * @li 3 = Datenpfad abgebaut * @li 4 = Datenpfad darf nicht aufgebaut werden * @return returns an int with the scripts play state. */ int getState() const; /** * Get the stream sequences. * @return returns a QVector which contains ScrEdAVStream objects. */ QVector getStreamSequences() const; /** * Denotes if the script is muted or not. * @return true when the script is muted, false otherwise. */ bool isMute() const; /** * Contains the script type. * * @param newVal The new value for the script category. possible values are: * @li 1 = AUDIO * @li 2 = VIDEO * @li 3 = LOCAL AUDIO * @li 4 = LOCAL VIDEO */ void setCategory(int newVal); /** * Set the name of the current played stream. * * @param newVal The name of the current played stream. */ void setCurrentPlayedStream(const QString &newVal); /** * Set the scripts duration. * * @param newVal The new script duration value. */ void setDuration(double newVal); /** * Set the elapsed time in relation to the script start. * * @param newVal The new vakue for the elapsed time. */ void setElapsedTime(double newVal); /** * Set the scripts end time. * * @param newVal The new value for the end time. */ void setEndTime(const QDateTime &newVal); /** * set the script muted or not. * * @param newVal the new value for mute. */ void setMute(bool newVal); /** * Set the script's name. * * @param newVal The scripts new name. */ void setName(const QString &newVal); /** * Set the scripts start time. * * @param newVal The scripts new start time. */ void setStartTime(const QDateTime &newVal); /** * set the scripts play state. * * @param newVal set the new play state: Possible states are: * @li 0 = STOP * @li 1 = START * @li 2 = PAUSE * @li 3 = Datenpfad abgebaut * @li 4 = Datenpfad darf nicht aufgebaut werden */ void setState(int newVal); /** * set the scripts play state. * * @param newVal set the new filesplitting value: Possible states are: * @li 0 = Dateisplitting nur bei einem Wechsel des Stream-Typs * @li 1 = Dateisplitting nach jeder Skriptzeile */ void setFileSplitting(int newVal); /** * set the stream sequences. * * @param newVal set a QVector with the new stream sequences. */ void setStreamSequences(const QVector &newVal); /** * set the name of the export script. * * @param newVal name of the export script. */ void setExportScriptName(const QString &newVal); /** * set the directory for the export script * * @param newVal directory of the export script */ void setExportDirectory(const QString &newVal); private: /** * Contains the script type. Possible values are: * @li 1 = AUDIO * @li 2 = VIDEO * @li 3 = LOCAL AUDIO * @li 4 = LOCAL VIDEO */ int m_Category{0}; /** * Contains the name of the current played stream. */ QString m_CurrentPlayedStream; /** * Contains the scripts duration. */ double m_Duration{0}; /** * Contains the elapsed time in relation to the script start. */ double m_ElapsedTime{0}; /** * Contains the scripts end time. */ QDateTime m_EndTime; /** * Denotes if the script is muted or not. */ bool m_Mute{false}; /** * Contains the script's name. */ QString m_Name; /** * Contains the scripts start time. */ QDateTime m_StartTime; /** * Contains the play state. Possible states are: * @li 0 = STOP * @li 1 = START * @li 2 = PAUSE * @li 3 = Datenpfad abgebaut * @li 4 = Datenpfad darf nicht aufgebaut werden */ int m_State{0}; /** * Contains the file splitting. Possible states are: * @li 0 = Dateisplitting nur bei einem Wechsel des Stream-Typs * @li 1 = Dateisplitting nach jeder Skriptzeile */ int m_FileSplitting{0}; /** * Contains the stream sequences. */ QVector m_StreamSequences; /** * Contains the export script name. */ QString m_ExportScriptName; /** * Contains the export directory name. */ QString m_ExportDirectory; }; //====================================================================================================================== /** * This class can be used in tests to replace AVS_Workstation. * It mocks the server side of the RCP/AVA protocol. * * Taken and adapted from ZW/ZWPR/ScrEdAV/TestApp/ScrEdAVTestServer.{hpp,cpp} */ class AvaTestServer : public QObject { Q_OBJECT public: AvaTestServer(); ~AvaTestServer() override; private: QTcpServer *m_Server; QVector m_Conns; QString m_SignalPause; QDateTime m_Position; float m_AbsScriptPos; float m_RelScriptPos; QString m_SelectedStream; QString m_SelectedScript; QString m_Outputdevice; QTimer *m_PosUpdate; QTimer *m_ScriptPosUpdate; int m_PosUpdateTime; int m_StreamState; int m_ScriptState; int m_StreamSpeed; int m_PendingListReading; bool m_ReversPlay; bool m_Audiomute; bool m_PlayMode; QVector m_Scripts; ScrEdAVScript m_Script; ScrEdAVStream m_SelStreamFromScript; int m_StreamNbr; QString qDateTimeToAVTime(const QDateTime &a_qDateTime); QString floatToAVTime(float a_time); float avTimeToFloat(const QByteArray &a_avTime); QDateTime avTimeToQDateTime(const QString &a_avTime); /** Called for every line received on a connection. */ void processLine(const QByteArray &line); QList parse(const QByteArray &a_byteArray, int a_i); void sendData(const QString &data_); void replyOk(); void replyBadArguments(); void replyBadCommand(); void replyCommandNotAllowed(); private slots: void connectionIncoming(); void readAndAnswer(); void sendPosUpdate(); void sendScriptPosUpdate(); void closedConnection(); }; } // namespace AudioVideoManagement