ossu | 7bb87ee | 2017-01-23 04:56:25 -0800 | [diff] [blame] | 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 | |
| 11 | // This file contains the implementation of MediaStreamInterface interface. |
| 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #ifndef PC_MEDIASTREAM_H_ |
| 14 | #define PC_MEDIASTREAM_H_ |
ossu | 7bb87ee | 2017-01-23 04:56:25 -0800 | [diff] [blame] | 15 | |
| 16 | #include <string> |
| 17 | #include <vector> |
| 18 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "api/mediastreaminterface.h" |
| 20 | #include "api/notifier.h" |
ossu | 7bb87ee | 2017-01-23 04:56:25 -0800 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | class MediaStream : public Notifier<MediaStreamInterface> { |
| 25 | public: |
| 26 | static rtc::scoped_refptr<MediaStream> Create(const std::string& label); |
| 27 | |
| 28 | std::string label() const override { return label_; } |
| 29 | |
| 30 | bool AddTrack(AudioTrackInterface* track) override; |
| 31 | bool AddTrack(VideoTrackInterface* track) override; |
| 32 | bool RemoveTrack(AudioTrackInterface* track) override; |
| 33 | bool RemoveTrack(VideoTrackInterface* track) override; |
| 34 | rtc::scoped_refptr<AudioTrackInterface> |
| 35 | FindAudioTrack(const std::string& track_id) override; |
| 36 | rtc::scoped_refptr<VideoTrackInterface> |
| 37 | FindVideoTrack(const std::string& track_id) override; |
| 38 | |
| 39 | AudioTrackVector GetAudioTracks() override { return audio_tracks_; } |
| 40 | VideoTrackVector GetVideoTracks() override { return video_tracks_; } |
| 41 | |
| 42 | protected: |
| 43 | explicit MediaStream(const std::string& label); |
| 44 | |
| 45 | private: |
| 46 | template <typename TrackVector, typename Track> |
| 47 | bool AddTrack(TrackVector* Tracks, Track* track); |
| 48 | template <typename TrackVector> |
| 49 | bool RemoveTrack(TrackVector* Tracks, MediaStreamTrackInterface* track); |
| 50 | |
| 51 | std::string label_; |
| 52 | AudioTrackVector audio_tracks_; |
| 53 | VideoTrackVector video_tracks_; |
| 54 | }; |
| 55 | |
| 56 | } // namespace webrtc |
| 57 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 58 | #endif // PC_MEDIASTREAM_H_ |