|
1 | 1 |
|
2 | 2 |
|
3 |
| - |
4 |
| - |
5 | 3 | 
|
6 | 4 |
|
7 |
| -# **VSource interface C++ library** |
| 5 | +# VSource interface C++ library |
8 | 6 |
|
9 |
| -**v1.3.2** |
| 7 | +**v1.4.0** |
10 | 8 |
|
11 | 9 | ------
|
12 | 10 |
|
|
36 | 34 | - [VSourceParam enum](#VSourceParam-enum)
|
37 | 35 | - [VSourceParams class description](#VSourceParams-class-description)
|
38 | 36 | - [VSourceParams class declaration](#VSourceParams-class-declaration)
|
39 |
| - - [Encode video source params](#Encode-video-source-params) |
40 |
| - - [Decode video source params](#Decode-video-source-params) |
| 37 | + - [Serialize video source params](#Serialize-video-source-params) |
| 38 | + - [Deserialize video source params](#Deserialize-video-source-params) |
41 | 39 | - [Read params from JSON file and write to JSON file](#Read-params-from-JSON-file-and-write-to-JSON-file)
|
42 | 40 | - [Build and connect to your project](#Build-and-connect-to-your-project)
|
43 | 41 |
|
|
64 | 62 | | 1.3.0 | 05.07.2023 | - VSourceParams class updated (initString replaced by source).<br />- decode(...) method in VSourceParams class updated. |
|
65 | 63 | | 1.3.1 | 06.07.2023 | - gain, exposure and focusPos fields of VSourceParams excluded from JSOM reading/writing. |
|
66 | 64 | | 1.3.2 | 06.07.2023 | - Frame library version updated. |
|
| 65 | +| 1.4.0 | 11.07.2023 | - Added VSourceParamsMask structure.<br />- Added params mask in encode(...) method of VSourceParams class. | |
67 | 66 |
|
68 | 67 |
|
69 | 68 |
|
@@ -191,7 +190,7 @@ std::cout << "VSource class version: " << VSource::getVersion() << std::endl;
|
191 | 190 | Console output:
|
192 | 191 |
|
193 | 192 | ```bash
|
194 |
| -VSource class version: 1.3.0 |
| 193 | +VSource class version: 1.4.0 |
195 | 194 | ```
|
196 | 195 |
|
197 | 196 |
|
@@ -610,8 +609,9 @@ public:
|
610 | 609 | * source and fourcc fields.
|
611 | 610 | * @param data Pointer to data buffer.
|
612 | 611 | * @param size Size of data.
|
| 612 | + * @param mask Pointer to parameters mask. |
613 | 613 | */
|
614 |
| - void encode(uint8_t* data, int& size); |
| 614 | + void encode(uint8_t* data, int& size, VSourceParamsMask* mask = nullptr); |
615 | 615 | /**
|
616 | 616 | * @brief Decode params. The method doesn't decode params:
|
617 | 617 | * source and fourcc fields.
|
@@ -648,52 +648,82 @@ public:
|
648 | 648 |
|
649 | 649 |
|
650 | 650 |
|
651 |
| -## Encode video source params |
| 651 | +## Serialize video source params |
652 | 652 |
|
653 |
| -**VSourceParams** class provides method **encode(...)** to serialize video source params (fields of VSourceParams class, see Table 4). Serialization of video source params necessary in case when you need to send video source params via communication channels. Method doesn't encode fields: **initString** and **fourcc**. Method declaration: |
| 653 | +**VSourceParams** class provides method **encode(...)** to serialize video source params (fields of VSourceParams class, see Table 4). Serialization of video source params necessary in case when you need to send video source params via communication channels. Method doesn't encode fields: **initString** and **fourcc**. Method provides options to exclude particular parameters from serialization. To do this method inserts binary mask (2 bytes) where each bit represents particular parameter and **decode(...)** method recognizes it. Method declaration: |
654 | 654 |
|
655 | 655 | ```cpp
|
656 |
| -void encode(uint8_t* data, int& size); |
| 656 | +void encode(uint8_t* data, int& size, VSourceParamsMask* mask = nullptr); |
657 | 657 | ```
|
658 | 658 |
|
659 | 659 | | Parameter | Value |
|
660 | 660 | | --------- | ------------------------------------------------------------ |
|
661 | 661 | | data | Pointer to data buffer. Buffer size should be at least **43** bytes. |
|
662 | 662 | | size | Size of encoded data. 43 bytes by default. |
|
| 663 | +| mask | Parameters mask - pointer to **VSourceParamsMask** structure. **VSourceParamsMask** (declared in VSource.h file) determines flags for each field (parameter) declared in **VSourceParams** class. If the user wants to exclude any parameters from serialization, he can put a pointer to the mask. If the user wants to exclude a particular parameter from serialization, he should set the corresponding flag in the VSourceParamsMask structure. | |
663 | 664 |
|
664 |
| -Example: |
| 665 | +**VSourceParamsMask** structure declaration: |
| 666 | + |
| 667 | +```cpp |
| 668 | +typedef struct VSourceParamsMask |
| 669 | +{ |
| 670 | + bool logLevel{true}; |
| 671 | + bool width{true}; |
| 672 | + bool height{true}; |
| 673 | + bool gainMode{true}; |
| 674 | + bool gain{true}; |
| 675 | + bool exposureMode{true}; |
| 676 | + bool exposure{true}; |
| 677 | + bool focusMode{true}; |
| 678 | + bool focusPos{true}; |
| 679 | + bool cycleTimeMks{true}; |
| 680 | + bool fps{true}; |
| 681 | + bool isOpen{true}; |
| 682 | + bool custom1{true}; |
| 683 | + bool custom2{true}; |
| 684 | + bool custom3{true}; |
| 685 | +} VSourceParamsMask; |
| 686 | +``` |
| 687 | + |
| 688 | +Example without parameters mask: |
665 | 689 |
|
666 | 690 | ```cpp
|
667 | 691 | // Prepare random params.
|
668 | 692 | VSourceParams in;
|
669 | 693 | in.initString = "alsfghljb";
|
670 |
| -in.fourcc = "skdfjhvk"; |
671 |
| -in.logLevel = "dsglbjlkfjwjgre"; |
672 |
| -in.cycleTimeMks = rand() % 255; |
673 |
| -in.exposure = rand() % 255; |
674 |
| -in.exposureMode = rand() % 255; |
675 |
| -in.gainMode = rand() % 255; |
676 |
| -in.gain = rand() % 255; |
677 |
| -in.focusMode = rand() % 255; |
678 |
| -in.focusPos = rand() % 255; |
679 |
| -in.fps = rand() % 255; |
680 |
| -in.width = rand() % 255; |
681 |
| -in.height = rand() % 255; |
682 |
| -in.isOpen = true; |
| 694 | +in.logLevel = 0; |
683 | 695 |
|
684 | 696 | // Encode data.
|
685 | 697 | uint8_t data[1024];
|
686 | 698 | int size = 0;
|
687 | 699 | in.encode(data, size);
|
| 700 | +cout << "Encoded data size: " << size << " bytes" << endl; |
| 701 | +``` |
| 702 | + |
| 703 | +Example without parameters mask: |
688 | 704 |
|
| 705 | +```cpp |
| 706 | +// Prepare random params. |
| 707 | +VSourceParams in; |
| 708 | +in.initString = "alsfghljb"; |
| 709 | +in.logLevel = 0; |
| 710 | + |
| 711 | +// Prepare params mask. |
| 712 | +VSourceParamsMask mask; |
| 713 | +mask.logLevel = false; // Exclude logLevel. Others by default. |
| 714 | + |
| 715 | +// Encode data. |
| 716 | +uint8_t data[1024]; |
| 717 | +int size = 0; |
| 718 | +in.encode(data, size, &mask); |
689 | 719 | cout << "Encoded data size: " << size << " bytes" << endl;
|
690 | 720 | ```
|
691 | 721 |
|
692 | 722 |
|
693 | 723 |
|
694 |
| -## Decode video source params |
| 724 | +## Deserialize video source params |
695 | 725 |
|
696 |
| -**VSourceParams** class provides method **decode(...)** to deserialize video source params (fields of VSourceParams class, see Table 4). Deserialization of video source params necessary in case when you need to receive video source params via communication channels. Method doesn't decode fields: **initString** and **fourcc**. Method declaration: |
| 726 | +**VSourceParams** class provides method **decode(...)** to deserialize video source params (fields of VSourceParams class, see Table 4). Deserialization of video source params necessary in case when you need to receive video source params via communication channels. Method doesn't decode fields: **initString** and **fourcc**. Method automatically recognizes which parameters were serialized by **encode(...)** method. Method declaration: |
697 | 727 |
|
698 | 728 | ```cpp
|
699 | 729 | bool decode(uint8_t* data);
|
|
0 commit comments