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) {
