blob: 708b13d8d0144904780456e69d5b08b9e139a587 [file] [log] [blame]
ossu7bb87ee2017-01-23 04:56:25 -08001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020013#ifndef PC_MEDIASTREAM_H_
14#define PC_MEDIASTREAM_H_
ossu7bb87ee2017-01-23 04:56:25 -080015
16#include <string>
17#include <vector>
18
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "api/mediastreaminterface.h"
20#include "api/notifier.h"
ossu7bb87ee2017-01-23 04:56:25 -080021
22namespace webrtc {
23
24class MediaStream : public Notifier<MediaStreamInterface> {
25 public:
26 static rtc::scoped_refptr<MediaStream> Create(const std::string& label);
27
Seth Hampson845e8782018-03-02 11:34:10 -080028 std::string label() const override { return id_; }
29 std::string id() const override { return id_; }
ossu7bb87ee2017-01-23 04:56:25 -080030
31 bool AddTrack(AudioTrackInterface* track) override;
32 bool AddTrack(VideoTrackInterface* track) override;
33 bool RemoveTrack(AudioTrackInterface* track) override;
34 bool RemoveTrack(VideoTrackInterface* track) override;
35 rtc::scoped_refptr<AudioTrackInterface>
36 FindAudioTrack(const std::string& track_id) override;
37 rtc::scoped_refptr<VideoTrackInterface>
38 FindVideoTrack(const std::string& track_id) override;
39
40 AudioTrackVector GetAudioTracks() override { return audio_tracks_; }
41 VideoTrackVector GetVideoTracks() override { return video_tracks_; }
42
43 protected:
44 explicit MediaStream(const std::string& label);
45
46 private:
47 template <typename TrackVector, typename Track>
48 bool AddTrack(TrackVector* Tracks, Track* track);
49 template <typename TrackVector>
50 bool RemoveTrack(TrackVector* Tracks, MediaStreamTrackInterface* track);
51
Seth Hampson845e8782018-03-02 11:34:10 -080052 std::string id_;
ossu7bb87ee2017-01-23 04:56:25 -080053 AudioTrackVector audio_tracks_;
54 VideoTrackVector video_tracks_;
55};
56
57} // namespace webrtc
58
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020059#endif // PC_MEDIASTREAM_H_