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

Unified Diff: content/browser/media/audio_output_impl.cc

Issue 1856673002: Mojofication of the Chrome Audio Rendering Prototype Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
Index: content/browser/media/audio_output_impl.cc
diff --git a/content/browser/media/audio_output_impl.cc b/content/browser/media/audio_output_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1b2d9acecccc0df6b134c4b7a8fb751ee0e94cae
--- /dev/null
+++ b/content/browser/media/audio_output_impl.cc
@@ -0,0 +1,125 @@
+// 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 "content/browser/media/audio_output_impl.h"
+
+#include <utility>
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/files/file.h"
+#include "base/logging.h"
+#include "base/memory/weak_ptr.h"
+#include "base/strings/string_number_conversions.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/browser/media/webrtc/webrtc_internals.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/common/child_process_host.h"
+#include "mojo/public/cpp/system/handle.h"
+
+namespace content {
+
+media::AudioParameters convert(
+ const mojom::AudioOutputStreamParametersPtr& input) {
+ media::AudioParameters output(
+ static_cast<media::AudioParameters::Format>(input->format_),
+ static_cast<media::ChannelLayout>(input->channel_layout_),
+ input->sample_rate_, input->bits_per_sample_, input->frames_per_buffer_);
+ output.set_channels(input->channels_);
+ output.set_effects(input->effects_);
+ return output;
+}
+
+AudioOutputStreamImpl::AudioOutputStreamImpl(
+ mojo::InterfaceRequest<AudioOutputStream> request,
+ AudioEntry* entry,
+ int stream_id,
+ AudioRendererHost* audio_renderer_host)
+ : binding_(this, std::move(request)),
+ entry_(entry),
+ stream_id_(stream_id),
+ audio_renderer_host_(audio_renderer_host) {
+ DLOG(WARNING) << "AudioOutputImpl::AudioOutputImpl";
+};
+
+void AudioOutputStreamImpl::set(int a) {
+ DLOG(WARNING) << "set" << a_ << "set" << a;
+ a_ = a;
+};
+
+void AudioOutputStreamImpl::Play(const PlayCallback& callback) {
+ DLOG(WARNING) << "play" << a_;
+ DLOG(WARNING) << "play" << stream_id_;
+ audio_renderer_host_->OnPlayEntry(entry_);
+ // entry->controller()->Play();
+ // audio_log_->OnStarted(stream_id);
+ callback.Run(true);
+};
+
+AudioOutputStreamImpl::~AudioOutputStreamImpl(){};
+
+AudioRendererHost* AudioOutputImpl::audio_renderer_host_ = 0;
+
+AudioOutputImpl::AudioOutputImpl(AudioRendererHost* audio_renderer_host,
+ mojom::AudioOutputRequest request)
+ : binding_(this) {
+ audio_renderer_host_ = audio_renderer_host;
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&AudioOutputImpl::InitMojo, base::Unretained(this),
+ base::Passed(&request)));
+}
+
+AudioOutputImpl::~AudioOutputImpl() {
+ DLOG(WARNING) << "AudioOutputImpl::~AudioOutputImpl";
+}
+
+void AudioOutputImpl::CloseStream(int32_t id) {
+ // DCHECK(thread_checker_.CalledOnValidThread());
+ DLOG(WARNING) << "Close mojo" << id;
+ audio_renderer_host_->OnCloseStream(id);
+};
+
+void AudioOutputImpl::DoCloseStream(int32_t id) {
+ DLOG(WARNING) << "do Close mojo" << id;
+ audio_renderer_host_->OnCloseStream(id);
+};
+
+void AudioOutputImpl::CreateStream(int stream_id,
+ int render_frame_id,
+ mojom::AudioOutputStreamParametersPtr params,
+ const CreateStreamCallback& callback) {
+ DLOG(WARNING) << "AudioOutputImpl::CreateStream" << stream_id;
+ mojom::AudioOutputStreamPtr stream;
+ media::AudioParameters audio_params = convert(params);
+ scoped_ptr<AudioOutputStreamImpl> stream_ptr(new AudioOutputStreamImpl(
+ mojo::GetProxy(&stream), 0, stream_id, audio_renderer_host_));
+ stream_ptr->set(5);
+ audio_renderer_host_->OnCreateStreamMojo(
+ stream_id, render_frame_id, audio_params, std::move(stream), callback);
+}
+
+mojom::AudioOutputStreamPtr* AudioOutputImpl::CreateStream(AudioEntry* entry,
+ int stream_id) {
+ mojom::AudioOutputStreamPtr* stream = new mojom::AudioOutputStreamPtr();
+
+ AudioOutputStreamImpl* stream_ptr(new AudioOutputStreamImpl(
+ mojo::GetProxy(stream), entry, stream_id, audio_renderer_host_));
+ stream_ptr->set(20);
+ return stream;
+}
+
+void AudioOutputImpl::InitMojo(mojo::InterfaceRequest<AudioOutput> request) {
+ binding_.Bind(std::move(request));
+ binding_.set_connection_error_handler(base::Bind(
+ base::Bind(&AudioOutputImpl::OnDisconnect, base::Unretained(this)),
+ base::Unretained(this)));
+}
+
+void AudioOutputImpl::OnDisconnect(AudioOutputImpl* impl) {
+ DLOG(WARNING) << "error";
+}
+
+} // namespace content
« no previous file with comments | « content/browser/media/audio_output_impl.h ('k') | content/browser/renderer_host/media/audio_renderer_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698