@pbvision/partner-sdk 0.1.17 → 0.1.18
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/README.md +5 -2
- package/package.json +1 -1
- package/src/index.js +34 -5
package/README.md
CHANGED
|
@@ -316,12 +316,15 @@ person recording can't change either. Ask for 4K with `resolution: '4k'` or
|
|
|
316
316
|
60 FPS with `fps: 60`; with `mayChangeResolution: true` or `mayChangeFPS: true`
|
|
317
317
|
the person recording may choose lower settings. Phones step down to what they
|
|
318
318
|
support, and recorders don't need a PB Vision subscription. 4K requires your
|
|
319
|
-
partner account to have 4K enabled
|
|
319
|
+
partner account to have 4K enabled, since PB Vision doesn't analyze video above
|
|
320
|
+
1080p without it. `getMyPartnerAccountInfo()` says whether yours does, and
|
|
321
|
+
without it `makeRecordingLink()` refuses `resolution: '4k'`.
|
|
320
322
|
|
|
321
323
|
```javascript
|
|
324
|
+
const { is4K } = await pbv.getMyPartnerAccountInfo();
|
|
322
325
|
const { url } = await pbv.makeRecordingLink({
|
|
323
326
|
fid,
|
|
324
|
-
resolution: '4k',
|
|
327
|
+
resolution: is4K ? '4k' : '1080p', // '1080p' (default) or '4k'
|
|
325
328
|
fps: 60, // 30 (default) or 60
|
|
326
329
|
mayChangeResolution: true, // default false
|
|
327
330
|
mayChangeFPS: false // default false
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -68,6 +68,26 @@ export class PBVision {
|
|
|
68
68
|
this.isDev = config === ENVIRONMENTS.test
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* @typedef {Object} PartnerAccountInfo
|
|
73
|
+
* @property {boolean} is4K whether your partner account may upload video
|
|
74
|
+
* above 1080p. Without 4K, PB Vision does not analyze such a video.
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Tells you what your partner account may do, e.g. whether to offer 4K.
|
|
79
|
+
*
|
|
80
|
+
* @returns {PartnerAccountInfo}
|
|
81
|
+
*/
|
|
82
|
+
async getMyPartnerAccountInfo () {
|
|
83
|
+
const resp = await this.__callAPI('about', {})
|
|
84
|
+
const { is4K } = JSON.parse(resp)
|
|
85
|
+
if (is4K) {
|
|
86
|
+
this.__is4K = true
|
|
87
|
+
}
|
|
88
|
+
return { is4K }
|
|
89
|
+
}
|
|
90
|
+
|
|
71
91
|
/**
|
|
72
92
|
* Tells PB Vision to make an HTTP POST request your URL after each of your
|
|
73
93
|
* videos is done processing.
|
|
@@ -274,9 +294,10 @@ export class PBVision {
|
|
|
274
294
|
* By default the app records at 1080p and 30 FPS, and the person recording
|
|
275
295
|
* can't change either. A phone that can't record what the link asks for
|
|
276
296
|
* steps down to the best quality it supports. The link's settings apply
|
|
277
|
-
* regardless of the recorder's own PB Vision subscription
|
|
278
|
-
*
|
|
279
|
-
*
|
|
297
|
+
* regardless of the recorder's own PB Vision subscription. 4K requires your
|
|
298
|
+
* partner account to have 4K enabled (see getMyPartnerAccountInfo()), so
|
|
299
|
+
* without it this refuses a 4K link rather than make a video PB Vision
|
|
300
|
+
* won't analyze.
|
|
280
301
|
*
|
|
281
302
|
* Each link is for one recording: only the first upload to its video
|
|
282
303
|
* counts, so make a new link for each game. If several people may ask for
|
|
@@ -293,8 +314,9 @@ export class PBVision {
|
|
|
293
314
|
* @param {RecordingLinkOptions} [options]
|
|
294
315
|
* @returns {RecordingLink}
|
|
295
316
|
* @throws {Error} if gameStartEpoch is given, a camera setting is invalid,
|
|
296
|
-
*
|
|
297
|
-
*
|
|
317
|
+
* 4K is asked for and your partner account doesn't have 4K, or PB Vision
|
|
318
|
+
* doesn't make the video (e.g. because the account paying for it can't
|
|
319
|
+
* pay for it)
|
|
298
320
|
*/
|
|
299
321
|
async makeRecordingLink ({
|
|
300
322
|
resolution = '1080p', fps = 30, mayChangeResolution = false, mayChangeFPS = false,
|
|
@@ -308,6 +330,13 @@ export class PBVision {
|
|
|
308
330
|
assert(typeof mayChangeResolution === 'boolean', 'mayChangeResolution must be a boolean')
|
|
309
331
|
assert(typeof mayChangeFPS === 'boolean', 'mayChangeFPS must be a boolean')
|
|
310
332
|
|
|
333
|
+
// checked before making the video, so a 4K link that PB Vision wouldn't
|
|
334
|
+
// analyze never gets one; only a yes is remembered, so an account that
|
|
335
|
+
// gets 4K later can ask for it without a new PBVision
|
|
336
|
+
if (resolution === '4k' && !this.__is4K && !(await this.getMyPartnerAccountInfo()).is4K) {
|
|
337
|
+
throw new Error('your partner account does not have 4K enabled, so PB Vision would not analyze a 4K recording; ask for 1080p, or ask PB Vision to enable 4K')
|
|
338
|
+
}
|
|
339
|
+
|
|
311
340
|
const { vid, uid, hasCredits } = await this.makeVideoId({
|
|
312
341
|
fileExt: 'mp4', userEmails, name, desc, facility, court, fid, playersForTagging, nonce })
|
|
313
342
|
if (hasCredits === false) {
|