@24i/smartapps-bigscreen-rnv-build-engine 0.17.2-alpha.2165 → 0.17.2-alpha.2167
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/dist/src/resolvers/index.js +3 -1
- package/dist/src/resolvers/resolveBuildFileBaseName.js +34 -0
- package/dist/src/resolvers/resolveBuildFileExtension.js +0 -1
- package/dist/src/resolvers/resolveBuildFileName.js +3 -27
- package/dist/src/sdks/sdk-androidtv/sdkAndroidtv.js +60 -12
- package/dist/src/tasks/task.rnv.build.js +0 -1
- package/dist/templates/platforms/androidtv/project/app/build.gradle +9 -0
- package/package.json +1 -1
- package/dist/templates/platforms/androidtv/project/app/src/main/java/com/twentyfouri/tvbridge/global/utils/HttpMediaDrmCallback.kt +0 -184
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveZippedPlatformBuildsRelativeFilePath = exports.resolvePackageVersions = exports.resolveBuildFileExtension = exports.resolveUsedFlavours = exports.resolveSupportedPlatforms = exports.getBaseConfig = exports.resolveBuildFileName = exports.resolveHbbtvDeployConfig = exports.resolveHbbtvDeployUrl = exports.resolveHbbtvRemoteBuildDirRelativePath = exports.resolveDeployLocations = exports.resolveBuildVersionOffset = exports.resolveBuildVersion = exports.resolveBaseUrl = void 0;
|
|
3
|
+
exports.resolveZippedPlatformBuildsRelativeFilePath = exports.resolvePackageVersions = exports.resolveBuildFileExtension = exports.resolveUsedFlavours = exports.resolveSupportedPlatforms = exports.getBaseConfig = exports.resolveBuildFileName = exports.resolveBuildFileBaseName = exports.resolveHbbtvDeployConfig = exports.resolveHbbtvDeployUrl = exports.resolveHbbtvRemoteBuildDirRelativePath = exports.resolveDeployLocations = exports.resolveBuildVersionOffset = exports.resolveBuildVersion = exports.resolveBaseUrl = void 0;
|
|
4
4
|
var resolveBaseUrl_1 = require("./resolveBaseUrl");
|
|
5
5
|
Object.defineProperty(exports, "resolveBaseUrl", { enumerable: true, get: function () { return resolveBaseUrl_1.resolveBaseUrl; } });
|
|
6
6
|
var resolveBuildVersion_1 = require("./resolveBuildVersion");
|
|
@@ -15,6 +15,8 @@ var resolveHbbtvDeployUrl_1 = require("./resolveHbbtvDeployUrl");
|
|
|
15
15
|
Object.defineProperty(exports, "resolveHbbtvDeployUrl", { enumerable: true, get: function () { return resolveHbbtvDeployUrl_1.resolveHbbtvDeployUrl; } });
|
|
16
16
|
var resolveHbbtvDeployConfig_1 = require("./resolveHbbtvDeployConfig");
|
|
17
17
|
Object.defineProperty(exports, "resolveHbbtvDeployConfig", { enumerable: true, get: function () { return resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig; } });
|
|
18
|
+
var resolveBuildFileBaseName_1 = require("./resolveBuildFileBaseName");
|
|
19
|
+
Object.defineProperty(exports, "resolveBuildFileBaseName", { enumerable: true, get: function () { return resolveBuildFileBaseName_1.resolveBuildFileBaseName; } });
|
|
18
20
|
var resolveBuildFileName_1 = require("./resolveBuildFileName");
|
|
19
21
|
Object.defineProperty(exports, "resolveBuildFileName", { enumerable: true, get: function () { return resolveBuildFileName_1.resolveBuildFileName; } });
|
|
20
22
|
var resolveGenericRnvConfig_1 = require("./resolveGenericRnvConfig");
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveBuildFileBaseName = void 0;
|
|
4
|
+
const resolveBuildVersion_1 = require("./resolveBuildVersion");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const getBuildVersionForFileName = (c) => {
|
|
7
|
+
const { platform, runtime } = c;
|
|
8
|
+
const { scheme, appId } = runtime;
|
|
9
|
+
switch (c.runtime.scheme) {
|
|
10
|
+
case constants_1.BuildSchemes.DEV_LATEST:
|
|
11
|
+
return 'latest.dev';
|
|
12
|
+
case constants_1.BuildSchemes.RC_LATEST:
|
|
13
|
+
return 'latest.rc';
|
|
14
|
+
case constants_1.BuildSchemes.RELEASE_LATEST:
|
|
15
|
+
return 'latest.release';
|
|
16
|
+
default:
|
|
17
|
+
return (0, resolveBuildVersion_1.resolveBuildVersion)({
|
|
18
|
+
platform,
|
|
19
|
+
scheme,
|
|
20
|
+
flavour: appId,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const resolveBuildFileBaseName = (c) => {
|
|
25
|
+
const platformName = c.platform;
|
|
26
|
+
const { appNameInFileName } = c.buildConfig.common;
|
|
27
|
+
if (!appNameInFileName) {
|
|
28
|
+
throw new Error('Missing value for "c.buildConfig.common.appNameInFileName"!');
|
|
29
|
+
}
|
|
30
|
+
const appConfigId = c.runtime.appId;
|
|
31
|
+
const buildVersion = getBuildVersionForFileName(c);
|
|
32
|
+
return `${appNameInFileName}_${platformName}_${buildVersion}_${appConfigId}`;
|
|
33
|
+
};
|
|
34
|
+
exports.resolveBuildFileBaseName = resolveBuildFileBaseName;
|
|
@@ -1,36 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveBuildFileName = void 0;
|
|
4
|
-
const
|
|
5
|
-
const constants_1 = require("../constants");
|
|
4
|
+
const resolveBuildFileBaseName_1 = require("./resolveBuildFileBaseName");
|
|
6
5
|
const resolveBuildFileExtension_1 = require("./resolveBuildFileExtension");
|
|
7
|
-
const getBuildVersionForFileName = (c) => {
|
|
8
|
-
const { platform, runtime } = c;
|
|
9
|
-
const { scheme, appId } = runtime;
|
|
10
|
-
switch (c.runtime.scheme) {
|
|
11
|
-
case constants_1.BuildSchemes.DEV_LATEST:
|
|
12
|
-
return 'latest.dev';
|
|
13
|
-
case constants_1.BuildSchemes.RC_LATEST:
|
|
14
|
-
return 'latest.rc';
|
|
15
|
-
case constants_1.BuildSchemes.RELEASE_LATEST:
|
|
16
|
-
return 'latest.release';
|
|
17
|
-
default:
|
|
18
|
-
return (0, resolveBuildVersion_1.resolveBuildVersion)({
|
|
19
|
-
platform,
|
|
20
|
-
scheme,
|
|
21
|
-
flavour: appId,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
6
|
const resolveBuildFileName = (c) => {
|
|
26
7
|
const platformName = c.platform;
|
|
27
|
-
const
|
|
28
|
-
if (!appNameInFileName) {
|
|
29
|
-
throw new Error('Missing value for "c.buildConfig.common.appNameInFileName"!');
|
|
30
|
-
}
|
|
31
|
-
const appConfigId = c.runtime.appId;
|
|
32
|
-
const buildVersion = getBuildVersionForFileName(c);
|
|
8
|
+
const baseName = (0, resolveBuildFileBaseName_1.resolveBuildFileBaseName)(c);
|
|
33
9
|
const extension = (0, resolveBuildFileExtension_1.resolveBuildFileExtension)(platformName);
|
|
34
|
-
return `${
|
|
10
|
+
return `${baseName}.${extension}`;
|
|
35
11
|
};
|
|
36
12
|
exports.resolveBuildFileName = resolveBuildFileName;
|
|
@@ -37,33 +37,80 @@ const services_1 = require("../sdk-utils/sdk-installer/services");
|
|
|
37
37
|
const resolvers_1 = require("../../resolvers");
|
|
38
38
|
const constants_1 = require("../../constants");
|
|
39
39
|
const flavourName = 'bigscreenAppstage';
|
|
40
|
-
const buildType = 'debug';
|
|
41
40
|
const capitalizeFirstLetter = (str) => {
|
|
42
41
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
43
42
|
};
|
|
44
43
|
const buildAndroidTVProject = async (c) => {
|
|
45
44
|
rnv_1.Logger.logTask('buildAndroidTVProject');
|
|
46
45
|
await (0, sdk_webpack_2.buildCoreWebpackProject)(c);
|
|
46
|
+
const buildType = c.runtime.scheme === constants_1.BuildSchemes.DEBUG
|
|
47
|
+
? 'debug' : 'release';
|
|
47
48
|
if (!c.program.hosted) {
|
|
48
49
|
const projectDir = rnv_1.Common.getPlatformProjectDir(c);
|
|
50
|
+
const taskBuildType = buildType === 'debug' ? 'Debug' : 'Release';
|
|
49
51
|
const projectParentDir = path.join(projectDir, '..');
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
52
|
+
const outputDir = path.join(projectParentDir, 'output');
|
|
53
|
+
const tmpOutputDir = path.join(projectParentDir, 'tmpOutput');
|
|
54
|
+
const apkFileName = `app-${flavourName}-${buildType}.apk`;
|
|
55
|
+
const apkFilePath = path.join(projectDir, `app/build/outputs/apk/${flavourName}/${buildType}/${apkFileName}`);
|
|
56
|
+
const aabFileName = `app-${flavourName}-${buildType}.aab`;
|
|
57
|
+
const aabFilePath = path.join(projectDir, `app/build/outputs/bundle/${flavourName}${taskBuildType}/${aabFileName}`);
|
|
53
58
|
const gradlew = './gradlew';
|
|
54
|
-
const taskBuildType = buildType === 'debug' ? 'Debug' : 'Release';
|
|
55
59
|
const taskFlavourName = capitalizeFirstLetter(flavourName);
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
const taskAssembleName = `assemble${taskFlavourName}${taskBuildType}`;
|
|
61
|
+
const taskBundleName = `bundle${taskFlavourName}${taskBuildType}`;
|
|
62
|
+
(0, child_process_1.execSync)(`cd ${projectDir} && ${gradlew} ${taskAssembleName}`);
|
|
63
|
+
(0, child_process_1.execSync)(`cd ${projectDir} && ${gradlew} ${taskBundleName}`);
|
|
64
|
+
fs.rmSync(tmpOutputDir, { recursive: true, force: true });
|
|
65
|
+
fs.mkdirSync(tmpOutputDir);
|
|
66
|
+
if (!fs.existsSync(outputDir)) {
|
|
67
|
+
fs.mkdirSync(outputDir);
|
|
60
68
|
}
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
const newApkFilePath = path.join(tmpOutputDir, `${(0, resolvers_1.resolveBuildFileBaseName)(c)}.apk`);
|
|
70
|
+
const newAabFilePath = path.join(tmpOutputDir, `${(0, resolvers_1.resolveBuildFileBaseName)(c)}.aab`);
|
|
71
|
+
fs.copyFileSync(apkFilePath, newApkFilePath);
|
|
72
|
+
fs.copyFileSync(aabFilePath, newAabFilePath);
|
|
73
|
+
const zipFileName = `${(0, resolvers_1.resolveBuildFileBaseName)(c)}.zip`;
|
|
74
|
+
(0, child_process_1.execSync)(`zip -r ${outputDir}/${zipFileName} *`, { cwd: `${tmpOutputDir}` });
|
|
75
|
+
fs.rmSync(tmpOutputDir, { recursive: true, force: true });
|
|
76
|
+
rnv_1.Logger.logSuccess(`Your .zip with APK and AAB packages is located in ${rnv_1.Logger.chalk().cyan(outputDir)}.`);
|
|
64
77
|
}
|
|
65
78
|
};
|
|
66
79
|
exports.buildAndroidTVProject = buildAndroidTVProject;
|
|
80
|
+
const configureSigning = (c) => {
|
|
81
|
+
rnv_1.Logger.logTask('configureSigning');
|
|
82
|
+
const { getConfigProp } = rnv_1.Common;
|
|
83
|
+
const storeFile = process.env.ANDROIDTV_STORE_FILE ?? getConfigProp(c, c.platform, 'storeFile');
|
|
84
|
+
const keyAlias = process.env.ANDROIDTV_KEY_ALIAS ?? getConfigProp(c, c.platform, 'keyAlias');
|
|
85
|
+
const storePassword = process.env.ANDROIDTV_STORE_PASSWORD ?? getConfigProp(c, c.platform, 'storePassword');
|
|
86
|
+
const keyPassword = process.env.ANDROIDTV_KEY_PASSWORD ?? getConfigProp(c, c.platform, 'keyPassword');
|
|
87
|
+
const buildGradleFileName = 'build.gradle';
|
|
88
|
+
const buildGradleFilePath = path.join(rnv_1.Common.getPlatformProjectDir(c), 'app', buildGradleFileName);
|
|
89
|
+
const srcStoreFilePath = path.join(process.cwd(), storeFile);
|
|
90
|
+
const destStoreFilePath = path.join(rnv_1.Common.getPlatformProjectDir(c), storeFile);
|
|
91
|
+
const destStoreFileDir = path.parse(destStoreFilePath).dir;
|
|
92
|
+
if (!fs.existsSync(destStoreFileDir)) {
|
|
93
|
+
fs.mkdirSync(destStoreFileDir, { recursive: true });
|
|
94
|
+
}
|
|
95
|
+
fs.copyFileSync(srcStoreFilePath, destStoreFilePath);
|
|
96
|
+
const injects = [{
|
|
97
|
+
pattern: '{{STORE_FILE}}',
|
|
98
|
+
override: destStoreFilePath,
|
|
99
|
+
}, {
|
|
100
|
+
pattern: '{{KEY_ALIAS}}',
|
|
101
|
+
override: keyAlias,
|
|
102
|
+
}, {
|
|
103
|
+
pattern: '{{STORE_PASSWORD}}',
|
|
104
|
+
override: storePassword,
|
|
105
|
+
}, {
|
|
106
|
+
pattern: '{{KEY_PASSWORD}}',
|
|
107
|
+
override: keyPassword,
|
|
108
|
+
}, {
|
|
109
|
+
pattern: '{{SIGNING_CONFIG_REF}}',
|
|
110
|
+
override: `signingConfig signingConfigs.${flavourName}`,
|
|
111
|
+
}];
|
|
112
|
+
rnv_1.FileUtils.writeCleanFile(buildGradleFilePath, buildGradleFilePath, injects, null, c);
|
|
113
|
+
};
|
|
67
114
|
const configureProject = (c) => {
|
|
68
115
|
rnv_1.Logger.logTask('configureProject');
|
|
69
116
|
const buildGradleFileName = 'build.gradle';
|
|
@@ -120,6 +167,7 @@ const configureAndroidTVProject = async (c) => {
|
|
|
120
167
|
await configureAndroidProperties(c);
|
|
121
168
|
configureProject(c);
|
|
122
169
|
configureEntryUrl(c);
|
|
170
|
+
configureSigning(c);
|
|
123
171
|
const gradlew = path.join(rnv_1.Common.getPlatformProjectDir(c), 'gradlew');
|
|
124
172
|
fs.chmodSync(gradlew, '755');
|
|
125
173
|
await rnv_1.ProjectManager.copyBuildsFolder(c, platform);
|
|
@@ -57,6 +57,14 @@ android {
|
|
|
57
57
|
keyPassword 'freddie12'
|
|
58
58
|
keyAlias 'iamflix-app'
|
|
59
59
|
}*/
|
|
60
|
+
bigscreenAppstage {
|
|
61
|
+
keyAlias '{{KEY_ALIAS}}'
|
|
62
|
+
keyPassword '{{KEY_PASSWORD}}'
|
|
63
|
+
storeFile file('{{STORE_FILE}}')
|
|
64
|
+
storePassword '{{STORE_PASSWORD}}'
|
|
65
|
+
v1SigningEnabled true
|
|
66
|
+
v2SigningEnabled true
|
|
67
|
+
}
|
|
60
68
|
kan {
|
|
61
69
|
keyAlias 'ireshet'
|
|
62
70
|
keyPassword 'applicaster'
|
|
@@ -252,6 +260,7 @@ android {
|
|
|
252
260
|
versionName "{{APP_VERSION_NAME}}"
|
|
253
261
|
applicationId "{{APP_ID}}"
|
|
254
262
|
resValue "string", "app_name", "{{configProps.appName}}"
|
|
263
|
+
{{SIGNING_CONFIG_REF}}
|
|
255
264
|
}
|
|
256
265
|
kan {
|
|
257
266
|
// X.Y.Z XXYYZZUU -> version 1.2.3 will be 01020300, 5th update of 1.2.3 will be 01020305
|
package/package.json
CHANGED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
package com.twentyfouri.tvbridge.global.utils
|
|
2
|
-
|
|
3
|
-
import android.net.Uri
|
|
4
|
-
import android.text.TextUtils
|
|
5
|
-
import android.util.Base64
|
|
6
|
-
import android.util.Log
|
|
7
|
-
import com.google.android.exoplayer2.C
|
|
8
|
-
import com.google.android.exoplayer2.drm.ExoMediaDrm
|
|
9
|
-
import com.google.android.exoplayer2.upstream.DataSourceInputStream
|
|
10
|
-
import com.google.android.exoplayer2.upstream.DataSpec
|
|
11
|
-
import com.google.android.exoplayer2.upstream.HttpDataSource
|
|
12
|
-
import com.google.android.exoplayer2.util.Assertions
|
|
13
|
-
import com.google.android.exoplayer2.util.Util
|
|
14
|
-
import com.twentyfouri.smartexoplayer.drm.SmartMediaDrmCallback
|
|
15
|
-
import com.twentyfouri.smartexoplayer.model.DrmConfiguration
|
|
16
|
-
import com.twentyfouri.tvbridge.BuildConfig
|
|
17
|
-
import org.json.JSONException
|
|
18
|
-
import org.json.JSONObject
|
|
19
|
-
import java.io.BufferedReader
|
|
20
|
-
import java.io.IOException
|
|
21
|
-
import java.io.InputStreamReader
|
|
22
|
-
import java.net.MalformedURLException
|
|
23
|
-
import java.net.URL
|
|
24
|
-
import java.net.URLEncoder
|
|
25
|
-
import java.util.HashMap
|
|
26
|
-
import java.util.UUID
|
|
27
|
-
|
|
28
|
-
class HttpMediaDrmCallback(
|
|
29
|
-
private val defaultLicenseUrl: String?,
|
|
30
|
-
private val forceDefaultLicenseUrl: Boolean,
|
|
31
|
-
private val dataSourceFactory: HttpDataSource.Factory
|
|
32
|
-
) : SmartMediaDrmCallback {
|
|
33
|
-
|
|
34
|
-
private val keyRequestProperties = HashMap<String, String>()
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
|
|
38
|
-
* their own license URL.
|
|
39
|
-
* @param dataSourceFactory A factory from which to obtain [HttpDataSource] instances.
|
|
40
|
-
*/
|
|
41
|
-
constructor(defaultLicenseUrl: String, dataSourceFactory: HttpDataSource.Factory) : this(defaultLicenseUrl, false, dataSourceFactory) {}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Sets a header for key requests made by the callback.
|
|
45
|
-
*
|
|
46
|
-
* @param name The name of the header field.
|
|
47
|
-
* @param value The value of the field.
|
|
48
|
-
*/
|
|
49
|
-
override fun setKeyRequestProperty(name: String, value: String) {
|
|
50
|
-
Log.d(TAG, "setKeyRequestProperty")
|
|
51
|
-
Assertions.checkNotNull(name)
|
|
52
|
-
Assertions.checkNotNull(value)
|
|
53
|
-
synchronized(keyRequestProperties) { keyRequestProperties.put(name, value) }
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Clears a header for key requests made by the callback.
|
|
58
|
-
*
|
|
59
|
-
* @param name The name of the header field.
|
|
60
|
-
*/
|
|
61
|
-
override fun clearKeyRequestProperty(name: String) {
|
|
62
|
-
Log.d(TAG, "clearKeyRequestProperty")
|
|
63
|
-
Assertions.checkNotNull(name)
|
|
64
|
-
synchronized(keyRequestProperties) { keyRequestProperties.remove(name) }
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Clears all headers for key requests made by the callback.
|
|
69
|
-
*/
|
|
70
|
-
override fun clearAllKeyRequestProperties() {
|
|
71
|
-
Log.d(TAG, "clearAllKeyRequestProperties")
|
|
72
|
-
synchronized(keyRequestProperties) { keyRequestProperties.clear() }
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@Throws(IOException::class)
|
|
76
|
-
override fun executeProvisionRequest(uuid: UUID, request: ExoMediaDrm.ProvisionRequest): ByteArray {
|
|
77
|
-
Log.d(TAG, "executeProvisionRequest")
|
|
78
|
-
val url = request.defaultUrl + "&signedRequest=" + String(request.data)
|
|
79
|
-
return executePost(dataSourceFactory, url, ByteArray(0), null)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
@Throws(Exception::class)
|
|
83
|
-
override fun executeKeyRequest(uuid: UUID, request: ExoMediaDrm.KeyRequest): ByteArray {
|
|
84
|
-
Log.d(TAG, "executeKeyRequest")
|
|
85
|
-
var url: String? = request.licenseServerUrl
|
|
86
|
-
if (forceDefaultLicenseUrl || url.isNullOrEmpty()) {
|
|
87
|
-
url = defaultLicenseUrl
|
|
88
|
-
}
|
|
89
|
-
val requestProperties: MutableMap<String, String> = HashMap()
|
|
90
|
-
// Add standard request properties for supported schemes.
|
|
91
|
-
val contentType = "text/plain"
|
|
92
|
-
requestProperties["Content-Type"] = contentType
|
|
93
|
-
if (C.PLAYREADY_UUID == uuid) {
|
|
94
|
-
requestProperties["SOAPAction"] = "http://schemas.microsoft.com/DRM/2007/03/protocols/AcquireLicense"
|
|
95
|
-
}
|
|
96
|
-
// Add additional request properties.
|
|
97
|
-
synchronized(keyRequestProperties) { requestProperties.putAll(keyRequestProperties) }
|
|
98
|
-
|
|
99
|
-
//adding data to url
|
|
100
|
-
val challenge = request.data
|
|
101
|
-
val encoded = URLEncoder.encode(Base64.encodeToString(challenge, Base64.NO_WRAP), "UTF-8")
|
|
102
|
-
url = appendQuery(url, "_widevineChallenge=$encoded")
|
|
103
|
-
if (BuildConfig.DEBUG) {
|
|
104
|
-
Log.d(TAG, "Executing post on url $url with content type $contentType")
|
|
105
|
-
}
|
|
106
|
-
return executeGet(url)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
class Factory(
|
|
110
|
-
private val licenseUrl: String?,
|
|
111
|
-
private val forceDefaultUrl: Boolean
|
|
112
|
-
) : SmartMediaDrmCallback.Factory {
|
|
113
|
-
override fun build(drm: DrmConfiguration, dataSourceFactory: HttpDataSource.Factory): SmartMediaDrmCallback =
|
|
114
|
-
HttpMediaDrmCallback(licenseUrl, forceDefaultUrl, dataSourceFactory)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
companion object {
|
|
118
|
-
private const val TAG = "DrmCallback"
|
|
119
|
-
|
|
120
|
-
private fun executeGet(urlString: String): ByteArray {
|
|
121
|
-
var licenserRequest: URL? = null
|
|
122
|
-
try {
|
|
123
|
-
licenserRequest = URL(urlString)
|
|
124
|
-
val yc = licenserRequest.openConnection()
|
|
125
|
-
val input = BufferedReader(InputStreamReader(yc.getInputStream()))
|
|
126
|
-
val builder = StringBuilder()
|
|
127
|
-
var inputLine: String?
|
|
128
|
-
while (input.readLine().also { inputLine = it } != null) {
|
|
129
|
-
builder.append(inputLine)
|
|
130
|
-
}
|
|
131
|
-
input.close()
|
|
132
|
-
val jsonObject = JSONObject(builder.toString())
|
|
133
|
-
val container = jsonObject.getJSONObject("getWidevineLicenseResponse")
|
|
134
|
-
val license = container.getString("license")
|
|
135
|
-
if (BuildConfig.DEBUG) {
|
|
136
|
-
Log.d(TAG, "Finished post: $license")
|
|
137
|
-
}
|
|
138
|
-
return Base64.decode(license, Base64.NO_WRAP)
|
|
139
|
-
} catch (e: MalformedURLException) {
|
|
140
|
-
e.printStackTrace()
|
|
141
|
-
} catch (e: IOException) {
|
|
142
|
-
e.printStackTrace()
|
|
143
|
-
} catch (e: JSONException) {
|
|
144
|
-
e.printStackTrace()
|
|
145
|
-
}
|
|
146
|
-
return byteArrayOf()
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
@Throws(IOException::class)
|
|
150
|
-
private fun executePost(
|
|
151
|
-
dataSourceFactory: HttpDataSource.Factory,
|
|
152
|
-
url: String,
|
|
153
|
-
data: ByteArray,
|
|
154
|
-
requestProperties: Map<String, String>?
|
|
155
|
-
): ByteArray {
|
|
156
|
-
Log.d(TAG, "executePost")
|
|
157
|
-
val dataSource = dataSourceFactory.createDataSource()
|
|
158
|
-
if (requestProperties != null) {
|
|
159
|
-
for ((key, value) in requestProperties) {
|
|
160
|
-
dataSource.setRequestProperty(key, value)
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
val dataSpec = DataSpec(Uri.parse(url), data, 0, 0, C.LENGTH_UNSET.toLong(), null,
|
|
164
|
-
DataSpec.FLAG_ALLOW_GZIP)
|
|
165
|
-
val inputStream = DataSourceInputStream(dataSource, dataSpec)
|
|
166
|
-
return try {
|
|
167
|
-
Util.toByteArray(inputStream)
|
|
168
|
-
} finally {
|
|
169
|
-
Util.closeQuietly(inputStream)
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
fun appendQuery(url: String?, appendQuery: String): String {
|
|
174
|
-
val oldUri = Uri.parse(url)
|
|
175
|
-
var newQuery = oldUri.query
|
|
176
|
-
if (newQuery == null) {
|
|
177
|
-
newQuery = appendQuery
|
|
178
|
-
} else {
|
|
179
|
-
newQuery += "&$appendQuery"
|
|
180
|
-
}
|
|
181
|
-
return oldUri.scheme + "://" + oldUri.authority + oldUri.path + "?" + newQuery
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|