Index: chromecast/media/cma/base/backend_client_callbacks.cc |
diff --git a/chromecast/media/cma/base/backend_client_callbacks.cc b/chromecast/media/cma/base/backend_client_callbacks.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bb4180e86e432b50052ee875b4db223a2566104a |
--- /dev/null |
+++ b/chromecast/media/cma/base/backend_client_callbacks.cc |
@@ -0,0 +1,62 @@ |
+// Copyright 2015 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 "chromecast/media/cma/base/backend_client_callbacks.h" |
+ |
+#include "base/bind.h" |
+#include "base/location.h" |
+#include "base/single_thread_task_runner.h" |
+#include "base/thread_task_runner_handle.h" |
+#include "chromecast/public/graphics_types.h" |
+ |
+namespace chromecast { |
+namespace media { |
+ |
+MediaComponentDeviceClientImpl::MediaComponentDeviceClientImpl( |
+ const base::Closure& eos_cb) |
+ : eos_cb_(eos_cb), task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
+ |
+MediaComponentDeviceClientImpl::~MediaComponentDeviceClientImpl() {} |
+ |
+void MediaComponentDeviceClientImpl::OnEndOfStream() { |
+ if (!eos_cb_.is_null()) { |
servolk
2015/07/27 21:25:47
Strictly speaking you shouldn't be accessing eos_c
halliwell
2015/07/28 02:19:35
Done.
|
+ if (task_runner_->BelongsToCurrentThread()) |
+ eos_cb_.Run(); |
+ else |
+ task_runner_->PostTask(FROM_HERE, eos_cb_); |
+ } |
+} |
+ |
+VideoPipelineDeviceClientImpl::VideoPipelineDeviceClientImpl( |
+ const SizeChangeCB& size_change_cb) |
+ : size_change_cb_(size_change_cb), |
+ task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
+ |
+VideoPipelineDeviceClientImpl::~VideoPipelineDeviceClientImpl() {} |
+ |
+void VideoPipelineDeviceClientImpl::OnNaturalSizeChanged(const Size& size) { |
+ if (!size_change_cb_.is_null()) { |
servolk
2015/07/27 21:25:47
ditto
halliwell
2015/07/28 02:19:35
Done.
|
+ if (task_runner_->BelongsToCurrentThread()) |
+ size_change_cb_.Run(size); |
+ else |
+ task_runner_->PostTask(FROM_HERE, base::Bind(size_change_cb_, size)); |
+ } |
+} |
+ |
+FrameStatusCBImpl::FrameStatusCBImpl(const CallbackType& cb) |
+ : cb_(cb), task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
+ |
+FrameStatusCBImpl::~FrameStatusCBImpl() {} |
+ |
+void FrameStatusCBImpl::Run(MediaComponentDevice::FrameStatus status) { |
+ if (!cb_.is_null()) { |
servolk
2015/07/27 21:25:47
ditto
halliwell
2015/07/28 02:19:35
Done.
|
+ if (task_runner_->BelongsToCurrentThread()) |
+ cb_.Run(status); |
+ else |
+ task_runner_->PostTask(FROM_HERE, base::Bind(cb_, status)); |
+ } |
+} |
+ |
+} // namespace media |
+} // namespace chromecast |