feat: add ffi datachannel & mute events (#88)
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/audio_options.h"
|
||||
#include "livekit/helper.h"
|
||||
#include "livekit/media_stream_track.h"
|
||||
#include "livekit/webrtc.h"
|
||||
@@ -78,7 +79,7 @@ std::shared_ptr<NativeAudioSink> new_native_audio_sink(
|
||||
class AudioTrackSource {
|
||||
class InternalSource : public webrtc::LocalAudioSource {
|
||||
public:
|
||||
InternalSource();
|
||||
InternalSource(const cricket::AudioOptions& options);
|
||||
|
||||
SourceState state() const override;
|
||||
bool remote() const override;
|
||||
@@ -88,6 +89,8 @@ class AudioTrackSource {
|
||||
void AddSink(webrtc::AudioTrackSinkInterface* sink) override;
|
||||
void RemoveSink(webrtc::AudioTrackSinkInterface* sink) override;
|
||||
|
||||
void set_options(const cricket::AudioOptions& options);
|
||||
|
||||
// AudioFrame should always contain 10 ms worth of data (see index.md of
|
||||
// acm)
|
||||
void on_captured_frame(rust::Slice<const int16_t> audio_data,
|
||||
@@ -96,13 +99,17 @@ class AudioTrackSource {
|
||||
size_t number_of_frames);
|
||||
|
||||
private:
|
||||
webrtc::Mutex mutex_;
|
||||
mutable webrtc::Mutex mutex_;
|
||||
std::vector<webrtc::AudioTrackSinkInterface*> sinks_;
|
||||
cricket::AudioOptions options_{};
|
||||
};
|
||||
|
||||
public:
|
||||
AudioTrackSource();
|
||||
AudioTrackSource(AudioSourceOptions options);
|
||||
|
||||
AudioSourceOptions audio_options() const;
|
||||
|
||||
void set_audio_options(const AudioSourceOptions& options) const;
|
||||
|
||||
void on_captured_frame(rust::Slice<const int16_t> audio_data,
|
||||
int sample_rate,
|
||||
@@ -115,7 +122,8 @@ class AudioTrackSource {
|
||||
rtc::scoped_refptr<InternalSource> source_;
|
||||
};
|
||||
|
||||
std::shared_ptr<AudioTrackSource> new_audio_track_source();
|
||||
std::shared_ptr<AudioTrackSource> new_audio_track_source(
|
||||
AudioSourceOptions options);
|
||||
|
||||
static std::shared_ptr<MediaStreamTrack> audio_to_media(
|
||||
std::shared_ptr<AudioTrack> track) {
|
||||
|
||||
@@ -87,23 +87,29 @@ std::shared_ptr<NativeVideoSink> new_native_video_sink(
|
||||
class VideoTrackSource {
|
||||
class InternalSource : public rtc::AdaptedVideoTrackSource {
|
||||
public:
|
||||
InternalSource();
|
||||
InternalSource(const VideoResolution&
|
||||
resolution); // (0, 0) means no resolution/optional, the
|
||||
// source will guess the resolution at the
|
||||
// first captured frame
|
||||
~InternalSource() override;
|
||||
|
||||
bool is_screencast() const override;
|
||||
absl::optional<bool> needs_denoising() const override;
|
||||
SourceState state() const override;
|
||||
bool remote() const override;
|
||||
|
||||
VideoResolution video_resolution() const;
|
||||
bool on_captured_frame(const webrtc::VideoFrame& frame);
|
||||
|
||||
private:
|
||||
webrtc::Mutex mutex_;
|
||||
mutable webrtc::Mutex mutex_;
|
||||
rtc::TimestampAligner timestamp_aligner_;
|
||||
VideoResolution resolution_;
|
||||
};
|
||||
|
||||
public:
|
||||
VideoTrackSource();
|
||||
VideoTrackSource(const VideoResolution& resolution);
|
||||
|
||||
VideoResolution video_resolution() const;
|
||||
|
||||
bool on_captured_frame(const std::unique_ptr<VideoFrame>& frame)
|
||||
const; // frames pushed from Rust (+interior mutability)
|
||||
@@ -114,7 +120,8 @@ class VideoTrackSource {
|
||||
rtc::scoped_refptr<InternalSource> source_;
|
||||
};
|
||||
|
||||
std::shared_ptr<VideoTrackSource> new_video_track_source();
|
||||
std::shared_ptr<VideoTrackSource> new_video_track_source(
|
||||
const VideoResolution& resolution);
|
||||
|
||||
static std::shared_ptr<MediaStreamTrack> video_to_media(
|
||||
std::shared_ptr<VideoTrack> track) {
|
||||
|
||||
Reference in New Issue
Block a user