Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
encoding.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Roc Streaming authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_rtp/encoding.h
10//! @brief RTP encoding.
11
12#ifndef ROC_RTP_ENCODING_H_
13#define ROC_RTP_ENCODING_H_
14
19#include "roc_core/attributes.h"
20#include "roc_core/iarena.h"
21#include "roc_rtp/headers.h"
22
23namespace roc {
24namespace rtp {
25
26//! RTP encoding.
27struct Encoding {
28 //! Payload type.
29 unsigned int payload_type;
30
31 //! Encoding specification.
33
34 //! Packet flags.
35 unsigned packet_flags;
36
37 //! Create frame encoder.
38 audio::IFrameEncoder* (*new_encoder)(core::IArena& arena,
40
41 //! Create frame decoder.
42 audio::IFrameDecoder* (*new_decoder)(core::IArena& arena,
44
45 //! Initialize.
47 : payload_type(0)
48 , sample_spec()
49 , packet_flags(0)
50 , new_encoder(NULL)
51 , new_decoder(NULL) {
52 }
53};
54
55//! Parse RTP encoding from string.
56//!
57//! @remarks
58//! The input string should have the form:
59//! - "<id>:<spec>"
60//!
61//! Where:
62//! - "<id>" is payload id, a positive integer
63//! - "<spec>" is sample spec, in form "<format>/<rate>/<channel>"
64//!
65//! See audio::parse_sample_spec() for details on "<spec>" format.
66//!
67//! Examples:
68//! - "55:s16/44100/stereo"
69//! - "77:f32/96000/20-30"
70//!
71//! @returns
72//! false if string can't be parsed.
73ROC_ATTR_NODISCARD bool parse_encoding(const char* str, Encoding& result);
74
75} // namespace rtp
76} // namespace roc
77
78#endif // ROC_RTP_ENCODING_H_
Compiler attributes.
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition attributes.h:31
Audio frame decoder interface.
Audio frame encoder interface.
Sample specification. Describes sample rate and channels.
Definition sample_spec.h:30
Memory arena interface.
Definition iarena.h:23
Memory arena interface.
Audio frame decoder interface.
Audio frame encoder interface.
bool parse_encoding(const char *str, Encoding &result)
Parse RTP encoding from string.
Root namespace.
PCM format.
RTP headers.
Sample specifications.
RTP encoding.
Definition encoding.h:27
audio::IFrameEncoder *(* new_encoder)(core::IArena &arena, const audio::SampleSpec &sample_spec)
Create frame encoder.
Definition encoding.h:38
unsigned packet_flags
Packet flags.
Definition encoding.h:35
audio::SampleSpec sample_spec
Encoding specification.
Definition encoding.h:32
Encoding()
Initialize.
Definition encoding.h:46
audio::IFrameDecoder *(* new_decoder)(core::IArena &arena, const audio::SampleSpec &sample_spec)
Create frame decoder.
Definition encoding.h:42
unsigned int payload_type
Payload type.
Definition encoding.h:29