| 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 | #include <algorithm> |
| 18 | #include <iostream> |
| 19 | #include <memory> |
| 20 | |
| 21 | #include "api/media_stream_interface.h" |
| 22 | #include "api/video/video_frame.h" |
| 23 | #include "api/video/video_rotation.h" |
| 24 | #include "audio/remix_resample.h" |
| 25 | #include "common_audio/include/audio_util.h" |
| 26 | #include "livekit/media_stream.h" |
| 27 | #include "rtc_base/logging.h" |
| 28 | #include "rtc_base/ref_counted_object.h" |
| 29 | #include "rtc_base/time_utils.h" |
| 30 | |
| 31 | namespace livekit_ffi { |
| 32 | |
| 33 | MediaStreamTrack::MediaStreamTrack( |
| 34 | std::shared_ptr<RtcRuntime> rtc_runtime, |
| 35 | webrtc::scoped_refptr<webrtc::MediaStreamTrackInterface> track) |
| 36 | : rtc_runtime_(rtc_runtime), track_(std::move(track)) {} |
| 37 | |
| 38 | rust::String MediaStreamTrack::kind() const { |
| 39 | return track_->kind(); |
| 40 | } |
| 41 | |
| 42 | rust::String MediaStreamTrack::id() const { |
| 43 | return track_->id(); |
| 44 | } |
| 45 | |
| 46 | bool MediaStreamTrack::enabled() const { |
| 47 | return track_->enabled(); |
| 48 | } |
| 49 | |
| 50 | bool MediaStreamTrack::set_enabled(bool enable) const { |
| 51 | return track_->set_enabled(enable); |
| 52 | } |
| 53 | |
| 54 | TrackState MediaStreamTrack::state() const { |
| 55 | return static_cast<TrackState>(track_->state()); |
| 56 | } |
| 57 | |
| 58 | } // namespace livekit_ffi |