refactored RTCEngine

This commit is contained in:
Théo Monnom
2022-12-20 23:05:31 +01:00
parent 2e3c87f232
commit 1ed925dd38
8 changed files with 339 additions and 501 deletions
@@ -24,10 +24,10 @@ class DataChannel {
void register_observer(NativeDataChannelObserver& observer);
void unregister_observer();
bool send(const DataBuffer& buffer);
bool send(const DataBuffer& buffer) const;
rust::String label() const;
DataState state() const;
void close();
void close() const;
private:
std::shared_ptr<RTCRuntime> rtc_runtime_;
@@ -24,7 +24,7 @@ void DataChannel::unregister_observer() {
data_channel_->UnregisterObserver();
}
bool DataChannel::send(const DataBuffer& buffer) {
bool DataChannel::send(const DataBuffer& buffer) const {
return data_channel_->Send(webrtc::DataBuffer{
rtc::CopyOnWriteBuffer(buffer.ptr, buffer.len), buffer.binary});
}
@@ -37,7 +37,7 @@ DataState DataChannel::state() const {
return static_cast<DataState>(data_channel_->state());
}
void DataChannel::close() {
void DataChannel::close() const {
return data_channel_->Close();
}
@@ -68,10 +68,10 @@ pub mod ffi {
);
fn unregister_observer(self: Pin<&mut DataChannel>);
fn send(self: Pin<&mut DataChannel>, data: &DataBuffer) -> bool;
fn send(self: &DataChannel, data: &DataBuffer) -> bool;
fn label(self: &DataChannel) -> String;
fn state(self: &DataChannel) -> DataState;
fn close(self: Pin<&mut DataChannel>);
fn close(self: &DataChannel);
fn create_data_channel_init(init: DataChannelInit) -> UniquePtr<NativeDataChannelInit>;
fn create_native_data_channel_observer(