121 #include <string_view>
123 #include "../base/bytes.h"
144 enum Format : uint8_t {
162 enum Layout : uint8_t {
164 kLayoutInterleaved = 1,
222 bool operator>>(Bytes& bytes)
const noexcept;
230 [[nodiscard]]
static bool check_valid(
const Bytes& bytes) noexcept;
244 [[nodiscard]]
bool is_valid()
const noexcept;
252 bool shallow_copy(
const AudioFrame& target) noexcept;
260 bool deep_copy(
const AudioFrame& target) noexcept;
276 bool create(
size_t size) noexcept;
281 void clear() noexcept;
290 bool shallow_copy(uint8_t* data,
size_t size) noexcept;
299 bool deep_copy(uint8_t* data,
size_t size) noexcept;
308 bool fill_data(uint8_t* data,
size_t size) noexcept;
315 [[nodiscard]] uint64_t update_time_ns()
const noexcept;
322 [[nodiscard]] uint64_t duration_ns()
const noexcept;
329 [[nodiscard]] std::string_view codec()
const noexcept;
336 [[nodiscard]] std::string_view language()
const noexcept;
343 [[nodiscard]] uint32_t channel()
const noexcept;
350 [[nodiscard]] uint32_t freq()
const noexcept;
357 [[nodiscard]] uint32_t sample_rate()
const noexcept;
364 [[nodiscard]] uint32_t num_samples()
const noexcept;
371 [[nodiscard]] uint32_t bitrate()
const noexcept;
378 [[nodiscard]] uint16_t num_channels()
const noexcept;
385 [[nodiscard]] uint16_t bit_depth()
const noexcept;
392 [[nodiscard]] Format format()
const noexcept;
399 [[nodiscard]] Layout layout()
const noexcept;
406 [[nodiscard]]
const uint8_t* data()
const noexcept;
413 [[nodiscard]]
size_t size()
const noexcept;
420 [[nodiscard]]
bool is_owner()
const noexcept;
427 void set_update_time_ns(uint64_t update_time_ns) noexcept;
434 void set_duration_ns(uint64_t duration_ns) noexcept;
441 void set_codec(std::string_view codec) noexcept;
448 void set_language(std::string_view language) noexcept;
455 void set_channel(uint32_t channel) noexcept;
462 void set_freq(uint32_t freq) noexcept;
469 void set_sample_rate(uint32_t sample_rate) noexcept;
476 void set_num_samples(uint32_t num_samples) noexcept;
483 void set_bitrate(uint32_t bitrate) noexcept;
490 void set_num_channels(uint16_t num_channels) noexcept;
497 void set_bit_depth(uint16_t bit_depth) noexcept;
504 void set_format(Format format) noexcept;
511 void set_layout(Layout layout) noexcept;
518 uint8_t& get_reserved() noexcept {
return reserved_buf_; }
525 uint32_t& get_reserved2() noexcept {
return reserved_buf2_; }
529 static constexpr
bool kZerocopyTypes{
true};
532 uint8_t* data_{
nullptr};
534 uint64_t update_time_ns_{0};
535 uint64_t duration_ns_{0};
537 char language_[8]{0};
538 uint32_t channel_{0};
540 uint32_t sample_rate_{0};
541 uint32_t num_samples_{0};
542 uint32_t bitrate_{0};
543 uint16_t num_channels_{0};
544 uint16_t bit_depth_{0};
545 Format format_{kFormatUnknown};
546 Layout layout_{kLayoutUnknown};
547 bool is_owner_{
false};
548 uint8_t reserved_buf_{0};
549 uint32_t reserved_buf2_{0};
551 static constexpr uint32_t kMagicNumberBegin{0x98B7F1AA};
552 static constexpr uint32_t kMagicNumberEnd{0x98B7F1AF};
constexpr bool is_valid() noexcept
Definition: name_detector.h:382
size_t get_serialized_size(const T &src) noexcept
Returns a serialised-size hint for src with explicit codec tag.
Definition: serializer-inl.h:298
VLINK_EXPORT std::ostream & operator<<(std::ostream &ostream, const BasePtr &status) noexcept
Writes the human-readable description of status to ostream.
struct VLINK_EXPORT_AND_ALIGNED(8) AudioFrame final
Definition: audio_frame.h:140
128-byte POD container holding one audio packet with full sample-format metadata.