media_stream.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2011 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. // This file contains the implementation of MediaStreamInterface interface.
  11. #ifndef PC_MEDIA_STREAM_H_
  12. #define PC_MEDIA_STREAM_H_
  13. #include <string>
  14. #include "api/media_stream_interface.h"
  15. #include "api/notifier.h"
  16. #include "api/scoped_refptr.h"
  17. namespace webrtc {
  18. class MediaStream : public Notifier<MediaStreamInterface> {
  19. public:
  20. static rtc::scoped_refptr<MediaStream> Create(const std::string& id);
  21. std::string id() const override { return id_; }
  22. bool AddTrack(AudioTrackInterface* track) override;
  23. bool AddTrack(VideoTrackInterface* track) override;
  24. bool RemoveTrack(AudioTrackInterface* track) override;
  25. bool RemoveTrack(VideoTrackInterface* track) override;
  26. rtc::scoped_refptr<AudioTrackInterface> FindAudioTrack(
  27. const std::string& track_id) override;
  28. rtc::scoped_refptr<VideoTrackInterface> FindVideoTrack(
  29. const std::string& track_id) override;
  30. AudioTrackVector GetAudioTracks() override { return audio_tracks_; }
  31. VideoTrackVector GetVideoTracks() override { return video_tracks_; }
  32. protected:
  33. explicit MediaStream(const std::string& id);
  34. private:
  35. template <typename TrackVector, typename Track>
  36. bool AddTrack(TrackVector* Tracks, Track* track);
  37. template <typename TrackVector>
  38. bool RemoveTrack(TrackVector* Tracks, MediaStreamTrackInterface* track);
  39. const std::string id_;
  40. AudioTrackVector audio_tracks_;
  41. VideoTrackVector video_tracks_;
  42. };
  43. } // namespace webrtc
  44. #endif // PC_MEDIA_STREAM_H_