code: function getScreenConstraints(callback, captureSourceIdWithAudio) {
      sourceId = '';
      var firefoxScreenConstraints = {
          mozMediaSource: 'window',
          mediaSource: 'window'
      };
      if (isFirefox)
          return callback(null, firefoxScreenConstraints);
      // this statement defines getUserMedia constraints
      // that will be used to capture content of screen
      var screen_constraints = {
          mandatory: {
              chromeMediaSource: chromeMediaSource,
              maxWidth: screen.width > 1920 ? screen.width : 1920,
              maxHeight: screen.height > 1080 ? screen.height : 1080
          },
          optional: []
      };
      // this statement verifies chrome extension availability
      // if installed and available then it will invoke extension API
      // otherwise it will fallback to command-line based screen capturing API
      if (chromeMediaSource == 'desktop' && !sourceId) {
          if (captureSourceIdWithAudio) {
              getSourceIdWithAudio(function (sourceId, canRequestAudioTrack) {
                  screen_constraints.mandatory.chromeMediaSourceId = sourceId;
  
                  if (canRequestAudioTrack) {
                      screen_constraints.canRequestAudioTrack = true;
                  }
                  callback(sourceId == 'PermissionDeniedError' ? sourceId : null, screen_constraints);
              });
          }
          else {
              getSourceId(function (sourceId) {
                  screen_constraints.mandatory.chromeMediaSourceId = sourceId;
                  callback(sourceId == 'PermissionDeniedError' ? sourceId : null, screen_constraints);
              });
          }
          return;
      }
  
      // this statement sets gets 'sourceId" and sets "chromeMediaSourceId" 
      if (chromeMediaSource == 'desktop') {
          screen_constraints.mandatory.chromeMediaSourceId = sourceId;
      }
  
      // now invoking native getUserMedia API
      callback(null, screen_constraints);
  }
docs: this function explains how to use above methods/objects