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
26 changes: 26 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
###################################################################################

The following modifications follow Apache License 2.0 from shiguredo.

https://github.com/webrtc-sdk/webrtc/commit/dfec53e93a0a1cb93f444caf50f844ec0068c7b7
https://github.com/webrtc-sdk/webrtc/commit/403b4678543c5d4ac77bd1ea5753c02637b3bb89
https://github.com/webrtc-sdk/webrtc/commit/77d5d685a90fb4bded17835ae72ec6671b26d696

Apache License 2.0

Copyright 2019-2021, Wandbox LLC (Original Author)
Copyright 2019-2021, Shiguredo Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

#####################################################################################
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# WebRTC-SDK

This is a **Community-Maintained** project, **Not the official Google WebRTC repository**. It is maintained by some contributors with WebRTC development experience, and the goal is to create a flexible release version to provide pre-compiled Mobile/Desktop/Embedded SDKs.

## Additional notes from [webrtc-sdk](https://github.com/webrtc-sdk) community

### Open Source License Compliance

* The original code was cloned from [google webrtc](https://chromium.googlesource.com/external/webrtc.git) and released with [BSD license](/LICENSE).

* Contains patches from the [shiguredo-webrtc-build](https://github.com/shiguredo-webrtc-build) community and complies with the [Apache 2.0](/NOTICE) license.

### Who is using this project

* [flutter-webrtc](https://github.com/flutter-webrtc/flutter-webrtc)

* [LiveKit](https://github.com/livekit)

## The Google WebRTC original README

**WebRTC is a free, open software project** that provides browsers and mobile
applications with Real-Time Communications (RTC) capabilities via simple APIs.
The WebRTC components have been optimized to best serve this purpose.
Expand Down
23 changes: 23 additions & 0 deletions sdk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ if (is_ios || is_mac) {

deps = [
":av1",
":simulcast",
":base_objc",
":native_video",
":videocodec_objc",
Expand Down Expand Up @@ -734,6 +735,22 @@ if (is_ios || is_mac) {
]
}

rtc_library("simulcast") {
sources = [
"objc/components/video_codec/RTCVideoEncoderFactorySimulcast.h",
"objc/components/video_codec/RTCVideoEncoderFactorySimulcast.mm",
"objc/api/video_codec/RTCVideoEncoderSimulcast.h",
"objc/api/video_codec/RTCVideoEncoderSimulcast.mm",
]

deps = [
":base_objc",
":wrapped_native_codec_objc",
"../media:rtc_media_base",
"../media:rtc_simulcast_encoder_adapter",
]
}

# Build the PeerConnectionFactory without audio/video support.
# This target depends on the objc_peeerconnectionfactory_base which still
# includes some audio/video related objects such as RTCAudioSource because
Expand Down Expand Up @@ -1300,6 +1317,9 @@ if (is_ios || is_mac) {
"objc/api/video_codec/RTCVideoEncoderAV1.h",
"objc/api/video_frame_buffer/RTCNativeI420Buffer.h",
"objc/api/video_frame_buffer/RTCNativeMutableI420Buffer.h",
# Added for Simulcast support
"objc/components/video_codec/RTCVideoEncoderFactorySimulcast.h",
"objc/api/video_codec/RTCVideoEncoderSimulcast.h",
]

if (!build_with_chromium) {
Expand Down Expand Up @@ -1444,6 +1464,9 @@ if (is_ios || is_mac) {
"objc/components/video_codec/RTCVideoEncoderH264.h",
"objc/components/video_frame_buffer/RTCCVPixelBuffer.h",
"objc/helpers/RTCDispatcher.h",
# Added for Simulcast support
"objc/components/video_codec/RTCVideoEncoderFactorySimulcast.h",
"objc/api/video_codec/RTCVideoEncoderSimulcast.h",
]
if (!build_with_chromium) {
sources += [
Expand Down
18 changes: 18 additions & 0 deletions sdk/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,8 @@ if (is_android) {
sources = [
"api/org/webrtc/SoftwareVideoDecoderFactory.java",
"api/org/webrtc/SoftwareVideoEncoderFactory.java",
"api/org/webrtc/SimulcastVideoEncoder.java",
"api/org/webrtc/SimulcastVideoEncoderFactory.java",
]

deps = [
Expand Down Expand Up @@ -870,13 +872,29 @@ if (current_os == "linux" || is_android) {
]
}

rtc_library("simulcast_jni") {
visibility = [ "*" ]
allow_poison = [ "software_video_codecs" ]
sources = [
"src/jni/simulcast_video_encoder.cc",
"src/jni/simulcast_video_encoder.h"
]
deps = [
":base_jni",
":video_jni",
":native_api_codecs",
"../../media:rtc_simulcast_encoder_adapter"
]
}

rtc_library("swcodecs_jni") {
visibility = [ "*" ]
allow_poison = [ "software_video_codecs" ]
deps = [
":libaom_av1_jni",
":libvpx_vp8_jni",
":libvpx_vp9_jni",
":simulcast_jni",
]
}

Expand Down
28 changes: 28 additions & 0 deletions sdk/android/api/org/webrtc/SimulcastVideoEncoder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.webrtc;

public class SimulcastVideoEncoder extends WrappedNativeVideoEncoder {

static native long nativeCreateEncoder(VideoEncoderFactory primary, VideoEncoderFactory fallback, VideoCodecInfo info);

VideoEncoderFactory primary;
VideoEncoderFactory fallback;
VideoCodecInfo info;

public SimulcastVideoEncoder(VideoEncoderFactory primary, VideoEncoderFactory fallback, VideoCodecInfo info) {
this.primary = primary;
this.fallback = fallback;
this.info = info;
}

@Override
public long createNativeVideoEncoder() {
return nativeCreateEncoder(primary, fallback, info);
}

@Override
public boolean isHardwareEncoder() {
return false;
}

}

43 changes: 43 additions & 0 deletions sdk/android/api/org/webrtc/SimulcastVideoEncoderFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/

package org.webrtc;

import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;

public class SimulcastVideoEncoderFactory implements VideoEncoderFactory {

VideoEncoderFactory primary;
VideoEncoderFactory fallback;

public SimulcastVideoEncoderFactory(VideoEncoderFactory primary, VideoEncoderFactory fallback) {
this.primary = primary;
this.fallback = fallback;
}

@Nullable
@Override
public VideoEncoder createEncoder(VideoCodecInfo info) {
return new SimulcastVideoEncoder(primary, fallback, info);
}

@Override
public VideoCodecInfo[] getSupportedCodecs() {
List<VideoCodecInfo> codecs = new ArrayList<VideoCodecInfo>();
codecs.addAll(Arrays.asList(primary.getSupportedCodecs()));
codecs.addAll(Arrays.asList(fallback.getSupportedCodecs()));
return codecs.toArray(new VideoCodecInfo[codecs.size()]);
}

}
34 changes: 34 additions & 0 deletions sdk/android/src/jni/simulcast_video_encoder.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <jni.h>

#include "sdk/android/src/jni/jni_helpers.h"
#include "sdk/android/src/jni/video_encoder_factory_wrapper.h"
#include "sdk/android/src/jni/video_codec_info.h"
#include "sdk/android/native_api/codecs/wrapper.h"
#include "media/engine/simulcast_encoder_adapter.h"
#include "rtc_base/logging.h"

using namespace webrtc;
using namespace webrtc::jni;

#ifdef __cplusplus
extern "C" {
#endif

// (VideoEncoderFactory primary, VideoEncoderFactory fallback, VideoCodecInfo info)
JNIEXPORT jlong JNICALL Java_org_webrtc_SimulcastVideoEncoder_nativeCreateEncoder(JNIEnv *env, jclass klass, jobject primary, jobject fallback, jobject info) {
RTC_LOG(LS_INFO) << "Create simulcast video encoder";
JavaParamRef<jobject> info_ref(info);
SdpVideoFormat format = VideoCodecInfoToSdpVideoFormat(env, info_ref);

// TODO: 影響は軽微だが、リークする可能性があるので将来的に修正したい
// https://github.com/shiguredo-webrtc-build/webrtc-build/pull/16#pullrequestreview-600675795
return NativeToJavaPointer(std::make_unique<SimulcastEncoderAdapter>(
JavaToNativeVideoEncoderFactory(env, primary).release(),
JavaToNativeVideoEncoderFactory(env, fallback).release(),
format).release());
}


#ifdef __cplusplus
}
#endif
22 changes: 22 additions & 0 deletions sdk/android/src/jni/simulcast_video_encoder.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ NS_ASSUME_NONNULL_BEGIN
initWithEncoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)encoderFactory
decoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory;

- (instancetype)
initWithBypassVoiceProcessing:(BOOL)bypassVoiceProcessing
encoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)encoderFactory
decoderFactory:
(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory;

/** Initialize an RTCPeerConnection with a configuration, constraints, and
* dependencies.
*/
Expand Down
7 changes: 7 additions & 0 deletions sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ RTC_OBJC_EXPORT
initWithEncoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)encoderFactory
decoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory;

/* Initialize object with bypass voice processing */
- (instancetype)
initWithBypassVoiceProcessing:(BOOL)bypassVoiceProcessing
encoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)encoderFactory
decoderFactory:
(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory;

/** Initialize an RTCAudioSource with constraints. */
- (RTC_OBJC_TYPE(RTCAudioSource) *)audioSourceWithConstraints:
(nullable RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints;
Expand Down
34 changes: 30 additions & 4 deletions sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ @implementation RTC_OBJC_TYPE (RTCPeerConnectionFactory) {

@synthesize nativeFactory = _nativeFactory;

- (rtc::scoped_refptr<webrtc::AudioDeviceModule>)audioDeviceModule {
- (rtc::scoped_refptr<webrtc::AudioDeviceModule>)audioDeviceModule:(BOOL)bypassVoiceProcessing {
#if defined(WEBRTC_IOS)
return webrtc::CreateAudioDeviceModule();
return webrtc::CreateAudioDeviceModule(bypassVoiceProcessing);
#else
return nullptr;
#endif
Expand All @@ -87,7 +87,7 @@ - (instancetype)init {
RTCVideoEncoderFactoryH264) alloc] init])
nativeVideoDecoderFactory:webrtc::ObjCToNativeVideoDecoderFactory([[RTC_OBJC_TYPE(
RTCVideoDecoderFactoryH264) alloc] init])
audioDeviceModule:[self audioDeviceModule]
audioDeviceModule:[self audioDeviceModule:false]
audioProcessingModule:nullptr];
#endif
}
Expand All @@ -110,10 +110,36 @@ - (instancetype)init {
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
nativeVideoEncoderFactory:std::move(native_encoder_factory)
nativeVideoDecoderFactory:std::move(native_decoder_factory)
audioDeviceModule:[self audioDeviceModule]
audioDeviceModule:[self audioDeviceModule:false]
audioProcessingModule:nullptr];
#endif
}

- (instancetype)
initWithBypassVoiceProcessing:(BOOL)bypassVoiceProcessing
encoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)encoderFactory
decoderFactory:
(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory {
#ifdef HAVE_NO_MEDIA
return [self initWithNoMedia];
#else
std::unique_ptr<webrtc::VideoEncoderFactory> native_encoder_factory;
std::unique_ptr<webrtc::VideoDecoderFactory> native_decoder_factory;
if (encoderFactory) {
native_encoder_factory = webrtc::ObjCToNativeVideoEncoderFactory(encoderFactory);
}
if (decoderFactory) {
native_decoder_factory = webrtc::ObjCToNativeVideoDecoderFactory(decoderFactory);
}
return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
nativeVideoEncoderFactory:std::move(native_encoder_factory)
nativeVideoDecoderFactory:std::move(native_decoder_factory)
audioDeviceModule:[self audioDeviceModule:bypassVoiceProcessing]
audioProcessingModule:nullptr];
#endif
}

- (instancetype)initNative {
if (self = [super init]) {
_networkThread = rtc::Thread::CreateWithSocketServer();
Expand Down
13 changes: 13 additions & 0 deletions sdk/objc/api/video_codec/RTCVideoEncoderSimulcast.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#import "RTCMacros.h"
#import "RTCVideoEncoder.h"
#import "RTCVideoEncoderFactory.h"
#import "RTCVideoCodecInfo.h"

RTC_OBJC_EXPORT
@interface RTC_OBJC_TYPE (RTCVideoEncoderSimulcast) : NSObject

+ (id<RTC_OBJC_TYPE(RTCVideoEncoder)>)simulcastEncoderWithPrimary:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)primary
fallback:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)fallback
videoCodecInfo:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)videoCodecInfo;

@end
Loading