SOLVED: Harware-accelerated video encoding from C++ buffer with gstreamer omxh264enc and filesink

Here are two samples of using appsink:
[url]https://devtalk.nvidia.com/default/topic/1011376/jetson-tx1/gstreamer-decode-live-video-stream-with-the-delay-difference-between-gst-launch-1-0-command-and-appsink-callback/post/5160929/#5160929[/url]
[url]NVMM memory - Jetson TX1 - NVIDIA Developer Forums

For saving H264 stream to a file, you can simply use filesink.