|
| 1 | +# DDS Video & H.264 Streaming |
| 2 | + |
| 3 | +This application demonstrates how to encode video frames with H.264 using the multimedia |
| 4 | +extension over DDS. |
| 5 | + |
| 6 | +The application can be run as either a publisher or as a subscriber. In either case, |
| 7 | +it will use the [VideoFrame](../../../operators/dds/video/VideoFrame.idl) data topic |
| 8 | +registered by the `DDSVideoPublisherOp` or `DDSVideoSubscriberOp` operators in order |
| 9 | +to write or read the video frame data to/from the DDS databus, respectively. |
| 10 | + |
| 11 | +When run as a publisher, the source for the input video frames can come from either an |
| 12 | +attached V4L2-compatible camera via the `V4L2VideoCaptureOp` operator or a video file via the |
| 13 | +`VideoStreamReplayerOp`. This can be configured in the `source` field inside the |
| 14 | +[dds_h264.yaml](./dds_h264.yaml) configuration file. |
| 15 | + |
| 16 | +When run as a subscriber, the application will use Holoviz to render the received |
| 17 | +video frames to the display. |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +- This application requires [RTI Connext](https://content.rti.com/l/983311/2024-04-30/pz1wms) |
| 22 | +be installed and configured with a valid RTI Connext license prior to use. |
| 23 | +- V4L2 capable device |
| 24 | + |
| 25 | +> [!NOTE] |
| 26 | +> Instructions below are based on the `.run' installer from RTI Connext. Refer to the |
| 27 | +> [Linux installation](https://community.rti.com/static/documentation/developers/get-started/full-install.html) |
| 28 | +> for details. |
| 29 | +
|
| 30 | + |
| 31 | +## Quick Start |
| 32 | + |
| 33 | +```bash |
| 34 | +# Start the publisher |
| 35 | +./dev_container build_and_run dds_h264 --container_args "-v $HOME/rti_connext_dds-7.3.0:/opt/rti.com/rti_connext_dds-7.3.0/" --run_args "-p" |
| 36 | + |
| 37 | +# Start the subscriber |
| 38 | +./dev_container build_and_run dds_h264 --container_args "-v $HOME/rti_connext_dds-7.3.0:/opt/rti.com/rti_connext_dds-7.3.0/" --run_args "-s" |
| 39 | +``` |
| 40 | + |
| 41 | + |
| 42 | +## Building the Application |
| 43 | + |
| 44 | +To build on an IGX devkit (using the `armv8` architecture), follow the |
| 45 | +[instructions to build Connext DDS applications for embedded Arm targets](https://community.rti.com/kb/how-do-i-create-connext-dds-application-rti-code-generator-and-build-it-my-embedded-target-arm) |
| 46 | +up to, and including, step 5 (Installing Java and setting JREHOME). |
| 47 | + |
| 48 | +To build the application, the `RTI_CONNEXT_DDS_DIR` CMake variable must point to |
| 49 | +the installation path for RTI Connext. This can be done automatically by setting |
| 50 | +the `NDDSHOME` environment variable to the RTI Connext installation directory |
| 51 | +(such as when using the RTI `setenv` scripts), or manually at build time, e.g.: |
| 52 | + |
| 53 | +```sh |
| 54 | +$ ./run build dds_h264 --configure-args -DRTI_CONNEXT_DDS_DIR=~/rti/rti_connext_dds-7.3.0 |
| 55 | +``` |
| 56 | + |
| 57 | +### Building with a Container |
| 58 | + |
| 59 | +Due to the license requirements of RTI Connext it is not currently supported to |
| 60 | +install RTI Connext into a development container. Instead, Connext should be |
| 61 | +installed onto the host as above and then the development container can be |
| 62 | +launched with the RTI Connext folder mounted at runtime. To do so, ensure that |
| 63 | +the `NDDSHOME` and `CONNEXTDDS_ARCH` environment variables are set (which can be |
| 64 | +done using the RTI `setenv` script) and use the following: |
| 65 | + |
| 66 | +```sh |
| 67 | +# 1. Build the container |
| 68 | +./dev_container build --docker_file applications/dds/dds_h264/Dockerfile |
| 69 | +# 2. Launch the container |
| 70 | +./dev_container launch --docker_opts "-v $HOME/rti_connext_dds-7.3.0:/opt/rti.com/rti_connext_dds-7.3.0/" |
| 71 | +# 3. Build the application |
| 72 | +./run build dds_h264 |
| 73 | +# Continue to the next section to run the application with the publisher. |
| 74 | +# Open a new terminal to repeat step #2 and launch a new container for the subscriber. |
| 75 | +``` |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +## Running the Application |
| 80 | + |
| 81 | +Both a publisher and subscriber process must be launched to see the result of |
| 82 | +writing to and reading the video stream from DDS, respectively. |
| 83 | + |
| 84 | +To run the publisher process, use the `-p` option: |
| 85 | + |
| 86 | +```sh |
| 87 | +$ ./run launch dds_h264 --extra_args "-p" |
| 88 | +``` |
| 89 | + |
| 90 | +To run the subscriber process, use the `-s` option: |
| 91 | + |
| 92 | +```sh |
| 93 | +$ ./run launch dds_h264 --extra_args "-s" |
| 94 | +``` |
| 95 | + |
| 96 | +If running the application generates an error about `RTI Connext DDS No Source |
| 97 | +for License information`, ensure that the RTI Connext license has either been |
| 98 | +installed system-wide or the `NDDSHOME` environment variable has been set to |
| 99 | +point to your user's RTI Connext installation path. |
| 100 | + |
| 101 | +Note that these processes can be run on the same or different systems, so long as they |
| 102 | +are both discoverable by the other via RTI Connext. If the processes are run on |
| 103 | +different systems then they will communicate using UDPv4, for which optimizations have |
| 104 | +been defined in the default `qos_profiles.xml` file. These optimizations include |
| 105 | +increasing the buffer size used by RTI Connext for network sockets, and so the systems |
| 106 | +running the application must also be configured to increase their maximum send and |
| 107 | +receive socket buffer sizes. This can be done by running the `set_socket_buffer_sizes.sh` |
| 108 | +script within this directory: |
| 109 | + |
| 110 | +```sh |
| 111 | +$ ./set_socket_buffer_sizes.sh |
| 112 | +``` |
| 113 | + |
| 114 | +For more details, see the [RTI Connext Guide to Improve DDS Network Performance on Linux Systems](https://community.rti.com/howto/improve-rti-connext-dds-network-performance-linux-systems) |
| 115 | + |
| 116 | +The QoS profiles used by the application can also be modified by editing the |
| 117 | +`qos_profiles.xml` file in the application directory. For more information about modifying |
| 118 | +the QoS profiles, see the [RTI Connext Basic QoS](https://community.rti.com/static/documentation/connext-dds/7.3.0/doc/manuals/connext_dds_professional/getting_started_guide/cpp11/intro_qos.html) |
| 119 | +tutorial or the [RTI Connext QoS Reference Guide](https://community.rti.com/static/documentation/connext-dds/7.3.0/doc/manuals/connext_dds_professional/qos_reference/index.htm). |
| 120 | + |
| 121 | +## Benchmarks |
| 122 | + |
| 123 | +We collected latency benchmark results from the log output of the subscriber. The benchmark is conducted on x86_64 with NVIDIA ADA6000 GPU. |
| 124 | + |
| 125 | +### Single System Setup |
| 126 | + |
| 127 | +**Source**: Video Stream Replayer |
| 128 | +**Resolution**: 854x480 |
| 129 | + |
| 130 | +| Configuration | FPS | AVg. Transfer Time | Jitter | Input Size | Avg. Encoded Size | |
| 131 | +|-------------------|---------|--------------------|---------|------------|-------------------| |
| 132 | +| `realtime: false` | 685.068 | 1.576ms | 0.840ms | 1,229,760 | 25,053 | |
| 133 | +| `realtime: true` | 30.049 | 0.150ms | 0.059ms | 1,229,760 | 26,800 | |
| 134 | + |
| 135 | +**Source** : V4L2 Camera |
| 136 | +**Frame Rate**: 30 |
| 137 | + |
| 138 | +| Resolution | FPS | AVg. Transfer Time | Jitter | Input Size | Avg. Encoded Size | |
| 139 | +|------------|--------|--------------------|---------|------------|-------------------| |
| 140 | +| 640x480 | 30.169 | 0.098ms | 0.030ms | 921,600 | 16,176 | |
| 141 | +| 1920x1080 | 30.281 | 0.104ms | 0.040ms | 6,220,800 | 86,222 | |
| 142 | + |
| 143 | +### Multiple System Setup |
| 144 | + |
| 145 | +The two systems are connected via VPNin this scenario. |
| 146 | + |
| 147 | +**Average Ping Latency**: 22.529ms |
| 148 | + |
| 149 | + |
| 150 | +**Source**: Video Stream Replayer |
| 151 | +**Resolution**: 854x480 |
| 152 | + |
| 153 | +| Configuration | FPS | AVg. Transfer Time | Jitter | Input Size | Avg. Encoded Size | |
| 154 | +|-------------------|---------|--------------------|---------|------------|-------------------| |
| 155 | +| `realtime: false` | 607.581 | 12.278ms | 3.595ms | 1,229,760 | 22,679 | |
| 156 | +| `realtime: true` | 30.050 | 12.937ms | 3.856ms | 1,229,760 | 26,741 | |
| 157 | + |
| 158 | + |
| 159 | +**Source** : V4L2 Camera |
| 160 | +**Frame Rate**: 30 |
| 161 | + |
| 162 | +| Resolution | FPS | AVg. Transfer Time | Jitter | Input Size | Avg. Encoded Size | |
| 163 | +|------------|--------|--------------------|---------|------------|-------------------| |
| 164 | +| 640x480 | 30.047 | 10.771ms | 4.621ms | 921,600 | 11,571 | |
| 165 | +| 1920x1080 | 28.877 | 14.322ms | 3.420ms | 6,220,800 | 52,273 | |
0 commit comments