void EngineClient::receiveDeleteSprite(ds::DataBuffer& data) { // First data is the count if (!data.canRead<size_t>()) return; size_t size = data.read<size_t>(); for (size_t k=0; k<size; ++k) { if (data.canRead<sprite_id_t>()) { const sprite_id_t id = data.read<sprite_id_t>(); // std::cout << "DELETE=" << id << std::endl; if (!mSprites.empty()) { auto f = mSprites.find(id); if (f != mSprites.end()) { // Once I delete this item, mSprites will have been updated, // with f->second and all children removed, so do not reference f again. if (f->second) f->second->release(); } } } else { break; } } if (!data.canRead<char>()) { DS_LOG_ERROR("EngineClient::receiveDeleteSprite() no space for an ending terminator"); return; } const char cmd(data.read<char>()); if (cmd != ds::TERMINATOR_CHAR) { DS_LOG_ERROR("EngineClient::receiveDeleteSprite() no ending terminator"); } }
ds::EngineService& SpriteEngine::private_getService(const std::string& str) { ds::EngineService* s = mData.mServices[str]; if (!s) { const std::string msg = "Service (" + str + ") does not exist"; DS_DBG_CODE(DS_LOG_ERROR(msg)); throw std::runtime_error(msg); } return *s; }
bool VideoMetaCache::getVideoInfo(Entry& entry) { MediaInfoDLL::MediaInfo media_info; if (!media_info.IsReady()) { // Indicates the DLL couldn't be loaded DS_LOG_ERROR("VideoMetaCache::getVideoInfo() MediaInfo not loaded, does dll/MediaInfo.dll exist in the app folder?"); throw std::runtime_error("VideoMetaCache::getVideoInfo() MediaInfo not loaded, does dll/MediaInfo.dll exist in the app folder?"); return false; } media_info.Open(ds::wstr_from_utf8(entry.mPath)); size_t numAudio = media_info.Count_Get(MediaInfoDLL::Stream_Audio); size_t numVideo = media_info.Count_Get(MediaInfoDLL::Stream_Video); if(numAudio < 1 && numVideo < 1){ DS_LOG_WARNING("Couldn't find any audio or video streams in " << entry.mPath); entry.mType = ERROR_TYPE; return false; } // If there's an audio channel, get it's codec if(numAudio > 0){ entry.mAudioCodec = ds::utf8_from_wstr(media_info.Get(MediaInfoDLL::Stream_Audio, 0, L"Codec", MediaInfoDLL::Info_Text)); } // No video streams, but has at least one audio stream is a AUDIO_TYPE if(numAudio > 0 && numVideo < 1){ entry.mType = AUDIO_TYPE; entry.mWidth = 0; entry.mHeight = 0; if(!ds::wstring_to_value(media_info.Get(MediaInfoDLL::Stream_Audio, 0, L"Duration", MediaInfoDLL::Info_Text), entry.mDuration)) return false; // Any number of audio streams and at least one video streams is VIDEO_TYPE } else if(numVideo > 0){ entry.mType = VIDEO_TYPE; if(!ds::wstring_to_value(media_info.Get(MediaInfoDLL::Stream_Video, 0, L"Width", MediaInfoDLL::Info_Text), entry.mWidth)) return false; if(!ds::wstring_to_value(media_info.Get(MediaInfoDLL::Stream_Video, 0, L"Height", MediaInfoDLL::Info_Text), entry.mHeight)) return false; // We don't check errors on these, cause they're not required by gstreamer to play a video, they're just nice-to-have entry.mVideoCodec = ds::utf8_from_wstr(media_info.Get(MediaInfoDLL::Stream_Video, 0, L"Codec", MediaInfoDLL::Info_Text)); entry.mColorSpace = ds::utf8_from_wstr(media_info.Get(MediaInfoDLL::Stream_Video, 0, L"Colorimetry", MediaInfoDLL::Info_Text)); ds::wstring_to_value(media_info.Get(MediaInfoDLL::Stream_Video, 0, L"Duration", MediaInfoDLL::Info_Text), entry.mDuration); } entry.mDuration /= 1000.0f; // Disabling duration check, if MediaInfo can't find it, that's ok, GStreamer can fill it in // if(entry.mDuration <= 0.0f || entry.mDuration > 360000.0f) { // 360000.0f == 100 hours. That should be enough, right? // DS_LOG_WARNING("VideoMetaCache::getVideoInfo() illegal duration (" << entry.mDuration << ") for file (" << entry.mPath << ")"); // return false; // } return true; }
void EngineClient::onClientStartedReplyCommand(ds::DataBuffer& data) { clearRoots(); char cmd; while (data.canRead<char>() && (cmd=data.read<char>()) != ds::TERMINATOR_CHAR) { if (cmd == ATT_CLIENT) { char att; std::string guid; int32_t sessionid(0); while (data.canRead<char>() && (att=data.read<char>()) != ds::TERMINATOR_CHAR) { if (att == ATT_GLOBAL_ID) { guid = data.read<std::string>(); } else if (att == ATT_SESSION_ID) { sessionid = data.read<int32_t>(); } else if(att == ATT_ROOTS){ std::vector<RootList::Root> roots; int numRoots = data.read<int32_t>(); for(int i = 0; i < numRoots; i++){ RootList::Root root = RootList::Root(); int rootId = data.read<int32_t>(); int typey = data.read<int32_t>(); if(typey == RootList::Root::kOrtho){ root.mType = RootList::Root::kOrtho; } else if(typey == RootList::Root::kPerspective){ root.mType = RootList::Root::kPerspective; } else { DS_LOG_ERROR("Got an invalid root type! " << typey); continue; } root.mRootId = rootId; roots.push_back(root); } createClientRoots(roots); } } if (guid == mIoInfo.mGlobalId) { mSessionId = sessionid; setState(mBlankState); } } } }
void Resource::Id::setupPaths(const std::string& resource, const std::string& db, const std::string& projectPath) { CMS_RESOURCE_PATH = resource; { Poco::Path p(resource); p.append(db); CMS_DB_PATH = p.toString(); } // Portable path std::string local = ds::Environment::expand("%LOCAL%"); if (boost::starts_with(resource, local)) { CMS_PORTABLE_RESOURCE_PATH = "%LOCAL%" + resource.substr(local.size()); } else { DS_LOG_ERROR("CMS resource path (" << CMS_RESOURCE_PATH << ") does not start with %LOCAL% (" << local << ")"); } // If the project path exists, then setup our app-local resources path. if (!projectPath.empty()) { Poco::Path p(Environment::getDownstreamDocumentsFolder()); p.append("resources"); p.append(projectPath); p.append("app"); APP_RESOURCE_PATH = p.toString(); p.append("db"); p.append("db.sqlite"); APP_DB_PATH = p.toString(); // Make sure we have the trailing separator on the resource path. if (!APP_RESOURCE_PATH.empty() && APP_RESOURCE_PATH.back() != Poco::Path::separator()) { APP_RESOURCE_PATH.append(1, Poco::Path::separator()); } } }
bool DeviceStorageRequestChild:: Recv__delete__(const DeviceStorageResponseValue& aValue) { switch (aValue.type()) { case DeviceStorageResponseValue::TErrorResponse: { DS_LOG_INFO("error %u", mRequest->GetId()); ErrorResponse r = aValue; mRequest->Reject(r.error()); break; } case DeviceStorageResponseValue::TSuccessResponse: { DS_LOG_INFO("success %u", mRequest->GetId()); nsString fullPath; mRequest->GetFile()->GetFullPath(fullPath); mRequest->Resolve(fullPath); break; } case DeviceStorageResponseValue::TFileDescriptorResponse: { DS_LOG_INFO("fd %u", mRequest->GetId()); FileDescriptorResponse r = aValue; DeviceStorageFile* file = mRequest->GetFile(); DeviceStorageFileDescriptor* descriptor = mRequest->GetFileDescriptor(); nsString fullPath; file->GetFullPath(fullPath); descriptor->mDSFile = file; descriptor->mFileDescriptor = r.fileDescriptor(); mRequest->Resolve(fullPath); break; } case DeviceStorageResponseValue::TBlobResponse: { DS_LOG_INFO("blob %u", mRequest->GetId()); BlobResponse r = aValue; BlobChild* actor = static_cast<BlobChild*>(r.blobChild()); RefPtr<BlobImpl> blobImpl = actor->GetBlobImpl(); mRequest->Resolve(blobImpl.get()); break; } case DeviceStorageResponseValue::TFreeSpaceStorageResponse: { DS_LOG_INFO("free %u", mRequest->GetId()); FreeSpaceStorageResponse r = aValue; mRequest->Resolve(r.freeBytes()); break; } case DeviceStorageResponseValue::TUsedSpaceStorageResponse: { DS_LOG_INFO("used %u", mRequest->GetId()); UsedSpaceStorageResponse r = aValue; mRequest->Resolve(r.usedBytes()); break; } case DeviceStorageResponseValue::TAvailableStorageResponse: { DS_LOG_INFO("available %u", mRequest->GetId()); AvailableStorageResponse r = aValue; mRequest->Resolve(r.mountState()); break; } case DeviceStorageResponseValue::TStorageStatusResponse: { DS_LOG_INFO("status %u", mRequest->GetId()); StorageStatusResponse r = aValue; mRequest->Resolve(r.storageStatus()); break; } case DeviceStorageResponseValue::TFormatStorageResponse: { DS_LOG_INFO("format %u", mRequest->GetId()); FormatStorageResponse r = aValue; mRequest->Resolve(r.mountState()); break; } case DeviceStorageResponseValue::TMountStorageResponse: { DS_LOG_INFO("mount %u", mRequest->GetId()); MountStorageResponse r = aValue; mRequest->Resolve(r.storageStatus()); break; } case DeviceStorageResponseValue::TUnmountStorageResponse: { DS_LOG_INFO("unmount %u", mRequest->GetId()); UnmountStorageResponse r = aValue; mRequest->Resolve(r.storageStatus()); break; } case DeviceStorageResponseValue::TEnumerationResponse: { DS_LOG_INFO("enumerate %u", mRequest->GetId()); EnumerationResponse r = aValue; auto request = static_cast<DeviceStorageCursorRequest*>(mRequest.get()); uint32_t count = r.paths().Length(); request->AddFiles(count); for (uint32_t i = 0; i < count; i++) { RefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(r.type(), r.paths()[i].storageName(), r.rootdir(), r.paths()[i].name()); request->AddFile(dsf.forget()); } request->Continue(); break; } default: { DS_LOG_ERROR("unknown %u", mRequest->GetId()); NS_RUNTIMEABORT("not reached"); break; } } return true; }