react-native-theoplayer 11.7.0 → 11.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/android/build.gradle +4 -2
  3. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  4. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  5. package/android/gradlew +176 -110
  6. package/android/gradlew.bat +23 -18
  7. package/android/src/main/java/com/theoplayer/ads/AdAdapter.kt +33 -7
  8. package/android/src/main/java/com/theoplayer/ads/AdEventAdapter.kt +8 -1
  9. package/android/src/main/java/com/theoplayer/drm/ContentProtectionAdapter.kt +24 -5
  10. package/android/src/main/java/com/theoplayer/drm/ContentProtectionModule.kt +61 -7
  11. package/android/src/main/java/com/theoplayer/drm/ProxyContentProtectionIntegration.kt +12 -5
  12. package/android/src/main/java/com/theoplayer/drm/ProxyContentProtectionIntegrationFactory.kt +3 -1
  13. package/android/src/main/java/com/theoplayer/source/SourceAdapter.kt +23 -0
  14. package/android/src/main/java/com/theoplayer/theolive/EndpointAdapter.kt +33 -0
  15. package/android/src/main/java/com/theoplayer/util/BridgeUtils.kt +4 -4
  16. package/android/src/test/java/com/theoplayer/ads/AdAdapterCustomDataTest.kt +144 -0
  17. package/ios/THEOplayerRCTBridge.m +7 -0
  18. package/ios/THEOplayerRCTMainEventHandler.swift +27 -1
  19. package/ios/THEOplayerRCTPlayerAPI.swift +20 -0
  20. package/ios/ads/THEOplayerRCTAdAdapter.swift +14 -3
  21. package/ios/ads/THEOplayerRCTAdsNative.swift +4 -0
  22. package/ios/contentprotection/THEOplayerRCTContentProtectionAPI.swift +39 -9
  23. package/ios/contentprotection/THEOplayerRCTContentProtectionAggregator.swift +15 -11
  24. package/ios/contentprotection/THEOplayerRCTProxyContentProtectionIntegration.swift +12 -7
  25. package/ios/theolive/THEOplayerRCTTHEOliveEventAdapter.swift +21 -0
  26. package/lib/commonjs/api/player/PlayerEventMap.js +1 -1
  27. package/lib/commonjs/api/source/abr/SourceAbrConfiguration.js +2 -0
  28. package/lib/commonjs/api/source/abr/SourceAbrConfiguration.js.map +1 -0
  29. package/lib/commonjs/api/source/abr/barrel.js +17 -0
  30. package/lib/commonjs/api/source/abr/barrel.js.map +1 -0
  31. package/lib/commonjs/api/source/barrel.js +18 -7
  32. package/lib/commonjs/api/source/barrel.js.map +1 -1
  33. package/lib/commonjs/internal/adapter/DefaultNativePlayerState.js +1 -0
  34. package/lib/commonjs/internal/adapter/DefaultNativePlayerState.js.map +1 -1
  35. package/lib/commonjs/internal/adapter/THEOplayerAdapter.js +9 -0
  36. package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
  37. package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js +13 -1
  38. package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
  39. package/lib/commonjs/internal/adapter/WebEventForwarder.js +61 -10
  40. package/lib/commonjs/internal/adapter/WebEventForwarder.js.map +1 -1
  41. package/lib/commonjs/internal/adapter/event/native/NativeTheoLiveEvent.js +2 -2
  42. package/lib/commonjs/internal/adapter/event/native/NativeTheoLiveEvent.js.map +1 -1
  43. package/lib/commonjs/internal/drm/ContentProtectionRegistry.js +38 -12
  44. package/lib/commonjs/internal/drm/ContentProtectionRegistry.js.map +1 -1
  45. package/lib/commonjs/manifest.json +1 -1
  46. package/lib/commonjs/plugins/typedoc-platform-icons/package-lock.json +200 -58
  47. package/lib/commonjs/plugins/typedoc-platform-icons/package.json +1 -1
  48. package/lib/commonjs/plugins/typedoc-platform-icons/tsconfig.json +2 -1
  49. package/lib/module/api/player/PlayerEventMap.js +1 -1
  50. package/lib/module/api/source/abr/SourceAbrConfiguration.js +2 -0
  51. package/lib/module/api/source/abr/SourceAbrConfiguration.js.map +1 -0
  52. package/lib/module/api/source/abr/barrel.js +4 -0
  53. package/lib/module/api/source/abr/barrel.js.map +1 -0
  54. package/lib/module/api/source/barrel.js +1 -0
  55. package/lib/module/api/source/barrel.js.map +1 -1
  56. package/lib/module/internal/adapter/DefaultNativePlayerState.js +1 -0
  57. package/lib/module/internal/adapter/DefaultNativePlayerState.js.map +1 -1
  58. package/lib/module/internal/adapter/THEOplayerAdapter.js +9 -0
  59. package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
  60. package/lib/module/internal/adapter/THEOplayerWebAdapter.js +13 -1
  61. package/lib/module/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
  62. package/lib/module/internal/adapter/WebEventForwarder.js +61 -10
  63. package/lib/module/internal/adapter/WebEventForwarder.js.map +1 -1
  64. package/lib/module/internal/adapter/event/native/NativeTheoLiveEvent.js +2 -2
  65. package/lib/module/internal/adapter/event/native/NativeTheoLiveEvent.js.map +1 -1
  66. package/lib/module/internal/drm/ContentProtectionRegistry.js +38 -12
  67. package/lib/module/internal/drm/ContentProtectionRegistry.js.map +1 -1
  68. package/lib/module/manifest.json +1 -1
  69. package/lib/module/plugins/typedoc-platform-icons/package-lock.json +200 -58
  70. package/lib/module/plugins/typedoc-platform-icons/package.json +1 -1
  71. package/lib/module/plugins/typedoc-platform-icons/tsconfig.json +2 -1
  72. package/lib/typescript/__tests__/ContentProtectionRegistry.test.d.ts +2 -0
  73. package/lib/typescript/__tests__/ContentProtectionRegistry.test.d.ts.map +1 -0
  74. package/lib/typescript/__tests__/NativeTheoLiveEvent.test.d.ts +2 -0
  75. package/lib/typescript/__tests__/NativeTheoLiveEvent.test.d.ts.map +1 -0
  76. package/lib/typescript/api/ads/Ad.d.ts +9 -0
  77. package/lib/typescript/api/ads/Ad.d.ts.map +1 -1
  78. package/lib/typescript/api/ads/AdBreak.d.ts +9 -0
  79. package/lib/typescript/api/ads/AdBreak.d.ts.map +1 -1
  80. package/lib/typescript/api/error/ChromecastError.d.ts +2 -2
  81. package/lib/typescript/api/player/PlayerEventMap.d.ts +1 -1
  82. package/lib/typescript/api/player/THEOplayer.d.ts +11 -0
  83. package/lib/typescript/api/player/THEOplayer.d.ts.map +1 -1
  84. package/lib/typescript/api/source/SourceDescription.d.ts +7 -0
  85. package/lib/typescript/api/source/SourceDescription.d.ts.map +1 -1
  86. package/lib/typescript/api/source/abr/SourceAbrConfiguration.d.ts +27 -0
  87. package/lib/typescript/api/source/abr/SourceAbrConfiguration.d.ts.map +1 -0
  88. package/lib/typescript/api/source/abr/barrel.d.ts +2 -0
  89. package/lib/typescript/api/source/abr/barrel.d.ts.map +1 -0
  90. package/lib/typescript/api/source/barrel.d.ts +1 -0
  91. package/lib/typescript/api/source/barrel.d.ts.map +1 -1
  92. package/lib/typescript/api/theoads/interstitial/Interstitial.d.ts +1 -1
  93. package/lib/typescript/api/theolive/TheoLiveEndpoint.d.ts +23 -5
  94. package/lib/typescript/api/theolive/TheoLiveEndpoint.d.ts.map +1 -1
  95. package/lib/typescript/api/theolive/WebrtcOptions.d.ts +1 -1
  96. package/lib/typescript/internal/adapter/DefaultNativePlayerState.d.ts +1 -0
  97. package/lib/typescript/internal/adapter/DefaultNativePlayerState.d.ts.map +1 -1
  98. package/lib/typescript/internal/adapter/NativePlayerState.d.ts +1 -0
  99. package/lib/typescript/internal/adapter/NativePlayerState.d.ts.map +1 -1
  100. package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts +2 -0
  101. package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts.map +1 -1
  102. package/lib/typescript/internal/adapter/THEOplayerWebAdapter.d.ts +2 -0
  103. package/lib/typescript/internal/adapter/THEOplayerWebAdapter.d.ts.map +1 -1
  104. package/lib/typescript/internal/adapter/WebEventForwarder.d.ts +3 -0
  105. package/lib/typescript/internal/adapter/WebEventForwarder.d.ts.map +1 -1
  106. package/lib/typescript/internal/adapter/web/PlayerFacadeAdsEvents.d.ts +2 -2
  107. package/lib/typescript/internal/adapter/web/PlayerFacadeAdsEvents.d.ts.map +1 -1
  108. package/lib/typescript/internal/drm/ContentProtectionRegistry.d.ts +3 -1
  109. package/lib/typescript/internal/drm/ContentProtectionRegistry.d.ts.map +1 -1
  110. package/lib/typescript/internal/drm/NativeContentProtectionEvent.d.ts +5 -0
  111. package/lib/typescript/internal/drm/NativeContentProtectionEvent.d.ts.map +1 -1
  112. package/package.json +5 -6
  113. package/react-native-theoplayer.podspec +6 -6
  114. package/src/__tests__/ContentProtectionRegistry.test.ts +239 -0
  115. package/src/__tests__/NativeTheoLiveEvent.test.ts +82 -0
  116. package/src/__tests__/PlayerFacadeWebAdapter.test.ts +13 -0
  117. package/src/api/ads/Ad.ts +10 -0
  118. package/src/api/ads/AdBreak.ts +10 -0
  119. package/src/api/error/ChromecastError.ts +2 -2
  120. package/src/api/player/PlayerEventMap.ts +1 -1
  121. package/src/api/player/THEOplayer.ts +12 -0
  122. package/src/api/source/SourceDescription.ts +8 -0
  123. package/src/api/source/abr/SourceAbrConfiguration.ts +27 -0
  124. package/src/api/source/abr/barrel.ts +1 -0
  125. package/src/api/source/barrel.ts +1 -0
  126. package/src/api/theoads/interstitial/Interstitial.ts +1 -1
  127. package/src/api/theolive/TheoLiveEndpoint.ts +24 -5
  128. package/src/api/theolive/WebrtcOptions.ts +1 -1
  129. package/src/internal/adapter/DefaultNativePlayerState.ts +1 -0
  130. package/src/internal/adapter/NativePlayerState.ts +1 -0
  131. package/src/internal/adapter/THEOplayerAdapter.ts +11 -0
  132. package/src/internal/adapter/THEOplayerWebAdapter.ts +15 -1
  133. package/src/internal/adapter/WebEventForwarder.ts +69 -10
  134. package/src/internal/adapter/event/native/NativeTheoLiveEvent.ts +2 -2
  135. package/src/internal/drm/ContentProtectionRegistry.ts +35 -17
  136. package/src/internal/drm/NativeContentProtectionEvent.ts +5 -0
  137. package/src/manifest.json +1 -1
  138. package/src/plugins/typedoc-platform-icons/package-lock.json +200 -58
  139. package/src/plugins/typedoc-platform-icons/package.json +1 -1
  140. package/src/plugins/typedoc-platform-icons/tsconfig.json +2 -1
  141. package/lib/typescript/plugins/expo/Common.d.ts +0 -13
  142. package/lib/typescript/plugins/expo/Common.d.ts.map +0 -1
  143. package/lib/typescript/plugins/expo/withCustomPod.d.ts +0 -2
  144. package/lib/typescript/plugins/expo/withCustomPod.d.ts.map +0 -1
  145. package/lib/typescript/plugins/expo/withTHEOplayer.d.ts +0 -4
  146. package/lib/typescript/plugins/expo/withTHEOplayer.d.ts.map +0 -1
  147. package/lib/typescript/plugins/expo/withTHEOplayerAndroid.d.ts +0 -4
  148. package/lib/typescript/plugins/expo/withTHEOplayerAndroid.d.ts.map +0 -1
  149. package/lib/typescript/plugins/expo/withTHEOplayerIOS.d.ts +0 -4
  150. package/lib/typescript/plugins/expo/withTHEOplayerIOS.d.ts.map +0 -1
  151. package/lib/typescript/plugins/typedoc-platform-icons/src/index.d.ts +0 -3
  152. package/lib/typescript/plugins/typedoc-platform-icons/src/index.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,38 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [11.9.0] - 13-11-26
9
+
10
+ ### Added
11
+
12
+ - Added `THEOplayer.allowsExternalPlayback` to enable or disable AirPlay playback on iOS.
13
+ - Added `abr` property to `TypedSource`, supporting `preferredVideoCodecs` and `preferredAudioCodecs` on Android and Web.
14
+ - Added `contentprotectionerror` event bridging on iOS.
15
+ - Added `customData` to `Ad` and `AdBreak`, including bidirectional event bridging on Android, iOS and tvOS.
16
+
17
+ ### Fixed
18
+
19
+ - Fixed an issue on Web where player facade listeners, such as analytics connectors, did not receive the player's `destroy` event.
20
+ - Fixed THEOlive events not being forwarded correctly on React Native v0.88.0+.
21
+ - Fixed an issue on Android where `preferredKeySystems` in the content protection configuration was ignored.
22
+ - Fixed ad-break integration identifiers being forwarded incorrectly on iOS and tvOS.
23
+
24
+ ## [11.8.0] - 18-10-26
25
+
26
+ ### Added
27
+
28
+ - Added the `src`, `srcType`, `provider` and `adSystem` properties to the THEOlive `endpoint` object of the `endpointloaded` event on all platforms.
29
+ - Added the `webrtc` playout delay options to `millicastSrc` on Android.
30
+
31
+ ### Changed
32
+
33
+ - Raised the minimum supported THEOplayer SDK version to 11.14.0 on all platforms.
34
+
35
+ ### Fixed
36
+
37
+ - Fixed an issue where re-registering a content protection integration for the same key system kept the previously registered factory active, causing stale DRM integrations to be used for subsequent sources.
38
+ - Fixed an issue on iOS and Android where certificate and license requests from multiple concurrently playing DRM-protected sources could be processed by the wrong content protection integration, or bypass it entirely, causing license acquisition to fail.
39
+
8
40
  ## [11.7.0] - 18-09-26
9
41
 
10
42
  ### Added
@@ -19,6 +51,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
19
51
  - Fixed an issue on Android where destroying the player during a pending `MediaPlaybackService` bind could cause a crash.
20
52
  - Fixed an issue on Android where the player could remain black when its view was attached after React Native had already assigned the layout.
21
53
  - Fixed an issue where `player.paused` remained `true` between the `play` and `playing` events.
54
+ - Fixed an issue on Web and iOS Safari where cues already present when a text track was added, including daterange cues, did not produce `addcue` player events.
55
+ - Fixed an issue where text and media track event listeners were not actually removed when a track was removed.
22
56
 
23
57
  ### Changed
24
58
 
@@ -126,8 +126,8 @@ repositories {
126
126
  mavenLocal()
127
127
  }
128
128
 
129
- // The minimum supported THEOplayer version is 11.5.0
130
- def theoVersion = safeExtGet('THEOplayer_sdk', '[11.5.0, 12.0.0)')
129
+ // The minimum supported THEOplayer version is 11.14.0
130
+ def theoVersion = safeExtGet('THEOplayer_sdk', '[11.14.0, 12.0.0)')
131
131
  def theoMediaSessionVersion = safeExtGet('THEOplayer_mediasession', '[11.0.0, 12.0.0)')
132
132
  def theoAdsWrapperVersion = "11.0.0"
133
133
  def coroutinesVersion = safeExtGet('coroutinesVersion', '1.10.2')
@@ -168,6 +168,8 @@ dependencies {
168
168
  implementation("com.theoplayer.theoplayer-sdk-android:ads-wrapper:$theoAdsWrapperVersion")
169
169
  implementation("com.theoplayer.android-connector:mediasession:$theoMediaSessionVersion")
170
170
  testImplementation("junit:junit:4.13.2")
171
+ testImplementation("com.vaadin.external.google:android-json:0.0.20131108.vaadin1")
172
+ testImplementation("org.mockito:mockito-core:5.20.0")
171
173
 
172
174
  addOptiViewIntegration(enabledGoogleIMA || enabledGoogleDAI || enabledTHEOads, 'integration-ads-ima')
173
175
  addOptiViewIntegration(enabledGoogleDAI || enabledTHEOads, 'integration-ads-dai')
@@ -1,5 +1,5 @@
1
1
  distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.6-bin.zip
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
package/android/gradlew CHANGED
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env sh
1
+ #!/bin/sh
2
2
 
3
3
  #
4
- # Copyright 2015 the original author or authors.
4
+ # Copyright © 2015-2021 the original authors.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -15,81 +15,115 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
+ # SPDX-License-Identifier: Apache-2.0
19
+ #
18
20
 
19
21
  ##############################################################################
20
- ##
21
- ## Gradle start up script for UN*X
22
- ##
22
+ #
23
+ # Gradle start up script for POSIX generated by Gradle.
24
+ #
25
+ # Important for running:
26
+ #
27
+ # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28
+ # noncompliant, but you have some other compliant shell such as ksh or
29
+ # bash, then to run this script, type that shell name before the whole
30
+ # command line, like:
31
+ #
32
+ # ksh Gradle
33
+ #
34
+ # Busybox and similar reduced shells will NOT work, because this script
35
+ # requires all of these POSIX shell features:
36
+ # * functions;
37
+ # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38
+ # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39
+ # * compound commands having a testable exit status, especially «case»;
40
+ # * various built-in commands including «command», «set», and «ulimit».
41
+ #
42
+ # Important for patching:
43
+ #
44
+ # (2) This script targets any POSIX shell, so it avoids extensions provided
45
+ # by Bash, Ksh, etc; in particular arrays are avoided.
46
+ #
47
+ # The "traditional" practice of packing multiple parameters into a
48
+ # space-separated string is a well documented source of bugs and security
49
+ # problems, so this is (mostly) avoided, by progressively accumulating
50
+ # options in "$@", and eventually passing that to Java.
51
+ #
52
+ # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53
+ # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54
+ # see the in-line comments for details.
55
+ #
56
+ # There are tweaks for specific operating systems such as AIX, CygWin,
57
+ # Darwin, MinGW, and NonStop.
58
+ #
59
+ # (3) This script is generated from the Groovy template
60
+ # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61
+ # within the Gradle project.
62
+ #
63
+ # You can find Gradle at https://github.com/gradle/gradle/.
64
+ #
23
65
  ##############################################################################
24
66
 
25
67
  # Attempt to set APP_HOME
68
+
26
69
  # Resolve links: $0 may be a link
27
- PRG="$0"
28
- # Need this for relative symlinks.
29
- while [ -h "$PRG" ] ; do
30
- ls=`ls -ld "$PRG"`
31
- link=`expr "$ls" : '.*-> \(.*\)$'`
32
- if expr "$link" : '/.*' > /dev/null; then
33
- PRG="$link"
34
- else
35
- PRG=`dirname "$PRG"`"/$link"
36
- fi
70
+ app_path=$0
71
+
72
+ # Need this for daisy-chained symlinks.
73
+ while
74
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75
+ [ -h "$app_path" ]
76
+ do
77
+ ls=$( ls -ld "$app_path" )
78
+ link=${ls#*' -> '}
79
+ case $link in #(
80
+ /*) app_path=$link ;; #(
81
+ *) app_path=$APP_HOME$link ;;
82
+ esac
37
83
  done
38
- SAVED="`pwd`"
39
- cd "`dirname \"$PRG\"`/" >/dev/null
40
- APP_HOME="`pwd -P`"
41
- cd "$SAVED" >/dev/null
42
84
 
43
- APP_NAME="Gradle"
44
- APP_BASE_NAME=`basename "$0"`
45
-
46
- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47
- DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
85
+ # This is normally unused
86
+ # shellcheck disable=SC2034
87
+ APP_BASE_NAME=${0##*/}
88
+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89
+ APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
48
90
 
49
91
  # Use the maximum available, or set MAX_FD != -1 to use that value.
50
- MAX_FD="maximum"
92
+ MAX_FD=maximum
51
93
 
52
94
  warn () {
53
95
  echo "$*"
54
- }
96
+ } >&2
55
97
 
56
98
  die () {
57
99
  echo
58
100
  echo "$*"
59
101
  echo
60
102
  exit 1
61
- }
103
+ } >&2
62
104
 
63
105
  # OS specific support (must be 'true' or 'false').
64
106
  cygwin=false
65
107
  msys=false
66
108
  darwin=false
67
109
  nonstop=false
68
- case "`uname`" in
69
- CYGWIN* )
70
- cygwin=true
71
- ;;
72
- Darwin* )
73
- darwin=true
74
- ;;
75
- MINGW* )
76
- msys=true
77
- ;;
78
- NONSTOP* )
79
- nonstop=true
80
- ;;
110
+ case "$( uname )" in #(
111
+ CYGWIN* ) cygwin=true ;; #(
112
+ Darwin* ) darwin=true ;; #(
113
+ MSYS* | MINGW* ) msys=true ;; #(
114
+ NONSTOP* ) nonstop=true ;;
81
115
  esac
82
116
 
83
- CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117
+ CLASSPATH="\\\"\\\""
84
118
 
85
119
 
86
120
  # Determine the Java command to use to start the JVM.
87
121
  if [ -n "$JAVA_HOME" ] ; then
88
122
  if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89
123
  # IBM's JDK on AIX uses strange locations for the executables
90
- JAVACMD="$JAVA_HOME/jre/sh/java"
124
+ JAVACMD=$JAVA_HOME/jre/sh/java
91
125
  else
92
- JAVACMD="$JAVA_HOME/bin/java"
126
+ JAVACMD=$JAVA_HOME/bin/java
93
127
  fi
94
128
  if [ ! -x "$JAVACMD" ] ; then
95
129
  die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -98,88 +132,120 @@ Please set the JAVA_HOME variable in your environment to match the
98
132
  location of your Java installation."
99
133
  fi
100
134
  else
101
- JAVACMD="java"
102
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
135
+ JAVACMD=java
136
+ if ! command -v java >/dev/null 2>&1
137
+ then
138
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103
139
 
104
140
  Please set the JAVA_HOME variable in your environment to match the
105
141
  location of your Java installation."
142
+ fi
106
143
  fi
107
144
 
108
145
  # Increase the maximum file descriptors if we can.
109
- if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110
- MAX_FD_LIMIT=`ulimit -H -n`
111
- if [ $? -eq 0 ] ; then
112
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113
- MAX_FD="$MAX_FD_LIMIT"
114
- fi
115
- ulimit -n $MAX_FD
116
- if [ $? -ne 0 ] ; then
117
- warn "Could not set maximum file descriptor limit: $MAX_FD"
118
- fi
119
- else
120
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121
- fi
146
+ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
147
+ case $MAX_FD in #(
148
+ max*)
149
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
150
+ # shellcheck disable=SC2039,SC3045
151
+ MAX_FD=$( ulimit -H -n ) ||
152
+ warn "Could not query maximum file descriptor limit"
153
+ esac
154
+ case $MAX_FD in #(
155
+ '' | soft) :;; #(
156
+ *)
157
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
158
+ # shellcheck disable=SC2039,SC3045
159
+ ulimit -n "$MAX_FD" ||
160
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
161
+ esac
122
162
  fi
123
163
 
124
- # For Darwin, add options to specify how the application appears in the dock
125
- if $darwin; then
126
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127
- fi
164
+ # Collect all arguments for the java command, stacking in reverse order:
165
+ # * args from the command line
166
+ # * the main class name
167
+ # * -classpath
168
+ # * -D...appname settings
169
+ # * --module-path (only if needed)
170
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
128
171
 
129
172
  # For Cygwin or MSYS, switch paths to Windows format before running java
130
- if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133
-
134
- JAVACMD=`cygpath --unix "$JAVACMD"`
135
-
136
- # We build the pattern for arguments to be converted via cygpath
137
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138
- SEP=""
139
- for dir in $ROOTDIRSRAW ; do
140
- ROOTDIRS="$ROOTDIRS$SEP$dir"
141
- SEP="|"
142
- done
143
- OURCYGPATTERN="(^($ROOTDIRS))"
144
- # Add a user-defined pattern to the cygpath arguments
145
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147
- fi
173
+ if "$cygwin" || "$msys" ; then
174
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176
+
177
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
178
+
148
179
  # Now convert the arguments - kludge to limit ourselves to /bin/sh
149
- i=0
150
- for arg in "$@" ; do
151
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153
-
154
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156
- else
157
- eval `echo args$i`="\"$arg\""
180
+ for arg do
181
+ if
182
+ case $arg in #(
183
+ -*) false ;; # don't mess with options #(
184
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
185
+ [ -e "$t" ] ;; #(
186
+ *) false ;;
187
+ esac
188
+ then
189
+ arg=$( cygpath --path --ignore --mixed "$arg" )
158
190
  fi
159
- i=`expr $i + 1`
191
+ # Roll the args list around exactly as many times as the number of
192
+ # args, so each arg winds up back in the position where it started, but
193
+ # possibly modified.
194
+ #
195
+ # NB: a `for` loop captures its iteration list before it begins, so
196
+ # changing the positional parameters here affects neither the number of
197
+ # iterations, nor the values presented in `arg`.
198
+ shift # remove old arg
199
+ set -- "$@" "$arg" # push replacement arg
160
200
  done
161
- case $i in
162
- 0) set -- ;;
163
- 1) set -- "$args0" ;;
164
- 2) set -- "$args0" "$args1" ;;
165
- 3) set -- "$args0" "$args1" "$args2" ;;
166
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172
- esac
173
201
  fi
174
202
 
175
- # Escape application args
176
- save () {
177
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178
- echo " "
179
- }
180
- APP_ARGS=`save "$@"`
181
203
 
182
- # Collect all arguments for the java command, following the shell quoting and substitution rules
183
- eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
204
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206
+
207
+ # Collect all arguments for the java command:
208
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209
+ # and any embedded shellness will be escaped.
210
+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211
+ # treated as '${Hostname}' itself on the command line.
212
+
213
+ set -- \
214
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
215
+ -classpath "$CLASSPATH" \
216
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217
+ "$@"
218
+
219
+ # Stop when "xargs" is not available.
220
+ if ! command -v xargs >/dev/null 2>&1
221
+ then
222
+ die "xargs is not available"
223
+ fi
224
+
225
+ # Use "xargs" to parse quoted args.
226
+ #
227
+ # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
228
+ #
229
+ # In Bash we could simply go:
230
+ #
231
+ # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
232
+ # set -- "${ARGS[@]}" "$@"
233
+ #
234
+ # but POSIX shell has neither arrays nor command substitution, so instead we
235
+ # post-process each arg (as a line of input to sed) to backslash-escape any
236
+ # character that might be a shell metacharacter, then use eval to reverse
237
+ # that process (while maintaining the separation between arguments), and wrap
238
+ # the whole thing up as a single "set" statement.
239
+ #
240
+ # This will of course break if any of these variables contains a newline or
241
+ # an unmatched quote.
242
+ #
243
+
244
+ eval "set -- $(
245
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
246
+ xargs -n1 |
247
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248
+ tr '\n' ' '
249
+ )" '"$@"'
184
250
 
185
251
  exec "$JAVACMD" "$@"
@@ -13,8 +13,10 @@
13
13
  @rem See the License for the specific language governing permissions and
14
14
  @rem limitations under the License.
15
15
  @rem
16
+ @rem SPDX-License-Identifier: Apache-2.0
17
+ @rem
16
18
 
17
- @if "%DEBUG%" == "" @echo off
19
+ @if "%DEBUG%"=="" @echo off
18
20
  @rem ##########################################################################
19
21
  @rem
20
22
  @rem Gradle startup script for Windows
@@ -25,7 +27,8 @@
25
27
  if "%OS%"=="Windows_NT" setlocal
26
28
 
27
29
  set DIRNAME=%~dp0
28
- if "%DIRNAME%" == "" set DIRNAME=.
30
+ if "%DIRNAME%"=="" set DIRNAME=.
31
+ @rem This is normally unused
29
32
  set APP_BASE_NAME=%~n0
30
33
  set APP_HOME=%DIRNAME%
31
34
 
@@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
40
43
 
41
44
  set JAVA_EXE=java.exe
42
45
  %JAVA_EXE% -version >NUL 2>&1
43
- if "%ERRORLEVEL%" == "0" goto execute
46
+ if %ERRORLEVEL% equ 0 goto execute
44
47
 
45
- echo.
46
- echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47
- echo.
48
- echo Please set the JAVA_HOME variable in your environment to match the
49
- echo location of your Java installation.
48
+ echo. 1>&2
49
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50
+ echo. 1>&2
51
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52
+ echo location of your Java installation. 1>&2
50
53
 
51
54
  goto fail
52
55
 
@@ -56,32 +59,34 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56
59
 
57
60
  if exist "%JAVA_EXE%" goto execute
58
61
 
59
- echo.
60
- echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61
- echo.
62
- echo Please set the JAVA_HOME variable in your environment to match the
63
- echo location of your Java installation.
62
+ echo. 1>&2
63
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64
+ echo. 1>&2
65
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66
+ echo location of your Java installation. 1>&2
64
67
 
65
68
  goto fail
66
69
 
67
70
  :execute
68
71
  @rem Setup the command line
69
72
 
70
- set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73
+ set CLASSPATH=
71
74
 
72
75
 
73
76
  @rem Execute Gradle
74
- "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
77
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
75
78
 
76
79
  :end
77
80
  @rem End local scope for the variables with windows NT shell
78
- if "%ERRORLEVEL%"=="0" goto mainEnd
81
+ if %ERRORLEVEL% equ 0 goto mainEnd
79
82
 
80
83
  :fail
81
84
  rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82
85
  rem the _cmd.exe /c_ return code!
83
- if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84
- exit /b 1
86
+ set EXIT_CODE=%ERRORLEVEL%
87
+ if %EXIT_CODE% equ 0 set EXIT_CODE=1
88
+ if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89
+ exit /b %EXIT_CODE%
85
90
 
86
91
  :mainEnd
87
92
  if "%OS%"=="Windows_NT" endlocal
@@ -2,6 +2,7 @@ package com.theoplayer.ads
2
2
 
3
3
  import com.facebook.react.bridge.Arguments
4
4
  import com.facebook.react.bridge.ReadableMap
5
+ import com.facebook.react.bridge.ReadableType
5
6
  import com.facebook.react.bridge.WritableMap
6
7
  import com.facebook.react.bridge.WritableArray
7
8
  import com.google.ads.interactivemedia.v3.api.AdPodInfo
@@ -12,6 +13,8 @@ import com.theoplayer.android.api.ads.CompanionAd
12
13
  import com.theoplayer.android.api.ads.ima.GoogleImaAd
13
14
  import com.theoplayer.android.api.ads.UniversalAdId
14
15
  import com.theoplayer.android.api.event.ads.AdIntegrationKind
16
+ import com.theoplayer.util.BridgeUtils
17
+ import org.json.JSONObject
15
18
  import java.lang.Exception
16
19
 
17
20
  private const val PROP_AD_SYSTEM = "adSystem"
@@ -49,6 +52,7 @@ private const val PROP_COMPANION_HEIGHT = "height"
49
52
  private const val PROP_COMPANION_RESOURCEURI = "resourceURI"
50
53
  private const val PROP_UNIVERSAL_AD_ID_REGISTRY = "adIdRegistry"
51
54
  private const val PROP_UNIVERSAL_AD_ID_VALUE = "adIdValue"
55
+ private const val PROP_CUSTOM_DATA = "customData"
52
56
 
53
57
  private const val INVALID_DOUBLE = -1.0
54
58
  private const val INVALID_INT = -1
@@ -130,6 +134,9 @@ object AdAdapter {
130
134
  }
131
135
  adPayload.putArray(PROP_AD_WRAPPER_CREATIVE_IDS, wrapperCreativeIdsPayload)
132
136
  }
137
+ fromCustomData(ad.customData)?.let {
138
+ adPayload.putMap(PROP_CUSTOM_DATA, it)
139
+ }
133
140
  return adPayload
134
141
  }
135
142
 
@@ -146,6 +153,9 @@ object AdAdapter {
146
153
  adbreakPayload.putInt(PROP_ADBREAK_MAXDURATION,adbreak.maxDuration)
147
154
  adbreakPayload.putInt(PROP_ADBREAK_TIMEOFFSET, adbreak.timeOffset)
148
155
  adbreakPayload.putDouble(PROP_ADBREAK_MAXREMAININGDURATION, adbreak.maxRemainingDuration)
156
+ fromCustomData(adbreak.customData)?.let {
157
+ adbreakPayload.putMap(PROP_CUSTOM_DATA, it)
158
+ }
149
159
  val adsPayload = Arguments.createArray()
150
160
  for (ad in adbreak.ads) {
151
161
  // Some ads in the ad break are possibly not loaded yet.
@@ -180,10 +190,27 @@ object AdAdapter {
180
190
  return companionsPayload
181
191
  }
182
192
 
193
+ private fun fromCustomData(customData: Any?): WritableMap? = when (customData) {
194
+ is JSONObject -> BridgeUtils.fromJSONObjectToBridge(customData)
195
+ is Map<*, *> -> BridgeUtils.fromJSONObjectToBridge(JSONObject(customData.filterKeys { it is String }))
196
+ else -> null
197
+ }
198
+
199
+ private fun parseCustomData(data: ReadableMap): Map<String, Any?>? =
200
+ if (data.hasKey(PROP_CUSTOM_DATA) && data.getType(PROP_CUSTOM_DATA) == ReadableType.Map) {
201
+ data.getMap(PROP_CUSTOM_DATA)?.toHashMap()
202
+ } else {
203
+ null
204
+ }
205
+
183
206
  /**
184
207
  * Convert a ReactNative Ad to a native Ad.
208
+ *
209
+ * @param ad The bridged ad, or null.
210
+ * @param parentAdBreak The owning break when parsing an ad nested in a break.
211
+ * @return The native ad, or null when the input is null.
185
212
  */
186
- fun parseAd(ad: ReadableMap?): GoogleImaAd? {
213
+ fun parseAd(ad: ReadableMap?, parentAdBreak: AdBreak? = null): GoogleImaAd? {
187
214
  if (ad == null) {
188
215
  return null
189
216
  }
@@ -201,7 +228,7 @@ object AdAdapter {
201
228
  }
202
229
 
203
230
  override fun getAdBreak(): AdBreak? {
204
- return parseAdBreak(ad.getMap(PROP_AD_BREAK))
231
+ return parentAdBreak ?: if (ad.hasKey(PROP_AD_BREAK)) parseAdBreak(ad.getMap(PROP_AD_BREAK)) else null
205
232
  }
206
233
 
207
234
  override fun getSkipOffset(): Int {
@@ -217,8 +244,7 @@ object AdAdapter {
217
244
  }
218
245
 
219
246
  override fun getCustomData(): Any? {
220
- // Not supported yet
221
- return null
247
+ return parseCustomData(ad)
222
248
  }
223
249
 
224
250
  override val imaAd: com.google.ads.interactivemedia.v3.api.Ad
@@ -256,7 +282,8 @@ object AdAdapter {
256
282
  }
257
283
  return object: AdBreak {
258
284
  override fun getAds(): List<Ad> {
259
- return emptyList()
285
+ val ads = if (adBreak.hasKey(PROP_ADBREAK_ADS)) adBreak.getArray(PROP_ADBREAK_ADS) else null
286
+ return (0 until (ads?.size() ?: 0)).mapNotNull { parseAd(ads?.getMap(it), this) }
260
287
  }
261
288
 
262
289
  override fun getMaxDuration(): Int {
@@ -298,8 +325,7 @@ object AdAdapter {
298
325
  }
299
326
 
300
327
  override fun getCustomData(): Any? {
301
- // Not supported yet
302
- return null
328
+ return parseCustomData(adBreak)
303
329
  }
304
330
  }
305
331
  }
@@ -65,7 +65,14 @@ class AdEventAdapter(private val adsApi: AdsApiWrapper, eventEmitter: AdEventEmi
65
65
  return if (event != null && eventType != null) {
66
66
  object : GoogleImaAdEvent {
67
67
  override val ad: GoogleImaAd?
68
- get() = AdAdapter.parseAd(event.getMap(EVENT_PROP_AD))
68
+ get() {
69
+ val payload = event.getMap(EVENT_PROP_AD)
70
+ val adBreak = when (eventType) {
71
+ GoogleImaAdEventType.AD_BREAK_STARTED, GoogleImaAdEventType.AD_BREAK_ENDED -> AdAdapter.parseAdBreak(payload)
72
+ else -> null
73
+ }
74
+ return AdAdapter.parseAd(payload, adBreak)
75
+ }
69
76
  override val adData: Map<String, String>
70
77
  get() = mapOf()
71
78
  override fun getDate(): Date {