// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// /* Main OdVisualizeStreamingClient commands implementation */ #include "OdaCommon.h" #include "Client.h" OdUInt64 OdTvStreamingClient::requestFileList( bool bPartialOnly ) { OdTvMessagePtr pMsg = m_messageBuilder.buildCommandMessage( bPartialOnly ? OdTvMessage::Commands::kGet_FileList_Partial : OdTvMessage::Commands::kGet_FileList_Linear ); if( !pMsg ) return -1; OdUInt64 nCmd = m_nRequestId++; pMsg->setId( nCmd ); std::lock_guard guard( m_commandsMutex ); m_commands.push_back( pMsg ); return nCmd; } OdUInt64 OdTvStreamingClient::requestFile( const OdString& file ) { OdTvMessagePtr pMsg = m_messageBuilder.buildFileRequestMessage( file ); if( !pMsg ) return -1; OdUInt64 nCmd = m_nRequestId++; pMsg->setId( nCmd ); std::lock_guard guard( m_commandsMutex ); m_commands.push_back( pMsg ); return nCmd; } OdUInt64 OdTvStreamingClient::requestFileParts( const OdString& file, const OdVector< OdTvMessage::FilePart >& parts ) { OdTvMessagePtr pMsg = m_messageBuilder.buildFilePartsRequestMessage( file, parts ); if( !pMsg ) return -1; OdUInt64 nCmd = m_nRequestId++; pMsg->setId( nCmd ); std::lock_guard guard( m_commandsMutex ); m_commands.push_back( pMsg ); return nCmd; } bool OdTvStreamingClient::cancelCommand( OdUInt64 id ) { unsigned nResponse = 0; { std::lock_guard guard( m_awaitsMutex ); for( ; nResponse < m_awaitsResponses.size(); nResponse++ ) { if( id == m_awaitsResponses[ nResponse ].id ) { m_awaitsResponses.removeAt( nResponse ); break; } } } { std::lock_guard guard( m_responseMutex ); auto iter = m_responses.find( id ); if( iter != m_responses.end() ) { m_responses.erase( iter ); } } OdTvMessagePtr pMsg = m_messageBuilder.buildCommandMessage( OdTvMessage::Commands::kCancelRequest ); if( !pMsg ) return false; pMsg->setId( id ); { std::lock_guard guard( m_commandsMutex ); m_commands.push_back( pMsg ); } return true; } OdTvMessagePtr OdTvStreamingClient::getTopCommand() { std::lock_guard guard( m_commandsMutex ); if( !m_commands.empty() ) return *m_commands.begin(); return std::shared_ptr< OdTvMessage >( nullptr ); } void OdTvStreamingClient::removeTopCommand() { std::lock_guard guard( m_commandsMutex ); if( !m_commands.empty() ) { m_commands.erase( m_commands.begin() ); } } void OdTvStreamingClient::closeConnection() { std::lock_guard guard( m_commandsMutex ); m_commands.clear(); OdTvMessagePtr pMsg = m_messageBuilder.buildCommandMessage( OdTvMessage::Commands::kClose ); if( !pMsg ) return; OdUInt64 nCmd = m_nRequestId++; pMsg->setId( nCmd ); m_commands.push_back( pMsg ); m_bClosing = true; } bool OdTvStreamingClient::isClosing() { std::lock_guard guard( m_commandsMutex ); return m_bClosing; } bool OdTvStreamingClient::hasResponse( OdUInt64 id ) { std::lock_guard guard( m_responseMutex ); return m_responses.find( id ) != m_responses.end(); } OdTvStreamingClientDataPtr OdTvStreamingClient::getResponse( OdUInt64 id ) { std::lock_guard guard( m_responseMutex ); auto iter = m_responses.find( id ); if( iter == m_responses.end() ) return OdTvStreamingClientDataPtr( nullptr ); OdTvStreamingClientDataPtr pRes = iter->second; m_responses.erase( iter ); return pRes; } OdTvStreamingClient::Status OdTvStreamingClient::clientStatus() { std::lock_guard guard( m_commandsMutex ); return m_status; } void OdTvStreamingClient::setClientStatus( OdTvStreamingClient::Status st ) { std::lock_guard guard( m_commandsMutex ); m_status = st; }