Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:
- name: Install ninja-build libgtk-3-dev
run: sudo apt-get install -y ninja-build libgtk-3-dev
- name: Install elinux
run: git clone https://github.com/sony/flutter-elinux.git ~/flutter-elinux
run: git clone https://github.com/sony/flutter-elinux.git -b 3.27.1 ~/flutter-elinux
- name: Build for elinux
working-directory: ./example
run: /home/runner/flutter-elinux/bin/flutter-elinux pub get && /home/runner/flutter-elinux/bin/flutter-elinux build elinux
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@

# Changelog

[1.0.9] - 2025-07-01
* [Android] fix: disable software encoding for certain codecs.
* [Android] fix: Nullpointer exception in `ConstraintsMap`.
* Synced flutter-webrtc v0.14.2
* [Windows/Linux] feat: Add audio processing and sink API for cpp. (#1867)
* [Linux] fix: Fixed audio device selection error for Linux. (#1864)
* [Android] fix: Fix screen capture orientation for landscape-native devices (#1854)

[1.0.8] - 2025-06-20
* [Android] Fix `getLocalDescription` throwing an exception when it's `null`

Expand Down
12 changes: 8 additions & 4 deletions common/cpp/include/flutter_webrtc_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "libwebrtc.h"

#include "rtc_audio_device.h"
#include "rtc_audio_processing.h"
#include "rtc_desktop_device.h"
#include "rtc_dtmf_sender.h"
#include "rtc_media_stream.h"
Expand All @@ -21,8 +22,6 @@
#include "rtc_peerconnection_factory.h"
#include "rtc_video_device.h"

#include "uuidxx.h"

namespace stream_webrtc_flutter_plugin {

using namespace libwebrtc;
Expand All @@ -46,14 +45,18 @@ class FlutterWebRTCBase {
FlutterWebRTCBase(BinaryMessenger* messenger, TextureRegistrar* textures, TaskRunner* task_runner);
~FlutterWebRTCBase();

virtual scoped_refptr<RTCAudioProcessing> audio_processing() {
return audio_processing_;
}

virtual scoped_refptr<RTCMediaTrack> MediaTrackForId(const std::string& id);

std::string GenerateUUID();

RTCPeerConnection* PeerConnectionForId(const std::string& id);

void RemovePeerConnectionForId(const std::string& id);

RTCMediaTrack* MediaTrackForId(const std::string& id);

void RemoveMediaTrackForId(const std::string& id);

FlutterPeerConnectionObserver* PeerConnectionObserversForId(
Expand Down Expand Up @@ -104,6 +107,7 @@ class FlutterWebRTCBase {
scoped_refptr<RTCAudioDevice> audio_device_;
scoped_refptr<RTCVideoDevice> video_device_;
scoped_refptr<RTCDesktopDevice> desktop_device_;
scoped_refptr<RTCAudioProcessing> audio_processing_;
RTCConfiguration configuration_;

std::map<std::string, scoped_refptr<RTCPeerConnection>> peerconnections_;
Expand Down
48 changes: 27 additions & 21 deletions common/cpp/src/flutter_media_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ void FlutterMediaStream::GetUserVideo(const EncodableMap& constraints,
if (!video_capturer.get())
return;


video_capturer->StartCapture();

const char* video_source_label = "video_input";
Expand Down Expand Up @@ -333,10 +332,11 @@ void FlutterMediaStream::GetSources(std::unique_ptr<MethodResultProxy> result) {

for (uint16_t i = 0; i < nb_audio_devices; i++) {
base_->audio_device_->RecordingDeviceName(i, strNameUTF8, strGuidUTF8);
std::string device_id = strlen(strGuidUTF8) > 0 ? std::string(strGuidUTF8)
: std::string(strNameUTF8);
EncodableMap audio;
audio[EncodableValue("label")] = EncodableValue(std::string(strNameUTF8));
audio[EncodableValue("deviceId")] =
EncodableValue(std::string(strGuidUTF8));
audio[EncodableValue("deviceId")] = EncodableValue(device_id);
audio[EncodableValue("facing")] = "";
audio[EncodableValue("kind")] = "audioinput";
sources.push_back(EncodableValue(audio));
Expand All @@ -345,10 +345,11 @@ void FlutterMediaStream::GetSources(std::unique_ptr<MethodResultProxy> result) {
nb_audio_devices = base_->audio_device_->PlayoutDevices();
for (uint16_t i = 0; i < nb_audio_devices; i++) {
base_->audio_device_->PlayoutDeviceName(i, strNameUTF8, strGuidUTF8);
std::string device_id = strlen(strGuidUTF8) > 0 ? std::string(strGuidUTF8)
: std::string(strNameUTF8);
EncodableMap audio;
audio[EncodableValue("label")] = EncodableValue(std::string(strNameUTF8));
audio[EncodableValue("deviceId")] =
EncodableValue(std::string(strGuidUTF8));
audio[EncodableValue("deviceId")] = EncodableValue(device_id);
audio[EncodableValue("facing")] = "";
audio[EncodableValue("kind")] = "audiooutput";
sources.push_back(EncodableValue(audio));
Expand All @@ -373,13 +374,16 @@ void FlutterMediaStream::GetSources(std::unique_ptr<MethodResultProxy> result) {
void FlutterMediaStream::SelectAudioOutput(
const std::string& device_id,
std::unique_ptr<MethodResultProxy> result) {
char strPlayoutName[256];
char strPlayoutGuid[256];
char deviceName[256];
char deviceGuid[256];
int playout_devices = base_->audio_device_->PlayoutDevices();
bool found = false;
for (uint16_t i = 0; i < playout_devices; i++) {
base_->audio_device_->PlayoutDeviceName(i, strPlayoutName, strPlayoutGuid);
if (device_id != "" && device_id == strPlayoutGuid) {
base_->audio_device_->PlayoutDeviceName(i, deviceName, deviceGuid);
std::string cur_device_id = strlen(deviceGuid) > 0
? std::string(deviceGuid)
: std::string(deviceName);
if (device_id != "" && device_id == cur_device_id) {
base_->audio_device_->SetPlayoutDevice(i);
found = true;
break;
Expand All @@ -395,14 +399,16 @@ void FlutterMediaStream::SelectAudioOutput(
void FlutterMediaStream::SelectAudioInput(
const std::string& device_id,
std::unique_ptr<MethodResultProxy> result) {
char strPlayoutName[256];
char strPlayoutGuid[256];
char deviceName[256];
char deviceGuid[256];
int playout_devices = base_->audio_device_->RecordingDevices();
bool found = false;
for (uint16_t i = 0; i < playout_devices; i++) {
base_->audio_device_->RecordingDeviceName(i, strPlayoutName,
strPlayoutGuid);
if (device_id != "" && device_id == strPlayoutGuid) {
base_->audio_device_->RecordingDeviceName(i, deviceName, deviceGuid);
std::string cur_device_id = strlen(deviceGuid) > 0
? std::string(deviceGuid)
: std::string(deviceName);
if (device_id != "" && device_id == cur_device_id) {
base_->audio_device_->SetRecordingDevice(i);
found = true;
break;
Expand Down Expand Up @@ -538,14 +544,14 @@ void FlutterMediaStream::MediaStreamTrackDispose(
if (track->id().std_string() == track_id) {
stream->RemoveTrack(track);

if (base_->video_capturers_.find(track_id) !=
base_->video_capturers_.end()) {
auto video_capture = base_->video_capturers_[track_id];
if (video_capture->CaptureStarted()) {
video_capture->StopCapture();
if (base_->video_capturers_.find(track_id) !=
base_->video_capturers_.end()) {
auto video_capture = base_->video_capturers_[track_id];
if (video_capture->CaptureStarted()) {
video_capture->StopCapture();
}
base_->video_capturers_.erase(track_id);
}
base_->video_capturers_.erase(track_id);
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion common/cpp/src/flutter_webrtc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ void FlutterWebRTC::HandleMethodCall(
return;
}
DataChannelSend(data_channel, type, data, std::move(result));
} else if (method_call.method_name().compare("dataChannelGetBufferedAmount") == 0) {
} else if (method_call.method_name().compare(
"dataChannelGetBufferedAmount") == 0) {
if (!method_call.arguments()) {
result->Error("Bad Arguments", "Null constraints arguments received");
return;
Expand Down
9 changes: 6 additions & 3 deletions common/cpp/src/flutter_webrtc_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "flutter_data_channel.h"
#include "flutter_peerconnection.h"

#include "helper.h"

namespace stream_webrtc_flutter_plugin {

const char* kEventChannelName = "FlutterWebRTC.Event";
Expand All @@ -16,6 +18,7 @@ FlutterWebRTCBase::FlutterWebRTCBase(BinaryMessenger* messenger,
audio_device_ = factory_->GetAudioDevice();
video_device_ = factory_->GetVideoDevice();
desktop_device_ = factory_->GetDesktopDevice();
audio_processing_ = factory_->GetAudioProcessing();
event_channel_ = EventChannelProxy::Create(messenger_, task_runner_, kEventChannelName);
}

Expand All @@ -28,7 +31,7 @@ EventChannelProxy* FlutterWebRTCBase::event_channel() {
}

std::string FlutterWebRTCBase::GenerateUUID() {
return uuidxx::uuid::Generate().ToString(false);
return libwebrtc::Helper::CreateRandomUuid().std_string();
}

RTCPeerConnection* FlutterWebRTCBase::PeerConnectionForId(
Expand All @@ -47,11 +50,11 @@ void FlutterWebRTCBase::RemovePeerConnectionForId(const std::string& id) {
peerconnections_.erase(it);
}

RTCMediaTrack* FlutterWebRTCBase ::MediaTrackForId(const std::string& id) {
scoped_refptr<RTCMediaTrack> FlutterWebRTCBase ::MediaTrackForId(const std::string& id) {
auto it = local_tracks_.find(id);

if (it != local_tracks_.end())
return (*it).second.get();
return (*it).second;

for (auto kv : peerconnection_observers_) {
auto pco = kv.second.get();
Expand Down
3 changes: 1 addition & 2 deletions elinux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ add_definitions(-DRTC_DESKTOP_DEVICE)
add_definitions(-DFLUTTER_ELINUX)

add_library(${PLUGIN_NAME} SHARED
"../third_party/uuidxx/uuidxx.cc"
"../common/cpp/src/flutter_data_channel.cc"
"../common/cpp/src/flutter_frame_cryptor.cc"
"../common/cpp/src/flutter_frame_capturer.cc"
Expand All @@ -28,7 +27,6 @@ add_library(${PLUGIN_NAME} SHARED
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/cpp/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../third_party/uuidxx"
"${CMAKE_CURRENT_SOURCE_DIR}/../third_party/libwebrtc/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../third_party/svpng"
)
Expand All @@ -39,6 +37,7 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/cpp/include"
)
target_link_libraries(${PLUGIN_NAME} PRIVATE
flutter
Expand Down
7 changes: 4 additions & 3 deletions linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ set(CMAKE_CXX_STANDARD 17)
add_definitions(-DRTC_DESKTOP_DEVICE)

add_library(${PLUGIN_NAME} SHARED
"../third_party/uuidxx/uuidxx.cc"
"../common/cpp/src/flutter_data_channel.cc"
"../common/cpp/src/flutter_frame_cryptor.cc"
"../common/cpp/src/flutter_media_stream.cc"
Expand All @@ -31,7 +30,6 @@ include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/flutter/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/cpp/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../third_party/uuidxx"
"${CMAKE_CURRENT_SOURCE_DIR}/../third_party/libwebrtc/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../third_party/svpng"
)
Expand All @@ -41,7 +39,10 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES
CXX_VISIBILITY_PRESET hidden)
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}")
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/../common/cpp/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../third_party/libwebrtc/include"
)
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)

Expand Down
6 changes: 6 additions & 0 deletions linux/stream_webrtc_flutter/flutter_web_r_t_c_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ G_BEGIN_DECLS
#define FLUTTER_PLUGIN_EXPORT
#endif

namespace stream_webrtc_flutter_plugin {
class FlutterWebRTC;
} // namespace stream_webrtc_flutter_plugin

typedef struct _FlutterWebrtcPlugin FlutterWebrtcPlugin;
typedef struct {
GObjectClass parent_class;
Expand All @@ -20,6 +24,8 @@ FLUTTER_PLUGIN_EXPORT GType stream_webrtc_flutter_plugin_get_type();
FLUTTER_PLUGIN_EXPORT void flutter_web_r_t_c_plugin_register_with_registrar(
FlPluginRegistrar* registrar);

FLUTTER_PLUGIN_EXPORT stream_webrtc_flutter_plugin::FlutterWebRTC* flutter_webrtc_plugin_get_shared_instance();

G_END_DECLS

#endif // PLUGINS_FLUTTER_WEBRTC_PLUGIN_CPP_H_
9 changes: 7 additions & 2 deletions linux/stream_webrtc_flutter_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "task_runner_linux.h"

const char* kChannelName = "FlutterWebRTC.Method";

static stream_webrtc_flutter_plugin::FlutterWebRTC* g_shared_instance = nullptr;
//#if defined(_WINDOWS)

namespace stream_webrtc_flutter_plugin {
Expand Down Expand Up @@ -49,6 +49,7 @@ class FlutterWebRTCPluginImpl : public FlutterWebRTCPlugin {
textures_(registrar->texture_registrar()),
task_runner_(std::make_unique<TaskRunnerLinux>()) {
webrtc_ = std::make_unique<FlutterWebRTC>(this);
g_shared_instance = webrtc_.get();
}

// Called when a method is called on |channel_|;
Expand All @@ -75,4 +76,8 @@ void flutter_web_r_t_c_plugin_register_with_registrar(
static auto* plugin_registrar = new flutter::PluginRegistrar(registrar);
stream_webrtc_flutter_plugin::FlutterWebRTCPluginImpl::RegisterWithRegistrar(
plugin_registrar);
}
}

stream_webrtc_flutter_plugin::FlutterWebRTC* flutter_webrtc_plugin_get_shared_instance() {
return g_shared_instance;
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: stream_webrtc_flutter
description: Flutter WebRTC plugin for iOS/Android/Destkop/Web, based on GoogleWebRTC.
version: 1.0.8
version: 1.0.9
homepage: https://github.com/GetStream/webrtc-flutter
environment:
sdk: ">=3.3.0 <4.0.0"
Expand Down
31 changes: 13 additions & 18 deletions third_party/libwebrtc/include/rtc_audio_frame.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#ifndef AUDIO_FRAME_HXX
#define AUDIO_FRAME_HXX
#ifndef LIB_WEBRTC_RTC_AUDIO_FRAME_HXX
#define LIB_WEBRTC_RTC_AUDIO_FRAME_HXX

#include "media_manager_types.h"
#include "rtc_types.h"

namespace b2bua {
namespace libwebrtc {

class AudioFrame {
class AudioFrame : public RefCountInterface {
public:
/**
* @brief Creates a new instance of AudioFrame.
* @return AudioFrame*: a pointer to the newly created AudioFrame.
*/
MEDIA_MANAGER_API static AudioFrame* Create();
LIB_WEBRTC_API static AudioFrame* Create();

/**
* @brief Creates a new instance of AudioFrame with specified parameters.
Expand All @@ -23,16 +23,11 @@ class AudioFrame {
* @param num_channels: the number of audio channels.
* @return AudioFrame*: a pointer to the newly created AudioFrame.
*/
MEDIA_MANAGER_API static AudioFrame* Create(int id, uint32_t timestamp,
const int16_t* data,
size_t samples_per_channel,
int sample_rate_hz,
size_t num_channels = 1);

/**
* @brief Releases the memory of this AudioFrame.
*/
virtual void Release() = 0;
LIB_WEBRTC_API static AudioFrame* Create(int id, uint32_t timestamp,
const int16_t* data,
size_t samples_per_channel,
int sample_rate_hz,
size_t num_channels = 1);

public:
/**
Expand Down Expand Up @@ -103,6 +98,6 @@ class AudioFrame {
virtual int id() = 0;
};

}; // namespace b2bua
}; // namespace libwebrtc

#endif
#endif // LIB_WEBRTC_RTC_AUDIO_FRAME_HXX
Loading