forked from shaka-project/eme_logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prototypes.js
717 lines (637 loc) · 21.4 KB
/
prototypes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
/**
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @fileoverview Defines prototypes for EME method calls and events.
*/
var emeLogger = {};
/**
* @typedef {{
* title: string,
* timestamp: string,
* names: !Array.<string>,
* values: !Array.<*>
* }}
*/
emeLogger.LogItemData;
/**
* Method call prototype.
* @param {string} title The title used to describe this call.
* @param {!Object} target The element this method was called on.
* @param {Object} result The object returned from this call, if any.
* @constructor
*/
emeLogger.EmeMethodCall = function(title, target, result) {
this.timestamp = emeLogger.timeToString_(new Date().getTime());
this.title = title;
this.target = target;
this.returned = result;
};
/**
* EME Event prototype.
* @param {string} title The title used to describe this event.
* @param {Event} e An EME event.
* @param {Object} target The element this event was fired on.
* @constructor
*/
emeLogger.EmeEvent = function(title, e, target) {
this.title = title;
this.event = e;
this.timestamp = emeLogger.timeToString_(e.timeStamp);
this.target = target;
};
/**
* Constructs a time string in the format hh:mm:ss:mil.
* @param {number} time The time in milliseconds.
* @return {string} A human readable string respresenting the time.
* @private
*/
emeLogger.timeToString_ = function(time) {
var date = new Date(time);
var hours = emeLogger.padNumber_(date.getHours().toString());
var minutes = emeLogger.padNumber_(date.getMinutes().toString());
var seconds = emeLogger.padNumber_(date.getSeconds().toString());
var milli = emeLogger.padNumber_(date.getMilliseconds().toString());
return hours.concat(':', minutes, ':', seconds, ':', milli);
};
/**
* Pads a number with leading zeros.
* @param {string} num A string representing the number.
* @param {number} length The desired length of the string.
* @return {string} A string padded with zeros to the desired length.
* @private
*/
emeLogger.padNumber_ = function(num, length) {
while (num.length < length) {
num = '0' + num;
}
return num;
};
/**
* Gets a formatted message from the EME Formatters.
* @param {string} name The name of the Event or Call being logged.
* @param {Object} data The EME data to be parsed from the Event/Call.
* @param {string} keySystem The keySystem used for this Event/Call.
* @return {string|undefined} The formatted message.
*/
emeLogger.getFormattedMessage = function(name, data, keySystem) {
if (!document.emeFormatters) {
return;
}
var formattedMessage = '';
for (var i = 0; i < document.emeFormatters.length; i++) {
var formatter = document.emeFormatters[i];
var formatFunctionName = 'format' + name;
if (!formatter[formatFunctionName]) {
continue;
}
// Only use formatters that support the |keySystem|, if specified.
// (|keySystem| is not specified for some events.)
if (keySystem && !formatter.isKeySystemSupported(keySystem)) {
continue;
}
try {
formattedMessage += formatter[formatFunctionName](data);
if (i > 0) {
formattedMessage += '\n';
}
} catch (e) {
console.warn('Formatter', formatter, 'failed:', e);
}
}
if (formattedMessage == '') {
return;
}
return formattedMessage;
};
/**
* PromiseResult contains the information resulting from a
* resolved/rejected Promise.
* @param {string} title The title used to describe this Promise.
* @param {string} status Status of the Promise.
* @param {Object} result The result of the Promise.
* @param {Array} args The arguments that were passed.
* @constructor
*/
emeLogger.PromiseResult = function(title, status, result, args) {
this.timestamp = emeLogger.timeToString_(new Date().getTime());
this.title = title;
this.status = status;
this.args = args;
if (result) {
this.result = result.constructor.name == 'MediaKeySystemAccess' ?
new emeLogger.MediaKeySystemAccess(result) : result;
}
};
/**
* Provides a simple representation of obj to be used for messaging. The
* names and values returned in emeLogger.LogItemData will only reflect the
* object's direct properties.
* @param {Object} obj An object to format into emeLogger.LogItemData.
* @return {!emeLogger.LogItemData} A formatted object.
*/
emeLogger.getMessagePassableObject = function(obj) {
var names = [];
var values = [];
for (var prop in obj) {
if (prop == 'title' || prop == 'timestamp') continue;
// We only care about direct properties of the object. Calling
// hasOwnProperty will stop from checking down the object's prototype chain.
if (obj.hasOwnProperty(prop)) {
if (typeof(obj[prop]) == 'function') continue;
names.push(prop);
if (typeof(obj[prop]) == 'object' && obj[prop] != null) {
// Give ArrayBuffers a view so they can be properly logged.
var value = obj[prop].constructor.name == 'ArrayBuffer' ?
new Uint8Array(obj[prop]) : obj[prop];
values.push(emeLogger.getMessagePassableObject(value));
} else {
values.push(obj[prop]);
}
}
}
var data = {
title: obj.title || obj.constructor.name,
names: names,
values: values
};
if (obj.timestamp) {
data.timestamp = obj.timestamp;
}
return data;
};
/** Typed Object Prototypes **/
/**
* MediaKeySystemAccess object prototype. Calls getConfiguration to include
* the objects configuration.
* @param {!MediaKeySystemAccess} mksa The MediaKeySystemAccess object
* @constructor
*/
emeLogger.MediaKeySystemAccess = function(mksa) {
this.title = 'MediaKeySystemAccess';
this.keySystem = mksa.keySystem;
this.configuration = mksa.listenersAdded_ ?
mksa.originalGetConfiguration() : mksa.getConfiguration();
};
/**
* MediaKeySession object prototype.
* @param {!MediaKeySession} mks The MediaKeySession object.
* @constructor
*/
emeLogger.MediaKeySession = function(mks) {
this.title = 'MediaKeySession';
this.sessionId = mks.sessionId;
this.expiration = mks.expiration;
this.keyStatuses = [];
mks.keyStatuses.forEach(function(status, keyId) {
this.keyStatuses.push({'keyId' : new Uint8Array(keyId), 'status' : status});
}.bind(this));
};
/**
* HTMLMediaElement object prototype.
* @param {!HTMLMediaElement} element The HTMLMediaElement.
* @constructor
*/
emeLogger.HTMLMediaElement = function(element) {
this.title = element.constructor.name;
this.id = element.id;
if (element.classList) {
this.classes = element.classList.toString();
}
};
/** Typed Event Prototypes **/
/**
* Message event prototype.
* @param {Event} e
* @extends {emeLogger.EmeEvent}
* @constructor
*/
emeLogger.MessageEvent = function(e) {
var mks = new emeLogger.MediaKeySession(e.target);
emeLogger.EmeEvent.apply(this, ['MessageEvent', e, mks]);
// If a formatter extension is available, message will be formatted.
this.message = new Uint8Array(e.message);
this.messageType = e.messageType;
this.formattedMessage = emeLogger.getFormattedMessage(
'message', e.message, e.keySystem);
};
emeLogger.MessageEvent.prototype = Object.create(emeLogger.EmeEvent.prototype);
/** @constructor */
emeLogger.MessageEvent.prototype.constructor = emeLogger.MessageEvent;
/**
* KeyStatusesChange event prototype.
* @param {Event} e
* @extends {emeLogger.EmeEvent}
* @constructor
*/
emeLogger.KeyStatusesChangeEvent = function(e) {
var mks = new emeLogger.MediaKeySession(e.target);
emeLogger.EmeEvent.apply(this, ['KeyStatusesChangeEvent', e, mks]);
};
emeLogger.KeyStatusesChangeEvent.prototype =
Object.create(emeLogger.EmeEvent.prototype);
/** @constructor */
emeLogger.KeyStatusesChangeEvent.prototype.constructor =
emeLogger.KeyStatusesChangeEvent;
/**
* NeedKey event prototype.
* @param {Event} e
* @extends {emeLogger.EmeEvent}
* @constructor
*/
emeLogger.NeedKeyEvent = function(e) {
var element = new emeLogger.HTMLMediaElement(e.target);
emeLogger.EmeEvent.apply(this, ['NeedKeyEvent', e, element]);
};
emeLogger.NeedKeyEvent.prototype = Object.create(emeLogger.EmeEvent.prototype);
/** @constructor */
emeLogger.NeedKeyEvent.prototype.constructor = emeLogger.NeedKeyEvent;
/**
* KeyMessage event prototype.
* @param {Event} e
* @extends {emeLogger.EmeEvent}
* @constructor
*/
emeLogger.KeyMessageEvent = function(e) {
var element = new emeLogger.HTMLMediaElement(e.target);
emeLogger.EmeEvent.apply(this, ['KeyMessageEvent', e, element]);
// If a formatter extension is available, message will be formatted.
this.formattedMessage = emeLogger.getFormattedMessage(
'webkitkeymessage', e.message, e.keySystem);
};
emeLogger.KeyMessageEvent.prototype =
Object.create(emeLogger.EmeEvent.prototype);
/** @constructor */
emeLogger.KeyMessageEvent.prototype.constructor = emeLogger.KeyMessageEvent;
/**
* KeyAdded event prototype.
* @param {Event} e
* @extends {emeLogger.EmeEvent}
* @constructor
*/
emeLogger.KeyAddedEvent = function(e) {
var element = new emeLogger.HTMLMediaElement(e.target);
emeLogger.EmeEvent.apply(this, ['KeyAddedEvent', e, element]);
};
emeLogger.KeyAddedEvent.prototype = Object.create(emeLogger.EmeEvent.prototype);
/** @constructor */
emeLogger.KeyAddedEvent.prototype.constructor = emeLogger.KeyAddedEvent;
/**
* KeyError event prototype.
* @param {Event} e
* @extends {emeLogger.EmeEvent}
* @constructor
*/
emeLogger.KeyErrorEvent = function(e) {
var element = new emeLogger.HTMLMediaElement(e.target);
emeLogger.EmeEvent.apply(this, ['KeyErrorEvent', e, element]);
};
emeLogger.KeyErrorEvent.prototype =
Object.create(emeLogger.EmeEvent.prototype);
/** @constructor */
emeLogger.KeyErrorEvent.prototype.constructor = emeLogger.KeyErrorEvent;
/**
* Encrypted event prototype.
* @param {Event} e
* @extends {emeLogger.EmeEvent}
* @constructor
*/
emeLogger.EncryptedEvent = function(e) {
var element = new emeLogger.HTMLMediaElement(e.target);
emeLogger.EmeEvent.apply(this, ['EncryptedEvent', e, element]);
this.initData = new Uint8Array(e.initData);
this.initDataType = e.initDataType;
};
emeLogger.EncryptedEvent.prototype =
Object.create(emeLogger.EmeEvent.prototype);
/** @constructor */
emeLogger.EncryptedEvent.prototype.constructor = emeLogger.EncryptedEvent;
/**
* Play event prototype.
* @param {Event} e
* @extends {emeLogger.EmeEvent}
* @constructor
*/
emeLogger.PlayEvent = function(e) {
var element = new emeLogger.HTMLMediaElement(e.target);
emeLogger.EmeEvent.apply(this, ['PlayEvent', e, element]);
};
emeLogger.PlayEvent.prototype = Object.create(emeLogger.EmeEvent.prototype);
/** @constructor */
emeLogger.PlayEvent.prototype.constructor = emeLogger.PlayEvent;
/**
* Error event prototype.
* @param {Event} e
* @extends {emeLogger.EmeEvent}
* @constructor
*/
emeLogger.ErrorEvent = function(e) {
var element = new emeLogger.HTMLMediaElement(e.target);
emeLogger.EmeEvent.apply(this, ['ErrorEvent', e, element]);
this.errorType = e.target.error;
this.errorCode = this.errorType.code;
};
emeLogger.ErrorEvent.prototype = Object.create(emeLogger.EmeEvent.prototype);
/** @constructor */
emeLogger.ErrorEvent.prototype.constructor = emeLogger.ErrorEvent;
/** Typed Method Call Prototypes **/
/**
* RequestMediaKeySystemAccess call prototype.
* @param {Array} args
* @param {Navigator} target
* @param {Promise} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.RequestMediaKeySystemAccessCall = function(args, target, result) {
emeLogger.EmeMethodCall.apply(
this, ['RequestMediaKeySystemAccessCall', target, result]);
this.keySystem = args[0];
this.supportedConfigurations = args[1];
};
emeLogger.RequestMediaKeySystemAccessCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.RequestMediaKeySystemAccessCall.prototype.constructor =
emeLogger.RequestMediaKeySystemAccessCall;
/**
* GetConfiguration call prototype.
* @param {Array} args
* @param {MediaKeySystemAccess} target
* @param {MediaKeySystemConfiguration} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.GetConfigurationCall = function(args, target, result) {
var mksa = new emeLogger.MediaKeySystemAccess(target);
emeLogger.EmeMethodCall.apply(this, ['GetConfigurationCall', mksa, result]);
};
emeLogger.GetConfigurationCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.GetConfigurationCall.prototype.constructor =
emeLogger.GetConfigurationCall;
/**
* CreateMediaKeys call prototype.
* @param {Array} args
* @param {MediaKeySystemAccess} target
* @param {Promise} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.CreateMediaKeysCall = function(args, target, result) {
var mksa = new emeLogger.MediaKeySystemAccess(target);
emeLogger.EmeMethodCall.apply(this, ['CreateMediaKeysCall', mksa, result]);
};
emeLogger.CreateMediaKeysCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.CreateMediaKeysCall.prototype.constructor =
emeLogger.CreateMediaKeysCall;
/**
* CreateSession call prototype.
* @param {Array} args
* @param {MediaKeys} target
* @param {MediaKeySession} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.CreateSessionCall = function(args, target, result) {
var mks = new emeLogger.MediaKeySession(result);
emeLogger.EmeMethodCall.apply(this, ['CreateSessionCall', target, mks]);
// Temporary is the default session type if none is provided.
this.sessionType = args[0] ? args[0] : 'temporary';
};
emeLogger.CreateSessionCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.CreateSessionCall.prototype.constructor = emeLogger.CreateSessionCall;
/**
* SetServerCertificate call prototype.
* @param {Array} args
* @param {MediaKeys} target
* @param {Promise} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.SetServerCertificateCall = function(args, target, result) {
emeLogger.EmeMethodCall.apply(
this, ['SetServerCertificateCall', target, result]);
this.serverCertificate = new Uint8Array(args[0]);
};
emeLogger.SetServerCertificateCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.SetServerCertificateCall.prototype.constructor =
emeLogger.SetServerCertificateCall;
/**
* GenerateRequest call prototype.
* @param {Array} args
* @param {MediaKeySession} target
* @param {Promise} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.GenerateRequestCall = function(args, target, result) {
var mks = new emeLogger.MediaKeySession(target);
emeLogger.EmeMethodCall.apply(this, ['GenerateRequestCall', mks, result]);
this.initDataType = args[0];
this.initData = new Uint8Array(args[1]);
};
emeLogger.GenerateRequestCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.GenerateRequestCall.prototype.constructor =
emeLogger.GenerateRequestCall;
/**
* Play call prototype.
* @param {Array} args
* @param {HTMLMediaElement} target
* @param {Object} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.PlayCall = function(args, target, result) {
var element = new emeLogger.HTMLMediaElement(target);
emeLogger.EmeMethodCall.apply(this, ['PlayCall', element, result]);
};
emeLogger.PlayCall.prototype = Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.PlayCall.prototype.constructor = emeLogger.PlayCall;
/**
* Load call prototype.
* @param {Array} args
* @param {MediaKeySession} target
* @param {Promise} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.LoadCall = function(args, target, result) {
var mks = new emeLogger.MediaKeySession(target);
emeLogger.EmeMethodCall.apply(this, ['LoadCall', mks, result]);
this.sessionId = args[0];
};
emeLogger.LoadCall.prototype = Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.LoadCall.prototype.constructor = emeLogger.LoadCall;
/**
* Update call prototype.
* @param {Array} args
* @param {MediaKeySession} target
* @param {Promise} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.UpdateCall = function(args, target, result) {
var mks = new emeLogger.MediaKeySession(target);
emeLogger.EmeMethodCall.apply(this, ['UpdateCall', mks, result]);
this.response = new Uint8Array(args[0]);
// If a formatter extension is available, response will be formatted.
this.formattedMessage = emeLogger.getFormattedMessage(
'UpdateCall', this.response, target.keySystem_);
};
emeLogger.UpdateCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.UpdateCall.prototype.constructor = emeLogger.UpdateCall;
/**
* Close call prototype.
* @param {Array} args
* @param {MediaKeySession} target
* @param {Promise} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.CloseCall = function(args, target, result) {
var mks = new emeLogger.MediaKeySession(target);
emeLogger.EmeMethodCall.apply(this, ['CloseCall', mks, result]);
};
emeLogger.CloseCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.CloseCall.prototype.constructor = emeLogger.CloseCall;
/**
* Remove call prototype.
* @param {Array} args
* @param {MediaKeySession} target
* @param {Promise} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.RemoveCall = function(args, target, result) {
var mks = new emeLogger.MediaKeySession(target);
emeLogger.EmeMethodCall.apply(this, ['RemoveCall', mks, result]);
};
emeLogger.RemoveCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.RemoveCall.prototype.constructor = emeLogger.RemoveCall;
/**
* CanPlayType call prototype.
* @param {Array} args
* @param {HTMLMediaElement} target
* @param {DOMString} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.CanPlayTypeCall = function(args, target, result) {
var element = new emeLogger.HTMLMediaElement(target);
emeLogger.EmeMethodCall.apply(this, ['CanPlayTypeCall', element, result]);
this.type = args[0];
this.keySystem = args[1];
};
emeLogger.CanPlayTypeCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.CanPlayTypeCall.prototype.constructor = emeLogger.CanPlayTypeCall;
/**
* GenerateKeyRequest call prototype.
* @param {Array} args
* @param {HTMLMediaElement} target
* @param {Object} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.GenerateKeyRequestCall = function(args, target, result) {
var element = new emeLogger.HTMLMediaElement(target);
emeLogger.EmeMethodCall.apply(
this, ['GenerateKeyRequestCall', element, result]);
this.keySystem = args[0];
this.initData = args[1];
};
emeLogger.GenerateKeyRequestCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.GenerateKeyRequestCall.prototype.constructor =
emeLogger.GenerateKeyRequestCall;
/**
* AddKey call prototype.
* @param {Array} args
* @param {HTMLMediaElement} target
* @param {Object} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.AddKeyCall = function(args, target, result) {
var element = new emeLogger.HTMLMediaElement(target);
emeLogger.EmeMethodCall.apply(this, ['AddKeyCall', element, result]);
this.keySystem = args[0];
this.key = args[1];
this.initData = args[2];
this.sessionId = args[3];
// If a formatter extension is available, key will be formatted.
this.formattedMessage = emeLogger.getFormattedMessage(
'AddKeyCall', this.key, this.keySystem);
};
emeLogger.AddKeyCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.AddKeyCall.prototype.constructor = emeLogger.AddKeyCall;
/**
* CancelKeyRequest call prototype.
* @param {Array} args
* @param {HTMLMediaElement} target
* @param {Object} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.CancelKeyRequestCall = function(args, target, result) {
var element = new emeLogger.HTMLMediaElement(target);
emeLogger.EmeMethodCall.apply(
this, ['CancelKeyRequestCall', element, result]);
this.keySystem = args[0];
this.sessionId = args[1];
};
emeLogger.CancelKeyRequestCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.CancelKeyRequestCall.prototype.constructor =
emeLogger.CancelKeyRequestCall;
/**
* SetMediaKeys call prototype.
* @param {Array} args
* @param {HTMLMediaElement} target
* @param {Promise} result
* @extends {emeLogger.EmeMethodCall}
* @constructor
*/
emeLogger.SetMediaKeysCall = function(args, target, result) {
var element = new emeLogger.HTMLMediaElement(target);
emeLogger.EmeMethodCall.apply(this, ['SetMediaKeysCall', element, result]);
this.mediaKeys = args[0];
};
emeLogger.SetMediaKeysCall.prototype =
Object.create(emeLogger.EmeMethodCall.prototype);
/** @constructor */
emeLogger.SetMediaKeysCall.prototype.constructor = emeLogger.SetMediaKeysCall;