fork/rust-sdks

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

Théo Monnomfeat: rtc stats (#218)a5ba08e

main
2.2 KiB81 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/peer_connection_interface.h"
22#include "api/rtp_sender_interface.h"
23#include "api/scoped_refptr.h"
24#include "livekit/media_stream.h"
25#include "livekit/rtc_error.h"
26#include "livekit/rtp_parameters.h"
27#include "rust/cxx.h"
28
29namespace livekit {
30class RtpSender;
31}
32#include "webrtc-sys/src/rtp_sender.rs.h"
33
34namespace livekit {
35
36// TODO(theomonnom): FrameTransformer & FrameEncryptor interface
37class RtpSender {
38 public:
39  RtpSender(
40      std::shared_ptr<RtcRuntime> rtc_runtime,
41      rtc::scoped_refptr<webrtc::RtpSenderInterface> sender,
42      rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection);
43
44  bool set_track(std::shared_ptr<MediaStreamTrack> track) const;
45
46  std::shared_ptr<MediaStreamTrack> track() const;
47
48  uint32_t ssrc() const;
49
50  void get_stats(
51      rust::Box<SenderContext> ctx,
52      rust::Fn<void(rust::Box<SenderContext>, rust::String)> on_stats) const;
53
54  MediaType media_type() const;
55
56  rust::String id() const;
57
58  rust::Vec<rust::String> stream_ids() const;
59
60  void set_streams(const rust::Vec<rust::String>& stream_ids) const;
61
62  rust::Vec<RtpEncodingParameters> init_send_encodings() const;
63
64  RtpParameters get_parameters() const;
65
66  void set_parameters(RtpParameters params) const;
67
68  rtc::scoped_refptr<webrtc::RtpSenderInterface> rtc_sender() const {
69    return sender_;
70  }
71
72 private:
73  std::shared_ptr<RtcRuntime> rtc_runtime_;
74  rtc::scoped_refptr<webrtc::RtpSenderInterface> sender_;
75  rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
76};
77
78static std::shared_ptr<RtpSender> _shared_rtp_sender() {
79  return nullptr;  // Ignore
80}
81}  // namespace livekit