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

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: merged 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 f2297c99e0b69bb5d82d6963d68d2be84ffca098..675d1d10de97f876c3f789b91c1017b3d9733e75 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"
@@ -119,6 +120,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;
+}
+
std::vector<CastRtpParams> SupportedAudioParams() {
// TODO(hclam): Fill in more codecs here.
std::vector<CastRtpParams> supported_params;
@@ -173,6 +187,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