| Index: content/renderer/media/webrtc/peer_connection_remote_audio_source.h
|
| diff --git a/content/renderer/media/webrtc/peer_connection_remote_audio_source.h b/content/renderer/media/webrtc/peer_connection_remote_audio_source.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cfa459f590d19a022c81da7c73f9793b7ae0bee7
|
| --- /dev/null
|
| +++ b/content/renderer/media/webrtc/peer_connection_remote_audio_source.h
|
| @@ -0,0 +1,73 @@
|
| +// 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.
|
| +
|
| +#ifndef CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_REMOTE_AUDIO_SOURCE_H_
|
| +#define CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_REMOTE_AUDIO_SOURCE_H_
|
| +
|
| +#include "base/memory/ref_counted.h"
|
| +#include "content/renderer/media/media_stream_audio_track.h"
|
| +#include "content/renderer/media/media_stream_audio_source.h"
|
| +#include "third_party/webrtc/api/mediastreaminterface.h"
|
| +
|
| +namespace content {
|
| +
|
| +// PeerConnectionRemoteAudioTrack is a WebRTC specific implementation of an
|
| +// audio track whose data is sourced from a PeerConnection.
|
| +class PeerConnectionRemoteAudioTrack : public MediaStreamAudioTrack {
|
| + public:
|
| + explicit PeerConnectionRemoteAudioTrack(
|
| + const scoped_refptr<webrtc::AudioTrackInterface>& track_interface);
|
| + ~PeerConnectionRemoteAudioTrack() final;
|
| +
|
| + // If |track| is an instance of PeerConnectionRemoteAudioTrack, return a
|
| + // type-casted pointer to it. Otherwise, return null.
|
| + static PeerConnectionRemoteAudioTrack* From(MediaStreamAudioTrack* track);
|
| +
|
| + webrtc::AudioTrackInterface* track_interface() const {
|
| + return track_interface_.get();
|
| + }
|
| +
|
| + // MediaStreamAudioTrack override.
|
| + void SetEnabled(bool enabled) final;
|
| + void* GetClassIdentifier() const final;
|
| +
|
| + private:
|
| + const scoped_refptr<webrtc::AudioTrackInterface> track_interface_;
|
| +};
|
| +
|
| +// Represents the audio provided by the receiving end of a PeerConnection.
|
| +class PeerConnectionRemoteAudioSource
|
| + : NON_EXPORTED_BASE(public MediaStreamAudioSource),
|
| + NON_EXPORTED_BASE(protected webrtc::AudioTrackSinkInterface) {
|
| + public:
|
| + explicit PeerConnectionRemoteAudioSource(
|
| + const scoped_refptr<webrtc::AudioTrackInterface>& track_interface);
|
| + ~PeerConnectionRemoteAudioSource() final;
|
| +
|
| + protected:
|
| + // MediaStreamAudioSource overrides.
|
| + scoped_ptr<MediaStreamAudioTrack> CreateMediaStreamAudioTrack(
|
| + const std::string& id) final;
|
| + void DoStopSource() final;
|
| + bool EnsureSourceIsStarted() final;
|
| +
|
| + // webrtc::AudioTrackSinkInterface implementation.
|
| + void OnData(const void* audio_data, int bits_per_sample, int sample_rate,
|
| + size_t number_of_channels, size_t number_of_frames) final;
|
| +
|
| + private:
|
| + // Interface to the implementation that calls OnData().
|
| + const scoped_refptr<webrtc::AudioTrackInterface> track_interface_;
|
| +
|
| + // True if |this| has been registered as a sink via |track_interface_|.
|
| + bool is_started_;
|
| +
|
| + // Buffer for converting from interleaved int16 PCM samples to the planar
|
| + // float format. Only used on the thread that calls OnData().
|
| + scoped_ptr<media::AudioBus> audio_bus_;
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_RENDERER_MEDIA_WEBRTC_PEER_CONNECTION_REMOTE_AUDIO_SOURCE_H_
|
|
|