Delete talk directory, and references from build_ios_libs.sh.

BUG=webrtc:4256

Review-Url: https://codereview.webrtc.org/2296613002
Cr-Commit-Position: refs/heads/master@{#14040}
This commit is contained in:
nisse 2016-09-02 03:07:06 -07:00 committed by Commit bot
parent f383c5754f
commit 3d21e23df2
110 changed files with 81 additions and 8597 deletions

View File

@ -1 +0,0 @@
Refer to talk/COPYING.

View File

@ -1 +1 @@
Refer to webrtc/LICENSE_THIRD_PARTY and talk/LICENSE_THIRD_PARTY.
Refer to webrtc/LICENSE_THIRD_PARTY.

View File

@ -63,7 +63,6 @@ NATIVE_API_DIRS = (
# These directories should not be used but are maintained only to avoid breaking
# some legacy downstream code.
LEGACY_API_DIRS = (
'talk/app/webrtc',
'webrtc/base',
'webrtc/common_audio/include',
'webrtc/modules/audio_coding/include',
@ -459,6 +458,7 @@ def _CommonChecks(input_api, output_api):
],
pylintrc='pylintrc'))
# TODO(nisse): talk/ is no more, so make below checks simpler?
# WebRTC can't use the presubmit_canned_checks.PanProjectChecks function since
# we need to have different license checks in talk/ and webrtc/ directories.
# Instead, hand-picked checks are included below.

12
all.gyp
View File

@ -63,18 +63,6 @@
'webrtc/sdk/sdk.gyp:*',
],
}],
['OS=="ios" or (OS=="mac" and target_arch!="ia32")', {
'dependencies': [
'talk/app/webrtc/legacy_objc_api.gyp:*',
],
'conditions': [
['include_tests==1', {
'dependencies': [
'talk/app/webrtc/legacy_objc_api_tests.gyp:*',
],
}],
],
}],
],
},
],

View File

@ -1,25 +0,0 @@
Copyright (c) 2013, Google Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

View File

@ -1,27 +0,0 @@
This source tree contains third party source code which is governed by third
party licenses. This file contains references to files which are under other
licenses than the one provided in the COPYING file in the root of the source
tree.
Files governed by third party licenses:
Governed by license within files (Public domain):
Exact origin unknown
base/base64.c
base/base64.h
Governed by http://www.fourmilab.ch/md5/ (Public domain):
base/md5.c
base/md5.h
Governed by license within files (Public domain):
Originally downloaded from http://svn.ghostscript.com/jbig2dec/tags/release_0_02/sha1.*
base/sha1.c
base/sha1.h
Governed by http://sigslot.sourceforge.net/#license (Public domain):
base/sigslot.cc
base/sigslot.h
Governed by http://www.freedesktop.org/wiki/Software/systemd (LGPL 2.1+):
third_party/libudev/libudev.h

View File

@ -1,13 +0,0 @@
hta@webrtc.org
jiayl@webrtc.org
juberti@webrtc.org
perkj@webrtc.org
pthatcher@webrtc.org
sergeyu@chromium.org
tommi@webrtc.org
per-file *.isolate=kjellander@webrtc.org
# These are for the common case of adding or renaming files. If you're doing
# structural changes, please get a review from a reviewer in this file.
per-file *.gyp=*
per-file *.gypi=*

View File

@ -1,94 +0,0 @@
# libjingle
# Copyright 2013 Google Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
def _LicenseHeader(input_api):
"""Returns the license header regexp."""
# Accept any year number from start of project to the current year
current_year = int(input_api.time.strftime('%Y'))
allowed_years = (str(s) for s in reversed(xrange(2004, current_year + 1)))
years_re = '(' + '|'.join(allowed_years) + ')'
years_re = '%s(--%s)?' % (years_re, years_re)
license_header = (
r'.*? libjingle\n'
r'.*? Copyright %(year)s Google Inc\..*\n'
r'.*?\n'
r'.*? Redistribution and use in source and binary forms, with or without'
r'\n'
r'.*? modification, are permitted provided that the following conditions '
r'are met:\n'
r'.*?\n'
r'.*? 1\. Redistributions of source code must retain the above copyright '
r'notice,\n'
r'.*? this list of conditions and the following disclaimer\.\n'
r'.*? 2\. Redistributions in binary form must reproduce the above '
r'copyright notice,\n'
r'.*? this list of conditions and the following disclaimer in the '
r'documentation\n'
r'.*? and/or other materials provided with the distribution\.\n'
r'.*? 3\. The name of the author may not be used to endorse or promote '
r'products\n'
r'.*? derived from this software without specific prior written '
r'permission\.\n'
r'.*?\n'
r'.*? THIS SOFTWARE IS PROVIDED BY THE AUTHOR \`\`AS IS\'\' AND ANY '
r'EXPRESS OR IMPLIED\n'
r'.*? WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES '
r'OF\n'
r'.*? MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE '
r'DISCLAIMED\. IN NO\n'
r'.*? EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, '
r'INCIDENTAL,\n'
r'.*? SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \(INCLUDING, '
r'BUT NOT LIMITED TO,\n'
r'.*? PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR '
r'PROFITS;\n'
r'.*? OR BUSINESS INTERRUPTION\) HOWEVER CAUSED AND ON ANY THEORY OF '
r'LIABILITY,\n'
r'.*? WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \(INCLUDING '
r'NEGLIGENCE OR\n'
r'.*? OTHERWISE\) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, '
r'EVEN IF\n'
r'.*? ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\.\n'
) % {
'year': years_re,
}
return license_header
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
results = []
results.extend(input_api.canned_checks.CheckLicense(
input_api, output_api, _LicenseHeader(input_api)))
return results
def CheckChangeOnUpload(input_api, output_api):
results = []
results.extend(_CommonChecks(input_api, output_api))
return results
def CheckChangeOnCommit(input_api, output_api):
results = []
results.extend(_CommonChecks(input_api, output_api))
return results

View File

@ -1,7 +0,0 @@
include_rules = [
"+talk/app/webrtc/objc",
"+webrtc/video_frame.h",
"+webrtc/api",
"+webrtc/base",
"+webrtc/media",
]

View File

@ -1,193 +0,0 @@
#
# libjingle
# Copyright 2012 Google Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{
'includes': ['../../build/common.gypi'],
'conditions': [
['OS=="ios" or (OS=="mac" and target_arch!="ia32")', {
# The >= 10.7 above is required for ARC.
'targets': [
{
'target_name': 'libjingle_peerconnection_objc',
'type': 'static_library',
'dependencies': [
'<(webrtc_root)/api/api.gyp:libjingle_peerconnection',
],
'sources': [
'objc/RTCAudioTrack+Internal.h',
'objc/RTCAudioTrack.mm',
'objc/RTCDataChannel+Internal.h',
'objc/RTCDataChannel.mm',
'objc/RTCEnumConverter.h',
'objc/RTCEnumConverter.mm',
'objc/RTCI420Frame+Internal.h',
'objc/RTCI420Frame.mm',
'objc/RTCICECandidate+Internal.h',
'objc/RTCICECandidate.mm',
'objc/RTCICEServer+Internal.h',
'objc/RTCICEServer.mm',
'objc/RTCLogging.mm',
'objc/RTCMediaConstraints+Internal.h',
'objc/RTCMediaConstraints.mm',
'objc/RTCMediaConstraintsNative.cc',
'objc/RTCMediaConstraintsNative.h',
'objc/RTCMediaSource+Internal.h',
'objc/RTCMediaSource.mm',
'objc/RTCMediaStream+Internal.h',
'objc/RTCMediaStream.mm',
'objc/RTCMediaStreamTrack+Internal.h',
'objc/RTCMediaStreamTrack.mm',
'objc/RTCOpenGLVideoRenderer.mm',
'objc/RTCPair.m',
'objc/RTCPeerConnection+Internal.h',
'objc/RTCPeerConnection.mm',
'objc/RTCPeerConnectionFactory.mm',
'objc/RTCPeerConnectionInterface+Internal.h',
'objc/RTCPeerConnectionInterface.mm',
'objc/RTCPeerConnectionObserver.h',
'objc/RTCPeerConnectionObserver.mm',
'objc/RTCSessionDescription+Internal.h',
'objc/RTCSessionDescription.mm',
'objc/RTCStatsReport+Internal.h',
'objc/RTCStatsReport.mm',
'objc/RTCVideoCapturer+Internal.h',
'objc/RTCVideoCapturer.mm',
'objc/RTCVideoRendererAdapter.h',
'objc/RTCVideoRendererAdapter.mm',
'objc/RTCVideoSource+Internal.h',
'objc/RTCVideoSource.mm',
'objc/RTCVideoTrack+Internal.h',
'objc/RTCVideoTrack.mm',
'objc/public/RTCAudioSource.h',
'objc/public/RTCAudioTrack.h',
'objc/public/RTCDataChannel.h',
'objc/public/RTCFileLogger.h',
'objc/public/RTCI420Frame.h',
'objc/public/RTCICECandidate.h',
'objc/public/RTCICEServer.h',
'objc/public/RTCLogging.h',
'objc/public/RTCMediaConstraints.h',
'objc/public/RTCMediaSource.h',
'objc/public/RTCMediaStream.h',
'objc/public/RTCMediaStreamTrack.h',
'objc/public/RTCOpenGLVideoRenderer.h',
'objc/public/RTCPair.h',
'objc/public/RTCPeerConnection.h',
'objc/public/RTCPeerConnectionDelegate.h',
'objc/public/RTCPeerConnectionFactory.h',
'objc/public/RTCPeerConnectionInterface.h',
'objc/public/RTCSessionDescription.h',
'objc/public/RTCSessionDescriptionDelegate.h',
'objc/public/RTCStatsDelegate.h',
'objc/public/RTCStatsReport.h',
'objc/public/RTCTypes.h',
'objc/public/RTCVideoCapturer.h',
'objc/public/RTCVideoRenderer.h',
'objc/public/RTCVideoSource.h',
'objc/public/RTCVideoTrack.h',
],
'direct_dependent_settings': {
'include_dirs': [
'<(DEPTH)/talk/app/webrtc/objc/public',
],
},
'include_dirs': [
'<(webrtc_root)/webrtc/api',
'<(DEPTH)/talk/app/webrtc/objc',
'<(DEPTH)/talk/app/webrtc/objc/public',
],
'link_settings': {
'libraries': [
'-lstdc++',
],
},
'all_dependent_settings': {
'xcode_settings': {
'CLANG_ENABLE_OBJC_ARC': 'YES',
},
},
'xcode_settings': {
'CLANG_ENABLE_OBJC_ARC': 'YES',
# common.gypi enables this for mac but we want this to be disabled
# like it is for ios.
'CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS': 'NO',
# Disabled due to failing when compiled with -Wall, see
# https://bugs.chromium.org/p/webrtc/issues/detail?id=5397
'WARNING_CFLAGS': ['-Wno-unused-property-ivar'],
},
'conditions': [
['OS=="ios"', {
'sources': [
'objc/avfoundationvideocapturer.h',
'objc/avfoundationvideocapturer.mm',
'objc/RTCAVFoundationVideoSource+Internal.h',
'objc/RTCAVFoundationVideoSource.mm',
'objc/RTCEAGLVideoView.m',
'objc/public/RTCEAGLVideoView.h',
'objc/public/RTCAVFoundationVideoSource.h',
],
'dependencies': [
'<(webrtc_root)/sdk/sdk.gyp:rtc_sdk_common_objc',
],
'link_settings': {
'xcode_settings': {
'OTHER_LDFLAGS': [
'-framework CoreGraphics',
'-framework GLKit',
'-framework OpenGLES',
'-framework QuartzCore',
],
},
},
}],
['OS=="mac"', {
'sources': [
'objc/RTCNSGLVideoView.m',
'objc/public/RTCNSGLVideoView.h',
],
'xcode_settings': {
# Need to build against 10.7 framework for full ARC support
# on OSX.
'MACOSX_DEPLOYMENT_TARGET' : '10.7',
# RTCVideoTrack.mm uses code with partial availability.
# https://code.google.com/p/webrtc/issues/detail?id=4695
'WARNING_CFLAGS!': ['-Wpartial-availability'],
},
'link_settings': {
'xcode_settings': {
'OTHER_LDFLAGS': [
'-framework Cocoa',
'-framework OpenGL',
],
},
},
}],
],
}, # target libjingle_peerconnection_objc
],
}],
],
}

View File

@ -1,94 +0,0 @@
#
# libjingle
# Copyright 2012 Google Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{
'includes': ['../../build/common.gypi'],
'conditions': [
['OS=="ios" or (OS=="mac" and target_arch!="ia32")', {
# The >=10.7 above is required to make ARC link cleanly (e.g. as
# opposed to _compile_ cleanly, which the library under test
# does just fine on 10.6 too).
'targets': [
{
'target_name': 'libjingle_peerconnection_objc_test',
'type': 'executable',
'includes': [ '../../../webrtc/build/ios/objc_app.gypi' ],
'dependencies': [
'<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:field_trial_default',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:metrics_default',
'legacy_objc_api.gyp:libjingle_peerconnection_objc',
],
'sources': [
'objctests/RTCPeerConnectionSyncObserver.h',
'objctests/RTCPeerConnectionSyncObserver.m',
'objctests/RTCPeerConnectionTest.mm',
'objctests/RTCSessionDescriptionSyncObserver.h',
'objctests/RTCSessionDescriptionSyncObserver.m',
# TODO(fischman): figure out if this works for ios or if it
# needs a GUI driver.
'objctests/mac/main.mm',
],
'conditions': [
['OS=="mac"', {
'xcode_settings': {
# Need to build against 10.7 framework for full ARC support
# on OSX.
'MACOSX_DEPLOYMENT_TARGET' : '10.7',
# common.gypi enables this for mac but we want this to be
# disabled like it is for ios.
'CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS': 'NO',
},
}],
],
}, # target libjingle_peerconnection_objc_test
{
'target_name': 'apprtc_signaling_gunit_test',
'type': 'executable',
'includes': [ '../../../webrtc/build/ios/objc_app.gypi' ],
'dependencies': [
'<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:field_trial_default',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:metrics_default',
'<(webrtc_root)/webrtc_examples.gyp:apprtc_signaling',
'<(DEPTH)/third_party/ocmock/ocmock.gyp:ocmock',
],
'sources': [
'objctests/mac/main.mm',
'<(webrtc_root)/examples/objc/AppRTCDemo/tests/ARDAppClientTest.mm',
],
'conditions': [
['OS=="mac"', {
'xcode_settings': {
'MACOSX_DEPLOYMENT_TARGET' : '10.8',
},
}],
],
}, # target apprtc_signaling_gunit_test
],
}],
],
}

View File

@ -1,10 +0,0 @@
BasedOnStyle: Chromium
ColumnLimit: 100
BinPackParameters: false
AllowAllParametersOfDeclarationOnNextLine: true
DerivePointerAlignment: false
PointerAlignment: Right
SpacesBeforeTrailingComments: 1
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true

View File

@ -1 +0,0 @@
tkchin@webrtc.org

View File

@ -1,68 +0,0 @@
This directory contains the ObjectiveC implementation of the
webrtc::PeerConnection API. This can be built for Mac or iOS. This
file describes building the API, unit test, and AppRTCDemo sample app.
Prerequisites:
- Make sure gclient is checking out tools necessary to target iOS: your
.gclient file should contain a line like:
target_os = ['ios', 'mac']
Make sure to re-run gclient sync after adding this to download the tools.
- Set up webrtc-related $GYP_DEFINES; example shell functions that set
up for building for iOS-device, iOS-simulator, and Mac (resp) are:
function wrbase() {
cd /path/to/webrtc/src
}
function wrios() {
wrbase
export GYP_DEFINES="$GYP_DEFINES OS=ios"
export GYP_GENERATOR_FLAGS="$GYP_GENERATOR_FLAGS output_dir=out_ios"
export GYP_CROSSCOMPILE=1
}
function wrios32() {
wrios
export GYP_DEFINES="$GYP_DEFINES target_arch=arm"
}
function wrios64() {
wrios
export GYP_DEFINES="$GYP_DEFINES target_arch=arm64"
}
function wrsim() {
wrbase
export GYP_DEFINES="$GYP_DEFINES OS=ios target_subarch=arm32 target_arch=ia32"
export GYP_GENERATOR_FLAGS="$GYP_GENERATOR_FLAGS output_dir=out_sim"
export GYP_CROSSCOMPILE=1
}
function wrmac() {
wrbase
export GYP_DEFINES="$GYP_DEFINES OS=mac target_subarch=arm64 target_arch=x64"
export GYP_GENERATOR_FLAGS="$GYP_GENERATOR_FLAGS output_dir=out_mac"
}
- Finally, run "webrtc/build/gyp_webrtc.py" to generate ninja files.
Example of building & using the unittest & app:
- To build & run the unittest (must target mac):
wrmac && ./webrtc/build/gyp_webrtc.py && \
ninja -C out_mac/Debug libjingle_peerconnection_objc_test && \
./out_mac/Debug/libjingle_peerconnection_objc_test.app/Contents/MacOS/libjingle_peerconnection_objc_test
- To build & launch the sample app on OSX:
wrmac && ./webrtc/build/gyp_webrtc.py && ninja -C out_mac/Debug AppRTCDemo && \
./out_mac/Debug/AppRTCDemo.app/Contents/MacOS/AppRTCDemo
- To build & launch the sample app on the iOS simulator:
wrsim && ./webrtc/build/gyp_webrtc.py && ninja -C out_sim/Debug iossim AppRTCDemo && \
./out_sim/Debug/iossim out_sim/Debug/AppRTCDemo.app
- To build & sign the sample app for an iOS device (32 bit):
wrios32 && ./webrtc/build/gyp_webrtc.py && ninja -C out_ios/Debug-iphoneos AppRTCDemo
- To build & sign the sample app for an iOS device (64 bit):
wrios64 && ./webrtc/build/gyp_webrtc.py && ninja -C out_ios/Debug-iphoneos AppRTCDemo

View File

@ -1,36 +0,0 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCAVFoundationVideoSource.h"
#include "avfoundationvideocapturer.h"
@interface RTCAVFoundationVideoSource ()
@property(nonatomic, readonly) webrtc::AVFoundationVideoCapturer* capturer;
@end

View File

@ -1,74 +0,0 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCAVFoundationVideoSource+Internal.h"
#import "RTCMediaConstraints+Internal.h"
#import "RTCMediaSource+Internal.h"
#import "RTCPeerConnectionFactory+Internal.h"
#import "RTCVideoSource+Internal.h"
#include <memory>
@implementation RTCAVFoundationVideoSource {
webrtc::AVFoundationVideoCapturer *_capturer;
}
- (instancetype)initWithFactory:(RTCPeerConnectionFactory*)factory
constraints:(RTCMediaConstraints*)constraints {
NSParameterAssert(factory);
// We pass ownership of the capturer to the source, but since we own
// the source, it should be ok to keep a raw pointer to the
// capturer.
_capturer = new webrtc::AVFoundationVideoCapturer();
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source =
factory.nativeFactory->CreateVideoSource(_capturer,
constraints.constraints);
return [super initWithMediaSource:source];
}
- (BOOL)canUseBackCamera {
return self.capturer->CanUseBackCamera();
}
- (BOOL)useBackCamera {
return self.capturer->GetUseBackCamera();
}
- (void)setUseBackCamera:(BOOL)useBackCamera {
self.capturer->SetUseBackCamera(useBackCamera);
}
- (AVCaptureSession*)captureSession {
return self.capturer->GetCaptureSession();
}
- (webrtc::AVFoundationVideoCapturer*)capturer {
return _capturer;
}
@end

View File

@ -1,37 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCAudioTrack.h"
#include "webrtc/api/mediastreaminterface.h"
@interface RTCAudioTrack (Internal)
@property(nonatomic, assign, readonly)
rtc::scoped_refptr<webrtc::AudioTrackInterface> audioTrack;
@end

View File

@ -1,45 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCAudioTrack+Internal.h"
#import "RTCMediaStreamTrack+Internal.h"
@implementation RTCAudioTrack
@end
@implementation RTCAudioTrack (Internal)
- (rtc::scoped_refptr<webrtc::AudioTrackInterface>)audioTrack {
return static_cast<webrtc::AudioTrackInterface*>(self.mediaTrack.get());
}
@end

View File

@ -1,55 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCDataChannel.h"
#include "webrtc/api/datachannelinterface.h"
#include "webrtc/base/scoped_ref_ptr.h"
@interface RTCDataBuffer (Internal)
@property(nonatomic, readonly) const webrtc::DataBuffer* dataBuffer;
- (instancetype)initWithDataBuffer:(const webrtc::DataBuffer&)buffer;
@end
@interface RTCDataChannelInit (Internal)
@property(nonatomic, readonly) const webrtc::DataChannelInit* dataChannelInit;
@end
@interface RTCDataChannel (Internal)
@property(nonatomic, readonly)
rtc::scoped_refptr<webrtc::DataChannelInterface> dataChannel;
- (instancetype)initWithDataChannel:
(rtc::scoped_refptr<webrtc::DataChannelInterface>)dataChannel;
@end

View File

@ -1,292 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCDataChannel+Internal.h"
#include <memory>
#include "webrtc/api/datachannelinterface.h"
namespace webrtc {
class RTCDataChannelObserver : public DataChannelObserver {
public:
RTCDataChannelObserver(RTCDataChannel* channel) { _channel = channel; }
void OnStateChange() override {
[_channel.delegate channelDidChangeState:_channel];
}
void OnBufferedAmountChange(uint64_t previousAmount) override {
RTCDataChannel* channel = _channel;
id<RTCDataChannelDelegate> delegate = channel.delegate;
if ([delegate
respondsToSelector:@selector(channel:didChangeBufferedAmount:)]) {
[delegate channel:channel didChangeBufferedAmount:previousAmount];
}
}
void OnMessage(const DataBuffer& buffer) override {
if (!_channel.delegate) {
return;
}
RTCDataBuffer* dataBuffer =
[[RTCDataBuffer alloc] initWithDataBuffer:buffer];
[_channel.delegate channel:_channel didReceiveMessageWithBuffer:dataBuffer];
}
private:
__weak RTCDataChannel* _channel;
};
}
// TODO(henrika): move to shared location.
// See https://code.google.com/p/webrtc/issues/detail?id=4773 for details.
NSString* NSStringFromStdString(const std::string& stdString) {
// std::string may contain null termination character so we construct
// using length.
return [[NSString alloc] initWithBytes:stdString.data()
length:stdString.length()
encoding:NSUTF8StringEncoding];
}
std::string StdStringFromNSString(NSString* nsString) {
NSData* charData = [nsString dataUsingEncoding:NSUTF8StringEncoding];
return std::string(reinterpret_cast<const char*>([charData bytes]),
[charData length]);
}
@implementation RTCDataChannelInit {
webrtc::DataChannelInit _dataChannelInit;
}
- (BOOL)isOrdered {
return _dataChannelInit.ordered;
}
- (void)setIsOrdered:(BOOL)isOrdered {
_dataChannelInit.ordered = isOrdered;
}
- (NSInteger)maxRetransmitTime {
return _dataChannelInit.maxRetransmitTime;
}
- (void)setMaxRetransmitTime:(NSInteger)maxRetransmitTime {
_dataChannelInit.maxRetransmitTime = maxRetransmitTime;
}
- (NSInteger)maxRetransmits {
return _dataChannelInit.maxRetransmits;
}
- (void)setMaxRetransmits:(NSInteger)maxRetransmits {
_dataChannelInit.maxRetransmits = maxRetransmits;
}
- (NSString*)protocol {
return NSStringFromStdString(_dataChannelInit.protocol);
}
- (void)setProtocol:(NSString*)protocol {
_dataChannelInit.protocol = StdStringFromNSString(protocol);
}
- (BOOL)isNegotiated {
return _dataChannelInit.negotiated;
}
- (void)setIsNegotiated:(BOOL)isNegotiated {
_dataChannelInit.negotiated = isNegotiated;
}
- (NSInteger)streamId {
return _dataChannelInit.id;
}
- (void)setStreamId:(NSInteger)streamId {
_dataChannelInit.id = streamId;
}
@end
@implementation RTCDataChannelInit (Internal)
- (const webrtc::DataChannelInit*)dataChannelInit {
return &_dataChannelInit;
}
@end
@implementation RTCDataBuffer {
std::unique_ptr<webrtc::DataBuffer> _dataBuffer;
}
- (instancetype)initWithData:(NSData*)data isBinary:(BOOL)isBinary {
NSAssert(data, @"data cannot be nil");
if (self = [super init]) {
rtc::CopyOnWriteBuffer buffer(
reinterpret_cast<const uint8_t*>([data bytes]), [data length]);
_dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary));
}
return self;
}
- (NSData*)data {
return [NSData dataWithBytes:_dataBuffer->data.data()
length:_dataBuffer->data.size()];
}
- (BOOL)isBinary {
return _dataBuffer->binary;
}
@end
@implementation RTCDataBuffer (Internal)
- (instancetype)initWithDataBuffer:(const webrtc::DataBuffer&)buffer {
if (self = [super init]) {
_dataBuffer.reset(new webrtc::DataBuffer(buffer));
}
return self;
}
- (const webrtc::DataBuffer*)dataBuffer {
return _dataBuffer.get();
}
@end
@implementation RTCDataChannel {
rtc::scoped_refptr<webrtc::DataChannelInterface> _dataChannel;
std::unique_ptr<webrtc::RTCDataChannelObserver> _observer;
BOOL _isObserverRegistered;
}
- (void)dealloc {
// Handles unregistering the observer properly. We need to do this because
// there may still be other references to the underlying data channel.
self.delegate = nil;
}
- (NSString*)label {
return NSStringFromStdString(_dataChannel->label());
}
- (BOOL)isReliable {
return _dataChannel->reliable();
}
- (BOOL)isOrdered {
return _dataChannel->ordered();
}
- (NSUInteger)maxRetransmitTimeMs {
return _dataChannel->maxRetransmitTime();
}
- (NSUInteger)maxRetransmits {
return _dataChannel->maxRetransmits();
}
- (NSString*)protocol {
return NSStringFromStdString(_dataChannel->protocol());
}
- (BOOL)isNegotiated {
return _dataChannel->negotiated();
}
- (NSInteger)streamId {
return _dataChannel->id();
}
- (RTCDataChannelState)state {
switch (_dataChannel->state()) {
case webrtc::DataChannelInterface::DataState::kConnecting:
return kRTCDataChannelStateConnecting;
case webrtc::DataChannelInterface::DataState::kOpen:
return kRTCDataChannelStateOpen;
case webrtc::DataChannelInterface::DataState::kClosing:
return kRTCDataChannelStateClosing;
case webrtc::DataChannelInterface::DataState::kClosed:
return kRTCDataChannelStateClosed;
}
}
- (NSUInteger)bufferedAmount {
return _dataChannel->buffered_amount();
}
- (void)setDelegate:(id<RTCDataChannelDelegate>)delegate {
if (_delegate == delegate) {
return;
}
if (_isObserverRegistered) {
_dataChannel->UnregisterObserver();
_isObserverRegistered = NO;
}
_delegate = delegate;
if (_delegate) {
_dataChannel->RegisterObserver(_observer.get());
_isObserverRegistered = YES;
}
}
- (void)close {
_dataChannel->Close();
}
- (BOOL)sendData:(RTCDataBuffer*)data {
return _dataChannel->Send(*data.dataBuffer);
}
@end
@implementation RTCDataChannel (Internal)
- (instancetype)initWithDataChannel:
(rtc::scoped_refptr<webrtc::DataChannelInterface>)
dataChannel {
NSAssert(dataChannel != NULL, @"dataChannel cannot be NULL");
if (self = [super init]) {
_dataChannel = dataChannel;
_observer.reset(new webrtc::RTCDataChannelObserver(self));
}
return self;
}
- (rtc::scoped_refptr<webrtc::DataChannelInterface>)dataChannel {
return _dataChannel;
}
@end

View File

@ -1,277 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCEAGLVideoView.h"
#import <GLKit/GLKit.h>
#import "RTCI420Frame.h"
#import "RTCOpenGLVideoRenderer.h"
// RTCDisplayLinkTimer wraps a CADisplayLink and is set to fire every two screen
// refreshes, which should be 30fps. We wrap the display link in order to avoid
// a retain cycle since CADisplayLink takes a strong reference onto its target.
// The timer is paused by default.
@interface RTCDisplayLinkTimer : NSObject
@property(nonatomic) BOOL isPaused;
- (instancetype)initWithTimerHandler:(void (^)(void))timerHandler;
- (void)invalidate;
@end
@implementation RTCDisplayLinkTimer {
CADisplayLink* _displayLink;
void (^_timerHandler)(void);
}
- (instancetype)initWithTimerHandler:(void (^)(void))timerHandler {
NSParameterAssert(timerHandler);
if (self = [super init]) {
_timerHandler = timerHandler;
_displayLink =
[CADisplayLink displayLinkWithTarget:self
selector:@selector(displayLinkDidFire:)];
_displayLink.paused = YES;
// Set to half of screen refresh, which should be 30fps.
[_displayLink setFrameInterval:2];
[_displayLink addToRunLoop:[NSRunLoop currentRunLoop]
forMode:NSRunLoopCommonModes];
}
return self;
}
- (void)dealloc {
[self invalidate];
}
- (BOOL)isPaused {
return _displayLink.paused;
}
- (void)setIsPaused:(BOOL)isPaused {
_displayLink.paused = isPaused;
}
- (void)invalidate {
[_displayLink invalidate];
}
- (void)displayLinkDidFire:(CADisplayLink*)displayLink {
_timerHandler();
}
@end
// RTCEAGLVideoView wraps a GLKView which is setup with
// enableSetNeedsDisplay = NO for the purpose of gaining control of
// exactly when to call -[GLKView display]. This need for extra
// control is required to avoid triggering method calls on GLKView
// that results in attempting to bind the underlying render buffer
// when the drawable size would be empty which would result in the
// error GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT. -[GLKView display] is
// the method that will trigger the binding of the render
// buffer. Because the standard behaviour of -[UIView setNeedsDisplay]
// is disabled for the reasons above, the RTCEAGLVideoView maintains
// its own |isDirty| flag.
@interface RTCEAGLVideoView () <GLKViewDelegate>
// |i420Frame| is set when we receive a frame from a worker thread and is read
// from the display link callback so atomicity is required.
@property(atomic, strong) RTCI420Frame* i420Frame;
@property(nonatomic, readonly) GLKView* glkView;
@property(nonatomic, readonly) RTCOpenGLVideoRenderer* glRenderer;
@end
@implementation RTCEAGLVideoView {
RTCDisplayLinkTimer* _timer;
GLKView* _glkView;
RTCOpenGLVideoRenderer* _glRenderer;
// This flag should only be set and read on the main thread (e.g. by
// setNeedsDisplay)
BOOL _isDirty;
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self configure];
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
if (self = [super initWithCoder:aDecoder]) {
[self configure];
}
return self;
}
- (void)configure {
EAGLContext* glContext =
[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
if (!glContext) {
glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
}
_glRenderer = [[RTCOpenGLVideoRenderer alloc] initWithContext:glContext];
// GLKView manages a framebuffer for us.
_glkView = [[GLKView alloc] initWithFrame:CGRectZero
context:glContext];
_glkView.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
_glkView.drawableDepthFormat = GLKViewDrawableDepthFormatNone;
_glkView.drawableStencilFormat = GLKViewDrawableStencilFormatNone;
_glkView.drawableMultisample = GLKViewDrawableMultisampleNone;
_glkView.delegate = self;
_glkView.layer.masksToBounds = YES;
_glkView.enableSetNeedsDisplay = NO;
[self addSubview:_glkView];
// Listen to application state in order to clean up OpenGL before app goes
// away.
NSNotificationCenter* notificationCenter =
[NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
selector:@selector(willResignActive)
name:UIApplicationWillResignActiveNotification
object:nil];
[notificationCenter addObserver:self
selector:@selector(didBecomeActive)
name:UIApplicationDidBecomeActiveNotification
object:nil];
// Frames are received on a separate thread, so we poll for current frame
// using a refresh rate proportional to screen refresh frequency. This
// occurs on the main thread.
__weak RTCEAGLVideoView* weakSelf = self;
_timer = [[RTCDisplayLinkTimer alloc] initWithTimerHandler:^{
RTCEAGLVideoView* strongSelf = weakSelf;
[strongSelf displayLinkTimerDidFire];
}];
[self setupGL];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
UIApplicationState appState =
[UIApplication sharedApplication].applicationState;
if (appState == UIApplicationStateActive) {
[self teardownGL];
}
[_timer invalidate];
}
#pragma mark - UIView
- (void)setNeedsDisplay {
[super setNeedsDisplay];
_isDirty = YES;
}
- (void)setNeedsDisplayInRect:(CGRect)rect {
[super setNeedsDisplayInRect:rect];
_isDirty = YES;
}
- (void)layoutSubviews {
[super layoutSubviews];
_glkView.frame = self.bounds;
}
#pragma mark - GLKViewDelegate
// This method is called when the GLKView's content is dirty and needs to be
// redrawn. This occurs on main thread.
- (void)glkView:(GLKView*)view drawInRect:(CGRect)rect {
// The renderer will draw the frame to the framebuffer corresponding to the
// one used by |view|.
[_glRenderer drawFrame:self.i420Frame];
}
#pragma mark - RTCVideoRenderer
// These methods may be called on non-main thread.
- (void)setSize:(CGSize)size {
__weak RTCEAGLVideoView* weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
RTCEAGLVideoView* strongSelf = weakSelf;
[strongSelf.delegate videoView:strongSelf didChangeVideoSize:size];
});
}
- (void)renderFrame:(RTCI420Frame*)frame {
self.i420Frame = frame;
}
#pragma mark - Private
- (void)displayLinkTimerDidFire {
// Don't render unless video frame have changed or the view content
// has explicitly been marked dirty.
if (!_isDirty && _glRenderer.lastDrawnFrame == self.i420Frame) {
return;
}
// Always reset isDirty at this point, even if -[GLKView display]
// won't be called in the case the drawable size is empty.
_isDirty = NO;
// Only call -[GLKView display] if the drawable size is
// non-empty. Calling display will make the GLKView setup its
// render buffer if necessary, but that will fail with error
// GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT if size is empty.
if (self.bounds.size.width > 0 && self.bounds.size.height > 0) {
[_glkView display];
}
}
- (void)setupGL {
self.i420Frame = nil;
[_glRenderer setupGL];
_timer.isPaused = NO;
}
- (void)teardownGL {
self.i420Frame = nil;
_timer.isPaused = YES;
[_glkView deleteDrawable];
[_glRenderer teardownGL];
}
- (void)didBecomeActive {
[self setupGL];
}
- (void)willResignActive {
[self teardownGL];
}
@end

View File

@ -1,83 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// TODO(tkchin): remove this in favor of having objc headers mirror their C++ counterparts.
// TODO(tkchin): see if we can move C++ enums into their own file so we can avoid all this
// conversion code.
#import "RTCTypes.h"
#import "talk/app/webrtc/objc/RTCPeerConnectionInterface+Internal.h"
@interface RTCEnumConverter : NSObject
// TODO(tkchin): rename these.
+ (RTCICEConnectionState)convertIceConnectionStateToObjC:
(webrtc::PeerConnectionInterface::IceConnectionState)nativeState;
+ (RTCICEGatheringState)convertIceGatheringStateToObjC:
(webrtc::PeerConnectionInterface::IceGatheringState)nativeState;
+ (RTCSignalingState)convertSignalingStateToObjC:
(webrtc::PeerConnectionInterface::SignalingState)nativeState;
+ (webrtc::PeerConnectionInterface::StatsOutputLevel)
convertStatsOutputLevelToNative:(RTCStatsOutputLevel)statsOutputLevel;
+ (RTCSourceState)convertSourceStateToObjC:
(webrtc::MediaSourceInterface::SourceState)nativeState;
+ (webrtc::MediaStreamTrackInterface::TrackState)convertTrackStateToNative:
(RTCTrackState)state;
+ (RTCTrackState)convertTrackStateToObjC:
(webrtc::MediaStreamTrackInterface::TrackState)nativeState;
+ (RTCIceTransportsType)iceTransportsTypeForNativeEnum:
(webrtc::PeerConnectionInterface::IceTransportsType)nativeEnum;
+ (webrtc::PeerConnectionInterface::IceTransportsType)nativeEnumForIceTransportsType:
(RTCIceTransportsType)iceTransportsType;
+ (RTCBundlePolicy)bundlePolicyForNativeEnum:
(webrtc::PeerConnectionInterface::BundlePolicy)nativeEnum;
+ (webrtc::PeerConnectionInterface::BundlePolicy)nativeEnumForBundlePolicy:
(RTCBundlePolicy)bundlePolicy;
+ (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativeEnum:
(webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeEnum;
+ (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeEnumForRtcpMuxPolicy:
(RTCRtcpMuxPolicy)rtcpMuxPolicy;
+ (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativeEnum:
(webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativeEnum;
+ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativeEnumForTcpCandidatePolicy:
(RTCTcpCandidatePolicy)tcpCandidatePolicy;
@end

View File

@ -1,223 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCEnumConverter.h"
#include "webrtc/api/peerconnectioninterface.h"
@implementation RTCEnumConverter
+ (RTCICEConnectionState)convertIceConnectionStateToObjC:
(webrtc::PeerConnectionInterface::IceConnectionState)nativeState {
switch (nativeState) {
case webrtc::PeerConnectionInterface::kIceConnectionNew:
return RTCICEConnectionNew;
case webrtc::PeerConnectionInterface::kIceConnectionChecking:
return RTCICEConnectionChecking;
case webrtc::PeerConnectionInterface::kIceConnectionConnected:
return RTCICEConnectionConnected;
case webrtc::PeerConnectionInterface::kIceConnectionCompleted:
return RTCICEConnectionCompleted;
case webrtc::PeerConnectionInterface::kIceConnectionFailed:
return RTCICEConnectionFailed;
case webrtc::PeerConnectionInterface::kIceConnectionDisconnected:
return RTCICEConnectionDisconnected;
case webrtc::PeerConnectionInterface::kIceConnectionClosed:
return RTCICEConnectionClosed;
case webrtc::PeerConnectionInterface::kIceConnectionMax:
NSAssert(NO, @"kIceConnectionMax not allowed");
return RTCICEConnectionMax;
}
}
+ (RTCICEGatheringState)convertIceGatheringStateToObjC:
(webrtc::PeerConnectionInterface::IceGatheringState)nativeState {
switch (nativeState) {
case webrtc::PeerConnectionInterface::kIceGatheringNew:
return RTCICEGatheringNew;
case webrtc::PeerConnectionInterface::kIceGatheringGathering:
return RTCICEGatheringGathering;
case webrtc::PeerConnectionInterface::kIceGatheringComplete:
return RTCICEGatheringComplete;
}
}
+ (RTCSignalingState)convertSignalingStateToObjC:
(webrtc::PeerConnectionInterface::SignalingState)nativeState {
switch (nativeState) {
case webrtc::PeerConnectionInterface::kStable:
return RTCSignalingStable;
case webrtc::PeerConnectionInterface::kHaveLocalOffer:
return RTCSignalingHaveLocalOffer;
case webrtc::PeerConnectionInterface::kHaveLocalPrAnswer:
return RTCSignalingHaveLocalPrAnswer;
case webrtc::PeerConnectionInterface::kHaveRemoteOffer:
return RTCSignalingHaveRemoteOffer;
case webrtc::PeerConnectionInterface::kHaveRemotePrAnswer:
return RTCSignalingHaveRemotePrAnswer;
case webrtc::PeerConnectionInterface::kClosed:
return RTCSignalingClosed;
}
}
+ (webrtc::PeerConnectionInterface::StatsOutputLevel)
convertStatsOutputLevelToNative:(RTCStatsOutputLevel)statsOutputLevel {
switch (statsOutputLevel) {
case RTCStatsOutputLevelStandard:
return webrtc::PeerConnectionInterface::kStatsOutputLevelStandard;
case RTCStatsOutputLevelDebug:
return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug;
}
}
+ (RTCSourceState)convertSourceStateToObjC:
(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;
}
}
+ (webrtc::MediaStreamTrackInterface::TrackState)
convertTrackStateToNative:(RTCTrackState)state {
switch (state) {
case RTCTrackStateLive:
return webrtc::MediaStreamTrackInterface::kLive;
case RTCTrackStateEnded:
return webrtc::MediaStreamTrackInterface::kEnded;
}
}
+ (RTCTrackState)convertTrackStateToObjC:
(webrtc::MediaStreamTrackInterface::TrackState)nativeState {
switch (nativeState) {
case webrtc::MediaStreamTrackInterface::kLive:
return RTCTrackStateLive;
case webrtc::MediaStreamTrackInterface::kEnded:
return RTCTrackStateEnded;
}
}
+ (RTCIceTransportsType)iceTransportsTypeForNativeEnum:
(webrtc::PeerConnectionInterface::IceTransportsType)nativeEnum {
switch (nativeEnum) {
case webrtc::PeerConnectionInterface::kNone:
return kRTCIceTransportsTypeNone;
case webrtc::PeerConnectionInterface::kRelay:
return kRTCIceTransportsTypeRelay;
case webrtc::PeerConnectionInterface::kNoHost:
return kRTCIceTransportsTypeNoHost;
case webrtc::PeerConnectionInterface::kAll:
return kRTCIceTransportsTypeAll;
}
}
+ (webrtc::PeerConnectionInterface::IceTransportsType)nativeEnumForIceTransportsType:
(RTCIceTransportsType)iceTransportsType {
switch (iceTransportsType) {
case kRTCIceTransportsTypeNone:
return webrtc::PeerConnectionInterface::kNone;
case kRTCIceTransportsTypeRelay:
return webrtc::PeerConnectionInterface::kRelay;
case kRTCIceTransportsTypeNoHost:
return webrtc::PeerConnectionInterface::kNoHost;
case kRTCIceTransportsTypeAll:
return webrtc::PeerConnectionInterface::kAll;
}
}
+ (RTCBundlePolicy)bundlePolicyForNativeEnum:
(webrtc::PeerConnectionInterface::BundlePolicy)nativeEnum {
switch (nativeEnum) {
case webrtc::PeerConnectionInterface::kBundlePolicyBalanced:
return kRTCBundlePolicyBalanced;
case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle:
return kRTCBundlePolicyMaxBundle;
case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat:
return kRTCBundlePolicyMaxCompat;
}
}
+ (webrtc::PeerConnectionInterface::BundlePolicy)nativeEnumForBundlePolicy:
(RTCBundlePolicy)bundlePolicy {
switch (bundlePolicy) {
case kRTCBundlePolicyBalanced:
return webrtc::PeerConnectionInterface::kBundlePolicyBalanced;
case kRTCBundlePolicyMaxBundle:
return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle;
case kRTCBundlePolicyMaxCompat:
return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat;
}
}
+ (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativeEnum:
(webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeEnum {
switch (nativeEnum) {
case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate:
return kRTCRtcpMuxPolicyNegotiate;
case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire:
return kRTCRtcpMuxPolicyRequire;
}
}
+ (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeEnumForRtcpMuxPolicy:
(RTCRtcpMuxPolicy)rtcpMuxPolicy {
switch (rtcpMuxPolicy) {
case kRTCRtcpMuxPolicyNegotiate:
return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
case kRTCRtcpMuxPolicyRequire:
return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
}
}
+ (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativeEnum:
(webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativeEnum {
switch (nativeEnum) {
case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled:
return kRTCTcpCandidatePolicyEnabled;
case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled:
return kRTCTcpCandidatePolicyDisabled;
}
}
+ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativeEnumForTcpCandidatePolicy:
(RTCTcpCandidatePolicy)tcpCandidatePolicy {
switch (tcpCandidatePolicy) {
case kRTCTcpCandidatePolicyEnabled:
return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled;
case kRTCTcpCandidatePolicyDisabled:
return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;
}
}
@end

View File

@ -1,36 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCI420Frame.h"
#include "webrtc/media/base/videoframe.h"
@interface RTCI420Frame (Internal)
- (instancetype)initWithVideoFrame:(const cricket::VideoFrame*)videoFrame;
@end

View File

@ -1,109 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCI420Frame.h"
#include <memory>
#include "webrtc/media/engine/webrtcvideoframe.h"
@implementation RTCI420Frame {
std::unique_ptr<cricket::VideoFrame> _videoFrame;
}
- (NSUInteger)width {
return _videoFrame->width();
}
- (NSUInteger)height {
return _videoFrame->height();
}
// TODO(nisse): chromaWidth and chromaHeight are used only in
// RTCOpenGLVideoRenderer.mm. Update, and then delete these
// properties.
- (NSUInteger)chromaWidth {
return (self.width + 1) / 2;
}
- (NSUInteger)chromaHeight {
return (self.height + 1) / 2;
}
- (const uint8_t*)yPlane {
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer =
_videoFrame->video_frame_buffer();
return buffer ? buffer->DataY() : nullptr;
}
- (const uint8_t*)uPlane {
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer =
_videoFrame->video_frame_buffer();
return buffer ? buffer->DataU() : nullptr;
}
- (const uint8_t*)vPlane {
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer =
_videoFrame->video_frame_buffer();
return buffer ? buffer->DataV() : nullptr;
}
- (NSInteger)yPitch {
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer =
_videoFrame->video_frame_buffer();
return buffer ? buffer->StrideY() : 0;
}
- (NSInteger)uPitch {
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer =
_videoFrame->video_frame_buffer();
return buffer ? buffer->StrideU() : 0;
}
- (NSInteger)vPitch {
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer =
_videoFrame->video_frame_buffer();
return buffer ? buffer->StrideV() : 0;
}
@end
@implementation RTCI420Frame (Internal)
- (instancetype)initWithVideoFrame:(cricket::VideoFrame*)videoFrame {
if (self = [super init]) {
// Keep a shallow copy of the video frame. The underlying frame buffer is
// not copied.
_videoFrame.reset(new cricket::WebRtcVideoFrame(
videoFrame->video_frame_buffer(),
videoFrame->rotation(),
videoFrame->timestamp_us()));
}
return self;
}
@end

View File

@ -1,39 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCICECandidate.h"
#include "webrtc/api/peerconnectioninterface.h"
@interface RTCICECandidate (Internal)
@property(nonatomic, assign, readonly) const
webrtc::IceCandidateInterface* candidate;
- (id)initWithCandidate:(const webrtc::IceCandidateInterface*)candidate;
@end

View File

@ -1,87 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCICECandidate+Internal.h"
@implementation RTCICECandidate
@synthesize sdpMid = _sdpMid;
@synthesize sdpMLineIndex = _sdpMLineIndex;
@synthesize sdp = _sdp;
- (id)initWithMid:(NSString*)sdpMid
index:(NSInteger)sdpMLineIndex
sdp:(NSString*)sdp {
if (!sdpMid || !sdp) {
NSAssert(NO, @"nil arguments not allowed");
return nil;
}
if ((self = [super init])) {
_sdpMid = [sdpMid copy];
_sdpMLineIndex = sdpMLineIndex;
_sdp = [sdp copy];
}
return self;
}
- (NSString*)description {
return [NSString stringWithFormat:@"%@:%ld:%@",
self.sdpMid,
(long)self.sdpMLineIndex,
self.sdp];
}
@end
@implementation RTCICECandidate (Internal)
- (id)initWithCandidate:(const webrtc::IceCandidateInterface*)candidate {
if ((self = [super init])) {
std::string sdp;
if (candidate->ToString(&sdp)) {
_sdpMid = @(candidate->sdp_mid().c_str());
_sdpMLineIndex = candidate->sdp_mline_index();
_sdp = @(sdp.c_str());
} else {
self = nil;
NSAssert(NO, @"ICECandidateInterface->ToString failed");
}
}
return self;
}
- (const webrtc::IceCandidateInterface*)candidate {
return webrtc::CreateIceCandidate(
[self.sdpMid UTF8String], self.sdpMLineIndex, [self.sdp UTF8String],
nullptr);
}
@end

View File

@ -1,38 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCICEServer.h"
#include "webrtc/api/peerconnectioninterface.h"
@interface RTCICEServer (Internal)
@property(nonatomic,
assign,
readonly) webrtc::PeerConnectionInterface::IceServer iceServer;
@end

View File

@ -1,75 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCICEServer+Internal.h"
@implementation RTCICEServer
@synthesize URI = _URI;
@synthesize username = _username;
@synthesize password = _password;
- (id)initWithURI:(NSURL*)URI
username:(NSString*)username
password:(NSString*)password {
if (!URI || !username || !password) {
NSAssert(NO, @"nil arguments not allowed");
self = nil;
return nil;
}
if ((self = [super init])) {
_URI = URI;
_username = [username copy];
_password = [password copy];
}
return self;
}
- (NSString*)description {
return [NSString stringWithFormat:@"RTCICEServer: [%@:%@:%@]",
[self.URI absoluteString],
self.username,
self.password];
}
@end
@implementation RTCICEServer (Internal)
- (webrtc::PeerConnectionInterface::IceServer)iceServer {
webrtc::PeerConnectionInterface::IceServer iceServer;
iceServer.uri = [[self.URI absoluteString] UTF8String];
iceServer.username = [self.username UTF8String];
iceServer.password = [self.password UTF8String];
return iceServer;
}
@end

View File

@ -1,64 +0,0 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCLogging.h"
#include "webrtc/base/logging.h"
rtc::LoggingSeverity RTCGetNativeLoggingSeverity(RTCLoggingSeverity severity) {
switch (severity) {
case kRTCLoggingSeverityVerbose:
return rtc::LS_VERBOSE;
case kRTCLoggingSeverityInfo:
return rtc::LS_INFO;
case kRTCLoggingSeverityWarning:
return rtc::LS_WARNING;
case kRTCLoggingSeverityError:
return rtc::LS_ERROR;
}
}
void RTCLogEx(RTCLoggingSeverity severity, NSString* logString) {
if (logString.length) {
const char* utf8String = logString.UTF8String;
LOG_V(RTCGetNativeLoggingSeverity(severity)) << utf8String;
}
}
void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity) {
rtc::LogMessage::LogToDebug(RTCGetNativeLoggingSeverity(severity));
}
NSString* RTCFileName(const char* filePath) {
NSString* nsFilePath =
[[NSString alloc] initWithBytesNoCopy:const_cast<char*>(filePath)
length:strlen(filePath)
encoding:NSUTF8StringEncoding
freeWhenDone:NO];
return nsFilePath.lastPathComponent;
}

View File

@ -1,40 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCMediaConstraints.h"
#import "RTCMediaConstraintsNative.h"
#include "webrtc/api/mediastreaminterface.h"
@interface RTCMediaConstraints (Internal)
// Ownership is retained for the lifetime of this object.
@property(nonatomic, assign, readonly) const
webrtc::RTCMediaConstraintsNative *constraints;
@end

View File

@ -1,76 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCMediaConstraints+Internal.h"
#import "RTCPair.h"
#include <memory>
// TODO(hughv): Add accessors for mandatory and optional constraints.
// TODO(hughv): Add description.
@implementation RTCMediaConstraints {
std::unique_ptr<webrtc::RTCMediaConstraintsNative> _constraints;
webrtc::MediaConstraintsInterface::Constraints _mandatory;
webrtc::MediaConstraintsInterface::Constraints _optional;
}
- (id)initWithMandatoryConstraints:(NSArray*)mandatory
optionalConstraints:(NSArray*)optional {
if ((self = [super init])) {
_mandatory = [[self class] constraintsFromArray:mandatory];
_optional = [[self class] constraintsFromArray:optional];
_constraints.reset(
new webrtc::RTCMediaConstraintsNative(_mandatory, _optional));
}
return self;
}
+ (webrtc::MediaConstraintsInterface::Constraints)constraintsFromArray:
(NSArray*)array {
webrtc::MediaConstraintsInterface::Constraints constraints;
for (RTCPair* pair in array) {
constraints.push_back(webrtc::MediaConstraintsInterface::Constraint(
[pair.key UTF8String], [pair.value UTF8String]));
}
return constraints;
}
@end
@implementation RTCMediaConstraints (internal)
- (const webrtc::RTCMediaConstraintsNative*)constraints {
return _constraints.get();
}
@end

View File

@ -1,51 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "talk/app/webrtc/objc/RTCMediaConstraintsNative.h"
namespace webrtc {
RTCMediaConstraintsNative::~RTCMediaConstraintsNative() {}
RTCMediaConstraintsNative::RTCMediaConstraintsNative() {}
RTCMediaConstraintsNative::RTCMediaConstraintsNative(
const MediaConstraintsInterface::Constraints& mandatory,
const MediaConstraintsInterface::Constraints& optional)
: mandatory_(mandatory), optional_(optional) {}
const MediaConstraintsInterface::Constraints&
RTCMediaConstraintsNative::GetMandatory() const {
return mandatory_;
}
const MediaConstraintsInterface::Constraints&
RTCMediaConstraintsNative::GetOptional() const {
return optional_;
}
} // namespace webrtc

View File

@ -1,50 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TALK_APP_WEBRTC_OBJC_RTCMEDIACONSTRAINTSNATIVE_H_
#define TALK_APP_WEBRTC_OBJC_RTCMEDIACONSTRAINTSNATIVE_H_
#include "webrtc/api/mediaconstraintsinterface.h"
namespace webrtc {
class RTCMediaConstraintsNative : public MediaConstraintsInterface {
public:
virtual ~RTCMediaConstraintsNative();
RTCMediaConstraintsNative();
RTCMediaConstraintsNative(
const MediaConstraintsInterface::Constraints& mandatory,
const MediaConstraintsInterface::Constraints& optional);
virtual const Constraints& GetMandatory() const;
virtual const Constraints& GetOptional() const;
private:
MediaConstraintsInterface::Constraints mandatory_;
MediaConstraintsInterface::Constraints optional_;
};
} // namespace webrtc
#endif // TALK_APP_WEBRTC_OBJC_RTCMEDIACONSTRAINTSNATIVE_H_

View File

@ -1,40 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCMediaSource.h"
#include "webrtc/api/mediastreaminterface.h"
@interface RTCMediaSource (Internal)
@property(nonatomic, assign, readonly)
rtc::scoped_refptr<webrtc::MediaSourceInterface> mediaSource;
- (id)initWithMediaSource:
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)mediaSource;
@end

View File

@ -1,65 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCMediaSource+Internal.h"
#import "RTCEnumConverter.h"
@implementation RTCMediaSource {
rtc::scoped_refptr<webrtc::MediaSourceInterface> _mediaSource;
}
- (RTCSourceState)state {
return [RTCEnumConverter convertSourceStateToObjC:self.mediaSource->state()];
}
@end
@implementation RTCMediaSource (Internal)
- (id)initWithMediaSource:
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)mediaSource {
if (!mediaSource) {
NSAssert(NO, @"nil arguments not allowed");
self = nil;
return nil;
}
if ((self = [super init])) {
_mediaSource = mediaSource;
}
return self;
}
- (rtc::scoped_refptr<webrtc::MediaSourceInterface>)mediaSource {
return _mediaSource;
}
@end

View File

@ -1,40 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCMediaStream.h"
#include "webrtc/api/mediastreamtrack.h"
@interface RTCMediaStream (Internal)
@property(nonatomic, assign, readonly)
rtc::scoped_refptr<webrtc::MediaStreamInterface> mediaStream;
- (id)initWithMediaStream:
(rtc::scoped_refptr<webrtc::MediaStreamInterface>)mediaStream;
@end

View File

@ -1,146 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCMediaStream+Internal.h"
#import "RTCAudioTrack+Internal.h"
#import "RTCMediaStreamTrack+Internal.h"
#import "RTCVideoTrack+Internal.h"
#include "webrtc/api/mediastreaminterface.h"
@implementation RTCMediaStream {
NSMutableArray* _audioTracks;
NSMutableArray* _videoTracks;
rtc::scoped_refptr<webrtc::MediaStreamInterface> _mediaStream;
}
- (NSString*)description {
return [NSString stringWithFormat:@"[%@:A=%lu:V=%lu]",
[self label],
(unsigned long)[self.audioTracks count],
(unsigned long)[self.videoTracks count]];
}
- (NSArray*)audioTracks {
return [_audioTracks copy];
}
- (NSArray*)videoTracks {
return [_videoTracks copy];
}
- (NSString*)label {
return @(self.mediaStream->label().c_str());
}
- (BOOL)addAudioTrack:(RTCAudioTrack*)track {
if (self.mediaStream->AddTrack(track.audioTrack)) {
[_audioTracks addObject:track];
return YES;
}
return NO;
}
- (BOOL)addVideoTrack:(RTCVideoTrack*)track {
if (self.mediaStream->AddTrack(track.nativeVideoTrack)) {
[_videoTracks addObject:track];
return YES;
}
return NO;
}
- (BOOL)removeAudioTrack:(RTCAudioTrack*)track {
NSUInteger index = [_audioTracks indexOfObjectIdenticalTo:track];
NSAssert(index != NSNotFound,
@"|removeAudioTrack| called on unexpected RTCAudioTrack");
if (index != NSNotFound && self.mediaStream->RemoveTrack(track.audioTrack)) {
[_audioTracks removeObjectAtIndex:index];
return YES;
}
return NO;
}
- (BOOL)removeVideoTrack:(RTCVideoTrack*)track {
NSUInteger index = [_videoTracks indexOfObjectIdenticalTo:track];
NSAssert(index != NSNotFound,
@"|removeAudioTrack| called on unexpected RTCVideoTrack");
if (index != NSNotFound &&
self.mediaStream->RemoveTrack(track.nativeVideoTrack)) {
[_videoTracks removeObjectAtIndex:index];
return YES;
}
return NO;
}
@end
@implementation RTCMediaStream (Internal)
- (id)initWithMediaStream:
(rtc::scoped_refptr<webrtc::MediaStreamInterface>)mediaStream {
if (!mediaStream) {
NSAssert(NO, @"nil arguments not allowed");
self = nil;
return nil;
}
if ((self = [super init])) {
webrtc::AudioTrackVector audio_tracks = mediaStream->GetAudioTracks();
webrtc::VideoTrackVector video_tracks = mediaStream->GetVideoTracks();
_audioTracks = [NSMutableArray arrayWithCapacity:audio_tracks.size()];
_videoTracks = [NSMutableArray arrayWithCapacity:video_tracks.size()];
_mediaStream = mediaStream;
for (size_t i = 0; i < audio_tracks.size(); ++i) {
rtc::scoped_refptr<webrtc::AudioTrackInterface> track =
audio_tracks[i];
RTCAudioTrack* audioTrack =
[[RTCAudioTrack alloc] initWithMediaTrack:track];
[_audioTracks addObject:audioTrack];
}
for (size_t i = 0; i < video_tracks.size(); ++i) {
rtc::scoped_refptr<webrtc::VideoTrackInterface> track =
video_tracks[i];
RTCVideoTrack* videoTrack =
[[RTCVideoTrack alloc] initWithMediaTrack:track];
[_videoTracks addObject:videoTrack];
}
}
return self;
}
- (rtc::scoped_refptr<webrtc::MediaStreamInterface>)mediaStream {
return _mediaStream;
}
@end

View File

@ -1,40 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCMediaStreamTrack.h"
#include "webrtc/api/mediastreaminterface.h"
@interface RTCMediaStreamTrack (Internal)
@property(nonatomic, assign, readonly)
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> mediaTrack;
- (id)initWithMediaTrack:
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)mediaTrack;
@end

View File

@ -1,124 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCEnumConverter.h"
#import "RTCMediaStreamTrack+Internal.h"
#include <memory>
namespace webrtc {
class RTCMediaStreamTrackObserver : public ObserverInterface {
public:
RTCMediaStreamTrackObserver(RTCMediaStreamTrack* track) { _track = track; }
void OnChanged() override {
[_track.delegate mediaStreamTrackDidChange:_track];
}
private:
__weak RTCMediaStreamTrack* _track;
};
}
@implementation RTCMediaStreamTrack {
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> _mediaTrack;
std::unique_ptr<webrtc::RTCMediaStreamTrackObserver> _observer;
}
@synthesize label;
- (BOOL)isEqual:(id)other {
// Equality is purely based on the label just like the C++ implementation.
if (self == other)
return YES;
if (![other isKindOfClass:[self class]] ||
![self isKindOfClass:[other class]]) {
return NO;
}
RTCMediaStreamTrack* otherMediaStream = (RTCMediaStreamTrack*)other;
return [self.label isEqual:otherMediaStream.label];
}
- (NSUInteger)hash {
return [self.label hash];
}
- (NSString*)kind {
return @(self.mediaTrack->kind().c_str());
}
- (NSString*)label {
return @(self.mediaTrack->id().c_str());
}
- (BOOL)isEnabled {
return self.mediaTrack->enabled();
}
- (BOOL)setEnabled:(BOOL)enabled {
return self.mediaTrack->set_enabled(enabled);
}
- (RTCTrackState)state {
return [RTCEnumConverter convertTrackStateToObjC:self.mediaTrack->state()];
}
@end
@implementation RTCMediaStreamTrack (Internal)
- (id)initWithMediaTrack:
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)
mediaTrack {
if (!mediaTrack) {
NSAssert(NO, @"nil arguments not allowed");
self = nil;
return nil;
}
if (self = [super init]) {
_mediaTrack = mediaTrack;
label = @(mediaTrack->id().c_str());
_observer.reset(new webrtc::RTCMediaStreamTrackObserver(self));
_mediaTrack->RegisterObserver(_observer.get());
}
return self;
}
- (void)dealloc {
_mediaTrack->UnregisterObserver(_observer.get());
}
- (rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)mediaTrack {
return _mediaTrack;
}
@end

View File

@ -1,158 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCNSGLVideoView.h"
#import <CoreVideo/CVDisplayLink.h>
#import <OpenGL/gl3.h>
#import "RTCI420Frame.h"
#import "RTCOpenGLVideoRenderer.h"
@interface RTCNSGLVideoView ()
// |i420Frame| is set when we receive a frame from a worker thread and is read
// from the display link callback so atomicity is required.
@property(atomic, strong) RTCI420Frame* i420Frame;
@property(atomic, strong) RTCOpenGLVideoRenderer* glRenderer;
- (void)drawFrame;
@end
static CVReturn OnDisplayLinkFired(CVDisplayLinkRef displayLink,
const CVTimeStamp* now,
const CVTimeStamp* outputTime,
CVOptionFlags flagsIn,
CVOptionFlags* flagsOut,
void* displayLinkContext) {
RTCNSGLVideoView* view = (__bridge RTCNSGLVideoView*)displayLinkContext;
[view drawFrame];
return kCVReturnSuccess;
}
@implementation RTCNSGLVideoView {
CVDisplayLinkRef _displayLink;
}
- (void)dealloc {
[self teardownDisplayLink];
}
- (void)drawRect:(NSRect)rect {
[self drawFrame];
}
- (void)reshape {
[super reshape];
NSRect frame = [self frame];
CGLLockContext([[self openGLContext] CGLContextObj]);
glViewport(0, 0, frame.size.width, frame.size.height);
CGLUnlockContext([[self openGLContext] CGLContextObj]);
}
- (void)lockFocus {
NSOpenGLContext* context = [self openGLContext];
[super lockFocus];
if ([context view] != self) {
[context setView:self];
}
[context makeCurrentContext];
}
- (void)prepareOpenGL {
[super prepareOpenGL];
if (!self.glRenderer) {
self.glRenderer =
[[RTCOpenGLVideoRenderer alloc] initWithContext:[self openGLContext]];
}
[self.glRenderer setupGL];
[self setupDisplayLink];
}
- (void)clearGLContext {
[self.glRenderer teardownGL];
self.glRenderer = nil;
[super clearGLContext];
}
#pragma mark - RTCVideoRenderer
// These methods may be called on non-main thread.
- (void)setSize:(CGSize)size {
dispatch_async(dispatch_get_main_queue(), ^{
[self.delegate videoView:self didChangeVideoSize:size];
});
}
- (void)renderFrame:(RTCI420Frame*)frame {
self.i420Frame = frame;
}
#pragma mark - Private
- (void)drawFrame {
RTCI420Frame* i420Frame = self.i420Frame;
if (self.glRenderer.lastDrawnFrame != i420Frame) {
// This method may be called from CVDisplayLink callback which isn't on the
// main thread so we have to lock the GL context before drawing.
CGLLockContext([[self openGLContext] CGLContextObj]);
[self.glRenderer drawFrame:i420Frame];
CGLUnlockContext([[self openGLContext] CGLContextObj]);
}
}
- (void)setupDisplayLink {
if (_displayLink) {
return;
}
// Synchronize buffer swaps with vertical refresh rate.
GLint swapInt = 1;
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
// Create display link.
CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink);
CVDisplayLinkSetOutputCallback(_displayLink,
&OnDisplayLinkFired,
(__bridge void*)self);
// Set the display link for the current renderer.
CGLContextObj cglContext = [[self openGLContext] CGLContextObj];
CGLPixelFormatObj cglPixelFormat = [[self pixelFormat] CGLPixelFormatObj];
CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(
_displayLink, cglContext, cglPixelFormat);
CVDisplayLinkStart(_displayLink);
}
- (void)teardownDisplayLink {
if (!_displayLink) {
return;
}
CVDisplayLinkRelease(_displayLink);
_displayLink = NULL;
}
@end

View File

@ -1,503 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCOpenGLVideoRenderer.h"
#include <string.h>
#include <memory>
#if TARGET_OS_IPHONE
#import <OpenGLES/ES3/gl.h>
#else
#import <OpenGL/gl3.h>
#endif
#import "RTCI420Frame.h"
// TODO(tkchin): check and log openGL errors. Methods here return BOOLs in
// anticipation of that happening in the future.
#if TARGET_OS_IPHONE
#define RTC_PIXEL_FORMAT GL_LUMINANCE
#define SHADER_VERSION
#define VERTEX_SHADER_IN "attribute"
#define VERTEX_SHADER_OUT "varying"
#define FRAGMENT_SHADER_IN "varying"
#define FRAGMENT_SHADER_OUT
#define FRAGMENT_SHADER_COLOR "gl_FragColor"
#define FRAGMENT_SHADER_TEXTURE "texture2D"
#else
#define RTC_PIXEL_FORMAT GL_RED
#define SHADER_VERSION "#version 150\n"
#define VERTEX_SHADER_IN "in"
#define VERTEX_SHADER_OUT "out"
#define FRAGMENT_SHADER_IN "in"
#define FRAGMENT_SHADER_OUT "out vec4 fragColor;\n"
#define FRAGMENT_SHADER_COLOR "fragColor"
#define FRAGMENT_SHADER_TEXTURE "texture"
#endif
// Vertex shader doesn't do anything except pass coordinates through.
static const char kVertexShaderSource[] =
SHADER_VERSION
VERTEX_SHADER_IN " vec2 position;\n"
VERTEX_SHADER_IN " vec2 texcoord;\n"
VERTEX_SHADER_OUT " vec2 v_texcoord;\n"
"void main() {\n"
" gl_Position = vec4(position.x, position.y, 0.0, 1.0);\n"
" v_texcoord = texcoord;\n"
"}\n";
// Fragment shader converts YUV values from input textures into a final RGB
// pixel. The conversion formula is from http://www.fourcc.org/fccyvrgb.php.
static const char kFragmentShaderSource[] =
SHADER_VERSION
"precision highp float;"
FRAGMENT_SHADER_IN " vec2 v_texcoord;\n"
"uniform lowp sampler2D s_textureY;\n"
"uniform lowp sampler2D s_textureU;\n"
"uniform lowp sampler2D s_textureV;\n"
FRAGMENT_SHADER_OUT
"void main() {\n"
" float y, u, v, r, g, b;\n"
" y = " FRAGMENT_SHADER_TEXTURE "(s_textureY, v_texcoord).r;\n"
" u = " FRAGMENT_SHADER_TEXTURE "(s_textureU, v_texcoord).r;\n"
" v = " FRAGMENT_SHADER_TEXTURE "(s_textureV, v_texcoord).r;\n"
" u = u - 0.5;\n"
" v = v - 0.5;\n"
" r = y + 1.403 * v;\n"
" g = y - 0.344 * u - 0.714 * v;\n"
" b = y + 1.770 * u;\n"
" " FRAGMENT_SHADER_COLOR " = vec4(r, g, b, 1.0);\n"
" }\n";
// Compiles a shader of the given |type| with GLSL source |source| and returns
// the shader handle or 0 on error.
GLuint CreateShader(GLenum type, const GLchar* source) {
GLuint shader = glCreateShader(type);
if (!shader) {
return 0;
}
glShaderSource(shader, 1, &source, NULL);
glCompileShader(shader);
GLint compileStatus = GL_FALSE;
glGetShaderiv(shader, GL_COMPILE_STATUS, &compileStatus);
if (compileStatus == GL_FALSE) {
glDeleteShader(shader);
shader = 0;
}
return shader;
}
// Links a shader program with the given vertex and fragment shaders and
// returns the program handle or 0 on error.
GLuint CreateProgram(GLuint vertexShader, GLuint fragmentShader) {
if (vertexShader == 0 || fragmentShader == 0) {
return 0;
}
GLuint program = glCreateProgram();
if (!program) {
return 0;
}
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glLinkProgram(program);
GLint linkStatus = GL_FALSE;
glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
if (linkStatus == GL_FALSE) {
glDeleteProgram(program);
program = 0;
}
return program;
}
// When modelview and projection matrices are identity (default) the world is
// contained in the square around origin with unit size 2. Drawing to these
// coordinates is equivalent to drawing to the entire screen. The texture is
// stretched over that square using texture coordinates (u, v) that range
// from (0, 0) to (1, 1) inclusive. Texture coordinates are flipped vertically
// here because the incoming frame has origin in upper left hand corner but
// OpenGL expects origin in bottom left corner.
const GLfloat gVertices[] = {
// X, Y, U, V.
-1, -1, 0, 1, // Bottom left.
1, -1, 1, 1, // Bottom right.
1, 1, 1, 0, // Top right.
-1, 1, 0, 0, // Top left.
};
// |kNumTextures| must not exceed 8, which is the limit in OpenGLES2. Two sets
// of 3 textures are used here, one for each of the Y, U and V planes. Having
// two sets alleviates CPU blockage in the event that the GPU is asked to render
// to a texture that is already in use.
static const GLsizei kNumTextureSets = 2;
static const GLsizei kNumTextures = 3 * kNumTextureSets;
@implementation RTCOpenGLVideoRenderer {
#if TARGET_OS_IPHONE
EAGLContext* _context;
#else
NSOpenGLContext* _context;
#endif
BOOL _isInitialized;
NSUInteger _currentTextureSet;
// Handles for OpenGL constructs.
GLuint _textures[kNumTextures];
GLuint _program;
#if !TARGET_OS_IPHONE
GLuint _vertexArray;
#endif
GLuint _vertexBuffer;
GLint _position;
GLint _texcoord;
GLint _ySampler;
GLint _uSampler;
GLint _vSampler;
// Used to create a non-padded plane for GPU upload when we receive padded
// frames.
std::unique_ptr<uint8_t[]> _planeBuffer;
}
+ (void)initialize {
// Disable dithering for performance.
glDisable(GL_DITHER);
}
#if TARGET_OS_IPHONE
- (instancetype)initWithContext:(EAGLContext*)context {
#else
- (instancetype)initWithContext:(NSOpenGLContext*)context {
#endif
NSAssert(context != nil, @"context cannot be nil");
if (self = [super init]) {
_context = context;
}
return self;
}
- (BOOL)drawFrame:(RTCI420Frame*)frame {
if (!_isInitialized) {
return NO;
}
if (_lastDrawnFrame == frame) {
return NO;
}
[self ensureGLContext];
glClear(GL_COLOR_BUFFER_BIT);
if (frame) {
if (![self updateTextureSizesForFrame:frame] ||
![self updateTextureDataForFrame:frame]) {
return NO;
}
#if !TARGET_OS_IPHONE
glBindVertexArray(_vertexArray);
#endif
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
#if !TARGET_OS_IPHONE
[_context flushBuffer];
#endif
_lastDrawnFrame = frame;
return YES;
}
- (void)setupGL {
if (_isInitialized) {
return;
}
[self ensureGLContext];
if (![self setupProgram]) {
return;
}
if (![self setupTextures]) {
return;
}
if (![self setupVertices]) {
return;
}
glUseProgram(_program);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
_isInitialized = YES;
}
- (void)teardownGL {
if (!_isInitialized) {
return;
}
[self ensureGLContext];
glDeleteProgram(_program);
_program = 0;
glDeleteTextures(kNumTextures, _textures);
glDeleteBuffers(1, &_vertexBuffer);
_vertexBuffer = 0;
#if !TARGET_OS_IPHONE
glDeleteVertexArrays(1, &_vertexArray);
#endif
_isInitialized = NO;
}
#pragma mark - Private
- (void)ensureGLContext {
NSAssert(_context, @"context shouldn't be nil");
#if TARGET_OS_IPHONE
if ([EAGLContext currentContext] != _context) {
[EAGLContext setCurrentContext:_context];
}
#else
if ([NSOpenGLContext currentContext] != _context) {
[_context makeCurrentContext];
}
#endif
}
- (BOOL)setupProgram {
NSAssert(!_program, @"program already set up");
GLuint vertexShader = CreateShader(GL_VERTEX_SHADER, kVertexShaderSource);
NSAssert(vertexShader, @"failed to create vertex shader");
GLuint fragmentShader =
CreateShader(GL_FRAGMENT_SHADER, kFragmentShaderSource);
NSAssert(fragmentShader, @"failed to create fragment shader");
_program = CreateProgram(vertexShader, fragmentShader);
// Shaders are created only to generate program.
if (vertexShader) {
glDeleteShader(vertexShader);
}
if (fragmentShader) {
glDeleteShader(fragmentShader);
}
if (!_program) {
return NO;
}
_position = glGetAttribLocation(_program, "position");
_texcoord = glGetAttribLocation(_program, "texcoord");
_ySampler = glGetUniformLocation(_program, "s_textureY");
_uSampler = glGetUniformLocation(_program, "s_textureU");
_vSampler = glGetUniformLocation(_program, "s_textureV");
if (_position < 0 || _texcoord < 0 || _ySampler < 0 || _uSampler < 0 ||
_vSampler < 0) {
return NO;
}
return YES;
}
- (BOOL)setupTextures {
glGenTextures(kNumTextures, _textures);
// Set parameters for each of the textures we created.
for (GLsizei i = 0; i < kNumTextures; i++) {
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(GL_TEXTURE_2D, _textures[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
return YES;
}
- (BOOL)updateTextureSizesForFrame:(RTCI420Frame*)frame {
if (frame.height == _lastDrawnFrame.height &&
frame.width == _lastDrawnFrame.width &&
frame.chromaWidth == _lastDrawnFrame.chromaWidth &&
frame.chromaHeight == _lastDrawnFrame.chromaHeight) {
return YES;
}
GLsizei lumaWidth = frame.width;
GLsizei lumaHeight = frame.height;
GLsizei chromaWidth = frame.chromaWidth;
GLsizei chromaHeight = frame.chromaHeight;
for (GLint i = 0; i < kNumTextureSets; i++) {
glActiveTexture(GL_TEXTURE0 + i * 3);
glTexImage2D(GL_TEXTURE_2D,
0,
RTC_PIXEL_FORMAT,
lumaWidth,
lumaHeight,
0,
RTC_PIXEL_FORMAT,
GL_UNSIGNED_BYTE,
0);
glActiveTexture(GL_TEXTURE0 + i * 3 + 1);
glTexImage2D(GL_TEXTURE_2D,
0,
RTC_PIXEL_FORMAT,
chromaWidth,
chromaHeight,
0,
RTC_PIXEL_FORMAT,
GL_UNSIGNED_BYTE,
0);
glActiveTexture(GL_TEXTURE0 + i * 3 + 2);
glTexImage2D(GL_TEXTURE_2D,
0,
RTC_PIXEL_FORMAT,
chromaWidth,
chromaHeight,
0,
RTC_PIXEL_FORMAT,
GL_UNSIGNED_BYTE,
0);
}
if (frame.yPitch != frame.width || frame.uPitch != frame.chromaWidth ||
frame.vPitch != frame.chromaWidth) {
_planeBuffer.reset(new uint8_t[frame.width * frame.height]);
} else {
_planeBuffer.reset();
}
return YES;
}
- (void)uploadPlane:(const uint8_t*)plane
sampler:(GLint)sampler
offset:(NSUInteger)offset
width:(NSUInteger)width
height:(NSUInteger)height
stride:(NSInteger)stride {
glActiveTexture(GL_TEXTURE0 + offset);
// When setting texture sampler uniforms, the texture index is used not
// the texture handle.
glUniform1i(sampler, offset);
#if TARGET_OS_IPHONE
BOOL hasUnpackRowLength = _context.API == kEAGLRenderingAPIOpenGLES3;
#else
BOOL hasUnpackRowLength = YES;
#endif
const uint8_t* uploadPlane = plane;
if (stride != width) {
if (hasUnpackRowLength) {
// GLES3 allows us to specify stride.
glPixelStorei(GL_UNPACK_ROW_LENGTH, stride);
glTexImage2D(GL_TEXTURE_2D,
0,
RTC_PIXEL_FORMAT,
width,
height,
0,
RTC_PIXEL_FORMAT,
GL_UNSIGNED_BYTE,
uploadPlane);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
return;
} else {
// Make an unpadded copy and upload that instead. Quick profiling showed
// that this is faster than uploading row by row using glTexSubImage2D.
uint8_t* unpaddedPlane = _planeBuffer.get();
for (NSUInteger y = 0; y < height; ++y) {
memcpy(unpaddedPlane + y * width, plane + y * stride, width);
}
uploadPlane = unpaddedPlane;
}
}
glTexImage2D(GL_TEXTURE_2D,
0,
RTC_PIXEL_FORMAT,
width,
height,
0,
RTC_PIXEL_FORMAT,
GL_UNSIGNED_BYTE,
uploadPlane);
}
- (BOOL)updateTextureDataForFrame:(RTCI420Frame*)frame {
NSUInteger textureOffset = _currentTextureSet * 3;
NSAssert(textureOffset + 3 <= kNumTextures, @"invalid offset");
[self uploadPlane:frame.yPlane
sampler:_ySampler
offset:textureOffset
width:frame.width
height:frame.height
stride:frame.yPitch];
[self uploadPlane:frame.uPlane
sampler:_uSampler
offset:textureOffset + 1
width:frame.chromaWidth
height:frame.chromaHeight
stride:frame.uPitch];
[self uploadPlane:frame.vPlane
sampler:_vSampler
offset:textureOffset + 2
width:frame.chromaWidth
height:frame.chromaHeight
stride:frame.vPitch];
_currentTextureSet = (_currentTextureSet + 1) % kNumTextureSets;
return YES;
}
- (BOOL)setupVertices {
#if !TARGET_OS_IPHONE
NSAssert(!_vertexArray, @"vertex array already set up");
glGenVertexArrays(1, &_vertexArray);
if (!_vertexArray) {
return NO;
}
glBindVertexArray(_vertexArray);
#endif
NSAssert(!_vertexBuffer, @"vertex buffer already set up");
glGenBuffers(1, &_vertexBuffer);
if (!_vertexBuffer) {
#if !TARGET_OS_IPHONE
glDeleteVertexArrays(1, &_vertexArray);
_vertexArray = 0;
#endif
return NO;
}
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(gVertices), gVertices, GL_DYNAMIC_DRAW);
// Read position attribute from |gVertices| with size of 2 and stride of 4
// beginning at the start of the array. The last argument indicates offset
// of data within |gVertices| as supplied to the vertex buffer.
glVertexAttribPointer(
_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (void*)0);
glEnableVertexAttribArray(_position);
// Read texcoord attribute from |gVertices| with size of 2 and stride of 4
// beginning at the first texcoord in the array. The last argument indicates
// offset of data within |gVertices| as supplied to the vertex buffer.
glVertexAttribPointer(_texcoord,
2,
GL_FLOAT,
GL_FALSE,
4 * sizeof(GLfloat),
(void*)(2 * sizeof(GLfloat)));
glEnableVertexAttribArray(_texcoord);
return YES;
}
@end

View File

@ -1,47 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCPair.h"
@implementation RTCPair
@synthesize key = _key;
@synthesize value = _value;
- (id)initWithKey:(NSString*)key value:(NSString*)value {
if ((self = [super init])) {
_key = [key copy];
_value = [value copy];
}
return self;
}
- (NSString*)description {
return [NSString stringWithFormat:@"%@: %@", _key, _value];
}
@end

View File

@ -1,48 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCPeerConnection.h"
#import "RTCPeerConnectionDelegate.h"
#include "webrtc/api/peerconnectioninterface.h"
@interface RTCPeerConnection (Internal)
@property(nonatomic, assign, readonly)
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peerConnection;
- (instancetype)initWithFactory:(webrtc::PeerConnectionFactoryInterface *)factory
iceServers:(const webrtc::PeerConnectionInterface::IceServers &)iceServers
constraints:(const webrtc::MediaConstraintsInterface *)constraints;
- (instancetype)initWithFactory:(webrtc::PeerConnectionFactoryInterface *)factory
config:(const webrtc::PeerConnectionInterface::RTCConfiguration &)config
constraints:(const webrtc::MediaConstraintsInterface *)constraints
delegate:(id<RTCPeerConnectionDelegate>)delegate;
@end

View File

@ -1,311 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCPeerConnection+Internal.h"
#import "RTCDataChannel+Internal.h"
#import "RTCEnumConverter.h"
#import "RTCICECandidate+Internal.h"
#import "RTCICEServer+Internal.h"
#import "RTCMediaConstraints+Internal.h"
#import "RTCMediaStream+Internal.h"
#import "RTCMediaStreamTrack+Internal.h"
#import "RTCPeerConnectionObserver.h"
#import "RTCSessionDescription+Internal.h"
#import "RTCSessionDescription.h"
#import "RTCSessionDescriptionDelegate.h"
#import "RTCStatsDelegate.h"
#import "RTCStatsReport+Internal.h"
#include <memory>
#include "webrtc/api/jsep.h"
NSString* const kRTCSessionDescriptionDelegateErrorDomain = @"RTCSDPError";
int const kRTCSessionDescriptionDelegateErrorCode = -1;
namespace webrtc {
class RTCCreateSessionDescriptionObserver
: public CreateSessionDescriptionObserver {
public:
RTCCreateSessionDescriptionObserver(
id<RTCSessionDescriptionDelegate> delegate,
RTCPeerConnection* peerConnection) {
_delegate = delegate;
_peerConnection = peerConnection;
}
void OnSuccess(SessionDescriptionInterface* desc) override {
RTCSessionDescription* session =
[[RTCSessionDescription alloc] initWithSessionDescription:desc];
[_delegate peerConnection:_peerConnection
didCreateSessionDescription:session
error:nil];
delete desc;
}
void OnFailure(const std::string& error) override {
NSString* str = @(error.c_str());
NSError* err =
[NSError errorWithDomain:kRTCSessionDescriptionDelegateErrorDomain
code:kRTCSessionDescriptionDelegateErrorCode
userInfo:@{@"error" : str}];
[_delegate peerConnection:_peerConnection
didCreateSessionDescription:nil
error:err];
}
private:
id<RTCSessionDescriptionDelegate> _delegate;
RTCPeerConnection* _peerConnection;
};
class RTCSetSessionDescriptionObserver : public SetSessionDescriptionObserver {
public:
RTCSetSessionDescriptionObserver(id<RTCSessionDescriptionDelegate> delegate,
RTCPeerConnection* peerConnection) {
_delegate = delegate;
_peerConnection = peerConnection;
}
void OnSuccess() override {
[_delegate peerConnection:_peerConnection
didSetSessionDescriptionWithError:nil];
}
void OnFailure(const std::string& error) override {
NSString* str = @(error.c_str());
NSError* err =
[NSError errorWithDomain:kRTCSessionDescriptionDelegateErrorDomain
code:kRTCSessionDescriptionDelegateErrorCode
userInfo:@{@"error" : str}];
[_delegate peerConnection:_peerConnection
didSetSessionDescriptionWithError:err];
}
private:
id<RTCSessionDescriptionDelegate> _delegate;
RTCPeerConnection* _peerConnection;
};
class RTCStatsObserver : public StatsObserver {
public:
RTCStatsObserver(id<RTCStatsDelegate> delegate,
RTCPeerConnection* peerConnection) {
_delegate = delegate;
_peerConnection = peerConnection;
}
void OnComplete(const StatsReports& reports) override {
NSMutableArray* stats = [NSMutableArray arrayWithCapacity:reports.size()];
for (const auto* report : reports) {
RTCStatsReport* statsReport =
[[RTCStatsReport alloc] initWithStatsReport:*report];
[stats addObject:statsReport];
}
[_delegate peerConnection:_peerConnection didGetStats:stats];
}
private:
id<RTCStatsDelegate> _delegate;
RTCPeerConnection* _peerConnection;
};
}
@implementation RTCPeerConnection {
NSMutableArray* _localStreams;
std::unique_ptr<webrtc::RTCPeerConnectionObserver> _observer;
rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection;
}
- (BOOL)addICECandidate:(RTCICECandidate*)candidate {
std::unique_ptr<const webrtc::IceCandidateInterface> iceCandidate(
candidate.candidate);
return self.peerConnection->AddIceCandidate(iceCandidate.get());
}
- (BOOL)addStream:(RTCMediaStream*)stream {
BOOL ret = self.peerConnection->AddStream(stream.mediaStream);
if (!ret) {
return NO;
}
[_localStreams addObject:stream];
return YES;
}
- (RTCDataChannel*)createDataChannelWithLabel:(NSString*)label
config:(RTCDataChannelInit*)config {
std::string labelString([label UTF8String]);
rtc::scoped_refptr<webrtc::DataChannelInterface> dataChannel =
self.peerConnection->CreateDataChannel(labelString,
config.dataChannelInit);
return [[RTCDataChannel alloc] initWithDataChannel:dataChannel];
}
- (void)createAnswerWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
constraints:(RTCMediaConstraints*)constraints {
rtc::scoped_refptr<webrtc::RTCCreateSessionDescriptionObserver>
observer(new rtc::RefCountedObject<
webrtc::RTCCreateSessionDescriptionObserver>(delegate, self));
self.peerConnection->CreateAnswer(observer, constraints.constraints);
}
- (void)createOfferWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
constraints:(RTCMediaConstraints*)constraints {
rtc::scoped_refptr<webrtc::RTCCreateSessionDescriptionObserver>
observer(new rtc::RefCountedObject<
webrtc::RTCCreateSessionDescriptionObserver>(delegate, self));
self.peerConnection->CreateOffer(observer, constraints.constraints);
}
- (void)removeStream:(RTCMediaStream*)stream {
self.peerConnection->RemoveStream(stream.mediaStream);
[_localStreams removeObject:stream];
}
- (void)setLocalDescriptionWithDelegate:
(id<RTCSessionDescriptionDelegate>)delegate
sessionDescription:(RTCSessionDescription*)sdp {
rtc::scoped_refptr<webrtc::RTCSetSessionDescriptionObserver> observer(
new rtc::RefCountedObject<webrtc::RTCSetSessionDescriptionObserver>(
delegate, self));
self.peerConnection->SetLocalDescription(observer, sdp.sessionDescription);
}
- (void)setRemoteDescriptionWithDelegate:
(id<RTCSessionDescriptionDelegate>)delegate
sessionDescription:(RTCSessionDescription*)sdp {
rtc::scoped_refptr<webrtc::RTCSetSessionDescriptionObserver> observer(
new rtc::RefCountedObject<webrtc::RTCSetSessionDescriptionObserver>(
delegate, self));
self.peerConnection->SetRemoteDescription(observer, sdp.sessionDescription);
}
- (BOOL)setConfiguration:(RTCConfiguration *)configuration {
std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config(
[configuration createNativeConfiguration]);
if (!config) {
return NO;
}
return self.peerConnection->SetConfiguration(*config);
}
- (RTCSessionDescription*)localDescription {
const webrtc::SessionDescriptionInterface* sdi =
self.peerConnection->local_description();
return sdi ? [[RTCSessionDescription alloc] initWithSessionDescription:sdi]
: nil;
}
- (NSArray*)localStreams {
return [_localStreams copy];
}
- (RTCSessionDescription*)remoteDescription {
const webrtc::SessionDescriptionInterface* sdi =
self.peerConnection->remote_description();
return sdi ? [[RTCSessionDescription alloc] initWithSessionDescription:sdi]
: nil;
}
- (RTCICEConnectionState)iceConnectionState {
return [RTCEnumConverter
convertIceConnectionStateToObjC:self.peerConnection
->ice_connection_state()];
}
- (RTCICEGatheringState)iceGatheringState {
return [RTCEnumConverter
convertIceGatheringStateToObjC:self.peerConnection
->ice_gathering_state()];
}
- (RTCSignalingState)signalingState {
return [RTCEnumConverter
convertSignalingStateToObjC:self.peerConnection->signaling_state()];
}
- (void)close {
self.peerConnection->Close();
}
- (BOOL)getStatsWithDelegate:(id<RTCStatsDelegate>)delegate
mediaStreamTrack:(RTCMediaStreamTrack*)mediaStreamTrack
statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel {
rtc::scoped_refptr<webrtc::RTCStatsObserver> observer(
new rtc::RefCountedObject<webrtc::RTCStatsObserver>(delegate,
self));
webrtc::PeerConnectionInterface::StatsOutputLevel nativeOutputLevel =
[RTCEnumConverter convertStatsOutputLevelToNative:statsOutputLevel];
return self.peerConnection->GetStats(
observer, mediaStreamTrack.mediaTrack, nativeOutputLevel);
}
@end
@implementation RTCPeerConnection (Internal)
- (instancetype)initWithFactory:(webrtc::PeerConnectionFactoryInterface*)factory
iceServers:(const webrtc::PeerConnectionInterface::IceServers&)iceServers
constraints:(const webrtc::MediaConstraintsInterface*)constraints {
NSParameterAssert(factory != nullptr);
if (self = [super init]) {
webrtc::PeerConnectionInterface::RTCConfiguration config;
config.servers = iceServers;
_observer.reset(new webrtc::RTCPeerConnectionObserver(self));
_peerConnection = factory->CreatePeerConnection(
config, constraints, nullptr, nullptr, _observer.get());
_localStreams = [[NSMutableArray alloc] init];
}
return self;
}
- (instancetype)initWithFactory:(webrtc::PeerConnectionFactoryInterface *)factory
config:(const webrtc::PeerConnectionInterface::RTCConfiguration &)config
constraints:(const webrtc::MediaConstraintsInterface *)constraints
delegate:(id<RTCPeerConnectionDelegate>)delegate {
NSParameterAssert(factory);
if (self = [super init]) {
_observer.reset(new webrtc::RTCPeerConnectionObserver(self));
_peerConnection =
factory->CreatePeerConnection(config, constraints, nullptr, nullptr, _observer.get());
_localStreams = [[NSMutableArray alloc] init];
_delegate = delegate;
}
return self;
}
- (rtc::scoped_refptr<webrtc::PeerConnectionInterface>)peerConnection {
return _peerConnection;
}
@end

View File

@ -1,37 +0,0 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCPeerConnectionFactory.h"
#include "webrtc/api/peerconnectionfactory.h"
@interface RTCPeerConnectionFactory ()
@property(nonatomic, assign) rtc::scoped_refptr<
webrtc::PeerConnectionFactoryInterface> nativeFactory;
@end

View File

@ -1,159 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCPeerConnectionFactory+Internal.h"
#include <memory>
#include <vector>
#import "RTCAudioTrack+Internal.h"
#import "RTCICEServer+Internal.h"
#import "RTCMediaConstraints+Internal.h"
#import "RTCMediaSource+Internal.h"
#import "RTCMediaStream+Internal.h"
#import "RTCMediaStreamTrack+Internal.h"
#import "RTCPeerConnection+Internal.h"
#import "RTCPeerConnectionDelegate.h"
#import "RTCPeerConnectionInterface+Internal.h"
#import "RTCVideoCapturer+Internal.h"
#import "RTCVideoSource+Internal.h"
#import "RTCVideoTrack+Internal.h"
#include "webrtc/api/audiotrack.h"
#include "webrtc/api/mediastreaminterface.h"
#include "webrtc/api/peerconnectioninterface.h"
#include "webrtc/api/videotrack.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/ssladapter.h"
@implementation RTCPeerConnectionFactory {
std::unique_ptr<rtc::Thread> _networkThread;
std::unique_ptr<rtc::Thread> _workerThread;
std::unique_ptr<rtc::Thread> _signalingThread;
}
@synthesize nativeFactory = _nativeFactory;
+ (void)initializeSSL {
BOOL initialized = rtc::InitializeSSL();
NSAssert(initialized, @"Failed to initialize SSL library");
}
+ (void)deinitializeSSL {
BOOL deinitialized = rtc::CleanupSSL();
NSAssert(deinitialized, @"Failed to deinitialize SSL library");
}
- (id)init {
if ((self = [super init])) {
_networkThread = rtc::Thread::CreateWithSocketServer();
BOOL result = _networkThread->Start();
NSAssert(result, @"Failed to start network thread.");
_workerThread = rtc::Thread::Create();
result = _workerThread->Start();
NSAssert(result, @"Failed to start worker thread.");
_signalingThread = rtc::Thread::Create();
result = _signalingThread->Start();
NSAssert(result, @"Failed to start signaling thread.");
_nativeFactory = webrtc::CreatePeerConnectionFactory(
_networkThread.get(), _workerThread.get(), _signalingThread.get(),
nullptr, nullptr, nullptr);
NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
// Uncomment to get sensitive logs emitted (to stderr or logcat).
// rtc::LogMessage::LogToDebug(rtc::LS_SENSITIVE);
}
return self;
}
- (RTCPeerConnection *)peerConnectionWithConfiguration:(RTCConfiguration *)configuration
constraints:(RTCMediaConstraints *)constraints
delegate:(id<RTCPeerConnectionDelegate>)delegate {
std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config(
[configuration createNativeConfiguration]);
if (!config) {
return nil;
}
return [[RTCPeerConnection alloc] initWithFactory:self.nativeFactory.get()
config:*config
constraints:constraints.constraints
delegate:delegate];
}
- (RTCPeerConnection*)
peerConnectionWithICEServers:(NSArray*)servers
constraints:(RTCMediaConstraints*)constraints
delegate:(id<RTCPeerConnectionDelegate>)delegate {
webrtc::PeerConnectionInterface::IceServers iceServers;
for (RTCICEServer* server in servers) {
iceServers.push_back(server.iceServer);
}
RTCPeerConnection* pc =
[[RTCPeerConnection alloc] initWithFactory:self.nativeFactory.get()
iceServers:iceServers
constraints:constraints.constraints];
pc.delegate = delegate;
return pc;
}
- (RTCMediaStream*)mediaStreamWithLabel:(NSString*)label {
rtc::scoped_refptr<webrtc::MediaStreamInterface> nativeMediaStream =
self.nativeFactory->CreateLocalMediaStream([label UTF8String]);
return [[RTCMediaStream alloc] initWithMediaStream:nativeMediaStream];
}
- (RTCVideoSource*)videoSourceWithCapturer:(RTCVideoCapturer*)capturer
constraints:(RTCMediaConstraints*)constraints {
if (!capturer) {
return nil;
}
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source =
self.nativeFactory->CreateVideoSource([capturer takeNativeCapturer], constraints.constraints);
return [[RTCVideoSource alloc] initWithMediaSource:source];
}
- (RTCVideoTrack*)videoTrackWithID:(NSString*)videoId
source:(RTCVideoSource*)source {
rtc::scoped_refptr<webrtc::VideoTrackInterface> track =
self.nativeFactory->CreateVideoTrack([videoId UTF8String],
source.videoSource);
return [[RTCVideoTrack alloc] initWithMediaTrack:track];
}
- (RTCAudioTrack*)audioTrackWithID:(NSString*)audioId {
rtc::scoped_refptr<webrtc::AudioTrackInterface> track =
self.nativeFactory->CreateAudioTrack([audioId UTF8String], NULL);
return [[RTCAudioTrack alloc] initWithMediaTrack:track];
}
@end

View File

@ -1,39 +0,0 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "talk/app/webrtc/objc/public/RTCPeerConnectionInterface.h"
#include "webrtc/api/peerconnectioninterface.h"
@interface RTCConfiguration ()
+ (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:(RTCEncryptionKeyType)keyType;
- (webrtc::PeerConnectionInterface::RTCConfiguration *)
createNativeConfiguration;
@end

View File

@ -1,133 +0,0 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "talk/app/webrtc/objc/RTCPeerConnectionInterface+Internal.h"
#import "talk/app/webrtc/objc/RTCEnumConverter.h"
#import "talk/app/webrtc/objc/RTCICEServer+Internal.h"
#import "talk/app/webrtc/objc/public/RTCLogging.h"
#include <memory>
#include "webrtc/base/rtccertificategenerator.h"
@implementation RTCConfiguration
@synthesize iceTransportsType = _iceTransportsType;
@synthesize iceServers = _iceServers;
@synthesize bundlePolicy = _bundlePolicy;
@synthesize rtcpMuxPolicy = _rtcpMuxPolicy;
@synthesize tcpCandidatePolicy = _tcpCandidatePolicy;
@synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets;
@synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout;
@synthesize iceBackupCandidatePairPingInterval = _iceBackupCandidatePairPingInterval;
@synthesize keyType = _keyType;
- (instancetype)init {
if (self = [super init]) {
// Copy defaults.
webrtc::PeerConnectionInterface::RTCConfiguration config;
_iceTransportsType = [RTCEnumConverter iceTransportsTypeForNativeEnum:config.type];
_bundlePolicy = [RTCEnumConverter bundlePolicyForNativeEnum:config.bundle_policy];
_rtcpMuxPolicy = [RTCEnumConverter rtcpMuxPolicyForNativeEnum:config.rtcp_mux_policy];
_tcpCandidatePolicy =
[RTCEnumConverter tcpCandidatePolicyForNativeEnum:config.tcp_candidate_policy];
_audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets;
_iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout;
_iceBackupCandidatePairPingInterval = config.ice_backup_candidate_pair_ping_interval;
_keyType = kRTCEncryptionKeyTypeECDSA;
}
return self;
}
- (instancetype)initWithIceTransportsType:(RTCIceTransportsType)iceTransportsType
bundlePolicy:(RTCBundlePolicy)bundlePolicy
rtcpMuxPolicy:(RTCRtcpMuxPolicy)rtcpMuxPolicy
tcpCandidatePolicy:(RTCTcpCandidatePolicy)tcpCandidatePolicy
audioJitterBufferMaxPackets:(int)audioJitterBufferMaxPackets
iceConnectionReceivingTimeout:(int)iceConnectionReceivingTimeout
iceBackupCandidatePairPingInterval:(int)iceBackupCandidatePairPingInterval {
if (self = [super init]) {
_iceTransportsType = iceTransportsType;
_bundlePolicy = bundlePolicy;
_rtcpMuxPolicy = rtcpMuxPolicy;
_tcpCandidatePolicy = tcpCandidatePolicy;
_audioJitterBufferMaxPackets = audioJitterBufferMaxPackets;
_iceConnectionReceivingTimeout = iceConnectionReceivingTimeout;
_iceBackupCandidatePairPingInterval = iceBackupCandidatePairPingInterval;
}
return self;
}
#pragma mark - Private
- (webrtc::PeerConnectionInterface::RTCConfiguration *)
createNativeConfiguration {
std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration>
nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration());
nativeConfig->type =
[RTCEnumConverter nativeEnumForIceTransportsType:_iceTransportsType];
for (RTCICEServer *iceServer : _iceServers) {
nativeConfig->servers.push_back(iceServer.iceServer);
}
nativeConfig->bundle_policy =
[RTCEnumConverter nativeEnumForBundlePolicy:_bundlePolicy];
nativeConfig->rtcp_mux_policy =
[RTCEnumConverter nativeEnumForRtcpMuxPolicy:_rtcpMuxPolicy];
nativeConfig->tcp_candidate_policy =
[RTCEnumConverter nativeEnumForTcpCandidatePolicy:_tcpCandidatePolicy];
nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets;
nativeConfig->ice_connection_receiving_timeout =
_iceConnectionReceivingTimeout;
nativeConfig->ice_backup_candidate_pair_ping_interval =
_iceBackupCandidatePairPingInterval;
rtc::KeyType keyType =
[[self class] nativeEncryptionKeyTypeForKeyType:_keyType];
if (keyType != rtc::KT_DEFAULT) {
rtc::scoped_refptr<rtc::RTCCertificate> certificate =
rtc::RTCCertificateGenerator::GenerateCertificate(
rtc::KeyParams(keyType), rtc::Optional<uint64_t>());
if (!certificate) {
RTCLogError(@"Failed to generate certificate.");
return nullptr;
}
nativeConfig->certificates.push_back(certificate);
}
return nativeConfig.release();
}
+ (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:
(RTCEncryptionKeyType)keyType {
switch (keyType) {
case kRTCEncryptionKeyTypeRSA:
return rtc::KT_RSA;
case kRTCEncryptionKeyTypeECDSA:
return rtc::KT_ECDSA;
}
}
@end

View File

@ -1,75 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "webrtc/api/peerconnectioninterface.h"
#import "RTCPeerConnection.h"
#import "RTCPeerConnectionDelegate.h"
// These objects are created by RTCPeerConnectionFactory to wrap an
// id<RTCPeerConnectionDelegate> and call methods on that interface.
namespace webrtc {
class RTCPeerConnectionObserver : public PeerConnectionObserver {
public:
RTCPeerConnectionObserver(RTCPeerConnection* peerConnection);
virtual ~RTCPeerConnectionObserver();
// Triggered when the SignalingState changed.
void OnSignalingChange(
PeerConnectionInterface::SignalingState new_state) override;
// Triggered when media is received on a new stream from remote peer.
void OnAddStream(MediaStreamInterface* stream) override;
// Triggered when a remote peer close a stream.
void OnRemoveStream(MediaStreamInterface* stream) override;
// Triggered when a remote peer open a data channel.
void OnDataChannel(DataChannelInterface* data_channel) override;
// Triggered when renegotiation is needed, for example the ICE has restarted.
void OnRenegotiationNeeded() override;
// Called any time the ICEConnectionState changes
void OnIceConnectionChange(
PeerConnectionInterface::IceConnectionState new_state) override;
// Called any time the ICEGatheringState changes
void OnIceGatheringChange(
PeerConnectionInterface::IceGatheringState new_state) override;
// New Ice candidate have been found.
void OnIceCandidate(const IceCandidateInterface* candidate) override;
private:
__weak RTCPeerConnection* _peerConnection;
};
} // namespace webrtc

View File

@ -1,108 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCPeerConnectionObserver.h"
#import "RTCDataChannel+Internal.h"
#import "RTCEnumConverter.h"
#import "RTCICECandidate+Internal.h"
#import "RTCMediaStream+Internal.h"
namespace webrtc {
RTCPeerConnectionObserver::RTCPeerConnectionObserver(
RTCPeerConnection* peerConnection) {
_peerConnection = peerConnection;
}
RTCPeerConnectionObserver::~RTCPeerConnectionObserver() {
}
void RTCPeerConnectionObserver::OnSignalingChange(
PeerConnectionInterface::SignalingState new_state) {
RTCSignalingState state =
[RTCEnumConverter convertSignalingStateToObjC:new_state];
[_peerConnection.delegate peerConnection:_peerConnection
signalingStateChanged:state];
}
void RTCPeerConnectionObserver::OnAddStream(MediaStreamInterface* stream) {
RTCMediaStream* mediaStream =
[[RTCMediaStream alloc] initWithMediaStream:stream];
[_peerConnection.delegate peerConnection:_peerConnection
addedStream:mediaStream];
}
void RTCPeerConnectionObserver::OnRemoveStream(MediaStreamInterface* stream) {
RTCMediaStream* mediaStream =
[[RTCMediaStream alloc] initWithMediaStream:stream];
[_peerConnection.delegate peerConnection:_peerConnection
removedStream:mediaStream];
}
void RTCPeerConnectionObserver::OnDataChannel(
DataChannelInterface* data_channel) {
RTCDataChannel* dataChannel =
[[RTCDataChannel alloc] initWithDataChannel:data_channel];
[_peerConnection.delegate peerConnection:_peerConnection
didOpenDataChannel:dataChannel];
}
void RTCPeerConnectionObserver::OnRenegotiationNeeded() {
id<RTCPeerConnectionDelegate> delegate = _peerConnection.delegate;
[delegate peerConnectionOnRenegotiationNeeded:_peerConnection];
}
void RTCPeerConnectionObserver::OnIceConnectionChange(
PeerConnectionInterface::IceConnectionState new_state) {
RTCICEConnectionState state =
[RTCEnumConverter convertIceConnectionStateToObjC:new_state];
[_peerConnection.delegate peerConnection:_peerConnection
iceConnectionChanged:state];
}
void RTCPeerConnectionObserver::OnIceGatheringChange(
PeerConnectionInterface::IceGatheringState new_state) {
RTCICEGatheringState state =
[RTCEnumConverter convertIceGatheringStateToObjC:new_state];
[_peerConnection.delegate peerConnection:_peerConnection
iceGatheringChanged:state];
}
void RTCPeerConnectionObserver::OnIceCandidate(
const IceCandidateInterface* candidate) {
RTCICECandidate* iceCandidate =
[[RTCICECandidate alloc] initWithCandidate:candidate];
[_peerConnection.delegate peerConnection:_peerConnection
gotICECandidate:iceCandidate];
}
} // namespace webrtc

View File

@ -1,41 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCSessionDescription.h"
#include "webrtc/api/jsep.h"
#include "webrtc/api/webrtcsession.h"
@interface RTCSessionDescription (Internal)
// Caller assumes ownership of this object!
- (webrtc::SessionDescriptionInterface *)sessionDescription;
- (id)initWithSessionDescription:
(const webrtc::SessionDescriptionInterface*)sessionDescription;
@end

View File

@ -1,81 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCSessionDescription+Internal.h"
@implementation RTCSessionDescription
@synthesize description = _description;
@synthesize type = _type;
- (id)initWithType:(NSString*)type sdp:(NSString*)sdp {
if (!type || !sdp) {
NSAssert(NO, @"nil arguments not allowed");
return nil;
}
if ((self = [super init])) {
_description = sdp;
_type = type;
}
return self;
}
@end
@implementation RTCSessionDescription (Internal)
- (id)initWithSessionDescription:
(const webrtc::SessionDescriptionInterface*)sessionDescription {
if (!sessionDescription) {
NSAssert(NO, @"nil arguments not allowed");
self = nil;
return nil;
}
if ((self = [super init])) {
const std::string& type = sessionDescription->type();
std::string sdp;
if (!sessionDescription->ToString(&sdp)) {
NSAssert(NO, @"Invalid SessionDescriptionInterface.");
self = nil;
} else {
_description = @(sdp.c_str());
_type = @(type.c_str());
}
}
return self;
}
- (webrtc::SessionDescriptionInterface*)sessionDescription {
return webrtc::CreateSessionDescription(
[self.type UTF8String], [self.description UTF8String], NULL);
}
@end

View File

@ -1,36 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCStatsReport.h"
#include "webrtc/api/statstypes.h"
@interface RTCStatsReport (Internal)
- (instancetype)initWithStatsReport:(const webrtc::StatsReport&)statsReport;
@end

View File

@ -1,69 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCStatsReport+Internal.h"
#import "RTCPair.h"
@implementation RTCStatsReport
- (NSString*)description {
NSString* format = @"id: %@, type: %@, timestamp: %f, values: %@";
return [NSString stringWithFormat:format,
self.reportId,
self.type,
self.timestamp,
self.values];
}
@end
@implementation RTCStatsReport (Internal)
- (instancetype)initWithStatsReport:(const webrtc::StatsReport&)statsReport {
if (self = [super init]) {
_reportId = @(statsReport.id()->ToString().c_str());
_type = @(statsReport.TypeToString());
_timestamp = statsReport.timestamp();
NSMutableArray* values =
[NSMutableArray arrayWithCapacity:statsReport.values().size()];
for (const auto& it : statsReport.values()) {
RTCPair* pair =
[[RTCPair alloc] initWithKey:@(it.second->display_name())
value:@(it.second->ToString().c_str())];
[values addObject:pair];
}
_values = values;
}
return self;
}
@end

View File

@ -1,38 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCVideoCapturer.h"
#include "webrtc/api/mediastreaminterface.h"
@interface RTCVideoCapturer (Internal)
- (cricket::VideoCapturer*)takeNativeCapturer;
- (id)initWithCapturer:(cricket::VideoCapturer*)capturer;
@end

View File

@ -1,67 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCVideoCapturer+Internal.h"
#include <memory>
#include "webrtc/media/base/videocapturer.h"
#include "webrtc/media/engine/webrtcvideocapturerfactory.h"
@implementation RTCVideoCapturer {
std::unique_ptr<cricket::VideoCapturer> _capturer;
}
+ (RTCVideoCapturer*)capturerWithDeviceName:(NSString*)deviceName {
cricket::WebRtcVideoDeviceCapturerFactory factory;
cricket::Device device(std::string(deviceName.UTF8String), 0);
std::unique_ptr<cricket::VideoCapturer> capturer(factory.Create(device));
RTCVideoCapturer* rtcCapturer =
[[RTCVideoCapturer alloc] initWithCapturer:capturer.release()];
return rtcCapturer;
}
@end
@implementation RTCVideoCapturer (Internal)
- (id)initWithCapturer:(cricket::VideoCapturer*)capturer {
if ((self = [super init])) {
_capturer.reset(capturer);
}
return self;
}
- (cricket::VideoCapturer*)takeNativeCapturer {
return _capturer.release();
}
@end

View File

@ -1,40 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCVideoRenderer.h"
#include "webrtc/api/mediastreaminterface.h"
@interface RTCVideoRendererAdapter : NSObject
@property(nonatomic, readonly) id<RTCVideoRenderer> videoRenderer;
@property(nonatomic, readonly)
rtc::VideoSinkInterface<cricket::VideoFrame> *nativeVideoRenderer;
- (instancetype)initWithVideoRenderer:(id<RTCVideoRenderer>)videoRenderer;
@end

View File

@ -1,82 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCI420Frame+Internal.h"
#import "RTCVideoRendererAdapter.h"
#include <memory>
namespace webrtc {
class RTCVideoRendererNativeAdapter
: public rtc::VideoSinkInterface<cricket::VideoFrame> {
public:
RTCVideoRendererNativeAdapter(RTCVideoRendererAdapter* adapter) {
_adapter = adapter;
_size = CGSizeZero;
}
void OnFrame(const cricket::VideoFrame& videoFrame) override {
const cricket::VideoFrame* frame = videoFrame.GetCopyWithRotationApplied();
CGSize currentSize = CGSizeMake(frame->width(), frame->height());
if (!CGSizeEqualToSize(_size, currentSize)) {
_size = currentSize;
[_adapter.videoRenderer setSize:_size];
}
RTCI420Frame* i420Frame = [[RTCI420Frame alloc] initWithVideoFrame:frame];
[_adapter.videoRenderer renderFrame:i420Frame];
}
private:
__weak RTCVideoRendererAdapter* _adapter;
CGSize _size;
};
}
@implementation RTCVideoRendererAdapter {
id<RTCVideoRenderer> _videoRenderer;
std::unique_ptr<webrtc::RTCVideoRendererNativeAdapter> _adapter;
}
- (instancetype)initWithVideoRenderer:(id<RTCVideoRenderer>)videoRenderer {
NSParameterAssert(videoRenderer);
if (self = [super init]) {
_videoRenderer = videoRenderer;
_adapter.reset(new webrtc::RTCVideoRendererNativeAdapter(self));
}
return self;
}
- (rtc::VideoSinkInterface<cricket::VideoFrame> *)nativeVideoRenderer {
return _adapter.get();
}
@end

View File

@ -1,37 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCVideoSource.h"
#include "webrtc/api/mediastreaminterface.h"
@interface RTCVideoSource (Internal)
@property(nonatomic, assign, readonly) rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>
videoSource;
@end

View File

@ -1,44 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCMediaSource+Internal.h"
#import "RTCVideoSource+Internal.h"
@implementation RTCVideoSource
@end
@implementation RTCVideoSource (Internal)
- (rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)videoSource {
return static_cast<webrtc::VideoTrackSourceInterface *>(self.mediaSource.get());
}
@end

View File

@ -1,40 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCVideoTrack.h"
#include "webrtc/api/mediastreaminterface.h"
#include "webrtc/api/peerconnectioninterface.h"
@class RTCVideoRenderer;
@interface RTCVideoTrack (Internal)
@property(nonatomic, readonly)
rtc::scoped_refptr<webrtc::VideoTrackInterface> nativeVideoTrack;
@end

View File

@ -1,123 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCVideoTrack+Internal.h"
#import "RTCMediaSource+Internal.h"
#import "RTCMediaStreamTrack+Internal.h"
#import "RTCPeerConnectionFactory+Internal.h"
#import "RTCVideoRendererAdapter.h"
#import "RTCVideoSource+Internal.h"
@implementation RTCVideoTrack {
NSMutableArray* _adapters;
}
@synthesize source = _source;
- (instancetype)initWithFactory:(RTCPeerConnectionFactory*)factory
source:(RTCVideoSource*)source
trackId:(NSString*)trackId {
NSParameterAssert(factory);
NSParameterAssert(source);
NSParameterAssert(trackId.length);
rtc::scoped_refptr<webrtc::VideoTrackInterface> track =
factory.nativeFactory->CreateVideoTrack([trackId UTF8String],
source.videoSource);
if (self = [super initWithMediaTrack:track]) {
[self configure];
_source = source;
}
return self;
}
- (instancetype)initWithMediaTrack:
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)mediaTrack {
if (self = [super initWithMediaTrack:mediaTrack]) {
[self configure];
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source =
self.nativeVideoTrack->GetSource();
if (source) {
_source = [[RTCVideoSource alloc] initWithMediaSource:source.get()];
}
}
return self;
}
- (void)configure {
_adapters = [NSMutableArray array];
}
- (void)dealloc {
for (RTCVideoRendererAdapter *adapter in _adapters) {
self.nativeVideoTrack->RemoveSink(adapter.nativeVideoRenderer);
}
}
- (void)addRenderer:(id<RTCVideoRenderer>)renderer {
// Make sure we don't have this renderer yet.
for (RTCVideoRendererAdapter* adapter in _adapters) {
NSParameterAssert(adapter.videoRenderer != renderer);
}
// Create a wrapper that provides a native pointer for us.
RTCVideoRendererAdapter* adapter =
[[RTCVideoRendererAdapter alloc] initWithVideoRenderer:renderer];
[_adapters addObject:adapter];
self.nativeVideoTrack->AddOrUpdateSink(adapter.nativeVideoRenderer,
rtc::VideoSinkWants());
}
- (void)removeRenderer:(id<RTCVideoRenderer>)renderer {
RTCVideoRendererAdapter* adapter = nil;
NSUInteger indexToRemove = NSNotFound;
for (NSUInteger i = 0; i < _adapters.count; i++) {
adapter = _adapters[i];
if (adapter.videoRenderer == renderer) {
indexToRemove = i;
break;
}
}
if (indexToRemove == NSNotFound) {
return;
}
self.nativeVideoTrack->RemoveSink(adapter.nativeVideoRenderer);
[_adapters removeObjectAtIndex:indexToRemove];
}
@end
@implementation RTCVideoTrack (Internal)
- (rtc::scoped_refptr<webrtc::VideoTrackInterface>)nativeVideoTrack {
return static_cast<webrtc::VideoTrackInterface*>(self.mediaTrack.get());
}
@end

View File

@ -1,89 +0,0 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TALK_APP_WEBRTC_OBJC_AVFOUNDATION_VIDEO_CAPTURER_H_
#define TALK_APP_WEBRTC_OBJC_AVFOUNDATION_VIDEO_CAPTURER_H_
#include "webrtc/media/base/videocapturer.h"
#include "webrtc/video_frame.h"
#import <AVFoundation/AVFoundation.h>
@class RTCAVFoundationVideoCapturerInternal;
namespace rtc {
class Thread;
} // namespace rtc
namespace webrtc {
class AVFoundationVideoCapturer : public cricket::VideoCapturer,
public rtc::MessageHandler {
public:
AVFoundationVideoCapturer();
~AVFoundationVideoCapturer();
cricket::CaptureState Start(const cricket::VideoFormat& format) override;
void Stop() override;
bool IsRunning() override;
bool IsScreencast() const override {
return false;
}
bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override {
fourccs->push_back(cricket::FOURCC_NV12);
return true;
}
// Returns the active capture session. Calls to the capture session should
// occur on the RTCDispatcherTypeCaptureSession queue in RTCDispatcher.
AVCaptureSession* GetCaptureSession();
// Returns whether the rear-facing camera can be used.
// e.g. It can't be used because it doesn't exist.
bool CanUseBackCamera() const;
// Switches the camera being used (either front or back).
void SetUseBackCamera(bool useBackCamera);
bool GetUseBackCamera() const;
// Converts the sample buffer into a cricket::CapturedFrame and signals the
// frame for capture.
void CaptureSampleBuffer(CMSampleBufferRef sampleBuffer);
// Handles messages from posts.
void OnMessage(rtc::Message *msg) override;
private:
void OnFrameMessage(CVImageBufferRef image_buffer, int64_t capture_time);
RTCAVFoundationVideoCapturerInternal* _capturer;
rtc::Thread* _startThread; // Set in Start(), unset in Stop().
}; // AVFoundationVideoCapturer
} // namespace webrtc
#endif // TALK_APP_WEBRTC_OBJC_AVFOUNDATION_CAPTURER_H_

View File

@ -1,562 +0,0 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "talk/app/webrtc/objc/avfoundationvideocapturer.h"
#include "webrtc/base/bind.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/thread.h"
#import <AVFoundation/AVFoundation.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "RTCDispatcher+Private.h"
#import "RTCLogging.h"
// TODO(tkchin): support other formats.
static NSString *const kDefaultPreset = AVCaptureSessionPreset640x480;
static cricket::VideoFormat const kDefaultFormat =
cricket::VideoFormat(640,
480,
cricket::VideoFormat::FpsToInterval(30),
cricket::FOURCC_NV12);
// This class used to capture frames using AVFoundation APIs on iOS. It is meant
// to be owned by an instance of AVFoundationVideoCapturer. The reason for this
// because other webrtc objects own cricket::VideoCapturer, which is not
// ref counted. To prevent bad behavior we do not expose this class directly.
@interface RTCAVFoundationVideoCapturerInternal : NSObject
<AVCaptureVideoDataOutputSampleBufferDelegate>
@property(nonatomic, readonly) AVCaptureSession *captureSession;
@property(nonatomic, readonly) BOOL isRunning;
@property(nonatomic, readonly) BOOL canUseBackCamera;
@property(nonatomic, assign) BOOL useBackCamera; // Defaults to NO.
// We keep a pointer back to AVFoundationVideoCapturer to make callbacks on it
// when we receive frames. This is safe because this object should be owned by
// it.
- (instancetype)initWithCapturer:(webrtc::AVFoundationVideoCapturer *)capturer;
// Starts and stops the capture session asynchronously. We cannot do this
// synchronously without blocking a WebRTC thread.
- (void)start;
- (void)stop;
@end
@implementation RTCAVFoundationVideoCapturerInternal {
// Keep pointers to inputs for convenience.
AVCaptureDeviceInput *_frontCameraInput;
AVCaptureDeviceInput *_backCameraInput;
AVCaptureVideoDataOutput *_videoDataOutput;
// The cricket::VideoCapturer that owns this class. Should never be NULL.
webrtc::AVFoundationVideoCapturer *_capturer;
BOOL _orientationHasChanged;
}
@synthesize captureSession = _captureSession;
@synthesize isRunning = _isRunning;
@synthesize useBackCamera = _useBackCamera;
// This is called from the thread that creates the video source, which is likely
// the main thread.
- (instancetype)initWithCapturer:(webrtc::AVFoundationVideoCapturer *)capturer {
RTC_DCHECK(capturer);
if (self = [super init]) {
_capturer = capturer;
// Create the capture session and all relevant inputs and outputs. We need
// to do this in init because the application may want the capture session
// before we start the capturer for e.g. AVCapturePreviewLayer. All objects
// created here are retained until dealloc and never recreated.
if (![self setupCaptureSession]) {
return nil;
}
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self
selector:@selector(deviceOrientationDidChange:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
[center addObserverForName:AVCaptureSessionRuntimeErrorNotification
object:nil
queue:nil
usingBlock:^(NSNotification *notification) {
RTCLogError(@"Capture session error: %@", notification.userInfo);
}];
}
return self;
}
- (void)dealloc {
RTC_DCHECK(!_isRunning);
[[NSNotificationCenter defaultCenter] removeObserver:self];
_capturer = nullptr;
}
- (AVCaptureSession *)captureSession {
return _captureSession;
}
// Called from any thread (likely main thread).
- (BOOL)canUseBackCamera {
return _backCameraInput != nil;
}
// Called from any thread (likely main thread).
- (BOOL)useBackCamera {
@synchronized(self) {
return _useBackCamera;
}
}
// Called from any thread (likely main thread).
- (void)setUseBackCamera:(BOOL)useBackCamera {
if (!self.canUseBackCamera) {
if (useBackCamera) {
RTCLogWarning(@"No rear-facing camera exists or it cannot be used;"
"not switching.");
}
return;
}
@synchronized(self) {
if (_useBackCamera == useBackCamera) {
return;
}
_useBackCamera = useBackCamera;
[self updateSessionInputForUseBackCamera:useBackCamera];
}
}
// Called from WebRTC thread.
- (void)start {
if (_isRunning) {
return;
}
_isRunning = YES;
[RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession
block:^{
_orientationHasChanged = NO;
[self updateOrientation];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
AVCaptureSession *captureSession = self.captureSession;
[captureSession startRunning];
}];
}
// Called from same thread as start.
- (void)stop {
if (!_isRunning) {
return;
}
_isRunning = NO;
[RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession
block:^{
[_videoDataOutput setSampleBufferDelegate:nil queue:nullptr];
[_captureSession stopRunning];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
}];
}
#pragma mark AVCaptureVideoDataOutputSampleBufferDelegate
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection {
NSParameterAssert(captureOutput == _videoDataOutput);
if (!_isRunning) {
return;
}
_capturer->CaptureSampleBuffer(sampleBuffer);
}
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didDropSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection {
RTCLogError(@"Dropped sample buffer.");
}
#pragma mark - Private
- (BOOL)setupCaptureSession {
AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];
#if defined(__IPHONE_7_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0
NSString *version = [[UIDevice currentDevice] systemVersion];
if ([version integerValue] >= 7) {
captureSession.usesApplicationAudioSession = NO;
}
#endif
if (![captureSession canSetSessionPreset:kDefaultPreset]) {
RTCLogError(@"Session preset unsupported.");
return NO;
}
captureSession.sessionPreset = kDefaultPreset;
// Add the output.
AVCaptureVideoDataOutput *videoDataOutput = [self videoDataOutput];
if (![captureSession canAddOutput:videoDataOutput]) {
RTCLogError(@"Video data output unsupported.");
return NO;
}
[captureSession addOutput:videoDataOutput];
// Get the front and back cameras. If there isn't a front camera
// give up.
AVCaptureDeviceInput *frontCameraInput = [self frontCameraInput];
AVCaptureDeviceInput *backCameraInput = [self backCameraInput];
if (!frontCameraInput) {
RTCLogError(@"No front camera for capture session.");
return NO;
}
// Add the inputs.
if (![captureSession canAddInput:frontCameraInput] ||
(backCameraInput && ![captureSession canAddInput:backCameraInput])) {
RTCLogError(@"Session does not support capture inputs.");
return NO;
}
AVCaptureDeviceInput *input = self.useBackCamera ?
backCameraInput : frontCameraInput;
[captureSession addInput:input];
_captureSession = captureSession;
return YES;
}
- (AVCaptureVideoDataOutput *)videoDataOutput {
if (!_videoDataOutput) {
// Make the capturer output NV12. Ideally we want I420 but that's not
// currently supported on iPhone / iPad.
AVCaptureVideoDataOutput *videoDataOutput =
[[AVCaptureVideoDataOutput alloc] init];
videoDataOutput = [[AVCaptureVideoDataOutput alloc] init];
videoDataOutput.videoSettings = @{
(NSString *)kCVPixelBufferPixelFormatTypeKey :
@(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange)
};
videoDataOutput.alwaysDiscardsLateVideoFrames = NO;
dispatch_queue_t queue =
[RTCDispatcher dispatchQueueForType:RTCDispatcherTypeCaptureSession];
[videoDataOutput setSampleBufferDelegate:self queue:queue];
_videoDataOutput = videoDataOutput;
}
return _videoDataOutput;
}
- (AVCaptureDevice *)videoCaptureDeviceForPosition:
(AVCaptureDevicePosition)position {
for (AVCaptureDevice *captureDevice in
[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) {
if (captureDevice.position == position) {
return captureDevice;
}
}
return nil;
}
- (AVCaptureDeviceInput *)frontCameraInput {
if (!_frontCameraInput) {
AVCaptureDevice *frontCameraDevice =
[self videoCaptureDeviceForPosition:AVCaptureDevicePositionFront];
if (!frontCameraDevice) {
RTCLogWarning(@"Failed to find front capture device.");
return nil;
}
NSError *error = nil;
AVCaptureDeviceInput *frontCameraInput =
[AVCaptureDeviceInput deviceInputWithDevice:frontCameraDevice
error:&error];
if (!frontCameraInput) {
RTCLogError(@"Failed to create front camera input: %@",
error.localizedDescription);
return nil;
}
_frontCameraInput = frontCameraInput;
}
return _frontCameraInput;
}
- (AVCaptureDeviceInput *)backCameraInput {
if (!_backCameraInput) {
AVCaptureDevice *backCameraDevice =
[self videoCaptureDeviceForPosition:AVCaptureDevicePositionBack];
if (!backCameraDevice) {
RTCLogWarning(@"Failed to find front capture device.");
return nil;
}
NSError *error = nil;
AVCaptureDeviceInput *backCameraInput =
[AVCaptureDeviceInput deviceInputWithDevice:backCameraDevice
error:&error];
if (!backCameraInput) {
RTCLogError(@"Failed to create front camera input: %@",
error.localizedDescription);
return nil;
}
_backCameraInput = backCameraInput;
}
return _backCameraInput;
}
- (void)deviceOrientationDidChange:(NSNotification *)notification {
[RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession
block:^{
_orientationHasChanged = YES;
[self updateOrientation];
}];
}
// Called from capture session queue.
- (void)updateOrientation {
AVCaptureConnection *connection =
[_videoDataOutput connectionWithMediaType:AVMediaTypeVideo];
if (!connection.supportsVideoOrientation) {
// TODO(tkchin): set rotation bit on frames.
return;
}
AVCaptureVideoOrientation orientation = AVCaptureVideoOrientationPortrait;
switch ([UIDevice currentDevice].orientation) {
case UIDeviceOrientationPortrait:
orientation = AVCaptureVideoOrientationPortrait;
break;
case UIDeviceOrientationPortraitUpsideDown:
orientation = AVCaptureVideoOrientationPortraitUpsideDown;
break;
case UIDeviceOrientationLandscapeLeft:
orientation = AVCaptureVideoOrientationLandscapeRight;
break;
case UIDeviceOrientationLandscapeRight:
orientation = AVCaptureVideoOrientationLandscapeLeft;
break;
case UIDeviceOrientationFaceUp:
case UIDeviceOrientationFaceDown:
case UIDeviceOrientationUnknown:
if (!_orientationHasChanged) {
connection.videoOrientation = orientation;
}
return;
}
connection.videoOrientation = orientation;
}
// Update the current session input to match what's stored in _useBackCamera.
- (void)updateSessionInputForUseBackCamera:(BOOL)useBackCamera {
[RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeCaptureSession
block:^{
[_captureSession beginConfiguration];
AVCaptureDeviceInput *oldInput = _backCameraInput;
AVCaptureDeviceInput *newInput = _frontCameraInput;
if (useBackCamera) {
oldInput = _frontCameraInput;
newInput = _backCameraInput;
}
if (oldInput) {
// Ok to remove this even if it's not attached. Will be no-op.
[_captureSession removeInput:oldInput];
}
if (newInput) {
[_captureSession addInput:newInput];
}
[self updateOrientation];
[_captureSession commitConfiguration];
}];
}
@end
namespace webrtc {
enum AVFoundationVideoCapturerMessageType : uint32_t {
kMessageTypeFrame,
};
struct AVFoundationFrame {
AVFoundationFrame(CVImageBufferRef buffer, int64_t time)
: image_buffer(buffer), capture_time(time) {}
CVImageBufferRef image_buffer;
int64_t capture_time;
};
AVFoundationVideoCapturer::AVFoundationVideoCapturer()
: _capturer(nil), _startThread(nullptr) {
// Set our supported formats. This matches kDefaultPreset.
std::vector<cricket::VideoFormat> supportedFormats;
supportedFormats.push_back(cricket::VideoFormat(kDefaultFormat));
SetSupportedFormats(supportedFormats);
_capturer =
[[RTCAVFoundationVideoCapturerInternal alloc] initWithCapturer:this];
}
AVFoundationVideoCapturer::~AVFoundationVideoCapturer() {
_capturer = nil;
}
cricket::CaptureState AVFoundationVideoCapturer::Start(
const cricket::VideoFormat& format) {
if (!_capturer) {
LOG(LS_ERROR) << "Failed to create AVFoundation capturer.";
return cricket::CaptureState::CS_FAILED;
}
if (_capturer.isRunning) {
LOG(LS_ERROR) << "The capturer is already running.";
return cricket::CaptureState::CS_FAILED;
}
if (format != kDefaultFormat) {
LOG(LS_ERROR) << "Unsupported format provided.";
return cricket::CaptureState::CS_FAILED;
}
// Keep track of which thread capture started on. This is the thread that
// frames need to be sent to.
RTC_DCHECK(!_startThread);
_startThread = rtc::Thread::Current();
SetCaptureFormat(&format);
// This isn't super accurate because it takes a while for the AVCaptureSession
// to spin up, and this call returns async.
// TODO(tkchin): make this better.
[_capturer start];
SetCaptureState(cricket::CaptureState::CS_RUNNING);
return cricket::CaptureState::CS_STARTING;
}
void AVFoundationVideoCapturer::Stop() {
[_capturer stop];
SetCaptureFormat(NULL);
_startThread = nullptr;
}
bool AVFoundationVideoCapturer::IsRunning() {
return _capturer.isRunning;
}
AVCaptureSession* AVFoundationVideoCapturer::GetCaptureSession() {
return _capturer.captureSession;
}
bool AVFoundationVideoCapturer::CanUseBackCamera() const {
return _capturer.canUseBackCamera;
}
void AVFoundationVideoCapturer::SetUseBackCamera(bool useBackCamera) {
_capturer.useBackCamera = useBackCamera;
}
bool AVFoundationVideoCapturer::GetUseBackCamera() const {
return _capturer.useBackCamera;
}
void AVFoundationVideoCapturer::CaptureSampleBuffer(
CMSampleBufferRef sampleBuffer) {
if (CMSampleBufferGetNumSamples(sampleBuffer) != 1 ||
!CMSampleBufferIsValid(sampleBuffer) ||
!CMSampleBufferDataIsReady(sampleBuffer)) {
return;
}
CVImageBufferRef image_buffer = CMSampleBufferGetImageBuffer(sampleBuffer);
if (image_buffer == NULL) {
return;
}
// Retain the buffer and post it to the webrtc thread. It will be released
// after it has successfully been signaled.
CVBufferRetain(image_buffer);
AVFoundationFrame frame(image_buffer, rtc::TimeNanos());
_startThread->Post(RTC_FROM_HERE, this, kMessageTypeFrame,
new rtc::TypedMessageData<AVFoundationFrame>(frame));
}
void AVFoundationVideoCapturer::OnMessage(rtc::Message *msg) {
switch (msg->message_id) {
case kMessageTypeFrame: {
rtc::TypedMessageData<AVFoundationFrame>* data =
static_cast<rtc::TypedMessageData<AVFoundationFrame>*>(msg->pdata);
const AVFoundationFrame& frame = data->data();
OnFrameMessage(frame.image_buffer, frame.capture_time);
delete data;
break;
}
}
}
void AVFoundationVideoCapturer::OnFrameMessage(CVImageBufferRef image_buffer,
int64_t capture_time) {
RTC_DCHECK(_startThread->IsCurrent());
// Base address must be unlocked to access frame data.
CVOptionFlags lock_flags = kCVPixelBufferLock_ReadOnly;
CVReturn ret = CVPixelBufferLockBaseAddress(image_buffer, lock_flags);
if (ret != kCVReturnSuccess) {
return;
}
static size_t const kYPlaneIndex = 0;
static size_t const kUVPlaneIndex = 1;
uint8_t* y_plane_address =
static_cast<uint8_t*>(CVPixelBufferGetBaseAddressOfPlane(image_buffer,
kYPlaneIndex));
size_t y_plane_height =
CVPixelBufferGetHeightOfPlane(image_buffer, kYPlaneIndex);
size_t y_plane_width =
CVPixelBufferGetWidthOfPlane(image_buffer, kYPlaneIndex);
size_t y_plane_bytes_per_row =
CVPixelBufferGetBytesPerRowOfPlane(image_buffer, kYPlaneIndex);
size_t uv_plane_height =
CVPixelBufferGetHeightOfPlane(image_buffer, kUVPlaneIndex);
size_t uv_plane_bytes_per_row =
CVPixelBufferGetBytesPerRowOfPlane(image_buffer, kUVPlaneIndex);
size_t frame_size = y_plane_bytes_per_row * y_plane_height +
uv_plane_bytes_per_row * uv_plane_height;
// Sanity check assumption that planar bytes are contiguous.
uint8_t* uv_plane_address =
static_cast<uint8_t*>(CVPixelBufferGetBaseAddressOfPlane(image_buffer,
kUVPlaneIndex));
RTC_DCHECK(uv_plane_address ==
y_plane_address + y_plane_height * y_plane_bytes_per_row);
// Stuff data into a cricket::CapturedFrame.
cricket::CapturedFrame frame;
frame.width = y_plane_width;
frame.height = y_plane_height;
frame.pixel_width = 1;
frame.pixel_height = 1;
frame.fourcc = static_cast<uint32_t>(cricket::FOURCC_NV12);
frame.time_stamp = capture_time;
frame.data = y_plane_address;
frame.data_size = frame_size;
// This will call a superclass method that will perform the frame conversion
// to I420.
SignalFrameCaptured(this, &frame);
CVPixelBufferUnlockBaseAddress(image_buffer, lock_flags);
CVBufferRelease(image_buffer);
}
} // namespace webrtc

View File

@ -1,51 +0,0 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCVideoSource.h"
@class AVCaptureSession;
@class RTCMediaConstraints;
@class RTCPeerConnectionFactory;
// RTCAVFoundationVideoSource is a video source that uses
// webrtc::AVFoundationVideoCapturer. We do not currently provide a wrapper for
// that capturer because cricket::VideoCapturer is not ref counted and we cannot
// guarantee its lifetime. Instead, we expose its properties through the ref
// counted video source interface.
@interface RTCAVFoundationVideoSource : RTCVideoSource
- (instancetype)initWithFactory:(RTCPeerConnectionFactory*)factory
constraints:(RTCMediaConstraints*)constraints;
// Returns whether rear-facing camera is available for use.
@property(nonatomic, readonly) BOOL canUseBackCamera;
// Switches the camera being used (either front or back).
@property(nonatomic, assign) BOOL useBackCamera;
// Returns the active capture session.
@property(nonatomic, readonly) AVCaptureSession* captureSession;
@end

View File

@ -1,40 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCMediaSource.h"
// RTCAudioSource is an ObjectiveC wrapper for AudioSourceInterface. It is
// used as the source for one or more RTCAudioTrack objects.
@interface RTCAudioSource : RTCMediaSource
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__(
(unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,39 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCMediaStreamTrack.h"
// RTCAudioTrack is an ObjectiveC wrapper for AudioTrackInterface.
@interface RTCAudioTrack : RTCMediaStreamTrack
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__(
(unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,118 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
// ObjectiveC wrapper for a DataChannelInit object.
@interface RTCDataChannelInit : NSObject
// Set to YES if ordered delivery is required
@property(nonatomic) BOOL isOrdered;
// Max period in milliseconds in which retransmissions will be sent. After this
// time, no more retransmissions will be sent. -1 if unset.
@property(nonatomic) NSInteger maxRetransmitTimeMs;
// The max number of retransmissions. -1 if unset.
@property(nonatomic) NSInteger maxRetransmits;
// Set to YES if the channel has been externally negotiated and we do not send
// an in-band signalling in the form of an "open" message
@property(nonatomic) BOOL isNegotiated;
// The stream id, or SID, for SCTP data channels. -1 if unset.
@property(nonatomic) NSInteger streamId;
// Set by the application and opaque to the WebRTC implementation.
@property(nonatomic) NSString* protocol;
@end
// ObjectiveC wrapper for a DataBuffer object.
@interface RTCDataBuffer : NSObject
@property(nonatomic, readonly) NSData* data;
@property(nonatomic, readonly) BOOL isBinary;
- (instancetype)initWithData:(NSData*)data isBinary:(BOOL)isBinary;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__((
unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end
// Keep in sync with webrtc::DataChannelInterface::DataState
typedef enum {
kRTCDataChannelStateConnecting,
kRTCDataChannelStateOpen,
kRTCDataChannelStateClosing,
kRTCDataChannelStateClosed
} RTCDataChannelState;
@class RTCDataChannel;
// Protocol for receving data channel state and message events.
@protocol RTCDataChannelDelegate<NSObject>
// Called when the data channel state has changed.
- (void)channelDidChangeState:(RTCDataChannel*)channel;
// Called when a data buffer was successfully received.
- (void)channel:(RTCDataChannel*)channel
didReceiveMessageWithBuffer:(RTCDataBuffer*)buffer;
@optional
// Called when the buffered amount has changed.
- (void)channel:(RTCDataChannel*)channel
didChangeBufferedAmount:(NSUInteger)amount;
@end
// ObjectiveC wrapper for a DataChannel object.
// See talk/app/webrtc/datachannelinterface.h
@interface RTCDataChannel : NSObject
@property(nonatomic, readonly) NSString* label;
@property(nonatomic, readonly) BOOL isReliable;
@property(nonatomic, readonly) BOOL isOrdered;
@property(nonatomic, readonly) NSUInteger maxRetransmitTime;
@property(nonatomic, readonly) NSUInteger maxRetransmits;
@property(nonatomic, readonly) NSString* protocol;
@property(nonatomic, readonly) BOOL isNegotiated;
@property(nonatomic, readonly) NSInteger streamId;
@property(nonatomic, readonly) RTCDataChannelState state;
@property(nonatomic, readonly) NSUInteger bufferedAmount;
@property(nonatomic, weak) id<RTCDataChannelDelegate> delegate;
- (void)close;
- (BOOL)sendData:(RTCDataBuffer*)data;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__((
unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,46 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "RTCVideoRenderer.h"
@class RTCEAGLVideoView;
@protocol RTCEAGLVideoViewDelegate
- (void)videoView:(RTCEAGLVideoView*)videoView didChangeVideoSize:(CGSize)size;
@end
// RTCEAGLVideoView is an RTCVideoRenderer which renders i420 frames in its
// bounds using OpenGLES 2.0.
@interface RTCEAGLVideoView : UIView <RTCVideoRenderer>
@property(nonatomic, weak) id<RTCEAGLVideoViewDelegate> delegate;
@end

View File

@ -1,91 +0,0 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
// TODO(tkchin): Move this to a common location.
#ifndef NS_DESIGNATED_INITIALIZER
#define NS_DESIGNATED_INITIALIZER
#endif
typedef NS_ENUM(NSUInteger, RTCFileLoggerSeverity) {
kRTCFileLoggerSeverityVerbose,
kRTCFileLoggerSeverityInfo,
kRTCFileLoggerSeverityWarning,
kRTCFileLoggerSeverityError
};
typedef NS_ENUM(NSUInteger, RTCFileLoggerRotationType) {
kRTCFileLoggerTypeCall,
kRTCFileLoggerTypeApp,
};
// This class intercepts WebRTC logs and saves them to a file. The file size
// will not exceed the given maximum bytesize. When the maximum bytesize is
// reached, logs are rotated according to the rotationType specified.
// For kRTCFileLoggerTypeCall, logs from the beginning and the end
// are preserved while the middle section is overwritten instead.
// For kRTCFileLoggerTypeApp, the oldest log is overwritten.
// This class is not threadsafe.
@interface RTCFileLogger : NSObject
// The severity level to capture. The default is kRTCFileLoggerSeverityInfo.
@property(nonatomic, assign) RTCFileLoggerSeverity severity;
// The rotation type for this file logger. The default is
// kRTCFileLoggerTypeCall.
@property(nonatomic, readonly) RTCFileLoggerRotationType rotationType;
// Disables buffering disk writes. Should be set before |start|. Buffering
// is enabled by default for performance.
@property(nonatomic, assign) BOOL shouldDisableBuffering;
// Default constructor provides default settings for dir path, file size and
// rotation type.
- (instancetype)init;
// Create file logger with default rotation type.
- (instancetype)initWithDirPath:(NSString *)dirPath
maxFileSize:(NSUInteger)maxFileSize;
- (instancetype)initWithDirPath:(NSString *)dirPath
maxFileSize:(NSUInteger)maxFileSize
rotationType:(RTCFileLoggerRotationType)rotationType
NS_DESIGNATED_INITIALIZER;
// Starts writing WebRTC logs to disk if not already started. Overwrites any
// existing file(s).
- (void)start;
// Stops writing WebRTC logs to disk. This method is also called on dealloc.
- (void)stop;
// Returns the current contents of the logs, or nil if start has been called
// without a stop.
- (NSData *)logData;
@end

View File

@ -1,53 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
// RTCI420Frame is an ObjectiveC version of cricket::VideoFrame.
// TODO(nisse): It appears it doesn't support any VideoFrame methods,
// so let it wrap an webrtc::VideoFrameBuffer instead?
@interface RTCI420Frame : NSObject
@property(nonatomic, readonly) NSUInteger width;
@property(nonatomic, readonly) NSUInteger height;
@property(nonatomic, readonly) NSUInteger chromaWidth;
@property(nonatomic, readonly) NSUInteger chromaHeight;
// These can return NULL if the object is not backed by a buffer.
@property(nonatomic, readonly) const uint8_t* yPlane;
@property(nonatomic, readonly) const uint8_t* uPlane;
@property(nonatomic, readonly) const uint8_t* vPlane;
@property(nonatomic, readonly) NSInteger yPitch;
@property(nonatomic, readonly) NSInteger uPitch;
@property(nonatomic, readonly) NSInteger vPitch;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__((
unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,56 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
// RTCICECandidate contains an instance of ICECandidateInterface.
@interface RTCICECandidate : NSObject
// If present, this contains the identifier of the "media stream
// identification" as defined in [RFC 3388] for m-line this candidate is
// associated with.
@property(nonatomic, copy, readonly) NSString* sdpMid;
// This indicates the index (starting at zero) of m-line in the SDP this
// candidate is associated with.
@property(nonatomic, assign, readonly) NSInteger sdpMLineIndex;
// Creates an SDP-ized form of this candidate.
@property(nonatomic, copy, readonly) NSString* sdp;
// Creates an ICECandidateInterface based on SDP string.
- (id)initWithMid:(NSString*)sdpMid
index:(NSInteger)sdpMLineIndex
sdp:(NSString*)sdp;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__((
unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,49 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
// RTCICEServer allows for the creation of ICEServer structs.
@interface RTCICEServer : NSObject
// The server URI, username, and password.
@property(nonatomic, strong, readonly) NSURL* URI;
@property(nonatomic, copy, readonly) NSString* username;
@property(nonatomic, copy, readonly) NSString* password;
// Initializer for RTCICEServer taking uri, username, and password.
- (id)initWithURI:(NSURL*)URI
username:(NSString*)username
password:(NSString*)password;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__((
unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,92 +0,0 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
// Subset of rtc::LoggingSeverity.
typedef NS_ENUM(NSInteger, RTCLoggingSeverity) {
kRTCLoggingSeverityVerbose,
kRTCLoggingSeverityInfo,
kRTCLoggingSeverityWarning,
kRTCLoggingSeverityError,
};
#if defined(__cplusplus)
extern "C" void RTCLogEx(RTCLoggingSeverity severity, NSString* logString);
extern "C" void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity);
extern "C" NSString* RTCFileName(const char* filePath);
#else
// Wrapper for C++ LOG(sev) macros.
// Logs the log string to the webrtc logstream for the given severity.
extern void RTCLogEx(RTCLoggingSeverity severity, NSString* logString);
// Wrapper for rtc::LogMessage::LogToDebug.
// Sets the minimum severity to be logged to console.
extern void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity);
// Returns the filename with the path prefix removed.
extern NSString* RTCFileName(const char* filePath);
#endif
// Some convenience macros.
#define RTCLogString(format, ...) \
[NSString stringWithFormat:@"(%@:%d %s): " format, \
RTCFileName(__FILE__), \
__LINE__, \
__FUNCTION__, \
##__VA_ARGS__]
#define RTCLogFormat(severity, format, ...) \
do { \
NSString *logString = RTCLogString(format, ##__VA_ARGS__); \
RTCLogEx(severity, logString); \
} while (false)
#define RTCLogVerbose(format, ...) \
RTCLogFormat(kRTCLoggingSeverityVerbose, format, ##__VA_ARGS__) \
#define RTCLogInfo(format, ...) \
RTCLogFormat(kRTCLoggingSeverityInfo, format, ##__VA_ARGS__) \
#define RTCLogWarning(format, ...) \
RTCLogFormat(kRTCLoggingSeverityWarning, format, ##__VA_ARGS__) \
#define RTCLogError(format, ...) \
RTCLogFormat(kRTCLoggingSeverityError, format, ##__VA_ARGS__) \
#if !defined(NDEBUG)
#define RTCLogDebug(format, ...) RTCLogInfo(format, ##__VA_ARGS__)
#else
#define RTCLogDebug(format, ...) \
do { \
} while (false)
#endif
#define RTCLog(format, ...) RTCLogInfo(format, ##__VA_ARGS__)

View File

@ -1,39 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
// RTCMediaConstraints contains the media constraints to be used in
// RTCPeerConnection and RTCMediaStream.
@interface RTCMediaConstraints : NSObject
// Initializer for RTCMediaConstraints. The parameters mandatory and optional
// contain RTCPair objects with key/value for each constrant.
- (id)initWithMandatoryConstraints:(NSArray *)mandatory
optionalConstraints:(NSArray *)optional;
@end

View File

@ -1,44 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#import "RTCTypes.h"
// RTCMediaSource is an ObjectiveC wrapper for MediaSourceInterface
@interface RTCMediaSource : NSObject
// The current state of the RTCMediaSource.
@property(nonatomic, assign, readonly) RTCSourceState state;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__((
unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,51 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
@class RTCAudioTrack;
@class RTCVideoTrack;
// RTCMediaStream is an ObjectiveC wrapper for MediaStreamInterface.
@interface RTCMediaStream : NSObject
@property(nonatomic, strong, readonly) NSArray *audioTracks;
@property(nonatomic, strong, readonly) NSArray *videoTracks;
@property(nonatomic, strong, readonly) NSString *label;
- (BOOL)addAudioTrack:(RTCAudioTrack *)track;
- (BOOL)addVideoTrack:(RTCVideoTrack *)track;
- (BOOL)removeAudioTrack:(RTCAudioTrack *)track;
- (BOOL)removeVideoTrack:(RTCVideoTrack *)track;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__(
(unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,58 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#import "RTCTypes.h"
@class RTCMediaStreamTrack;
@protocol RTCMediaStreamTrackDelegate<NSObject>
- (void)mediaStreamTrackDidChange:(RTCMediaStreamTrack*)mediaStreamTrack;
@end
// RTCMediaStreamTrack implements the interface common to RTCAudioTrack and
// RTCVideoTrack. Do not create an instance of this class, rather create one
// of the derived classes.
@interface RTCMediaStreamTrack : NSObject
@property(nonatomic, readonly) NSString* kind;
@property(nonatomic, readonly) NSString* label;
@property(nonatomic, weak) id<RTCMediaStreamTrackDelegate> delegate;
- (BOOL)isEnabled;
- (BOOL)setEnabled:(BOOL)enabled;
- (RTCTrackState)state;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__(
(unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,47 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if TARGET_OS_IPHONE
#error "This file targets OSX."
#endif
#import <AppKit/NSOpenGLView.h>
#import "RTCVideoRenderer.h"
@class RTCNSGLVideoView;
@protocol RTCNSGLVideoViewDelegate
- (void)videoView:(RTCNSGLVideoView*)videoView didChangeVideoSize:(CGSize)size;
@end
@interface RTCNSGLVideoView : NSOpenGLView <RTCVideoRenderer>
@property(nonatomic, weak) id<RTCNSGLVideoViewDelegate> delegate;
@end

View File

@ -1,73 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#if TARGET_OS_IPHONE
#import <GLKit/GLKit.h>
#else
#import <AppKit/NSOpenGL.h>
#endif
@class RTCI420Frame;
// RTCOpenGLVideoRenderer issues appropriate OpenGL commands to draw a frame to
// the currently bound framebuffer. Supports OpenGL 3.2 and OpenGLES 2.0. OpenGL
// framebuffer creation and management should be handled elsewhere using the
// same context used to initialize this class.
@interface RTCOpenGLVideoRenderer : NSObject
// The last successfully drawn frame. Used to avoid drawing frames unnecessarily
// hence saving battery life by reducing load.
@property(nonatomic, readonly) RTCI420Frame* lastDrawnFrame;
#if TARGET_OS_IPHONE
- (instancetype)initWithContext:(EAGLContext*)context;
#else
- (instancetype)initWithContext:(NSOpenGLContext*)context;
#endif
// Draws |frame| onto the currently bound OpenGL framebuffer. |setupGL| must be
// called before this function will succeed.
- (BOOL)drawFrame:(RTCI420Frame*)frame;
// The following methods are used to manage OpenGL resources. On iOS
// applications should release resources when placed in background for use in
// the foreground application. In fact, attempting to call OpenGLES commands
// while in background will result in application termination.
// Sets up the OpenGL state needed for rendering.
- (void)setupGL;
// Tears down the OpenGL state created by |setupGL|.
- (void)teardownGL;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__((
unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,45 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
// A class to hold a key and value.
@interface RTCPair : NSObject
@property(nonatomic, strong, readonly) NSString *key;
@property(nonatomic, strong, readonly) NSString *value;
// Initialize a RTCPair object with a key and value.
- (id)initWithKey:(NSString *)key value:(NSString *)value;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__(
(unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,127 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCPeerConnectionDelegate.h"
@class RTCConfiguration;
@class RTCDataChannel;
@class RTCDataChannelInit;
@class RTCICECandidate;
@class RTCICEServers;
@class RTCMediaConstraints;
@class RTCMediaStream;
@class RTCMediaStreamTrack;
@class RTCSessionDescription;
@protocol RTCSessionDescriptionDelegate;
@protocol RTCStatsDelegate;
// RTCPeerConnection is an ObjectiveC friendly wrapper around a PeerConnection
// object. See the documentation in talk/app/webrtc/peerconnectioninterface.h.
// or http://www.webrtc.org/reference/native-apis, which in turn is inspired by
// the JS APIs: http://dev.w3.org/2011/webrtc/editor/webrtc.html and
// http://www.w3.org/TR/mediacapture-streams/
@interface RTCPeerConnection : NSObject
@property(nonatomic, weak) id<RTCPeerConnectionDelegate> delegate;
// Accessor methods to active local streams.
@property(nonatomic, strong, readonly) NSArray *localStreams;
// The local description.
@property(nonatomic, assign, readonly) RTCSessionDescription *localDescription;
// The remote description.
@property(nonatomic, assign, readonly) RTCSessionDescription *remoteDescription;
// The current signaling state.
@property(nonatomic, assign, readonly) RTCSignalingState signalingState;
@property(nonatomic, assign, readonly) RTCICEConnectionState iceConnectionState;
@property(nonatomic, assign, readonly) RTCICEGatheringState iceGatheringState;
// Add a new MediaStream to be sent on this PeerConnection.
// Note that a SessionDescription negotiation is needed before the
// remote peer can receive the stream.
- (BOOL)addStream:(RTCMediaStream *)stream;
// Remove a MediaStream from this PeerConnection.
// Note that a SessionDescription negotiation is need before the
// remote peer is notified.
- (void)removeStream:(RTCMediaStream *)stream;
// Create a data channel.
- (RTCDataChannel*)createDataChannelWithLabel:(NSString*)label
config:(RTCDataChannelInit*)config;
// Create a new offer.
// Success or failure will be reported via RTCSessionDescriptionDelegate.
- (void)createOfferWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
constraints:(RTCMediaConstraints *)constraints;
// Create an answer to an offer.
// Success or failure will be reported via RTCSessionDescriptionDelegate.
- (void)createAnswerWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
constraints:(RTCMediaConstraints *)constraints;
// Sets the local session description.
// Success or failure will be reported via RTCSessionDescriptionDelegate.
- (void)
setLocalDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
sessionDescription:(RTCSessionDescription *)sdp;
// Sets the remote session description.
// Success or failure will be reported via RTCSessionDescriptionDelegate.
- (void)
setRemoteDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
sessionDescription:(RTCSessionDescription *)sdp;
// Sets the PeerConnection's global configuration to |configuration|.
// Any changes to STUN/TURN servers or ICE candidate policy will affect the
// next gathering phase, and cause the next call to createOffer to generate
// new ICE credentials. Note that the BUNDLE and RTCP-multiplexing policies
// cannot be changed with this method.
- (BOOL)setConfiguration:(RTCConfiguration *)configuration;
// Provides a remote candidate to the ICE Agent.
- (BOOL)addICECandidate:(RTCICECandidate *)candidate;
// Terminates all media and closes the transport.
- (void)close;
// Gets statistics for the media track. If |mediaStreamTrack| is nil statistics
// are gathered for all tracks.
// Statistics information will be reported via RTCStatsDelegate.
- (BOOL)getStatsWithDelegate:(id<RTCStatsDelegate>)delegate
mediaStreamTrack:(RTCMediaStreamTrack*)mediaStreamTrack
statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__(
(unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,72 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#import "RTCTypes.h"
@class RTCDataChannel;
@class RTCICECandidate;
@class RTCMediaStream;
@class RTCPeerConnection;
// RTCPeerConnectionDelegate is a protocol for an object that must be
// implemented to get messages from PeerConnection.
@protocol RTCPeerConnectionDelegate<NSObject>
// Triggered when the SignalingState changed.
- (void)peerConnection:(RTCPeerConnection *)peerConnection
signalingStateChanged:(RTCSignalingState)stateChanged;
// Triggered when media is received on a new stream from remote peer.
- (void)peerConnection:(RTCPeerConnection *)peerConnection
addedStream:(RTCMediaStream *)stream;
// Triggered when a remote peer close a stream.
- (void)peerConnection:(RTCPeerConnection *)peerConnection
removedStream:(RTCMediaStream *)stream;
// Triggered when renegotiation is needed, for example the ICE has restarted.
- (void)peerConnectionOnRenegotiationNeeded:(RTCPeerConnection *)peerConnection;
// Called any time the ICEConnectionState changes.
- (void)peerConnection:(RTCPeerConnection *)peerConnection
iceConnectionChanged:(RTCICEConnectionState)newState;
// Called any time the ICEGatheringState changes.
- (void)peerConnection:(RTCPeerConnection *)peerConnection
iceGatheringChanged:(RTCICEGatheringState)newState;
// New Ice candidate have been found.
- (void)peerConnection:(RTCPeerConnection *)peerConnection
gotICECandidate:(RTCICECandidate *)candidate;
// New data channel has been opened.
- (void)peerConnection:(RTCPeerConnection*)peerConnection
didOpenDataChannel:(RTCDataChannel*)dataChannel;
@end

View File

@ -1,77 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
@class RTCAudioTrack;
@class RTCConfiguration;
@class RTCMediaConstraints;
@class RTCMediaStream;
@class RTCPeerConnection;
@class RTCVideoCapturer;
@class RTCVideoSource;
@class RTCVideoTrack;
@protocol RTCPeerConnectionDelegate;
// RTCPeerConnectionFactory is an ObjectiveC wrapper for PeerConnectionFactory.
// It is the main entry point to the PeerConnection API for clients.
@interface RTCPeerConnectionFactory : NSObject
// Initialize & de-initialize the SSL subsystem. Failure is fatal.
+ (void)initializeSSL;
+ (void)deinitializeSSL;
// Create an RTCPeerConnection object. RTCPeerConnectionFactory will create
// required libjingle threads, socket and network manager factory classes for
// networking.
- (RTCPeerConnection *)
peerConnectionWithICEServers:(NSArray *)servers
constraints:(RTCMediaConstraints *)constraints
delegate:(id<RTCPeerConnectionDelegate>)delegate;
// Creates a peer connection using the default port allocator factory and identity service.
- (RTCPeerConnection *)peerConnectionWithConfiguration:(RTCConfiguration *)configuration
constraints:(RTCMediaConstraints *)constraints
delegate:(id<RTCPeerConnectionDelegate>)delegate;
// Create an RTCMediaStream named |label|.
- (RTCMediaStream *)mediaStreamWithLabel:(NSString *)label;
// Creates a RTCVideoSource. The new source takes ownership of |capturer|.
// |constraints| decides video resolution and frame rate but can be NULL.
- (RTCVideoSource *)videoSourceWithCapturer:(RTCVideoCapturer *)capturer
constraints:(RTCMediaConstraints *)constraints;
// Creates a new local VideoTrack. The same |source| can be used in several
// tracks.
- (RTCVideoTrack *)videoTrackWithID:(NSString *)videoId
source:(RTCVideoSource *)source;
// Creates an new AudioTrack.
- (RTCAudioTrack *)audioTrackWithID:(NSString *)audioId;
@end

View File

@ -1,83 +0,0 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// See talk/app/webrtc/peerconnectioninterface.h.
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, RTCIceTransportsType) {
kRTCIceTransportsTypeNone,
kRTCIceTransportsTypeRelay,
kRTCIceTransportsTypeNoHost,
kRTCIceTransportsTypeAll,
};
// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-08#section-4.1.1
typedef NS_ENUM(NSInteger, RTCBundlePolicy) {
kRTCBundlePolicyBalanced,
kRTCBundlePolicyMaxBundle,
kRTCBundlePolicyMaxCompat,
};
// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-09#section-4.1.1
typedef NS_ENUM(NSInteger, RTCRtcpMuxPolicy) {
kRTCRtcpMuxPolicyNegotiate,
kRTCRtcpMuxPolicyRequire,
};
typedef NS_ENUM(NSInteger, RTCTcpCandidatePolicy) {
kRTCTcpCandidatePolicyEnabled,
kRTCTcpCandidatePolicyDisabled,
};
typedef NS_ENUM(NSInteger, RTCEncryptionKeyType) {
kRTCEncryptionKeyTypeRSA,
kRTCEncryptionKeyTypeECDSA,
};
// Configuration object used for creating a peer connection.
@interface RTCConfiguration : NSObject
@property(nonatomic, assign) RTCIceTransportsType iceTransportsType;
@property(nonatomic, copy) NSArray *iceServers;
@property(nonatomic, assign) RTCBundlePolicy bundlePolicy;
@property(nonatomic, assign) RTCRtcpMuxPolicy rtcpMuxPolicy;
@property(nonatomic, assign) RTCTcpCandidatePolicy tcpCandidatePolicy;
@property(nonatomic, assign) int audioJitterBufferMaxPackets;
@property(nonatomic, assign) int iceConnectionReceivingTimeout;
@property(nonatomic, assign) int iceBackupCandidatePairPingInterval;
@property(nonatomic, assign) RTCEncryptionKeyType keyType;
- (instancetype)initWithIceTransportsType:(RTCIceTransportsType)iceTransportsType
bundlePolicy:(RTCBundlePolicy)bundlePolicy
rtcpMuxPolicy:(RTCRtcpMuxPolicy)rtcpMuxPolicy
tcpCandidatePolicy:(RTCTcpCandidatePolicy)tcpCandidatePolicy
audioJitterBufferMaxPackets:(int)audioJitterBufferMaxPackets
iceConnectionReceivingTimeout:(int)iceConnectionReceivingTimeout
iceBackupCandidatePairPingInterval:(int)iceBackupCandidatePairPingInterval;
@end

View File

@ -1,50 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
// Description of an RFC 4566 Session.
// RTCSessionDescription is an ObjectiveC wrapper for
// SessionDescriptionInterface.
@interface RTCSessionDescription : NSObject
// The SDP description.
@property(nonatomic, copy, readonly) NSString *description;
// The session type.
@property(nonatomic, copy, readonly) NSString *type;
- (id)initWithType:(NSString *)type sdp:(NSString *)sdp;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__(
(unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,49 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
@class RTCPeerConnection;
@class RTCSessionDescription;
extern NSString* const kRTCSessionDescriptionDelegateErrorDomain;
extern int const kRTCSessionDescriptionDelegateErrorCode;
// RTCSessionDescriptionDelegate is a protocol for listening to callback
// messages when RTCSessionDescriptions are created or set.
@protocol RTCSessionDescriptionDelegate<NSObject>
// Called when creating a session.
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didCreateSessionDescription:(RTCSessionDescription *)sdp
error:(NSError *)error;
// Called when setting a local or remote description.
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didSetSessionDescriptionWithError:(NSError *)error;
@end

View File

@ -1,39 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
@class RTCPeerConnection;
// RTCSessionDescriptionDelegate is a protocol for receiving statistic
// reports from RTCPeerConnection.
@protocol RTCStatsDelegate<NSObject>
- (void)peerConnection:(RTCPeerConnection*)peerConnection
didGetStats:(NSArray*)stats; // NSArray of RTCStatsReport*.
@end

View File

@ -1,45 +0,0 @@
/*
* libjingle
* Copyright 2014 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
// ObjectiveC friendly wrapper around a StatsReport object.
// See talk/app/webrtc/statsypes.h
@interface RTCStatsReport : NSObject
@property(nonatomic, readonly) NSString* reportId;
@property(nonatomic, readonly) NSString* type;
@property(nonatomic, readonly) CFTimeInterval timestamp;
@property(nonatomic, readonly) NSArray* values; // NSArray of RTCPair*.
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__((
unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,77 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// Enums that are common to the ObjectiveC version of the PeerConnection API.
// RTCICEConnectionState correspond to the states in webrtc::ICEConnectionState.
typedef enum {
RTCICEConnectionNew,
RTCICEConnectionChecking,
RTCICEConnectionConnected,
RTCICEConnectionCompleted,
RTCICEConnectionFailed,
RTCICEConnectionDisconnected,
RTCICEConnectionClosed,
RTCICEConnectionMax,
} RTCICEConnectionState;
// RTCICEGatheringState the states in webrtc::ICEGatheringState.
typedef enum {
RTCICEGatheringNew,
RTCICEGatheringGathering,
RTCICEGatheringComplete,
} RTCICEGatheringState;
// RTCSignalingState correspond to the states in webrtc::SignalingState.
typedef enum {
RTCSignalingStable,
RTCSignalingHaveLocalOffer,
RTCSignalingHaveLocalPrAnswer,
RTCSignalingHaveRemoteOffer,
RTCSignalingHaveRemotePrAnswer,
RTCSignalingClosed,
} RTCSignalingState;
// RTCStatsOutputLevel correspond to webrtc::StatsOutputLevel
typedef enum {
RTCStatsOutputLevelStandard,
RTCStatsOutputLevelDebug,
} RTCStatsOutputLevel;
// RTCSourceState corresponds to the states in webrtc::SourceState.
typedef enum {
RTCSourceStateInitializing,
RTCSourceStateLive,
RTCSourceStateEnded,
RTCSourceStateMuted,
} RTCSourceState;
// RTCTrackState corresponds to the states in webrtc::TrackState.
typedef enum {
RTCTrackStateLive,
RTCTrackStateEnded,
} RTCTrackState;

View File

@ -1,42 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
// RTCVideoCapturer is an ObjectiveC wrapper for VideoCapturerInterface.
@interface RTCVideoCapturer : NSObject
// Create a new video capturer using the specified device.
+ (RTCVideoCapturer *)capturerWithDeviceName:(NSString *)deviceName;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__(
(unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,43 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#endif
@class RTCI420Frame;
@protocol RTCVideoRenderer<NSObject>
// The size of the frame.
- (void)setSize:(CGSize)size;
// The frame to be displayed.
- (void)renderFrame:(RTCI420Frame*)frame;
@end

View File

@ -1,39 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCMediaSource.h"
// RTCVideoSource is an ObjectiveC wrapper for VideoSourceInterface.
@interface RTCVideoSource : RTCMediaSource
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__(
(unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,55 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "RTCMediaStreamTrack.h"
@protocol RTCVideoRenderer;
@class RTCPeerConnectionFactory;
@class RTCVideoSource;
// RTCVideoTrack is an ObjectiveC wrapper for VideoTrackInterface.
@interface RTCVideoTrack : RTCMediaStreamTrack
@property(nonatomic, readonly) RTCVideoSource* source;
- (instancetype)initWithFactory:(RTCPeerConnectionFactory*)factory
source:(RTCVideoSource*)source
trackId:(NSString*)trackId;
// Register a renderer that will render all frames received on this track.
- (void)addRenderer:(id<RTCVideoRenderer>)renderer;
// Deregister a renderer.
- (void)removeRenderer:(id<RTCVideoRenderer>)renderer;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Disallow init and don't add to documentation
- (id)init __attribute__(
(unavailable("init is not a supported initializer for this class.")));
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@end

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.Google.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>

View File

@ -1 +0,0 @@
tkchin@webrtc.org

View File

@ -1 +0,0 @@
See ../objc/README for information on what this is and how to use it.

View File

@ -1,60 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#import "RTCDataChannel.h"
#import "RTCPeerConnectionDelegate.h"
// Observer of PeerConnection events, used by RTCPeerConnectionTest to check
// expectations.
@interface RTCPeerConnectionSyncObserver
: NSObject<RTCPeerConnectionDelegate, RTCDataChannelDelegate>
@property(nonatomic) RTCDataChannel* dataChannel;
// TODO(hughv): Add support for RTCVideoRendererDelegate when Video is enabled.
// Transfer received ICE candidates to the caller.
- (NSArray*)releaseReceivedICECandidates;
// Register expectations for events that this observer should see before it can
// be considered satisfied (see below).
- (void)expectError;
- (void)expectSignalingChange:(RTCSignalingState)state;
- (void)expectAddStream:(NSString *)label;
- (void)expectRemoveStream:(NSString *)label;
- (void)expectICECandidates:(int)count;
- (void)expectICEConnectionChange:(RTCICEConnectionState)state;
- (void)expectICEGatheringChange:(RTCICEGatheringState)state;
- (void)expectDataChannel:(NSString*)label;
- (void)expectStateChange:(RTCDataChannelState)state;
- (void)expectMessage:(NSData*)message isBinary:(BOOL)isBinary;
// Wait until all registered expectations above have been observed.
// Return false if expectations aren't met within |timeoutSeconds|.
- (BOOL)waitForAllExpectationsToBeSatisfiedWithTimeout:(NSTimeInterval)timeout;
@end

View File

@ -1,263 +0,0 @@
/*
* libjingle
* Copyright 2013 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#import "RTCPeerConnectionSyncObserver.h"
#import "RTCMediaStream.h"
@implementation RTCPeerConnectionSyncObserver {
int _expectedErrors;
NSMutableArray* _expectedSignalingChanges;
NSMutableArray* _expectedAddStreamLabels;
NSMutableArray* _expectedRemoveStreamLabels;
int _expectedICECandidates;
NSMutableArray* _receivedICECandidates;
NSMutableArray* _expectedICEConnectionChanges;
NSMutableArray* _expectedICEGatheringChanges;
NSMutableArray* _expectedDataChannels;
NSMutableArray* _expectedStateChanges;
NSMutableArray* _expectedMessages;
}
- (id)init {
self = [super init];
if (self) {
_expectedSignalingChanges = [NSMutableArray array];
_expectedSignalingChanges = [NSMutableArray array];
_expectedAddStreamLabels = [NSMutableArray array];
_expectedRemoveStreamLabels = [NSMutableArray array];
_receivedICECandidates = [NSMutableArray array];
_expectedICEConnectionChanges = [NSMutableArray array];
_expectedICEGatheringChanges = [NSMutableArray array];
_expectedDataChannels = [NSMutableArray array];
_expectedMessages = [NSMutableArray array];
_expectedStateChanges = [NSMutableArray array];
}
return self;
}
- (int)popFirstElementAsInt:(NSMutableArray*)array {
NSAssert([array count] > 0, @"Empty array");
NSNumber* boxedState = [array objectAtIndex:0];
[array removeObjectAtIndex:0];
return [boxedState intValue];
}
- (NSString*)popFirstElementAsNSString:(NSMutableArray*)array {
NSAssert([array count] > 0, @"Empty expectation array");
NSString* string = [array objectAtIndex:0];
[array removeObjectAtIndex:0];
return string;
}
- (BOOL)areAllExpectationsSatisfied {
return _expectedICECandidates <= 0 && // See comment in gotICECandidate.
_expectedErrors == 0 && [_expectedSignalingChanges count] == 0 &&
[_expectedICEConnectionChanges count] == 0 &&
[_expectedICEGatheringChanges count] == 0 &&
[_expectedAddStreamLabels count] == 0 &&
[_expectedRemoveStreamLabels count] == 0 &&
[_expectedDataChannels count] == 0 &&
[_expectedStateChanges count] == 0 &&
[_expectedMessages count] == 0;
// TODO(hughv): Test video state here too.
}
- (NSArray*)releaseReceivedICECandidates {
NSArray* ret = _receivedICECandidates;
_receivedICECandidates = [NSMutableArray array];
return ret;
}
- (void)expectError {
++_expectedErrors;
}
- (void)expectSignalingChange:(RTCSignalingState)state {
[_expectedSignalingChanges addObject:@((int)state)];
}
- (void)expectAddStream:(NSString*)label {
[_expectedAddStreamLabels addObject:label];
}
- (void)expectRemoveStream:(NSString*)label {
[_expectedRemoveStreamLabels addObject:label];
}
- (void)expectICECandidates:(int)count {
_expectedICECandidates += count;
}
- (void)expectICEConnectionChange:(RTCICEConnectionState)state {
[_expectedICEConnectionChanges addObject:@((int)state)];
}
- (void)expectICEGatheringChange:(RTCICEGatheringState)state {
[_expectedICEGatheringChanges addObject:@((int)state)];
}
- (void)expectDataChannel:(NSString*)label {
[_expectedDataChannels addObject:label];
}
- (void)expectStateChange:(RTCDataChannelState)state {
[_expectedStateChanges addObject:@(state)];
}
- (void)expectMessage:(NSData*)message isBinary:(BOOL)isBinary {
RTCDataBuffer* buffer = [[RTCDataBuffer alloc] initWithData:message
isBinary:isBinary];
[_expectedMessages addObject:buffer];
}
- (BOOL)waitForAllExpectationsToBeSatisfiedWithTimeout:(NSTimeInterval)timeout {
NSParameterAssert(timeout >= 0);
// TODO (fischman): Revisit. Keeping in sync with the Java version, but
// polling is not optimal.
// https://code.google.com/p/libjingle/source/browse/trunk/talk/app/webrtc/javatests/src/org/webrtc/PeerConnectionTest.java?line=212#212
NSDate *startTime = [NSDate date];
while (![self areAllExpectationsSatisfied]) {
if (startTime.timeIntervalSinceNow < -timeout) {
return NO;
}
[[NSRunLoop currentRunLoop]
runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
}
return YES;
}
#pragma mark - RTCPeerConnectionDelegate methods
- (void)peerConnection:(RTCPeerConnection*)peerConnection
signalingStateChanged:(RTCSignalingState)stateChanged {
int expectedState = [self popFirstElementAsInt:_expectedSignalingChanges];
NSString* message =
[NSString stringWithFormat:@"RTCPeerConnectionDelegate::"
@"onSignalingStateChange [%d] expected[%d]",
stateChanged,
expectedState];
NSAssert(expectedState == (int)stateChanged, message);
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
addedStream:(RTCMediaStream*)stream {
NSString* expectedLabel =
[self popFirstElementAsNSString:_expectedAddStreamLabels];
NSAssert([expectedLabel isEqual:stream.label], @"Stream not expected");
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
removedStream:(RTCMediaStream*)stream {
NSString* expectedLabel =
[self popFirstElementAsNSString:_expectedRemoveStreamLabels];
NSAssert([expectedLabel isEqual:stream.label], @"Stream not expected");
}
- (void)peerConnectionOnRenegotiationNeeded:(RTCPeerConnection*)peerConnection {
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
gotICECandidate:(RTCICECandidate*)candidate {
--_expectedICECandidates;
// We don't assert expectedICECandidates >= 0 because it's hard to know
// how many to expect, in general. We only use expectICECandidates to
// assert a minimal count.
[_receivedICECandidates addObject:candidate];
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
iceGatheringChanged:(RTCICEGatheringState)newState {
// It's fine to get a variable number of GATHERING messages before
// COMPLETE fires (depending on how long the test runs) so we don't assert
// any particular count.
if (newState == RTCICEGatheringGathering) {
return;
}
NSAssert([_expectedICEGatheringChanges count] > 0,
@"Unexpected ICE gathering state change");
int expectedState = [self popFirstElementAsInt:_expectedICEGatheringChanges];
NSAssert(expectedState == (int)newState,
@"ICE gathering state should match expectation");
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
iceConnectionChanged:(RTCICEConnectionState)newState {
// See TODO(fischman) in RTCPeerConnectionTest.mm about Completed.
if (newState == RTCICEConnectionCompleted)
return;
NSAssert([_expectedICEConnectionChanges count] > 0,
@"Unexpected ICE connection state change");
int expectedState = [self popFirstElementAsInt:_expectedICEConnectionChanges];
NSAssert(expectedState == (int)newState,
@"ICE connection state should match expectation");
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
didOpenDataChannel:(RTCDataChannel*)dataChannel {
NSString* expectedLabel =
[self popFirstElementAsNSString:_expectedDataChannels];
NSAssert([expectedLabel isEqual:dataChannel.label],
@"Data channel not expected");
self.dataChannel = dataChannel;
dataChannel.delegate = self;
NSAssert(kRTCDataChannelStateConnecting == dataChannel.state,
@"Unexpected state");
}
#pragma mark - RTCDataChannelDelegate
- (void)channelDidChangeState:(RTCDataChannel*)channel {
NSAssert([_expectedStateChanges count] > 0,
@"Unexpected state change");
int expectedState = [self popFirstElementAsInt:_expectedStateChanges];
NSAssert(expectedState == channel.state, @"Channel state should match");
}
- (void)channel:(RTCDataChannel*)channel
didChangeBufferedAmount:(NSUInteger)previousAmount {
NSAssert(channel.bufferedAmount != previousAmount,
@"Invalid bufferedAmount change");
}
- (void)channel:(RTCDataChannel*)channel
didReceiveMessageWithBuffer:(RTCDataBuffer*)buffer {
NSAssert([_expectedMessages count] > 0,
@"Unexpected message received");
RTCDataBuffer* expectedBuffer = [_expectedMessages objectAtIndex:0];
NSAssert(expectedBuffer.isBinary == buffer.isBinary,
@"Buffer isBinary should match");
NSAssert([expectedBuffer.data isEqual:buffer.data],
@"Buffer data should match");
[_expectedMessages removeObjectAtIndex:0];
}
@end

Some files were not shown because too many files have changed in this diff Show More