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

Unified Diff: content/renderer/media/webrtc/peer_connection_remote_audio_source.h

Issue 1647773002: MediaStream audio sourcing: Bypass audio processing for non-WebRTC cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NOT FOR REVIEW -- This will be broken-up across multiple CLs. Created 4 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: 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_

Powered by Google App Engine
This is Rietveld 408576698