blob: 920bb948bafc8b158a655d020ac0be5330e9da4b [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:361/*
kjellanderb24317b2016-02-10 15:54:432 * Copyright 2011 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:363 *
kjellanderb24317b2016-02-10 15:54:434 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
henrike@webrtc.org28e20752013-07-10 00:45:369 */
10
Steve Anton10542f22019-01-11 17:11:0011#ifndef PC_AUDIO_TRACK_H_
12#define PC_AUDIO_TRACK_H_
henrike@webrtc.org28e20752013-07-10 00:45:3613
tommi6eca7e32015-12-15 12:27:1114#include <string>
15
Steve Anton10542f22019-01-11 17:11:0016#include "api/media_stream_interface.h"
Harald Alvestrand9cb42c82020-10-11 13:03:4717#include "api/media_stream_track.h"
Mirko Bonadeid9708072019-01-25 19:26:4818#include "api/scoped_refptr.h"
Artem Titovd15a5752021-02-10 13:31:2419#include "api/sequence_checker.h"
Tomas Gunnarssonfe328ca2022-02-16 19:02:1220#include "rtc_base/system/no_unique_address.h"
henrike@webrtc.org28e20752013-07-10 00:45:3621
22namespace webrtc {
23
Tommi09f57132022-02-17 12:19:5524// TODO(tommi): Instead of inheriting from `MediaStreamTrack<>`, implement the
25// properties directly in this class. `MediaStreamTrack` doesn't guard against
26// conflicting access, so we'd need to override those methods anyway in this
27// class in order to make sure things are correctly checked.
tommi6eca7e32015-12-15 12:27:1128class AudioTrack : public MediaStreamTrack<AudioTrackInterface>,
29 public ObserverInterface {
30 protected:
31 // Protected ctor to force use of factory method.
32 AudioTrack(const std::string& label,
33 const rtc::scoped_refptr<AudioSourceInterface>& source);
Niels Möllerde953292020-09-29 07:46:2134
35 AudioTrack() = delete;
36 AudioTrack(const AudioTrack&) = delete;
37 AudioTrack& operator=(const AudioTrack&) = delete;
38
tommi6eca7e32015-12-15 12:27:1139 ~AudioTrack() override;
40
henrike@webrtc.org28e20752013-07-10 00:45:3641 public:
buildbot@webrtc.orgd4e598d2014-07-29 17:36:5242 static rtc::scoped_refptr<AudioTrack> Create(
tommi6eca7e32015-12-15 12:27:1143 const std::string& id,
44 const rtc::scoped_refptr<AudioSourceInterface>& source);
henrike@webrtc.org28e20752013-07-10 00:45:3645
henrike@webrtc.org40b3b682014-03-03 18:30:1146 // MediaStreamTrack implementation.
kjellander@webrtc.org14665ff2015-03-04 12:58:3547 std::string kind() const override;
henrike@webrtc.org28e20752013-07-10 00:45:3648
tommi6eca7e32015-12-15 12:27:1149 // AudioTrackInterface implementation.
50 AudioSourceInterface* GetSource() const override;
51
52 void AddSink(AudioTrackSinkInterface* sink) override;
53 void RemoveSink(AudioTrackSinkInterface* sink) override;
54
Tommi816134a2021-05-24 14:54:4155 private:
tommi6eca7e32015-12-15 12:27:1156 // ObserverInterface implementation.
57 void OnChanged() override;
henrike@webrtc.org28e20752013-07-10 00:45:3658
59 private:
tommi6eca7e32015-12-15 12:27:1160 const rtc::scoped_refptr<AudioSourceInterface> audio_source_;
Tomas Gunnarssonfe328ca2022-02-16 19:02:1261 RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker signaling_thread_checker_;
henrike@webrtc.org28e20752013-07-10 00:45:3662};
63
64} // namespace webrtc
65
Steve Anton10542f22019-01-11 17:11:0066#endif // PC_AUDIO_TRACK_H_