NVIDIA DeepStream SDK API Reference

7.0 Release
gstnvstreammux_audio.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2023 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 #ifndef __GST_NVSTREAMMUX_AUDIO_H__
14 #define __GST_NVSTREAMMUX_AUDIO_H__
15 
16 #include "gstnvstreammux_impl.h"
17 #include "nvbufaudio.h"
18 
19 #define NVSTREAMMUX_BYTES_TO_AUDIOSAMPLESIZE(bytes, channels, bpf) \
20  ((bytes) / ( (channels) * (bpf)))
21 
22 #define NVSTREAMMUX_AUDIOSAMPLESIZE_TO_BYTES(samples, channels, bpf) \
23  ((samples) * (channels) * (bpf))
24 
25 
26 extern "C"
27 {
28 static void
29 audio_mem_buf_unref_callback (gpointer data);
30 }
31 
32 
39 {
40 
41  public :
42  GstAudioBatchBufferWrapper(GstNvStreamMux * mux, unsigned int size, bool is_raw) : NvDsBatchBufferWrapper(size) , is_raw(is_raw), mux(mux), api((GstElement*)mux)
43  {
44 
45  batch = malloc(sizeof(NvBufAudio));
46  memset (batch, 0 , sizeof(NvBufAudio));
47  ((NvBufAudio *)batch)->audioBuffers = (NvBufAudioParams *)malloc(sizeof(NvBufAudioParams) * size);
48  ((NvBufAudio *)batch)->numFilled = 0;
49  ((NvBufAudio *)batch)->batchSize = size;
50  if(!is_raw)
51  {
52  gst_buffer =
53  gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY, (NvBufAudio *)batch, sizeof (NvBufAudio),
54  0, sizeof (NvBufAudio), (void *)this, audio_mem_buf_unref_callback);
55  //gst_buffer_ref(gst_buffer);
56  }
57  else
58  {
59  raw_batch = gst_buffer_list_new_sized (size);
60  }
61  }
62 
63  void unref() override;
64  void reset_batch();
65  void dummy(){}
66  void copy_meta(unsigned int id, std::shared_ptr<BufferWrapper> src_buffer, unsigned int batch_id, unsigned int frame_number, unsigned int num_surfaces_per_frame, NvDsBatchMeta * dest_batch_meta, unsigned int source_id) override;
67  unsigned int copy_buf(std::shared_ptr<BufferWrapper> src, unsigned int pos) override;
68  bool push(SourcePad * src_pad, TimePoint current_play_start, NanoSecondsType accum_dur) override;
69  bool push(SourcePad * src_pad, unsigned long pts) override;
70  void unref_gst_bufs();
71 
72  GstBufferList *raw_batch;
74  bool is_raw;
76  std::vector<std::shared_ptr<GstBufferWrapper> > gst_in_bufs;
77 
78  private:
79 
80  unsigned int copy_buf_impl(std::shared_ptr<BufferWrapper> buf, unsigned int pos);
81 
82  private:
84 
85 };
86 
87 extern "C"
88 {
89 static void
91 {
92 
93  if(data != NULL)
94  {
96  batch->unref_gst_bufs();
97  delete batch;
98  }
99 
100 }
101 }
102 
103 
104 #endif
GstAudioBatchBufferWrapper::unref_gst_bufs
void unref_gst_bufs()
_GstNvStreamMux
Definition: gstnvstreammux.h:42
GstAudioBatchBufferWrapper::copy_buf
unsigned int copy_buf(std::shared_ptr< BufferWrapper > src, unsigned int pos) override
NvBufAudioParams
Definition: nvbufaudio.h:82
GstAudioBatchBufferWrapper::dummy
void dummy()
Definition: gstnvstreammux_audio.h:65
NvDsBatchBufferWrapper
Definition: nvstreammux_batch.h:108
GstCommonBufferAPI
Definition: gstnvstreammux_impl.h:32
audio_mem_buf_unref_callback
static void audio_mem_buf_unref_callback(gpointer data)
Definition: gstnvstreammux_audio.h:90
GstAudioBatchBufferWrapper::mux
GstNvStreamMux * mux
Definition: gstnvstreammux_audio.h:75
GstAudioBatchBufferWrapper::gst_buffer
GstBuffer * gst_buffer
Definition: gstnvstreammux_audio.h:73
SourcePad
Definition: nvstreammux_pads.h:140
NvBufAudio
Definition: nvbufaudio.h:109
GstAudioBatchBufferWrapper::reset_batch
void reset_batch()
BatchBufferWrapper::batch
void * batch
Definition: nvstreammux_batch.h:102
gstnvstreammux_impl.h
_NvDsBatchMeta
Holds information about a formed batch containing frames from different sources.
Definition: nvdsmeta.h:241
GstAudioBatchBufferWrapper::gst_in_bufs
std::vector< std::shared_ptr< GstBufferWrapper > > gst_in_bufs
Definition: gstnvstreammux_audio.h:76
nvbufaudio.h
GstAudioBatchBufferWrapper::raw_batch
GstBufferList * raw_batch
Definition: gstnvstreammux_audio.h:72
GstAudioBatchBufferWrapper::copy_meta
void copy_meta(unsigned int id, std::shared_ptr< BufferWrapper > src_buffer, unsigned int batch_id, unsigned int frame_number, unsigned int num_surfaces_per_frame, NvDsBatchMeta *dest_batch_meta, unsigned int source_id) override
NanoSecondsType
std::chrono::duration< double, std::nano > NanoSecondsType
Definition: nvstreammux_pads.h:22
GstBuffer
struct _GstBuffer GstBuffer
Definition: idatatype.h:19
GstAudioBatchBufferWrapper
The GStreamer wrapper code for NvDsBatchBufferWrapper which represent one batched buffer.
Definition: gstnvstreammux_audio.h:38
GstAudioBatchBufferWrapper::is_raw
bool is_raw
Definition: gstnvstreammux_audio.h:74
GstAudioBatchBufferWrapper::GstAudioBatchBufferWrapper
GstAudioBatchBufferWrapper(GstNvStreamMux *mux, unsigned int size, bool is_raw)
Definition: gstnvstreammux_audio.h:42
GstAudioBatchBufferWrapper::push
bool push(SourcePad *src_pad, TimePoint current_play_start, NanoSecondsType accum_dur) override
TimePoint
std::chrono::time_point< std::chrono::steady_clock, NanoSecondsType > TimePoint
Definition: nvstreammux_batch.h:37
GstAudioBatchBufferWrapper::unref
void unref() override