Blame view

node_modules/videojs-contrib-hls/es5/util/codecs.js 1.11 KB
2a09d1a4   liuqimichale   添加宜春 天水 宣化
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
  
  /**
   * @file - codecs.js - Handles tasks regarding codec strings such as translating them to
   * codec strings, or translating codec strings into objects that can be examined.
   */
  
  /**
   * Parses a codec string to retrieve the number of codecs specified,
   * the video codec and object type indicator, and the audio profile.
   */
  
  'use strict';
  
  Object.defineProperty(exports, '__esModule', {
    value: true
  });
  var parseCodecs = function parseCodecs() {
    var codecs = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];
  
    var result = {
      codecCount: 0
    };
    var parsed = undefined;
  
    result.codecCount = codecs.split(',').length;
    result.codecCount = result.codecCount || 2;
  
    // parse the video codec
    parsed = /(^|\s|,)+(avc1)([^ ,]*)/i.exec(codecs);
    if (parsed) {
      result.videoCodec = parsed[2];
      result.videoObjectTypeIndicator = parsed[3];
    }
  
    // parse the last field of the audio codec
    result.audioProfile = /(^|\s|,)+mp4a.[0-9A-Fa-f]+\.([0-9A-Fa-f]+)/i.exec(codecs);
    result.audioProfile = result.audioProfile && result.audioProfile[2];
  
    return result;
  };
  exports.parseCodecs = parseCodecs;