1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
|
Description: Always use std::to_string to serialize ints
Origin: https://github.com/TelegramMessenger/tgcalls/commit/fecf542a74b0eb2c15ec7820d16653c57f4db27e
https://github.com/TelegramMessenger/tgcalls/commit/012f7a75ba7e20e1790203d02aedf573e3551d2f
Author: John Preston <johnprestonmail@gmail.com>
Acked-By: Nicholas Guriev <guriev-ns@ya.ru>
Last-Update: Thu, 04 May 2023 12:44:16 +0300
--- a/Telegram/ThirdParty/tgcalls/tgcalls/group/GroupInstanceCustomImpl.cpp
+++ b/Telegram/ThirdParty/tgcalls/tgcalls/group/GroupInstanceCustomImpl.cpp
@@ -102,15 +102,11 @@ static int stringToInt(std::string const &string) {
}
static std::string intToString(int value) {
- std::ostringstream stringStream;
- stringStream << value;
- return stringStream.str();
+ return std::to_string(value);
}
static std::string uint32ToString(uint32_t value) {
- std::ostringstream stringStream;
- stringStream << value;
- return stringStream.str();
+ return std::to_string(value);
}
static uint32_t stringToUInt32(std::string const &string) {
@@ -129,6 +125,7 @@ static uint16_t stringToUInt16(std::string const &string) {
static std::string formatTimestampMillis(int64_t timestamp) {
std::ostringstream stringStream;
+ stringStream.imbue(std::locale::classic());
stringStream << std::fixed << std::setprecision(3) << (double)timestamp / 1000.0;
return stringStream.str();
}
--- a/Telegram/ThirdParty/tgcalls/tgcalls/v2/ContentNegotiation.cpp
+++ b/Telegram/ThirdParty/tgcalls/tgcalls/v2/ContentNegotiation.cpp
@@ -187,11 +187,7 @@ cricket::ContentInfo createInactiveContentInfo(std::string const &contentId) {
}
std::string contentIdBySsrc(uint32_t ssrc) {
- std::ostringstream contentIdString;
-
- contentIdString << ssrc;
-
- return contentIdString.str();
+ return std::to_string(ssrc);
}
}
@@ -639,11 +635,10 @@ void ContentNegotiationContext::setAnswer(std::unique_ptr<ContentNegotiationCont
}
std::string ContentNegotiationContext::takeNextOutgoingChannelId() {
- std::ostringstream result;
- result << "m" << _nextOutgoingChannelId;
+ const auto result = "m" + std::to_string(_nextOutgoingChannelId);
_nextOutgoingChannelId++;
-
- return result.str();
+
+ return result;
}
std::unique_ptr<ContentNegotiationContext::CoordinatedState> ContentNegotiationContext::coordinatedState() const {
--- a/Telegram/ThirdParty/tgcalls/tgcalls/v2/InstanceV2Impl.cpp
+++ b/Telegram/ThirdParty/tgcalls/tgcalls/v2/InstanceV2Impl.cpp
@@ -136,13 +136,12 @@ public:
audioOptions.noise_suppression = true;
}
- std::ostringstream contentId;
- contentId << _ssrc;
+ const auto contentId = std::to_string(_ssrc);
std::vector<std::string> streamIds;
- streamIds.push_back(contentId.str());
+ streamIds.push_back(contentId);
- _outgoingAudioChannel = _channelManager->CreateVoiceChannel(call, cricket::MediaConfig(), contentId.str(), false, NativeNetworkingImpl::getDefaulCryptoOptions(), audioOptions);
+ _outgoingAudioChannel = _channelManager->CreateVoiceChannel(call, cricket::MediaConfig(), contentId, false, NativeNetworkingImpl::getDefaulCryptoOptions(), audioOptions);
_threads->getNetworkThread()->BlockingCall([&]() {
_outgoingAudioChannel->SetRtpTransport(rtpTransport);
});
@@ -272,12 +271,9 @@ public:
audioOptions.audio_jitter_buffer_fast_accelerate = true;
audioOptions.audio_jitter_buffer_min_delay_ms = 50;
- std::ostringstream contentId;
- contentId << _ssrc;
+ const auto streamId = std::to_string(_ssrc);
- std::string streamId = contentId.str();
-
- _audioChannel = _channelManager->CreateVoiceChannel(call, cricket::MediaConfig(), contentId.str(), false, NativeNetworkingImpl::getDefaulCryptoOptions(), audioOptions);
+ _audioChannel = _channelManager->CreateVoiceChannel(call, cricket::MediaConfig(), streamId, false, NativeNetworkingImpl::getDefaulCryptoOptions(), audioOptions);
_threads->getNetworkThread()->BlockingCall([&]() {
_audioChannel->SetRtpTransport(rtpTransport);
});
@@ -401,10 +397,7 @@ public:
cricket::VideoOptions videoOptions;
videoOptions.is_screencast = isScreencast;
- std::ostringstream contentId;
- contentId << mediaContent.ssrc;
-
- _outgoingVideoChannel = _channelManager->CreateVideoChannel(call, cricket::MediaConfig(), contentId.str(), false, NativeNetworkingImpl::getDefaulCryptoOptions(), videoOptions, videoBitrateAllocatorFactory);
+ _outgoingVideoChannel = _channelManager->CreateVideoChannel(call, cricket::MediaConfig(), std::to_string(mediaContent.ssrc), false, NativeNetworkingImpl::getDefaulCryptoOptions(), videoOptions, videoBitrateAllocatorFactory);
_threads->getNetworkThread()->BlockingCall([&]() {
_outgoingVideoChannel->SetRtpTransport(rtpTransport);
});
@@ -702,10 +695,9 @@ public:
_videoBitrateAllocatorFactory = webrtc::CreateBuiltinVideoBitrateAllocatorFactory();
- std::ostringstream contentId;
- contentId << mediaContent.ssrc;
+ const auto contentId = std::to_string(mediaContent.ssrc);
- _videoChannel = _channelManager->CreateVideoChannel(call, cricket::MediaConfig(), contentId.str(), false, NativeNetworkingImpl::getDefaulCryptoOptions(), cricket::VideoOptions(), _videoBitrateAllocatorFactory.get());
+ _videoChannel = _channelManager->CreateVideoChannel(call, cricket::MediaConfig(), contentId, false, NativeNetworkingImpl::getDefaulCryptoOptions(), cricket::VideoOptions(), _videoBitrateAllocatorFactory.get());
_threads->getNetworkThread()->BlockingCall([&]() {
_videoChannel->SetRtpTransport(rtpTransport);
});
@@ -750,7 +742,7 @@ public:
videoRecvStreamParams.ssrcs = allSsrcs;
videoRecvStreamParams.cname = "cname";
- videoRecvStreamParams.set_stream_ids({ contentId.str() });
+ videoRecvStreamParams.set_stream_ids({ contentId });
auto incomingVideoDescription = std::make_unique<cricket::VideoContentDescription>();
for (const auto &rtpExtension : mediaContent.rtpExtensions) {
@@ -1978,14 +1970,10 @@ public:
for (const auto &record : _networkStateLogRecords) {
json11::Json::object jsonRecord;
- std::ostringstream timestampString;
-
if (baseTimestamp == 0) {
baseTimestamp = record.timestamp;
}
- timestampString << (record.timestamp - baseTimestamp);
-
- jsonRecord.insert(std::make_pair("t", json11::Json(timestampString.str())));
+ jsonRecord.insert(std::make_pair("t", json11::Json(std::to_string(record.timestamp - baseTimestamp))));
jsonRecord.insert(std::make_pair("c", json11::Json(record.record.isConnected ? 1 : 0)));
if (record.record.route) {
jsonRecord.insert(std::make_pair("local", json11::Json(record.record.route->localDescription)));
--- a/Telegram/ThirdParty/tgcalls/tgcalls/v2/InstanceV2ReferenceImpl.cpp
+++ b/Telegram/ThirdParty/tgcalls/tgcalls/v2/InstanceV2ReferenceImpl.cpp
@@ -653,10 +653,8 @@ public:
if (server.isTurn) {
webrtc::PeerConnectionInterface::IceServer mappedServer;
- std::ostringstream uri;
- uri << "turn:" << address.HostAsURIString() << ":" << server.port;
-
- mappedServer.urls.push_back(uri.str());
+ mappedServer.urls.push_back(
+ "turn:" + address.HostAsURIString() + ":" + std::to_string(server.port));
mappedServer.username = server.login;
mappedServer.password = server.password;
@@ -664,10 +662,8 @@ public:
} else {
webrtc::PeerConnectionInterface::IceServer mappedServer;
- std::ostringstream uri;
- uri << "stun:" << address.HostAsURIString() << ":" << server.port;
-
- mappedServer.urls.push_back(uri.str());
+ mappedServer.urls.push_back(
+ "stun:" + address.HostAsURIString() + ":" + std::to_string(server.port));
peerConnectionConfiguration.servers.push_back(mappedServer);
}
@@ -1455,14 +1451,10 @@ public:
for (const auto &record : _networkStateLogRecords) {
json11::Json::object jsonRecord;
- std::ostringstream timestampString;
-
if (baseTimestamp == 0) {
baseTimestamp = record.timestamp;
}
- timestampString << (record.timestamp - baseTimestamp);
-
- jsonRecord.insert(std::make_pair("t", json11::Json(timestampString.str())));
+ jsonRecord.insert(std::make_pair("t", json11::Json(std::to_string(record.timestamp - baseTimestamp))));
jsonRecord.insert(std::make_pair("c", json11::Json(record.record.isConnected ? 1 : 0)));
if (record.record.route) {
jsonRecord.insert(std::make_pair("local", json11::Json(record.record.route->localDescription)));
--- a/Telegram/ThirdParty/tgcalls/tgcalls/v2/Signaling.cpp
+++ b/Telegram/ThirdParty/tgcalls/tgcalls/v2/Signaling.cpp
@@ -11,9 +11,7 @@ namespace tgcalls {
namespace signaling {
static std::string uint32ToString(uint32_t value) {
- std::ostringstream stringStream;
- stringStream << value;
- return stringStream.str();
+ return std::to_string(value);
}
static uint32_t stringToUInt32(std::string const &string) {
--- a/Telegram/ThirdParty/tgcalls/tgcalls/v2_4_0_0/InstanceV2_4_0_0Impl.cpp
+++ b/Telegram/ThirdParty/tgcalls/tgcalls/v2_4_0_0/InstanceV2_4_0_0Impl.cpp
@@ -57,9 +57,7 @@ namespace tgcalls {
namespace {
static std::string intToString(int value) {
- std::ostringstream stringStream;
- stringStream << value;
- return stringStream.str();
+ return std::to_string(value);
}
static VideoCaptureInterfaceObject *GetVideoCaptureAssumingSameThread(VideoCaptureInterface *videoCapture) {
--- a/Telegram/ThirdParty/tgcalls/tgcalls/v2_4_0_0/Signaling_4_0_0.cpp
+++ b/Telegram/ThirdParty/tgcalls/tgcalls/v2_4_0_0/Signaling_4_0_0.cpp
@@ -10,9 +10,7 @@ namespace tgcalls {
namespace signaling_4_0_0 {
static std::string uint32ToString(uint32_t value) {
- std::ostringstream stringStream;
- stringStream << value;
- return stringStream.str();
+ return std::to_string(value);
}
static uint32_t stringToUInt32(std::string const &string) {
|