Skip to content

Commit e70ea93

Browse files
committed
Consistency between native/plugin implementation, better handling of null manifest
1 parent 231db18 commit e70ea93

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

samples/c2pa/c2pa-player.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ var C2PAMenu = function() {
5454
c2paItem: function (itemName, c2paStatus, compromisedRegions = []) {
5555

5656
const verificationStatus = c2paStatus.verified;
57-
const manifest = c2paStatus.details.video.manifest;
57+
let manifest = null;
58+
try {
59+
manifest = c2paStatus.details.video.manifest;
60+
} catch (error) {
61+
console.error('[C2PA] Manifest does not exist');
62+
}
5863

5964
if (manifest != null && manifest['manifestStore'] != null) {
6065
if (itemName == "SIG_ISSUER") {
@@ -292,7 +297,7 @@ var C2PAPlayer = function (videoJsPlayer, videoHtml, isMonolithic = false) {
292297

293298
//Convert verification status to string since this value is saved in the segment dataset
294299
//If variable is not a boolean, we set the status to unknown
295-
let verificationStatus = 'unkown';
300+
let verificationStatus = 'unknown';
296301
if (typeof verificationStatusBool === 'boolean')
297302
verificationStatus = verificationStatusBool.toString();
298303

samples/c2pa/plugin-dash/c2pa-dash-plugin.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ async function c2pa_init(player, onPlaybackTimeUpdated) {
2424
let tag = chunk.streamId + '-' + chunk.mediaInfo.type + '-' + chunk.representationId;
2525

2626
if (chunk.segmentType == 'InitializationSegment') {
27+
//TODO: mimetype should change based on actual type from chunk
2728
initFragment[tag] = new Blob([chunk.bytes], {type: 'video/mp4'});
28-
console.log('Got init seg for '+ tag)
29+
console.log('[C2PA] Got init seg for ' + tag)
2930
} else if (!(tag in initFragment)) {
3031
console.error('initFragment is null for ' + tag);
3132
} else {
@@ -39,7 +40,7 @@ async function c2pa_init(player, onPlaybackTimeUpdated) {
3940
'manifest': manifest
4041
});
4142

42-
console.log('C2pa manifest extracted for ' + tag);
43+
console.log('[C2PA] Manifest extracted for ' + tag + ': ', manifest);
4344
}
4445

4546
return Promise.resolve(chunk);
@@ -76,8 +77,11 @@ async function c2pa_init(player, onPlaybackTimeUpdated) {
7677

7778
let segs = tree[tag].search([e.time, e.time + 0.01]);
7879

79-
if (segs.length > 1)
80+
if (segs.length > 1) {
8081
detail['error'] = 'Retrieved unexpected number of segments: ' + segs.length + ' for media type ' + type;
82+
isUndefined = true;
83+
continue;
84+
}
8185

8286
if (segs.length == 0) {
8387
detail['error'] = 'No segment found for media type ' + type;

src/streaming/C2pa.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ function C2paController(_eventBus) {
4949

5050
// TODO(hawang) change the mimetype the actual one from the response
5151
// TODO(hawang) use InitCache created for each media type in BufferController instead of saving here
52-
if (e.request.type == 'InitializationSegment')
52+
if (e.request.type == 'InitializationSegment') {
53+
//TODO: mimetype should change based on actual type from chunk
5354
initFragment[tag] = new Blob([e.response], {type: 'video/mp4'});
55+
console.log('[C2PA] Got init seg for ' + tag)
56+
}
5457
else if (!(tag in initFragment)) {
55-
console.error('initFragment is null');
58+
console.error('initFragment is null ' + tag);
5659
} else {
5760
c2pa.then(result => {
5861
result.readFragment(initFragment[tag], e.response)
@@ -64,7 +67,7 @@ function C2paController(_eventBus) {
6467
'type': e.request.segmentType,
6568
'manifest': manifest
6669
});
67-
console.log('C2pa manifest extracted for ' + tag + ': ' + manifest);
70+
console.log('[C2PA] Manifest extracted for ' + tag + ': ', manifest);
6871
}).catch(error => console.error('Failed to extract C2pa manifest: ' + error));
6972
});
7073
}
@@ -97,8 +100,11 @@ function C2paController(_eventBus) {
97100

98101
let segs = tree[tag].search([time, time + 0.01]);
99102

100-
if (segs.length > 1)
103+
if (segs.length > 1) {
101104
detail['error'] = 'Retrieved unexpected number of segments: ' + segs.length + ' for media type ' + type;
105+
isUndefined = true;
106+
continue;
107+
}
102108

103109
if (segs.length == 0) {
104110
detail['error'] = 'No segment found for media type ' + type;

0 commit comments

Comments
 (0)