CVB++ 15.1
Loading...
Searching...
No Matches
detail_gendc_descriptor.hpp
1#pragma once
2
3#include "../_decl/decl_gendc_descriptor.hpp"
4#include "../../_cexports/c_driver.h"
5
6#include "../../global.hpp"
7#include "../../composite.hpp"
8#include "../../utilities/system_info.hpp"
9
10#include <numeric>
11
12namespace Cvb
13{
14
15 CVB_BEGIN_INLINE_NS
16
17 namespace Driver
18 {
19 namespace Detail
20 {
21 template <typename T>
22 T GetPartInfo(void *handle, CExports::CVDGNDCPartInfoCmd cmd, std::size_t componentIdx, std::size_t partIdx)
23 {
24 return Internal::DoResCallValueOut<T>([&](T &value) {
25 size_t valueSize = sizeof(T);
26 return CVB_CALL_CAPI(CVDGNDCGetPartInfo(handle, cmd, valueSize, &value, componentIdx, partIdx));
27 });
28 }
29
30 template <typename T>
31 void SetPartInfo(void *handle, CExports::CVDGNDCPartInfoCmd cmd, std::size_t componentIdx, std::size_t partIdx,
32 const T &value)
33 {
34 return Internal::DoResCall([&]() {
35 size_t valueSize = sizeof(T);
36 return CVB_CALL_CAPI(CVDGNDCSetPartInfo(handle, cmd, valueSize, &value, componentIdx, partIdx));
37 });
38 }
39
40 template <typename T>
41 T GetComponentInfo(void *handle, CExports::CVDGNDCComponentInfoCmd cmd, std::size_t componentIdx)
42 {
43 return Internal::DoResCallValueOut<T>([&](T &value) {
44 size_t valueSize = sizeof(T);
45 return CVB_CALL_CAPI(CVDGNDCGetComponentInfo(handle, cmd, valueSize, &value, componentIdx));
46 });
47 }
48
49 template <typename T>
50 void SetComponentInfo(void *handle, CExports::CVDGNDCComponentInfoCmd cmd, std::size_t componentIdx,
51 const T &value)
52 {
53 return Internal::DoResCall([&]() {
54 size_t valueSize = sizeof(T);
55 return CVB_CALL_CAPI(CVDGNDCSetComponentInfo(handle, cmd, valueSize, &value, componentIdx));
56 });
57 }
58
59 template <typename T>
60 T GetHeaderInfo(void *handle, CExports::CVDGNDCHeaderInfoCmd cmd)
61 {
62 return Internal::DoResCallValueOut<T>([&](T &value) {
63 size_t valueSize = sizeof(T);
64 return CVB_CALL_CAPI(CVDGNDCGetHeaderInfo(handle, cmd, valueSize, &value));
65 });
66 }
67
68 template <typename T>
69 void SetHeaderInfo(void *handle, CExports::CVDGNDCHeaderInfoCmd cmd, T &value)
70 {
71 return Internal::DoResCall([&]() {
72 size_t valueSize = sizeof(T);
73 return CVB_CALL_CAPI(CVDGNDCSetHeaderInfo(handle, cmd, valueSize, &value));
74 });
75 }
76 } // namespace Detail
77
78 inline GenDcDescriptorPartConfig::GenDcDescriptorPartConfig(GenDCPartType partType, Cvb::PfncFormat pfncFormat,
79 std::uint16_t flowId, std::uint64_t flowOffset,
80 std::uint64_t dataSize)
81 : PartType{partType}
82 , Format{pfncFormat}
83 , FlowId{flowId}
84 , FlowOffset{flowOffset}
85 , DataSize{dataSize}
86 {
87 }
88
89 inline GenDcDescriptorMetadataPartConfig::GenDcDescriptorMetadataPartConfig(GenDCPartType partType,
90 std::uint16_t flowId,
91 std::uint64_t flowOffset,
92 std::uint64_t dataSize)
93 : GenDcDescriptorPartConfig{partType, PfncFormat::Data8, flowId, flowOffset, dataSize}
94 {
95 if ((static_cast<std::underlying_type_t<GenDCPartType>>(partType)
96 & static_cast<std::underlying_type_t<GenDCPartType>>(GenDCPartType::_TypeGenericPartMetadata))
97 == 0)
98 throw std::runtime_error("GenDcDescriptorMetadataPart must contain a metadata part type");
99 }
100
101 inline GenDcDescriptorMetadataComponentConfig::GenDcDescriptorMetadataComponentConfig(
103 : GenDcDescriptorComponentConfig{ComponentId::Metadata, PfncFormat::Data8}
104 {
105 std::transform(parts.begin(), parts.end(), std::back_inserter(Parts),
106 [](const auto &part) { return static_cast<GenDcDescriptorPartConfig>(part); });
107 }
108
109 inline GenDcPart::GenDcPart(void *handle, size_t componentIdx, size_t partIdx)
110 : handle_{handle}
111 , componentIdx_{componentIdx}
112 , partIdx_{partIdx}
113 {
114 }
115
117 {
118 return Detail::GetPartInfo<std::uint64_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_PartOffset,
119 componentIdx_, partIdx_);
120 }
121
123 {
124 return Detail::GetPartInfo<GenDCPartType>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_HeaderType,
125 componentIdx_, partIdx_);
126 }
127
129 {
130 return Detail::GetPartInfo<GenDcPartFlags>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_FlagsValue,
131 componentIdx_, partIdx_);
132 }
133
135 {
136 return Detail::GetPartInfo<std::uint32_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_HeaderSize,
137 componentIdx_, partIdx_);
138 }
139
141 {
142 return Detail::GetPartInfo<PfncFormat>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_Format, componentIdx_,
143 partIdx_);
144 }
145
147 {
148 return Detail::GetPartInfo<std::uint16_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_FlowId, componentIdx_,
149 partIdx_);
150 }
151
153 {
154 return Detail::GetPartInfo<std::size_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_FlowOffset,
155 componentIdx_, partIdx_);
156 }
157
159 {
160 return Detail::GetPartInfo<std::size_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_DataOffset,
161 componentIdx_, partIdx_);
162 }
163
165 {
166 return Detail::GetPartInfo<std::size_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_DataSize, componentIdx_,
167 partIdx_);
168 }
169
171 {
172 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_FlagsValue, componentIdx_, partIdx_, flags);
173 }
174
176 {
177 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_DataOffset, componentIdx_, partIdx_, offset);
178 }
179
181 {
182 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_DataSize, componentIdx_, partIdx_, size);
183 }
184
186 {
187 return Detail::GetPartInfo<std::uint64_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC1DPI_Size, componentIdx_,
188 partIdx_);
189 }
190
192 {
193 return Detail::GetPartInfo<std::uint16_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC1DPI_Padding,
194 componentIdx_, partIdx_);
195 }
196
198 {
199 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC1DPI_Size, componentIdx_, partIdx_, size);
200 }
201
203 {
204 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC1DPI_Padding, componentIdx_, partIdx_, padding);
205 }
206
207 inline GenDcPartMetadata::GenDcPartMetadata(void *handle, size_t componentIdx, size_t partIdx)
208 : GenDcPart{handle, componentIdx, partIdx}
209 {
210 }
211
213 {
214 return Detail::GetPartInfo<std::uint64_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNCDC1DPI_InfoTypeSpecific,
215 componentIdx_,
216 partIdx_);
217 }
218
220 {
221 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNCDC1DPI_InfoTypeSpecific, componentIdx_, partIdx_,
222 id);
223 }
224
225 inline GenDcPartMetadataGenICamChunk::GenDcPartMetadataGenICamChunk(void *handle, size_t componentIdx,
226 size_t partIdx)
227 : GenDcPartMetadata{handle, componentIdx, partIdx}
228 {
229 }
230
232 {
233 return Detail::GetPartInfo<std::uint64_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNCDC1DPI_InfoTypeSpecific,
234 componentIdx_,
235 partIdx_);
236 }
237
239 {
240 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNCDC1DPI_InfoTypeSpecific, componentIdx_, partIdx_,
241 id);
242 }
243
244 inline GenDcPartMetadataGenICamXML::GenDcPartMetadataGenICamXML(void *handle, size_t componentIdx, size_t partIdx)
245 : GenDcPartMetadata{handle, componentIdx, partIdx}
246 {
247 }
248
250 {
251 return Detail::GetPartInfo<std::uint64_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC1DPI_Size, componentIdx_,
252 partIdx_);
253 }
254
256 {
257 return Detail::GetPartInfo<std::uint16_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC1DPI_Padding,
258 componentIdx_, partIdx_);
259 }
260
262 {
263 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC1DPI_Size, componentIdx_, partIdx_, size);
264 }
265
267 {
268 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC1DPI_Padding, componentIdx_, partIdx_, padding);
269 }
270
271 inline GenDcPart1D::GenDcPart1D(void *handle, size_t componentIdx, size_t partIdx)
272 : GenDcPart{handle, componentIdx, partIdx}
273 {
274 }
275
277 {
278 return Detail::GetPartInfo<std::uint32_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC2DPI_SizeX, componentIdx_,
279 partIdx_);
280 }
281
283 {
284 return Detail::GetPartInfo<std::uint32_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC2DPI_SizeY, componentIdx_,
285 partIdx_);
286 }
287
289 {
290 return Detail::GetPartInfo<std::uint16_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC2DPI_PaddingX,
291 componentIdx_, partIdx_);
292 }
293
295 {
296 return Detail::GetPartInfo<std::uint16_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC2DPI_PaddingY,
297 componentIdx_, partIdx_);
298 }
299
301 {
302 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC2DPI_SizeX, componentIdx_, partIdx_, size);
303 }
304
306 {
307 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC2DPI_SizeY, componentIdx_, partIdx_, size);
308 }
309
311 {
312 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC2DPI_PaddingX, componentIdx_, partIdx_,
313 padding);
314 }
315
317 {
318 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDC2DPI_PaddingY, componentIdx_, partIdx_,
319 padding);
320 }
321
322 inline GenDcPart2D::GenDcPart2D(void *handle, size_t componentIdx, size_t partIdx)
323 : GenDcPart{handle, componentIdx, partIdx}
324 {
325 }
326
328 {
329 return Detail::GetPartInfo<std::uint32_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_SizeX,
330 componentIdx_, partIdx_);
331 }
332
334 {
335 return Detail::GetPartInfo<std::uint32_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_SizeY,
336 componentIdx_, partIdx_);
337 }
338
340 {
341 return Detail::GetPartInfo<std::uint16_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_PaddingX,
342 componentIdx_, partIdx_);
343 }
344
346 {
347 return Detail::GetPartInfo<std::uint16_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_PaddingY,
348 componentIdx_, partIdx_);
349 }
350
352 {
353 return Detail::GetPartInfo<std::uint8_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_ProfileIDC,
354 componentIdx_, partIdx_);
355 }
356
358 {
359 return Detail::GetPartInfo<H264Flags>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_H264Flags,
360 componentIdx_, partIdx_);
361 }
362
364 {
365 return Detail::GetPartInfo<std::uint8_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_LevelIDC,
366 componentIdx_, partIdx_);
367 }
368
370 {
371 return Detail::GetPartInfo<std::uint16_t>(
372 handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_SpropInterleavingDepth, componentIdx_,
373 partIdx_);
374 }
376 {
377 return Detail::GetPartInfo<std::uint16_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_SpropMaxDonDiff,
378 componentIdx_,
379 partIdx_);
380 }
381
383 {
384 return Detail::GetPartInfo<std::uint32_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_SpropDeintBufReq,
385 componentIdx_,
386 partIdx_);
387 }
388
390 {
391 return Detail::GetPartInfo<std::uint32_t>(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_SpropInitBufTime,
392 componentIdx_,
393 partIdx_);
394 }
395
397 {
398 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_SizeX, componentIdx_, partIdx_, size);
399 }
400
402 {
403 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_SizeY, componentIdx_, partIdx_, size);
404 }
405
407 {
408 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_PaddingX, componentIdx_, partIdx_,
409 padding);
410 }
411
413 {
414 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_PaddingY, componentIdx_, partIdx_,
415 padding);
416 }
417
419 {
420 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_ProfileIDC, componentIdx_, partIdx_,
421 profile);
422 }
423
425 {
426 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_H264Flags, componentIdx_, partIdx_,
427 flags);
428 }
429
431 {
432 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_LevelIDC, componentIdx_, partIdx_,
433 level);
434 }
435
437 {
438 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_SpropInterleavingDepth, componentIdx_,
439 partIdx_, depth);
440 }
441
443 {
444 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_SpropMaxDonDiff, componentIdx_, partIdx_,
445 diff);
446 }
447
449 {
450 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_SpropDeintBufReq, componentIdx_,
451 partIdx_, req);
452 }
453
455 {
456 Detail::SetPartInfo(handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCH264PI_SpropInitBufTime, componentIdx_,
457 partIdx_, time);
458 }
459
460 inline GenDcPartH264::GenDcPartH264(void *handle, size_t componentIdx, size_t partIdx)
461 : GenDcPart2D{handle, componentIdx, partIdx}
462 {
463 }
464
465 inline GenDcComponent::GenDcComponent(void *handle, size_t componentIdx)
466 : handle_{handle}
467 , componentIdx_{componentIdx}
468 {
469 const auto partCount = Detail::GetComponentInfo<std::uint16_t>(
470 handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_PartCount, componentIdx_);
471 for (std::size_t idx = 0; idx < partCount; ++idx)
472 {
473 const auto type = Detail::GetPartInfo<GenDCPartType>(
474 handle_, CExports::CVDGNDCPartInfoCmd::CVDGNDCPI_HeaderType, componentIdx_, idx);
475 switch (type)
476 {
478 parts_.push_back(GenDcPartMetadataGenICamChunk{handle_, componentIdx_, idx});
479 break;
481 parts_.push_back(GenDcPartMetadataGenICamXML{handle_, componentIdx_, idx});
482 break;
483 case GenDCPartType::Type1D:
484 parts_.push_back(GenDcPart1D{handle_, componentIdx_, idx});
485 break;
487 // fallthrough
489 // fallthrough
491 parts_.push_back(GenDcPart2D{handle_, componentIdx_, idx});
492 break;
494 parts_.push_back(GenDcPartH264{handle_, componentIdx_, idx});
495 break;
496 default:
497 parts_.push_back(GenDcPart{handle_, componentIdx_, idx});
498 break;
499 }
500 }
501 }
502
504 {
505 return Detail::GetComponentInfo<std::uint64_t>(
506 handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_ComponentOffset, componentIdx_);
507 }
508
510 {
511 return Detail::GetComponentInfo<GenDcComponentFlags>(
512 handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_FlagsValue, componentIdx_);
513 }
514
516 {
517 return Detail::GetComponentInfo<std::uint32_t>(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_HeaderSize,
518 componentIdx_);
519 }
520
522 {
523 return Detail::GetComponentInfo<std::uint16_t>(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_GroupId,
524 componentIdx_);
525 }
526
528 {
529 return Detail::GetComponentInfo<std::uint16_t>(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_SourceId,
530 componentIdx_);
531 }
532
534 {
535 return Detail::GetComponentInfo<std::uint16_t>(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_RegionId,
536 componentIdx_);
537 }
538
540 {
541 return Detail::GetComponentInfo<std::uint32_t>(
542 handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_RegionOffsetX, componentIdx_);
543 }
544
546 {
547 return Detail::GetComponentInfo<std::uint32_t>(
548 handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_RegionOffsetY, componentIdx_);
549 }
550
552 {
553 return Detail::GetComponentInfo<std::uint64_t>(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_Timestamp,
554 componentIdx_);
555 }
556
558 {
559 return static_cast<ComponentId>(Detail::GetComponentInfo<std::uint64_t>(
560 handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_TypeId, componentIdx_));
561 }
562
564 {
565 return Detail::GetComponentInfo<PfncFormat>(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_Format,
566 componentIdx_);
567 }
568
570 {
571 return parts_;
572 }
573
575 {
576 return parts_;
577 }
578
580 {
581 return Detail::SetComponentInfo(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_FlagsValue, componentIdx_,
582 flags);
583 }
584
586 {
587 return Detail::SetComponentInfo(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_GroupId, componentIdx_,
588 id);
589 }
590
592 {
593 return Detail::SetComponentInfo(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_SourceId, componentIdx_,
594 id);
595 }
596
598 {
599 return Detail::SetComponentInfo(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_RegionId, componentIdx_,
600 id);
601 }
602
604 {
605 return Detail::SetComponentInfo(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_RegionOffsetX,
606 componentIdx_, offset);
607 }
608
610 {
611 return Detail::SetComponentInfo(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_RegionOffsetY,
612 componentIdx_, offset);
613 }
614
616 {
617 return Detail::SetComponentInfo(handle_, CExports::CVDGNDCComponentInfoCmd::CVDGNDCCMPI_Timestamp, componentIdx_,
618 timestamp);
619 }
620
621 inline GenDcDescriptor::GenDcDescriptor(HandleGuard<GenDcDescriptor> &&guard)
622 : handle_(std::move(guard))
623 , components_{}
624 {
625 const auto componentCount =
626 Detail::GetHeaderInfo<std::uint32_t>(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_ComponentCount);
627 for (std::size_t idx = 0; idx < componentCount; ++idx)
628 components_.push_back(GenDcComponent{Handle(), idx});
629 }
630
631 inline std::unique_ptr<GenDcDescriptor> GenDcDescriptor::FromHandle(HandleGuard<GenDcDescriptor> &&guard)
632 {
633 if (!guard.Handle())
634 throw std::runtime_error("handle must not be null");
635
636 return std::unique_ptr<GenDcDescriptor>{new GenDcDescriptor{std::move(guard)}};
637 }
638
640 {
641 return {Detail::GetHeaderInfo<std::uint8_t>(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_VersionMajor),
642 Detail::GetHeaderInfo<std::uint8_t>(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_VersionMinor),
643 Detail::GetHeaderInfo<std::uint8_t>(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_VersionSubMinor)};
644 }
645
647 {
648 return Detail::GetHeaderInfo<GenDcDescriptorFlag>(Handle(),
649 CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_FlagsValue);
650 }
651
653 {
654 return Detail::GetHeaderInfo<std::uint32_t>(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_HeaderSize);
655 }
656
658 {
659 return Detail::GetHeaderInfo<std::uint64_t>(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_ContainerId);
660 }
661
663 {
664 return Detail::GetHeaderInfo<GenDcDescriptorVariableField>(
665 Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_VariableFields);
666 }
667
669 {
670 return Detail::GetHeaderInfo<std::uint64_t>(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_DataSize);
671 }
672
674 {
675 return Detail::GetHeaderInfo<std::int64_t>(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_DataOffset);
676 }
677
679 {
680 return Detail::GetHeaderInfo<std::uint32_t>(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_DescriptorSize);
681 }
682
684 {
685 return components_;
686 }
687
689 {
690 return components_;
691 }
692
694 {
695 if (GetComponents().size() == 0)
696 return 0;
697
698 size_t maxFlowIdx = 0;
699 for (const auto &component : GetComponents())
700 {
701 for (const auto &part : component.GetParts())
702 {
703 auto flowIdx = visit([](const GenDcPart &part) -> size_t { return part.GetFlowId(); }, part);
704
705 maxFlowIdx = std::max(maxFlowIdx, flowIdx);
706 }
707 }
708 return maxFlowIdx+1;
709 }
710
712 {
713 std::vector<std::size_t> flowSizes{};
714 flowSizes.resize(CalculateDataFlowCount(), 0);
715 for (const auto &component : GetComponents())
716 {
717 for (const auto &part : component.GetParts())
718 {
719 std::size_t flowIdx = 0;
720 std::size_t dataSize = 0;
721 std::tie(flowIdx, dataSize) = visit(
722 [](const GenDcPart &part) -> std::tuple<std::size_t, size_t> {
723 return std::make_tuple(part.GetFlowId(), part.GetDataSize());
724 },
725 part);
726
727 flowSizes[flowIdx] += dataSize;
728 }
729 }
730
731 return flowSizes;
732 }
733
735 {
736 Detail::SetHeaderInfo(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_FlagsValue, flags);
737 }
738
740 {
741 Detail::SetHeaderInfo(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_ContainerId, id);
742 }
743
745 {
746 Detail::SetHeaderInfo(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_VariableFields, fields);
747 }
748
750 {
751 Detail::SetHeaderInfo(Handle(), CExports::CVDGNDCHeaderInfoCmd::CVDGNDCCNTI_DataSize, size);
752 }
753
754 inline void *GenDcDescriptor::Handle() const noexcept
755 {
756 return handle_.Handle();
757 }
758
760 {
761 return Internal::DoResCallValueOut<std::size_t>(
762 [&](std::size_t &value) { return CVB_CALL_CAPI(CVDGNDCSerialize(Handle(), value, nullptr)); });
763 }
764
765 inline void GenDcDescriptor::Serialize(std::uint8_t *buffer, std::size_t size) const
766 {
767 return Internal::DoResCall([&]() { return CVB_CALL_CAPI(CVDGNDCSerialize(Handle(), size, buffer)); });
768 }
769
771 {
772 const std::size_t serializedSize = GetSerializedSize();
773 std::vector<std::uint8_t> buffer(serializedSize);
774 Serialize(buffer.data(), buffer.size());
775 return buffer;
776 }
777
779 {
780 if (descriptorConfig.Components.size() > std::numeric_limits<CExports::cvbuint32_t>::max())
781 throw std::invalid_argument("Descriptor has more components than allowed in a GenDC container");
782
783 const auto partCount =
784 std::accumulate(descriptorConfig.Components.begin(), descriptorConfig.Components.end(), size_t{0},
785 [](size_t count, const auto &component) { return count + component.Parts.size(); });
787 parts.reserve(partCount);
789 for (const auto &component : descriptorConfig.Components)
790 {
791 if (component.Parts.size() > std::numeric_limits<CExports::cvbuint16_t>::max())
792 throw std::invalid_argument("Component has more parts than allowed in a GenDC container");
793
794 size_t startOffset = parts.size();
795 for (const auto &part : component.Parts)
796 {
797 parts.push_back(CExports::CVDGenDCPartConfig{
798 static_cast<CExports::cvbuint16_t>(part.PartType),
799 static_cast<CExports::cvbuint32_t>(part.Format),
800 part.FlowId,
801 part.FlowOffset,
802 part.DataSize,
803 });
804 }
805 components.push_back(CExports::CVDGenDCComponentConfig{
806 static_cast<CExports::cvbuint32_t>(component.TypeId), static_cast<CExports::cvbuint32_t>(component.Format),
807 static_cast<CExports::cvbuint16_t>(component.Parts.size()), parts.data() + startOffset});
808 }
809
810 CExports::CVDGenDCDescriptorConfig config{static_cast<CExports::cvbuint32_t>(components.size()),
811 components.data()};
812
813 return Internal::DoResCallObjectOut<GenDcDescriptor>(
814 [&](void *&handle) { return CVB_CALL_CAPI(CVDGNDCCreateDescriptor(config, handle)); });
815 }
816
817 } // namespace Driver
818
819
821 {
822 if (!CExports::CVDCanGenDCDescriptorProvider(Handle()))
823 throw std::runtime_error("Composite does not represent a GenDC container");
824
825 return Internal::DoResCallObjectOut<Driver::GenDcDescriptor>(
826 [this](CExports::CVDGNDCDESCRIPTOR &handle) { return CVB_CALL_CAPI(CVDGNDCPGetDescriptor(Handle(), handle)); });
827 }
828
829 CVB_END_INLINE_NS
830
831} // namespace Cvb
T accumulate(T... args)
T back_inserter(T... args)
void * Handle() const noexcept
Classic API node handle.
Definition decl_composite.hpp:95
std::unique_ptr< Driver::GenDcDescriptor > GenDCFinalDescriptor() const
If this Composite represents a GenDC container, returns the GenDC final descriptor.
Definition detail_gendc_descriptor.hpp:820
Class for a GenDC component descriptor.
Definition decl_gendc_descriptor.hpp:541
std::uint64_t GetTimestamp() const
Return the timestamp of this GenDC component's generation.
Definition detail_gendc_descriptor.hpp:551
std::uint32_t GetHeaderSize() const
Return the size of this GenDC component descriptor.
Definition detail_gendc_descriptor.hpp:515
void SetTimestamp(std::uint64_t timestamp)
Set the timestamp of this GenDC component's generation.
Definition detail_gendc_descriptor.hpp:615
std::uint16_t GetRegionId() const
Return the Source ID of this GenDC component.
Definition detail_gendc_descriptor.hpp:533
ComponentId GetTypeId() const
Return the type identifier of this GenDC component.
Definition detail_gendc_descriptor.hpp:557
const std::vector< GenDCPartVariant > & GetParts() const
Return the part descriptors of this GenDC component.
Definition detail_gendc_descriptor.hpp:569
std::uint32_t GetRegionOffsetX() const
Return the X Offset of this GenDC component's region.
Definition detail_gendc_descriptor.hpp:539
std::size_t GetOffset() const
Return the offset of this component descriptor in the GenDC descriptor.
Definition detail_gendc_descriptor.hpp:503
PfncFormat GetFormat() const
Return the format of the whole GenDC component (including all its parts).
Definition detail_gendc_descriptor.hpp:563
void SetSourceId(std::uint16_t id)
Set the Source ID of this GenDC component.
Definition detail_gendc_descriptor.hpp:591
void SetFlags(GenDcComponentFlags flags)
Set the flags of this GenDC component.
Definition detail_gendc_descriptor.hpp:579
std::uint16_t GetGroupId() const
Return the Group ID of this GenDC component.
Definition detail_gendc_descriptor.hpp:521
GenDcComponentFlags GetFlags() const
Return the flags of this GenDC component.
Definition detail_gendc_descriptor.hpp:509
std::uint32_t GetRegionOffsetY() const
Return the Y Offset of this GenDC component's region.
Definition detail_gendc_descriptor.hpp:545
std::uint16_t GetSourceId() const
Return the Source ID of this GenDC component.
Definition detail_gendc_descriptor.hpp:527
void SetRegionOffsetX(std::uint32_t offset)
Set the X Offset of this GenDC component's region.
Definition detail_gendc_descriptor.hpp:603
void SetRegionId(std::uint16_t id)
Set the Source ID of this GenDC component.
Definition detail_gendc_descriptor.hpp:597
void SetRegionOffsetY(std::uint32_t offset)
Set the Y Offset of this GenDC component's region.
Definition detail_gendc_descriptor.hpp:609
void SetGroupId(std::uint16_t id)
Set the Group ID of this GenDC component.
Definition detail_gendc_descriptor.hpp:585
std::uint32_t GetHeaderSize() const
Return the size of this GenDC container descriptor.
Definition detail_gendc_descriptor.hpp:652
std::size_t GetSerializedSize() const
Get the size in bytes of this GenDC descriptor when serialized.
Definition detail_gendc_descriptor.hpp:759
const std::vector< GenDcComponent > & GetComponents() const
Return the component descriptors of this GenDC container.
Definition detail_gendc_descriptor.hpp:683
GenDcDescriptorFlag GetFlags() const
Return the flags of this GenDC container.
Definition detail_gendc_descriptor.hpp:646
void SetVariableFields(GenDcDescriptorVariableField fields)
Set the flags identifying the variable fields of this GenDC container.
Definition detail_gendc_descriptor.hpp:744
void SetContainerId(std::uint64_t id)
Set the identifier of GenDC container.
Definition detail_gendc_descriptor.hpp:739
std::vector< std::uint8_t > Serialize() const
Serialize this GenDC descriptor into a new buffer.
Definition detail_gendc_descriptor.hpp:770
std::uint64_t GetDataSize() const
Return the size of the GenDC data.
Definition detail_gendc_descriptor.hpp:668
std::uint64_t GetContainerId() const
Return the identifier of GenDC container.
Definition detail_gendc_descriptor.hpp:657
size_t CalculateDataFlowCount() const
Return the number of data flows that are configured in the GenDC container.
Definition detail_gendc_descriptor.hpp:693
void SetFlags(GenDcDescriptorFlag flags)
Set the flags of this GenDC container.
Definition detail_gendc_descriptor.hpp:734
void SetDataSize(std::uint32_t size)
Set the size of the GenDC data.
Definition detail_gendc_descriptor.hpp:749
GenDcDescriptorVariableField GetVariableFields() const
Return the flags identifying the variable fields of this GenDC container.
Definition detail_gendc_descriptor.hpp:662
std::vector< size_t > CalculateDataFlowSizes() const
Return the sizes of data flows that the GenDC container requires.
Definition detail_gendc_descriptor.hpp:711
std::int64_t GetDataOffset() const
Return the offset of the GenDC data.
Definition detail_gendc_descriptor.hpp:673
static std::unique_ptr< GenDcDescriptor > FromHandle(HandleGuard< GenDcDescriptor > &&guard)
Creates a GenDC descriptor from a classic API handle.
Definition detail_gendc_descriptor.hpp:631
std::uint32_t GetDescriptorSize() const
Return the size of the GenDC container descriptor.
Definition detail_gendc_descriptor.hpp:678
void * Handle() const noexcept
Return the Handle to the internal resource.
Definition detail_gendc_descriptor.hpp:754
Version GetVersion() const
Return the GenDC descriptor standards version.
Definition detail_gendc_descriptor.hpp:639
static std::unique_ptr< GenDcDescriptor > Create(const GenDcDescriptorConfig &descriptorConfig)
Create a GenDC descriptor.
Definition detail_gendc_descriptor.hpp:778
void SetPadding(std::uint16_t padding)
Set the padding of this GenDC 1D part.
Definition detail_gendc_descriptor.hpp:266
std::uint16_t GetPadding() const
Return the padding of this GenDC 1D part.
Definition detail_gendc_descriptor.hpp:255
void SetSize(std::uint64_t size)
Set the size of the GenDC 1D part.
Definition detail_gendc_descriptor.hpp:261
std::uint64_t GetSize() const
Return the size of the GenDC 1D part.
Definition detail_gendc_descriptor.hpp:249
Class for a GenDC 2D part descriptor.
Definition decl_gendc_descriptor.hpp:299
virtual void SetSizeY(std::uint32_t size)
Set the Y size of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:305
virtual std::uint32_t GetSizeY() const
Return the Y size of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:282
virtual std::uint16_t GetPaddingY() const
Return the Y padding of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:294
virtual void SetPaddingX(std::uint16_t padding)
Set the X padding of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:310
virtual void SetSizeX(std::uint32_t size)
Set the X size of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:300
virtual std::uint16_t GetPaddingX() const
Return the X padding of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:288
virtual std::uint32_t GetSizeX() const
Return the X size of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:276
virtual void SetPaddingY(std::uint16_t padding)
Set the Y padding of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:316
std::uint8_t GetLevelIDC() const
Return the level_idc sequence parameter of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:363
void SetSpropMaxDonDiff(std::uint16_t diff)
Set the sprop-max-don-diff of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:442
std::uint16_t GetPaddingY() const override
Return the Y padding of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:345
void SetSizeY(std::uint32_t size) override
Set the Y size of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:401
std::uint32_t GetSizeY() const override
Return the Y size of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:333
std::uint16_t GetSpropMaxDonDiff() const
Return the sprop-max-don-diff of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:375
void SetPaddingX(std::uint16_t padding) override
Set the X padding of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:406
std::uint16_t GetSpropInterleavingDepth() const
Return the sprop-interleaving-depth of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:369
void SetSpropInitBufTime(std::uint32_t time)
Set the sprop-init-buf-time of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:454
std::uint8_t GetProfileIDC() const
Return the profile_idc of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:351
void SetSizeX(std::uint32_t size) override
Set the X size of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:396
void SetH264Flags(H264Flags flags)
Set the Flags of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:424
void SetProfileIDC(std::uint8_t profile)
Set the profile_idc of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:418
void SetSpropInterleavingDepth(std::uint16_t depth)
Set the sprop-interleaving-depth of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:436
void SetLevelIDC(std::uint8_t level)
Set the level_idc sequence parameter of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:430
std::uint32_t GetSizeX() const override
Return the X size of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:327
std::uint16_t GetPaddingX() const override
Return the X padding of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:339
void SetSpropDeintBufReq(std::uint32_t req)
Set the sprop-deint-buf-req of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:448
std::uint32_t GetSpropDeintBufReq() const
Return the sprop-deint-buf-req of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:382
void SetPaddingY(std::uint16_t padding) override
Set the Y padding of the GenDC 2D part.
Definition detail_gendc_descriptor.hpp:412
H264Flags GetH264Flags() const
Return the Flags of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:357
std::uint32_t GetSpropInitBufTime() const
Return the sprop-init-buf-time of the GenDC H.264 part.
Definition detail_gendc_descriptor.hpp:389
Class for a generic GenDC part descriptor.
Definition decl_gendc_descriptor.hpp:72
void SetDataOffset(std::size_t offset)
Set the Data offset of this GenDC part.
Definition detail_gendc_descriptor.hpp:175
std::uint32_t GetHeaderSize() const
Return the size of this GenDC part descriptor.
Definition detail_gendc_descriptor.hpp:134
void SetFlags(GenDcPartFlags flags)
Set the flags of this GenDC part.
Definition detail_gendc_descriptor.hpp:170
std::size_t GetDataOffset() const
Return the Data offset of this GenDC part.
Definition detail_gendc_descriptor.hpp:158
std::uint16_t GetFlowId() const
Return the Flow ID of this GenDC part.
Definition detail_gendc_descriptor.hpp:146
std::size_t GetOffset() const
Return the offset of this part descriptor in the GenDC descriptor.
Definition detail_gendc_descriptor.hpp:116
PfncFormat GetFormat() const
Return the data format of this GenDC part.
Definition detail_gendc_descriptor.hpp:140
GenDCPartType GetType() const
Return the type of this GenDC part descriptor.
Definition detail_gendc_descriptor.hpp:122
std::size_t GetDataSize() const
Return the Data size of this GenDC part.
Definition detail_gendc_descriptor.hpp:164
GenDcPartFlags GetFlags() const
Return the flags of this GenDC part.
Definition detail_gendc_descriptor.hpp:128
void SetDataSize(std::size_t size)
Set the Data size of this GenDC part.
Definition detail_gendc_descriptor.hpp:180
std::size_t GetFlowOffset() const
Return the Flow offset of this GenDC part.
Definition detail_gendc_descriptor.hpp:152
std::uint64_t GetGenICamLayoutId() const
Return the Layout ID of this GenDC metadata chunk part.
Definition detail_gendc_descriptor.hpp:212
void SetGenICamLayoutId(std::uint64_t id)
Set the Layout ID of this GenDC metadata chunk part.
Definition detail_gendc_descriptor.hpp:219
std::uint64_t GetGenICamLayoutId() const
Return the Layout ID of this GenDC metadata XML part.
Definition detail_gendc_descriptor.hpp:231
void SetGenICamLayoutId(std::uint64_t id)
Set the Layout ID of this GenDC metadata XML part.
Definition detail_gendc_descriptor.hpp:238
Class for a generic GenDC metadata part descriptor.
Definition decl_gendc_descriptor.hpp:171
void SetPadding(std::uint16_t padding)
Set the padding of this GenDC metadata part.
Definition detail_gendc_descriptor.hpp:202
std::uint16_t GetPadding() const
Return the padding of this GenDC metadata part.
Definition detail_gendc_descriptor.hpp:191
void SetSize(std::uint64_t size)
Set the size of the GenDC metadata part.
Definition detail_gendc_descriptor.hpp:197
std::uint64_t GetSize() const
Return the size of the GenDC metadata part.
Definition detail_gendc_descriptor.hpp:185
T make_tuple(T... args)
T max(T... args)
T move(T... args)
Namespace for driver or device related operations.
Definition decl_composite.hpp:27
ComponentId
Component type identifier,.
Definition driver.hpp:609
@ Metadata
Metadata component.
Definition driver.hpp:629
GenDcDescriptorVariableField
Flags specifying which type of data information might vary during the Container reception.
Definition driver.hpp:652
@ Format
If True, the Components' Format might change. This bit can only be set in a prefetch Descriptor.
Definition driver.hpp:662
@ DataSize
If True, the DataSize of the Components' Parts might become smaller.
Definition driver.hpp:654
H264Flags
Flags specifying the characteristics and format of the H.264 Part.
Definition driver.hpp:690
GenDCPartType
Part Type Header format identifier,.
Definition driver.hpp:581
@ TypeMetadataGenICamXML
GenICam Metadata XML.
Definition driver.hpp:594
@ TypeJPEG
JPEG compressed Image.
Definition driver.hpp:600
@ Type2D
Rectangular uncompressed image (monochrome or none planar color).
Definition driver.hpp:598
@ TypeMetadataGenICamChunk
GenICam Chunk Metadata.
Definition driver.hpp:592
@ TypeH264
H.264 compressed Image.
Definition driver.hpp:604
@ TypeJPEG2000
JPEG 2000 compressed Image.
Definition driver.hpp:602
GenDcDescriptorFlag
Flags specifying the characteristics and format of the Container.
Definition driver.hpp:641
GenDcPartFlags
Flags specifying the characteristics and format of the Part.
Definition driver.hpp:681
GenDcComponentFlags
Flags specifying the characteristics and format of the Component.
Definition driver.hpp:673
PfncFormat
GenICam Pixel Format Naming Convention (PFNC) format values.
Definition pfnc_format.hpp:34
@ Data8
Binary 8-bit data.
Definition pfnc_format.hpp:1006
Root namespace for the Image Manager interface.
Definition version.hpp:11
Configuration class for a GenDC descriptor.
Definition decl_gendc_descriptor.hpp:65
std::vector< GenDcDescriptorComponentConfig > Components
Configurations of the GenDC components in this GenDC descriptor.
Definition decl_gendc_descriptor.hpp:67
Class representing a Semantic Version in Major.Minor.SubMinor format.
Definition version.hpp:14
T tie(T... args)
T transform(T... args)