fork/rust-sdks

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

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

main
2.3 KiB79 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_receiver_interface.h"
23#include "api/scoped_refptr.h"
24#include "livekit/helper.h"
25#include "livekit/media_stream.h"
26#include "livekit/rtp_parameters.h"
27#include "livekit/webrtc.h"
28#include "rust/cxx.h"
29
30namespace livekit {
31class RtpReceiver;
32}
33#include "webrtc-sys/src/rtp_receiver.rs.h"
34namespace livekit {
35
36// TODO(theomonnom): Implement RtpReceiverObserverInterface?
37// TODO(theomonnom): RtpSource
38// TODO(theomonnom): FrameTransformer & FrameDecryptor interface
39class RtpReceiver {
40 public:
41  RtpReceiver(
42      std::shared_ptr<RtcRuntime> rtc_runtime,
43      rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver,
44      rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection);
45
46  std::shared_ptr<MediaStreamTrack> track() const;
47
48  void get_stats(
49      rust::Box<ReceiverContext> ctx,
50      rust::Fn<void(rust::Box<ReceiverContext>, rust::String)> on_stats) const;
51
52  rust::Vec<rust::String> stream_ids() const;
53  rust::Vec<MediaStreamPtr> streams() const;
54
55  MediaType media_type() const;
56  rust::String id() const;
57
58  RtpParameters get_parameters() const;
59
60  // bool set_parameters(RtpParameters parameters) const; // Seems unsupported
61
62  void set_jitter_buffer_minimum_delay(bool is_some,
63                                       double delay_seconds) const;
64
65  rtc::scoped_refptr<webrtc::RtpReceiverInterface> rtc_receiver() const {
66    return receiver_;
67  }
68
69 private:
70  std::shared_ptr<RtcRuntime> rtc_runtime_;
71  rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver_;
72  rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
73};
74
75static std::shared_ptr<RtpReceiver> _shared_rtp_receiver() {
76  return nullptr;
77}
78
79}  // namespace livekit