MCPcopy Create free account
hub / github.com/OSVR/OSVR-Core / m_sendImageDataViaSharedMemory

Method m_sendImageDataViaSharedMemory

src/osvr/Common/ImagingComponent.cpp:249–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247#endif
248
249 bool ImagingComponent::m_sendImageDataViaSharedMemory(
250 OSVR_ImagingMetadata metadata, OSVR_ImageBufferElement *imageData,
251 OSVR_ChannelCount sensor, OSVR_TimeValue const &timestamp) {
252
253 m_growShmVecIfRequired(sensor);
254 uint32_t imageBufferSize = getBufferSize(metadata);
255 if (!m_shmBuf[sensor] ||
256 m_shmBuf[sensor]->getEntrySize() != imageBufferSize) {
257 // create or replace the shared memory ring buffer.
258 auto makeName =
259 [](OSVR_ChannelCount sensor, std::string const &devName) {
260 std::ostringstream os;
261 os << "com.osvr.imaging/" << devName << "/" << int(sensor);
262 return os.str();
263 };
264 m_shmBuf[sensor] = IPCRingBuffer::create(
265 IPCRingBuffer::Options(
266 makeName(sensor, m_getParent().getDeviceName()))
267 .setEntrySize(imageBufferSize));
268 }
269 if (!m_shmBuf[sensor]) {
270 OSVR_DEV_VERBOSE(
271 "Some issue creating shared memory for imaging, skipping out.");
272 return false;
273 }
274 auto &shm = *(m_shmBuf[sensor]);
275 auto seq = shm.put(imageData, imageBufferSize);
276
277 Buffer<> buf;
278 messages::ImagePlacedInSharedMemory::MessageSerialization serialization(
279 messages::SharedMemoryMessage{metadata, seq, sensor,
280 IPCRingBuffer::getABILevel(),
281 shm.getBackend(), shm.getName()});
282 serialize(buf, serialization);
283 m_getParent().packMessage(
284 buf, imagePlacedInSharedMemory.getMessageType(), timestamp);
285
286 return true;
287 }
288
289 bool ImagingComponent::m_sendImageDataOnTheWire(
290 OSVR_ImagingMetadata metadata, OSVR_ImageBufferElement *imageData,

Callers

nothing calls this directly

Calls 10

getBufferSizeFunction · 0.85
serializeFunction · 0.85
strMethod · 0.80
getNameMethod · 0.80
packMessageMethod · 0.80
getMessageTypeMethod · 0.80
OptionsClass · 0.50
getEntrySizeMethod · 0.45
putMethod · 0.45
getBackendMethod · 0.45

Tested by

no test coverage detected