@npaw/forge-react-native-video 20.5.14 → 20.6.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.
package/android/build.gradle
CHANGED
|
@@ -25,11 +25,11 @@ def safeExtGet(prop, fallback) {
|
|
|
25
25
|
|
|
26
26
|
def forgeCoreVersion = project.hasProperty('NpawForge_forgeCoreVersion')
|
|
27
27
|
? project.property('NpawForge_forgeCoreVersion')
|
|
28
|
-
: (System.getenv('FORGE_CORE_VERSION') ?: '10.
|
|
28
|
+
: (System.getenv('FORGE_CORE_VERSION') ?: '10.6.0')
|
|
29
29
|
|
|
30
30
|
def forgeAdapterVersion = project.hasProperty('NpawForge_forgeAdapterVersion')
|
|
31
31
|
? project.property('NpawForge_forgeAdapterVersion')
|
|
32
|
-
: (System.getenv('FORGE_ADAPTER_VERSION') ?: '10.
|
|
32
|
+
: (System.getenv('FORGE_ADAPTER_VERSION') ?: '10.6.0')
|
|
33
33
|
|
|
34
34
|
android {
|
|
35
35
|
namespace 'com.npaw.forge.reactnative.video'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npaw/forge-react-native-video",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.6.0",
|
|
4
4
|
"description": "react-native-video adapter glue for NPAW Forge: attaches the native Media3/AVPlayer Forge adapters to react-native-video's internal players via its native plugin API (react-native-video 6 and 7 generations, one major each).",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Victor Soto <victor.soto@nicepeopleatwork.com>",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"NPAWForgeReactNativeVideo.podspec",
|
|
12
12
|
"README.md",
|
|
13
13
|
"android",
|
|
14
|
+
"!android/src/test",
|
|
14
15
|
"generations.json",
|
|
15
16
|
"ios",
|
|
16
17
|
"src"
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
"test": "jest"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
23
|
-
"@npaw/forge-react-native": "^10.
|
|
24
|
+
"@npaw/forge-react-native": "^10.6.0",
|
|
24
25
|
"react": "*",
|
|
25
26
|
"react-native": "*",
|
|
26
27
|
"react-native-video": ">=7.0.0-beta.11 <8",
|
package/android/src/test/java/com/npaw/forge/reactnative/video/RNVideoAttachCoordinatorTest.java
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (C) NPAW - All Rights Reserved
|
|
3
|
-
*
|
|
4
|
-
* This source code is protected under international copyright law. All rights
|
|
5
|
-
* reserved and protected by the copyright holders.
|
|
6
|
-
* This file is confidential and only available to authorized individuals with the
|
|
7
|
-
* permission of the copyright holders. If you encounter this file and do not have
|
|
8
|
-
* permission, please contact the copyright holders and delete this file.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @author: Victor Soto <victor.soto@nicepeopleatwork.com>
|
|
12
|
-
* @description: JVM unit tests for the attach correlation policy engine (fake players; no ExoPlayer or Android runtime).
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
package com.npaw.forge.reactnative.video;
|
|
16
|
-
|
|
17
|
-
import static org.junit.Assert.assertEquals;
|
|
18
|
-
import static org.junit.Assert.assertFalse;
|
|
19
|
-
import static org.junit.Assert.assertTrue;
|
|
20
|
-
|
|
21
|
-
import androidx.annotation.Nullable;
|
|
22
|
-
import java.util.ArrayList;
|
|
23
|
-
import java.util.HashMap;
|
|
24
|
-
import java.util.List;
|
|
25
|
-
import java.util.Map;
|
|
26
|
-
import org.junit.Before;
|
|
27
|
-
import org.junit.Test;
|
|
28
|
-
|
|
29
|
-
public class RNVideoAttachCoordinatorTest {
|
|
30
|
-
|
|
31
|
-
private static final class FakeBinder implements RNVideoAttachCoordinator.Binder<Object> {
|
|
32
|
-
final List<String> binds = new ArrayList<>();
|
|
33
|
-
final List<String> unbinds = new ArrayList<>();
|
|
34
|
-
|
|
35
|
-
@Override
|
|
36
|
-
public void bind(String instanceId, String identifier, String playerId, Object player) {
|
|
37
|
-
binds.add(identifier + "->" + playerId);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@Override
|
|
41
|
-
public void unbind(String instanceId, String identifier, String playerId, boolean fireStop) {
|
|
42
|
-
unbinds.add(identifier + "->" + playerId + (fireStop ? " stop" : " silent"));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private final Map<String, String> tokens = new HashMap<>();
|
|
47
|
-
private final Map<String, String> uris = new HashMap<>();
|
|
48
|
-
private FakeBinder binder;
|
|
49
|
-
private RNVideoAttachCoordinator<Object> coordinator;
|
|
50
|
-
|
|
51
|
-
@Before
|
|
52
|
-
public void setUp() {
|
|
53
|
-
tokens.clear();
|
|
54
|
-
uris.clear();
|
|
55
|
-
binder = new FakeBinder();
|
|
56
|
-
coordinator =
|
|
57
|
-
new RNVideoAttachCoordinator<>(
|
|
58
|
-
new RNVideoAttachCoordinator.PlayerIntrospection() {
|
|
59
|
-
@Nullable
|
|
60
|
-
@Override
|
|
61
|
-
public String currentToken(String playerId) {
|
|
62
|
-
return tokens.get(playerId);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@Nullable
|
|
66
|
-
@Override
|
|
67
|
-
public String currentUri(String playerId) {
|
|
68
|
-
return uris.get(playerId);
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
binder);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
private static RNVideoAttachCoordinator.AttachRequest auto(String identifier) {
|
|
75
|
-
return new RNVideoAttachCoordinator.AttachRequest(
|
|
76
|
-
"forge-1", identifier, "auto", null, null, true);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private static RNVideoAttachCoordinator.AttachRequest token(String identifier, String token) {
|
|
80
|
-
return new RNVideoAttachCoordinator.AttachRequest(
|
|
81
|
-
"forge-1", identifier, "match", token, null, true);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private static RNVideoAttachCoordinator.AttachRequest uri(String identifier, String uri) {
|
|
85
|
-
return new RNVideoAttachCoordinator.AttachRequest(
|
|
86
|
-
"forge-1", identifier, "match", null, uri, true);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@Test
|
|
90
|
-
public void attachBeforeCreateBindsWhenPlayerArrives() {
|
|
91
|
-
RNVideoAttachCoordinator.AttachOutcome outcome = coordinator.attach(auto("default"));
|
|
92
|
-
assertEquals("pending", outcome.attachment);
|
|
93
|
-
assertTrue(outcome.accepted);
|
|
94
|
-
|
|
95
|
-
coordinator.playerCreated("p1", new Object());
|
|
96
|
-
assertEquals(List.of("default->p1"), binder.binds);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@Test
|
|
100
|
-
public void createBeforeAttachBindsImmediately() {
|
|
101
|
-
coordinator.playerCreated("p1", new Object());
|
|
102
|
-
RNVideoAttachCoordinator.AttachOutcome outcome = coordinator.attach(auto("default"));
|
|
103
|
-
assertEquals("bound", outcome.attachment);
|
|
104
|
-
assertEquals(List.of("default->p1"), binder.binds);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
@Test
|
|
108
|
-
public void autoRefusesAmbiguity() {
|
|
109
|
-
coordinator.playerCreated("p1", new Object());
|
|
110
|
-
coordinator.playerCreated("p2", new Object());
|
|
111
|
-
RNVideoAttachCoordinator.AttachOutcome outcome = coordinator.attach(auto("default"));
|
|
112
|
-
assertEquals("unsupported_capability", outcome.code);
|
|
113
|
-
assertEquals("ambiguous_auto_attach", outcome.reason);
|
|
114
|
-
assertTrue(binder.binds.isEmpty());
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
@Test
|
|
118
|
-
public void autoPendingDoesNotBindWhileAmbiguous() {
|
|
119
|
-
coordinator.attach(auto("default"));
|
|
120
|
-
coordinator.playerCreated("p1", new Object());
|
|
121
|
-
coordinator.playerCreated("p2", new Object());
|
|
122
|
-
// p1 bound the pending attach when it was the single player; p2 arriving
|
|
123
|
-
// afterwards must not steal or duplicate.
|
|
124
|
-
assertEquals(List.of("default->p1"), binder.binds);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
@Test
|
|
128
|
-
public void headerTokenMatchesTheRightPlayer() {
|
|
129
|
-
coordinator.playerCreated("p1", new Object());
|
|
130
|
-
coordinator.playerCreated("p2", new Object());
|
|
131
|
-
tokens.put("p2", "main");
|
|
132
|
-
|
|
133
|
-
RNVideoAttachCoordinator.AttachOutcome outcome = coordinator.attach(token("default", "main"));
|
|
134
|
-
assertEquals("bound", outcome.attachment);
|
|
135
|
-
assertEquals(List.of("default->p2"), binder.binds);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
@Test
|
|
139
|
-
public void tokenSettlingLateBindsOnSourceSettled() {
|
|
140
|
-
coordinator.playerCreated("p1", new Object());
|
|
141
|
-
coordinator.playerCreated("p2", new Object());
|
|
142
|
-
RNVideoAttachCoordinator.AttachOutcome outcome = coordinator.attach(token("default", "main"));
|
|
143
|
-
assertEquals("pending", outcome.attachment);
|
|
144
|
-
|
|
145
|
-
tokens.put("p1", "main");
|
|
146
|
-
coordinator.playerSourceSettled();
|
|
147
|
-
assertEquals(List.of("default->p1"), binder.binds);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
@Test
|
|
151
|
-
public void sourceUriFallbackMatches() {
|
|
152
|
-
coordinator.playerCreated("p1", new Object());
|
|
153
|
-
coordinator.playerCreated("p2", new Object());
|
|
154
|
-
uris.put("p2", "https://cdn/x.m3u8");
|
|
155
|
-
|
|
156
|
-
coordinator.attach(uri("default", "https://cdn/x.m3u8"));
|
|
157
|
-
assertEquals(List.of("default->p2"), binder.binds);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
@Test
|
|
161
|
-
public void twoIdentifiersTwoTokensBindDistinctPlayers() {
|
|
162
|
-
coordinator.playerCreated("p1", new Object());
|
|
163
|
-
coordinator.playerCreated("p2", new Object());
|
|
164
|
-
tokens.put("p1", "a");
|
|
165
|
-
tokens.put("p2", "b");
|
|
166
|
-
|
|
167
|
-
coordinator.attach(token("main", "a"));
|
|
168
|
-
coordinator.attach(token("pip", "b"));
|
|
169
|
-
assertEquals(List.of("main->p1", "pip->b".replace("b", "p2")), binder.binds);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
@Test
|
|
173
|
-
public void duplicateAttachIsIgnored() {
|
|
174
|
-
coordinator.playerCreated("p1", new Object());
|
|
175
|
-
coordinator.attach(auto("default"));
|
|
176
|
-
RNVideoAttachCoordinator.AttachOutcome outcome = coordinator.attach(auto("default"));
|
|
177
|
-
assertEquals("ignored_duplicate", outcome.code);
|
|
178
|
-
assertEquals(1, binder.binds.size());
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
@Test
|
|
182
|
-
public void detachUnbindsWithStopAndAllowsRebind() {
|
|
183
|
-
coordinator.playerCreated("p1", new Object());
|
|
184
|
-
coordinator.attach(auto("default"));
|
|
185
|
-
|
|
186
|
-
assertTrue(coordinator.detach("forge-1", "default", true));
|
|
187
|
-
assertEquals(List.of("default->p1 stop"), binder.unbinds);
|
|
188
|
-
|
|
189
|
-
coordinator.attach(auto("default"));
|
|
190
|
-
assertEquals(2, binder.binds.size());
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
@Test
|
|
194
|
-
public void detachWithoutBindingReportsFalse() {
|
|
195
|
-
assertFalse(coordinator.detach("forge-1", "default", true));
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
@Test
|
|
199
|
-
public void playerRemovedHonorsStopOnPlayerRemoved() {
|
|
200
|
-
coordinator.playerCreated("p1", new Object());
|
|
201
|
-
coordinator.attach(
|
|
202
|
-
new RNVideoAttachCoordinator.AttachRequest("forge-1", "default", "auto", null, null, false));
|
|
203
|
-
coordinator.playerRemoved("p1");
|
|
204
|
-
assertEquals(List.of("default->p1 silent"), binder.unbinds);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
@Test
|
|
208
|
-
public void reattachAfterRemovalGoesPendingThenBindsNextPlayer() {
|
|
209
|
-
coordinator.playerCreated("p1", new Object());
|
|
210
|
-
coordinator.attach(auto("default"));
|
|
211
|
-
coordinator.playerRemoved("p1");
|
|
212
|
-
|
|
213
|
-
RNVideoAttachCoordinator.AttachOutcome outcome = coordinator.attach(auto("default"));
|
|
214
|
-
assertEquals("pending", outcome.attachment);
|
|
215
|
-
coordinator.playerCreated("p2", new Object());
|
|
216
|
-
assertEquals(List.of("default->p1", "default->p2"), binder.binds);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (C) NPAW - All Rights Reserved
|
|
3
|
-
*
|
|
4
|
-
* This source code is protected under international copyright law. All rights
|
|
5
|
-
* reserved and protected by the copyright holders.
|
|
6
|
-
* This file is confidential and only available to authorized individuals with the
|
|
7
|
-
* permission of the copyright holders. If you encounter this file and do not have
|
|
8
|
-
* permission, please contact the copyright holders and delete this file.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @author: Victor Soto <victor.soto@nicepeopleatwork.com>
|
|
12
|
-
* @description: JVM unit tests for the header-token extraction shared by the react-native-video 7 module (case-insensitive header key, empty and missing values, first non-empty casing wins).
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
package com.npaw.forge.reactnative.video;
|
|
16
|
-
|
|
17
|
-
import static org.junit.Assert.assertEquals;
|
|
18
|
-
import static org.junit.Assert.assertNull;
|
|
19
|
-
|
|
20
|
-
import java.util.HashMap;
|
|
21
|
-
import java.util.LinkedHashMap;
|
|
22
|
-
import java.util.Map;
|
|
23
|
-
import org.junit.Test;
|
|
24
|
-
|
|
25
|
-
public class RNVideoHeaderTokenTest {
|
|
26
|
-
|
|
27
|
-
@Test
|
|
28
|
-
public void nullMapYieldsNull() {
|
|
29
|
-
assertNull(RNVideoHeaderToken.fromHeaders(null));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@Test
|
|
33
|
-
public void missingHeaderYieldsNull() {
|
|
34
|
-
Map<String, String> headers = new HashMap<>();
|
|
35
|
-
headers.put("Authorization", "Bearer x");
|
|
36
|
-
assertNull(RNVideoHeaderToken.fromHeaders(headers));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@Test
|
|
40
|
-
public void matchesTheHeaderCaseInsensitively() {
|
|
41
|
-
Map<String, String> headers = new HashMap<>();
|
|
42
|
-
headers.put("X-NPAW-Forge", "main");
|
|
43
|
-
assertEquals("main", RNVideoHeaderToken.fromHeaders(headers));
|
|
44
|
-
|
|
45
|
-
headers.clear();
|
|
46
|
-
headers.put("x-npaw-forge", "pip");
|
|
47
|
-
assertEquals("pip", RNVideoHeaderToken.fromHeaders(headers));
|
|
48
|
-
|
|
49
|
-
headers.clear();
|
|
50
|
-
headers.put("X-Npaw-FORGE", "mixed");
|
|
51
|
-
assertEquals("mixed", RNVideoHeaderToken.fromHeaders(headers));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@Test
|
|
55
|
-
public void emptyValueCountsAsAbsent() {
|
|
56
|
-
Map<String, String> headers = new HashMap<>();
|
|
57
|
-
headers.put("X-NPAW-Forge", "");
|
|
58
|
-
assertNull(RNVideoHeaderToken.fromHeaders(headers));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
@Test
|
|
62
|
-
public void firstNonEmptyCasingWins() {
|
|
63
|
-
Map<String, String> headers = new LinkedHashMap<>();
|
|
64
|
-
headers.put("x-npaw-forge", "");
|
|
65
|
-
headers.put("X-NPAW-Forge", "second");
|
|
66
|
-
assertEquals("second", RNVideoHeaderToken.fromHeaders(headers));
|
|
67
|
-
}
|
|
68
|
-
}
|