diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index 434cf2d5..33a4538b 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -52,6 +52,7 @@ public: CChannelFader ( QWidget* pNW, QHBoxLayout* pParentLayout ); void SetText ( const QString sText ); + void SetInstrumentPicture ( const int iInstrument ); void Show() { pFrame->show(); } void Hide() { pFrame->hide(); } bool IsVisible() { return pLabel->isVisible(); } @@ -93,12 +94,12 @@ public: CAudioMixerBoard ( QWidget* parent = 0, Qt::WindowFlags f = 0 ); void HideAll(); - void ApplyNewConClientList ( CVector& vecChanInfo ); + void ApplyNewConClientList ( CVector& vecChanInfo ); void SetServerName ( const QString& strNewServerName ); void SetGUIDesign ( const EGUIDesign eNewDesign ); protected: - QString GenFaderText ( CChannelShortInfo& ChanInfo ); + QString GenFaderText ( CChannelInfo& ChanInfo ); void OnChSoloStateChanged ( const int iChannelIdx, const int iValue ); CVector vecpChanFader; diff --git a/src/client.h b/src/client.h index 613c1713..b4025917 100755 --- a/src/client.h +++ b/src/client.h @@ -216,7 +216,7 @@ public: void SetRemoteChanGain ( const int iId, const double dGain ) { Channel.SetRemoteChanGain ( iId, dGain ); } - void SetRemoteName() { Channel.SetRemoteName ( strName ); } + void SetRemoteInfo() { Channel.SetRemoteInfo ( ChannelInfo ); } void CreateChatTextMes ( const QString& strChatText ) { Channel.CreateChatTextMes ( strChatText ); } @@ -240,7 +240,7 @@ public: // settings CVector vstrIPAddress; - QString strName; + CChannelCoreInfo ChannelInfo; #ifdef LLCON_VST_PLUGIN // VST version must have direct access to sound object @@ -324,7 +324,7 @@ public slots: void OnDetectedCLMessage ( CVector vecbyData, int iNumBytes ); void OnReqJittBufSize() { CreateServerJitterBufferMessage(); } void OnJittBufSizeChanged ( int iNewJitBufSize ); - void OnReqChanName() { Channel.SetRemoteName ( strName ); } + void OnReqChanInfo() { Channel.SetRemoteInfo ( ChannelInfo ); } void OnNewConnection(); void OnCLPingReceived ( CHostAddress InetAddr, int iMs ); @@ -337,7 +337,8 @@ public slots: void OnSndCrdReinitRequest ( int iSndCrdResetType ); signals: - void ConClientListMesReceived ( CVector vecChanInfo ); + void ConClientListNameMesReceived ( CVector vecChanInfo ); + void ConClientListMesReceived ( CVector vecChanInfo ); void ChatTextReceived ( QString strChatText ); void PingTimeReceived ( int iPingTime ); void CLServerListReceived ( CHostAddress InetAddr, diff --git a/src/protocol.cpp b/src/protocol.cpp index 3246cb69..f04fed82 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -64,7 +64,7 @@ MESSAGES (with connection) +-------------------+--------------+ -- PROTMESSID_CONN_CLIENTS_LIST: IP number and name of connected clients +- PROTMESSID_CONN_CLIENTS_LIST_NAME: IP number and name of connected clients for each connected client append following data: @@ -76,17 +76,19 @@ MESSAGES (with connection) ... ----------------------+ -- PROTMESSID_CONN_CLIENTS_LIST_ADD: Additional information about connected - clients +- PROTMESSID_CONN_CLIENTS_LIST: Information about connected clients for each connected client append following data: +-------------------+-----------------+--------------------+ ... | 1 byte channel ID | 2 bytes country | 4 bytes instrument | ... +-------------------+-----------------+--------------------+ ... - ... --------------------+ ... - ... 1 byte skill level | ... - ... --------------------+ ... + ... --------------------+--------------------+ ... + ... 1 byte skill level | 4 bytes IP address | ... + ... --------------------+--------------------+ ... + ... ------------------+---------------------------+ + ... 2 bytes number n | n bytes UTF-8 string name | + ... ------------------+---------------------------+ ... ------------------+---------------------------+ ... 2 bytes number n | n bytes UTF-8 string city | ... ------------------+---------------------------+ @@ -99,14 +101,28 @@ MESSAGES (with connection) - PROTMESSID_CHANNEL_NAME: Name of channel - for each connected client append following data: - +------------------+----------------------+ | 2 bytes number n | n bytes UTF-8 string | +------------------+----------------------+ -- PROTMESSID_REQ_CHANNEL_NAME: Request name of channel +- PROTMESSID_CHANNEL_INFOS: Information about the channel + + +-----------------+--------------------+ ... + | 2 bytes country | 4 bytes instrument | ... + +-----------------+--------------------+ ... + ... --------------------+ ... + ... 1 byte skill level | ... + ... --------------------+ ... + ... ------------------+---------------------------+ ... + ... 2 bytes number n | n bytes UTF-8 string name | ... + ... ------------------+---------------------------+ ... + ... ------------------+---------------------------+ + ... 2 bytes number n | n bytes UTF-8 string city | + ... ------------------+---------------------------+ + + +- PROTMESSID_REQ_CHANNEL_INFOS: Request infos of the channel note: does not have any data -> n = 0 @@ -514,24 +530,30 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false; bRet = EvaluateChanGainMes ( vecData ); break; +// #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### +case PROTMESSID_CONN_CLIENTS_LIST_NAME: + bRet = EvaluateConClientListNameMes ( vecData ); + break; + case PROTMESSID_CONN_CLIENTS_LIST: bRet = EvaluateConClientListMes ( vecData ); break; - case PROTMESSID_CONN_CLIENTS_LIST_ADD: - bRet = EvaluateConClientListAddMes ( vecData ); - break; - case PROTMESSID_REQ_CONN_CLIENTS_LIST: bRet = EvaluateReqConnClientsList(); break; - case PROTMESSID_CHANNEL_NAME: - bRet = EvaluateChanNameMes ( vecData ); +// #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### +case PROTMESSID_CHANNEL_NAME: + bRet = EvaluateChanNameMes ( vecData ); + break; + + case PROTMESSID_CHANNEL_INFOS: + bRet = EvaluateChanInfoMes ( vecData ); break; - case PROTMESSID_REQ_CHANNEL_NAME: - bRet = EvaluateReqChanNameMes(); + case PROTMESSID_REQ_CHANNEL_INFOS: + bRet = EvaluateReqChanInfoMes(); break; case PROTMESSID_CHAT_TEXT: @@ -744,7 +766,7 @@ bool CProtocol::EvaluateChanGainMes ( const CVector& vecData ) return false; // no error } -void CProtocol::CreateConClientListMes ( const CVector& vecChanInfo ) +void CProtocol::CreateConClientListNameMes ( const CVector& vecChanInfo ) { const int iNumClients = vecChanInfo.Size(); @@ -777,14 +799,14 @@ void CProtocol::CreateConClientListMes ( const CVector& vecCh PutStringUTF8OnStream ( vecData, iPos, strUTF8Name ); } - CreateAndSendMessage ( PROTMESSID_CONN_CLIENTS_LIST, vecData ); + CreateAndSendMessage ( PROTMESSID_CONN_CLIENTS_LIST_NAME, vecData ); } -bool CProtocol::EvaluateConClientListMes ( const CVector& vecData ) +bool CProtocol::EvaluateConClientListNameMes ( const CVector& vecData ) { - int iPos = 0; // init position pointer - const int iDataLen = vecData.Size(); - CVector vecChanInfo ( 0 ); + int iPos = 0; // init position pointer + const int iDataLen = vecData.Size(); + CVector vecChanInfo ( 0 ); while ( iPos < iDataLen ) { @@ -813,7 +835,7 @@ bool CProtocol::EvaluateConClientListMes ( const CVector& vecData ) } // add channel information to vector - vecChanInfo.Add ( CChannelShortInfo ( iChanID, iIpAddr, strCurStr ) ); + vecChanInfo.Add ( CChannelInfo ( iChanID, iIpAddr, strCurStr ) ); } // check size: all data is read, the position must now be at the end @@ -823,12 +845,12 @@ bool CProtocol::EvaluateConClientListMes ( const CVector& vecData ) } // invoke message action - emit ConClientListMesReceived ( vecChanInfo ); + emit ConClientListNameMesReceived ( vecChanInfo ); return false; // no error } -void CProtocol::CreateConClientListAddMes ( const CVector& vecChanInfo ) +void CProtocol::CreateConClientListMes ( const CVector& vecChanInfo ) { const int iNumClients = vecChanInfo.Size(); @@ -838,13 +860,16 @@ void CProtocol::CreateConClientListAddMes ( const CVector ( vecChanInfo[i].iSkillLevel ), 1 ); + static_cast ( vecChanInfo[i].eSkillLevel ), 1 ); + + // IP address (4 bytes) + PutValOnStream ( vecData, iPos, + static_cast ( vecChanInfo[i].iIpAddr ), 4 ); + + // name + PutStringUTF8OnStream ( vecData, iPos, strUTF8Name ); // city PutStringUTF8OnStream ( vecData, iPos, strUTF8City ); } - CreateAndSendMessage ( PROTMESSID_CONN_CLIENTS_LIST_ADD, vecData ); + CreateAndSendMessage ( PROTMESSID_CONN_CLIENTS_LIST, vecData ); } -bool CProtocol::EvaluateConClientListAddMes ( const CVector& vecData ) +bool CProtocol::EvaluateConClientListMes ( const CVector& vecData ) { - int iPos = 0; // init position pointer - const int iDataLen = vecData.Size(); - CVector vecChanInfo ( 0 ); + int iPos = 0; // init position pointer + const int iDataLen = vecData.Size(); + CVector vecChanInfo ( 0 ); while ( iPos < iDataLen ) { - // check size (the next 8 bytes) - if ( ( iDataLen - iPos ) < 8 ) + // check size (the next 12 bytes) + if ( ( iDataLen - iPos ) < 12 ) { return true; // return error code } @@ -900,25 +932,41 @@ bool CProtocol::EvaluateConClientListAddMes ( const CVector& vecData ) static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); // skill level (1 byte) - const int iSkillLevel = - static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + const ESkillLevel eSkillLevel = + static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + + // IP address (4 bytes) + const int iIpAddr = + static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); + + // name + QString strCurName; + if ( GetStringFromStream ( vecData, + iPos, + MAX_LEN_FADER_TAG, + strCurName ) ) + { + return true; // return error code + } // city - QString strCurStr; + QString strCurCity; if ( GetStringFromStream ( vecData, iPos, MAX_LEN_SERVER_CITY, - strCurStr ) ) + strCurCity ) ) { return true; // return error code } // add channel information to vector - vecChanInfo.Add ( CChannelAdditionalInfo ( iChanID, - eCountry, - strCurStr, - iInstrument, - iSkillLevel ) ); + vecChanInfo.Add ( CChannelInfo ( iChanID, + iIpAddr, + strCurName, + eCountry, + strCurCity, + iInstrument, + eSkillLevel ) ); } // check size: all data is read, the position must now be at the end @@ -928,7 +976,7 @@ bool CProtocol::EvaluateConClientListAddMes ( const CVector& vecData ) } // invoke message action - emit ConClientListAddMesReceived ( vecChanInfo ); + emit ConClientListMesReceived ( vecChanInfo ); return false; // no error } @@ -993,15 +1041,108 @@ bool CProtocol::EvaluateChanNameMes ( const CVector& vecData ) return false; // no error } -void CProtocol::CreateReqChanNameMes() +void CProtocol::CreateChanInfoMes ( const CChannelCoreInfo ChanInfo ) { - CreateAndSendMessage ( PROTMESSID_REQ_CHANNEL_NAME, CVector ( 0 ) ); + int iPos = 0; // init position pointer + + // convert strings to utf-8 + const QByteArray strUTF8Name = ChanInfo.strName.toUtf8(); + const QByteArray strUTF8City = ChanInfo.strCity.toUtf8(); + + // size of current list entry + const int iEntrLen = + 2 /* country */ + + 4 /* instrument */ + 1 /* skill level */ + + 2 /* utf-8 str. size */ + strUTF8Name.size() + + 2 /* utf-8 str. size */ + strUTF8City.size(); + + // build data vector + CVector vecData ( iEntrLen ); + + // country (2 bytes) + PutValOnStream ( vecData, iPos, + static_cast ( ChanInfo.eCountry ), 2 ); + + // instrument (4 bytes) + PutValOnStream ( vecData, iPos, + static_cast ( ChanInfo.iInstrument ), 4 ); + + // skill level (1 byte) + PutValOnStream ( vecData, iPos, + static_cast ( ChanInfo.eSkillLevel ), 1 ); + + // name + PutStringUTF8OnStream ( vecData, iPos, strUTF8Name ); + + // city + PutStringUTF8OnStream ( vecData, iPos, strUTF8City ); + + CreateAndSendMessage ( PROTMESSID_CHANNEL_INFOS, vecData ); } -bool CProtocol::EvaluateReqChanNameMes() +bool CProtocol::EvaluateChanInfoMes ( const CVector& vecData ) +{ + int iPos = 0; // init position pointer + const int iDataLen = vecData.Size(); + CChannelCoreInfo ChanInfo; + + // check size (the first 7 bytes) + if ( iDataLen < 7 ) + { + return true; // return error code + } + + // country (2 bytes) + ChanInfo.eCountry = + static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); + + // instrument (4 bytes) + ChanInfo.iInstrument = + static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); + + // skill level (1 byte) + ChanInfo.eSkillLevel = + static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + + // name + if ( GetStringFromStream ( vecData, + iPos, + MAX_LEN_FADER_TAG, + ChanInfo.strName ) ) + { + return true; // return error code + } + + // city + if ( GetStringFromStream ( vecData, + iPos, + MAX_LEN_SERVER_CITY, + ChanInfo.strCity ) ) + { + return true; // return error code + } + + // check size: all data is read, the position must now be at the end + if ( iPos != iDataLen ) + { + return true; // return error code + } + + // invoke message action + emit ChangeChanInfo ( ChanInfo ); + + return false; // no error +} + +void CProtocol::CreateReqChanInfoMes() +{ + CreateAndSendMessage ( PROTMESSID_REQ_CHANNEL_INFOS, CVector ( 0 ) ); +} + +bool CProtocol::EvaluateReqChanInfoMes() { // invoke message action - emit ReqChanName(); + emit ReqChanInfo(); return false; // no error } diff --git a/src/protocol.h b/src/protocol.h index de75dfe5..6fe7abd4 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -41,7 +41,7 @@ #define PROTMESSID_REQ_JITT_BUF_SIZE 11 // request jitter buffer size #define PROTMESSID_NET_BLSI_FACTOR 12 // OLD (not used anymore) #define PROTMESSID_CHANNEL_GAIN 13 // set channel gain for mix -#define PROTMESSID_CONN_CLIENTS_LIST 14 // connected client list +#define PROTMESSID_CONN_CLIENTS_LIST_NAME 14 // connected client list #define PROTMESSID_SERVER_FULL 15 // OLD (not used anymore) #define PROTMESSID_REQ_CONN_CLIENTS_LIST 16 // request connected client list #define PROTMESSID_CHANNEL_NAME 17 // set channel name for fader tag @@ -50,8 +50,9 @@ #define PROTMESSID_NETW_TRANSPORT_PROPS 20 // properties for network transport #define PROTMESSID_REQ_NETW_TRANSPORT_PROPS 21 // request properties for network transport #define PROTMESSID_DISCONNECTION 22 // OLD (not used anymore) -#define PROTMESSID_REQ_CHANNEL_NAME 23 // request channel name for fader tag -#define PROTMESSID_CONN_CLIENTS_LIST_ADD 24 // additional infos for connected clients +#define PROTMESSID_REQ_CHANNEL_INFOS 23 // request channel infos for fader tag +#define PROTMESSID_CONN_CLIENTS_LIST 24 // channel infos for connected clients +#define PROTMESSID_CHANNEL_INFOS 25 // set channel infos // message IDs of connection less messages (CLM) // DEFINITION -> start at 1000, end at 1999, see IsConnectionLessMessageID @@ -88,11 +89,12 @@ public: void CreateJitBufMes ( const int iJitBufSize ); void CreateReqJitBufMes(); void CreateChanGainMes ( const int iChanID, const double dGain ); - void CreateConClientListMes ( const CVector& vecChanInfo ); - void CreateConClientListAddMes ( const CVector& vecChanInfo ); + void CreateConClientListNameMes ( const CVector& vecChanInfo ); + void CreateConClientListMes ( const CVector& vecChanInfo ); void CreateReqConnClientsList(); void CreateChanNameMes ( const QString strName ); - void CreateReqChanNameMes(); + void CreateChanInfoMes ( const CChannelCoreInfo ChanInfo ); + void CreateReqChanInfoMes(); void CreateChatTextMes ( const QString strChatText ); void CreatePingMes ( const int iMs ); void CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrProps ); @@ -200,11 +202,12 @@ protected: bool EvaluateJitBufMes ( const CVector& vecData ); bool EvaluateReqJitBufMes(); bool EvaluateChanGainMes ( const CVector& vecData ); + bool EvaluateConClientListNameMes ( const CVector& vecData ); bool EvaluateConClientListMes ( const CVector& vecData ); - bool EvaluateConClientListAddMes ( const CVector& vecData ); bool EvaluateReqConnClientsList(); bool EvaluateChanNameMes ( const CVector& vecData ); - bool EvaluateReqChanNameMes(); + bool EvaluateChanInfoMes ( const CVector& vecData ); + bool EvaluateReqChanInfoMes(); bool EvaluateChatTextMes ( const CVector& vecData ); bool EvaluatePingMes ( const CVector& vecData ); bool EvaluateNetwTranspPropsMes ( const CVector& vecData ); @@ -248,12 +251,13 @@ signals: void ReqJittBufSize(); void ChangeNetwBlSiFact ( int iNewNetwBlSiFact ); void ChangeChanGain ( int iChanID, double dNewGain ); - void ConClientListMesReceived ( CVector vecChanInfo ); - void ConClientListAddMesReceived ( CVector vecChanInfo ); + void ConClientListNameMesReceived ( CVector vecChanInfo ); + void ConClientListMesReceived ( CVector vecChanInfo ); void ServerFullMesReceived(); void ReqConnClientsList(); void ChangeChanName ( QString strName ); - void ReqChanName(); + void ChangeChanInfo ( CChannelCoreInfo ChanInfo ); + void ReqChanInfo(); void ChatTextReceived ( QString strChatText ); void PingReceived ( int iMs ); void NetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps ); diff --git a/src/server.h b/src/server.h index c73d1b08..a7b39a0f 100755 --- a/src/server.h +++ b/src/server.h @@ -184,7 +184,7 @@ protected: int GetFreeChan(); int FindChannel ( const CHostAddress& InetAddr ); int GetNumberOfConnectedClients(); - CVector CreateChannelList(); + CVector CreateChannelList(); void CreateAndSendChanListForAllConChannels(); void CreateAndSendChanListForThisChan ( const int iCurChanID ); void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, @@ -342,18 +342,18 @@ public slots: void OnReqConnClientsListCh10() { CreateAndSendChanListForThisChan ( 10 ); } void OnReqConnClientsListCh11() { CreateAndSendChanListForThisChan ( 11 ); } - void OnNameHasChangedCh0() { CreateAndSendChanListForAllConChannels(); } - void OnNameHasChangedCh1() { CreateAndSendChanListForAllConChannels(); } - void OnNameHasChangedCh2() { CreateAndSendChanListForAllConChannels(); } - void OnNameHasChangedCh3() { CreateAndSendChanListForAllConChannels(); } - void OnNameHasChangedCh4() { CreateAndSendChanListForAllConChannels(); } - void OnNameHasChangedCh5() { CreateAndSendChanListForAllConChannels(); } - void OnNameHasChangedCh6() { CreateAndSendChanListForAllConChannels(); } - void OnNameHasChangedCh7() { CreateAndSendChanListForAllConChannels(); } - void OnNameHasChangedCh8() { CreateAndSendChanListForAllConChannels(); } - void OnNameHasChangedCh9() { CreateAndSendChanListForAllConChannels(); } - void OnNameHasChangedCh10() { CreateAndSendChanListForAllConChannels(); } - void OnNameHasChangedCh11() { CreateAndSendChanListForAllConChannels(); } + void OnChanInfoHasChangedCh0() { CreateAndSendChanListForAllConChannels(); } + void OnChanInfoHasChangedCh1() { CreateAndSendChanListForAllConChannels(); } + void OnChanInfoHasChangedCh2() { CreateAndSendChanListForAllConChannels(); } + void OnChanInfoHasChangedCh3() { CreateAndSendChanListForAllConChannels(); } + void OnChanInfoHasChangedCh4() { CreateAndSendChanListForAllConChannels(); } + void OnChanInfoHasChangedCh5() { CreateAndSendChanListForAllConChannels(); } + void OnChanInfoHasChangedCh6() { CreateAndSendChanListForAllConChannels(); } + void OnChanInfoHasChangedCh7() { CreateAndSendChanListForAllConChannels(); } + void OnChanInfoHasChangedCh8() { CreateAndSendChanListForAllConChannels(); } + void OnChanInfoHasChangedCh9() { CreateAndSendChanListForAllConChannels(); } + void OnChanInfoHasChangedCh10() { CreateAndSendChanListForAllConChannels(); } + void OnChanInfoHasChangedCh11() { CreateAndSendChanListForAllConChannels(); } void OnChatTextReceivedCh0 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 0, strChatText ); } void OnChatTextReceivedCh1 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 1, strChatText ); } diff --git a/src/settings.cpp b/src/settings.cpp index 45650e77..5dd2792e 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -66,7 +66,15 @@ void CSettings::Load() } // name - pClient->strName = GetIniSetting ( IniXMLDocument, "client", "name" ); + pClient->ChannelInfo.strName = + GetIniSetting ( IniXMLDocument, "client", "name" ); + + // instrument + if ( GetNumericIniSet ( IniXMLDocument, "client", "instrument", + 0, CInstPictures::GetNumAvailableInst() - 1, iValue ) ) + { + pClient->ChannelInfo.iInstrument = iValue; + } // audio fader if ( GetNumericIniSet ( IniXMLDocument, "client", "audfad", @@ -268,7 +276,11 @@ void CSettings::Save() // name PutIniSetting ( IniXMLDocument, "client", "name", - pClient->strName ); + pClient->ChannelInfo.strName ); + + // instrument + SetNumericIniSet ( IniXMLDocument, "client", "instrument", + pClient->ChannelInfo.iInstrument ); // audio fader SetNumericIniSet ( IniXMLDocument, "client", "audfad",