Ring Daemon
Loading...
Searching...
No Matches
media_attribute.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2004-2026 Savoir-faire Linux Inc.
3
*
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16
*/
17
18
#pragma once
19
20
#ifdef HAVE_CONFIG_H
21
#include "config.h"
22
#endif
23
24
#include "
media/media_codec.h
"
25
#include "
jami.h
"
26
27
namespace
jami
{
28
29
class
MediaAttribute
30
{
31
public
:
32
MediaAttribute
(
MediaType
type =
MediaType::MEDIA_NONE
,
33
bool
muted
=
false
,
34
bool
secure =
true
,
35
bool
enabled =
false
,
36
std::string_view source = {},
37
std::string_view
label
= {},
38
bool
hold =
false
)
39
:
type_
(type)
40
,
muted_
(
muted
)
41
,
secure_
(secure)
42
,
enabled_
(enabled)
43
,
sourceUri_
(source)
44
,
label_
(
label
)
45
,
hold_
(hold)
46
{}
47
48
MediaAttribute
(
const
libjami::MediaMap
&
mediaMap
,
bool
secure);
49
50
static
std::vector<MediaAttribute>
buildMediaAttributesList
(
const
std::vector<libjami::MediaMap>&
mediaList
,
51
bool
secure);
52
53
static
MediaType
stringToMediaType
(
const
std::string& mediaType);
54
55
static
std::pair<bool, MediaType>
getMediaType
(
const
libjami::MediaMap
& map);
56
57
static
std::pair<bool, bool>
getBoolValue
(
const
libjami::MediaMap
&
mediaMap
,
const
std::string& key);
58
59
static
std::pair<bool, std::string>
getStringValue
(
const
libjami::MediaMap
&
mediaMap
,
const
std::string& key);
60
61
// Return true if at least one media has a matching type.
62
static
bool
hasMediaType
(
const
std::vector<MediaAttribute>&
mediaList
,
MediaType
type);
63
64
// Return a string of a boolean
65
static
char
const
*
boolToString
(
bool
val
);
66
67
// Return a string of the media type
68
static
char
const
*
mediaTypeToString
(
MediaType
type);
69
70
// Convert MediaAttribute to MediaMap
71
static
libjami::MediaMap
toMediaMap
(
const
MediaAttribute&
mediaAttr
);
72
73
// Serialize a vector of MediaAttribute to a vector of MediaMap
74
static
std::vector<libjami::MediaMap>
mediaAttributesToMediaMaps
(
const
std::vector<MediaAttribute>&
mediaAttrList
);
75
76
std::string
toString
(
bool
full
=
false
)
const
;
77
78
MediaType
type_
{
MediaType::MEDIA_NONE
};
79
bool
muted_
{
false
};
80
bool
secure_
{
true
};
81
bool
enabled_
{
false
};
82
std::string
sourceUri_
{};
83
std::string
label_
{};
84
bool
hold_
{
false
};
85
86
// NOTE: the hold and mute attributes are related but not
87
// tightly coupled. A hold/resume operation should always
88
// trigger a new re-invite to notify the change in media
89
// direction. For instance, on an active call, the hold action
90
// would change the media direction attribute from "sendrecv"
91
// to "sendonly". A new SDP with the new media direction will
92
// be generated and sent to the peer in the re-invite.
93
// In contrast, the mute attribute is a local attribute, and
94
// describes the presence (or absence) of the media signal in
95
// the stream. In other words, the mute action can be performed
96
// with or without a media direction change (no re-invite).
97
// For instance, muting the audio can be done by disabling the
98
// audio input (capture) of the encoding session, resulting in
99
// sending RTP packets without actual audio (silence).
100
101
bool
hasValidVideo
();
102
};
103
}
// namespace jami
jami::MediaAttribute
Definition
media_attribute.h:30
jami::MediaAttribute::stringToMediaType
static MediaType stringToMediaType(const std::string &mediaType)
Definition
media_attribute.cpp:71
jami::MediaAttribute::buildMediaAttributesList
static std::vector< MediaAttribute > buildMediaAttributesList(const std::vector< libjami::MediaMap > &mediaList, bool secure)
Definition
media_attribute.cpp:58
jami::MediaAttribute::muted_
bool muted_
Definition
media_attribute.h:79
jami::MediaAttribute::hold_
bool hold_
Definition
media_attribute.h:84
jami::MediaAttribute::hasValidVideo
bool hasValidVideo()
Definition
media_attribute.cpp:202
jami::MediaAttribute::getMediaType
static std::pair< bool, MediaType > getMediaType(const libjami::MediaMap &map)
Definition
media_attribute.cpp:81
jami::MediaAttribute::secure_
bool secure_
Definition
media_attribute.h:80
jami::MediaAttribute::MediaAttribute
MediaAttribute(MediaType type=MediaType::MEDIA_NONE, bool muted=false, bool secure=true, bool enabled=false, std::string_view source={}, std::string_view label={}, bool hold=false)
Definition
media_attribute.h:32
jami::MediaAttribute::hasMediaType
static bool hasMediaType(const std::vector< MediaAttribute > &mediaList, MediaType type)
Definition
media_attribute.cpp:145
jami::MediaAttribute::mediaAttributesToMediaMaps
static std::vector< libjami::MediaMap > mediaAttributesToMediaMaps(const std::vector< MediaAttribute > &mediaAttrList)
Definition
media_attribute.cpp:168
jami::MediaAttribute::label_
std::string label_
Definition
media_attribute.h:83
jami::MediaAttribute::sourceUri_
std::string sourceUri_
Definition
media_attribute.h:82
jami::MediaAttribute::toString
std::string toString(bool full=false) const
Definition
media_attribute.cpp:180
jami::MediaAttribute::type_
MediaType type_
Definition
media_attribute.h:78
jami::MediaAttribute::getStringValue
static std::pair< bool, std::string > getStringValue(const libjami::MediaMap &mediaMap, const std::string &key)
Definition
media_attribute.cpp:116
jami::MediaAttribute::mediaTypeToString
static char const * mediaTypeToString(MediaType type)
Definition
media_attribute.cpp:133
jami::MediaAttribute::toMediaMap
static libjami::MediaMap toMediaMap(const MediaAttribute &mediaAttr)
Definition
media_attribute.cpp:153
jami::MediaAttribute::enabled_
bool enabled_
Definition
media_attribute.h:81
jami::MediaAttribute::getBoolValue
static std::pair< bool, bool > getBoolValue(const libjami::MediaMap &mediaMap, const std::string &key)
Definition
media_attribute.cpp:98
jami::MediaAttribute::boolToString
static char const * boolToString(bool val)
Definition
media_attribute.cpp:127
jami.h
media_codec.h
jami
Definition
account.cpp:56
jami::emitSignal
void emitSignal(Args... args)
Definition
jami_signal.h:64
jami::MediaType
MediaType
Definition
media_codec.h:44
jami::MEDIA_NONE
@ MEDIA_NONE
Definition
media_codec.h:45
libjami::MediaMap
std::map< std::string, std::string > MediaMap
Definition
jami.h:271
src
media
media_attribute.h
Generated on Fri Apr 3 2026 14:23:10 for Ring Daemon by
1.9.8