fork/rust-sdks

git clone https://git.julia.blue/fork/rust-sdks

Théo Monnomcleanup: webrtc-sys & fix RtcRuntime disposing crashes (#81)55bda13

main
1.7 KiB57 linesraw
1/*
2 * Copyright 2023 LiveKit
3 *
4 * Licensed under the Apache License, Version 2.0 (the “License”);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an “AS IS” BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <memory>
20
21#include "api/media_stream_interface.h"
22#include "livekit/helper.h"
23#include "livekit/webrtc.h"
24#include "rust/cxx.h"
25
26namespace livekit {
27class MediaStream;
28}  // namespace livekit
29#include "webrtc-sys/src/media_stream.rs.h"
30
31namespace livekit {
32
33class MediaStream {
34 public:
35  MediaStream(std::shared_ptr<RtcRuntime> rtc_runtime,
36              rtc::scoped_refptr<webrtc::MediaStreamInterface> stream);
37
38  rust::String id() const;
39  rust::Vec<VideoTrackPtr> get_video_tracks() const;
40  rust::Vec<AudioTrackPtr> get_audio_tracks() const;
41
42  std::shared_ptr<AudioTrack> find_audio_track(rust::String track_id) const;
43  std::shared_ptr<VideoTrack> find_video_track(rust::String track_id) const;
44
45  bool add_track(std::shared_ptr<MediaStreamTrack> track) const;
46  bool remove_track(std::shared_ptr<MediaStreamTrack> track) const;
47
48 private:
49  std::shared_ptr<RtcRuntime> rtc_runtime_;
50  rtc::scoped_refptr<webrtc::MediaStreamInterface> media_stream_;
51};
52
53static std::shared_ptr<MediaStream> _shared_media_stream() {
54  return nullptr;  // Ignore
55}
56
57}  // namespace livekit