Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
session_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/session_description.h
10 //! @brief Session Description Protocol.
11 
12 #ifndef ROC_SDP_SESSION_DESCRIPTION_H_
13 #define ROC_SDP_SESSION_DESCRIPTION_H_
14 
16 #include "roc_core/array.h"
17 #include "roc_core/attributes.h"
18 #include "roc_core/iarena.h"
19 #include "roc_core/list.h"
20 #include "roc_core/log.h"
21 #include "roc_core/shared_ptr.h"
22 #include "roc_core/string_buffer.h"
26 
27 namespace roc {
28 namespace sdp {
29 
30 //! SDP session description.
32 public:
33  //! Initialize empty session description
35 
36  //! Clear all fields.
37  void clear();
38 
39  //! Globally Unique Identifier for the session.
40  //! Built from a tuple of username, sess-id, nettype, addrtype, and unicast-address.
41  const char* guid() const;
42 
43  //! Set GUID
44  ROC_ATTR_NODISCARD bool set_guid(const char* start_p_origin_username,
45  const char* end_p_origin_username,
46  const char* start_p_origin_sess_id,
47  const char* end_p_origin_sess_id,
48  const char* start_p_origin_nettype,
49  const char* end_p_origin_nettype,
50  const char* start_p_origin_addr,
51  const char* end_p_origin_addr);
52 
53  //! Origin unicast address.
55 
56  //! Check and set origin unicast address from a string.
58  const char* str,
59  size_t str_len);
60 
61  //! Check and set session connection address from a string.
63  const char* str,
64  size_t str_len);
65 
66  //! Get reference to the connection data of the session.
68 
69  //! Create and add a new empty media description.
71 
72  //! Get a shared pointer to the last added media description.
74 
75  //! Get a shared pointer to the first added media description.
77 
78  //! Get a const reference to the list of media descriptions.
80 
81  //! Get list media description next to given one.
82  //!
83  //! @returns
84  //! list media description following @p element if @p element is not
85  //! last, or NULL otherwise.
86  //!
87  //! @pre
88  //! @p element should be member of the list of media descriptions.
91 
92 private:
93  core::StringBuffer guid_;
94 
95  address::SocketAddr origin_unicast_address_;
96 
97  ConnectionData session_connection_data_;
98 
99  core::List<MediaDescription> media_descriptions_;
100 
101  core::IArena& arena_;
102 };
103 
104 //! Parse SDP session description from string.
105 bool parse_sdp(const char* str, SessionDescription& result);
106 
107 } // namespace sdp
108 } // namespace roc
109 
110 #endif // ROC_SDP_SESSION_DESCRIPTION_H_
Dynamic array.
Compiler attributes.
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition: attributes.h:31
Socket address.
Definition: socket_addr.h:26
Memory arena interface.
Definition: iarena.h:23
Intrusive doubly-linked list.
Definition: list.h:35
Base class for non-copyable objects.
Definition: noncopyable.h:23
Shared ownership intrusive pointer.
Definition: shared_ptr.h:32
SDP connection data field.
SDP session description.
const address::SocketAddr & origin_unicast_address() const
Origin unicast address.
const core::SharedPtr< MediaDescription > last_media_description() const
Get a shared pointer to the last added media description.
const ConnectionData & session_connection_data()
Get reference to the connection data of the session.
ROC_ATTR_NODISCARD bool add_media_description()
Create and add a new empty media description.
ROC_ATTR_NODISCARD bool set_origin_unicast_address(address::AddrFamily addrtype, const char *str, size_t str_len)
Check and set origin unicast address from a string.
SessionDescription(core::IArena &arena)
Initialize empty session description.
const core::List< MediaDescription > get_media_descriptions() const
Get a const reference to the list of media descriptions.
const core::SharedPtr< MediaDescription > nextof_media_description(core::SharedPtr< MediaDescription > element) const
Get list media description next to given one.
const char * guid() const
Globally Unique Identifier for the session. Built from a tuple of username, sess-id,...
ROC_ATTR_NODISCARD bool set_session_connection_data(address::AddrFamily addrtype, const char *str, size_t str_len)
Check and set session connection address from a string.
void clear()
Clear all fields.
const core::SharedPtr< MediaDescription > first_media_description() const
Get a shared pointer to the first added media description.
ROC_ATTR_NODISCARD bool set_guid(const char *start_p_origin_username, const char *end_p_origin_username, const char *start_p_origin_sess_id, const char *end_p_origin_sess_id, const char *start_p_origin_nettype, const char *end_p_origin_nettype, const char *start_p_origin_addr, const char *end_p_origin_addr)
Set GUID.
Connection field in a SDP.
Memory arena interface.
Intrusive doubly-linked list.
Logging.
SDP Media Description.
AddrFamily
Address family.
Definition: addr_family.h:19
bool parse_sdp(const char *str, SessionDescription &result)
Parse SDP session description from string.
Root namespace.
Shared ownership intrusive pointer.
Socket address.
String buffer.
String builder.