Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
media_description.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 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_sdp/media_description.h
10//! @brief SDP Media Description.
11
12#ifndef ROC_SDP_MEDIA_DESCRIPTION_H_
13#define ROC_SDP_MEDIA_DESCRIPTION_H_
14
16#include "roc_core/attributes.h"
17#include "roc_core/list.h"
18#include "roc_core/list_node.h"
19#include "roc_core/log.h"
21#include "roc_core/shared_ptr.h"
27#include "roc_sdp/media_type.h"
28
29namespace roc {
30namespace sdp {
31
32//! SDP media description.
33//! @code
34//! m=<type> <port> <proto> <fmt>
35//! @endcode
36class MediaDescription : public core::RefCounted<MediaDescription, core::ArenaAllocation>,
37 public core::ListNode<> {
38public:
39 //! Initialize empty media description
41
42 //! Clear all fields.
43 void clear();
44
45 //! Media type.
46 MediaType type() const;
47
48 //! Transport port.
49 int port() const;
50
51 //! Number of transport port(s).
52 int nb_ports() const;
53
54 //! Transport protocol.
56
57 //! Default media payload id.
58 unsigned default_payload_id() const;
59
60 //! Number of payload ids.
61 size_t nb_payload_ids() const;
62
63 //! Get the payload id that was listed at the i position in the media description.
64 unsigned payload_id(size_t i) const;
65
66 //! Number of connection data.
67 size_t nb_connection_data() const;
68
69 //! Get the reference of the i-th connection data that was listed just after the media
70 //! description.
71 const ConnectionData& connection_data(size_t i) const;
72
73 //! Set media type.
75
76 //! Set proto.
78
79 //! Set transport port.
81
82 //! Set number of transport port(s).
84
85 //! Add a media payload id.
87
88 //! Add a connection field from a string.
90 add_connection_data(address::AddrFamily addrtype, const char* str, size_t str_len);
91
92private:
93 MediaType type_;
94 int port_;
95 int nb_ports_;
96 MediaTransport transport_;
97 core::Array<unsigned, 2> payload_ids_;
98
99 core::Array<ConnectionData, 1> connection_data_;
100};
101
102} // namespace sdp
103} // namespace roc
104
105#endif // ROC_SDP_MEDIA_DESCRIPTION_H_
Compiler attributes.
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition attributes.h:31
IArena & arena() const
Get arena.
Memory arena interface.
Definition iarena.h:23
Base class for List element.
Definition list_node.h:48
Base class for object with reference counter.
Definition ref_counted.h:40
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
SDP connection data field.
SDP media description.
void clear()
Clear all fields.
const ConnectionData & connection_data(size_t i) const
Get the reference of the i-th connection data that was listed just after the media description.
size_t nb_connection_data() const
Number of connection data.
int nb_ports() const
Number of transport port(s).
MediaTransport transport() const
Transport protocol.
bool set_port(long port)
Set transport port.
int port() const
Transport port.
unsigned default_payload_id() const
Default media payload id.
bool add_connection_data(address::AddrFamily addrtype, const char *str, size_t str_len)
Add a connection field from a string.
bool set_type(MediaType type)
Set media type.
size_t nb_payload_ids() const
Number of payload ids.
unsigned payload_id(size_t i) const
Get the payload id that was listed at the i position in the media description.
bool add_payload_id(unsigned payload_id)
Add a media payload id.
bool set_transport(MediaTransport transport)
Set proto.
MediaType type() const
Media type.
MediaDescription(core::IArena &arena)
Initialize empty media description.
bool set_nb_ports(long nb_ports)
Set number of transport port(s).
Connection field in a SDP.
Intrusive doubly-linked list.
Linked list node.
Logging.
SDP media transport protocol.
SDP media description type.
AddrFamily
Address family.
Definition addr_family.h:19
MediaType
Media type.
Definition media_type.h:19
MediaTransport
Media transport protocol.
Root namespace.
Base class for object with reference counter.
Shared ownership intrusive pointer.
Socket address.
String buffer.
String builder.
Dynamic list of strings.