HoviTron Video Pipeline
DynamicInputProvider.h
1/* ----------------------
2* Copyright 2023 Université Libre de Bruxelles(ULB), Universidad Politécnica de Madrid(UPM), CREAL, Deutsches Zentrum für Luft - und Raumfahrt(DLR)
3
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at < http://www.apache.org/licenses/LICENSE-2.0>
7
8* Unless required by applicable law or agreed to in writing, software
9* distributed under the License is distributed on an "AS IS" BASIS,
10* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11* See the License for the specific language governing permissionsand
12* limitations under the License.
13---------------------- */
14
15
16
17#pragma once
18#include <string>
19
20#include "InputProvider.h"
21#include "HvtStreamingAPI.h"
22#include "VulkanWrapper.h"
23
24
26{
27#ifdef WIN32
28 static constexpr auto memory_handle_type = vk::ExternalMemoryHandleTypeFlagBits::eOpaqueWin32;
29 static constexpr auto semaphore_handle_type = vk::ExternalSemaphoreHandleTypeFlagBits::eOpaqueWin32;
30 #else
31 static constexpr auto memory_handle_type = vk::ExternalMemoryHandleTypeFlagBits::eOpaqueFd;
32 static constexpr auto semaphore_handle_type = vk::ExternalSemaphoreHandleTypeFlagBits::eOpaqueFd;
33#endif
34 static constexpr auto inFlightSync = 3;
35 public:
36 DynamicInputProvider(const std::string& libraryPath, VulkanWrapper& vkw);
37
38 std::vector<StreamParameters> enumerateStreamsParameters() const override;
39 std::vector<StreamImage> enumerateStreamImages(uint32_t streamIndex, bool depth) const override;
40 void acquireStreamsFrames(const Extrinsics& targetViewExtrinsics, std::span<StreamFrameInfo> outFrameInfos) override;
41 void releaseStreamsFrames() override;
42
44 private:
45
46 void loadLibrary(const std::string& libraryPath);
47 void init();
48 void initStreams();
49 void initSynchronisation();
50
54 struct Library{
55 PFN_hvtCreateStreamingContext createStreamingContext;
56 PFN_hvtEnumerateStreamsParameters enumerateStreamsParameters;
57 PFN_hvtExportStreamImages exportStreamImages;
58 PFN_hvtExportSemaphore exportSemaphore;
59 PFN_hvtAcquireStreamsFrames acquireStreamsFrames;
60 PFN_hvtReleaseStreamsFrames releaseStreamsFrames;
61 PFN_hvtStartStreaming startStreaming;
62 PFN_hvtStopStreaming stopStreaming;
63 PFN_hvtDestroySemaphore destroySemaphore;
64 PFN_hvtDestroyStreamingContext destroyStreamingContext;
65 };
66
70 struct ImageSlot{
71 vk::UniqueImage image;
72 vk::UniqueDeviceMemory memory;
73 vk::MemoryRequirements memoryRequirements;
74 vk::UniqueImageView imageView;
75 };
76
77 struct Stream{
78 std::vector<ImageSlot> colorSlots;
79 std::vector<ImageSlot> depthSlots;
80 std::vector<StreamImage> colorImages;
81 std::vector<StreamImage> depthImages;
82 vk::UniqueSamplerYcbcrConversion ycbcrConversion;
83 vk::UniqueSampler colorSampler;
84 vk::UniqueSampler depthSampler;
85 };
86
87 struct SyncInfo{
88 vk::UniqueSemaphore acquireSemaphore;
89 vk::UniqueSemaphore releaseSempahore;
90 HvtSemaphore acquireHvt;
91 HvtSemaphore releaseHvt;
92 };
93
94 std::array<SyncInfo, inFlightSync> syncInfos;
95 int currentSyncSlot = 0;
96
97 VulkanWrapper& vkw;
98 vk::UniqueCommandPool commandPool;
99 HvtStreamingContext context;
100 std::vector<Stream> streamStorage;
101 std::vector<StreamParameters> cachedStreamParameters;
102 Library hvt;
103};
file that contains the VulkanWrapper class that manages the classes related to Vulkan code and ease t...
Abstract interface around getting source views parameters and data.
Definition: InputProvider.h:35
Class that manages the classes related to Vulkan code and act as a wrapper around them.
Definition: VulkanWrapper.h:66