-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simulcast support for iOS SDK (#4) Support for simulcast in Android SDK (#3) include simulcast headers for mac also (#10) Fix simulcast using hardware encoder on Android (#48) Co-authored-by: Hiroshi Horie <[email protected]> Co-authored-by: Angelika Serwa <[email protected]>
- Loading branch information
1 parent
272127d
commit ee03026
Showing
12 changed files
with
275 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
43
sdk/android/api/org/webrtc/SimulcastVideoEncoderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()]); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
#import "RTCMacros.h" | ||
#import "RTCVideoEncoderSimulcast.h" | ||
#import "RTCWrappedNativeVideoEncoder.h" | ||
#import "api/peerconnection/RTCVideoCodecInfo+Private.h" | ||
|
||
#include "native/api/video_encoder_factory.h" | ||
#include "media/engine/simulcast_encoder_adapter.h" | ||
|
||
@implementation RTC_OBJC_TYPE (RTCVideoEncoderSimulcast) | ||
|
||
+ (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 { | ||
auto nativePrimary = webrtc::ObjCToNativeVideoEncoderFactory(primary); | ||
auto nativeFallback = webrtc::ObjCToNativeVideoEncoderFactory(fallback); | ||
auto nativeFormat = [videoCodecInfo nativeSdpVideoFormat]; | ||
return [[RTC_OBJC_TYPE(RTCWrappedNativeVideoEncoder) alloc] | ||
initWithNativeEncoder: std::make_unique<webrtc::SimulcastEncoderAdapter>( | ||
nativePrimary.release(), | ||
nativeFallback.release(), | ||
std::move(nativeFormat))]; | ||
} | ||
|
||
@end |
16 changes: 16 additions & 0 deletions
16
sdk/objc/components/video_codec/RTCVideoEncoderFactorySimulcast.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
#import "RTCMacros.h" | ||
#import "RTCVideoEncoderFactory.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
RTC_OBJC_EXPORT | ||
@interface RTC_OBJC_TYPE (RTCVideoEncoderFactorySimulcast) : NSObject <RTC_OBJC_TYPE(RTCVideoEncoderFactory)> | ||
|
||
- (instancetype)initWithPrimary:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)primary | ||
fallback:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)fallback; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
39 changes: 39 additions & 0 deletions
39
sdk/objc/components/video_codec/RTCVideoEncoderFactorySimulcast.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
#import "RTCMacros.h" | ||
#import "RTCVideoCodecInfo.h" | ||
#import "RTCVideoEncoderFactorySimulcast.h" | ||
#import "api/video_codec/RTCVideoEncoderSimulcast.h" | ||
|
||
@interface RTC_OBJC_TYPE (RTCVideoEncoderFactorySimulcast) () | ||
|
||
@property id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)> primary; | ||
@property id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)> fallback; | ||
|
||
@end | ||
|
||
|
||
@implementation RTC_OBJC_TYPE (RTCVideoEncoderFactorySimulcast) | ||
|
||
@synthesize primary = _primary; | ||
@synthesize fallback = _fallback; | ||
|
||
- (instancetype)initWithPrimary:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)primary | ||
fallback:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)fallback { | ||
if (self = [super init]) { | ||
_primary = primary; | ||
_fallback = fallback; | ||
} | ||
return self; | ||
} | ||
|
||
- (nullable id<RTC_OBJC_TYPE(RTCVideoEncoder)>)createEncoder: (RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info { | ||
return [RTCVideoEncoderSimulcast simulcastEncoderWithPrimary: _primary fallback: _fallback videoCodecInfo: info]; | ||
} | ||
|
||
- (NSArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *)supportedCodecs { | ||
return [[_primary supportedCodecs] arrayByAddingObjectsFromArray: [_fallback supportedCodecs]]; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters