Add AudioFrameV3
This commit is contained in:
@@ -29,3 +29,35 @@ void PyAudioFrameV2::setMetadata(const std::string &data) {
|
||||
_metadata = data;
|
||||
p_metadata = _metadata.c_str();
|
||||
}
|
||||
|
||||
PyAudioFrameV3::PyAudioFrameV3(int sample_rate_, int no_channels_,
|
||||
int no_samples_, int64_t timecode_,
|
||||
NDIlib_FourCC_audio_type_e FourCC_,
|
||||
uint8_t *p_data_, int channel_stride_in_bytes_,
|
||||
const std::string &metadata_, int64_t timestamp_)
|
||||
: _metadata(metadata_) {
|
||||
sample_rate = sample_rate_;
|
||||
no_channels = no_channels_;
|
||||
no_samples = no_samples_;
|
||||
timecode = timecode_;
|
||||
FourCC = FourCC_;
|
||||
p_data = p_data_;
|
||||
channel_stride_in_bytes = channel_stride_in_bytes_;
|
||||
p_metadata = _metadata.c_str();
|
||||
timestamp = timestamp_;
|
||||
}
|
||||
|
||||
PyAudioFrameV3::~PyAudioFrameV3() {}
|
||||
|
||||
void PyAudioFrameV3::setData(py::array_t<uint8_t> &array) {
|
||||
auto info = array.request();
|
||||
p_data = reinterpret_cast<uint8_t *>(info.ptr);
|
||||
channel_stride_in_bytes = info.strides[0];
|
||||
}
|
||||
|
||||
const std::string &PyAudioFrameV3::getMetadata() const { return _metadata; }
|
||||
|
||||
void PyAudioFrameV3::setMetadata(const std::string &data) {
|
||||
_metadata = data;
|
||||
p_metadata = _metadata.c_str();
|
||||
}
|
||||
|
||||
@@ -22,3 +22,20 @@ public:
|
||||
private:
|
||||
std::string _metadata;
|
||||
};
|
||||
|
||||
class PyAudioFrameV3 : public NDIlib_audio_frame_v3_t {
|
||||
public:
|
||||
PyAudioFrameV3(int sample_rate_, int no_channels_, int no_samples_,
|
||||
int64_t timecode_, NDIlib_FourCC_audio_type_e FourCC_,
|
||||
uint8_t *p_data_, int channel_stride_in_bytes_,
|
||||
const std::string &metadata_, int64_t timestamp_);
|
||||
virtual ~PyAudioFrameV3();
|
||||
|
||||
void setData(py::array_t<uint8_t> &array);
|
||||
|
||||
const std::string &getMetadata() const;
|
||||
void setMetadata(const std::string &data);
|
||||
|
||||
private:
|
||||
std::string _metadata;
|
||||
};
|
||||
|
||||
23
src/main.cpp
23
src/main.cpp
@@ -146,11 +146,32 @@ PYBIND11_MODULE(NDIlib, m) {
|
||||
.def_readwrite("timecode", &PyAudioFrameV2::timecode)
|
||||
.def_property("data", nullptr, &PyAudioFrameV2::setData)
|
||||
.def_readwrite("channel_stride_in_bytes",
|
||||
&NDIlib_audio_frame_v2_t::channel_stride_in_bytes)
|
||||
&PyAudioFrameV2::channel_stride_in_bytes)
|
||||
.def_property("metadata", &PyAudioFrameV2::getMetadata,
|
||||
&PyAudioFrameV2::setMetadata)
|
||||
.def_readwrite("timestamp", &PyAudioFrameV2::timestamp);
|
||||
|
||||
py::class_<PyAudioFrameV3>(m, "AudioFrameV3")
|
||||
.def(py::init<int, int, int, int64_t, NDIlib_FourCC_audio_type_e,
|
||||
uint8_t *, int, const std::string &, int64_t>(),
|
||||
py::arg("sample_rate") = 48000, py::arg("no_channels") = 2,
|
||||
py::arg("no_samples") = 0,
|
||||
py::arg("timecode") = NDIlib_send_timecode_synthesize,
|
||||
py::arg("FourCC") = NDIlib_FourCC_audio_type_FLTP,
|
||||
py::arg("data") = nullptr, py::arg("channel_stride_in_bytes") = 0,
|
||||
py::arg("metadata") = nullptr, py::arg("timestamp") = 0)
|
||||
.def_readwrite("sample_rate", &PyAudioFrameV3::sample_rate)
|
||||
.def_readwrite("no_channels", &PyAudioFrameV3::no_channels)
|
||||
.def_readwrite("no_samples", &PyAudioFrameV3::no_samples)
|
||||
.def_readwrite("timecode", &PyAudioFrameV3::timecode)
|
||||
.def_readwrite("FourCC", &PyAudioFrameV3::FourCC)
|
||||
.def_property("data", nullptr, &PyAudioFrameV3::setData)
|
||||
.def_readwrite("channel_stride_in_bytes",
|
||||
&PyAudioFrameV3::channel_stride_in_bytes)
|
||||
.def_property("metadata", &PyAudioFrameV3::getMetadata,
|
||||
&PyAudioFrameV3::setMetadata)
|
||||
.def_readwrite("timestamp", &PyAudioFrameV3::timestamp);
|
||||
|
||||
py::class_<PyMetadataFrame>(m, "MetadataFrame")
|
||||
.def(py::init<int, int64_t, const std::string &>(), py::arg("length") = 0,
|
||||
py::arg("timecode") = NDIlib_send_timecode_synthesize,
|
||||
|
||||
Reference in New Issue
Block a user