Skip to content
Open
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
85 changes: 85 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import("../webrtc.gni")

declare_args() {
libwebrtc_interop = true
libwebrtc_intel_media_sdk = false
libwebrtc_desktop_capture = true
}
Expand Down Expand Up @@ -68,6 +69,7 @@ rtc_shared_library("libwebrtc") {
"include/base/refcountedobject.h",
"include/base/scoped_ref_ptr.h",
"include/libwebrtc.h",
"include/rtc_base_list.h",
"include/rtc_audio_device.h",
"include/rtc_audio_processing.h",
"include/rtc_audio_source.h",
Expand All @@ -76,6 +78,7 @@ rtc_shared_library("libwebrtc") {
"include/rtc_dtls_transport.h",
"include/rtc_dtmf_sender.h",
"include/rtc_frame_cryptor.h",
"include/rtc_sdp_parse_error.h",
"include/rtc_ice_candidate.h",
"include/rtc_media_stream.h",
"include/rtc_media_track.h",
Expand All @@ -95,9 +98,14 @@ rtc_shared_library("libwebrtc") {
"include/rtc_video_source.h",
"include/rtc_video_track.h",
"include/rtc_logging.h",
"include/rtc_dummy_video_capturer.h",
"include/rtc_audio_data.h",
"include/rtc_dummy_audio_source.h",
"include/helper.h",
"src/helper.cc",
"src/base/portable.cc",
"src/internal/audio_util.cc",
"src/internal/audio_util.h",
"src/internal/custom_audio_transport_impl.cc",
"src/internal/custom_audio_transport_impl.h",
"src/internal/local_audio_track.cc",
Expand All @@ -106,6 +114,10 @@ rtc_shared_library("libwebrtc") {
"src/internal/vcm_capturer.h",
"src/internal/video_capturer.cc",
"src/internal/video_capturer.h",
"src/internal/dummy_capturer.cc",
"src/internal/dummy_capturer.h",
"src/internal/dummy_audio_capturer.cc",
"src/internal/dummy_audio_capturer.h",
"src/libwebrtc.cc",
"src/rtc_audio_device_impl.cc",
"src/rtc_audio_device_impl.h",
Expand All @@ -123,6 +135,8 @@ rtc_shared_library("libwebrtc") {
"src/rtc_dtmf_sender_impl.h",
"src/rtc_frame_cryptor_impl.cc",
"src/rtc_frame_cryptor_impl.h",
"src/rtc_sdp_parse_error_impl.cc",
"src/rtc_sdp_parse_error_impl.h",
"src/rtc_ice_candidate_impl.cc",
"src/rtc_ice_candidate_impl.h",
"src/rtc_media_stream_impl.cc",
Expand All @@ -149,14 +163,68 @@ rtc_shared_library("libwebrtc") {
"src/rtc_video_device_impl.h",
"src/rtc_video_frame_impl.cc",
"src/rtc_video_frame_impl.h",
"src/rtc_video_renderer_impl.cc",
"src/rtc_video_renderer_impl.h",
"src/rtc_video_sink_adapter.cc",
"src/rtc_video_sink_adapter.h",
"src/rtc_video_source_impl.cc",
"src/rtc_video_source_impl.h",
"src/rtc_video_track_impl.cc",
"src/rtc_video_track_impl.h",
"src/rtc_logging.cc",
"src/rtc_dummy_video_capturer_impl.cc",
"src/rtc_dummy_video_capturer_impl.h",
"src/rtc_audio_data_impl.cc",
"src/rtc_audio_data_impl.h",
"src/rtc_dummy_audio_source_impl.cc",
"src/rtc_dummy_audio_source_impl.h",
]

# for interop methods
if (libwebrtc_interop) {
sources += [
"include/interop_macros.h",
"include/interop_api.h",
"src/interop/ref_counted_object_interop.cc",
"src/interop/libwebrtc_interop.cc",
"src/interop/rtc_sdp_parse_error_interop.cc",
"src/interop/rtc_mediaconstraints_interop.cc",
"src/interop/rtc_peerconnection_factory_interop.cc",
"src/interop/rtc_audio_data_interop.cc",
"src/interop/rtc_media_track_interop.cc",
"src/interop/rtc_audio_device_interop.cc",
"src/interop/rtc_audio_track_interop.cc",
"src/interop/rtc_dummy_audio_source_interop.cc",
"src/interop/rtc_video_device_interop.cc",
"src/interop/rtc_video_track_interop.cc",
"src/interop/rtc_video_frame_interop.cc",
"src/interop/rtc_video_renderer_interop.cc",
"src/interop/rtc_dummy_video_capturer_interop.cc",
"src/interop/rtc_data_channel_interop.cc",
"src/interop/rtc_ice_candidate_interop.cc",
"src/interop/rtc_logging_interop.cc",
"src/interop/rtc_media_stream_interop.cc",
"src/interop/rtc_dtmf_sender_interop.cc",
"src/interop/rtc_dtls_transport_interop.cc",
"src/interop/rtc_rtp_capabilities_interop.cc",
"src/interop/rtc_rtp_parameters_interop.cc",
"src/interop/rtc_rtp_receiver_interop.cc",
"src/interop/rtc_rtp_sender_interop.cc",
"src/interop/rtc_rtp_transceiver_interop.cc",
"src/interop/rtc_session_description_interop.cc",
"src/interop/rtc_peerconnection_interop.cc",
"src/interop/rtc_audio_processing_interop.cc",
"src/interop/rtc_frame_cryptor_interop.cc",
]

if (libwebrtc_desktop_capture) {
sources += [
"src/interop/rtc_desktop_media_list_interop.cc",
"src/interop/rtc_desktop_capturer_interop.cc",
"src/interop/rtc_desktop_device_interop.cc",
]
}
}

# intel media sdk
if (is_win && libwebrtc_intel_media_sdk) {
Expand Down Expand Up @@ -273,3 +341,20 @@ rtc_shared_library("libwebrtc") {
}
}
}


rtc_test("libwebrtc_unittests") {
testonly = true

sources = [
"test/peerconnection.test.cc",
"test/tests.cc",
]

deps = [
":libwebrtc",
"//testing/gtest",
"//test:test_support",
"//test:test_main",
]
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Porting CAPI-Interop WebRTC M125 to the current LibWebRTC M137
CAPI-Interop repo: https://github.com/GERD0GDU/libwebrtc author: GERD0GDU


# libwebrtc-{windows,linux}-{amd64,x86,armv7,arm64}.{dll,so}

WebRTC C++ wrapper
Expand Down
74 changes: 72 additions & 2 deletions include/base/portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <map>
#include <string>
#include <vector>
#include <sstream>

/**
* This file defines structures that can be passed across shared library/DLL
Expand All @@ -38,6 +39,9 @@ namespace portable {

#define PORTABLE_STRING_BUF_SIZE 48

template <typename T>
class vector;

class string {
private:
char m_buf[PORTABLE_STRING_BUF_SIZE];
Expand All @@ -49,7 +53,11 @@ class string {
LIB_PORTABLE_API void init(const char* str, size_t len);
LIB_PORTABLE_API void destroy();

inline string(const char* str) { init(str, strlen(str)); }
inline string(const char* str)
{
const char* strTemp = str ? str : "\0";
init(strTemp, strlen(strTemp));
}

inline string(const std::string& str) { init(str.c_str(), str.length()); }

Expand All @@ -71,7 +79,7 @@ class string {
return *this;
}

inline size_t size() { return m_length; }
inline size_t size() const { return m_length; }

inline const char* c_string() const {
return m_dynamic == 0 ? m_buf : m_dynamic;
Expand All @@ -80,6 +88,52 @@ class string {
inline std::string std_string() const {
return std::string(m_dynamic == 0 ? m_buf : m_dynamic, m_length);
}

/**
* Makes safe copies up to the size of the output buffer.
*
* @param dest - Output buffer
* @param sz_dest - Size of the output buffer
* @return size_t - Number of characters copied. (excluding the ending character '\0')
*/
inline size_t copy_to(char* dest, size_t sz_dest) const {
if (dest == 0) { return 0; }
*dest = '\0';
if (sz_dest == 0 || m_length == 0) { return 0; }
size_t cch_len = sz_dest - 1;
// safe copy
strncpy(dest, c_string(), cch_len);
dest[cch_len] = '\0';
return cch_len;
}

inline std::vector<string> split(string delimiter, bool removeEmptyEntries = true)
{
std::string input = std_string();
std::string item;
std::vector<string> tokens;
size_t start = 0;
size_t end = input.find(delimiter.c_string());

while (end != std::string::npos) {
item = input.substr(start, end - start);
if (!removeEmptyEntries || item.size() > 0) {
tokens.push_back(item);
}
start = end + delimiter.size();
end = input.find(delimiter.c_string(), start);
}

item = input.substr(start);
if (removeEmptyEntries && item.size() == 0) {
return tokens;
}

tokens.push_back(input.substr(start));
return tokens;
}

static std::string join(string separator, const vector<string>& values);
};

inline std::string to_std_string(const string& str) { return str.std_string(); }
Expand Down Expand Up @@ -213,6 +267,22 @@ class vector {
}
};

inline std::string string::join(string separator, const vector<string>& values)
{
size_t count = values.size();
if (count == 0) {
return std::string();
}
std::string retVal;
for (size_t i = 0; i < count; i++) {
retVal += values[i].std_string();
if ((i + 1) < count) {
retVal += separator.std_string();
}
}
return retVal;
}

template <typename K, typename V>
class pair {
public:
Expand Down
Loading