iOS: Add ability to specify audio constraints.
NOTRY=True BUG= Review-Url: https://codereview.webrtc.org/2290583003 Cr-Commit-Position: refs/heads/master@{#13976}
This commit is contained in:
@ -73,6 +73,8 @@ if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
|
|||||||
sources = [
|
sources = [
|
||||||
"objc/Framework/Classes/RTCAVFoundationVideoSource+Private.h",
|
"objc/Framework/Classes/RTCAVFoundationVideoSource+Private.h",
|
||||||
"objc/Framework/Classes/RTCAVFoundationVideoSource.mm",
|
"objc/Framework/Classes/RTCAVFoundationVideoSource.mm",
|
||||||
|
"objc/Framework/Classes/RTCAudioSource+Private.h",
|
||||||
|
"objc/Framework/Classes/RTCAudioSource.mm",
|
||||||
"objc/Framework/Classes/RTCAudioTrack+Private.h",
|
"objc/Framework/Classes/RTCAudioTrack+Private.h",
|
||||||
"objc/Framework/Classes/RTCAudioTrack.mm",
|
"objc/Framework/Classes/RTCAudioTrack.mm",
|
||||||
"objc/Framework/Classes/RTCConfiguration+Private.h",
|
"objc/Framework/Classes/RTCConfiguration+Private.h",
|
||||||
@ -88,6 +90,8 @@ if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
|
|||||||
"objc/Framework/Classes/RTCIceServer.mm",
|
"objc/Framework/Classes/RTCIceServer.mm",
|
||||||
"objc/Framework/Classes/RTCMediaConstraints+Private.h",
|
"objc/Framework/Classes/RTCMediaConstraints+Private.h",
|
||||||
"objc/Framework/Classes/RTCMediaConstraints.mm",
|
"objc/Framework/Classes/RTCMediaConstraints.mm",
|
||||||
|
"objc/Framework/Classes/RTCMediaSource+Private.h",
|
||||||
|
"objc/Framework/Classes/RTCMediaSource.mm",
|
||||||
"objc/Framework/Classes/RTCMediaStream+Private.h",
|
"objc/Framework/Classes/RTCMediaStream+Private.h",
|
||||||
"objc/Framework/Classes/RTCMediaStream.mm",
|
"objc/Framework/Classes/RTCMediaStream.mm",
|
||||||
"objc/Framework/Classes/RTCMediaStreamTrack+Private.h",
|
"objc/Framework/Classes/RTCMediaStreamTrack+Private.h",
|
||||||
@ -130,6 +134,7 @@ if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
|
|||||||
"objc/Framework/Classes/avfoundationvideocapturer.h",
|
"objc/Framework/Classes/avfoundationvideocapturer.h",
|
||||||
"objc/Framework/Classes/avfoundationvideocapturer.mm",
|
"objc/Framework/Classes/avfoundationvideocapturer.mm",
|
||||||
"objc/Framework/Headers/WebRTC/RTCAVFoundationVideoSource.h",
|
"objc/Framework/Headers/WebRTC/RTCAVFoundationVideoSource.h",
|
||||||
|
"objc/Framework/Headers/WebRTC/RTCAudioSource.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCAudioTrack.h",
|
"objc/Framework/Headers/WebRTC/RTCAudioTrack.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCConfiguration.h",
|
"objc/Framework/Headers/WebRTC/RTCConfiguration.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCDataChannel.h",
|
"objc/Framework/Headers/WebRTC/RTCDataChannel.h",
|
||||||
@ -137,6 +142,7 @@ if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
|
|||||||
"objc/Framework/Headers/WebRTC/RTCIceCandidate.h",
|
"objc/Framework/Headers/WebRTC/RTCIceCandidate.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCIceServer.h",
|
"objc/Framework/Headers/WebRTC/RTCIceServer.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCMediaConstraints.h",
|
"objc/Framework/Headers/WebRTC/RTCMediaConstraints.h",
|
||||||
|
"objc/Framework/Headers/WebRTC/RTCMediaSource.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCMediaStream.h",
|
"objc/Framework/Headers/WebRTC/RTCMediaStream.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCMediaStreamTrack.h",
|
"objc/Framework/Headers/WebRTC/RTCMediaStreamTrack.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCPeerConnection.h",
|
"objc/Framework/Headers/WebRTC/RTCPeerConnection.h",
|
||||||
|
|||||||
32
webrtc/sdk/objc/Framework/Classes/RTCAudioSource+Private.h
Normal file
32
webrtc/sdk/objc/Framework/Classes/RTCAudioSource+Private.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "WebRTC/RTCAudioSource.h"
|
||||||
|
|
||||||
|
#import "RTCMediaSource+Private.h"
|
||||||
|
|
||||||
|
@interface RTCAudioSource ()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The AudioSourceInterface object passed to this RTCAudioSource during
|
||||||
|
* construction.
|
||||||
|
*/
|
||||||
|
@property(nonatomic, readonly) rtc::scoped_refptr<webrtc::AudioSourceInterface> nativeAudioSource;
|
||||||
|
|
||||||
|
/** Initialize an RTCAudioSource from a native AudioSourceInterface. */
|
||||||
|
- (instancetype)initWithNativeAudioSource:
|
||||||
|
(rtc::scoped_refptr<webrtc::AudioSourceInterface>)nativeAudioSource
|
||||||
|
NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
- (instancetype)initWithNativeMediaSource:
|
||||||
|
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
||||||
|
type:(RTCMediaSourceType)type NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
@end
|
||||||
47
webrtc/sdk/objc/Framework/Classes/RTCAudioSource.mm
Normal file
47
webrtc/sdk/objc/Framework/Classes/RTCAudioSource.mm
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "RTCAudioSource+Private.h"
|
||||||
|
|
||||||
|
#include "webrtc/base/checks.h"
|
||||||
|
|
||||||
|
@implementation RTCAudioSource {
|
||||||
|
rtc::scoped_refptr<webrtc::AudioSourceInterface> _nativeAudioSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithNativeAudioSource:
|
||||||
|
(rtc::scoped_refptr<webrtc::AudioSourceInterface>)nativeAudioSource {
|
||||||
|
RTC_DCHECK(nativeAudioSource);
|
||||||
|
if (self = [super initWithNativeMediaSource:nativeAudioSource
|
||||||
|
type:RTCMediaSourceTypeAudio]) {
|
||||||
|
_nativeAudioSource = nativeAudioSource;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithNativeMediaSource:
|
||||||
|
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
||||||
|
type:(RTCMediaSourceType)type {
|
||||||
|
RTC_NOTREACHED();
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)description {
|
||||||
|
NSString *stateString = [[self class] stringForState:self.state];
|
||||||
|
return [NSString stringWithFormat:@"RTCAudioSource( %p ): %@", self, stateString];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private
|
||||||
|
|
||||||
|
- (rtc::scoped_refptr<webrtc::AudioSourceInterface>)nativeAudioSource {
|
||||||
|
return _nativeAudioSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@ -23,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
/** Initialize an RTCAudioTrack with an id. */
|
/** Initialize an RTCAudioTrack with an id. */
|
||||||
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
|
source:(RTCAudioSource *)source
|
||||||
trackId:(NSString *)trackId;
|
trackId:(NSString *)trackId;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -11,19 +11,30 @@
|
|||||||
#import "RTCAudioTrack+Private.h"
|
#import "RTCAudioTrack+Private.h"
|
||||||
|
|
||||||
#import "NSString+StdString.h"
|
#import "NSString+StdString.h"
|
||||||
|
#import "RTCAudioSource+Private.h"
|
||||||
#import "RTCMediaStreamTrack+Private.h"
|
#import "RTCMediaStreamTrack+Private.h"
|
||||||
#import "RTCPeerConnectionFactory+Private.h"
|
#import "RTCPeerConnectionFactory+Private.h"
|
||||||
|
|
||||||
|
#include "webrtc/base/checks.h"
|
||||||
|
|
||||||
@implementation RTCAudioTrack
|
@implementation RTCAudioTrack
|
||||||
|
|
||||||
|
@synthesize source = _source;
|
||||||
|
|
||||||
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
|
source:(RTCAudioSource *)source
|
||||||
trackId:(NSString *)trackId {
|
trackId:(NSString *)trackId {
|
||||||
NSParameterAssert(factory);
|
RTC_DCHECK(factory);
|
||||||
NSParameterAssert(trackId.length);
|
RTC_DCHECK(source);
|
||||||
|
RTC_DCHECK(trackId.length);
|
||||||
|
|
||||||
std::string nativeId = [NSString stdStringForString:trackId];
|
std::string nativeId = [NSString stdStringForString:trackId];
|
||||||
rtc::scoped_refptr<webrtc::AudioTrackInterface> track =
|
rtc::scoped_refptr<webrtc::AudioTrackInterface> track =
|
||||||
factory.nativeFactory->CreateAudioTrack(nativeId, nullptr);
|
factory.nativeFactory->CreateAudioTrack(nativeId, source.nativeAudioSource);
|
||||||
return [self initWithNativeTrack:track type:RTCMediaStreamTrackTypeAudio];
|
if ([self initWithNativeTrack:track type:RTCMediaStreamTrackTypeAudio]) {
|
||||||
|
_source = source;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithNativeTrack:
|
- (instancetype)initWithNativeTrack:
|
||||||
@ -34,6 +45,18 @@
|
|||||||
return [super initWithNativeTrack:nativeTrack type:type];
|
return [super initWithNativeTrack:nativeTrack type:type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (RTCAudioSource *)source {
|
||||||
|
if (!_source) {
|
||||||
|
rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
|
||||||
|
self.nativeAudioTrack->GetSource();
|
||||||
|
if (source) {
|
||||||
|
_source = [[RTCAudioSource alloc] initWithNativeAudioSource:source.get()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _source;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Private
|
#pragma mark - Private
|
||||||
|
|
||||||
- (rtc::scoped_refptr<webrtc::AudioTrackInterface>)nativeAudioTrack {
|
- (rtc::scoped_refptr<webrtc::AudioTrackInterface>)nativeAudioTrack {
|
||||||
|
|||||||
42
webrtc/sdk/objc/Framework/Classes/RTCMediaSource+Private.h
Normal file
42
webrtc/sdk/objc/Framework/Classes/RTCMediaSource+Private.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "WebRTC/RTCMediaSource.h"
|
||||||
|
|
||||||
|
#include "webrtc/api/mediastreaminterface.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, RTCMediaSourceType) {
|
||||||
|
RTCMediaSourceTypeAudio,
|
||||||
|
RTCMediaSourceTypeVideo,
|
||||||
|
};
|
||||||
|
|
||||||
|
@interface RTCMediaSource ()
|
||||||
|
|
||||||
|
@property(nonatomic, readonly)
|
||||||
|
rtc::scoped_refptr<webrtc::MediaSourceInterface> nativeMediaSource;
|
||||||
|
|
||||||
|
- (instancetype)initWithNativeMediaSource:
|
||||||
|
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
||||||
|
type:(RTCMediaSourceType)type
|
||||||
|
NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
+ (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForState:
|
||||||
|
(RTCSourceState)state;
|
||||||
|
|
||||||
|
+ (RTCSourceState)sourceStateForNativeState:
|
||||||
|
(webrtc::MediaSourceInterface::SourceState)nativeState;
|
||||||
|
|
||||||
|
+ (NSString *)stringForState:(RTCSourceState)state;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
79
webrtc/sdk/objc/Framework/Classes/RTCMediaSource.mm
Normal file
79
webrtc/sdk/objc/Framework/Classes/RTCMediaSource.mm
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "RTCMediaSource+Private.h"
|
||||||
|
|
||||||
|
#include "webrtc/base/checks.h"
|
||||||
|
|
||||||
|
@implementation RTCMediaSource {
|
||||||
|
RTCMediaSourceType _type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@synthesize nativeMediaSource = _nativeMediaSource;
|
||||||
|
|
||||||
|
- (instancetype)initWithNativeMediaSource:
|
||||||
|
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
||||||
|
type:(RTCMediaSourceType)type {
|
||||||
|
RTC_DCHECK(nativeMediaSource);
|
||||||
|
if (self = [super init]) {
|
||||||
|
_nativeMediaSource = nativeMediaSource;
|
||||||
|
_type = type;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (RTCSourceState)state {
|
||||||
|
return [[self class] sourceStateForNativeState:_nativeMediaSource->state()];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private
|
||||||
|
|
||||||
|
+ (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForState:
|
||||||
|
(RTCSourceState)state {
|
||||||
|
switch (state) {
|
||||||
|
case RTCSourceStateInitializing:
|
||||||
|
return webrtc::MediaSourceInterface::kInitializing;
|
||||||
|
case RTCSourceStateLive:
|
||||||
|
return webrtc::MediaSourceInterface::kLive;
|
||||||
|
case RTCSourceStateEnded:
|
||||||
|
return webrtc::MediaSourceInterface::kEnded;
|
||||||
|
case RTCSourceStateMuted:
|
||||||
|
return webrtc::MediaSourceInterface::kMuted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (RTCSourceState)sourceStateForNativeState:
|
||||||
|
(webrtc::MediaSourceInterface::SourceState)nativeState {
|
||||||
|
switch (nativeState) {
|
||||||
|
case webrtc::MediaSourceInterface::kInitializing:
|
||||||
|
return RTCSourceStateInitializing;
|
||||||
|
case webrtc::MediaSourceInterface::kLive:
|
||||||
|
return RTCSourceStateLive;
|
||||||
|
case webrtc::MediaSourceInterface::kEnded:
|
||||||
|
return RTCSourceStateEnded;
|
||||||
|
case webrtc::MediaSourceInterface::kMuted:
|
||||||
|
return RTCSourceStateMuted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSString *)stringForState:(RTCSourceState)state {
|
||||||
|
switch (state) {
|
||||||
|
case RTCSourceStateInitializing:
|
||||||
|
return @"Initializing";
|
||||||
|
case RTCSourceStateLive:
|
||||||
|
return @"Live";
|
||||||
|
case RTCSourceStateEnded:
|
||||||
|
return @"Ended";
|
||||||
|
case RTCSourceStateMuted:
|
||||||
|
return @"Muted";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@ -12,7 +12,9 @@
|
|||||||
|
|
||||||
#import "NSString+StdString.h"
|
#import "NSString+StdString.h"
|
||||||
#import "RTCAVFoundationVideoSource+Private.h"
|
#import "RTCAVFoundationVideoSource+Private.h"
|
||||||
|
#import "RTCAudioSource+Private.h"
|
||||||
#import "RTCAudioTrack+Private.h"
|
#import "RTCAudioTrack+Private.h"
|
||||||
|
#import "RTCMediaConstraints+Private.h"
|
||||||
#import "RTCMediaStream+Private.h"
|
#import "RTCMediaStream+Private.h"
|
||||||
#import "RTCPeerConnection+Private.h"
|
#import "RTCPeerConnection+Private.h"
|
||||||
#import "RTCVideoSource+Private.h"
|
#import "RTCVideoSource+Private.h"
|
||||||
@ -61,17 +63,34 @@
|
|||||||
_nativeFactory->StopAecDump();
|
_nativeFactory->StopAecDump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)constraints {
|
||||||
|
std::unique_ptr<webrtc::MediaConstraints> nativeConstraints;
|
||||||
|
if (constraints) {
|
||||||
|
nativeConstraints = constraints.nativeConstraints;
|
||||||
|
}
|
||||||
|
rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
|
||||||
|
_nativeFactory->CreateAudioSource(nativeConstraints.get());
|
||||||
|
return [[RTCAudioSource alloc] initWithNativeAudioSource:source];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId {
|
||||||
|
RTCAudioSource *audioSource = [self audioSourceWithConstraints:nil];
|
||||||
|
return [self audioTrackWithSource:audioSource trackId:trackId];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (RTCAudioTrack *)audioTrackWithSource:(RTCAudioSource *)source
|
||||||
|
trackId:(NSString *)trackId {
|
||||||
|
return [[RTCAudioTrack alloc] initWithFactory:self
|
||||||
|
source:source
|
||||||
|
trackId:trackId];
|
||||||
|
}
|
||||||
|
|
||||||
- (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints:
|
- (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints:
|
||||||
(nullable RTCMediaConstraints *)constraints {
|
(nullable RTCMediaConstraints *)constraints {
|
||||||
return [[RTCAVFoundationVideoSource alloc] initWithFactory:self
|
return [[RTCAVFoundationVideoSource alloc] initWithFactory:self
|
||||||
constraints:constraints];
|
constraints:constraints];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId {
|
|
||||||
return [[RTCAudioTrack alloc] initWithFactory:self
|
|
||||||
trackId:trackId];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source
|
- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source
|
||||||
trackId:(NSString *)trackId {
|
trackId:(NSString *)trackId {
|
||||||
return [[RTCVideoTrack alloc] initWithFactory:self
|
return [[RTCVideoTrack alloc] initWithFactory:self
|
||||||
|
|||||||
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#import "WebRTC/RTCVideoSource.h"
|
#import "WebRTC/RTCVideoSource.h"
|
||||||
|
|
||||||
|
#import "RTCMediaSource+Private.h"
|
||||||
|
|
||||||
#include "webrtc/api/mediastreaminterface.h"
|
#include "webrtc/api/mediastreaminterface.h"
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
@ -29,13 +31,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
(rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)nativeVideoSource
|
(rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)nativeVideoSource
|
||||||
NS_DESIGNATED_INITIALIZER;
|
NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
+ (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForState:
|
- (instancetype)initWithNativeMediaSource:
|
||||||
(RTCSourceState)state;
|
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
||||||
|
type:(RTCMediaSourceType)type NS_UNAVAILABLE;
|
||||||
+ (RTCSourceState)sourceStateForNativeState:
|
|
||||||
(webrtc::MediaSourceInterface::SourceState)nativeState;
|
|
||||||
|
|
||||||
+ (NSString *)stringForState:(RTCSourceState)state;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@ -10,17 +10,32 @@
|
|||||||
|
|
||||||
#import "RTCVideoSource+Private.h"
|
#import "RTCVideoSource+Private.h"
|
||||||
|
|
||||||
|
#include "webrtc/base/checks.h"
|
||||||
|
|
||||||
@implementation RTCVideoSource {
|
@implementation RTCVideoSource {
|
||||||
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> _nativeVideoSource;
|
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> _nativeVideoSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (RTCSourceState)state {
|
- (instancetype)initWithNativeVideoSource:
|
||||||
return [[self class] sourceStateForNativeState:_nativeVideoSource->state()];
|
(rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)nativeVideoSource {
|
||||||
|
RTC_DCHECK(nativeVideoSource);
|
||||||
|
if (self = [super initWithNativeMediaSource:nativeVideoSource
|
||||||
|
type:RTCMediaSourceTypeVideo]) {
|
||||||
|
_nativeVideoSource = nativeVideoSource;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithNativeMediaSource:
|
||||||
|
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
||||||
|
type:(RTCMediaSourceType)type {
|
||||||
|
RTC_NOTREACHED();
|
||||||
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)description {
|
- (NSString *)description {
|
||||||
return [NSString stringWithFormat:@"RTCVideoSource:\n%@",
|
NSString *stateString = [[self class] stringForState:self.state];
|
||||||
[[self class] stringForState:self.state]];
|
return [NSString stringWithFormat:@"RTCVideoSource( %p ): %@", self, stateString];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Private
|
#pragma mark - Private
|
||||||
@ -29,54 +44,4 @@
|
|||||||
return _nativeVideoSource;
|
return _nativeVideoSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithNativeVideoSource:
|
|
||||||
(rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)nativeVideoSource {
|
|
||||||
NSParameterAssert(nativeVideoSource);
|
|
||||||
if (self = [super init]) {
|
|
||||||
_nativeVideoSource = nativeVideoSource;
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForState:
|
|
||||||
(RTCSourceState)state {
|
|
||||||
switch (state) {
|
|
||||||
case RTCSourceStateInitializing:
|
|
||||||
return webrtc::MediaSourceInterface::kInitializing;
|
|
||||||
case RTCSourceStateLive:
|
|
||||||
return webrtc::MediaSourceInterface::kLive;
|
|
||||||
case RTCSourceStateEnded:
|
|
||||||
return webrtc::MediaSourceInterface::kEnded;
|
|
||||||
case RTCSourceStateMuted:
|
|
||||||
return webrtc::MediaSourceInterface::kMuted;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (RTCSourceState)sourceStateForNativeState:
|
|
||||||
(webrtc::MediaSourceInterface::SourceState)nativeState {
|
|
||||||
switch (nativeState) {
|
|
||||||
case webrtc::MediaSourceInterface::kInitializing:
|
|
||||||
return RTCSourceStateInitializing;
|
|
||||||
case webrtc::MediaSourceInterface::kLive:
|
|
||||||
return RTCSourceStateLive;
|
|
||||||
case webrtc::MediaSourceInterface::kEnded:
|
|
||||||
return RTCSourceStateEnded;
|
|
||||||
case webrtc::MediaSourceInterface::kMuted:
|
|
||||||
return RTCSourceStateMuted;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSString *)stringForState:(RTCSourceState)state {
|
|
||||||
switch (state) {
|
|
||||||
case RTCSourceStateInitializing:
|
|
||||||
return @"Initializing";
|
|
||||||
case RTCSourceStateLive:
|
|
||||||
return @"Live";
|
|
||||||
case RTCSourceStateEnded:
|
|
||||||
return @"Ended";
|
|
||||||
case RTCSourceStateMuted:
|
|
||||||
return @"Muted";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
25
webrtc/sdk/objc/Framework/Headers/WebRTC/RTCAudioSource.h
Normal file
25
webrtc/sdk/objc/Framework/Headers/WebRTC/RTCAudioSource.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <WebRTC/RTCMacros.h>
|
||||||
|
#import <WebRTC/RTCMediaSource.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
RTC_EXPORT
|
||||||
|
@interface RTCAudioSource : RTCMediaSource
|
||||||
|
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@ -13,11 +13,16 @@
|
|||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@class RTCAudioSource;
|
||||||
|
|
||||||
RTC_EXPORT
|
RTC_EXPORT
|
||||||
@interface RTCAudioTrack : RTCMediaStreamTrack
|
@interface RTCAudioTrack : RTCMediaStreamTrack
|
||||||
|
|
||||||
- (instancetype)init NS_UNAVAILABLE;
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
/** The audio source for this audio track. */
|
||||||
|
@property(nonatomic, readonly) RTCAudioSource *source;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|||||||
34
webrtc/sdk/objc/Framework/Headers/WebRTC/RTCMediaSource.h
Normal file
34
webrtc/sdk/objc/Framework/Headers/WebRTC/RTCMediaSource.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <WebRTC/RTCMacros.h>
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, RTCSourceState) {
|
||||||
|
RTCSourceStateInitializing,
|
||||||
|
RTCSourceStateLive,
|
||||||
|
RTCSourceStateEnded,
|
||||||
|
RTCSourceStateMuted,
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
RTC_EXPORT
|
||||||
|
@interface RTCMediaSource : NSObject
|
||||||
|
|
||||||
|
/** The current state of the RTCMediaSource. */
|
||||||
|
@property(nonatomic, readonly) RTCSourceState state;
|
||||||
|
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@ -15,6 +15,7 @@
|
|||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@class RTCAVFoundationVideoSource;
|
@class RTCAVFoundationVideoSource;
|
||||||
|
@class RTCAudioSource;
|
||||||
@class RTCAudioTrack;
|
@class RTCAudioTrack;
|
||||||
@class RTCConfiguration;
|
@class RTCConfiguration;
|
||||||
@class RTCMediaConstraints;
|
@class RTCMediaConstraints;
|
||||||
@ -29,13 +30,22 @@ RTC_EXPORT
|
|||||||
|
|
||||||
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
/** Initialize an RTCAudioSource with constraints. */
|
||||||
|
- (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)constraints;
|
||||||
|
|
||||||
|
/** Initialize an RTCAudioTrack with an id. Convenience ctor to use an audio source with no
|
||||||
|
* constraints.
|
||||||
|
*/
|
||||||
|
- (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId;
|
||||||
|
|
||||||
|
/** Initialize an RTCAudioTrack with a source and an id. */
|
||||||
|
- (RTCAudioTrack *)audioTrackWithSource:(RTCAudioSource *)source
|
||||||
|
trackId:(NSString *)trackId;
|
||||||
|
|
||||||
/** Initialize an RTCAVFoundationVideoSource with constraints. */
|
/** Initialize an RTCAVFoundationVideoSource with constraints. */
|
||||||
- (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints:
|
- (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints:
|
||||||
(nullable RTCMediaConstraints *)constraints;
|
(nullable RTCMediaConstraints *)constraints;
|
||||||
|
|
||||||
/** Initialize an RTCAudioTrack with an id. */
|
|
||||||
- (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId;
|
|
||||||
|
|
||||||
/** Initialize an RTCVideoTrack with a source and an id. */
|
/** Initialize an RTCVideoTrack with a source and an id. */
|
||||||
- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source
|
- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source
|
||||||
trackId:(NSString *)trackId;
|
trackId:(NSString *)trackId;
|
||||||
|
|||||||
@ -11,21 +11,12 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#import <WebRTC/RTCMacros.h>
|
#import <WebRTC/RTCMacros.h>
|
||||||
|
#import <WebRTC/RTCMediaSource.h>
|
||||||
typedef NS_ENUM(NSInteger, RTCSourceState) {
|
|
||||||
RTCSourceStateInitializing,
|
|
||||||
RTCSourceStateLive,
|
|
||||||
RTCSourceStateEnded,
|
|
||||||
RTCSourceStateMuted,
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
RTC_EXPORT
|
RTC_EXPORT
|
||||||
@interface RTCVideoSource : NSObject
|
@interface RTCVideoSource : RTCMediaSource
|
||||||
|
|
||||||
/** The current state of the RTCVideoSource. */
|
|
||||||
@property(nonatomic, readonly) RTCSourceState state;
|
|
||||||
|
|
||||||
- (instancetype)init NS_UNAVAILABLE;
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import <WebRTC/RTCAVFoundationVideoSource.h>
|
#import <WebRTC/RTCAVFoundationVideoSource.h>
|
||||||
|
#import <WebRTC/RTCAudioSource.h>
|
||||||
#import <WebRTC/RTCAudioTrack.h>
|
#import <WebRTC/RTCAudioTrack.h>
|
||||||
#import <WebRTC/RTCCameraPreviewView.h>
|
#import <WebRTC/RTCCameraPreviewView.h>
|
||||||
#import <WebRTC/RTCConfiguration.h>
|
#import <WebRTC/RTCConfiguration.h>
|
||||||
@ -23,6 +24,7 @@
|
|||||||
#import <WebRTC/RTCLogging.h>
|
#import <WebRTC/RTCLogging.h>
|
||||||
#import <WebRTC/RTCMacros.h>
|
#import <WebRTC/RTCMacros.h>
|
||||||
#import <WebRTC/RTCMediaConstraints.h>
|
#import <WebRTC/RTCMediaConstraints.h>
|
||||||
|
#import <WebRTC/RTCMediaSource.h>
|
||||||
#import <WebRTC/RTCMediaStream.h>
|
#import <WebRTC/RTCMediaStream.h>
|
||||||
#import <WebRTC/RTCMediaStreamTrack.h>
|
#import <WebRTC/RTCMediaStreamTrack.h>
|
||||||
#import <WebRTC/RTCMetrics.h>
|
#import <WebRTC/RTCMetrics.h>
|
||||||
|
|||||||
@ -108,6 +108,8 @@
|
|||||||
'sources': [
|
'sources': [
|
||||||
'objc/Framework/Classes/RTCAVFoundationVideoSource+Private.h',
|
'objc/Framework/Classes/RTCAVFoundationVideoSource+Private.h',
|
||||||
'objc/Framework/Classes/RTCAVFoundationVideoSource.mm',
|
'objc/Framework/Classes/RTCAVFoundationVideoSource.mm',
|
||||||
|
'objc/Framework/Classes/RTCAudioSource+Private.h',
|
||||||
|
'objc/Framework/Classes/RTCAudioSource.mm',
|
||||||
'objc/Framework/Classes/RTCAudioTrack+Private.h',
|
'objc/Framework/Classes/RTCAudioTrack+Private.h',
|
||||||
'objc/Framework/Classes/RTCAudioTrack.mm',
|
'objc/Framework/Classes/RTCAudioTrack.mm',
|
||||||
'objc/Framework/Classes/RTCConfiguration+Private.h',
|
'objc/Framework/Classes/RTCConfiguration+Private.h',
|
||||||
@ -123,6 +125,8 @@
|
|||||||
'objc/Framework/Classes/RTCIceServer.mm',
|
'objc/Framework/Classes/RTCIceServer.mm',
|
||||||
'objc/Framework/Classes/RTCMediaConstraints+Private.h',
|
'objc/Framework/Classes/RTCMediaConstraints+Private.h',
|
||||||
'objc/Framework/Classes/RTCMediaConstraints.mm',
|
'objc/Framework/Classes/RTCMediaConstraints.mm',
|
||||||
|
'objc/Framework/Classes/RTCMediaSource+Private.h',
|
||||||
|
'objc/Framework/Classes/RTCMediaSource.mm',
|
||||||
'objc/Framework/Classes/RTCMediaStream+Private.h',
|
'objc/Framework/Classes/RTCMediaStream+Private.h',
|
||||||
'objc/Framework/Classes/RTCMediaStream.mm',
|
'objc/Framework/Classes/RTCMediaStream.mm',
|
||||||
'objc/Framework/Classes/RTCMediaStreamTrack+Private.h',
|
'objc/Framework/Classes/RTCMediaStreamTrack+Private.h',
|
||||||
@ -165,6 +169,7 @@
|
|||||||
'objc/Framework/Classes/avfoundationvideocapturer.h',
|
'objc/Framework/Classes/avfoundationvideocapturer.h',
|
||||||
'objc/Framework/Classes/avfoundationvideocapturer.mm',
|
'objc/Framework/Classes/avfoundationvideocapturer.mm',
|
||||||
'objc/Framework/Headers/WebRTC/RTCAVFoundationVideoSource.h',
|
'objc/Framework/Headers/WebRTC/RTCAVFoundationVideoSource.h',
|
||||||
|
'objc/Framework/Headers/WebRTC/RTCAudioSource.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCAudioTrack.h',
|
'objc/Framework/Headers/WebRTC/RTCAudioTrack.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCConfiguration.h',
|
'objc/Framework/Headers/WebRTC/RTCConfiguration.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCDataChannel.h',
|
'objc/Framework/Headers/WebRTC/RTCDataChannel.h',
|
||||||
@ -172,6 +177,7 @@
|
|||||||
'objc/Framework/Headers/WebRTC/RTCIceCandidate.h',
|
'objc/Framework/Headers/WebRTC/RTCIceCandidate.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCIceServer.h',
|
'objc/Framework/Headers/WebRTC/RTCIceServer.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCMediaConstraints.h',
|
'objc/Framework/Headers/WebRTC/RTCMediaConstraints.h',
|
||||||
|
'objc/Framework/Headers/WebRTC/RTCMediaSource.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCMediaStream.h',
|
'objc/Framework/Headers/WebRTC/RTCMediaStream.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCMediaStreamTrack.h',
|
'objc/Framework/Headers/WebRTC/RTCMediaStreamTrack.h',
|
||||||
'objc/Framework/Headers/WebRTC/RTCPeerConnection.h',
|
'objc/Framework/Headers/WebRTC/RTCPeerConnection.h',
|
||||||
|
|||||||
Reference in New Issue
Block a user