mirror of
git://nv-tegra.nvidia.com/tegra/gst-src/nvgstapps.git
synced 2025-12-22 09:22:36 +03:00
Compare commits
1 Commits
jetson_36.
...
l4t/l4t-r3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b224ccaf2 |
15
commitFile.txt
Normal file
15
commitFile.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
Updating prebuilts and/or headers
|
||||
|
||||
6bafa48f47ad43d33ee446cf86f2b1da134f7868 - nvgstapps_src/nvgst_sample_apps/nvgstplayer-1.0/nvgst_asound_common.h
|
||||
c028fa403772288daf002520356e8e18cce5cb06 - nvgstapps_src/nvgst_sample_apps/nvgstplayer-1.0/nvgstplayer.h
|
||||
33a285339d714d5546cddb92a710e418853470aa - nvgstapps_src/nvgst_sample_apps/nvgstplayer-1.0/nvgst_asound_common.c
|
||||
582a142d1a3098aed3bb4c8f7329e8cdac7b0ed8 - nvgstapps_src/nvgst_sample_apps/nvgstplayer-1.0/nvgst_x11_common.c
|
||||
d3dee823127d19bcf050cb35c5e0962e9130d789 - nvgstapps_src/nvgst_sample_apps/nvgstplayer-1.0/nvgstplayer.c
|
||||
aaafd7fd4c0214a52bf73dd2a0ba0af08c675b85 - nvgstapps_src/nvgst_sample_apps/nvgstplayer-1.0/nvgst_x11_common.h
|
||||
7152d9928416f55c6879ec0170a495f71eabf80d - nvgstapps_src/nvgst_sample_apps/nvgstipctestapp-1.0/Makefile.public
|
||||
6913ed4a984b2247d1373f0e1b395c582fefb2bd - nvgstapps_src/nvgst_sample_apps/nvgstipctestapp-1.0/LICENSE
|
||||
820c394e9e2e204fd1e289e3b0aa58c91339172b - nvgstapps_src/nvgst_sample_apps/nvgstipctestapp-1.0/nvgstipctestapp.c
|
||||
bd149086ce2fd243a4f2ef669945ed673aa459b9 - nvgstapps_src/nvgst_sample_apps/nvgstcapture-1.0/nvgstcapture.h
|
||||
ec4e84387d8e0e16529f7c8bcd7fee48c16c769c - nvgstapps_src/nvgst_sample_apps/nvgstcapture-1.0/nvgstcapture.c
|
||||
a5bdf6935960973677a005d9d28a04c023f5ec6f - nvgstapps_src/nvgst_sample_apps/nvgstcapture-1.0/nvgst_x11_common.c
|
||||
87556b6e7da0ec3865546f10b7a58959cd8c6bfc - nvgstapps_src/nvgst_sample_apps/nvgstcapture-1.0/nvgst_x11_common.h
|
||||
77
nvgstapps_src/README.txt
Normal file
77
nvgstapps_src/README.txt
Normal file
@@ -0,0 +1,77 @@
|
||||
|
||||
This file explains the procedure to compile NvGstApps sources for hardfp(armhf)
|
||||
ARM architecture.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Prerequisites for nvgst-1.0 applications
|
||||
--------------------------------------------------------------------------------
|
||||
For nvgstcapture-1.0, nvgstplayer-1.0 and nvgstipctestapp-1.0 applications:
|
||||
|
||||
* You must install GStreamer-1.0 on the target board using apt-get, as follows:
|
||||
|
||||
sudo apt-get install gstreamer1.0-tools gstreamer1.0-alsa \
|
||||
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
|
||||
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
|
||||
gstreamer1.0-libav libgstreamer1.0-dev
|
||||
|
||||
|
||||
* Download or copy the nvgstapps_src.tbz2 file on device and untar it.
|
||||
tar -xpf nvgstapps_src.tbz2
|
||||
|
||||
|
||||
* Compile nvgstapps with following procedures.
|
||||
--------------------------------------------------------------------------------
|
||||
Procedure to compile nvgstcapture-1.0:
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
On the target, execute the following commands:
|
||||
|
||||
sudo apt-get install libgstreamer-plugins-base1.0-dev
|
||||
sudo apt-get install libegl1-mesa-dev
|
||||
sudo apt-get install libx11-dev libxext-dev
|
||||
|
||||
As the above steps will overwrite the sym-links to the hardware accelerated libegl
|
||||
binary, to point back to the tegra version, execute the following commands:
|
||||
|
||||
Export ARM application binary interface based on the Linux and ARM platform:
|
||||
Linux 64bit userspace support:
|
||||
export TEGRA_ARMABI=aarch64-linux-gnu
|
||||
Linux 32bit userspace and ARM hardfp support:
|
||||
export TEGRA_ARMABI=arm-linux-gnueabihf
|
||||
|
||||
cd nvgstapps_src/nvgst_sample_apps/nvgstcapture-1.0
|
||||
gcc nvgstcapture.c nvgst_x11_common.c -o nvgstcapture-1.0 \
|
||||
$(pkg-config --cflags --libs gstreamer-1.0 gstreamer-plugins-base-1.0 \
|
||||
gstreamer-pbutils-1.0 x11 xext gstreamer-video-1.0) -ldl
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Procedure to compile nvgstplayer-1.0:
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
On the target, execute the following commands:
|
||||
|
||||
cd nvgstapps_src/nvgst_sample_apps/nvgstplayer-1.0
|
||||
gcc nvgstplayer.c nvgst_x11_common.c nvgst_asound_common.c -o nvgstplayer-1.0 \
|
||||
$(pkg-config --cflags --libs gstreamer-1.0 gstreamer-plugins-base-1.0 \
|
||||
gstreamer-pbutils-1.0 gstreamer-video-1.0 x11 xext alsa)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Procedure to compile nvgstipctestapp-1.0:
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
On the target, execute the following commands:
|
||||
|
||||
cd nvgstapps_src/nvgst_sample_apps/nvgstipctestapp-1.0
|
||||
gcc nvgstipctestapp.c -o nvgstipctestapp-1.0 \
|
||||
$(pkg-config --cflags --libs gstreamer-1.0 gstreamer-plugins-base-1.0 \
|
||||
gstreamer-pbutils-1.0 gstreamer-video-1.0 x11 gstreamer-video-1.0 gstreamer-app-1.0) -lm
|
||||
|
||||
* For nvgstcapture-1.0 usage, refer to
|
||||
nvgstapps_src/nvgst_sample_apps/nvgstcapture-1.0/nvgstcapture-1.0_README.txt
|
||||
|
||||
* For nvgstplayer-1.0 usage, refer to
|
||||
nvgstapps_src/nvgst_sample_apps/nvgstplayer-1.0/nvgstplayer-1.0_README.txt
|
||||
|
||||
* For nvgstipctestapp-1.0 usage, refer to
|
||||
nvgstapps_src/nvgst_sample_apps/nvgstipctestapp-1.0/nvgstipctestapp-1.0_README.txt
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "nvgst_x11_common.h"
|
||||
|
||||
void
|
||||
nvgst_x11_init (displayCtx * dpyCtx)
|
||||
{
|
||||
dpyCtx->isDPMSdisabled = 0;
|
||||
int screen = 0;
|
||||
dpyCtx->mDisplay = XOpenDisplay (NULL);
|
||||
if (!dpyCtx->mDisplay)
|
||||
printf
|
||||
("\nCannot open display specified with DISPLAY environment variable\n");
|
||||
else {
|
||||
screen = DefaultScreen (dpyCtx->mDisplay);
|
||||
dpyCtx->display_width = DisplayWidth (dpyCtx->mDisplay, screen);
|
||||
dpyCtx->display_height = DisplayHeight (dpyCtx->mDisplay, screen);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvgst_x11_uninit (displayCtx * dpyCtx)
|
||||
{
|
||||
if (dpyCtx->window)
|
||||
XDestroyWindow (dpyCtx->mDisplay, dpyCtx->window);
|
||||
XCloseDisplay (dpyCtx->mDisplay);
|
||||
dpyCtx->mDisplay = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
saver_off (displayCtx * dpyCtx)
|
||||
{
|
||||
int nothing;
|
||||
if (DPMSQueryExtension (dpyCtx->mDisplay, ¬hing, ¬hing)) {
|
||||
BOOL enabled;
|
||||
CARD16 powerLevel;
|
||||
|
||||
DPMSInfo (dpyCtx->mDisplay, &powerLevel, &enabled);
|
||||
if (enabled) {
|
||||
DPMSDisable (dpyCtx->mDisplay);
|
||||
DPMSInfo (dpyCtx->mDisplay, &powerLevel, &enabled);
|
||||
if (enabled) {
|
||||
printf ("\ncould not disable DPMS\n");
|
||||
}
|
||||
} else {
|
||||
printf ("\nDPMS already DISABLED\n");
|
||||
dpyCtx->isDPMSdisabled = 1;
|
||||
}
|
||||
} else
|
||||
printf ("\nserver does not have extension for -dpms option\n");
|
||||
}
|
||||
|
||||
void
|
||||
saver_on (displayCtx * dpyCtx)
|
||||
{
|
||||
int nothing;
|
||||
if (DPMSQueryExtension (dpyCtx->mDisplay, ¬hing, ¬hing)) {
|
||||
BOOL enabled;
|
||||
CARD16 powerLevel;
|
||||
|
||||
DPMSInfo (dpyCtx->mDisplay, &powerLevel, &enabled);
|
||||
if (!enabled) {
|
||||
if (!dpyCtx->isDPMSdisabled)
|
||||
DPMSEnable (dpyCtx->mDisplay);
|
||||
DPMSInfo (dpyCtx->mDisplay, &powerLevel, &enabled);
|
||||
if (!enabled && !dpyCtx->isDPMSdisabled) {
|
||||
printf ("\ncould not enable DPMS\n");
|
||||
}
|
||||
} else
|
||||
printf ("\nDPMS already ENABLED\n");
|
||||
} else
|
||||
printf ("\nserver does not have extension for -dpms option\n");
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
nvgst_create_window (displayCtx * dpyCtx, char *title)
|
||||
{
|
||||
int screen = 0;
|
||||
XTextProperty xproperty;
|
||||
|
||||
if (dpyCtx->mDisplay) {
|
||||
screen = DefaultScreen (dpyCtx->mDisplay);
|
||||
if (!dpyCtx->width && !dpyCtx->height) {
|
||||
dpyCtx->width = DisplayWidth (dpyCtx->mDisplay, screen);
|
||||
dpyCtx->height = DisplayHeight (dpyCtx->mDisplay, screen);
|
||||
}
|
||||
|
||||
dpyCtx->window = XCreateSimpleWindow (dpyCtx->mDisplay,
|
||||
RootWindow (dpyCtx->mDisplay, screen),
|
||||
dpyCtx->x, dpyCtx->y, dpyCtx->width, dpyCtx->height, 0, 0,
|
||||
BlackPixel (dpyCtx->mDisplay, screen));
|
||||
|
||||
XSetWindowBackgroundPixmap (dpyCtx->mDisplay, dpyCtx->window, None);
|
||||
|
||||
if (title) {
|
||||
if ((XStringListToTextProperty (((char **) &title), 1, &xproperty)) != 0) {
|
||||
XSetWMName (dpyCtx->mDisplay, dpyCtx->window, &xproperty);
|
||||
XFree (xproperty.value);
|
||||
|
||||
}
|
||||
} else
|
||||
printf ("\ncan't set title to window, title NULL\n");
|
||||
|
||||
/* Tell the window manager we'd like delete client messages instead of
|
||||
* being killed */
|
||||
Atom wmDeleteMessage =
|
||||
XInternAtom (dpyCtx->mDisplay, "WM_DELETE_WINDOW", False);
|
||||
if (wmDeleteMessage != None) {
|
||||
XSetWMProtocols (dpyCtx->mDisplay, dpyCtx->window, &wmDeleteMessage, 1);
|
||||
}
|
||||
|
||||
XMapRaised (dpyCtx->mDisplay, dpyCtx->window);
|
||||
|
||||
XSync (dpyCtx->mDisplay, 1); //discard the events for now
|
||||
} else
|
||||
printf ("\ncan't create window, Display NULL\n");
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
nvgst_destroy_window (displayCtx * dpyCtx)
|
||||
{
|
||||
XDestroyWindow (dpyCtx->mDisplay, dpyCtx->window);
|
||||
dpyCtx->window = (Window) NULL;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/extensions/dpms.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Display *mDisplay;
|
||||
Window window;
|
||||
int width;
|
||||
int height;
|
||||
int display_width;
|
||||
int display_height;
|
||||
int x;
|
||||
int y;
|
||||
int isDPMSdisabled;
|
||||
} displayCtx;
|
||||
|
||||
void nvgst_x11_init (displayCtx * dpyCtx);
|
||||
void nvgst_x11_uninit (displayCtx * dpyCtx);
|
||||
void saver_off (displayCtx * dpyCtx);
|
||||
void saver_on (displayCtx * dpyCtx);
|
||||
void nvgst_create_window (displayCtx * dpyCtx, char *title);
|
||||
void nvgst_destroy_window (displayCtx * dpyCtx);
|
||||
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
* Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
=> PRE-REQUISITES :
|
||||
|
||||
1. You must install GStreamer-1.0 on the target board using apt-get, as follows:
|
||||
|
||||
sudo apt-get install gstreamer1.0-tools gstreamer1.0-alsa gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav
|
||||
|
||||
2. To check the running gstreamer version, use the following command before you start using the nvgstcapture application:
|
||||
|
||||
gst-inspect-1.0 --version
|
||||
|
||||
3. Execute the following commands on the target board's Ubuntu command line:
|
||||
|
||||
export DISPLAY=:0
|
||||
|
||||
=> NvGstCapture Usage:
|
||||
|
||||
* The nvgstcapture application can capture video data and encapsulate encoded data in a container file.
|
||||
|
||||
* The nvgstcapture application supports both command-line and runtime options.
|
||||
|
||||
=> NvGstCapture Application Options:
|
||||
|
||||
Usage: ./nvgstcapture-1.0 --help
|
||||
|
||||
* Command-line options for NvArgusCamera:
|
||||
|
||||
--prev-res Preview width & height.Range: 2 to 12 (5632x4224) e.g., --prev-res=3
|
||||
--cus-prev-res Custom Preview width & height e.g., --cus-prev-res=1920x1080
|
||||
--image-res Image width & height. Range: 2 to 12 (5632x4224) e.g., --image-res=3
|
||||
--video-res Video width & height. Range: 2 to 9 (3896x2192) e.g., --video-res=3
|
||||
--camsrc Camera Source to use (0=v4l2, 1=csi[default], 2=videotest, 3=eglstream)
|
||||
-m, --mode Capture mode value (1=still 2=video)
|
||||
-v, --video-enc Video encoder type (0=h264[HW] 1=vp8[HW] 2=h265[HW] 3=vp9[HW])
|
||||
-p, --hw-enc-path Frame Work type (1=V4L2[Default])
|
||||
-b, --enc-bitrate Video encoding Bit-rate(in bytes) e.g., --enc-bitrate=4000000
|
||||
--enc-controlrate Video encoding Bit-rate control method 0 = Disable, 1 = variable(Default), 2 = constant e.g., --enc-controlrate=1
|
||||
--enc-EnableTwopassCBR Enable two pass CBR while encoding 0 = Disable, 1 = Enable e.g., --enc-EnableTwopassCBR=1
|
||||
--enc-profile Video encoder profile For H.264: 0=Baseline, 1=Main, 2=High
|
||||
-J, --image-enc Image encoder type (0=jpeg_SW[jpegenc] 1=jpeg_HW[nvjpegenc])
|
||||
-k, --file-type Container file type (0=mp4 1=3gp 2=mkv)
|
||||
--file-name Captured file name. nvcamtest is used by default
|
||||
--color-format Color format to use (0=I420,1=NV12[For CSI only and default for CSI], 2=YUY2[For V4L2 only, default for v4l2])
|
||||
--enable-meta Enable Sensor MetaData reporting
|
||||
--app-profile Enable KPI profiling
|
||||
--kpi-numbers Enable KPI measurement
|
||||
--cap-dev-node Video capture device node (0=/dev/video0[default], 1=/dev/video1, 2=/dev/video2) e.g., --cap-dev-node=0
|
||||
--svs [For USB] (=) chain for video Preview. [For CSI only] use "nveglglessink"
|
||||
--eglConfig EGL window Coordinates (x_pos y_pos) in that order e.g., --eglConfig="50 100"
|
||||
--orientation Camera sensor orientation value
|
||||
-w, --whitebalance Capture whitebalance value
|
||||
--timeout Capture timeout value
|
||||
--saturation Camera Saturation value
|
||||
--sensor-id Camera Sensor ID value
|
||||
--exposuretimerange Property to adjust exposure time range in nanoseconds e.g., --exposuretimerange="34000 358733000"
|
||||
--gainrange Property to adjust gain range e.g., --gainrange="1 16"
|
||||
--ispdigitalgainrange Property to adjust digital gain range e.g., --ispdigitalgainrange="1 8"
|
||||
--aelock Enable AE Lock, default is disabled
|
||||
--awblock Enable AWB Lock, default is disabled
|
||||
--exposurecompensation Property to adjust exposure compensation e.g., --exposurecompensation=0.5
|
||||
--aeantibanding Property to set the auto exposure antibanding mode e.g., --aeantibanding=2
|
||||
--tnr-mode Property to select temporal noise reduction mode e.g., --tnr-mode=2
|
||||
--tnr-strength Property to adjust temporal noise reduction strength e.g., --tnr-strength=0.5
|
||||
--ee-mode Property to select edge enhancement mode e.g., --ee-mode=2
|
||||
--ee-strength Property to adjust edge enhancement strength e.g., --ee-strength=0.5
|
||||
--overlayConfig Overlay Configuration Options index and coordinates in (index, x_pos, y_pos, width, height) order e.g. --overlayConfig="0, 0, 0, 1280, 720"
|
||||
-A, --automate Run application in automation mode
|
||||
-S, --start-time Start capture after specified time in seconds. Default = 5 sec (use with --automate or -A only)
|
||||
-Q, --quit-after Quit application once automation is done after specified time in seconds. Default = 0 sec (use with --automate or -A only)
|
||||
-C, --count Number of iterations of automation testcase. Default = 1 (use with --automate or -A only)
|
||||
-N, --num-sensors Number of sensors (use with --automate or -A only)
|
||||
--capture-gap Number of milliseconds between successive image/video capture. Default = 250 msec (use with --automate and --capture-auto only)
|
||||
--capture-time Capture video for specified time in seconds. Default = 10 sec (use with --automate and --capture-auto only)
|
||||
--toggle-mode Toggle between still and video capture modes for count number of times (use with --automate or -A only)
|
||||
--capture-auto Do image/video capture in automation mode for count number of times(use with --automate or -A only)
|
||||
--toggle-sensor Toggle between num_sensors if given otherwise between sensor-id 0 and 1 (use with --automate or -A only)
|
||||
--enum-wb Enumerate all white-balance modes for count number of times (use with --automate or -A only)
|
||||
--enum-st Enumerate saturation value through 0 to 2 by a step of 0.1 for count number of times (use with --automate or -A only)
|
||||
|
||||
|
||||
Supported resolutions in case of NvArgusCamera
|
||||
(2) : 640x480
|
||||
(3) : 1280x720
|
||||
(4) : 1920x1080
|
||||
(5) : 2104x1560
|
||||
(6) : 2592x1944
|
||||
(7) : 2616x1472
|
||||
(8) : 3840x2160
|
||||
(9) : 3896x2192
|
||||
(10): 4208x3120
|
||||
(11): 5632x3168
|
||||
(12): 5632x4224
|
||||
|
||||
* Runtime options for NvArgusCamera:
|
||||
|
||||
Help : 'h'
|
||||
Quit : 'q'
|
||||
Set Capture Mode:
|
||||
mo:<val>
|
||||
(1): image
|
||||
(2): video
|
||||
Get Capture Mode:
|
||||
gmo
|
||||
Set sensor orientation:
|
||||
so:<val>
|
||||
(0): none
|
||||
(1): Rotate counter-clockwise 90 degrees
|
||||
(2): Rotate 180 degrees
|
||||
(3): Rotate clockwise 90 degrees
|
||||
Get sensor orientation:
|
||||
gso
|
||||
Set Whitebalance Mode:
|
||||
wb:<val>
|
||||
(0): off
|
||||
(1): auto
|
||||
(2): incandescent
|
||||
(3): fluorescent
|
||||
(4): warm-fluorescent
|
||||
(5): daylight
|
||||
(6): cloudy-daylight
|
||||
(7): twilight
|
||||
(8): shade
|
||||
(9): manual
|
||||
Get Whitebalance Mode:
|
||||
gwb
|
||||
Set Saturation (0 to 2):
|
||||
st:<val> e.g., st:1.25
|
||||
Get Saturation:
|
||||
gst
|
||||
Set Exposure Compensation (-2 to 2):
|
||||
ec:<val> e.g., ec:-2
|
||||
Get Exposure Compensation:
|
||||
gec
|
||||
Set Auto Whitebalance Lock:
|
||||
awbl:<val> e.g., awbl:0
|
||||
Get Auto Whitebalance Lock:
|
||||
awbl
|
||||
Set Auto Exposure Lock:
|
||||
ael:<val> e.g., ael:0
|
||||
Get Auto Exposure Lock:
|
||||
gael
|
||||
Set TNR Mode:
|
||||
tnrm:<val> e.g., tnrm:1
|
||||
(0): DENOISE_MODE_OFF
|
||||
(1): DENOISE_MODE_FAST
|
||||
(2): DENOISE_MODE_HIGH_QUALITY
|
||||
Get TNR Mode:
|
||||
gtnrm
|
||||
Set TNR Strength (-1 to 1):
|
||||
tnrs:<val> e.g., tnrs:0.5
|
||||
Get TNR Strength:
|
||||
gtnrs
|
||||
Set EE Mode:
|
||||
eem:<val> e.g., eem:1
|
||||
(0): EDGE_ENHANCE_MODE_OFF
|
||||
(1): EDGE_ENHANCE_MODE_FAST
|
||||
(2): EDGE_ENHANCE_MODE_HIGH_QUALITY
|
||||
Get EE Mode:
|
||||
geem
|
||||
Set EE Strength (-1 to 1):
|
||||
ees:<val> e.g., ees:0.5
|
||||
Get EE Strength:
|
||||
gees
|
||||
Set Auto Exposure Anti-Banding (0 to 3):
|
||||
aeab:<val> e.g., aeab:2
|
||||
(0): AE_ANTIBANDING_MODE_OFF
|
||||
(1): AE_ANTIBANDING_MODE_AUTO
|
||||
(2): AE_ANTIBANDING_MODE_50HZ
|
||||
(3): AE_ANTIBANDING_MODE_60HZ
|
||||
Get Auto Exposure Anti-Banding:
|
||||
gaeab
|
||||
Set Gain Range:
|
||||
gr:<val><space><val> e.g., gr:1 16
|
||||
Get Gain Range:
|
||||
ggr
|
||||
Set Exposure Time Range:
|
||||
etr:<val><space><val> e.g., etr:34000 35000
|
||||
Get Exposure Time Range:
|
||||
getr
|
||||
Set ISP Digital Gain Range:
|
||||
dgr:<val><space><val> e.g., dgr:2 152
|
||||
Get ISP Digital Gain Range:
|
||||
gdgr
|
||||
Capture: enter 'j' OR
|
||||
followed by a timer (e.g., jx5000, capture after 5 seconds) OR
|
||||
followed by multishot count (e.g., j:6, capture 6 images)
|
||||
timer/multihot values are optional, capture defaults to single shot with timer=0s
|
||||
Start Recording : enter '1'
|
||||
Stop Recording : enter '0'
|
||||
Video snapshot : enter '2' (While recording video)
|
||||
Get Preview Resolution:
|
||||
gpcr
|
||||
Get Image Capture Resolution:
|
||||
gicr
|
||||
Get Video Capture Resolution:
|
||||
gvcr
|
||||
|
||||
Runtime encoder configuration options:
|
||||
|
||||
Set Encoding Bit-rate(in bytes):
|
||||
br:<val> e.g., br:4000000
|
||||
Get Encoding Bit-rate(in bytes):
|
||||
gbr
|
||||
Set Encoding Profile(only for H.264):
|
||||
ep:<val> e.g., ep:1
|
||||
(0): Baseline
|
||||
(1): Main
|
||||
(2): High
|
||||
Get Encoding Profile(only for H.264):
|
||||
gep
|
||||
Force IDR Frame on video Encoder(only for H.264):
|
||||
Enter 'f'
|
||||
|
||||
Runtime encoder configuration options:
|
||||
|
||||
Set Encoding Bit-rate(in bytes):
|
||||
br:<val> e.g., br:4000000
|
||||
Get Encoding Bit-rate(in bytes):
|
||||
gbr
|
||||
Set Encoding Profile(only for H.264):
|
||||
ep:<val> e.g., ep:1
|
||||
(0): Baseline
|
||||
(1): Main
|
||||
(2): High
|
||||
Get Encoding Profile(only for H.264):
|
||||
gep
|
||||
Force IDR Frame on video Encoder(only for H.264):
|
||||
Enter 'f'
|
||||
|
||||
NOTES:
|
||||
|
||||
1. The nvgstcapture application generates image and video output files in the same directory as the application itself.
|
||||
|
||||
2. Filenames for image and video content are in the formats "nvcamtest_<pid>_s<sensor-id>_<capture-count>.jpg" and
|
||||
"nvcamtest_<pid>_s<sensor-id>_<capture-count>.mp4" respectively.
|
||||
where,
|
||||
<pid> is process id,
|
||||
<sensor-id> is camera sensor id
|
||||
<capture-count> is a counter starting from 0 every time you run the application.
|
||||
Rename or move files between runs to avoid overwriting results you want to save.
|
||||
|
||||
3. The nvgstcapture application default supports native capture (video only) mode.
|
||||
|
||||
4. Advanced features, like setting zoom, brightness, exposure, and whitebalance, are not supported with USB-Camera.
|
||||
|
||||
5. The nvgstcapture application sets nvjpegenc[HW] by default for Image encoding.
|
||||
|
||||
6. User can specify a sensor supported custom preview resolution. A CSI camera will output at the custom resolution
|
||||
but visible preview will be capped at 1080p max. Command:
|
||||
./nvgstcapture-1.0 --prev-res=2 --cus-prev-res=1280x960
|
||||
|
||||
7. nvgstcapture-1.0 supports automation. Details of the commands can be found in help. Here are example command lines
|
||||
for a few use cases:
|
||||
|
||||
i) Capture 50 images with 1080p resolutions:
|
||||
./nvgstcapture-1.0 -A -C 50 --capture-auto --image-res=4
|
||||
|
||||
ii) Capture 5 720p videos, each of length 60 seconds, with a gap of 2 seconds between recordings
|
||||
and quit application 10 seconds after that:
|
||||
./nvgstcapture-1.0 -A -C 5 --capture-auto --video-res=3 --capture-time=60 --mode=2 --capture-gap=2000 --quit-after=10
|
||||
|
||||
8. nvhdmioverlaysink and nvoverlaysnk has been deprecated.
|
||||
|
||||
9. For a USB camera use "--cap-dev-node" command line option along with "--camsrc=0" to specify the capture node.
|
||||
|
||||
10. Hardware encoder support depends on the Jetson platform. Please refer to the following section in Accelerated GStreamer User Guide for supported codecs for your platform:
|
||||
Gstreamer-1.0 Installation and Setup > Gstreamer-1.0 Plugin Reference > gst-omx video encoders
|
||||
|
||||
11. The nvgstcapture application uses gst-v4l2 encoders by default.
|
||||
|
||||
4796
nvgstapps_src/nvgst_sample_apps/nvgstcapture-1.0/nvgstcapture.c
Normal file
4796
nvgstapps_src/nvgst_sample_apps/nvgstcapture-1.0/nvgstcapture.c
Normal file
File diff suppressed because it is too large
Load Diff
691
nvgstapps_src/nvgst_sample_apps/nvgstcapture-1.0/nvgstcapture.h
Normal file
691
nvgstapps_src/nvgst_sample_apps/nvgstcapture-1.0/nvgstcapture.h
Normal file
@@ -0,0 +1,691 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2014-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _NV_GST_CAPTURE_H_
|
||||
#define _NV_GST_CAPTURE_H_
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/videooverlay.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#include "gst/pbutils/pbutils.h"
|
||||
#include "gst/pbutils/encoding-profile.h"
|
||||
#include "gst/pbutils/encoding-target.h"
|
||||
#include "nvgst_x11_common.h"
|
||||
|
||||
#ifdef WITH_GUI
|
||||
|
||||
#include "nvgstcapture_gui_interface.h"
|
||||
|
||||
#else
|
||||
|
||||
int dummy_func (void);
|
||||
int dummy_func ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#define GUI 0
|
||||
#define CALL_GUI_FUNC(func, ...) dummy_func()
|
||||
#define GET_GUI_CTX() NULL
|
||||
|
||||
#endif
|
||||
|
||||
#define FUNCTION_START() \
|
||||
time_t startTime = 0; \
|
||||
struct timeval start_tv = {0, 0}; \
|
||||
time_t endTime = 0; \
|
||||
struct timeval end_tv = {0, 0}; \
|
||||
if (gettimeofday(&start_tv, NULL) == 0) \
|
||||
startTime = start_tv.tv_sec * 1000000 + start_tv.tv_usec; \
|
||||
else \
|
||||
startTime = 0;
|
||||
|
||||
#define FUNCTION_END() \
|
||||
if (gettimeofday(&end_tv, NULL) == 0) \
|
||||
endTime = end_tv.tv_sec * 1000000 + end_tv.tv_usec; \
|
||||
else \
|
||||
endTime = 0; \
|
||||
if (app->enableKpiProfile) \
|
||||
g_print("\nKPI total time for %s in mS: %ld\n", \
|
||||
__func__, ((endTime - startTime) / 1000));
|
||||
|
||||
#define GET_TIMESTAMP(PLACE) \
|
||||
if (gettimeofday(&app->timeStamp, NULL) == 0) \
|
||||
app->timeStampStore[PLACE] = (app->timeStamp.tv_sec * 1000000) + app->timeStamp.tv_usec; \
|
||||
else \
|
||||
app->timeStampStore[PLACE] = 0;
|
||||
|
||||
/* CAPTURE GENERIC */
|
||||
#define NVGST_DEFAULT_CAPTURE_MODE CAPTURE_IMAGE
|
||||
#define NVGST_DEFAULT_FILENAME "nvcamtest"
|
||||
#define NVGST_DEFAULT_FILE_TYPE FILE_MP4
|
||||
#define NVGST_DEFAULT_LOCATION "/dev/null"
|
||||
#define NVGST_DEFAULT_CAPTURE_FORMAT "I420"
|
||||
#define NVGST_DEFAULT_CAPTURE_FPS 30
|
||||
#define NVGST_DEFAULT_VIDCAP_DEVICE "/dev/video0"
|
||||
#define NVGST_DEFAULT_V4L2_NVENC_DEVICE_PATH "/dev/nvhost-msenc"
|
||||
#define NVGST_DEFAULT_V4L2_NVENC_DEVICE_PATH_ALT "/dev/v4l2-nvenc"
|
||||
#define DEFAULT_LOCATION "/dev/null"
|
||||
#define SUCCESS 0
|
||||
|
||||
/* PREVIEW */
|
||||
#define NVGST_DEFAULT_PREVIEW_WIDTH 640
|
||||
#define NVGST_DEFAULT_PREVIEW_HEIGHT 480
|
||||
#define NVGST_DEFAULT_RENDER_TARGET RENDER_OVERLAY
|
||||
|
||||
/* IMAGE & VIDEO CAPTURE */
|
||||
#define NVGST_DEFAULT_VIDEO_MIMETYPE "video/x-raw"
|
||||
#define NVGST_DEFAULT_CAPTURE_WIDTH 640
|
||||
#define NVGST_DEFAULT_CAPTURE_HEIGHT 480
|
||||
#define NVGST_DEFAULT_480P_ENCODER_BITRATE 4000000
|
||||
#define NVGST_DEFAULT_720P_ENCODER_BITRATE 8000000
|
||||
#define NVGST_DEFAULT_1080P_ENCODER_BITRATE 14000000
|
||||
#define NVGST_DEFAULT_2160P_ENCODER_BITRATE 20000000
|
||||
#define NVGST_DEFAULT_VIDEO_ENCODER_PROFILE PROFILE_HIGH
|
||||
#define NVGST_DEFAULT_VIDEO_ENCODER_CONTROLRATE CONTROLRATE_VARIABLE
|
||||
#define NVGST_DEFAULT_VIDEO_ENCODER_TWOPASSCBR FALSE
|
||||
|
||||
#define NVGST_DEFAULT_IMAGE_ENCODER FORMAT_JPEG_HW
|
||||
#define NVGST_DEFAULT_VIDEO_ENCODER FORMAT_H264_HW
|
||||
#define NVGST_DEFAULT_FLIP_METHOD 0
|
||||
|
||||
/* CAPTURE ELEMENTS */
|
||||
#define NVGST_VIDEO_CAPTURE_SRC_TEST "videotestsrc"
|
||||
#define NVGST_VIDEO_CAPTURE_SRC_V4L2 "v4l2src"
|
||||
#define NVGST_VIDEO_CAPTURE_SRC_CSI_ARGUS "nvarguscamerasrc"
|
||||
#define NVGST_EGLSTREAM_CAPTURE_SRC "nveglstreamsrc"
|
||||
#define NVGST_VIDEO_SINK "nvvideosink"
|
||||
#define NVGST_DEFAULT_VIDEO_CONVERTER "videoconvert"
|
||||
#define NVGST_DEFAULT_VIDEO_CONVERTER_CSI "nvvidconv"
|
||||
#define NVGST_DEFAULT_VIDEO_SCALER "videoscale"
|
||||
#ifdef WITH_GUI
|
||||
#define NVGST_DEFAULT_PREVIEW_SINK_CSI "nveglglessink"
|
||||
#else
|
||||
#define NVGST_DEFAULT_PREVIEW_SINK_CSI "nveglglessink"
|
||||
#endif
|
||||
#define NVGST_DEFAULT_PREVIEW_SINK_USB "xvimagesink"
|
||||
#define NVGST_DEFAULT_CAPTURE_FILTER "capsfilter"
|
||||
#define NVGST_DEFAULT_IMAGE_ENC "nvjpegenc"
|
||||
#define NVGST_DEFAULT_IMAGE_ENC_CONVERTER "nvvidconv"
|
||||
#define NVGST_SW_IMAGE_ENC "jpegenc"
|
||||
#define NVGST_DEFAULT_IENC_SINK "fakesink"
|
||||
#define NVGST_DEFAULT_VENC_SINK "filesink"
|
||||
#define NVGST_DEFAULT_VENC_PARSE "h264parse"
|
||||
#define NVGST_PRIMARY_V4L2_H264_VENC "nvv4l2h264enc"
|
||||
#define NVGST_PRIMARY_V4L2_VP8_VENC "nvv4l2vp8enc"
|
||||
#define NVGST_PRIMARY_V4L2_VP9_VENC "nvv4l2vp9enc"
|
||||
#define NVGST_PRIMARY_V4L2_H265_VENC "nvv4l2h265enc"
|
||||
#define NVGST_SW_H264_ENC "x264enc"
|
||||
#define NVGST_PRIMARY_H264_PARSER "h264parse"
|
||||
#define NVGST_PRIMARY_H265_PARSER "h265parse"
|
||||
#define NVGST_PRIMARY_MP4_MUXER "qtmux"
|
||||
#define NVGST_PRIMARY_3GP_MUXER "3gppmux"
|
||||
#define NVGST_PRIMARY_MKV_MUXER "matroskamux"
|
||||
#define NVGST_PRIMARY_STREAM_SELECTOR "tee"
|
||||
#define NVGST_PRIMARY_QUEUE "queue"
|
||||
#define NVGST_PRIMARY_IDENTITY "identity"
|
||||
|
||||
#ifdef WITH_STREAMING
|
||||
#define NVGST_STREAMING_SRC_FILE "uridecodebin"
|
||||
#endif
|
||||
|
||||
/* CSI CAMERA DEFAULT PROPERTIES TUNING */
|
||||
|
||||
#define NVGST_DEFAULT_WHITEBALANCE 1
|
||||
#define NVGST_DEFAULT_SATURATION 1
|
||||
#define NVGST_DEFAULT_EXPOSURE_COMPENSATION 0
|
||||
#define NVGST_DEFAULT_TNR_STRENGTH -1
|
||||
#define NVGST_DEFAULT_EE_STRENGTH -1
|
||||
#define NVGST_DEFAULT_AEANTIBANDING 0
|
||||
#define NVGST_DEFAULT_AE_LOCK 0
|
||||
#define NVGST_DEFAULT_AWB_LOCK 0
|
||||
#define NVGST_DEFAULT_TNR_MODE 1
|
||||
#define NVGST_DEFAULT_EE_MODE 1
|
||||
#define NVGST_DEFAULT_SENSOR_ID 0
|
||||
#define NVGST_DEFAULT_SENSOR_MODE -1
|
||||
#define NVGST_DEFAULT_DISPLAY_ID 0
|
||||
|
||||
#define MIN_EXPOSURE_COMPENSATION -2
|
||||
#define MAX_EXPOSURE_COMPENSATION 2
|
||||
#define MIN_TNR_MODE 0
|
||||
#define MAX_TNR_MODE 2
|
||||
#define MIN_EE_MODE 0
|
||||
#define MAX_EE_MODE 2
|
||||
#define MIN_STRENGTH -1
|
||||
#define MAX_STRENGTH 1
|
||||
#define MIN_AE_ANTIBANDING_MODE 0
|
||||
#define MAX_AE_ANTIBANDING_MODE 3
|
||||
|
||||
/* CSI CAMERA DEFAULT AUTOMATION */
|
||||
|
||||
#define NVGST_DEFAULT_AUTOMATION_MODE FALSE
|
||||
#define NVGST_DEFAULT_CAP_START_DELAY 5
|
||||
#define NVGST_DEFAULT_QUIT_TIME 0
|
||||
#define NVGST_DEFAULT_ITERATION_COUNT 1
|
||||
#define NVGST_DEFAULT_CAPTURE_GAP 250
|
||||
#define NVGST_DEFAULT_CAPTURE_TIME 10
|
||||
#define NVGST_DEFAULT_NUM_SENSORS 2
|
||||
#define NVGST_DEFAULT_TOGGLE_CAMERA_MODE FALSE
|
||||
#define NVGST_DEFAULT_TOGGLE_CAMERA_SENSOR FALSE
|
||||
#define NVGST_DEFAULT_TOGGLE_CAMERA_SENSOR_MODES FALSE
|
||||
#define NVGST_DEFAULT_ENUMERATE_WHITEBALANCE FALSE
|
||||
#define NVGST_DEFAULT_ENUMERATE_SATURATION FALSE
|
||||
#define NVGST_DEFAULT_ENUMERATE_CAPTURE_AUTO FALSE
|
||||
|
||||
|
||||
#define MIN_V4L2_RES PR_176x144
|
||||
#define MAX_V4L2_RES PR_1920x1080
|
||||
#define MIN_CSI_RES PR_640x480
|
||||
#define MAX_CSI_RES PR_5632x4224
|
||||
|
||||
/* DEBUG LOG LEVEL */
|
||||
#ifdef NVGST_LOG_LEVEL_DEBUG
|
||||
#define NVGST_ENTER_FUNCTION() g_print("%s{", __FUNCTION__)
|
||||
#define NVGST_EXIT_FUNCTION() g_print("%s}", __FUNCTION__)
|
||||
#define NVGST_EXIT_FUNCTION_VIA(s) g_print("%s}['%s']", __FUNCTION__, s)
|
||||
#define NVGST_DEBUG_MESSAGE(s) g_debug("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_DEBUG_MESSAGE_V(s, ...) g_debug("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#define NVGST_INFO_MESSAGE(s) g_message("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_INFO_MESSAGE_V(s, ...) g_message("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#define NVGST_WARNING_MESSAGE(s) g_warning("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_WARNING_MESSAGE_V(s, ...) g_warning("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#define NVGST_CRITICAL_MESSAGE(s) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_CRITICAL_MESSAGE_V(s, ...) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__,__VA_ARGS__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_ERROR_MESSAGE(s) g_error("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_ERROR_MESSAGE_V(s, ...) g_error("<%s:%d> "s, __FUNCTION__, __LINE__,__VA_ARGS__)
|
||||
|
||||
#elif defined NVGST_LOG_LEVEL_INFO
|
||||
#define NVGST_ENTER_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION_VIA(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE(s) g_message("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_INFO_MESSAGE_V(s, ...) g_message("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#define NVGST_WARNING_MESSAGE(s) g_warning("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_WARNING_MESSAGE_V(s, ...) g_warning("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#define NVGST_CRITICAL_MESSAGE(s) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_CRITICAL_MESSAGE_V(s, ...) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_ERROR_MESSAGE(s) g_error("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_ERROR_MESSAGE_V(s, ...) g_error("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#elif defined NVGST_LOG_LEVEL_WARNING
|
||||
#define NVGST_ENTER_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION_VIA(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_WARNING_MESSAGE(s) g_warning("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_WARNING_MESSAGE_V(s, ...) g_warning("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#define NVGST_CRITICAL_MESSAGE(s) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_CRITICAL_MESSAGE_V(s, ...) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_ERROR_MESSAGE(s) g_error("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_ERROR_MESSAGE_V(s, ...) g_error("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#elif defined NVGST_LOG_LEVEL_CRITICAL
|
||||
#define NVGST_ENTER_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION_VIA(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_WARNING_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_WARNING_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_CRITICAL_MESSAGE(s) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_CRITICAL_MESSAGE_V(s, ...) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_ERROR_MESSAGE(s) g_error("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_ERROR_MESSAGE_V(s, ...) g_error("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#else
|
||||
#define NVGST_ENTER_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION_VIA(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_WARNING_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_WARNING_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_CRITICAL_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_CRITICAL_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_ERROR_MESSAGE(s) g_error("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_ERROR_MESSAGE_V(s, ...) g_error("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#endif
|
||||
#define INVALID_SELECTION_ARGUS "Not a valid option for ARGUS Plugin\n"
|
||||
|
||||
/* CAMERA KPI PARAMS */
|
||||
typedef enum
|
||||
{
|
||||
FIRST_FRAME = 0,
|
||||
APP_LAUNCH,
|
||||
CURRENT_EVENT,
|
||||
KPI_EVENT_SIZE,
|
||||
} KpiEvents;
|
||||
|
||||
/* CAMERA AUTOMATION PARAMS */
|
||||
typedef struct
|
||||
{
|
||||
gint capture_start_time;
|
||||
gint quit_time;
|
||||
gint iteration_count;
|
||||
gint capture_gap;
|
||||
gint capture_time;
|
||||
gint num_sensors;
|
||||
gboolean automate;
|
||||
gboolean toggle_mode;
|
||||
gboolean toggle_sensor;
|
||||
gboolean toggle_sensor_modes;
|
||||
gboolean enum_wb;
|
||||
gboolean enum_st;
|
||||
gboolean capture_auto;
|
||||
} Automate;
|
||||
|
||||
/* PREVIEW RESOLUTION */
|
||||
typedef enum
|
||||
{
|
||||
PR_176x144 = 0,
|
||||
PR_320x240,
|
||||
PR_640x480,
|
||||
PR_1280x720,
|
||||
PR_1920x1080,
|
||||
PR_2104x1560,
|
||||
PR_2592x1944,
|
||||
PR_2616x1472,
|
||||
PR_3840x2160,
|
||||
PR_3896x2192,
|
||||
PR_4208x3120,
|
||||
PR_5632x3168,
|
||||
PR_5632x4224,
|
||||
} Prev_Res;
|
||||
|
||||
/* IMAGE CAPTURE RESOLUTION */
|
||||
typedef enum
|
||||
{
|
||||
IR_176x144 = 0,
|
||||
IR_320x240,
|
||||
IR_640x480,
|
||||
IR_1280x720,
|
||||
IR_1920x1080,
|
||||
IR_2104x1560,
|
||||
IR_2592x1944,
|
||||
IR_2616x1472,
|
||||
IR_3840x2160,
|
||||
IR_3896x2192,
|
||||
IR_4208x3120,
|
||||
IR_5632x3168,
|
||||
IR_5632x4224,
|
||||
} Icap_Res;
|
||||
|
||||
/* VIDEO CAPTURE RESOLUTION */
|
||||
typedef enum
|
||||
{
|
||||
VR_176x144 = 0,
|
||||
VR_320x240,
|
||||
VR_640x480,
|
||||
VR_1280x720,
|
||||
VR_1920x1080,
|
||||
VR_2104x1560,
|
||||
VR_2592x1944,
|
||||
VR_2616x1472,
|
||||
VR_3840x2160,
|
||||
VR_3896x2192,
|
||||
VR_4208x3120,
|
||||
VR_5632x3168,
|
||||
VR_5632x4224,
|
||||
} Vcap_Res;
|
||||
|
||||
#define RESOLUTION_STRINGS {"176 x 144", "320 x 240", "640 x 480", \
|
||||
"1280 x 720", "1920 x 1080", "2104 x 1560", "2592 x 1944", \
|
||||
"2616 x 1472", "3840 x 2160", "3896 x 2192", "4208 x 3120", \
|
||||
"5632 x 3168", "5632 x 4224", NULL};
|
||||
|
||||
/* CAPTURE CONTAINER TYPE */
|
||||
typedef enum
|
||||
{
|
||||
FILE_MP4 = 0,
|
||||
FILE_3GP,
|
||||
FILE_MKV,
|
||||
FILE_H265
|
||||
} FileType;
|
||||
|
||||
#define FILE_TYPE_STRINGS {"MP4", "3GP", "MKV", "H.265", NULL};
|
||||
|
||||
/* IMAGE ENCODE TYPE */
|
||||
typedef enum
|
||||
{
|
||||
FORMAT_JPEG_SW = 0,
|
||||
FORMAT_JPEG_HW
|
||||
} ImageEncFormatType;
|
||||
|
||||
#define IMAGE_ENCODER_STRINGS {"SW JPEG", "HW JPEG", NULL};
|
||||
|
||||
/* VIDEO ENCODE TYPE */
|
||||
typedef enum
|
||||
{
|
||||
FORMAT_H264_HW = 0,
|
||||
FORMAT_VP8_HW,
|
||||
FORMAT_H265_HW,
|
||||
FORMAT_VP9_HW,
|
||||
FORMAT_H264_SW
|
||||
} VideoEncFormatType;
|
||||
|
||||
#define VIDEO_ENC_STRINGS {"H.264 (HW)", "VP8 (HW)", "H.265 (HW)", "VP9 (HW)", "H264 (SW)", NULL};
|
||||
|
||||
/* H264 ENCODE PROFILE TYPE */
|
||||
typedef enum
|
||||
{
|
||||
PROFILE_BASELINE = 0,
|
||||
PROFILE_MAIN,
|
||||
PROFILE_HIGH
|
||||
} H264EncProfileType;
|
||||
|
||||
/* ENCODER BITRATE CONTROL METHOD */
|
||||
typedef enum
|
||||
{
|
||||
CONTROLRATE_DISABLE,
|
||||
CONTROLRATE_VARIABLE,
|
||||
CONTROLRATE_CONSTANT
|
||||
} EncControlRateType;
|
||||
|
||||
/* CAPTURE MODE */
|
||||
typedef enum
|
||||
{
|
||||
CAPTURE_NONE = 0,
|
||||
CAPTURE_IMAGE,
|
||||
CAPTURE_VIDEO
|
||||
} CaptureType;
|
||||
|
||||
/* CAPTURE COLOR FORMAT */
|
||||
typedef enum
|
||||
{
|
||||
CAPTURE_I420,
|
||||
CAPTURE_NV12,
|
||||
CAPTURE_YUY2,
|
||||
CAPTURE_UYVY,
|
||||
} CaptureColorFormat;
|
||||
|
||||
/* CAPTURE PAD TYPE */
|
||||
typedef enum
|
||||
{
|
||||
CAPTURE_PAD_PREV = 0,
|
||||
CAPTURE_PAD_IMAGE,
|
||||
CAPTURE_PAD_VIDEO
|
||||
} CapturePadType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NV_CAM_SRC_V4L2,
|
||||
NV_CAM_SRC_CSI,
|
||||
NV_CAM_SRC_TEST,
|
||||
NV_CAM_SRC_EGLSTREAM
|
||||
} NvCamSrcType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HW_V4L2_ENC = 1
|
||||
} HardwareEncoderType;
|
||||
|
||||
/* CAMERA CAPTURE RESOLUTIONS */
|
||||
typedef struct
|
||||
{
|
||||
gint preview_width;
|
||||
gint preview_height;
|
||||
gint cus_prev_width;
|
||||
gint cus_prev_height;
|
||||
gint prev_res_index;
|
||||
gint image_cap_width;
|
||||
gint image_cap_height;
|
||||
gint img_res_index;
|
||||
gint video_cap_width;
|
||||
gint video_cap_height;
|
||||
gint vid_res_index;
|
||||
gint current_max_res;
|
||||
} CamRes;
|
||||
|
||||
/* CAMERA ENCODER PARAMS */
|
||||
typedef struct
|
||||
{
|
||||
gint image_enc;
|
||||
VideoEncFormatType video_enc;
|
||||
HardwareEncoderType hw_enc_type;
|
||||
guint bitrate;
|
||||
gboolean enabletwopassCBR;
|
||||
EncControlRateType controlrate;
|
||||
H264EncProfileType video_enc_profile;
|
||||
} EncSet;
|
||||
|
||||
/* CAPTURE PIPELINE ELEMENTS */
|
||||
typedef struct
|
||||
{
|
||||
GstElement *camera;
|
||||
GstElement *vsrc;
|
||||
GstElement *vsink;
|
||||
GstElement *colorspace_conv;
|
||||
GstElement *cap_filter;
|
||||
GstElement *cap_tee;
|
||||
GstElement *prev_q;
|
||||
GstElement *ienc_q;
|
||||
GstElement *venc_q;
|
||||
GstElement *vid_enc;
|
||||
GstElement *img_enc;
|
||||
GstElement *img_enc_conv;
|
||||
GstElement *parser;
|
||||
GstElement *muxer;
|
||||
GstElement *img_sink;
|
||||
GstElement *video_sink;
|
||||
GstElement *capbin;
|
||||
GstElement *vid_bin;
|
||||
GstElement *img_bin;
|
||||
GstElement *svsbin;
|
||||
GstElement *vid_enc_conv;
|
||||
GstElement *vid_enc_cap_filter;
|
||||
|
||||
/* Elements for EGLStreamProducer */
|
||||
GstElement *eglproducer_pipeline;
|
||||
GstElement *eglproducer_bin;
|
||||
GstElement *eglproducer_videosink;
|
||||
GstElement *eglproducer_nvvideosink;
|
||||
GstElement *eglproducer_videotestsrc;
|
||||
GstElement *eglproducer_capsfilter;
|
||||
GstElement *eglproducer_videoconvert;
|
||||
|
||||
/* Scaling elements for preview, image and video */
|
||||
GstElement *svc_prebin;
|
||||
GstElement *svc_prevconv;
|
||||
GstElement *svc_prevconv_out_filter;
|
||||
GstElement *svc_imgbin;
|
||||
GstElement *svc_imgvconv;
|
||||
GstElement *svc_imgvconv_out_filter;
|
||||
GstElement *svc_vidbin;
|
||||
GstElement *svc_vidvconv;
|
||||
GstElement *svc_vidvconv_out_filter;
|
||||
|
||||
/* Elements for video snapshot */
|
||||
GstElement *vsnap_q;
|
||||
GstElement *vsnap_bin;
|
||||
GstElement *vsnap_enc;
|
||||
GstElement *vsnap_sink;
|
||||
GstElement *svc_snapconv;
|
||||
GstElement *svc_snapconv_out_filter;
|
||||
} CamPipe;
|
||||
|
||||
#ifdef WITH_STREAMING
|
||||
typedef struct
|
||||
{
|
||||
GObject *media_factory;
|
||||
GstElement *appsrc;
|
||||
GstElement *streaming_file_src_conv;
|
||||
gchar *streaming_src_file;
|
||||
} RTSPStreamingCtx;
|
||||
#endif
|
||||
|
||||
/* EGLStream Producer ID */
|
||||
typedef enum
|
||||
{
|
||||
EGLSTREAM_PRODUCER_ID_SCF_CAMERA = 0,
|
||||
EGLSTREAM_PRODUCER_ID_MAX,
|
||||
} EGLStream_Producer_ID;
|
||||
|
||||
/* CAMERA CONTEX PARAMS */
|
||||
typedef struct
|
||||
{
|
||||
gint mode;
|
||||
gint file_type;
|
||||
gint capture_count;
|
||||
gint return_value;
|
||||
gint capcount;
|
||||
gint color_format;
|
||||
gint color_format_csi;
|
||||
gint color_format_v4l2;
|
||||
gboolean muxer_is_identity;
|
||||
|
||||
/*CSI camera features */
|
||||
gint whitebalance;
|
||||
gint ae_antibanding;
|
||||
gint tnr_mode;
|
||||
gint ee_mode;
|
||||
gint timeout;
|
||||
gfloat saturation;
|
||||
gfloat exposure_compensation;
|
||||
gfloat tnr_strength;
|
||||
gfloat ee_strength;
|
||||
guint sensor_id;
|
||||
guint sensor_mode;
|
||||
guint framerate;
|
||||
guint flip_method;
|
||||
guint display_id;
|
||||
guint overlay_index;
|
||||
guint overlay_x_pos;
|
||||
guint overlay_y_pos;
|
||||
guint overlay_width;
|
||||
guint overlay_height;
|
||||
|
||||
GstPadProbeReturn native_record;
|
||||
|
||||
gchar *svs;
|
||||
gchar *file_name;
|
||||
gchar *csi_options_argus;
|
||||
gchar *csi_resolution;
|
||||
gchar *usb_options;
|
||||
gchar *encoder_options;
|
||||
gchar *vidcap_device;
|
||||
gchar *cap_dev_node;
|
||||
gchar *overlayConfig;
|
||||
gchar *eglConfig;
|
||||
gchar *exposure_timerange;
|
||||
gchar *gain_range;
|
||||
gchar *isp_digital_gainrange;
|
||||
|
||||
NvCamSrcType cam_src;
|
||||
gboolean cap_success;
|
||||
gboolean use_cus_res;
|
||||
gboolean use_eglstream;
|
||||
|
||||
gboolean first_frame;
|
||||
time_t timeStampStore[KPI_EVENT_SIZE];
|
||||
struct timeval timeStamp;
|
||||
gboolean enableKpiProfile;
|
||||
gboolean enableKpiNumbers;
|
||||
gboolean enableMeta;
|
||||
gboolean enableAeLock;
|
||||
gboolean enableAwbLock;
|
||||
gulong prev_probe_id;
|
||||
gulong enc_probe_id;
|
||||
time_t currentFrameTime;
|
||||
time_t prevFrameTime;
|
||||
gulong frameCount;
|
||||
time_t accumulator;
|
||||
time_t currentEncFrameTime;
|
||||
time_t prevEncFrameTime;
|
||||
gulong encFrameCount;
|
||||
time_t encAccumulator;
|
||||
|
||||
GMutex *lock;
|
||||
GCond *cond;
|
||||
GCond *x_cond;
|
||||
GThread *reset_thread;
|
||||
GThread *x_event_thread;
|
||||
|
||||
CamRes capres;
|
||||
EncSet encset;
|
||||
CamPipe ele;
|
||||
displayCtx disp;
|
||||
|
||||
/* EGLStream */
|
||||
EGLStream_Producer_ID eglstream_producer_id;
|
||||
EGLDisplay display;
|
||||
EGLStreamKHR stream;
|
||||
|
||||
/* EGLStream Producer */
|
||||
guint fifosize;
|
||||
gboolean enable_fifo;
|
||||
|
||||
/* AUTOMATION */
|
||||
Automate aut;
|
||||
|
||||
#ifdef WITH_STREAMING
|
||||
gint streaming_mode;
|
||||
RTSPStreamingCtx video_streaming_ctx;
|
||||
#endif
|
||||
} CamCtx;
|
||||
|
||||
#endif
|
||||
|
||||
20
nvgstapps_src/nvgst_sample_apps/nvgstipctestapp-1.0/LICENSE
Normal file
20
nvgstapps_src/nvgst_sample_apps/nvgstipctestapp-1.0/LICENSE
Normal file
@@ -0,0 +1,20 @@
|
||||
SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
SPDX-License-Identifier: MIT
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,111 @@
|
||||
################################################################################
|
||||
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
################################################################################
|
||||
|
||||
SRC:=nvgstipctestapp.c
|
||||
|
||||
PKGS := gstreamer-1.0 \
|
||||
gstreamer-base-1.0 \
|
||||
gstreamer-video-1.0 \
|
||||
gstreamer-allocators-1.0 \
|
||||
gstreamer-audio-1.0 \
|
||||
gstreamer-app-1.0 \
|
||||
glib-2.0 \
|
||||
gobject-2.0 \
|
||||
gthread-2.0 \
|
||||
gmodule-2.0 \
|
||||
|
||||
# Clear the flags from env
|
||||
CFLAGS :=
|
||||
LDFLAGS :=
|
||||
|
||||
# Verbose flag
|
||||
ifeq ($(VERBOSE), 1)
|
||||
AT =
|
||||
else
|
||||
AT = @
|
||||
endif
|
||||
|
||||
# ARM ABI of the target platform
|
||||
ifeq ($(TEGRA_ARMABI),)
|
||||
TEGRA_ARMABI ?= aarch64-linux-gnu
|
||||
endif
|
||||
|
||||
# Location of the target rootfs
|
||||
ifeq ($(shell uname -m), aarch64)
|
||||
TARGET_ROOTFS :=
|
||||
else
|
||||
ifeq ($(TARGET_ROOTFS),)
|
||||
$(error Please specify the target rootfs path if you are cross-compiling)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(shell uname -m), aarch64)
|
||||
CROSS_COMPILE :=
|
||||
else
|
||||
CROSS_COMPILE ?= aarch64-unknown-linux-gnu-
|
||||
endif
|
||||
AS = $(AT) $(CROSS_COMPILE)as
|
||||
LD = $(AT) $(CROSS_COMPILE)ld
|
||||
CC = $(AT) $(CROSS_COMPILE)gcc
|
||||
AR = $(AT) $(CROSS_COMPILE)ar
|
||||
NM = $(AT) $(CROSS_COMPILE)nm
|
||||
STRIP = $(AT) $(CROSS_COMPILE)strip
|
||||
OBJCOPY = $(AT) $(CROSS_COMPILE)objcopy
|
||||
OBJDUMP = $(AT) $(CROSS_COMPILE)objdump
|
||||
|
||||
# Specify the logical root directory for headers and libraries.
|
||||
ifneq ($(TARGET_ROOTFS),)
|
||||
LDFLAGS += \
|
||||
-Wl,-rpath-link=$(TARGET_ROOTFS)/usr/lib \
|
||||
-Wl,-rpath-link=$(TARGET_ROOTFS)/lib/$(TEGRA_ARMABI) \
|
||||
-Wl,-rpath-link=$(TARGET_ROOTFS)/usr/lib/$(TEGRA_ARMABI)/gstreamer-1.0
|
||||
endif
|
||||
|
||||
# All common dependent libraries
|
||||
LDFLAGS += \
|
||||
-lpthread \
|
||||
-lm \
|
||||
-ldl \
|
||||
-L"$(TARGET_ROOTFS)/usr/lib" \
|
||||
-L"$(TARGET_ROOTFS)/usr/lib/$(TEGRA_ARMABI)" \
|
||||
-L"$(TARGET_ROOTFS)/usr/lib/$(TEGRA_ARMABI)/gstreamer-1.0"
|
||||
|
||||
OBJS := $(SRC:.c=.o)
|
||||
|
||||
CFLAGS +=`pkg-config --cflags $(PKGS)`
|
||||
LDFLAGS +=`pkg-config --libs $(PKGS)`
|
||||
|
||||
APP:=nvgstipctestapp-1.0
|
||||
|
||||
all: $(APP)
|
||||
|
||||
%.o: %.c
|
||||
@echo "Compiling: $<"
|
||||
$(CC) -c $< $(CFLAGS) -o $@
|
||||
|
||||
$(APP): $(OBJS)
|
||||
@echo "Linking: $@"
|
||||
$(CC) -o $@ $(OBJS) $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
$(AT)rm -rf $(APP) $(OBJS)
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
NvGstIpcTestApp Usage (command: ./nvgstipctestapp --help)
|
||||
=======
|
||||
=> PREREQUISITES:
|
||||
|
||||
1. You must install GStreamer-1.0 on the target board using apt-get, as follows:
|
||||
|
||||
sudo apt-get install gstreamer1.0-tools gstreamer1.0-alsa gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad gstreamer1.0-libav
|
||||
|
||||
2. Execute the following commands on the target board's Ubuntu command line before starting the player:
|
||||
|
||||
export DISPLAY=:0
|
||||
xinit &
|
||||
|
||||
NvGstIpcTestApp Usage
|
||||
-----------------------------------------------
|
||||
Run with the command line.
|
||||
|
||||
$ nvgstipctestapp server <rtsp_url> <socket_path>
|
||||
$ nvgstipctestapp client <socket_path>
|
||||
e.g.
|
||||
$ nvgstipctestapp server rtsp://127.0.0.1/video1 /tmp/test1
|
||||
$ nvgstipctestapp client /tmp/test1
|
||||
|
||||
This sample act as either server or client based on command line arguments.
|
||||
|
||||
The server accepts H.264/H.265 video stream RTSP URL and IPC socket path
|
||||
as input. It does the decoding of the stream and listens for the connection
|
||||
on the IPC socket path. It sends decoded data over IPC to the connected client.
|
||||
|
||||
The client accepts IPC socket path as input. It sends connection request to the
|
||||
server. Once server accepts the request, it starts receiving the decoded data
|
||||
over IPC which is further pushed into the pipeline.
|
||||
@@ -0,0 +1,549 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MAX_SOURCE_BINS 32
|
||||
|
||||
/* NVIDIA Decoder source pad memory feature. This feature signifies that source
|
||||
* pads having this capability will push GstBuffers containing cuda buffers. */
|
||||
#define GST_CAPS_FEATURES_NVMM "memory:NVMM"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *uri;
|
||||
gchar *socket_path;
|
||||
guint bus_id;
|
||||
GstElement *pipeline;
|
||||
void *appCtx;
|
||||
} NvIpcServerPipeline;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *socket_path[MAX_SOURCE_BINS];
|
||||
guint bus_id;
|
||||
GstElement *pipeline;
|
||||
void *appCtx;
|
||||
} NvIpcClientPipeline;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GMainLoop *loop;
|
||||
NvIpcServerPipeline ipcserver[MAX_SOURCE_BINS];
|
||||
NvIpcClientPipeline ipcclient;
|
||||
gboolean quit;
|
||||
} AppCtx;
|
||||
|
||||
static gboolean
|
||||
bus_call (GstBus * bus, GstMessage * msg, gpointer user_data)
|
||||
{
|
||||
GMainLoop *loop = (GMainLoop *) user_data;
|
||||
switch (GST_MESSAGE_TYPE (msg)) {
|
||||
case GST_MESSAGE_EOS:
|
||||
g_print ("End of stream\n");
|
||||
g_main_loop_quit (loop);
|
||||
break;
|
||||
case GST_MESSAGE_WARNING:
|
||||
{
|
||||
gchar *debug;
|
||||
GError *error;
|
||||
gst_message_parse_warning (msg, &error, &debug);
|
||||
g_printerr ("WARNING from element %s: %s\n",
|
||||
GST_OBJECT_NAME (msg->src), error->message);
|
||||
g_free (debug);
|
||||
g_printerr ("Warning: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
break;
|
||||
}
|
||||
case GST_MESSAGE_ERROR:
|
||||
{
|
||||
gchar *debug;
|
||||
GError *error;
|
||||
gst_message_parse_error (msg, &error, &debug);
|
||||
g_printerr ("ERROR from element %s: %s\n",
|
||||
GST_OBJECT_NAME (msg->src), error->message);
|
||||
if (debug)
|
||||
g_printerr ("Error details: %s\n", debug);
|
||||
g_free (debug);
|
||||
g_error_free (error);
|
||||
g_main_loop_quit (loop);
|
||||
break;
|
||||
}
|
||||
case GST_MESSAGE_STATE_CHANGED:{
|
||||
GstState oldstate, newstate;
|
||||
gst_message_parse_state_changed (msg, &oldstate, &newstate, NULL);
|
||||
switch (newstate) {
|
||||
case GST_STATE_PLAYING:
|
||||
g_print ("Pipeline running\n");
|
||||
break;
|
||||
case GST_STATE_PAUSED:
|
||||
if (oldstate == GST_STATE_PLAYING) {
|
||||
g_print ("Pipeline paused\n");
|
||||
}
|
||||
break;
|
||||
case GST_STATE_READY:
|
||||
if (oldstate == GST_STATE_NULL) {
|
||||
g_print ("Pipeline ready\n");
|
||||
} else {
|
||||
g_print ("Pipeline stopped\n");
|
||||
}
|
||||
break;
|
||||
case GST_STATE_NULL:
|
||||
g_print ("Pipeline Null\n");
|
||||
g_main_loop_quit (loop);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
cb_newpad (GstElement * decodebin, GstPad * decoder_src_pad, gpointer data)
|
||||
{
|
||||
GstCaps *caps = gst_pad_get_current_caps (decoder_src_pad);
|
||||
if (!caps) {
|
||||
caps = gst_pad_query_caps (decoder_src_pad, NULL);
|
||||
}
|
||||
const GstStructure *str = gst_caps_get_structure (caps, 0);
|
||||
const gchar *name = gst_structure_get_name (str);
|
||||
GstElement *source_bin = (GstElement *) data;
|
||||
GstCapsFeatures *features = gst_caps_get_features (caps, 0);
|
||||
|
||||
/* Need to check if the pad created by the decodebin is for video and not
|
||||
* audio. */
|
||||
if (!strncmp (name, "video", 5)) {
|
||||
/* Link the decodebin pad only if decodebin has picked nvidia
|
||||
* decoder plugin nvdec_*. We do this by checking if the pad caps contain
|
||||
* NVMM memory features. */
|
||||
if (gst_caps_features_contains (features, GST_CAPS_FEATURES_NVMM)) {
|
||||
/* Get the source bin ghost pad */
|
||||
GstPad *bin_ghost_pad = gst_element_get_static_pad (source_bin, "src");
|
||||
if (!gst_ghost_pad_set_target (GST_GHOST_PAD (bin_ghost_pad),
|
||||
decoder_src_pad)) {
|
||||
g_printerr ("Failed to link decoder src pad to source bin ghost pad\n");
|
||||
}
|
||||
gst_object_unref (bin_ghost_pad);
|
||||
} else {
|
||||
g_printerr ("Error: Decodebin did not pick nvidia decoder plugin.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
decodebin_child_added (GstChildProxy * child_proxy, GObject * object,
|
||||
gchar * name, gpointer user_data)
|
||||
{
|
||||
g_print ("Decodebin child added: %s\n", name);
|
||||
if (g_strrstr (name, "decodebin") == name) {
|
||||
g_signal_connect (G_OBJECT (object), "child-added",
|
||||
G_CALLBACK (decodebin_child_added), user_data);
|
||||
}
|
||||
}
|
||||
|
||||
static GstElement *
|
||||
create_source_bin (guint index, gchar * uri)
|
||||
{
|
||||
GstElement *bin = NULL, *uri_decode_bin = NULL;
|
||||
gchar bin_name[16] = { };
|
||||
|
||||
g_snprintf (bin_name, 15, "source-bin-%02d", index);
|
||||
/* Create a source GstBin to abstract this bin's content from the rest of the
|
||||
* pipeline */
|
||||
bin = gst_bin_new (bin_name);
|
||||
|
||||
/* Source element for reading from the uri.
|
||||
* We will use decodebin and let it figure out the container format of the
|
||||
* stream and the codec and plug the appropriate demux and decode plugins. */
|
||||
uri_decode_bin = gst_element_factory_make ("uridecodebin", NULL);
|
||||
|
||||
if (!bin || !uri_decode_bin) {
|
||||
g_printerr ("One element in source bin could not be created.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We set the input uri to the source element */
|
||||
g_object_set (G_OBJECT (uri_decode_bin), "uri", uri, NULL);
|
||||
|
||||
/* Connect to the "pad-added" signal of the decodebin which generates a
|
||||
* callback once a new pad for raw data has beed created by the decodebin */
|
||||
g_signal_connect (G_OBJECT (uri_decode_bin), "pad-added",
|
||||
G_CALLBACK (cb_newpad), bin);
|
||||
g_signal_connect (G_OBJECT (uri_decode_bin), "child-added",
|
||||
G_CALLBACK (decodebin_child_added), bin);
|
||||
|
||||
gst_bin_add (GST_BIN (bin), uri_decode_bin);
|
||||
|
||||
/* We need to create a ghost pad for the source bin which will act as a proxy
|
||||
* for the video decoder src pad. The ghost pad will not have a target right
|
||||
* now. Once the decode bin creates the video decoder and generates the
|
||||
* cb_newpad callback, we will set the ghost pad target to the video decoder
|
||||
* src pad. */
|
||||
if (!gst_element_add_pad (bin, gst_ghost_pad_new_no_target ("src",
|
||||
GST_PAD_SRC))) {
|
||||
g_printerr ("Failed to add ghost pad in source bin\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return bin;
|
||||
}
|
||||
|
||||
static GstElement *
|
||||
create_ipc_source_bin (NvIpcClientPipeline *ipcclient, guint index, gchar *socket_path)
|
||||
{
|
||||
GstElement *bin = NULL, *nvunixfdsrc = NULL, *capsfilter = NULL, *queue = NULL;
|
||||
GstPad *source_pad = NULL, *ghost_sourcepad = NULL;
|
||||
gchar bin_name[16] = { };
|
||||
|
||||
ipcclient->socket_path[index] = strdup(socket_path);
|
||||
|
||||
g_snprintf (bin_name, 15, "source-bin-%02d", index);
|
||||
/* Create a source GstBin to abstract this bin's content from the rest of the
|
||||
* pipeline */
|
||||
bin = gst_bin_new (bin_name);
|
||||
|
||||
nvunixfdsrc = gst_element_factory_make ("nvunixfdsrc", NULL);
|
||||
capsfilter = gst_element_factory_make ("capsfilter", NULL);
|
||||
queue = gst_element_factory_make ("queue", NULL);
|
||||
if (!bin || !nvunixfdsrc || !capsfilter || !queue) {
|
||||
g_printerr ("One element in source bin could not be created.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GstCaps* caps = gst_caps_new_simple ("video/x-raw",
|
||||
"format", G_TYPE_STRING, "NV12", NULL);
|
||||
GstCapsFeatures *feature = NULL;
|
||||
feature = gst_caps_features_new ("memory:NVMM", NULL);
|
||||
gst_caps_set_features (caps, 0, feature);
|
||||
g_object_set (G_OBJECT (capsfilter), "caps", caps, NULL);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
g_object_set (G_OBJECT(nvunixfdsrc), "socket-path", ipcclient->socket_path[index], NULL);
|
||||
g_object_set (G_OBJECT(nvunixfdsrc), "buffer-timestamp-copy", TRUE, NULL);
|
||||
|
||||
gst_bin_add_many (GST_BIN (bin), nvunixfdsrc, capsfilter, queue, NULL);
|
||||
|
||||
if (!gst_element_link_many(nvunixfdsrc, capsfilter, queue, NULL)) {
|
||||
g_printerr ("Failed to link in source bin\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
source_pad = gst_element_get_static_pad (queue, "src");
|
||||
ghost_sourcepad = gst_ghost_pad_new ("src", source_pad);
|
||||
gst_pad_set_active (ghost_sourcepad, TRUE);
|
||||
if (!gst_element_add_pad (bin, ghost_sourcepad)) {
|
||||
g_printerr ("Failed to add ghost pad in source bin\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_object_unref (source_pad);
|
||||
|
||||
return bin;
|
||||
}
|
||||
|
||||
static int
|
||||
create_client_pipeline (int argc, char *argv[])
|
||||
{
|
||||
AppCtx appCtx;
|
||||
GMainLoop *loop = NULL;
|
||||
GstElement *pipeline = NULL, *compositor = NULL, *sink = NULL, *fpssink = NULL;
|
||||
GstBus *bus = NULL;
|
||||
guint bus_watch_id;
|
||||
guint i =0, num_sources = 0;
|
||||
guint tiler_rows, tiler_columns, tiler_row, tiler_xpos, tiler_ypos,
|
||||
tiler_column, tiler_width, tiler_height;
|
||||
gboolean PERF_MODE = g_getenv("NV_IPC_TEST_PERF_MODE") &&
|
||||
!g_strcmp0(g_getenv("NV_IPC_TEST_PERF_MODE"), "1");
|
||||
|
||||
memset(&appCtx, 0, sizeof(AppCtx));
|
||||
appCtx.loop = loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
/* Create gstreamer elements */
|
||||
pipeline = gst_pipeline_new (NULL);
|
||||
|
||||
compositor = gst_element_factory_make ("nvcompositor", NULL);
|
||||
g_object_set (G_OBJECT (compositor), "start-time-selection", 1, NULL);
|
||||
|
||||
if (!pipeline || !compositor) {
|
||||
g_printerr ("One element could not be created. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
gst_bin_add (GST_BIN (pipeline), compositor);
|
||||
|
||||
num_sources = argc - 2;
|
||||
tiler_row = 0;
|
||||
tiler_column = 0;
|
||||
tiler_rows = (guint) round (sqrt (num_sources));
|
||||
tiler_columns = (guint) ceil (1.0 * num_sources / tiler_rows);
|
||||
tiler_width = 1920/tiler_columns;
|
||||
tiler_height = 1080/tiler_columns;
|
||||
g_print("rows %d columns %d width %d height %d\n", tiler_rows, tiler_columns, tiler_width, tiler_height);
|
||||
|
||||
for (i = 0; i < num_sources; i++) {
|
||||
GstPad *sinkpad, *srcpad;
|
||||
gchar pad_name[16] = { };
|
||||
|
||||
GstElement *source_bin= NULL;
|
||||
source_bin = create_ipc_source_bin (&appCtx.ipcclient, i, argv[i + 2]);
|
||||
if (!source_bin) {
|
||||
g_printerr ("Failed to create source bin. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
gst_bin_add (GST_BIN (pipeline), source_bin);
|
||||
|
||||
g_snprintf (pad_name, 15, "sink_%u", i);
|
||||
sinkpad = gst_element_request_pad_simple (compositor, pad_name);
|
||||
if (!sinkpad) {
|
||||
g_printerr ("compositor request sink pad failed. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
srcpad = gst_element_get_static_pad (source_bin, "src");
|
||||
if (!srcpad) {
|
||||
g_printerr ("Failed to get src pad of source bin. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK) {
|
||||
g_printerr ("Failed to link source bin to stream muxer. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tiler_xpos = (tiler_column * tiler_width);
|
||||
tiler_ypos = (tiler_row * tiler_height);
|
||||
g_print("xpos %d ypos %d width %d height %d\n", tiler_xpos, tiler_ypos, tiler_width, tiler_height);
|
||||
|
||||
if (tiler_column < tiler_columns - 1) {
|
||||
tiler_column++;
|
||||
} else {
|
||||
tiler_row++;
|
||||
tiler_column = 0;
|
||||
}
|
||||
|
||||
g_object_set (sinkpad, "xpos", tiler_xpos, NULL);
|
||||
g_object_set (sinkpad, "ypos", tiler_ypos, NULL);
|
||||
g_object_set (sinkpad, "width", tiler_width, NULL);
|
||||
g_object_set (sinkpad, "height", tiler_height, NULL);
|
||||
|
||||
gst_object_unref (srcpad);
|
||||
gst_object_unref (sinkpad);
|
||||
}
|
||||
|
||||
fpssink = gst_element_factory_make ("fpsdisplaysink", NULL);
|
||||
if (!fpssink) {
|
||||
g_printerr ("One element could not be created. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PERF_MODE)
|
||||
sink = gst_element_factory_make ("fakesink", NULL);
|
||||
else
|
||||
sink = gst_element_factory_make ("nv3dsink", NULL);
|
||||
if (!sink) {
|
||||
g_printerr ("One element could not be created. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_object_set (G_OBJECT (sink), "sync", FALSE, NULL);
|
||||
g_object_set (G_OBJECT (fpssink), "text-overlay", FALSE, "sync", FALSE, "video-sink", sink, NULL);
|
||||
|
||||
/* we add a message handler */
|
||||
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
||||
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
|
||||
gst_object_unref (bus);
|
||||
|
||||
gst_bin_add_many (GST_BIN (pipeline), fpssink, NULL);
|
||||
|
||||
if (!gst_element_link_many (compositor, fpssink, NULL)) {
|
||||
g_printerr ("Elements could not be linked. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PERF_MODE)
|
||||
g_signal_connect(pipeline, "deep-notify", G_CALLBACK( gst_object_default_deep_notify ), NULL );
|
||||
|
||||
/* Set the pipeline to "playing" state */
|
||||
g_print ("Now playing:");
|
||||
for (i = 0; i < num_sources; i++) {
|
||||
g_print (" %s,", argv[i + 2]);
|
||||
}
|
||||
g_print ("\n");
|
||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||
|
||||
/* Wait till pipeline encounters an error or EOS */
|
||||
g_print ("Running...\n");
|
||||
g_main_loop_run (loop);
|
||||
appCtx.quit = TRUE;
|
||||
|
||||
for (i = 0; i < num_sources; i++) {
|
||||
g_free(appCtx.ipcclient.socket_path[i]);
|
||||
}
|
||||
|
||||
/* Out of the main loop, clean up nicely */
|
||||
g_print ("Returned, stopping playback\n");
|
||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||
g_print ("Deleting pipeline\n");
|
||||
gst_object_unref (GST_OBJECT (pipeline));
|
||||
g_source_remove (bus_watch_id);
|
||||
g_main_loop_unref (loop);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
create_server_pipeline (int argc, char *argv[])
|
||||
{
|
||||
AppCtx appCtx;
|
||||
guint i =0, num_sources = 0;
|
||||
num_sources = (argc - 2)/2;
|
||||
GMainLoop *loop = NULL;
|
||||
gboolean PERF_MODE = g_getenv("NV_IPC_TEST_PERF_MODE") &&
|
||||
!g_strcmp0(g_getenv("NV_IPC_TEST_PERF_MODE"), "1");
|
||||
|
||||
memset(&appCtx, 0, sizeof(AppCtx));
|
||||
appCtx.loop = loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
for (i = 0; i < num_sources; i++) {
|
||||
GstElement *pipeline = NULL;
|
||||
GstBus *bus = NULL;
|
||||
guint bus_watch_id;
|
||||
GstElement *source_bin=NULL, *nvunixfdsink= NULL, *fpssink;
|
||||
|
||||
/* Create gstreamer elements */
|
||||
appCtx.ipcserver[i].pipeline = pipeline = gst_pipeline_new (NULL);
|
||||
if (!pipeline) {
|
||||
g_printerr ("Failed to create pipeline. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
source_bin = create_source_bin (i, argv[(i*2) + 2]);
|
||||
if (!source_bin) {
|
||||
g_printerr ("Failed to create source bin. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
gst_bin_add (GST_BIN (pipeline), source_bin);
|
||||
appCtx.ipcserver[i].uri = strdup(argv[(i*2) + 2]);
|
||||
|
||||
appCtx.ipcserver[i].socket_path = strdup(argv[(i*2) + 3]);
|
||||
nvunixfdsink = gst_element_factory_make ("nvunixfdsink", NULL);
|
||||
if (!nvunixfdsink) {
|
||||
g_printerr ("Failed to create nvunixfdsink. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
fpssink = gst_element_factory_make ("fpsdisplaysink", NULL);
|
||||
if (!fpssink) {
|
||||
g_printerr ("Failed to create fpssink. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
gst_bin_add (GST_BIN (pipeline), fpssink);
|
||||
|
||||
g_object_set (G_OBJECT (fpssink), "text-overlay", FALSE, "sync", FALSE, "video-sink", nvunixfdsink, NULL);
|
||||
g_object_set (G_OBJECT(nvunixfdsink), "sync", FALSE, NULL);
|
||||
g_object_set (G_OBJECT(nvunixfdsink), "socket-path", appCtx.ipcserver[i].socket_path, NULL);
|
||||
g_object_set (G_OBJECT(nvunixfdsink), "buffer-timestamp-copy", TRUE, NULL);
|
||||
|
||||
/* link the elements together */
|
||||
if (!gst_element_link_many (source_bin, fpssink, NULL)) {
|
||||
g_printerr ("Elements could not be linked. Exiting.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* we add a message handler */
|
||||
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
||||
appCtx.ipcserver[i].bus_id = bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
|
||||
gst_object_unref (bus);
|
||||
|
||||
appCtx.ipcserver[i].appCtx = &appCtx;
|
||||
if (PERF_MODE)
|
||||
g_signal_connect(pipeline, "deep-notify", G_CALLBACK(gst_object_default_deep_notify), NULL);
|
||||
}
|
||||
|
||||
/* Set the pipeline to "playing" state */
|
||||
g_print ("Now playing:");
|
||||
|
||||
for (i = 0; i < num_sources; i++) {
|
||||
gst_element_set_state (appCtx.ipcserver[i].pipeline, GST_STATE_PLAYING);
|
||||
g_print("server is started uri: %s path: %s\n",
|
||||
appCtx.ipcserver[i].uri, appCtx.ipcserver[i].socket_path);
|
||||
}
|
||||
|
||||
/* Wait till pipeline encounters an error or EOS */
|
||||
g_print ("Running...\n");
|
||||
g_main_loop_run (loop);
|
||||
appCtx.quit = TRUE;
|
||||
|
||||
/* Out of the main loop, clean up nicely */
|
||||
g_print ("Returned, stopping playback\n");
|
||||
g_print ("Deleting pipeline\n");
|
||||
for (i = 0; i < num_sources; i++) {
|
||||
gst_element_set_state (appCtx.ipcserver[i].pipeline, GST_STATE_NULL);
|
||||
gst_object_unref (GST_OBJECT (appCtx.ipcserver[i].pipeline));
|
||||
g_source_remove (appCtx.ipcserver[i].bus_id);
|
||||
g_print("server is closed uri: %s path: %s\n",
|
||||
appCtx.ipcserver[i].uri, appCtx.ipcserver[i].socket_path);
|
||||
g_free(appCtx.ipcserver[i].uri);
|
||||
g_free(appCtx.ipcserver[i].socket_path);
|
||||
}
|
||||
|
||||
g_main_loop_unref (loop);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* Check input arguments */
|
||||
if (argc < 3) {
|
||||
g_printerr ("Usage: %s <server> <rtsp_url> <socket_path>\n", argv[0]);
|
||||
g_printerr ("OR: %s <client> <socket_path> \n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Standard GStreamer initialization */
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
if (strcmp(argv[1], "client") == 0) {
|
||||
ret = create_client_pipeline(argc, argv);
|
||||
} else {
|
||||
ret = create_server_pipeline(argc, argv);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2021 NVIDIA Corporation. All rights reserved.
|
||||
*
|
||||
* NVIDIA Corporation and its licensors retain all intellectual property
|
||||
* and proprietary rights in and to this software, related documentation
|
||||
* and any modifications thereto. Any use, reproduction, disclosure or
|
||||
* distribution of this software and related documentation without an express
|
||||
* license agreement from NVIDIA Corporation is strictly prohibited.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nvgst_asound_common.h"
|
||||
|
||||
char *
|
||||
nvgst_asound_get_device ()
|
||||
{
|
||||
int card_num = -1, device_num = -1;
|
||||
char ctl_name[15];
|
||||
char dev_name[20];
|
||||
snd_ctl_t *ctl;
|
||||
snd_pcm_t *handle;
|
||||
|
||||
if (snd_pcm_open (&handle, "default", SND_PCM_STREAM_PLAYBACK, 0) == 0) {
|
||||
snd_pcm_close (handle);
|
||||
return strdup ("default");
|
||||
}
|
||||
|
||||
while (snd_card_next (&card_num) == 0 && card_num > -1) {
|
||||
snprintf (ctl_name, sizeof(ctl_name)-1, "hw:%d", card_num);
|
||||
ctl_name[sizeof (ctl_name)-1] = '\0';
|
||||
if (snd_ctl_open (&ctl, ctl_name, 0) < 0)
|
||||
continue;
|
||||
device_num = -1;
|
||||
while (snd_ctl_pcm_next_device (ctl, &device_num) == 0 && device_num > -1) {
|
||||
snprintf (dev_name, sizeof(dev_name)-1, "hw:%d,%d", card_num, device_num);
|
||||
dev_name[sizeof (dev_name)-1] = '\0';
|
||||
if (snd_pcm_open (&handle, dev_name, SND_PCM_STREAM_PLAYBACK, 0) == 0) {
|
||||
snd_pcm_close (handle);
|
||||
snd_ctl_close (ctl);
|
||||
return strdup (dev_name);
|
||||
}
|
||||
}
|
||||
snd_ctl_close (ctl);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2015 NVIDIA Corporation. All rights reserved.
|
||||
*
|
||||
* NVIDIA Corporation and its licensors retain all intellectual property
|
||||
* and proprietary rights in and to this software, related documentation
|
||||
* and any modifications thereto. Any use, reproduction, disclosure or
|
||||
* distribution of this software and related documentation without an express
|
||||
* license agreement from NVIDIA Corporation is strictly prohibited.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char * nvgst_asound_get_device (void);
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2011-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "nvgst_x11_common.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
Display *
|
||||
nvgst_x11_init (displayCtx * dpyCtx)
|
||||
{
|
||||
dpyCtx->isDPMSdisabled = 0;
|
||||
dpyCtx->mDisplay = XOpenDisplay (NULL);
|
||||
if (!dpyCtx->mDisplay)
|
||||
printf
|
||||
("\nCannot open display specified with DISPLAY environment variable\n");
|
||||
return dpyCtx->mDisplay;
|
||||
}
|
||||
|
||||
void
|
||||
nvgst_x11_uninit (displayCtx * dpyCtx)
|
||||
{
|
||||
if (dpyCtx->window)
|
||||
XDestroyWindow (dpyCtx->mDisplay, dpyCtx->window);
|
||||
XCloseDisplay (dpyCtx->mDisplay);
|
||||
dpyCtx->mDisplay = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
saver_off (displayCtx * dpyCtx)
|
||||
{
|
||||
int nothing;
|
||||
if (DPMSQueryExtension (dpyCtx->mDisplay, ¬hing, ¬hing)) {
|
||||
BOOL enabled = false;
|
||||
CARD16 powerLevel;
|
||||
|
||||
DPMSInfo (dpyCtx->mDisplay, &powerLevel, &enabled);
|
||||
if (enabled) {
|
||||
DPMSDisable (dpyCtx->mDisplay);
|
||||
DPMSInfo (dpyCtx->mDisplay, &powerLevel, &enabled);
|
||||
if (enabled) {
|
||||
printf ("\ncould not disable DPMS\n");
|
||||
}
|
||||
} else {
|
||||
printf ("\nDPMS already DISABLED\n");
|
||||
dpyCtx->isDPMSdisabled = 1;
|
||||
}
|
||||
} else
|
||||
printf ("\nserver does not have extension for -dpms option\n");
|
||||
}
|
||||
|
||||
void
|
||||
saver_on (displayCtx * dpyCtx)
|
||||
{
|
||||
int nothing;
|
||||
if (DPMSQueryExtension (dpyCtx->mDisplay, ¬hing, ¬hing)) {
|
||||
BOOL enabled = false;
|
||||
CARD16 powerLevel;
|
||||
|
||||
DPMSInfo (dpyCtx->mDisplay, &powerLevel, &enabled);
|
||||
if (!enabled) {
|
||||
if (!dpyCtx->isDPMSdisabled)
|
||||
DPMSEnable (dpyCtx->mDisplay);
|
||||
DPMSInfo (dpyCtx->mDisplay, &powerLevel, &enabled);
|
||||
if (!enabled && !dpyCtx->isDPMSdisabled) {
|
||||
printf ("\ncould not enable DPMS\n");
|
||||
}
|
||||
} else
|
||||
printf ("\nDPMS already ENABLED\n");
|
||||
} else
|
||||
printf ("\nserver does not have extension for -dpms option\n");
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
nvgst_create_window (displayCtx * dpyCtx, char *title)
|
||||
{
|
||||
int screen = 0;
|
||||
XTextProperty xproperty;
|
||||
|
||||
if (dpyCtx->mDisplay) {
|
||||
screen = DefaultScreen (dpyCtx->mDisplay);
|
||||
if (!dpyCtx->width && !dpyCtx->height) {
|
||||
dpyCtx->width = DisplayWidth (dpyCtx->mDisplay, screen);
|
||||
dpyCtx->height = DisplayHeight (dpyCtx->mDisplay, screen);
|
||||
}
|
||||
|
||||
dpyCtx->window = XCreateSimpleWindow (dpyCtx->mDisplay,
|
||||
RootWindow (dpyCtx->mDisplay, screen),
|
||||
dpyCtx->x, dpyCtx->y, dpyCtx->width, dpyCtx->height, 0, 0,
|
||||
BlackPixel (dpyCtx->mDisplay, screen));
|
||||
|
||||
XSetWindowBackgroundPixmap (dpyCtx->mDisplay, dpyCtx->window, None);
|
||||
|
||||
if (title) {
|
||||
if ((XStringListToTextProperty (((char **) &title), 1, &xproperty)) != 0) {
|
||||
XSetWMName (dpyCtx->mDisplay, dpyCtx->window, &xproperty);
|
||||
XFree (xproperty.value);
|
||||
|
||||
}
|
||||
} else
|
||||
printf ("\ncan't set title to window, title NULL\n");
|
||||
|
||||
/* Tell the window manager we'd like delete client messages instead of
|
||||
* being killed */
|
||||
Atom wmDeleteMessage =
|
||||
XInternAtom (dpyCtx->mDisplay, "WM_DELETE_WINDOW", False);
|
||||
if (wmDeleteMessage != None) {
|
||||
XSetWMProtocols (dpyCtx->mDisplay, dpyCtx->window, &wmDeleteMessage, 1);
|
||||
}
|
||||
|
||||
XMapRaised (dpyCtx->mDisplay, dpyCtx->window);
|
||||
|
||||
XSync (dpyCtx->mDisplay, 1); //discard the events for now
|
||||
} else
|
||||
printf ("\ncan't create window, Display NULL\n");
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
nvgst_destroy_window (displayCtx * dpyCtx)
|
||||
{
|
||||
XDestroyWindow (dpyCtx->mDisplay, dpyCtx->window);
|
||||
dpyCtx->window = (Window) NULL;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2011-2015, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/extensions/dpms.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Display *mDisplay;
|
||||
Window window;
|
||||
int width;
|
||||
int height;
|
||||
int x;
|
||||
int y;
|
||||
int isDPMSdisabled;
|
||||
} displayCtx;
|
||||
|
||||
Display *nvgst_x11_init (displayCtx * dpyCtx);
|
||||
void nvgst_x11_uninit (displayCtx * dpyCtx);
|
||||
void saver_off (displayCtx * dpyCtx);
|
||||
void saver_on (displayCtx * dpyCtx);
|
||||
void nvgst_create_window (displayCtx * dpyCtx, char *title);
|
||||
void nvgst_destroy_window (displayCtx * dpyCtx);
|
||||
@@ -0,0 +1,354 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
NvGstPlayer Usage (command: ./nvgstplayer-1.0 --help)
|
||||
Gstreamer Version used (command: ./nvgstplayer-1.0 --version)
|
||||
=======
|
||||
=> PREREQUISITES:
|
||||
|
||||
1. You must install GStreamer-1.0 on the target board using apt-get, as follows:
|
||||
|
||||
sudo apt-get install gstreamer1.0-tools gstreamer1.0-alsa gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad gstreamer1.0-libav
|
||||
|
||||
2. Execute the following commands on the target board's Ubuntu command line before starting the player:
|
||||
|
||||
export DISPLAY=:0
|
||||
xinit &
|
||||
|
||||
NvGstPlayer Usage
|
||||
-----------------------------------------------
|
||||
Run the nvgstplayer application with the following basic syntax:
|
||||
|
||||
./nvgstaplayer-1.0 -i <uri>
|
||||
|
||||
nvgstplayer application support following options:
|
||||
|
||||
-u, --urifile Path of the file containing the URIs
|
||||
-i, --uri input URI
|
||||
-r, --gst_script Path of the file containing the Script to be used
|
||||
--automotive Enter the AutoMotive Mode, to support GstMediaPlayer functionalities in NvGstPlayer
|
||||
-e, --elemfile Element(s) (Properties) file
|
||||
-x, --cxpr Command sequence expression
|
||||
-n, --loop Number of times to play the media
|
||||
-c, --audio-track If stream have multiple audio tracks, play stream with given track no
|
||||
-v, --video-track If stream have multiple video tracks, play stream with given track no
|
||||
-a, --start Start of the segment in media in seconds
|
||||
-d, --duration Play duration of the segment in media in seconds
|
||||
--no-sync Disable AV Sync
|
||||
--disable-dpms Unconditionally Disable DPMS/ScreenBlanking during operation and re-enable upon exit
|
||||
--stealth Operate in stealth mode, alive even when no media is playing
|
||||
--bg Operate in background mode, keyboard input will be entirely ignored
|
||||
--use-playbin Use Playbin
|
||||
--no-audio Disable audio
|
||||
--no-video Disable video
|
||||
--disable-anative Disable native audio rendering
|
||||
--disable-vnative Disable native video rendering
|
||||
--use-buffering Use Buffering
|
||||
-l, --low-percent Low threshold for buffering to start, in %
|
||||
-j, --high-percent High threshold for buffering to finish, in %
|
||||
--loop-forever Play the URI(s) in loop forever
|
||||
-t, --max-size-time Max. amount of time in the queue (0=automatic)
|
||||
-y, --max-size-bytes Max. amount of bytes in the queue (0=automatic)
|
||||
-b, --max-size-buffers Max. amount of buffers in the queue (0=automatic)
|
||||
--window-x X coordinate for player window (for non overlay rendering)
|
||||
--window-y Y coordinate for player window (for non overlay rendering)
|
||||
--window-width Window width (for non overlay rendering)
|
||||
--window-height Window height (for non overlay rendering)
|
||||
--disable-fullscreen Play video in non fullscreen mode (for nvxvimagesink)
|
||||
-h, --drop-threshold-pct Permittable frames drop percentage, to be used with --stats (only for development purpose)
|
||||
-k, --image-display-time Image display time in seconds
|
||||
--show-tags shows tags (metadata), if available
|
||||
--smartdimmer Enable smart dimmer for power saving
|
||||
--stats shows stream statistics, if enabled
|
||||
--stats-file File to dump stream statistics, if enabled
|
||||
--svd (=) chain for video decoding
|
||||
--sad (=) chain for audio decoding
|
||||
--svc (=) chain for video postprocessing
|
||||
--sac (=) chain for audio postprocessing
|
||||
--svs (=) chain for video rendering
|
||||
--sas (=) chain for audio rendering
|
||||
--shttp (=) chain for http source
|
||||
--srtsp (=) chain for rtsp source
|
||||
--sudp (=) chain for udp source
|
||||
--sfsrc (=) chain for file source
|
||||
|
||||
Runtime Commands:
|
||||
q quit the application
|
||||
h print help
|
||||
Up Key, ] goto next track
|
||||
c restart current track
|
||||
Down Key, [ goto previous track
|
||||
spos query for position
|
||||
sdur query for duration
|
||||
s<val> seek to <val> position in seconds, eg "s5.120"
|
||||
v<val> seek to <val> percent of the duration, eg "v54"
|
||||
f<val> seek by <val> seconds, relative to current position eg "f23.901"
|
||||
Left Key, < seek backwards by 10 seconds
|
||||
Right Key, > seek forward by 10 seconds
|
||||
p pause playback
|
||||
r start/resume the playback
|
||||
z stop the playback
|
||||
i:<val> enter a single URI
|
||||
|
||||
The nvgstplayer application supports local file playback, and playback from RTSP, HTTP and UDP streams.
|
||||
|
||||
For example:
|
||||
|
||||
./nvgstplayer-1.0 -i /home/test.mp4
|
||||
./nvgstplayer-1.0 -i file:///home/test.mp4
|
||||
./nvgstplayer-1.0 -i udp://192.168.2.5:123
|
||||
|
||||
The nvgstplayer application operates in two modes, Playbin (--use-playbin) and Decodebin. Decodebin
|
||||
allows you to choose elements.
|
||||
Currently only Decodebin is operational.
|
||||
|
||||
A subset of options is documented below. For a complete description of available options use the --help option.
|
||||
|
||||
|
||||
Audio/Video Decoder Chain (--sad/--svd)
|
||||
---------------------------------------
|
||||
Specify a desired decode chain for a particular URI using --sad or --svd, with the -i option or using a URI file with the -u option.
|
||||
|
||||
For example:
|
||||
|
||||
--sad=”avdec_mp3”
|
||||
--sad=”avdec_amrnb# variant=1 ! audioresample ! audioconvert”
|
||||
--sad=”aacparse ! faad# min-latency=4000000”
|
||||
--svd=”avdec_h264# prop=val# prop2=val2”
|
||||
|
||||
Note the ‘#’ and ‘!’ character after every token.
|
||||
|
||||
|
||||
Audio/Video PostProcess Chain (--sac/--svc)
|
||||
------------------------------------------
|
||||
Specify a desired postprocess chain for a particular URI using --sac or --svc, with the -i option or using a URI file with the -u option.
|
||||
|
||||
For example:
|
||||
|
||||
--sac=”audioconvert ! audioresample”
|
||||
--svc= “my_video_postprocess# prop1=val1 ! videoconvert ! videoscale”
|
||||
|
||||
Note the ‘#’ and ‘!’ character after every token. To include this in your pipeline
|
||||
use the -–disable-anative/--disable-vnative options, or, in a URI a file,
|
||||
native_video=0/native_audio=0.
|
||||
|
||||
Audio/Video Render Chain (--sas/--svs)
|
||||
--------------------------------------
|
||||
Specify a desired render chain for a particular URI using --sas or --svs with the -i option or using a URI file with the -u option.
|
||||
|
||||
For example:
|
||||
|
||||
--sas=”alsasink# device=hw:0,0”
|
||||
--sas=”audioconvert ! alsasink”
|
||||
--svs= “xvimagesink”
|
||||
--svs = “videoconvert ! videoscale ! ximagesink# sync=0”
|
||||
|
||||
Note the ‘#’ and ‘!’ character after every token.
|
||||
|
||||
|
||||
Elements file (--elemfile/-e)
|
||||
-----------------------------
|
||||
Specfy with --elemfile (or -e) an input file containing the sources, decoders, parsers, postprocess, and sinks that you want to use.
|
||||
|
||||
|
||||
Decoders/Parsers Chain Format
|
||||
-----------------------------
|
||||
[capabilties]
|
||||
type=<val>, val = ‘sad’, ‘svd’
|
||||
pipe=<my_chain>
|
||||
|
||||
|
||||
Post Process/Render chain Format
|
||||
-------------------------------
|
||||
[type]
|
||||
pipe=<my_chain>
|
||||
|
||||
For example:
|
||||
|
||||
[video/x-h264]
|
||||
type=svd
|
||||
pipe=h264parse ! my_h264_dec# prop1=val1
|
||||
|
||||
[svs]
|
||||
pipe=xvimagesink
|
||||
|
||||
[sas]
|
||||
pipe=audioconvert ! osssink# device=/dev/dsp1# latency-time=20000#
|
||||
|
||||
[video/mpeg, mpegversion=4]
|
||||
type=svd
|
||||
pipe= ffdec_mpeg4
|
||||
|
||||
[audio/mpeg, mpegversion=1, layer=3]
|
||||
type=sad
|
||||
pipe= mp3parse ! mad
|
||||
|
||||
[audio/mpeg, mpegversion=4]
|
||||
type=sad
|
||||
pipe=faad
|
||||
|
||||
[svc]
|
||||
pipe= videoconvert# qos=0 ! videoscale
|
||||
|
||||
|
||||
Command Sequence Expression (--cxpr/-x)
|
||||
---------------------------------------
|
||||
Use the --cxpr (or -x) option (as a string) to provide a series of commands in an expression format.
|
||||
The following commands can be inserted in an expression:
|
||||
|
||||
r<val> play for <val> seconds until next command in the expression
|
||||
p<val> pause for <val> seconds until next command in the expression
|
||||
z<val> stop for <val> seconds until next command in the expression
|
||||
w<val> do nothing for <val> seconds until next command in the expression
|
||||
s<val> seek to absolute time <val> seconds
|
||||
v<val> seek to absolute time <val> in % of duration
|
||||
f<val> seek to relative time <val> seconds from current position
|
||||
> seek forward by 10 seconds
|
||||
< seek behind by 10 seconds
|
||||
] goto next track
|
||||
[ goto previous track
|
||||
c reset current track
|
||||
|
||||
For example:
|
||||
|
||||
r10.5,s80,w5,p7,r
|
||||
2{p10,r,w7,s90.55,w2,p,w10,r2} <will iterate the expression 2 times>
|
||||
2{r20,s10,w5,p10, 2{s10,w6,r9}, 3{r10, p20}}
|
||||
5{r8, p10, s90, w10}, 8{s10, w2, p20}
|
||||
|
||||
Random cxpr:
|
||||
------------
|
||||
A random command sequence expression can be generated by giving cxpr as "*"
|
||||
|
||||
For example:
|
||||
|
||||
./nvgstplayer-1.0 -i <uri> --cxpr=*
|
||||
|
||||
This will generate a random command sequence expression (up to 100 characters).
|
||||
|
||||
|
||||
URI File (--urifile/-u)
|
||||
-----------------------
|
||||
Use the --urifile (or -u) option to specify a list of URIs. The player plays all URIs listed in the file. Any options for the URI specified in the file take precedence over the same options set by application command line arguments for that particular URI.
|
||||
|
||||
Format of the URI file and the options for the URI
|
||||
------------------------------------------------
|
||||
[uri1]
|
||||
option1=val1
|
||||
option2=val2
|
||||
.......
|
||||
........
|
||||
|
||||
[uri2]
|
||||
option1=val1
|
||||
..........
|
||||
..........
|
||||
|
||||
List of all possible options for URIs inside URI file
|
||||
-----------------------------------------------------
|
||||
cxpr=<val> command expression for the URI
|
||||
nop=<val> if '1' , will disable the global cxpr (if given as command line arg)
|
||||
start=<val> start playback time in seconds/ or percentage of URI duration
|
||||
startper=<val> '1' indicating that the 'start' option will be % value
|
||||
duration=<val> desired playback time in seconds
|
||||
repeats=<val> playback iterations
|
||||
audio=<val> 0/1 to disable/enable audio in the URI
|
||||
video=<val> 0/1 to disable/enable video in the URI
|
||||
native_video=<val> 0/1 to disable/enable native video rendering
|
||||
native_audio=<val> 0/1 to disable/enable native audio rendering
|
||||
sync=<val> 1/0 to enabling/disabling AV sync
|
||||
use-buffering=<val> 1/0 to enable/disable buffering
|
||||
low-percent=<val> low threshold for buffering in %
|
||||
high-percent=<val> high threshold for buffering in %
|
||||
max-size-bytes=<val> max size of bytes in queue for buffering
|
||||
max-size-buffers=<val> max size of buffers in queue for buffering
|
||||
max-size-time=<val> max size time in queue for buffering
|
||||
image-display-time=<val> image display time in seconds (if URI is an image file)
|
||||
tags=<val> 0/1 disable/enable tags print
|
||||
svd=<val> video decoding chain
|
||||
sad=<val> audio decoding chain
|
||||
svc=<val> video post-precessing chain
|
||||
sac=<val> audio post-precessing chain
|
||||
svs=<val> video rendering chain
|
||||
sas=<val> audio rendering chain
|
||||
shttp=<val> http source chain
|
||||
srtsp=<val> rtsp source chain
|
||||
sudp=<val> udp source chain
|
||||
sfsrc=<val> file source chain
|
||||
|
||||
|
||||
For example, use the following as a URI file with the syntax "./nvgstplayer-1.0 -u TestURIfile":
|
||||
|
||||
TestURIfile
|
||||
|
||||
[/home/user/test.avi]
|
||||
cxpr=2{p5, r, w10, s20.5, w6.6, p3, 2 {r, w10, p4}}
|
||||
start=10.45
|
||||
repeats=3
|
||||
audio=0
|
||||
native_video=0
|
||||
svd=my_h264dec
|
||||
svc=videoconvert ! my_pp# prop1=shuba# prop2=val2# ! videoscale
|
||||
|
||||
[/home/user/test.mp3]
|
||||
sas=audioconvert ! alsasink
|
||||
|
||||
[/home/user/test.mp4]
|
||||
nop=1
|
||||
video=0
|
||||
|
||||
|
||||
NOTES:
|
||||
|
||||
1. Elements to use can be provided in several different ways:
|
||||
|
||||
a. Provided in an elements file.
|
||||
|
||||
b. Provided as command-line arguments applicable to all the streams in the URI file, with the –I option. Elements provided in this way override values (if present) inside an elements file.
|
||||
|
||||
c. Provided in a URI file, specific for each URI, if desired. Elements provided in this way override any elements provided at the command-line or in an elements file.
|
||||
|
||||
2. For Laguna-ERSS on K3.10, no amixer settings are required to enable/disable internal speaker as internal speaker is not present on the board.
|
||||
|
||||
a. To enable audio through Headphones, use:
|
||||
|
||||
amixer cset name="Int Spk Switch" 0
|
||||
amixer cset name='Headphone Jack Switch' 1
|
||||
|
||||
b. To disable audio through Headphones, use:
|
||||
|
||||
amixer cset name='Headphone Jack Switch' 0
|
||||
|
||||
By default, audio is enabled through Headphones.
|
||||
|
||||
3. The URI list can be looped forever by providing --loop-forever option:
|
||||
|
||||
./nvgstplayer-1.0 -u <uri_file> --loop-forever
|
||||
|
||||
4. To enable hw accelerated jpeg decoding use following command:
|
||||
|
||||
./nvgstplayer-1.0 -i <filename.jpg> --svd=nvjpegdec --svs=nvoverlaysink
|
||||
|
||||
5. nvhdmioverlaysink has been deprecated. Use nvoverlaysink with display-id property instead.
|
||||
|
||||
./nvgstplayer-1.0 -i <filename> --svs="nvoverlaysink # display-id=<value>"
|
||||
4060
nvgstapps_src/nvgst_sample_apps/nvgstplayer-1.0/nvgstplayer.c
Normal file
4060
nvgstapps_src/nvgst_sample_apps/nvgstplayer-1.0/nvgstplayer.c
Normal file
File diff suppressed because it is too large
Load Diff
435
nvgstapps_src/nvgst_sample_apps/nvgstplayer-1.0/nvgstplayer.h
Normal file
435
nvgstapps_src/nvgst_sample_apps/nvgstplayer-1.0/nvgstplayer.h
Normal file
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __NVGSTPLAYER_H__
|
||||
#define __NVGSTPLAYER_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/videooverlay.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <math.h>
|
||||
#include <pthread.h>
|
||||
#include <ctype.h>
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#include "nvgst_x11_common.h"
|
||||
#include "nvgst_asound_common.h"
|
||||
|
||||
#ifdef WITH_GUI
|
||||
|
||||
#include "nvgstplayer_gui_interface.h"
|
||||
|
||||
#else
|
||||
|
||||
gpointer dummy_func (void);
|
||||
gpointer
|
||||
dummy_func ()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define GUI 0
|
||||
#define CALL_GUI_FUNC(func, ...) dummy_func()
|
||||
#define GET_GUI_CTX() NULL
|
||||
#define GUI_CALLBACKS "nvgstplayer.h"
|
||||
#endif
|
||||
|
||||
#define APPLICATION_NAME "nvgstplayer"
|
||||
#define NVSTARTPER "startper"
|
||||
#define NVSTART "start"
|
||||
#define NVDURATION "duration"
|
||||
#define NVCXPR "cxpr"
|
||||
#define NVREPEATS "repeats"
|
||||
#define NVAUDIO "audio"
|
||||
#define NVVIDEO "video"
|
||||
#define NVNATIVE_AUDIO "native_audio"
|
||||
#define NVNATIVE_VIDEO "native_video"
|
||||
#define NVNOP "nop"
|
||||
#define NVSYNC "sync"
|
||||
#define NVUSE_BUFFERING "use_buffering"
|
||||
#define NVLOW_PERCENT "low_percent"
|
||||
#define NVHIGH_PERCENT "high_percent"
|
||||
#define NVMAX_SIZE_TIME "max_size_time"
|
||||
#define NVMAX_SIZE_BYTES "max_size_bytes"
|
||||
#define NVMAX_SIZE_BUFFERS "max_size_buffers"
|
||||
#define NVIMAGE_DISPLAY_TIME "image_display_time"
|
||||
#define NVTAGS "tags"
|
||||
|
||||
#define NVGST_AUDIO_DEC "sad"
|
||||
#define NVGST_VIDEO_DEC "svd"
|
||||
#define NVGST_AUDIO_CONV "sac"
|
||||
#define NVGST_VIDEO_CONV "svc"
|
||||
#define NVGST_AUDIO_SINK "sas"
|
||||
#define NVGST_VIDEO_SINK "svs"
|
||||
#define NVGST_FILE_SRC "sfsrc"
|
||||
#define NVGST_RTSP_SRC "srtsp"
|
||||
#define NVGST_HTTP_SRC "shttp"
|
||||
#define NVGST_UDP_SRC "sudp"
|
||||
|
||||
#define NVGST_DEFAULT_AUDIO_CONV "audioconvert ! audioresample"
|
||||
#define NVGST_DEFAULT_VIDEO_CONV "nvvidconv"
|
||||
#define NVGST_DEFAULT_AUDIO_SINK "alsasink"
|
||||
#define NVGST_DEFAULT_VIDEO_SINK "nv3dsink"
|
||||
#define NVGST_DEFAULT_VIDEO_DEC "nvv4l2decoder"
|
||||
#define NVGST_DEFAULT_FILE_SRC "filesrc"
|
||||
#define NVGST_DEFAULT_RTSP_SRC "rtspsrc"
|
||||
#define NVGST_DEFAULT_HTTP_SRC "souphttpsrc"
|
||||
#define NVGST_DEFAULT_UDP_SRC "udpsrc"
|
||||
|
||||
#ifdef NVGST_LOG_LEVEL_DEBUG
|
||||
#define NVGST_ENTER_FUNCTION() g_print("%s{", __FUNCTION__)
|
||||
#define NVGST_EXIT_FUNCTION() g_print("%s}", __FUNCTION__)
|
||||
#define NVGST_EXIT_FUNCTION_VIA(s) g_print("%s}['%s']", __FUNCTION__, s)
|
||||
#define NVGST_DEBUG_MESSAGE(s) g_debug("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_DEBUG_MESSAGE_V(s, ...) g_debug("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#define NVGST_INFO_MESSAGE(s) g_message("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_INFO_MESSAGE_V(s, ...) g_message("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#define NVGST_WARNING_MESSAGE(s) g_warning("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_WARNING_MESSAGE_V(s, ...) g_warning("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#define NVGST_CRITICAL_MESSAGE(s) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_CRITICAL_MESSAGE_V(s, ...) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__,__VA_ARGS__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_ERROR_MESSAGE(s) g_error("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_ERROR_MESSAGE_V(s, ...) g_error("<%s:%d> "s, __FUNCTION__, __LINE__,__VA_ARGS__)
|
||||
|
||||
#elif defined NVGST_LOG_LEVEL_INFO
|
||||
#define NVGST_ENTER_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION_VIA(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE(s) g_message("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_INFO_MESSAGE_V(s, ...) g_message("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#define NVGST_WARNING_MESSAGE(s) g_warning("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_WARNING_MESSAGE_V(s, ...) g_warning("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#define NVGST_CRITICAL_MESSAGE(s) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_CRITICAL_MESSAGE_V(s, ...) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_ERROR_MESSAGE(s) g_error("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_ERROR_MESSAGE_V(s, ...) g_error("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#elif defined NVGST_LOG_LEVEL_WARNING
|
||||
#define NVGST_ENTER_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION_VIA(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_WARNING_MESSAGE(s) g_warning("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_WARNING_MESSAGE_V(s, ...) g_warning("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#define NVGST_CRITICAL_MESSAGE(s) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_CRITICAL_MESSAGE_V(s, ...) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_ERROR_MESSAGE(s) g_error("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_ERROR_MESSAGE_V(s, ...) g_error("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#elif defined NVGST_LOG_LEVEL_CRITICAL
|
||||
#define NVGST_ENTER_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION_VIA(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_WARNING_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_WARNING_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_CRITICAL_MESSAGE(s) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_CRITICAL_MESSAGE_V(s, ...) do {\
|
||||
g_critical("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__);\
|
||||
app->return_value = -1;\
|
||||
} while (0)
|
||||
#define NVGST_ERROR_MESSAGE(s) g_error("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_ERROR_MESSAGE_V(s, ...) g_error("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#else
|
||||
#define NVGST_ENTER_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION() G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_EXIT_FUNCTION_VIA(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_DEBUG_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_INFO_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_WARNING_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_WARNING_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_CRITICAL_MESSAGE(s) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_CRITICAL_MESSAGE_V(s, ...) G_STMT_START{ (void)0; }G_STMT_END
|
||||
#define NVGST_ERROR_MESSAGE(s) g_error("<%s:%d> "s, __FUNCTION__, __LINE__)
|
||||
#define NVGST_ERROR_MESSAGE_V(s, ...) g_error("<%s:%d> "s, __FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define INITIAL_FPS_UPDATE_INTERVAL_MS 400
|
||||
#ifdef WITH_GUI
|
||||
#define DEFAULT_FPS_UPDATE_INTERVAL_MS 400
|
||||
#else
|
||||
#define DEFAULT_FPS_UPDATE_INTERVAL_MS 5000
|
||||
#endif
|
||||
|
||||
#define CALC_RUNNING_AVERAGE(avg,val,size) (((val) + ((size)-1) * (avg)) / (size))
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NVGST_RET_ASYNC = 1,
|
||||
NVGST_RET_SUCCESS = 0,
|
||||
NVGST_RET_ERR = -1,
|
||||
NVGST_RET_END = -2,
|
||||
NVGST_RET_INVALID = -3
|
||||
} NvGstReturn;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NVGST_AUTOPLUG_SELECT_TRY = 0,
|
||||
NVGST_AUTOPLUG_SELECT_EXPOSE,
|
||||
NVGST_AUTOPLUG_SELECT_SKIP
|
||||
} NvGstAutoplugSelectResult;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NVGST_PLAY_FLAG_VIDEO = (1 << 0),
|
||||
NVGST_PLAY_FLAG_AUDIO = (1 << 1),
|
||||
NVGST_PLAY_FLAG_TEXT = (1 << 2),
|
||||
NVGST_PLAY_FLAG_VIS = (1 << 3),
|
||||
NVGST_PLAY_FLAG_SOFT_VOLUME = (1 << 4),
|
||||
NVGST_PLAY_FLAG_NATIVE_AUDIO = (1 << 5),
|
||||
NVGST_PLAY_FLAG_NATIVE_VIDEO = (1 << 6),
|
||||
NVGST_PLAY_FLAG_DOWNLOAD = (1 << 7),
|
||||
NVGST_PLAY_FLAG_BUFFERING = (1 << 8),
|
||||
NVGST_PLAY_FLAG_DEINTERLACE = (1 << 9),
|
||||
/* added */
|
||||
NVGST_PLAY_FLAG_PLAYBIN = (1 << 10)
|
||||
} NvGstPlayFlags;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NVGST_OPS_NONE,
|
||||
NVGST_OPS_PAUSE,
|
||||
NVGST_OPS_PLAY,
|
||||
NVGST_OPS_SEEK,
|
||||
NVGST_OPS_WAIT,
|
||||
NVGST_OPS_STOP
|
||||
} NvGstOperation;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NVGST_CMD_NONE,
|
||||
NVGST_CMD_SCRIPT,
|
||||
NVGST_CMD_USER
|
||||
} NvGstOpMode;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUFFER_MODE_NONE = 0,
|
||||
BUFFER_MODE_SLAVE = 1,
|
||||
BUFFER_MODE_BUFFER = 2,
|
||||
BUFFER_MODE_AUTO = 3
|
||||
} JitterBufferMode;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint repeats;
|
||||
gboolean startPer;
|
||||
GstClockTimeDiff segment_start;
|
||||
GstClockTimeDiff segment_duration;
|
||||
NvGstPlayFlags flags;
|
||||
gboolean sync;
|
||||
gboolean use_buffering;
|
||||
gboolean disable_fullscreen;
|
||||
gint low_percent;
|
||||
gint high_percent;
|
||||
gint aud_track;
|
||||
gint vid_track;
|
||||
gint drop_threshold_pct;
|
||||
gboolean loop_forever;
|
||||
gint max_size_buffers;
|
||||
gint max_size_bytes;
|
||||
GstClockTime max_size_time;
|
||||
gint image_display_time;
|
||||
gboolean show_tags;
|
||||
GList *lplist_head;
|
||||
GList *cmlist_head;
|
||||
GList *lplist;
|
||||
GList *cmlist;
|
||||
} attrs_s;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *uri;
|
||||
NvGstOpMode operation_mode;
|
||||
GstClockTimeDiff duration;
|
||||
gchar **audio_dec;
|
||||
gchar **video_dec;
|
||||
attrs_s attrs;
|
||||
gboolean selfexpr;
|
||||
gboolean pending_play;
|
||||
guint64 interval;
|
||||
gboolean postpone;
|
||||
gboolean dbin_audio_decoders;
|
||||
gboolean dbin_video_decoders;
|
||||
} inAttrs;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
guint frames_rendered, frames_dropped, frames_dropped_decoder;
|
||||
guint64 last_frames_rendered, last_frames_dropped;
|
||||
|
||||
GstClockTime start_ts;
|
||||
GstClockTime last_ts;
|
||||
|
||||
gdouble max_fps;
|
||||
gdouble min_fps;
|
||||
gdouble average_fps;
|
||||
|
||||
GTimer *timer;
|
||||
guint dps_cb;
|
||||
GstClockTime prev_ts;
|
||||
GstClockTime avg_in_diff;
|
||||
GstClockTime max_latency;
|
||||
gboolean initial_fps;
|
||||
} pfData_s;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
inAttrs *input;
|
||||
gchar *extra_options;
|
||||
GKeyFile *pathCfg;
|
||||
GKeyFile *elemCfg;
|
||||
GHashTable *htable;
|
||||
NvGstOperation cur_operation;
|
||||
attrs_s attrs;
|
||||
GstElement *pipeline;
|
||||
GstElement *source;
|
||||
GstElement *vpipe;
|
||||
GstElement *apipe;
|
||||
GstElement *vsink;
|
||||
GstElement *asink;
|
||||
GstElement *adbin;
|
||||
GstElement *vdbin;
|
||||
GstElement *seekElement;
|
||||
gboolean no_more_pads;
|
||||
gint cmd_id;
|
||||
gint bus_id;
|
||||
gint uriCount;
|
||||
gsize uriTotal;
|
||||
gchar **uriGroups;
|
||||
gboolean version;
|
||||
gboolean have_alsa_sinks;
|
||||
gboolean found_demuxer;
|
||||
gboolean got_eos;
|
||||
gboolean is_live;
|
||||
gboolean in_error;
|
||||
gboolean pre_dbin_lp;
|
||||
gboolean unpause;
|
||||
gboolean buffering;
|
||||
gboolean running;
|
||||
guint image_eos;
|
||||
gint return_value;
|
||||
GstState target_state;
|
||||
GstClockTimeDiff last_seek_time;
|
||||
GstClockTimeDiff accum_time;
|
||||
GstClockTime seekPos;
|
||||
gchar *uri;
|
||||
gchar **elem_gps;
|
||||
gboolean stealth_mode;
|
||||
gboolean bg_mode;
|
||||
gchar *svd;
|
||||
gchar *sad;
|
||||
gchar *svc;
|
||||
gchar *sac;
|
||||
gchar *svs;
|
||||
gchar *sas;
|
||||
gchar *shttp;
|
||||
gchar *srtsp;
|
||||
gchar *sudp;
|
||||
gchar *sfsrc;
|
||||
gint astreams;
|
||||
gint vstreams;
|
||||
gint astream_select;
|
||||
gint vstream_select;
|
||||
gboolean disable_dpms;
|
||||
displayCtx disp;
|
||||
GThread *x_event_thread;
|
||||
GMutex window_lock;
|
||||
|
||||
/* stats */
|
||||
gboolean stats;
|
||||
gchar *stats_file;
|
||||
pfData_s pfData;
|
||||
GstPad *vrender_pad;
|
||||
GstPad *arender_pad;
|
||||
gchar *elem_file;
|
||||
GMutex dbin_lock;
|
||||
|
||||
} appCtx;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
guint x;
|
||||
guint n;
|
||||
GList *c;
|
||||
} sLp;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *id;
|
||||
GList *list;
|
||||
} sCm;
|
||||
#endif
|
||||
1
push_info.txt
Normal file
1
push_info.txt
Normal file
@@ -0,0 +1 @@
|
||||
jetson_36.4.3
|
||||
Reference in New Issue
Block a user