Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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 
17 #include "roc_audio/pcm_format.h"
18 #include "roc_audio/sample_spec.h"
19 #include "roc_core/attributes.h"
20 #include "roc_core/iarena.h"
21 #include "roc_rtp/headers.h"
22 
23 namespace roc {
24 namespace rtp {
25 
26 //! RTP encoding.
27 struct 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.
73 ROC_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.
ROC_ATTR_NODISCARD 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
audio::IFrameDecoder *(* new_decoder)(core::IArena &arena, const audio::SampleSpec &sample_spec)
Create frame decoder.
Definition: encoding.h:42
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
unsigned int payload_type
Payload type.
Definition: encoding.h:29