PLINK_FILE FsmReadCFile( FILE *fd ) { PLINK_FILE pFileBase = NULL, pFile; UCHAR auchLine[ MAX_LINE_LEN ]; BOOL boolOldFsmCode = FALSE; PSZ pszToken, pszTmp; USHORT i; // PSZ pszLine = (PSZ)auchLine; while (fgets( auchLine, MAX_LINE_LEN - 1, fd ) != NULL) { if (!boolOldFsmCode) { NEW( pFile ); pFile->pszLine = StrAlloc( auchLine ); pFile->usState = FSM_NORMAL_C_LINE; pFileBase = LinkElement( pFileBase, pFile ); if (!memcmp( auchLine, "#ifdef", sizeof( "#ifdef" ) - 1 )) { // I don't trust on sscanf ... pszToken = StrNotBrk( &auchLine[sizeof( "#ifdef" )], " \t"); pszTmp = StrBrk( pszToken, " \t\n\r"); *pszTmp = 0; for (i = 0; aFsmCTokens[i].pszToken != NULL; i++) { if (!_stricmp( aFsmCTokens[i].pszToken, pszToken )) { pFile->usState = aFsmCTokens[i].usToken; boolOldFsmCode = TRUE; break; } } } } else { if (!memcmp( auchLine, "#endif", sizeof( "#endif" ) - 1)) { boolOldFsmCode = FALSE; NEW( pFile ); pFile->usState = FSM_NORMAL_C_LINE; pFile->pszLine = StrAlloc( auchLine ); pFileBase = LinkElement( pFileBase, pFile ); } } } return pFileBase; }
void BasicMediaStream::Create() { std::string defaultCameraPath = m_context->ConfigurationReader->GetKeyStringValue(KnownConfigKeys::BMS_DEFAULT_CAMERA); // setting source auto availableCameras = m_context->CameraHandler->GetCameras(); auto it = availableCameras.find(defaultCameraPath); if(it == availableCameras.end()) return; auto cameraElement = m_context->CameraHandler->GetCameraElement(defaultCameraPath); m_elements.push_back(cameraElement); /* // setting queue std::string queueName = "queue"; std::shared_ptr<IStreamElement> queueElement = std::make_shared<QueueElement>(queueName); m_elements.push_back(queueElement); */ // setting MPEG decode stream std::string mpegDecode = "decodebin"; std::shared_ptr<IStreamElement> decodeElement = std::make_shared<DecodeBinElement>(mpegDecode); m_elements.push_back(decodeElement); // setting sink std::string sinkName = "sink"; std::shared_ptr<IStreamElement> sinkElement = std::make_shared<AutoVideoSinkElement>(sinkName); m_elements.push_back(sinkElement); if(cameraElement == nullptr //|| queueElement == nullptr || decodeElement == nullptr || sinkElement == nullptr) { const std::string errorMsg = "Couldn't create elements in stream: " + m_name; m_context->Logger->WriteError(errorMsg); throw StreamNotCreatedException(m_name); } // adding elements to stream bool success = true; success &= cameraElement->AddToStream(m_bin); //success &= queueElement->AddToStream(m_bin); //success &= decodeElement->AddToStream(m_bin); success &= sinkElement->AddToStream(m_bin); if(!success) { const std::string errorMsg = "Couldn't add elements to stream: " + m_name; m_context->Logger->WriteError(errorMsg); throw StreamNotCreatedException(m_name); } //success &= cameraElement->LinkElement(decodeElement); //success &= decodeElement->LinkElement(sinkElement); //std::map<std::string, std::string> params = {{"height", "640"}, {"width", "480"}, {"framerate", "30/1"}}; success &= cameraElement->LinkElement(sinkElement); g_object_set (sinkElement->GetRawElement(), "sync", false, NULL); if(!success) { const std::string errorMsg = "Couldn't link elements in stream: " + m_name; m_context->Logger->WriteError(errorMsg); throw StreamNotCreatedException(m_name); } }