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

Unified Diff: chrome/renderer/media/cast_rtp_stream.cc

Issue 228313002: Cast: Use 2 threads for encoding on capable systems (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months 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 | « no previous file | media/cast/cast_config.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/media/cast_rtp_stream.cc
diff --git a/chrome/renderer/media/cast_rtp_stream.cc b/chrome/renderer/media/cast_rtp_stream.cc
index 4b7963c703f06d7612c63cd2fb39994c42165681..c4836007b464ecc6fb89d8397d8b2a56866104f1 100644
--- a/chrome/renderer/media/cast_rtp_stream.cc
+++ b/chrome/renderer/media/cast_rtp_stream.cc
@@ -8,6 +8,7 @@
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
+#include "base/sys_info.h"
#include "chrome/renderer/media/cast_session.h"
#include "chrome/renderer/media/cast_udp_transport.h"
#include "content/public/renderer/media_stream_audio_sink.h"
@@ -116,6 +117,19 @@ bool IsHardwareH264EncodingSupported() {
return false;
}
+int NumberOfEncodeThreads() {
+ // We want to give CPU cycles for capturing and not to saturate the system
+ // just for encoding. So on a lower end system with only 1 or 2 cores we
+ // use only one thread for encoding.
+ if (base::SysInfo::NumberOfProcessors() <= 2)
+ return 1;
+
+ // On higher end we want to use 2 threads for encoding to reduce latency.
+ // In theory a physical CPU core has maximum 2 hyperthreads. Having 3 or
+ // more logical processors means the system has at least 2 physical cores.
+ return 2;
miu 2014/04/09 00:53:42 Unless I'm missing something, the change descripti
+}
+
std::vector<CastRtpParams> SupportedAudioParams() {
// TODO(hclam): Fill in more codecs here.
std::vector<CastRtpParams> supported_params;
@@ -168,6 +182,9 @@ bool ToVideoSenderConfig(const CastRtpParams& params,
} else {
return false;
}
+ if (!config->use_external_encoder) {
+ config->number_of_encode_threads = NumberOfEncodeThreads();
+ }
return true;
}
« no previous file with comments | « no previous file | media/cast/cast_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698