| 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..0d1a66712894adea13c3d001bcf90f7269da7b93
|
| --- /dev/null
|
| +++ b/content/browser/media/audio_output_impl.cc
|
| @@ -0,0 +1,102 @@
|
| +// 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 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;
|
| +}
|
| +
|
| +AudioOutputImpl::AudioOutputImpl(
|
| + scoped_refptr<AudioRendererHost> audio_renderer_host,
|
| + AudioOutputRequest request)
|
| + : audio_renderer_host_(audio_renderer_host), binding_(this) {
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO, FROM_HERE,
|
| + base::Bind(&AudioOutputImpl::InitMojo, base::Unretained(this),
|
| + base::Passed(&request)));
|
| +}
|
| +
|
| +AudioOutputImpl::~AudioOutputImpl() {}
|
| +
|
| +void AudioOutputImpl::CloseStream(int32_t id) {
|
| + // DCHECK(thread_checker_.CalledOnValidThread());
|
| + DLOG(WARNING) << "Close mojo" << id;
|
| + audio_renderer_host_->OnCloseStream(id);
|
| +};
|
| +
|
| +class AudioOutputStreamÍmpl : public AudioOutputStream {
|
| + public:
|
| + explicit AudioOutputStreamÍmpl(
|
| + mojo::InterfaceRequest<AudioOutputStream> request)
|
| + : binding_(this, std::move(request)){};
|
| + void set(int a) override {
|
| + DLOG(WARNING) << "set" << a_ << "set" << a_;
|
| + a_ = a;
|
| + };
|
| +
|
| + void Play() override { DLOG(WARNING) << "set" << a_ << "set" << a_; };
|
| +
|
| + private:
|
| + int a_;
|
| + mojo::Binding<AudioOutputStream> binding_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AudioOutputStreamÍmpl);
|
| +};
|
| +
|
| +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_,
|
| + AudioOutputStreamParametersPtr params,
|
| + const CreateStreamCallback& callback) {
|
| + AudioOutputStreamPtr stream;
|
| + media::AudioParameters audio_params = convert(params);
|
| + scoped_ptr<AudioOutputStreamÍmpl> stream_ptr(
|
| + new AudioOutputStreamÍmpl(mojo::GetProxy(&stream)));
|
| + stream_ptr->set(5);
|
| + audio_renderer_host_->OnCreateStreamMojo(
|
| + stream_id_, render_frame_id_, audio_params, std::move(stream), callback);
|
| + // callback.Run(std::move(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
|
|
|