fork/rust-sdks

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

Théo Monnomoptimize AudioSource captures (#425)09f7da1

main
2.3 KiB73 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 "api/peer_connection_interface.h"
20#include "api/scoped_refptr.h"
21#include "api/task_queue/task_queue_factory.h"
22#include "livekit/audio_device.h"
23#include "media_stream.h"
24#include "rtp_parameters.h"
25#include "rust/cxx.h"
26#include "webrtc.h"
27
28namespace livekit {
29class PeerConnectionFactory;
30class PeerConnectionObserverWrapper;
31}  // namespace livekit
32#include "webrtc-sys/src/peer_connection_factory.rs.h"
33
34namespace livekit {
35
36class PeerConnection;
37struct RtcConfiguration;
38
39webrtc::PeerConnectionInterface::RTCConfiguration to_native_rtc_configuration(
40    RtcConfiguration config);
41
42class PeerConnectionFactory {
43 public:
44  explicit PeerConnectionFactory(std::shared_ptr<RtcRuntime> rtc_runtime);
45  ~PeerConnectionFactory();
46
47  std::shared_ptr<PeerConnection> create_peer_connection(
48      RtcConfiguration config,
49      rust::Box<PeerConnectionObserverWrapper> observer) const;
50
51  std::shared_ptr<VideoTrack> create_video_track(
52      rust::String label,
53      std::shared_ptr<VideoTrackSource> source) const;
54
55  std::shared_ptr<AudioTrack> create_audio_track(
56      rust::String label,
57      std::shared_ptr<AudioTrackSource> source) const;
58
59  RtpCapabilities rtp_sender_capabilities(MediaType type) const;
60
61  RtpCapabilities rtp_receiver_capabilities(MediaType type) const;
62
63  std::shared_ptr<RtcRuntime> rtc_runtime() const { return rtc_runtime_; }
64
65 private:
66  std::shared_ptr<RtcRuntime> rtc_runtime_;
67  rtc::scoped_refptr<AudioDevice> audio_device_;
68  rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> peer_factory_;
69  webrtc::TaskQueueFactory* task_queue_factory_;
70};
71
72std::shared_ptr<PeerConnectionFactory> create_peer_connection_factory();
73}  // namespace livekit