| 1 | /* |
| 2 | * Copyright 2025 LiveKit, Inc. |
| 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_parameters.h" |
| 23 | #include "api/rtp_transceiver_direction.h" |
| 24 | #include "api/rtp_transceiver_interface.h" |
| 25 | #include "api/scoped_refptr.h" |
| 26 | #include "livekit/rtc_error.h" |
| 27 | #include "livekit/rtp_parameters.h" |
| 28 | #include "livekit/rtp_receiver.h" |
| 29 | #include "livekit/rtp_sender.h" |
| 30 | #include "rust/cxx.h" |
| 31 | |
| 32 | namespace livekit_ffi { |
| 33 | class RtpTransceiver; |
| 34 | } |
| 35 | #include "webrtc-sys/src/rtp_transceiver.rs.h" |
| 36 | |
| 37 | namespace livekit_ffi { |
| 38 | |
| 39 | webrtc::RtpTransceiverInit to_native_rtp_transceiver_init( |
| 40 | RtpTransceiverInit init); |
| 41 | |
| 42 | class RtpTransceiver { |
| 43 | public: |
| 44 | RtpTransceiver( |
| 45 | std::shared_ptr<RtcRuntime> rtc_runtime, |
| 46 | webrtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver, |
| 47 | webrtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection); |
| 48 | |
| 49 | MediaType media_type() const; |
| 50 | |
| 51 | rust::String mid() const; |
| 52 | |
| 53 | std::shared_ptr<RtpSender> sender() const; |
| 54 | |
| 55 | std::shared_ptr<RtpReceiver> receiver() const; |
| 56 | |
| 57 | bool stopped() const; |
| 58 | |
| 59 | bool stopping() const; |
| 60 | |
| 61 | RtpTransceiverDirection direction() const; |
| 62 | |
| 63 | void set_direction(RtpTransceiverDirection direction) const; |
| 64 | |
| 65 | RtpTransceiverDirection current_direction() const; |
| 66 | |
| 67 | RtpTransceiverDirection fired_direction() const; |
| 68 | |
| 69 | void stop_standard() const; |
| 70 | |
| 71 | void set_codec_preferences(rust::Vec<RtpCodecCapability> codecs) const; |
| 72 | |
| 73 | rust::Vec<RtpCodecCapability> codec_preferences() const; |
| 74 | |
| 75 | rust::Vec<RtpHeaderExtensionCapability> header_extensions_to_negotiate() |
| 76 | const; |
| 77 | |
| 78 | rust::Vec<RtpHeaderExtensionCapability> negotiated_header_extensions() const; |
| 79 | |
| 80 | void set_header_extensions_to_negotiate( |
| 81 | rust::Vec<RtpHeaderExtensionCapability> header_extensions_to_offer) const; |
| 82 | |
| 83 | private: |
| 84 | std::shared_ptr<RtcRuntime> rtc_runtime_; |
| 85 | webrtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver_; |
| 86 | webrtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; |
| 87 | }; |
| 88 | |
| 89 | static std::shared_ptr<RtpTransceiver> _shared_rtp_transceiver() { |
| 90 | return nullptr; |
| 91 | } |
| 92 | |
| 93 | } // namespace livekit_ffi |