Skip to content

Commit 981ce1e

Browse files
zhenjiang.zhangzjzhang-cn
authored andcommitted
Set the volume of the remote audio track, volume in [0~10]. Invalid for local track settings.
1 parent 20999af commit 981ce1e

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

include/rtc_audio_track.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ namespace libwebrtc {
1212
* This class is a subclass of the RTCMediaTrack class, which provides a base
1313
* interface for all media tracks in WebRTC.
1414
*/
15-
class RTCAudioTrack : public RTCMediaTrack {
15+
class RTCAudioTrack : public RTCMediaTrack {
16+
public:
17+
// volume in [0-10]
18+
virtual void SetVolume(double volume) = 0;
19+
1620
protected:
1721
/**
1822
* The destructor for the RTCAudioTrack class.

src/rtc_audio_track_impl.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ AudioTrackImpl::~AudioTrackImpl() {
1414
RTC_LOG(LS_INFO) << __FUNCTION__ << ": dtor ";
1515
}
1616

17+
void AudioTrackImpl::SetVolume(double volume) {
18+
rtc_track_->GetSource()->SetVolume(volume);
19+
}
20+
1721
} // namespace libwebrtc

src/rtc_audio_track_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class AudioTrackImpl : public RTCAudioTrack {
2121

2222
virtual ~AudioTrackImpl();
2323

24+
virtual void SetVolume(double volume) override;
25+
2426
virtual const string kind() const override { return kind_; }
2527

2628
virtual const string id() const override { return id_; }

0 commit comments

Comments
 (0)