media_stream_observer.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 2015 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * 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.
  9. */
  10. #ifndef PC_MEDIA_STREAM_OBSERVER_H_
  11. #define PC_MEDIA_STREAM_OBSERVER_H_
  12. #include "api/media_stream_interface.h"
  13. #include "api/scoped_refptr.h"
  14. #include "rtc_base/third_party/sigslot/sigslot.h"
  15. namespace webrtc {
  16. // Helper class which will listen for changes to a stream and emit the
  17. // corresponding signals.
  18. class MediaStreamObserver : public ObserverInterface {
  19. public:
  20. explicit MediaStreamObserver(MediaStreamInterface* stream);
  21. ~MediaStreamObserver() override;
  22. const MediaStreamInterface* stream() const { return stream_; }
  23. void OnChanged() override;
  24. sigslot::signal2<AudioTrackInterface*, MediaStreamInterface*>
  25. SignalAudioTrackAdded;
  26. sigslot::signal2<AudioTrackInterface*, MediaStreamInterface*>
  27. SignalAudioTrackRemoved;
  28. sigslot::signal2<VideoTrackInterface*, MediaStreamInterface*>
  29. SignalVideoTrackAdded;
  30. sigslot::signal2<VideoTrackInterface*, MediaStreamInterface*>
  31. SignalVideoTrackRemoved;
  32. private:
  33. rtc::scoped_refptr<MediaStreamInterface> stream_;
  34. AudioTrackVector cached_audio_tracks_;
  35. VideoTrackVector cached_video_tracks_;
  36. };
  37. } // namespace webrtc
  38. #endif // PC_MEDIA_STREAM_OBSERVER_H_