From d023fe22e26040d5426d23af75397e12e7cbe32b Mon Sep 17 00:00:00 2001 From: Randall Barker Date: Thu, 9 Apr 2015 09:15:00 -0400 Subject: [PATCH] Bug 1101651 - Part 2: Enable WebRTC unit tests to be built using standalone WebRTC library. r=jesup --- media/mtransport/build/moz.build | 62 +------- media/mtransport/common.build | 95 ++++++++++++ media/mtransport/moz.build | 17 +++ media/mtransport/objs.mozbuild | 35 ----- media/mtransport/standalone/moz.build | 64 +------- media/mtransport/stun_udp_socket_filter.cpp | 27 ++++ media/mtransport/test/moz.build | 24 ++- media/mtransport/test/mtransport_test_utils.h | 20 ++- media/mtransport/testlib/moz.build | 16 ++ media/webrtc/moz.build | 14 +- media/webrtc/signaling/signaling.gyp | 32 +++- .../src/common/browser_logging/WebRtcLog.cpp | 6 +- .../src/media-conduit/AudioConduit.cpp | 14 +- .../src/media-conduit/AudioConduit.h | 4 +- .../src/media-conduit/CodecStatistics.cpp | 10 ++ .../src/media-conduit/VideoConduit.cpp | 2 +- .../src/mediapipeline/MediaPipeline.cpp | 40 +++-- .../src/mediapipeline/MediaPipeline.h | 14 +- .../peerconnection/MediaPipelineFactory.cpp | 12 +- .../src/peerconnection/PeerConnectionCtx.cpp | 8 +- .../src/peerconnection/PeerConnectionCtx.h | 4 +- .../src/peerconnection/PeerConnectionImpl.cpp | 103 +++++++------ .../src/peerconnection/PeerConnectionImpl.h | 32 ++-- .../peerconnection/PeerConnectionMedia.cpp | 22 ++- .../src/peerconnection/PeerConnectionMedia.h | 14 +- .../webrtc/signaling/test/FakeMediaStreams.h | 36 +++++ media/webrtc/signaling/test/FakePCObserver.h | 7 + media/webrtc/signaling/test/common.build | 143 ++++++++++++++++++ .../signaling/test/jsep_session_unittest.cpp | 2 +- media/webrtc/signaling/test/moz.build | 136 +---------------- .../signaling/test/signaling_unittests.cpp | 11 +- .../jsep_session_unittest_standalone.cpp | 7 + .../mediaconduit_unittests_standalone.cpp | 5 + .../mediapipeline_unittest_standalone.cpp | 7 + .../signaling/test/standalone/moz.build | 58 +++++++ .../standalone/sdp_unittests_standalone.cpp | 7 + .../signaling_unittests_standalone.cpp | 5 + toolkit/toolkit.mozbuild | 5 +- xpcom/components/nsComponentManager.cpp | 1 + xpcom/components/nsComponentManager.h | 1 + 40 files changed, 693 insertions(+), 429 deletions(-) create mode 100644 media/mtransport/common.build create mode 100644 media/mtransport/moz.build delete mode 100644 media/mtransport/objs.mozbuild create mode 100644 media/mtransport/testlib/moz.build create mode 100644 media/webrtc/signaling/test/common.build create mode 100644 media/webrtc/signaling/test/standalone/jsep_session_unittest_standalone.cpp create mode 100644 media/webrtc/signaling/test/standalone/mediaconduit_unittests_standalone.cpp create mode 100644 media/webrtc/signaling/test/standalone/mediapipeline_unittest_standalone.cpp create mode 100644 media/webrtc/signaling/test/standalone/moz.build create mode 100644 media/webrtc/signaling/test/standalone/sdp_unittests_standalone.cpp create mode 100644 media/webrtc/signaling/test/standalone/signaling_unittests_standalone.cpp diff --git a/media/mtransport/build/moz.build b/media/mtransport/build/moz.build index 57ecc27c6f6..ae7fcf94699 100644 --- a/media/mtransport/build/moz.build +++ b/media/mtransport/build/moz.build @@ -25,7 +25,7 @@ EXPORTS.mtransport += [ '../transportlayerprsock.h', ] -include('../objs.mozbuild') +include('../common.build') # These files cannot be built in unified mode because of the redefinition of # getLogModule, UNIMPLEMENTED, nr_socket_long_term_violation_time, @@ -34,67 +34,7 @@ SOURCES += mtransport_cppsrcs FAIL_ON_WARNINGS = True -LOCAL_INCLUDES += [ - '/media/mtransport/', - '/media/mtransport/third_party/', - '/media/mtransport/third_party/nICEr/src/crypto', - '/media/mtransport/third_party/nICEr/src/ice', - '/media/mtransport/third_party/nICEr/src/net', - '/media/mtransport/third_party/nICEr/src/stun', - '/media/mtransport/third_party/nICEr/src/util', - '/media/mtransport/third_party/nrappkit/src/event', - '/media/mtransport/third_party/nrappkit/src/log', - '/media/mtransport/third_party/nrappkit/src/plugin', - '/media/mtransport/third_party/nrappkit/src/port/generic/include', - '/media/mtransport/third_party/nrappkit/src/registry', - '/media/mtransport/third_party/nrappkit/src/share', - '/media/mtransport/third_party/nrappkit/src/stats', - '/media/mtransport/third_party/nrappkit/src/util/libekr', -] - -if CONFIG['OS_TARGET'] in ['Darwin', 'DragonFly', 'FreeBSD', 'NetBSD', 'OpenBSD']: - if CONFIG['OS_TARGET'] == 'Darwin': - DEFINES['DARWIN'] = True - else: - DEFINES['BSD'] = True - LOCAL_INCLUDES += [ - '/media/mtransport/third_party/nrappkit/src/port/darwin/include', - ] -elif CONFIG['OS_TARGET'] == 'Linux': - DEFINES['LINUX'] = True - DEFINES['USE_INTERFACE_PRIORITIZER'] = True - LOCAL_INCLUDES += [ - '/media/mtransport/third_party/nrappkit/src/port/linux/include', - ] -elif CONFIG['OS_TARGET'] == 'Android': - DEFINES['LINUX'] = True - DEFINES['ANDROID'] = True - LOCAL_INCLUDES += [ - '/media/mtransport/third_party/nrappkit/src/port/android/include', - ] -elif CONFIG['OS_TARGET'] == 'WINNT': - DEFINES['WIN'] = True - # for stun.h - DEFINES['WIN32'] = True - DEFINES['NOMINMAX'] = True - LOCAL_INCLUDES += [ - '/media/mtransport/third_party/nrappkit/src/port/win32/include', - ] - if CONFIG['GKMEDIAS_SHARED_LIBRARY']: NO_VISIBILITY_FLAGS = True FINAL_LIBRARY = 'xul' - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': - DEFINES['USE_INTERFACE_PRIORITIZER'] = True - -for var in ('HAVE_STRDUP', 'NR_SOCKET_IS_VOID_PTR'): - DEFINES[var] = True - -DEFINES['R_DEFINED_INT2'] = 'int16_t' -DEFINES['R_DEFINED_UINT2'] = 'uint16_t' -DEFINES['R_DEFINED_INT4'] = 'int32_t' -DEFINES['R_DEFINED_UINT4'] = 'uint32_t' -DEFINES['R_DEFINED_INT8'] = 'int64_t' -DEFINES['R_DEFINED_UINT8'] = 'uint64_t' diff --git a/media/mtransport/common.build b/media/mtransport/common.build new file mode 100644 index 00000000000..6d5556a6e28 --- /dev/null +++ b/media/mtransport/common.build @@ -0,0 +1,95 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +mtransport_lcppsrcs = [ + 'dtlsidentity.cpp', + 'nr_socket_prsock.cpp', + 'nr_timer.cpp', + 'nricectx.cpp', + 'nricemediastream.cpp', + 'nriceresolver.cpp', + 'nriceresolverfake.cpp', + 'nrinterfaceprioritizer.cpp', + 'rlogringbuffer.cpp', + 'simpletokenbucket.cpp', + 'stun_udp_socket_filter.cpp', + 'transportflow.cpp', + 'transportlayer.cpp', + 'transportlayerdtls.cpp', + 'transportlayerice.cpp', + 'transportlayerlog.cpp', + 'transportlayerloopback.cpp', + 'transportlayerprsock.cpp', +] + +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': + mtransport_lcppsrcs += [ + 'gonk_addrs.cpp', + ] + +mtransport_cppsrcs = [ + '%s/media/mtransport/%s' % (TOPSRCDIR, s) for s in sorted(mtransport_lcppsrcs) +] + +LOCAL_INCLUDES += [ + '/media/mtransport/', + '/media/mtransport/third_party/', + '/media/mtransport/third_party/nICEr/src/crypto', + '/media/mtransport/third_party/nICEr/src/ice', + '/media/mtransport/third_party/nICEr/src/net', + '/media/mtransport/third_party/nICEr/src/stun', + '/media/mtransport/third_party/nICEr/src/util', + '/media/mtransport/third_party/nrappkit/src/event', + '/media/mtransport/third_party/nrappkit/src/log', + '/media/mtransport/third_party/nrappkit/src/plugin', + '/media/mtransport/third_party/nrappkit/src/port/generic/include', + '/media/mtransport/third_party/nrappkit/src/registry', + '/media/mtransport/third_party/nrappkit/src/share', + '/media/mtransport/third_party/nrappkit/src/stats', + '/media/mtransport/third_party/nrappkit/src/util/libekr', +] + +if CONFIG['OS_TARGET'] in ['Darwin', 'DragonFly', 'FreeBSD', 'NetBSD', 'OpenBSD']: + if CONFIG['OS_TARGET'] == 'Darwin': + DEFINES['DARWIN'] = True + else: + DEFINES['BSD'] = True + LOCAL_INCLUDES += [ + '/media/mtransport/third_party/nrappkit/src/port/darwin/include', + ] +elif CONFIG['OS_TARGET'] == 'Linux': + DEFINES['LINUX'] = True + DEFINES['USE_INTERFACE_PRIORITIZER'] = True + LOCAL_INCLUDES += [ + '/media/mtransport/third_party/nrappkit/src/port/linux/include', + ] +elif CONFIG['OS_TARGET'] == 'Android': + DEFINES['LINUX'] = True + DEFINES['ANDROID'] = True + LOCAL_INCLUDES += [ + '/media/mtransport/third_party/nrappkit/src/port/android/include', + ] +elif CONFIG['OS_TARGET'] == 'WINNT': + DEFINES['WIN'] = True + # for stun.h + DEFINES['WIN32'] = True + DEFINES['NOMINMAX'] = True + LOCAL_INCLUDES += [ + '/media/mtransport/third_party/nrappkit/src/port/win32/include', + ] + +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': + DEFINES['USE_INTERFACE_PRIORITIZER'] = True + +for var in ('HAVE_STRDUP', 'NR_SOCKET_IS_VOID_PTR'): + DEFINES[var] = True + +DEFINES['R_DEFINED_INT2'] = 'int16_t' +DEFINES['R_DEFINED_UINT2'] = 'uint16_t' +DEFINES['R_DEFINED_INT4'] = 'int32_t' +DEFINES['R_DEFINED_UINT4'] = 'uint32_t' +DEFINES['R_DEFINED_INT8'] = 'int64_t' +DEFINES['R_DEFINED_UINT8'] = 'uint64_t' diff --git a/media/mtransport/moz.build b/media/mtransport/moz.build new file mode 100644 index 00000000000..4b532c07db1 --- /dev/null +++ b/media/mtransport/moz.build @@ -0,0 +1,17 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DIRS += [ + '/media/mtransport/third_party', + '/media/mtransport/build', + '/media/mtransport/testlib', +] +if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': + DIRS += [ + '/media/mtransport/standalone', + ] + + diff --git a/media/mtransport/objs.mozbuild b/media/mtransport/objs.mozbuild deleted file mode 100644 index 025bf5bff7c..00000000000 --- a/media/mtransport/objs.mozbuild +++ /dev/null @@ -1,35 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -mtransport_lcppsrcs = [ - 'dtlsidentity.cpp', - 'nr_socket_prsock.cpp', - 'nr_timer.cpp', - 'nricectx.cpp', - 'nricemediastream.cpp', - 'nriceresolver.cpp', - 'nriceresolverfake.cpp', - 'nrinterfaceprioritizer.cpp', - 'rlogringbuffer.cpp', - 'simpletokenbucket.cpp', - 'stun_udp_socket_filter.cpp', - 'transportflow.cpp', - 'transportlayer.cpp', - 'transportlayerdtls.cpp', - 'transportlayerice.cpp', - 'transportlayerlog.cpp', - 'transportlayerloopback.cpp', - 'transportlayerprsock.cpp', -] - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': - mtransport_lcppsrcs += [ - 'gonk_addrs.cpp', - ] - -mtransport_cppsrcs = [ - '%s/media/mtransport/%s' % (TOPSRCDIR, s) for s in sorted(mtransport_lcppsrcs) -] diff --git a/media/mtransport/standalone/moz.build b/media/mtransport/standalone/moz.build index 5678dfb978c..ec59b576bc6 100644 --- a/media/mtransport/standalone/moz.build +++ b/media/mtransport/standalone/moz.build @@ -4,73 +4,17 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -include('../objs.mozbuild') +Library('mtransport_standalone') + +include('../common.build') # These files cannot be built in unified mode because of the redefinition of # getLogModule, UNIMPLEMENTED, nr_socket_long_term_violation_time, # nr_socket_short_term_violation_time. SOURCES += mtransport_cppsrcs -Library('mtransport_s') - -LOCAL_INCLUDES += [ - '/media/mtransport/', - '/media/mtransport/third_party/', - '/media/mtransport/third_party/nICEr/src/crypto', - '/media/mtransport/third_party/nICEr/src/ice', - '/media/mtransport/third_party/nICEr/src/net', - '/media/mtransport/third_party/nICEr/src/stun', - '/media/mtransport/third_party/nICEr/src/util', - '/media/mtransport/third_party/nrappkit/src/event', - '/media/mtransport/third_party/nrappkit/src/log', - '/media/mtransport/third_party/nrappkit/src/plugin', - '/media/mtransport/third_party/nrappkit/src/port/generic/include', - '/media/mtransport/third_party/nrappkit/src/registry', - '/media/mtransport/third_party/nrappkit/src/share', - '/media/mtransport/third_party/nrappkit/src/stats', - '/media/mtransport/third_party/nrappkit/src/util/libekr', -] - -if CONFIG['OS_TARGET'] in ['Darwin', 'DragonFly', 'FreeBSD', 'NetBSD', 'OpenBSD']: - if CONFIG['OS_TARGET'] == 'Darwin': - DEFINES['DARWIN'] = True - else: - DEFINES['BSD'] = True - LOCAL_INCLUDES += [ - '/media/mtransport/third_party/nrappkit/src/port/darwin/include', - ] -elif CONFIG['OS_TARGET'] == 'Linux': - DEFINES['LINUX'] = True - DEFINES['USE_INTERFACE_PRIORITIZER'] = True - LOCAL_INCLUDES += [ - '/media/mtransport/third_party/nrappkit/src/port/linux/include', - ] -elif CONFIG['OS_TARGET'] == 'Android': - DEFINES['LINUX'] = True - DEFINES['ANDROID'] = True - LOCAL_INCLUDES += [ - '/media/mtransport/third_party/nrappkit/src/port/android/include', - ] -elif CONFIG['OS_TARGET'] == 'WINNT': - DEFINES['WIN'] = True - # for stun.h - DEFINES['WIN32'] = True - DEFINES['NOMINMAX'] = True - LOCAL_INCLUDES += [ - '/media/mtransport/third_party/nrappkit/src/port/win32/include', - ] - FORCE_STATIC_LIB = True -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': - DEFINES['USE_INTERFACE_PRIORITIZER'] = True - -for var in ('HAVE_STRDUP', 'NR_SOCKET_IS_VOID_PTR'): +for var in ('MOZILLA_INTERNAL_API', 'MOZILLA_XPCOMRT_API', 'MOZILLA_EXTERNAL_LINKAGE'): DEFINES[var] = True -DEFINES['R_DEFINED_INT2'] = 'int16_t' -DEFINES['R_DEFINED_UINT2'] = 'uint16_t' -DEFINES['R_DEFINED_INT4'] = 'int32_t' -DEFINES['R_DEFINED_UINT4'] = 'uint32_t' -DEFINES['R_DEFINED_INT8'] = 'int64_t' -DEFINES['R_DEFINED_UINT8'] = 'uint64_t' diff --git a/media/mtransport/stun_udp_socket_filter.cpp b/media/mtransport/stun_udp_socket_filter.cpp index 9b530e1e014..af580b8889c 100644 --- a/media/mtransport/stun_udp_socket_filter.cpp +++ b/media/mtransport/stun_udp_socket_filter.cpp @@ -14,6 +14,10 @@ extern "C" { #include "mozilla/net/DNS.h" #include "stun_udp_socket_filter.h" #include "nr_socket_prsock.h" +#if defined(MOZILLA_XPCOMRT_API) +#include "mozilla/Module.h" +#include "mozilla/ModuleUtils.h" +#endif namespace { @@ -206,3 +210,26 @@ NS_IMETHODIMP nsStunUDPSocketFilterHandler::NewFilter(nsIUDPSocketFilter **resul NS_ADDREF(*result = ret); return NS_OK; } + +#if defined(MOZILLA_XPCOMRT_API) +NS_DEFINE_NAMED_CID(NS_STUN_UDP_SOCKET_FILTER_HANDLER_CID) + +NS_GENERIC_FACTORY_CONSTRUCTOR(nsStunUDPSocketFilterHandler) + +static const mozilla::Module::CIDEntry kCIDs[] = { + { &kNS_STUN_UDP_SOCKET_FILTER_HANDLER_CID, false, nullptr, nsStunUDPSocketFilterHandlerConstructor }, + { nullptr } +}; + +static const mozilla::Module::ContractIDEntry kContracts[] = { + { NS_STUN_UDP_SOCKET_FILTER_HANDLER_CONTRACTID, &kNS_STUN_UDP_SOCKET_FILTER_HANDLER_CID }, + { nullptr } +}; + +extern const mozilla::Module kStunUDPSocketFilterHandlerModule; +const mozilla::Module kStunUDPSocketFilterHandlerModule = { + mozilla::Module::kVersion, + kCIDs, + kContracts +}; +#endif diff --git a/media/mtransport/test/moz.build b/media/mtransport/test/moz.build index 1f764ffc5a6..0cebf9a0daf 100644 --- a/media/mtransport/test/moz.build +++ b/media/mtransport/test/moz.build @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': - GeckoCppUnitTests([ + CppUnitTests([ 'buffered_stun_socket_unittest', 'ice_unittest', 'nrappkit_unittest', @@ -20,13 +20,13 @@ if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': ]) if CONFIG['MOZ_SCTP']: - GeckoCppUnitTests([ + CppUnitTests([ 'sctp_unittest', ]) FAIL_ON_WARNINGS = True -for var in ('HAVE_STRDUP', 'NR_SOCKET_IS_VOID_PTR', 'SCTP_DEBUG', 'INET'): +for var in ('MOZILLA_INTERNAL_API', 'MOZILLA_XPCOMRT_API', 'MOZILLA_EXTERNAL_LINKAGE', 'HAVE_STRDUP', 'NR_SOCKET_IS_VOID_PTR', 'SCTP_DEBUG', 'INET'): DEFINES[var] = True if CONFIG['OS_TARGET'] == 'Android': @@ -40,6 +40,12 @@ if CONFIG['OS_TARGET'] == 'Linux': LOCAL_INCLUDES += [ '/media/mtransport/third_party/nrappkit/src/port/linux/include', ] + USE_LIBS += [ + 'static:/nsprpub/lib/libc/src/plc4', + ] + OS_LIBS += [ + '-lrt', + ] if CONFIG['OS_TARGET'] == 'Darwin': LOCAL_INCLUDES += [ @@ -80,14 +86,22 @@ LOCAL_INCLUDES += [ '/media/mtransport/third_party/nrappkit/src/util/libekr', '/media/webrtc/trunk/testing/gtest/include/', '/netwerk/sctp/src/', + '/xpcom/libxpcomrt', ] USE_LIBS += [ '/media/webrtc/trunk/testing/gtest_gtest/gtest', - 'mtransport_s', + 'fallible', + 'mfbt', + 'mozglue', + 'mtransport_standalone', + 'necko_standalone', 'nicer', 'nrappkit', + 'nspr', 'nss', + 'unicharutil_standalone', + 'xpcomrt', ] if not CONFIG['MOZ_NATIVE_NSS'] and not CONFIG['MOZ_FOLD_LIBS']: @@ -100,3 +114,5 @@ if CONFIG['MOZ_SCTP']: USE_LIBS += [ 'nksctp_s', ] + +USE_LIBS += ['mozglue'] diff --git a/media/mtransport/test/mtransport_test_utils.h b/media/mtransport/test/mtransport_test_utils.h index 80c6253cc06..6c96c6f1e16 100644 --- a/media/mtransport/test/mtransport_test_utils.h +++ b/media/mtransport/test/mtransport_test_utils.h @@ -19,7 +19,7 @@ #include "nsIComponentManager.h" #include "nsIComponentRegistrar.h" -#include "nsNetUtil.h" +#include "nsIEventTarget.h" #include "nsIIOService.h" #include "nsIServiceManager.h" #include "nsISocketTransportService.h" @@ -30,7 +30,22 @@ #endif #include "nsPISocketTransportService.h" #include "nsServiceManagerUtils.h" +#if !defined(MOZILLA_XPCOMRT_API) #include "TestHarness.h" +#else +#include "XPCOMRTInit.h" +class ScopedXPCOM { +public: + explicit ScopedXPCOM(const char*) + { + NS_InitXPCOMRT(); + } + ~ScopedXPCOM() + { + NS_ShutdownXPCOMRT(); + } +}; +#endif class MtransportTestUtils { public: @@ -46,8 +61,6 @@ class MtransportTestUtils { void InitServices() { nsresult rv; - ioservice_ = do_GetIOService(&rv); - MOZ_ASSERT(NS_SUCCEEDED(rv)); sts_target_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv); MOZ_ASSERT(NS_SUCCEEDED(rv)); sts_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv); @@ -80,7 +93,6 @@ class MtransportTestUtils { private: ScopedXPCOM xpcom_; - nsCOMPtr ioservice_; nsCOMPtr sts_target_; nsCOMPtr sts_; #ifdef MOZ_CRASHREPORTER diff --git a/media/mtransport/testlib/moz.build b/media/mtransport/testlib/moz.build new file mode 100644 index 00000000000..5a6e62a6cf2 --- /dev/null +++ b/media/mtransport/testlib/moz.build @@ -0,0 +1,16 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +include('../common.build') + +# These files cannot be built in unified mode because of the redefinition of +# getLogModule, UNIMPLEMENTED, nr_socket_long_term_violation_time, +# nr_socket_short_term_violation_time. +SOURCES += mtransport_cppsrcs + +Library('mtransport_s') + +FORCE_STATIC_LIB = True diff --git a/media/webrtc/moz.build b/media/webrtc/moz.build index 92b99b25d91..5ecaa5a23d3 100644 --- a/media/webrtc/moz.build +++ b/media/webrtc/moz.build @@ -48,7 +48,8 @@ if CONFIG['MOZ_WEBRTC_SIGNALING']: GYP_DIRS['signaling'].input = 'signaling/signaling.gyp' GYP_DIRS['signaling'].variables = gyp_vars.copy() GYP_DIRS['signaling'].variables.update( - build_for_test=0 + build_for_test=0, + build_for_standalone=0 ) GYP_DIRS['signaling'].sandbox_vars['FINAL_LIBRARY'] = 'xul' # Excluded for various symbol conflicts @@ -92,7 +93,16 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': GYP_DIRS['signalingtest'].input = 'signaling/signaling.gyp' GYP_DIRS['signalingtest'].variables = gyp_vars.copy() GYP_DIRS['signalingtest'].variables.update( - build_for_test=1 + build_for_test=1, + build_for_standalone=0 ) GYP_DIRS['signalingtest'].non_unified_sources += signaling_non_unified_sources + GYP_DIRS += ['signalingstandalone'] + GYP_DIRS['signalingstandalone'].input = 'signaling/signaling.gyp' + GYP_DIRS['signalingstandalone'].variables = gyp_vars.copy() + GYP_DIRS['signalingstandalone'].variables.update( + build_for_test=0, + build_for_standalone=1 + ) + GYP_DIRS['signalingstandalone'].non_unified_sources += signaling_non_unified_sources diff --git a/media/webrtc/signaling/signaling.gyp b/media/webrtc/signaling/signaling.gyp index 240fa3f76d2..02e965b15cf 100644 --- a/media/webrtc/signaling/signaling.gyp +++ b/media/webrtc/signaling/signaling.gyp @@ -77,8 +77,6 @@ './src/media-conduit/CodecStatistics.h', './src/media-conduit/CodecStatistics.cpp', './src/media-conduit/RunningStat.h', - './src/media-conduit/GmpVideoCodec.cpp', - './src/media-conduit/WebrtcGmpVideoCodec.cpp', # Common './src/common/CommonTypes.h', './src/common/csf_common.h', @@ -98,8 +96,6 @@ # PeerConnection './src/peerconnection/MediaPipelineFactory.cpp', './src/peerconnection/MediaPipelineFactory.h', - './src/peerconnection/MediaStreamList.cpp', - './src/peerconnection/MediaStreamList.h', './src/peerconnection/PeerConnectionCtx.cpp', './src/peerconnection/PeerConnectionCtx.h', './src/peerconnection/PeerConnectionImpl.cpp', @@ -220,11 +216,13 @@ 'MOZ_WEBRTC_OMX' ], }], - ['build_for_test==0', { + ['(build_for_test==0) and (build_for_standalone==0)', { 'defines' : [ - 'MOZILLA_INTERNAL_API' + 'MOZILLA_INTERNAL_API', ], 'sources': [ + './src/peerconnection/MediaStreamList.cpp', + './src/peerconnection/MediaStreamList.h', './src/peerconnection/WebrtcGlobalInformation.cpp', './src/peerconnection/WebrtcGlobalInformation.h', ], @@ -236,7 +234,27 @@ 'defines' : [ 'NO_CHROMIUM_LOGGING', 'USE_FAKE_MEDIA_STREAMS', - 'USE_FAKE_PCOBSERVER' + 'USE_FAKE_PCOBSERVER', + 'MOZILLA_EXTERNAL_LINKAGE', + ], + }], + ['build_for_standalone==0', { + 'sources': [ + './src/media-conduit/GmpVideoCodec.cpp', + './src/media-conduit/WebrtcGmpVideoCodec.cpp', + ], + }], + ['build_for_standalone!=0', { + 'include_dirs': [ + './test' + ], + 'defines' : [ + 'MOZILLA_INTERNAL_API', + 'MOZILLA_XPCOMRT_API', + 'MOZILLA_EXTERNAL_LINKAGE', + 'NO_CHROMIUM_LOGGING', + 'USE_FAKE_MEDIA_STREAMS', + 'USE_FAKE_PCOBSERVER', ], }], ['(OS=="linux") or (OS=="android")', { diff --git a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp index 17d719f6410..b5598d9b9d6 100644 --- a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp +++ b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp @@ -11,7 +11,9 @@ #include "nscore.h" #ifdef MOZILLA_INTERNAL_API #include "nsString.h" +#if !defined(MOZILLA_XPCOMRT_API) #include "mozilla/Preferences.h" +#endif // !defined(MOZILLA_XPCOMRT_API) #else #include "nsStringAPI.h" #endif @@ -57,11 +59,13 @@ static WebRtcTraceCallback gWebRtcCallback; #ifdef MOZILLA_INTERNAL_API void GetWebRtcLogPrefs(uint32_t *aTraceMask, nsACString* aLogFile, nsACString *aAECLogDir, bool *aMultiLog) { +#if !defined(MOZILLA_XPCOMRT_API) *aMultiLog = mozilla::Preferences::GetBool("media.webrtc.debug.multi_log"); *aTraceMask = mozilla::Preferences::GetUint("media.webrtc.debug.trace_mask"); mozilla::Preferences::GetCString("media.webrtc.debug.log_file", aLogFile); mozilla::Preferences::GetCString("media.webrtc.debug.aec_log_dir", aAECLogDir); webrtc::Trace::set_aec_debug_size(mozilla::Preferences::GetUint("media.webrtc.debug.aec_dump_max_size")); +#endif // !defined(MOZILLA_XPCOMRT_API) } #endif @@ -141,7 +145,7 @@ void ConfigWebRtcLog(uint32_t trace_mask, nsCString &aLogFile, nsCString &aAECLo webrtc::Trace::SetTraceFile(aLogFile.get(), multi_log); } } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // Capture the final choices for the trace settings. mozilla::Preferences::SetCString("media.webrtc.debug.log_file", aLogFile); mozilla::Preferences::SetUint("media.webrtc.debug.trace_mask", trace_mask); diff --git a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp index 26aba7a4486..444f8fa97b4 100755 --- a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp @@ -18,7 +18,7 @@ #include "nsIPrefService.h" #include "nsIPrefBranch.h" #include "nsThreadUtils.h" -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) #include "Latency.h" #include "mozilla/Telemetry.h" #endif @@ -369,7 +369,7 @@ WebrtcAudioConduit::ConfigureSendMediaCodec(const AudioCodecConfig* codecConfig) return kMediaConduitUnknownError; } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // TEMPORARY - see bug 694814 comment 2 nsresult rv; nsCOMPtr prefs = do_GetService("@mozilla.org/preferences-service;1", &rv); @@ -530,7 +530,7 @@ WebrtcAudioConduit::SendAudioFrame(const int16_t audio_data[], return kMediaConduitSessionNotInited; } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (PR_LOG_TEST(GetLatencyLog(), PR_LOG_DEBUG)) { struct Processing insert = { TimeStamp::Now(), 0 }; mProcessing.AppendElement(insert); @@ -624,7 +624,7 @@ WebrtcAudioConduit::GetAudioFrame(int16_t speechData[], if (GetAVStats(&jitter_buffer_delay_ms, &playout_buffer_delay_ms, &avsync_offset_ms)) { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (avsync_offset_ms < 0) { Telemetry::Accumulate(Telemetry::WEBRTC_AVSYNC_WHEN_VIDEO_LAGS_AUDIO_MS, -avsync_offset_ms); @@ -642,7 +642,7 @@ WebrtcAudioConduit::GetAudioFrame(int16_t speechData[], mLastSyncLog = mSamples; } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (PR_LOG_TEST(GetLatencyLog(), PR_LOG_DEBUG)) { if (mProcessing.Length() > 0) { unsigned int now; @@ -679,7 +679,7 @@ WebrtcAudioConduit::ReceivedRTPPacket(const void *data, int len) if(mEngineReceiving) { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (PR_LOG_TEST(GetLatencyLog(), PR_LOG_DEBUG)) { // timestamp is at 32 bits in ([1]) struct Processing insert = { TimeStamp::Now(), @@ -817,7 +817,7 @@ int WebrtcAudioConduit::SendPacket(int channel, const void* data, int len) { CSFLogDebug(logTag, "%s : channel %d", __FUNCTION__, channel); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (PR_LOG_TEST(GetLatencyLog(), PR_LOG_DEBUG)) { if (mProcessing.Length() > 0) { TimeStamp started = mProcessing[0].mTimeStamp; diff --git a/media/webrtc/signaling/src/media-conduit/AudioConduit.h b/media/webrtc/signaling/src/media-conduit/AudioConduit.h index e862c2a8159..507f3d7a67a 100755 --- a/media/webrtc/signaling/src/media-conduit/AudioConduit.h +++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.h @@ -171,7 +171,7 @@ public: mChannel(-1), mCurSendCodecConfig(nullptr), mCaptureDelay(150), -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) mLastTimestamp(0), #endif // MOZILLA_INTERNAL_API mSamples(0), @@ -282,7 +282,7 @@ private: // Current "capture" delay (really output plus input delay) int32_t mCaptureDelay; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) uint32_t mLastTimestamp; #endif // MOZILLA_INTERNAL_API diff --git a/media/webrtc/signaling/src/media-conduit/CodecStatistics.cpp b/media/webrtc/signaling/src/media-conduit/CodecStatistics.cpp index 39b7fd87ed1..f13dc7efad3 100644 --- a/media/webrtc/signaling/src/media-conduit/CodecStatistics.cpp +++ b/media/webrtc/signaling/src/media-conduit/CodecStatistics.cpp @@ -5,7 +5,9 @@ #include "CodecStatistics.h" #include "CSFLog.h" +#if !defined(MOZILLA_XPCOMRT_API) #include "mozilla/Telemetry.h" +#endif // !defined(MOZILLA_XPCOMRT_API) using namespace mozilla; using namespace webrtc; @@ -117,8 +119,10 @@ void VideoCodecStatistics::ReceiveStateChange(const int aChannel, TimeDuration timeDelta = TimeStamp::Now() - mReceiveFailureTime; CSFLogError(logTag, "Video error duration: %u ms", static_cast(timeDelta.ToMilliseconds())); +#if !defined(MOZILLA_XPCOMRT_API) Telemetry::Accumulate(Telemetry::WEBRTC_VIDEO_ERROR_RECOVERY_MS, static_cast(timeDelta.ToMilliseconds())); +#endif // mRecoveredLosses++; // to calculate losses per minute mTotalLossTime += timeDelta; // To calculate % time in recovery @@ -140,16 +144,22 @@ void VideoCodecStatistics::EndOfCallStats() if (callDelta.ToSeconds() != 0) { uint32_t recovered_per_min = mRecoveredBeforeLoss/(callDelta.ToSeconds()/60); CSFLogError(logTag, "Video recovery before error per min %u", recovered_per_min); +#if !defined(MOZILLA_XPCOMRT_API) Telemetry::Accumulate(Telemetry::WEBRTC_VIDEO_RECOVERY_BEFORE_ERROR_PER_MIN, recovered_per_min); +#endif // !defined(MOZILLA_XPCOMRT_API) uint32_t err_per_min = mRecoveredLosses/(callDelta.ToSeconds()/60); CSFLogError(logTag, "Video recovery after error per min %u", err_per_min); +#if !defined(MOZILLA_XPCOMRT_API) Telemetry::Accumulate(Telemetry::WEBRTC_VIDEO_RECOVERY_AFTER_ERROR_PER_MIN, err_per_min); +#endif // !defined(MOZILLA_XPCOMRT_API) float percent = (mTotalLossTime.ToSeconds()*100)/callDelta.ToSeconds(); CSFLogError(logTag, "Video error time percentage %f%%", percent); +#if !defined(MOZILLA_XPCOMRT_API) Telemetry::Accumulate(Telemetry::WEBRTC_VIDEO_DECODE_ERROR_TIME_PERMILLE, static_cast(percent*10)); +#endif // !defined(MOZILLA_XPCOMRT_API) } } #endif diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp index b85f51e3f8a..bcb8e48eba2 100755 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp @@ -278,7 +278,7 @@ WebrtcVideoConduit::Init() { CSFLogDebug(logTag, "%s this=%p", __FUNCTION__, this); -#ifdef MOZILLA_INTERNAL_API +#if defined(MOZILLA_INTERNAL_API) && !defined(MOZILLA_INTERNAL_API) // already know we must be on MainThread barring unit test weirdness MOZ_ASSERT(NS_IsMainThread()); diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index 3911263c23c..e2a33263e9b 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -16,7 +16,7 @@ #include "nspr.h" #include "srtp.h" -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) #include "VideoSegment.h" #include "Layers.h" #include "ImageTypes.h" @@ -38,7 +38,7 @@ #include "transportlayerice.h" #include "runnable_utils.h" #include "libyuv/convert.h" -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) #include "mozilla/PeerIdentity.h" #endif #include "mozilla/gfx/Point.h" @@ -643,7 +643,7 @@ void MediaPipelineTransmit::AttachToTrack(const std::string& track_id) { #endif } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) void MediaPipelineTransmit::UpdateSinkIdentity_m(nsIPrincipal* principal, const PeerIdentity* sinkIdentity) { ASSERT_ON_THREAD(main_thread_); @@ -931,7 +931,7 @@ NewData(MediaStreamGraph* graph, TrackID tid, iter.Next(); } } else if (media.GetType() == MediaSegment::VIDEO) { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) VideoSegment* video = const_cast( static_cast(&media)); @@ -1044,7 +1044,7 @@ void MediaPipelineTransmit::PipelineListener::ProcessAudioChunk( } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) void MediaPipelineTransmit::PipelineListener::ProcessVideoChunk( VideoSessionConduit* conduit, VideoChunk& chunk) { @@ -1234,7 +1234,7 @@ static void AddTrackAndListener(MediaStream* source, const RefPtr& completed, bool queue_track) { // This both adds the listener and the track -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) class Message : public ControlMessage { public: Message(MediaStream* stream, TrackID track, TrackRate rate, @@ -1396,7 +1396,7 @@ nsresult MediaPipelineReceiveVideo::Init() { description_ += track_id_; description_ += "]"; -#ifdef MOZILLA_INTERNAL_API +#if defined(MOZILLA_INTERNAL_API) listener_->AddSelf(new VideoSegment()); #endif @@ -1412,12 +1412,14 @@ MediaPipelineReceiveVideo::PipelineListener::PipelineListener( : GenericReceiveListener(source, track_id, source->GraphRate(), queue_track), width_(640), height_(480), -#ifdef MOZILLA_INTERNAL_API +#if defined(MOZILLA_XPCOMRT_API) + image_(new mozilla::SimpleImageBuffer), +#elif defined(MOZILLA_INTERNAL_API) image_container_(), image_(), #endif monitor_("Video PipelineListener") { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) image_container_ = layers::LayerManager::CreateImageContainer(); #endif } @@ -1428,9 +1430,16 @@ void MediaPipelineReceiveVideo::PipelineListener::RenderVideoFrame( uint32_t time_stamp, int64_t render_time, const RefPtr& video_image) { + #ifdef MOZILLA_INTERNAL_API ReentrantMonitorAutoEnter enter(monitor_); +#endif // MOZILLA_INTERNAL_API +#if defined(MOZILLA_XPCOMRT_API) + if (buffer) { + image_->SetImage(buffer, buffer_size, width_, height_); + } +#elif defined(MOZILLA_INTERNAL_API) if (buffer) { // Create a video frame using |buffer|. #ifdef MOZ_WIDGET_GONK @@ -1473,10 +1482,15 @@ void MediaPipelineReceiveVideo::PipelineListener:: NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) { ReentrantMonitorAutoEnter enter(monitor_); -#ifdef MOZILLA_INTERNAL_API +#if defined(MOZILLA_XPCOMRT_API) + nsRefPtr image = image_; +#elif defined(MOZILLA_INTERNAL_API) nsRefPtr image = image_; // our constructor sets track_rate_ to the graph rate MOZ_ASSERT(track_rate_ == source_->GraphRate()); +#endif + +#if defined(MOZILLA_INTERNAL_API) StreamTime delta = desired_time - played_ticks_; // Don't append if we've already provided a frame that supposedly @@ -1494,6 +1508,12 @@ NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) { } } #endif +#if defined(MOZILLA_XPCOMRT_API) + // Clear the image without deleting the memory. + // This prevents image_ from being used if it + // does not have new content during the next NotifyPull. + image_->SetImage(nullptr, 0, 0, 0); +#endif } diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h index 45317bbca4c..f10c630ec64 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h @@ -27,7 +27,7 @@ #include "runnable_utils.h" #include "transportflow.h" -#ifdef MOZILLA_INTERNAL_API +#if defined(MOZILLA_INTERNAL_API) #include "VideoSegment.h" #endif @@ -406,7 +406,7 @@ public: // written and used from MainThread virtual bool IsVideo() const override { return is_video_; } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // when the principal of the PeerConnection changes, it calls through to here // so that we can determine whether to enable stream transmission virtual void UpdateSinkIdentity_m(nsIPrincipal* principal, @@ -449,7 +449,7 @@ public: samples_10ms_buffer_(nullptr), buffer_current_(0), samplenum_10ms_(0) -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) , last_img_(-1) #endif // MOZILLA_INTERNAL_API { @@ -494,7 +494,7 @@ public: virtual void ProcessAudioChunk(AudioSessionConduit *conduit, TrackRate rate, AudioChunk& chunk); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) virtual void ProcessVideoChunk(VideoSessionConduit *conduit, VideoChunk& chunk); #endif @@ -525,7 +525,7 @@ public: // The number of samples in a 10ms audio chunk. int64_t samplenum_10ms_; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) int32_t last_img_; // serial number of last Image #endif // MOZILLA_INTERNAL_API }; @@ -746,7 +746,9 @@ class MediaPipelineReceiveVideo : public MediaPipelineReceive { private: int width_; int height_; -#ifdef MOZILLA_INTERNAL_API +#if defined(MOZILLA_XPCOMRT_API) + nsRefPtr image_; +#elif defined(MOZILLA_INTERNAL_API) nsRefPtr image_container_; nsRefPtr image_; #endif diff --git a/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp b/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp index 2c8a8f10185..85e632e01e9 100644 --- a/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp +++ b/media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp @@ -16,7 +16,7 @@ #include "signaling/src/jsep/JsepTransport.h" #include "signaling/src/common/PtrVector.h" -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) #include "MediaStreamTrack.h" #include "nsIPrincipal.h" #include "nsIDocument.h" @@ -519,7 +519,7 @@ MediaPipelineFactory::CreateMediaPipelineSending( aRtcpFlow, aFilter); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // implement checking for peerIdentity (where failure == black/silence) nsIDocument* doc = mPC->GetWindow()->GetExtantDoc(); if (doc) { @@ -787,7 +787,7 @@ nsresult MediaPipelineFactory::ConfigureVideoCodecMode(const JsepTrack& aTrack, VideoSessionConduit& aConduit) { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsRefPtr stream = mPCMedia->GetLocalStreamById(aTrack.GetStreamId()); @@ -858,7 +858,7 @@ MediaPipelineFactory::EnsureExternalCodec(VideoSessionConduit& aConduit, #ifdef MOZ_WEBRTC_OMX encoder = OMXVideoCodec::CreateEncoder(OMXVideoCodec::CodecType::CODEC_H264); -#else +#elif !defined(MOZILLA_XPCOMRT_API) encoder = GmpVideoCodec::CreateEncoder(); #endif if (encoder) { @@ -867,11 +867,11 @@ MediaPipelineFactory::EnsureExternalCodec(VideoSessionConduit& aConduit, return kMediaConduitInvalidSendCodec; } } else { - VideoDecoder* decoder; + VideoDecoder* decoder = nullptr; #ifdef MOZ_WEBRTC_OMX decoder = OMXVideoCodec::CreateDecoder(OMXVideoCodec::CodecType::CODEC_H264); -#else +#elif !defined(MOZILLA_XPCOMRT_API) decoder = GmpVideoCodec::CreateDecoder(); #endif if (decoder) { diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp index 465b8dc930d..696c7699cb2 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp @@ -12,7 +12,7 @@ #include "mozilla/Telemetry.h" -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) #include "mozilla/dom/RTCPeerConnectionBinding.h" #include "mozilla/Preferences.h" #include @@ -151,7 +151,7 @@ void PeerConnectionCtx::Destroy() { } } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) typedef Vector> RTCStatsQueries; // Telemetry reporting every second after start of first call. @@ -309,7 +309,7 @@ PeerConnectionCtx::EverySecondTelemetryCallback_m(nsITimer* timer, void *closure nsresult PeerConnectionCtx::Initialize() { initGMP(); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) mConnectionCounter = 0; Telemetry::GetHistogramById(Telemetry::WEBRTC_CALL_COUNT)->Add(0); @@ -372,7 +372,7 @@ nsresult PeerConnectionCtx::Cleanup() { PeerConnectionCtx::~PeerConnectionCtx() { // ensure mTelemetryTimer ends on main thread MOZ_ASSERT(NS_IsMainThread()); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (mTelemetryTimer) { mTelemetryTimer->Cancel(); } diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h index 3855788b7c6..4c7f8616697 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h @@ -49,7 +49,7 @@ class PeerConnectionCtx { friend class PeerConnectionWrapper; friend class mozilla::dom::WebrtcGlobalInformation; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // WebrtcGlobalInformation uses this; we put it here so we don't need to // create another shutdown observer class. mozilla::dom::Sequence @@ -74,7 +74,7 @@ class PeerConnectionCtx { static void EverySecondTelemetryCallback_m(nsITimer* timer, void *); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // Telemetry Peer conection counter int mConnectionCounter; diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index c89726cc90c..b9e32ab7c88 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -46,7 +46,7 @@ #include "signaling/src/jsep/JsepSession.h" #include "signaling/src/jsep/JsepSessionImpl.h" -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) #ifdef XP_WIN // We need to undef the MS macro for nsIDocument::CreateEvent #ifdef CreateEvent @@ -54,9 +54,7 @@ #endif #endif // XP_WIN -#ifdef MOZILLA_INTERNAL_API #include "nsIDocument.h" -#endif #include "nsPerformance.h" #include "nsGlobalWindow.h" #include "nsDOMDataChannel.h" @@ -136,7 +134,7 @@ class JSErrorResult : public ErrorResult public: ~JSErrorResult() { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) WouldReportJSException(); if (IsJSException()) { MOZ_ASSERT(NS_IsMainThread()); @@ -174,7 +172,7 @@ private: }; } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) class TracksAvailableCallback : public DOMMediaStream::OnTracksAvailableCallback { public: @@ -264,7 +262,7 @@ private: }; #endif -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) static nsresult InitNSSInContent() { NS_ENSURE_TRUE(NS_IsMainThread(), NS_ERROR_NOT_SAME_THREAD); @@ -320,7 +318,7 @@ const nsIID nsISupportsWeakReference::COMTypeInfo namespace mozilla { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) RTCStatsQuery::RTCStatsQuery(bool internal) : failed(false), internalStats(internal), @@ -335,7 +333,7 @@ RTCStatsQuery::~RTCStatsQuery() { NS_IMPL_ISUPPORTS0(PeerConnectionImpl) -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) bool PeerConnectionImpl::WrapObject(JSContext* aCx, JS::Handle aGivenProto, @@ -392,7 +390,7 @@ PeerConnectionImpl::PeerConnectionImpl(const GlobalObject* aGlobal) , mTrickle(true) // TODO(ekr@rtfm.com): Use pref , mShouldSuppressNegotiationNeeded(false) { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) MOZ_ASSERT(NS_IsMainThread()); if (aGlobal) { mWindow = do_QueryInterface(aGlobal->GetAsSupports()); @@ -401,7 +399,7 @@ PeerConnectionImpl::PeerConnectionImpl(const GlobalObject* aGlobal) CSFLogInfo(logTag, "%s: PeerConnectionImpl constructor for %s", __FUNCTION__, mHandle.c_str()); STAMP_TIMECARD(mTimeCard, "Constructor Completed"); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) mAllowIceLoopback = Preferences::GetBool( "media.peerconnection.ice.loopback", false); #endif @@ -428,7 +426,7 @@ PeerConnectionImpl::~PeerConnectionImpl() Close(); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) { // Deregister as an NSS Shutdown Object nsNSSShutDownPreventionLock locker; @@ -454,7 +452,7 @@ PeerConnectionImpl::MakeMediaStream() nsRefPtr stream = DOMMediaStream::CreateSourceStream(GetWindow()); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // Make the stream data (audio/video samples) accessible to the receiving page. // We're only certain that privacy hasn't been requested if we're connected. if (mDtlsConnected && !PrivacyRequested()) { @@ -510,7 +508,7 @@ nsresult PeerConnectionImpl::ConvertRTCConfiguration(const RTCConfiguration& aSrc, IceConfiguration *aDst) { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (aSrc.mIceServers.WasPassed()) { for (size_t i = 0; i < aSrc.mIceServers.Value().Length(); i++) { nsresult rv = AddIceServer(aSrc.mIceServers.Value()[i], aDst); @@ -525,7 +523,7 @@ nsresult PeerConnectionImpl::AddIceServer(const RTCIceServer &aServer, IceConfiguration *aDst) { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) NS_ENSURE_STATE(aServer.mUrls.WasPassed()); NS_ENSURE_STATE(aServer.mUrls.Value().IsStringSequence()); auto &urls = aServer.mUrls.Value().GetAsStringSequence(); @@ -645,7 +643,7 @@ PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver, mSTSThread = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &res); MOZ_ASSERT(mSTSThread); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // Initialize NSS if we are in content process. For chrome process, NSS should already // been initialized. @@ -673,7 +671,7 @@ PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver, // Ok if we truncate this. char temp[128]; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsAutoCString locationCStr; nsIDOMLocation* location; res = mWindow->GetLocation(&location); @@ -840,6 +838,7 @@ class CompareCodecPriority { nsresult PeerConnectionImpl::ConfigureJsepSessionCodecs() { +#if !defined(MOZILLA_XPCOMRT_API) nsresult res; nsCOMPtr prefs = do_GetService("@mozilla.org/preferences-service;1", &res); @@ -890,7 +889,7 @@ PeerConnectionImpl::ConfigureJsepSessionCodecs() { #endif // MOZ_WEBRTC_OMX -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) bool softwareH264Enabled = PeerConnectionCtx::GetInstance()->gmpHasH264(); #else // For unit-tests @@ -991,7 +990,7 @@ PeerConnectionImpl::ConfigureJsepSessionCodecs() { } std::stable_sort(codecs.begin(), codecs.end(), comparator); - +#endif // !defined(MOZILLA_XPCOMRT_API) return NS_OK; } @@ -1010,7 +1009,7 @@ PeerConnectionImpl::EnsureDataConnection(uint16_t aNumstreams) { PC_AUTO_ENTER_API_CALL_NO_CHECK(); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (mDataConnection) { CSFLogDebug(logTag,"%s DataConnection already connected",__FUNCTION__); // Ignore the request to connect when already connected. This entire @@ -1120,7 +1119,7 @@ PeerConnectionImpl::InitializeDataChannel() return NS_OK; } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) uint32_t channels = codec->mChannels; if (channels > MAX_NUM_STREAMS) { channels = MAX_NUM_STREAMS; @@ -1166,7 +1165,7 @@ PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel, uint16_t aStream, ErrorResult &rv) { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsRefPtr result; rv = CreateDataChannel(aLabel, aProtocol, aType, outOfOrderAllowed, aMaxTime, aMaxNum, aExternalNegotiated, @@ -1191,7 +1190,7 @@ PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel, PC_AUTO_ENTER_API_CALL_NO_CHECK(); MOZ_ASSERT(aRetval); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsRefPtr dataChannel; DataChannelConnection::Type theType = static_cast(aType); @@ -1275,7 +1274,7 @@ do_QueryObjectReferent(nsIWeakReference* aRawPtr) { } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // Not a member function so that we don't need to keep the PC live. static void NotifyDataChannel_m(nsRefPtr aChannel, nsRefPtr aObserver) @@ -1303,7 +1302,7 @@ PeerConnectionImpl::NotifyDataChannel(already_AddRefed aChannel) CSFLogDebug(logTag, "%s: channel: %p", __FUNCTION__, channel); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsCOMPtr domchannel; nsresult rv = NS_NewDOMDataChannel(already_AddRefed(channel), mWindow, getter_AddRefs(domchannel)); @@ -1328,7 +1327,7 @@ NS_IMETHODIMP PeerConnectionImpl::CreateOffer(const RTCOfferOptions& aOptions) { JsepOfferOptions options; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (aOptions.mOfferToReceiveAudio.WasPassed()) { options.mOfferToReceiveAudio = mozilla::Some(size_t(aOptions.mOfferToReceiveAudio.Value())); @@ -1475,7 +1474,7 @@ PeerConnectionImpl::SetLocalDescription(int32_t aAction, const char* aSDP) STAMP_TIMECARD(mTimeCard, "Set Local Description"); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) bool isolated = mMedia->AnyLocalStreamHasPeerIdentity(); mPrivacyRequested = mPrivacyRequested || isolated; #endif @@ -1656,7 +1655,7 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) } CSFLogDebug(logTag, "Added remote stream %s", info->GetId().c_str()); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) info->GetMediaStream()->AssignId(NS_ConvertUTF8toUTF16(streamId.c_str())); #else info->GetMediaStream()->AssignId((streamId)); @@ -1687,7 +1686,7 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) } // Now that the streams are all set up, notify about track availability. -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) TracksAvailableCallback* tracksAvailableCallback = new TracksAvailableCallback(numNewAudioTracks, numNewVideoTracks, @@ -1722,7 +1721,7 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) } pco->OnSetRemoteDescriptionSuccess(jrv); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) startCallTelem(); #endif } @@ -1733,7 +1732,7 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) // WebRTC uses highres time relative to the UNIX epoch (Jan 1, 1970, UTC). -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsresult PeerConnectionImpl::GetTimeSinceEpoch(DOMHighResTimeStamp *result) { MOZ_ASSERT(NS_IsMainThread()); @@ -1765,7 +1764,7 @@ NS_IMETHODIMP PeerConnectionImpl::GetStats(MediaStreamTrack *aSelector) { PC_AUTO_ENTER_API_CALL(true); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (!mMedia) { // Since we zero this out before the d'tor, we should check. return NS_ERROR_UNEXPECTED; @@ -1800,7 +1799,7 @@ PeerConnectionImpl::AddIceCandidate(const char* aCandidate, const char* aMid, un CSFLogDebug(logTag, "AddIceCandidate: %s", aCandidate); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // When remote candidates are added before our ICE ctx is up and running // (the transition to New is async through STS, so this is not impossible), // we won't record them as trickle candidates. Is this what we want? @@ -1863,7 +1862,7 @@ PeerConnectionImpl::CloseStreams() { return NS_OK; } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsresult PeerConnectionImpl::SetPeerIdentity(const nsAString& aPeerIdentity) { @@ -1897,7 +1896,7 @@ PeerConnectionImpl::SetDtlsConnected(bool aPrivacyRequested) // fixate on that peer. Dealing with multiple peers or connections is more // than this run-down wreck of an object can handle. // Besides, this is only used to say if we have been connected ever. -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (!mPrivacyRequested && !aPrivacyRequested && !mDtlsConnected) { // now we know that privacy isn't needed for sure nsIDocument* doc = GetWindow()->GetExtantDoc(); @@ -1913,7 +1912,7 @@ PeerConnectionImpl::SetDtlsConnected(bool aPrivacyRequested) return NS_OK; } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) void PeerConnectionImpl::PrincipalChanged(DOMMediaStream* aMediaStream) { nsIDocument* doc = GetWindow()->GetExtantDoc(); @@ -1925,7 +1924,7 @@ PeerConnectionImpl::PrincipalChanged(DOMMediaStream* aMediaStream) { } #endif -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsresult PeerConnectionImpl::GetRemoteTrackId(const std::string streamId, TrackID numericTrackId, @@ -1942,7 +1941,7 @@ PeerConnectionImpl::GetRemoteTrackId(const std::string streamId, std::string PeerConnectionImpl::GetTrackId(const MediaStreamTrack& aTrack) { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsString wideTrackId; aTrack.GetId(wideTrackId); return NS_ConvertUTF16toUTF8(wideTrackId).get(); @@ -1954,7 +1953,7 @@ PeerConnectionImpl::GetTrackId(const MediaStreamTrack& aTrack) std::string PeerConnectionImpl::GetStreamId(const DOMMediaStream& aStream) { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsString wideStreamId; aStream.GetId(wideStreamId); return NS_ConvertUTF16toUTF8(wideStreamId).get(); @@ -2016,7 +2015,7 @@ PeerConnectionImpl::AddTrack(MediaStreamTrack& aTrack, } if (aTrack.AsVideoStreamTrack()) { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (!Preferences::GetBool("media.peerconnection.video.enabled", true)) { // Before this code was moved, this would silently ignore just like it // does now. Is this actually what we want to do? @@ -2091,7 +2090,7 @@ PeerConnectionImpl::ReplaceTrack(MediaStreamTrack& aThisTrack, } JSErrorResult jrv; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (&aThisTrack == &aWithTrack) { pco->OnReplaceTrackSuccess(jrv); if (jrv.Failed()) { @@ -2308,7 +2307,7 @@ PeerConnectionImpl::PluginCrash(uint64_t aPluginID, CSFLogError(logTag, "%s: Our plugin %llu crashed", __FUNCTION__, static_cast(aPluginID)); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsCOMPtr doc = mWindow->GetExtantDoc(); if (!doc) { NS_WARNING("Couldn't get document for PluginCrashed event!"); @@ -2350,7 +2349,7 @@ PeerConnectionImpl::CloseInt() if (mJsepSession) { mJsepSession->Close(); } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (mDataConnection) { CSFLogInfo(logTag, "%s: Destroying DataChannelConnection %p for %s", __FUNCTION__, (void *) mDataConnection.get(), mHandle.c_str()); @@ -2373,7 +2372,7 @@ PeerConnectionImpl::ShutdownMedia() if (!mMedia) return; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // before we destroy references to local streams, detach from them for(uint32_t i = 0; i < media()->LocalStreamsLength(); ++i) { LocalSourceStreamInfo *info = media()->GetLocalStreamByIndex(i); @@ -2392,7 +2391,7 @@ PeerConnectionImpl::ShutdownMedia() mMedia.forget().take()->SelfDestruct(); } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // If NSS is shutting down, then we need to get rid of the DTLS // identity right now; otherwise, we'll cause wreckage when we do // finally deallocate it in our destructor. @@ -2648,7 +2647,7 @@ PeerConnectionImpl::SendLocalIceCandidateToContent( NS_DISPATCH_NORMAL); } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) static bool isDone(PCImplIceConnectionState state) { return state != PCImplIceConnectionState::Checking && state != PCImplIceConnectionState::New; @@ -2674,7 +2673,7 @@ void PeerConnectionImpl::IceConnectionStateChange( auto domState = toDomIceConnectionState(state); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (!isDone(mIceConnectionState) && isDone(domState)) { // mIceStartTime can be null if going directly from New to Closed, in which // case we don't count it as a success or a failure. @@ -2710,7 +2709,7 @@ void PeerConnectionImpl::IceConnectionStateChange( STAMP_TIMECARD(mTimeCard, "Ice state: new"); break; case PCImplIceConnectionState::Checking: -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // For telemetry mIceStartTime = TimeStamp::Now(); #endif @@ -2800,7 +2799,7 @@ PeerConnectionImpl::EndOfLocalCandidates(const std::string& defaultAddr, mJsepSession->EndOfLocalCandidates(defaultAddr, defaultPort, level); } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsresult PeerConnectionImpl::BuildStatsQuery_m( mozilla::dom::MediaStreamTrack *aSelector, @@ -3248,7 +3247,7 @@ void PeerConnectionImpl::DeliverStatsReportToPCObserver_m( void PeerConnectionImpl::RecordLongtermICEStatistics() { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) WebrtcGlobalInformation::StoreLongTermICEStatistics(*this); #endif } @@ -3280,7 +3279,7 @@ PeerConnectionImpl::IceStreamReady(NrIceMediaStream *aStream) CSFLogDebug(logTag, "%s: %s", __FUNCTION__, aStream->name().c_str()); } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) //Telemetry for when calls start void PeerConnectionImpl::startCallTelem() { @@ -3299,7 +3298,7 @@ NS_IMETHODIMP PeerConnectionImpl::GetLocalStreams(nsTArray >& result) { PC_AUTO_ENTER_API_CALL_NO_CHECK(); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) for(uint32_t i=0; i < media()->LocalStreamsLength(); i++) { LocalSourceStreamInfo *info = media()->GetLocalStreamByIndex(i); NS_ENSURE_TRUE(info, NS_ERROR_UNEXPECTED); @@ -3315,7 +3314,7 @@ NS_IMETHODIMP PeerConnectionImpl::GetRemoteStreams(nsTArray >& result) { PC_AUTO_ENTER_API_CALL_NO_CHECK(); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) for(uint32_t i=0; i < media()->RemoteStreamsLength(); i++) { RemoteSourceStreamInfo *info = media()->GetRemoteStreamByIndex(i); NS_ENSURE_TRUE(info, NS_ERROR_UNEXPECTED); diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h index 3cf6dd965d7..c543fb24ae2 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h @@ -33,7 +33,7 @@ #include "mozilla/dom/PeerConnectionImplEnumsBinding.h" #include "StreamBuffer.h" -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) #include "mozilla/TimeStamp.h" #include "mozilla/net/DataChannel.h" #include "VideoUtils.h" @@ -129,7 +129,7 @@ using mozilla::DtlsIdentity; using mozilla::ErrorResult; using mozilla::NrIceStunServer; using mozilla::NrIceTurnServer; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) using mozilla::PeerIdentity; #endif @@ -186,7 +186,7 @@ private: std::vector mTurnServers; }; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // Not an inner class so we can forward declare. class RTCStatsQuery { public: @@ -228,7 +228,7 @@ class RTCStatsQuery { #define PC_AUTO_ENTER_API_CALL_NO_CHECK() CheckThread() class PeerConnectionImpl final : public nsISupports, -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) public mozilla::DataChannelConnection::DataConnectionListener, public nsNSSShutDownObject, public DOMMediaStream::PrincipalChangeObserver, @@ -253,7 +253,7 @@ public: NS_DECL_THREADSAFE_ISUPPORTS -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) bool WrapObject(JSContext* aCx, JS::Handle aGivenProto, JS::MutableHandle aReflector); #endif @@ -271,7 +271,7 @@ public: // DataConnection observers void NotifyDataChannel(already_AddRefed aChannel) -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // PeerConnectionImpl only inherits from mozilla::DataChannelConnection // inside libxul. override @@ -425,7 +425,7 @@ public: nsresult GetPeerIdentity(nsAString& peerIdentity) { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) if (mPeerIdentity) { peerIdentity = mPeerIdentity->ToString(); return NS_OK; @@ -436,7 +436,7 @@ public: return NS_OK; } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) const PeerIdentity* GetPeerIdentity() const { return mPeerIdentity; } nsresult SetPeerIdentity(const nsAString& peerIdentity); @@ -583,7 +583,7 @@ public: bool HasMedia() const; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // initialize telemetry for when calls start void startCallTelem(); @@ -626,9 +626,11 @@ private: MOZ_ASSERT(CheckThreadInt(), "Wrong thread"); } bool CheckThreadInt() const { -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // Thread assertions are disabled in the C++ unit tests because those // make API calls off the main thread. + // This affects the standalone version of WebRTC since it is also used + // for an alternate build of the unit tests. // TODO(ekr@rtfm.com): Fix the unit tests so they don't do that. bool on; NS_ENSURE_SUCCESS(mThread->IsOnCurrentThread(&on), false); @@ -637,7 +639,7 @@ private: return true; } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) void virtualDestroyNSSReference() final; void destructorSafeDestroyNSSReference(); nsresult GetTimeSinceEpoch(DOMHighResTimeStamp *result); @@ -655,7 +657,7 @@ private: const mozilla::JsepApplicationCodecDescription** codec, uint16_t* level) const; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) static void GetStatsForPCObserver_s( const std::string& pcHandle, nsAutoPtr query); @@ -707,7 +709,7 @@ private: // identity-related fields mozilla::RefPtr mIdentity; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // The entity on the other end of the peer-to-peer connection; // void if they are not yet identified, and no identity setting has been set nsAutoPtr mPeerIdentity; @@ -729,7 +731,7 @@ private: // The target to run stuff on nsCOMPtr mSTSThread; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // DataConnection that's used to get all the DataChannels nsRefPtr mDataConnection; #endif @@ -741,7 +743,7 @@ private: mozilla::UniquePtr mUuidGen; mozilla::UniquePtr mJsepSession; -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // Start time of ICE, used for telemetry mozilla::TimeStamp mIceStartTime; // Start time of call used for Telemetry diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp index daf22747aed..1e8cf2f8991 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp @@ -23,6 +23,7 @@ #include "signaling/src/jsep/JsepSession.h" #include "signaling/src/jsep/JsepTransport.h" +#if !defined(MOZILLA_XPCOMRT_API) #include "nsNetCID.h" #include "nsNetUtil.h" #include "nsICancelable.h" @@ -31,9 +32,11 @@ #include "nsIContentPolicy.h" #include "nsIProxyInfo.h" #include "nsIProtocolProxyService.h" +#endif // !defined(MOZILLA_XPCOMRT_API) + #include "nsProxyRelease.h" -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) #include "MediaStreamList.h" #include "nsIScriptGlobalObject.h" #include "mozilla/Preferences.h" @@ -153,6 +156,7 @@ PeerConnectionImpl* PeerConnectionImpl::CreatePeerConnection() return pc; } +#if !defined(MOZILLA_XPCOMRT_API) NS_IMETHODIMP PeerConnectionMedia::ProtocolProxyQueryHandler:: OnProxyAvailable(nsICancelable *request, nsIChannel *aChannel, @@ -199,6 +203,7 @@ OnProxyAvailable(nsICancelable *request, } NS_IMPL_ISUPPORTS(PeerConnectionMedia::ProtocolProxyQueryHandler, nsIProtocolProxyCallback) +#endif // !defined(MOZILLA_XPCOMRT_API) PeerConnectionMedia::PeerConnectionMedia(PeerConnectionImpl *parent) : mParent(parent), @@ -217,6 +222,10 @@ nsresult PeerConnectionMedia::Init(const std::vector& stun_serv const std::vector& turn_servers) { nsresult rv; +#if defined(MOZILLA_XPCOMRT_API) + // TODO(Bug 1126039) Standalone XPCOMRT does not currently support nsIProtocolProxyService or nsIIOService + mProxyResolveCompleted = true; +#else nsCOMPtr pps = do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv); @@ -237,7 +246,7 @@ nsresult PeerConnectionMedia::Init(const std::vector& stun_serv nsCOMPtr channel; -#ifdef MOZILLA_INTERNAL_API +#if defined(MOZILLA_INTERNAL_API) nsCOMPtr principal = mParent->GetWindow()->GetExtantDoc(); #else // For unit-tests @@ -256,7 +265,7 @@ nsresult PeerConnectionMedia::Init(const std::vector& stun_serv CSFLogError(logTag, "%s: Failed to get systemPrincipal: %d", __FUNCTION__, (int)rv); return NS_ERROR_FAILURE; } -#endif +#endif // defined(MOZILLA_INTERNAL_API) rv = NS_NewChannel(getter_AddRefs(channel), fakeHttpsLocation, @@ -279,6 +288,7 @@ nsresult PeerConnectionMedia::Init(const std::vector& stun_serv CSFLogError(logTag, "%s: Failed to resolve protocol proxy: %d", __FUNCTION__, (int)rv); return NS_ERROR_FAILURE; } +#endif // defined(MOZILLA_XPCOMRT_API) // TODO(ekr@rtfm.com): need some way to set not offerer later // Looks like a bug in the NrIceCtx API. @@ -296,7 +306,7 @@ nsresult PeerConnectionMedia::Init(const std::vector& stun_serv return rv; } // Give us a way to globally turn off TURN support -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) bool disabled = Preferences::GetBool("media.peerconnection.turn.disable", false); #else bool disabled = false; @@ -1045,7 +1055,7 @@ LocalSourceStreamInfo::TakePipelineFrom(RefPtr& info, return NS_OK; } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) /** * Tells you if any local streams is isolated to a specific peer identity. * Obviously, we want all the streams to be isolated equally so that they can @@ -1139,7 +1149,7 @@ SourceStreamInfo::AnyCodecHasPluginID(uint64_t aPluginID) return false; } -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsRefPtr SourceStreamInfo::GetVideoTrackByTrackId(const std::string& trackId) { diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h index 46890e8d177..377247503a2 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h @@ -15,7 +15,9 @@ #include "mozilla/RefPtr.h" #include "mozilla/UniquePtr.h" #include "nsComponentManagerUtils.h" +#if !defined(MOZILLA_XPCOMRT_API) #include "nsIProtocolProxyCallback.h" +#endif #ifdef USE_FAKE_MEDIA_STREAMS #include "FakeMediaStreams.h" @@ -27,7 +29,7 @@ #include "signaling/src/jsep/JsepSession.h" #include "AudioSegment.h" -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) #include "Layers.h" #include "VideoUtils.h" #include "ImageLayers.h" @@ -105,7 +107,7 @@ public: void DetachTransport_s(); void DetachMedia_m(); bool AnyCodecHasPluginID(uint64_t aPluginID); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) nsRefPtr GetVideoTrackByTrackId(const std::string& trackId); #endif protected: @@ -134,7 +136,7 @@ public: const std::string& oldTrackId, const std::string& newTrackId); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) void UpdateSinkIdentity_m(nsIPrincipal* aPrincipal, const PeerIdentity* aSinkIdentity); #endif @@ -159,7 +161,7 @@ class RemoteSourceStreamInfo : public SourceStreamInfo { void SyncPipeline(RefPtr aPipeline); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) void UpdatePrincipal_m(nsIPrincipal* aPrincipal); #endif @@ -296,7 +298,7 @@ class PeerConnectionMedia : public sigslot::has_slots<> { const std::string& newStreamId, const std::string& aNewTrack); -#ifdef MOZILLA_INTERNAL_API +#if !defined(MOZILLA_EXTERNAL_LINKAGE) // In cases where the peer isn't yet identified, we disable the pipeline (not // the stream, that would potentially affect others), so that it sends // black/silence. Once the peer is identified, re-enable those streams. @@ -391,6 +393,7 @@ class PeerConnectionMedia : public sigslot::has_slots<> { SignalEndOfLocalCandidates; private: +#if !defined(MOZILLA_XPCOMRT_API) class ProtocolProxyQueryHandler : public nsIProtocolProxyCallback { public: explicit ProtocolProxyQueryHandler(PeerConnectionMedia *pcm) : @@ -406,6 +409,7 @@ class PeerConnectionMedia : public sigslot::has_slots<> { RefPtr pcm_; virtual ~ProtocolProxyQueryHandler() {} }; +#endif // !defined(MOZILLA_XPCOMRT_API) // Shutdown media transport. Must be called on STS thread. void ShutdownMediaTransport_s(); diff --git a/media/webrtc/signaling/test/FakeMediaStreams.h b/media/webrtc/signaling/test/FakeMediaStreams.h index 39e63d145d6..32f2518d154 100644 --- a/media/webrtc/signaling/test/FakeMediaStreams.h +++ b/media/webrtc/signaling/test/FakeMediaStreams.h @@ -33,6 +33,15 @@ namespace mozilla { class MediaSegment; }; +class Fake_VideoSink { +public: + Fake_VideoSink() {} + virtual void SegmentReady(mozilla::MediaSegment* aSegment) = 0; + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Fake_VideoSink) +protected: + virtual ~Fake_VideoSink() {} +}; + class Fake_SourceMediaStream; class Fake_MediaStreamListener @@ -82,6 +91,16 @@ class Fake_MediaStream { mListeners.erase(aListener); } + void NotifyPull(mozilla::MediaStreamGraph* graph, + mozilla::StreamTime aDesiredTime) { + + mozilla::MutexAutoLock lock(mMutex); + std::set::iterator it; + for (it = mListeners.begin(); it != mListeners.end(); ++it) { + (*it)->NotifyPull(graph, aDesiredTime); + } + } + virtual Fake_SourceMediaStream *AsSourceStream() { return nullptr; } virtual nsresult Start() { return NS_OK; } @@ -134,6 +153,11 @@ class Fake_SourceMediaStream : public Fake_MediaStream { enum { ADDTRACK_QUEUED = 0x01 // Queue track add until FinishAddTracks() }; + + void AddVideoSink(const nsRefPtr& aSink) { + mSink = aSink; + } + void AddTrack(mozilla::TrackID aID, mozilla::StreamTime aStart, mozilla::MediaSegment* aSegment, uint32_t aFlags = 0) { delete aSegment; @@ -182,6 +206,9 @@ class Fake_SourceMediaStream : public Fake_MediaStream { } else { //in the case of video segment appended, we just increase the //segment count. + if (mSink.get()) { + mSink->SegmentReady(aSegment); + } ++mSegmentsAdded; } return true; @@ -217,6 +244,7 @@ class Fake_SourceMediaStream : public Fake_MediaStream { bool mPullEnabled; bool mStop; nsRefPtr mPeriodic; + nsRefPtr mSink; nsCOMPtr mTimer; }; @@ -249,6 +277,14 @@ public: { return mIsVideo? nullptr : this; } + const uint32_t typeSize () const + { + return sizeof(Fake_MediaStreamTrack); + } + const char* typeName () const + { + return "Fake_MediaStreamTrack"; + } private: ~Fake_MediaStreamTrack() {} diff --git a/media/webrtc/signaling/test/FakePCObserver.h b/media/webrtc/signaling/test/FakePCObserver.h index 64fdd9a4433..805b5c7b6d1 100644 --- a/media/webrtc/signaling/test/FakePCObserver.h +++ b/media/webrtc/signaling/test/FakePCObserver.h @@ -55,6 +55,13 @@ public: pc(peerConnection) { } + AFakePCObserver() : + state(stateNoResponse), addIceSuccessCount(0), + onAddStreamCalled(false), + name(""), + pc(nullptr) { + } + virtual ~AFakePCObserver() {} std::vector GetStreams() { return streams; } diff --git a/media/webrtc/signaling/test/common.build b/media/webrtc/signaling/test/common.build new file mode 100644 index 00000000000..8b2bb1e6e36 --- /dev/null +++ b/media/webrtc/signaling/test/common.build @@ -0,0 +1,143 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +if CONFIG['OS_TARGET'] in ('Darwin', 'Android'): + DEFINES['GTEST_USE_OWN_TR1_TUPLE'] = 1 + +for var in ('MOZILLA_EXTERNAL_LINKAGE', 'USE_FAKE_MEDIA_STREAMS', 'USE_FAKE_PCOBSERVER', + 'NR_SOCKET_IS_VOID_PTR', 'HAVE_STRDUP'): + DEFINES[var] = True + +GENERATED_INCLUDES += [ + '/dom/bindings', +] +LOCAL_INCLUDES += [ + '/dom/media/', + '/ipc/chromium/src', + '/media/mtransport', + '/media/mtransport/test', + '/media/mtransport/third_party/nICEr/src/ice', + '/media/mtransport/third_party/nICEr/src/net', + '/media/mtransport/third_party/nICEr/src/stun', + '/media/mtransport/third_party/nrappkit/src/event', + '/media/mtransport/third_party/nrappkit/src/log', + '/media/mtransport/third_party/nrappkit/src/plugin', + '/media/mtransport/third_party/nrappkit/src/registry', + '/media/mtransport/third_party/nrappkit/src/share', + '/media/mtransport/third_party/nrappkit/src/stats', + '/media/mtransport/third_party/nrappkit/src/util/libekr', + '/media/webrtc', + '/media/webrtc/signaling/src/common/browser_logging', + '/media/webrtc/signaling/src/common/time_profiling', + '/media/webrtc/signaling/src/media', + '/media/webrtc/signaling/src/media-conduit', + '/media/webrtc/signaling/src/mediapipeline', + '/media/webrtc/signaling/src/peerconnection', + '/media/webrtc/signaling/src/sdp/sipcc', + '/media/webrtc/trunk', + '/media/webrtc/trunk/testing/gtest/include', + '/xpcom/base', +] + +if CONFIG['OS_TARGET'] == 'Android': + LOCAL_INCLUDES += [ + '/media/mtransport/third_party/nrappkit/src/port/android/include', + ] + +if CONFIG['OS_TARGET'] == 'Linux': + LOCAL_INCLUDES += [ + '/media/mtransport/third_party/nrappkit/src/port/linux/include', + ] + +if CONFIG['OS_TARGET'] == 'Darwin': + LOCAL_INCLUDES += [ + '/media/mtransport/third_party/nrappkit/src/port/darwin/include', + ] + OS_LIBS += [ + '-framework AudioToolbox', + '-framework AudioUnit', + '-framework Carbon', + '-framework CoreAudio', + '-framework OpenGL', + '-framework QTKit', + '-framework QuartzCore', + '-framework Security', + '-framework SystemConfiguration', + '-framework IOKit', + '-F%s' % CONFIG['MACOS_PRIVATE_FRAMEWORKS_DIR'], + '-framework CoreUI', + ] + +if CONFIG['OS_TARGET'] in ('DragonFly', 'FreeBSD', 'NetBSD', 'OpenBSD'): + LOCAL_INCLUDES += [ + '/media/mtransport/third_party/nrappkit/src/port/darwin/include', + '/media/mtransport/third_party/nrappkit/src/port/generic/include', + ] + +USE_LIBS += [ + '/media/webrtc/trunk/testing/gtest_gtest/gtest', + 'gkmedias', + 'nksrtp_s', + 'nss', + 'webrtc', + 'yuv', + 'zlib', +] + +if CONFIG['BUILD_ARM_NEON']: + USE_LIBS += [ + 'yuv_neon', + ] + +if CONFIG['JS_SHARED_LIBRARY']: + USE_LIBS += [ + 'js', + ] + +USE_LIBS += ['mozglue'] + +OS_LIBS += CONFIG['MOZ_WEBRTC_X11_LIBS'] +OS_LIBS += CONFIG['REALTIME_LIBS'] + +if CONFIG['MOZ_ALSA']: + OS_LIBS += CONFIG['MOZ_ALSA_LIBS'] + +if CONFIG['MOZ_NATIVE_JPEG']: + OS_LIBS += CONFIG['MOZ_JPEG_LIBS'] + +if CONFIG['MOZ_NATIVE_LIBVPX']: + OS_LIBS += CONFIG['MOZ_LIBVPX_LIBS'] + +if not CONFIG['MOZ_TREE_PIXMAN']: + OS_LIBS += CONFIG['MOZ_PIXMAN_LIBS'] + +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk2': + OS_LIBS += CONFIG['XLIBS'] + OS_LIBS += CONFIG['MOZ_GTK2_LIBS'] + OS_LIBS += [ + 'gmodule-2.0', + 'gthread-2.0', + ] + +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3': + OS_LIBS += CONFIG['MOZ_GTK3_LIBS'] + USE_LIBS += [ + 'freetype', + ] + +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': + OS_LIBS += CONFIG['XLIBS'] + OS_LIBS += CONFIG['TK_LIBS'] + OS_LIBS += CONFIG['MOZ_PANGO_LIBS'] + +if CONFIG['OS_TARGET'] in ('Linux', 'DragonFly', 'FreeBSD', 'NetBSD', + 'OpenBSD'): + OS_LIBS += CONFIG['MOZ_CAIRO_OSLIBS'] + +if CONFIG['OS_TARGET'] == 'Darwin': + OS_LIBS += CONFIG['TK_LIBS'] + +FAIL_ON_WARNINGS = True diff --git a/media/webrtc/signaling/test/jsep_session_unittest.cpp b/media/webrtc/signaling/test/jsep_session_unittest.cpp index 147b887cd6c..938c5d90c8a 100644 --- a/media/webrtc/signaling/test/jsep_session_unittest.cpp +++ b/media/webrtc/signaling/test/jsep_session_unittest.cpp @@ -28,7 +28,7 @@ #include "signaling/src/jsep/JsepSessionImpl.h" #include "signaling/src/jsep/JsepTrack.h" -#include "TestHarness.h" +#include "mtransport_test_utils.h" namespace mozilla { static const char* kCandidates[] = { diff --git a/media/webrtc/signaling/test/moz.build b/media/webrtc/signaling/test/moz.build index 991f03f63db..2d7750dc812 100644 --- a/media/webrtc/signaling/test/moz.build +++ b/media/webrtc/signaling/test/moz.build @@ -9,145 +9,15 @@ if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'jsep_session_unittest', 'mediaconduit_unittests', 'mediapipeline_unittest', - 'sdp_unittests', - 'signaling_unittests', + 'sdp_unittests', + 'signaling_unittests', ]) include('/ipc/chromium/chromium-config.mozbuild') - -if CONFIG['OS_TARGET'] in ('Darwin', 'Android'): - DEFINES['GTEST_USE_OWN_TR1_TUPLE'] = 1 - -for var in ('USE_FAKE_MEDIA_STREAMS', 'USE_FAKE_PCOBSERVER', - 'NR_SOCKET_IS_VOID_PTR', 'HAVE_STRDUP'): - DEFINES[var] = True - -GENERATED_INCLUDES += [ - '/dom/bindings', -] -LOCAL_INCLUDES += [ - '/ipc/chromium/src', - '/media/mtransport', - '/media/mtransport/test', - '/media/mtransport/third_party/nICEr/src/ice', - '/media/mtransport/third_party/nICEr/src/net', - '/media/mtransport/third_party/nICEr/src/stun', - '/media/mtransport/third_party/nrappkit/src/event', - '/media/mtransport/third_party/nrappkit/src/log', - '/media/mtransport/third_party/nrappkit/src/plugin', - '/media/mtransport/third_party/nrappkit/src/registry', - '/media/mtransport/third_party/nrappkit/src/share', - '/media/mtransport/third_party/nrappkit/src/stats', - '/media/mtransport/third_party/nrappkit/src/util/libekr', - '/media/webrtc', - '/media/webrtc/signaling/src/common/browser_logging', - '/media/webrtc/signaling/src/common/time_profiling', - '/media/webrtc/signaling/src/media', - '/media/webrtc/signaling/src/media-conduit', - '/media/webrtc/signaling/src/mediapipeline', - '/media/webrtc/signaling/src/peerconnection', - '/media/webrtc/signaling/src/sdp/sipcc', - '/media/webrtc/trunk', - '/media/webrtc/trunk/testing/gtest/include', - '/xpcom/base', -] - -if CONFIG['OS_TARGET'] == 'Android': - LOCAL_INCLUDES += [ - '/media/mtransport/third_party/nrappkit/src/port/android/include', - ] - -if CONFIG['OS_TARGET'] == 'Linux': - LOCAL_INCLUDES += [ - '/media/mtransport/third_party/nrappkit/src/port/linux/include', - ] - -if CONFIG['OS_TARGET'] == 'Darwin': - LOCAL_INCLUDES += [ - '/media/mtransport/third_party/nrappkit/src/port/darwin/include', - ] - OS_LIBS += [ - '-framework AudioToolbox', - '-framework AudioUnit', - '-framework Carbon', - '-framework CoreAudio', - '-framework OpenGL', - '-framework QTKit', - '-framework QuartzCore', - '-framework Security', - '-framework SystemConfiguration', - '-framework IOKit', - '-F%s' % CONFIG['MACOS_PRIVATE_FRAMEWORKS_DIR'], - '-framework CoreUI', - ] - -if CONFIG['OS_TARGET'] in ('DragonFly', 'FreeBSD', 'NetBSD', 'OpenBSD'): - LOCAL_INCLUDES += [ - '/media/mtransport/third_party/nrappkit/src/port/darwin/include', - '/media/mtransport/third_party/nrappkit/src/port/generic/include', - ] +include('common.build') USE_LIBS += [ '/media/webrtc/signalingtest/signaling_ecc/ecc', - '/media/webrtc/trunk/testing/gtest_gtest/gtest', - 'gkmedias', 'mtransport_s', - 'nksrtp_s', - 'nss', - 'webrtc', - 'yuv', - 'zlib', ] -if CONFIG['BUILD_ARM_NEON']: - USE_LIBS += [ - 'yuv_neon', - ] - -if CONFIG['JS_SHARED_LIBRARY']: - USE_LIBS += [ - 'js', - ] - -OS_LIBS += CONFIG['MOZ_WEBRTC_X11_LIBS'] -OS_LIBS += CONFIG['REALTIME_LIBS'] - -if CONFIG['MOZ_ALSA']: - OS_LIBS += CONFIG['MOZ_ALSA_LIBS'] - -if CONFIG['MOZ_NATIVE_JPEG']: - OS_LIBS += CONFIG['MOZ_JPEG_LIBS'] - -if CONFIG['MOZ_NATIVE_LIBVPX']: - OS_LIBS += CONFIG['MOZ_LIBVPX_LIBS'] - -if not CONFIG['MOZ_TREE_PIXMAN']: - OS_LIBS += CONFIG['MOZ_PIXMAN_LIBS'] - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk2': - OS_LIBS += CONFIG['XLIBS'] - OS_LIBS += CONFIG['MOZ_GTK2_LIBS'] - OS_LIBS += [ - 'gmodule-2.0', - 'gthread-2.0', - ] - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3': - OS_LIBS += CONFIG['MOZ_GTK3_LIBS'] - USE_LIBS += [ - 'freetype', - ] - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': - OS_LIBS += CONFIG['XLIBS'] - OS_LIBS += CONFIG['TK_LIBS'] - OS_LIBS += CONFIG['MOZ_PANGO_LIBS'] - -if CONFIG['OS_TARGET'] in ('Linux', 'DragonFly', 'FreeBSD', 'NetBSD', - 'OpenBSD'): - OS_LIBS += CONFIG['MOZ_CAIRO_OSLIBS'] - -if CONFIG['OS_TARGET'] == 'Darwin': - OS_LIBS += CONFIG['TK_LIBS'] - -FAIL_ON_WARNINGS = True diff --git a/media/webrtc/signaling/test/signaling_unittests.cpp b/media/webrtc/signaling/test/signaling_unittests.cpp index 07b87873b81..91961a87a1d 100644 --- a/media/webrtc/signaling/test/signaling_unittests.cpp +++ b/media/webrtc/signaling/test/signaling_unittests.cpp @@ -31,8 +31,6 @@ #include "mozilla/Services.h" #include "nsIPrefService.h" #include "nsIPrefBranch.h" -#include "nsNetUtil.h" -#include "nsIIOService.h" #include "nsIDNSService.h" #include "nsWeakReference.h" #include "nricectx.h" @@ -2112,6 +2110,9 @@ public: uint16_t stun_port_; }; +#if !defined(MOZILLA_XPCOMRT_API) +// FIXME XPCOMRT doesn't support nsPrefService +// See Bug 1129188 - Create standalone libpref for use in standalone WebRTC static void SetIntPrefOnMainThread(nsCOMPtr prefs, const char *pref_name, int new_value) { @@ -2161,6 +2162,7 @@ class FsFrPrefClearer { private: nsCOMPtr mPrefs; }; +#endif // !defined(MOZILLA_XPCOMRT_API) TEST_P(SignalingTest, JustInit) { @@ -3908,6 +3910,10 @@ TEST_P(SignalingTest, hugeSdp) a2_->CreateAnswer(OFFER_AV); } +#if !defined(MOZILLA_XPCOMRT_API) +// FIXME XPCOMRT doesn't support nsPrefService +// See Bug 1129188 - Create standalone libpref for use in standalone WebRTC + // Test max_fs and max_fr prefs have proper impact on SDP offer TEST_P(SignalingTest, MaxFsFrInOffer) { @@ -4042,6 +4048,7 @@ TEST_P(SignalingTest, MaxFsFrCallerCodec) ASSERT_EQ(video_conduit->SendingMaxFs(), (unsigned short) 600); ASSERT_EQ(video_conduit->SendingMaxFr(), (unsigned short) 60); } +#endif // !defined(MOZILLA_XPCOMRT_API) // Validate offer with multiple video codecs TEST_P(SignalingTest, ValidateMultipleVideoCodecsInOffer) diff --git a/media/webrtc/signaling/test/standalone/jsep_session_unittest_standalone.cpp b/media/webrtc/signaling/test/standalone/jsep_session_unittest_standalone.cpp new file mode 100644 index 00000000000..4c184645123 --- /dev/null +++ b/media/webrtc/signaling/test/standalone/jsep_session_unittest_standalone.cpp @@ -0,0 +1,7 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "../jsep_session_unittest.cpp" diff --git a/media/webrtc/signaling/test/standalone/mediaconduit_unittests_standalone.cpp b/media/webrtc/signaling/test/standalone/mediaconduit_unittests_standalone.cpp new file mode 100644 index 00000000000..051dfe76ed3 --- /dev/null +++ b/media/webrtc/signaling/test/standalone/mediaconduit_unittests_standalone.cpp @@ -0,0 +1,5 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "../mediaconduit_unittests.cpp" diff --git a/media/webrtc/signaling/test/standalone/mediapipeline_unittest_standalone.cpp b/media/webrtc/signaling/test/standalone/mediapipeline_unittest_standalone.cpp new file mode 100644 index 00000000000..a00703111bc --- /dev/null +++ b/media/webrtc/signaling/test/standalone/mediapipeline_unittest_standalone.cpp @@ -0,0 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// Original author: ekr@rtfm.com + +#include "../mediapipeline_unittest.cpp" diff --git a/media/webrtc/signaling/test/standalone/moz.build b/media/webrtc/signaling/test/standalone/moz.build new file mode 100644 index 00000000000..164467d622c --- /dev/null +++ b/media/webrtc/signaling/test/standalone/moz.build @@ -0,0 +1,58 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Standalone WebRTC does not link on Android. +# See Bug 1127510 - Standalone WebRTC unit tests fail to link on Android +if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk' and CONFIG['OS_TARGET'] != 'Android': + CppUnitTests([ + 'jsep_session_unittest_standalone', +# mediaconduit_unittests disabled for standalone build until GMP support added. +# See Bug 1121677 - Enable GMP for WebRTC standalone. +# 'mediaconduit_unittests_standalone', + 'mediapipeline_unittest_standalone', + 'sdp_unittests_standalone', + 'signaling_unittests_standalone', + ]) + +include('/ipc/chromium/chromium-config.mozbuild') +include('../common.build') + +for var in ('MOZILLA_INTERNAL_API', 'MOZILLA_XPCOMRT_API'): + DEFINES[var] = True + +if CONFIG['OS_TARGET'] == 'Linux': + USE_LIBS += [ + 'static:/nsprpub/lib/libc/src/plc4', + ] + OS_LIBS += [ + '-lrt', + ] + +LOCAL_INCLUDES += [ + '..', + '/xpcom/libxpcomrt', +] + +USE_LIBS += [ + '/media/webrtc/signalingstandalone/signaling_ecc/ecc', + 'fallible', + 'media_standalone', + 'mfbt', + 'mozglue', + 'mtransport_standalone', + 'necko_standalone', + 'nspr', + 'nss', + 'unicharutil_standalone', + 'xpcomrt', +] + +if CONFIG['OS_TARGET'] == 'Android': + USE_LIBS += [ + 'freetype', + ] + +USE_LIBS += ['mozglue'] diff --git a/media/webrtc/signaling/test/standalone/sdp_unittests_standalone.cpp b/media/webrtc/signaling/test/standalone/sdp_unittests_standalone.cpp new file mode 100644 index 00000000000..122eb46b21b --- /dev/null +++ b/media/webrtc/signaling/test/standalone/sdp_unittests_standalone.cpp @@ -0,0 +1,7 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "../sdp_unittests.cpp" diff --git a/media/webrtc/signaling/test/standalone/signaling_unittests_standalone.cpp b/media/webrtc/signaling/test/standalone/signaling_unittests_standalone.cpp new file mode 100644 index 00000000000..796aa23b52c --- /dev/null +++ b/media/webrtc/signaling/test/standalone/signaling_unittests_standalone.cpp @@ -0,0 +1,5 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "../signaling_unittests.cpp" diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild index 2427f1d87b8..06cf7cff8e7 100644 --- a/toolkit/toolkit.mozbuild +++ b/toolkit/toolkit.mozbuild @@ -61,9 +61,7 @@ DIRS += [ if CONFIG['MOZ_WEBRTC']: DIRS += [ '/media/webrtc', - '/media/mtransport/third_party', - '/media/mtransport/build', - '/media/mtransport/standalone', + '/media/mtransport', ] if CONFIG['MOZ_OMX_PLUGIN']: @@ -192,5 +190,6 @@ if CONFIG['ENABLE_TESTS']: if CONFIG['MOZ_WEBRTC'] and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': DIRS += [ '/media/webrtc/signaling/test', + '/media/webrtc/signaling/test/standalone', '/media/mtransport/test', ] diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index cc0246e5a0b..f07a1bcc6af 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -397,6 +397,7 @@ nsComponentManagerImpl::Init() #if defined(MOZILLA_XPCOMRT_API) RegisterModule(&kXPCOMRTModule, nullptr); RegisterModule(&kNeckoStandaloneModule, nullptr); + RegisterModule(&kStunUDPSocketFilterHandlerModule, nullptr); #else RegisterModule(&kXPCOMModule, nullptr); #endif // defined(MOZILLA_XPCOMRT_API) diff --git a/xpcom/components/nsComponentManager.h b/xpcom/components/nsComponentManager.h index 319b0ff600a..734f894e5e2 100644 --- a/xpcom/components/nsComponentManager.h +++ b/xpcom/components/nsComponentManager.h @@ -71,6 +71,7 @@ extern const char staticComponentType[]; #if defined(MOZILLA_XPCOMRT_API) extern const mozilla::Module kXPCOMRTModule; extern const mozilla::Module kNeckoStandaloneModule; +extern const mozilla::Module kStunUDPSocketFilterHandlerModule; #else extern const mozilla::Module kXPCOMModule; #endif