Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: webrtc/voice_engine/voe_base_impl.cc

Issue 1493663002: Removing some unnecessary string manipulation code from VoEBase::GetVersion(). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: comment Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/voice_engine/voe_base_impl.h ('k') | webrtc/voice_engine/voe_base_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/voice_engine/voe_base_impl.cc
diff --git a/webrtc/voice_engine/voe_base_impl.cc b/webrtc/voice_engine/voe_base_impl.cc
index 60a649eefd5770443bf8cdde279dfbbee2655440..0b6c13c45822f7ff20437cac13f4befb9f2b357c 100644
--- a/webrtc/voice_engine/voe_base_impl.cc
+++ b/webrtc/voice_engine/voe_base_impl.cc
@@ -582,69 +582,19 @@ int VoEBaseImpl::StopSend(int channel) {
}
int VoEBaseImpl::GetVersion(char version[1024]) {
- static_assert(kVoiceEngineVersionMaxMessageSize == 1024, "");
-
if (version == nullptr) {
shared_->SetLastError(VE_INVALID_ARGUMENT, kTraceError);
- return (-1);
- }
-
- char versionBuf[kVoiceEngineVersionMaxMessageSize];
- char* versionPtr = versionBuf;
-
- int32_t len = 0;
- int32_t accLen = 0;
-
- len = AddVoEVersion(versionPtr);
- if (len == -1) {
return -1;
}
- versionPtr += len;
- accLen += len;
- assert(accLen < kVoiceEngineVersionMaxMessageSize);
-
-#ifdef WEBRTC_EXTERNAL_TRANSPORT
- len = AddExternalTransportBuild(versionPtr);
- if (len == -1) {
- return -1;
- }
- versionPtr += len;
- accLen += len;
- assert(accLen < kVoiceEngineVersionMaxMessageSize);
-#endif
-
- memcpy(version, versionBuf, accLen);
- version[accLen] = '\0';
-
- // to avoid the truncation in the trace, split the string into parts
- char partOfVersion[256];
- for (int partStart = 0; partStart < accLen;) {
- memset(partOfVersion, 0, sizeof(partOfVersion));
- int partEnd = partStart + 180;
- while (version[partEnd] != '\n' && version[partEnd] != '\0') {
- partEnd--;
- }
- if (partEnd < accLen) {
- memcpy(partOfVersion, &version[partStart], partEnd - partStart);
- } else {
- memcpy(partOfVersion, &version[partStart], accLen - partStart);
- }
- partStart = partEnd;
- }
+ std::string versionString = VoiceEngine::GetVersionString();
+ RTC_DCHECK_GT(1024u, versionString.size() + 1);
+ char* end = std::copy(versionString.cbegin(), versionString.cend(), version);
+ end[0] = '\n';
+ end[1] = '\0';
return 0;
}
-int32_t VoEBaseImpl::AddVoEVersion(char* str) const {
- return sprintf(str, "VoiceEngine 4.1.0\n");
-}
-
-#ifdef WEBRTC_EXTERNAL_TRANSPORT
-int32_t VoEBaseImpl::AddExternalTransportBuild(char* str) const {
- return sprintf(str, "External transport build\n");
-}
-#endif
-
int VoEBaseImpl::LastError() { return (shared_->statistics().LastError()); }
int32_t VoEBaseImpl::StartPlayout() {
« no previous file with comments | « webrtc/voice_engine/voe_base_impl.h ('k') | webrtc/voice_engine/voe_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698