blob: c033cf6f35f07d74438304feac4a003ea1a725e6 [file] [log] [blame]
ossu7bb87ee2017-01-23 12:56:251/*
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
Steve Anton10542f22019-01-11 17:11:0013#ifndef PC_MEDIA_STREAM_H_
14#define PC_MEDIA_STREAM_H_
ossu7bb87ee2017-01-23 12:56:2515
16#include <string>
ossu7bb87ee2017-01-23 12:56:2517
Steve Anton10542f22019-01-11 17:11:0018#include "api/media_stream_interface.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3119#include "api/notifier.h"
Mirko Bonadeid9708072019-01-25 19:26:4820#include "api/scoped_refptr.h"
ossu7bb87ee2017-01-23 12:56:2521
22namespace webrtc {
23
24class MediaStream : public Notifier<MediaStreamInterface> {
25 public:
Seth Hampsona859c1a2018-03-31 00:09:4326 static rtc::scoped_refptr<MediaStream> Create(const std::string& id);
ossu7bb87ee2017-01-23 12:56:2527
Seth Hampson845e8782018-03-02 19:34:1028 std::string id() const override { return id_; }
ossu7bb87ee2017-01-23 12:56:2529
Harald Alvestrand2f7ad282022-04-21 11:35:4330 bool AddTrack(rtc::scoped_refptr<AudioTrackInterface> track) override;
31 bool AddTrack(rtc::scoped_refptr<VideoTrackInterface> track) override;
32 bool RemoveTrack(rtc::scoped_refptr<AudioTrackInterface> track) override;
33 bool RemoveTrack(rtc::scoped_refptr<VideoTrackInterface> track) override;
Yves Gerey665174f2018-06-19 13:03:0534 rtc::scoped_refptr<AudioTrackInterface> FindAudioTrack(
35 const std::string& track_id) override;
36 rtc::scoped_refptr<VideoTrackInterface> FindVideoTrack(
37 const std::string& track_id) override;
ossu7bb87ee2017-01-23 12:56:2538
39 AudioTrackVector GetAudioTracks() override { return audio_tracks_; }
40 VideoTrackVector GetVideoTracks() override { return video_tracks_; }
41
42 protected:
Seth Hampsona859c1a2018-03-31 00:09:4343 explicit MediaStream(const std::string& id);
ossu7bb87ee2017-01-23 12:56:2544
45 private:
46 template <typename TrackVector, typename Track>
Niels Möllere7cc8832022-01-04 14:20:0347 bool AddTrack(TrackVector* Tracks, rtc::scoped_refptr<Track> track);
ossu7bb87ee2017-01-23 12:56:2548 template <typename TrackVector>
Harald Alvestrand2f7ad282022-04-21 11:35:4349 bool RemoveTrack(TrackVector* Tracks,
50 rtc::scoped_refptr<MediaStreamTrackInterface> track);
ossu7bb87ee2017-01-23 12:56:2551
Tomas Gunnarssonfc83cdc2020-09-10 11:04:5052 const std::string id_;
ossu7bb87ee2017-01-23 12:56:2553 AudioTrackVector audio_tracks_;
54 VideoTrackVector video_tracks_;
55};
56
57} // namespace webrtc
58
Steve Anton10542f22019-01-11 17:11:0059#endif // PC_MEDIA_STREAM_H_