blob: 34299f46e36b4c751a35289714f7430810aa499b [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
30 bool AddTrack(AudioTrackInterface* track) override;
31 bool AddTrack(VideoTrackInterface* track) override;
32 bool RemoveTrack(AudioTrackInterface* track) override;
33 bool RemoveTrack(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>
47 bool AddTrack(TrackVector* Tracks, Track* track);
48 template <typename TrackVector>
49 bool RemoveTrack(TrackVector* Tracks, MediaStreamTrackInterface* track);
50
Seth Hampson845e8782018-03-02 19:34:1051 std::string id_;
ossu7bb87ee2017-01-23 12:56:2552 AudioTrackVector audio_tracks_;
53 VideoTrackVector video_tracks_;
54};
55
56} // namespace webrtc
57
Steve Anton10542f22019-01-11 17:11:0058#endif // PC_MEDIA_STREAM_H_