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

Unified Diff: media/cast/test/utility/standalone_cast_environment.cc

Issue 184813009: Cast Streaming API end-to-end browser_test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed hubbe's comments, and fixed threading/shutdown issues. Created 6 years, 10 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
Index: media/cast/test/utility/standalone_cast_environment.cc
diff --git a/media/cast/test/utility/standalone_cast_environment.cc b/media/cast/test/utility/standalone_cast_environment.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a5bbf074f65119a9fcddf93990a63034beff49bf
--- /dev/null
+++ b/media/cast/test/utility/standalone_cast_environment.cc
@@ -0,0 +1,53 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/cast/test/utility/standalone_cast_environment.h"
+
+#include "base/time/default_tick_clock.h"
+
+namespace media {
+namespace cast {
+
+StandaloneCastEnvironment::StandaloneCastEnvironment(
+ const CastLoggingConfig& logging_config)
+ : CastEnvironment(
hubbe 2014/03/06 19:54:43 Just use the 7-argument constructor, no need to sp
miu 2014/03/07 22:40:29 Done.
+ make_scoped_ptr<base::TickClock>(new base::DefaultTickClock()),
+ logging_config),
+ main_thread_("StandaloneCastEnvironment Main"),
+ audio_encode_thread_("StandaloneCastEnvironment Audio Encode"),
+ audio_decode_thread_("StandaloneCastEnvironment Audio Decode"),
+ video_encode_thread_("StandaloneCastEnvironment Video Encode"),
+ video_decode_thread_("StandaloneCastEnvironment Video Decode"),
+ transport_thread_("StandaloneCastEnvironment Transport") {
+#define CREATE_TASK_RUNNER(name, options) \
+ name##_thread_.StartWithOptions(options); \
+ CastEnvironment::name##_thread_proxy_ = name##_thread_.message_loop_proxy()
+
+ CREATE_TASK_RUNNER(main,
+ base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
+ CREATE_TASK_RUNNER(audio_encode, base::Thread::Options());
+ CREATE_TASK_RUNNER(audio_decode, base::Thread::Options());
+ CREATE_TASK_RUNNER(video_encode, base::Thread::Options());
+ CREATE_TASK_RUNNER(video_decode, base::Thread::Options());
+ CREATE_TASK_RUNNER(transport, base::Thread::Options());
+
+#undef CREATE_TASK_RUNNER
+}
+
+StandaloneCastEnvironment::~StandaloneCastEnvironment() {
+ DCHECK(CalledOnValidThread());
+}
+
+void StandaloneCastEnvironment::Shutdown() {
+ DCHECK(CalledOnValidThread());
+ main_thread_.Stop();
+ audio_encode_thread_.Stop();
+ audio_decode_thread_.Stop();
+ video_encode_thread_.Stop();
+ video_decode_thread_.Stop();
+ transport_thread_.Stop();
+}
+
+} // namespace cast
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698