blob: 34299f46e36b4c751a35289714f7430810aa499b [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
Steve Anton10542f22019-01-11 09:11:00 -080013#ifndef PC_MEDIA_STREAM_H_
14#define PC_MEDIA_STREAM_H_
ossu7bb87ee2017-01-23 04:56:25 -080015
16#include <string>
ossu7bb87ee2017-01-23 04:56:25 -080017
Steve Anton10542f22019-01-11 09:11:00 -080018#include "api/media_stream_interface.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "api/notifier.h"
Mirko Bonadeid9708072019-01-25 20:26:48 +010020#include "api/scoped_refptr.h"
ossu7bb87ee2017-01-23 04:56:25 -080021
22namespace webrtc {
23
24class MediaStream : public Notifier<MediaStreamInterface> {
25 public:
Seth Hampsona859c1a2018-03-30 17:09:43 -070026 static rtc::scoped_refptr<MediaStream> Create(const std::string& id);
ossu7bb87ee2017-01-23 04:56:25 -080027
Seth Hampson845e8782018-03-02 11:34:10 -080028 std::string id() const override { return id_; }
ossu7bb87ee2017-01-23 04:56:25 -080029
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 15:03:05 +020034 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 04:56:25 -080038
39 AudioTrackVector GetAudioTracks() override { return audio_tracks_; }
40 VideoTrackVector GetVideoTracks() override { return video_tracks_; }
41
42 protected:
Seth Hampsona859c1a2018-03-30 17:09:43 -070043 explicit MediaStream(const std::string& id);
ossu7bb87ee2017-01-23 04:56:25 -080044
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 11:34:10 -080051 std::string id_;
ossu7bb87ee2017-01-23 04:56:25 -080052 AudioTrackVector audio_tracks_;
53 VideoTrackVector video_tracks_;
54};
55
56} // namespace webrtc
57
Steve Anton10542f22019-01-11 09:11:00 -080058#endif // PC_MEDIA_STREAM_H_