NVIDIA DeepStream SDK API Reference

7.1 Release
deepstream_asr_tts_app.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6  * property and proprietary rights in and to this material, related
7  * documentation and any modifications thereto. Any use, reproduction,
8  * disclosure or distribution of this material and related documentation
9  * without an express license agreement from NVIDIA CORPORATION or
10  * its affiliates is strictly prohibited.
11  */
12 
13 
14 #ifndef __DEEPSTREAM_TTS_APP_H_
15 #define __DEEPSTREAM_TTS_APP_H_
16 
17 #include <gst/gst.h>
18 #include <gst/audio/audio.h>
19 #include <glib.h>
20 #include <stdio.h>
21 #include <stdlib.h>
23 
24 #define CHECK_PTR(ptr) \
25  if(ptr == NULL) \
26  { \
27  return -1; \
28  }
29 
30 #define MAX_FILENAME_LENGTH (256)
31 #define MUX_AUDIO_VIDEO_OUT
32 
33 /* Macro for linking Gstreamer elements with source request pad and static sink pad */
34 #define LINK_REQUEST_PAD_STATIC_PAD(src, srcpadname, sink, sinkpadname) \
35 { \
36  GstPad *srcpad = gst_element_request_pad_simple (src, srcpadname); \
37  if (!srcpad) { \
38  g_printerr ("%s source pad %s request failed.\n", #src, #srcpadname); \
39  return -1; \
40  } \
41  GstPad *sinkpad = gst_element_get_static_pad (sink, sinkpadname); \
42  if (!sinkpad) { \
43  g_printerr ("%s sink pad %s request failed.\n", #sink, #sinkpadname); \
44  return -1; \
45  } \
46 \
47  if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK) { \
48  g_printerr ("Failed to link %s to %s\n", #src, #sink); \
49  return -1; \
50  } \
51  gst_object_unref (srcpad); \
52  gst_object_unref (sinkpad); \
53 }
54 
55 /* Macro for linking Gstreamer elements with source static pad and request sink pad */
56 #define LINK_STATIC_PAD_REQUEST_PAD(src, srcpadname, sink, sinkpadname) \
57 { \
58  GstPad *srcpad = gst_element_get_static_pad (src, srcpadname); \
59  if (!srcpad) { \
60  g_printerr ("%s source pad %s request failed.\n", #src, #srcpadname); \
61  return -1; \
62  } \
63  GstPad *sinkpad = gst_element_request_pad_simple (sink, sinkpadname); \
64  if (!sinkpad) { \
65  g_printerr ("%s sink pad %s request failed.\n", #sink, #sinkpadname); \
66  return -1; \
67  } \
68 \
69  if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK) { \
70  g_printerr ("Failed to link %s to %s\n", #src, #sink); \
71  return -1; \
72  } \
73  gst_object_unref (srcpad); \
74  gst_object_unref (sinkpad); \
75 }
76 
77 #define ATTACH_STATIC_PAD_PROBE(element, padname, probe_type, probe, dataptr) \
78 { \
79  GstPad *pad = gst_element_get_static_pad (element, padname); \
80  if (!pad) { \
81  g_printerr ("Get pad failed for %s %s. Exiting.\n",#element, padname); \
82  return -1; \
83  } \
84  gst_pad_add_probe (pad, probe_type, probe, dataptr, NULL); \
85  gst_object_unref (pad); \
86 }
87 
88 
89 typedef struct __StreamCtx
90 {
91  gchar *uri;
92  guint stream_id;
93  guint has_audio;
94  guint bus_id;
95  GstElement *asr_pipeline;
96  GstElement *input_downmixer;
99  FILE *FP_asr;
100 } StreamCtx;
101 
102 typedef struct __AppCtx
103 {
104  guint num_sources;
106  GstElement **proxy_audio_sinks;
107  GstElement **proxy_audio_sources;
108  GstElement *renderer_pipeline;
109  gboolean enable_playback;
111  gboolean pts_mode;
112  gboolean sync;
113  guint bus_id;
116 } AppCtx;
117 
118 
119 int create_pipeline(AppCtx *appctx, int stream_num, StreamCtx *sctx,
120  GstElement **p_proxy_audio_sink);
121 int create_renderer_pipeline(AppCtx *appctx);
122 int start_pipeline(int stream_num, StreamCtx *sctx);
123 int destroy_pipeline(StreamCtx *sctx);
124 
125 guint get_num_sources (gchar *cfg_file_path);
126 gboolean parse_config_file (AppCtx *appctx, gchar *config_file);
127 
128 G_BEGIN_DECLS
129 
130 guint get_num_sources_yaml (gchar *cfg_file_path);
131 gboolean parse_config_file_yaml (AppCtx *appctx, gchar *config_file);
132 
133 G_END_DECLS
134 #endif
__StreamCtx::input_downmixer
GstElement * input_downmixer
Definition: deepstream_asr_tts_app.h:96
__AppCtx::app_config
NvDsAppConfig app_config
Definition: deepstream_asr_tts_app.h:115
__StreamCtx::asr_pipeline
GstElement * asr_pipeline
Definition: deepstream_asr_tts_app.h:95
AppCtx
REST server application context.
Definition: nvds_appctx_server.h:46
__AppCtx::proxy_audio_sinks
GstElement ** proxy_audio_sinks
Definition: deepstream_asr_tts_app.h:106
__AppCtx::num_sources
guint num_sources
Definition: deepstream_asr_tts_app.h:104
__StreamCtx::eos_received
int eos_received
Definition: deepstream_asr_tts_app.h:97
parse_config_file
gboolean parse_config_file(AppCtx *appctx, gchar *config_file)
__AppCtx::playback_output_file_name
const char * playback_output_file_name
Definition: deepstream_asr_tts_app.h:110
__StreamCtx::stream_id
guint stream_id
Definition: deepstream_asr_tts_app.h:92
__StreamCtx
Definition: deepstream_asr_tts_app.h:89
__AppCtx::pts_mode
gboolean pts_mode
Definition: deepstream_asr_tts_app.h:111
create_pipeline
int create_pipeline(AppCtx *appctx, int stream_num, StreamCtx *sctx, GstElement **p_proxy_audio_sink)
get_num_sources_yaml
G_BEGIN_DECLS guint get_num_sources_yaml(gchar *cfg_file_path)
deepstream_asr_tts_config_file_parser.h
__StreamCtx::FP_asr
FILE * FP_asr
Definition: deepstream_asr_tts_app.h:99
parse_config_file_yaml
gboolean parse_config_file_yaml(AppCtx *appctx, gchar *config_file)
__NvDsAppConfig
Definition: deepstream_asr_tts_config_file_parser.h:26
AppCtx
struct __AppCtx AppCtx
get_num_sources
guint get_num_sources(gchar *cfg_file_path)
destroy_pipeline
int destroy_pipeline(StreamCtx *sctx)
__StreamCtx::bus_id
guint bus_id
Definition: deepstream_asr_tts_app.h:94
__NvDsAudioConfig
Definition: deepstream_asr_tts_config_file_parser.h:20
__AppCtx::enable_playback
gboolean enable_playback
Definition: deepstream_asr_tts_app.h:109
__AppCtx::eos_received
int eos_received
Definition: deepstream_asr_tts_app.h:114
__AppCtx::sctx
StreamCtx * sctx
Definition: deepstream_asr_tts_app.h:105
__AppCtx::proxy_audio_sources
GstElement ** proxy_audio_sources
Definition: deepstream_asr_tts_app.h:107
start_pipeline
int start_pipeline(int stream_num, StreamCtx *sctx)
create_renderer_pipeline
int create_renderer_pipeline(AppCtx *appctx)
__StreamCtx::audio_config
NvDsAudioConfig audio_config
Definition: deepstream_asr_tts_app.h:98
__StreamCtx::uri
gchar * uri
Definition: deepstream_asr_tts_app.h:91
__StreamCtx::has_audio
guint has_audio
Definition: deepstream_asr_tts_app.h:93
__AppCtx::bus_id
guint bus_id
Definition: deepstream_asr_tts_app.h:113
StreamCtx
struct __StreamCtx StreamCtx
__AppCtx::sync
gboolean sync
Definition: deepstream_asr_tts_app.h:112
__AppCtx
Definition: deepstream_asr_tts_app.h:102
__AppCtx::renderer_pipeline
GstElement * renderer_pipeline
Definition: deepstream_asr_tts_app.h:108