blob: 1aed50b50ebadaabe31197ce36e742d5cdd71e33 [file] [log] [blame]
Taylor Brandstettercf846ad2015-12-10 15:52:02 -08001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
Taylor Brandstettercf846ad2015-12-10 15:52:02 -08003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * 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.
Taylor Brandstettercf846ad2015-12-10 15:52:02 -08009 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef PC_MEDIASTREAMOBSERVER_H_
12#define PC_MEDIASTREAMOBSERVER_H_
Taylor Brandstettercf846ad2015-12-10 15:52:02 -080013
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#include "api/mediastreaminterface.h"
15#include "rtc_base/scoped_ref_ptr.h"
16#include "rtc_base/sigslot.h"
deadbeefeb459812015-12-15 19:24:43 -080017
18namespace webrtc {
19
20// Helper class which will listen for changes to a stream and emit the
21// corresponding signals.
22class MediaStreamObserver : public ObserverInterface {
23 public:
24 explicit MediaStreamObserver(MediaStreamInterface* stream);
25 ~MediaStreamObserver();
26
27 const MediaStreamInterface* stream() const { return stream_; }
28
29 void OnChanged() override;
30
31 sigslot::signal2<AudioTrackInterface*, MediaStreamInterface*>
32 SignalAudioTrackAdded;
33 sigslot::signal2<AudioTrackInterface*, MediaStreamInterface*>
34 SignalAudioTrackRemoved;
35 sigslot::signal2<VideoTrackInterface*, MediaStreamInterface*>
36 SignalVideoTrackAdded;
37 sigslot::signal2<VideoTrackInterface*, MediaStreamInterface*>
38 SignalVideoTrackRemoved;
39
40 private:
41 rtc::scoped_refptr<MediaStreamInterface> stream_;
42 AudioTrackVector cached_audio_tracks_;
43 VideoTrackVector cached_video_tracks_;
44};
45
46} // namespace webrtc
47
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020048#endif // PC_MEDIASTREAMOBSERVER_H_