    import { VideoSourceType, Zondy } from './index'
    import { defaultValue, getVideoType } from '../util'
    import VideoRegistrationParam from './VideoRegistrationParam'

    /**
     * 视频源数据
     * @typedef VideoSource
     * @type {Object}
     * @property {String} videoUrl 视频源地址
     * @property {VideoSourceType} protocol 视频传输协议
     */

    /**
     * 视频元数据
     * @class VideoMetaData
     * @classdesc 视频调绘标定配准元数据
     * @param {Object} options 构造参数
     * @param {String} [options.videoID = null] 视频ID
     * @param {String} [options.videoName = null] 视频名称
     * @param {VideoSource|HTMLVideoElement|Object} [options.videoSource = null] 视频源<brl>
     * 支持url链接，支持HTMLVideoElemen，支持videojs对象
     * @param {VideoRegistrationParam} options.videoRegistrationParam 视频配准参数
     * @param {String} [options.version = null] 元数据的版本
     */
    class VideoMetaData {
      constructor(options) {
        options = defaultValue(options, {})

        this._videoID = defaultValue(options.videoID, null)
        this._videoName = defaultValue(options.videoName, null)

        this._videoSource = defaultValue(options.videoSource, null)
        if (this._videoSource) {
          if (this._videoSource.videoUrl) {
            this._videoUrl = defaultValue(this._videoSource.videoUrl, null)
            this._videoProtocol = defaultValue(this._videoSource.protocol, null)
            switch (this._videoProtocol) {
              case VideoSourceType.mp4:
                this._videoProtocol = VideoSourceType.mp4
                break
              case VideoSourceType.hls:
                this._videoProtocol = VideoSourceType.hls
                break
              case VideoSourceType.rtmp:
                this._videoProtocol = VideoSourceType.rtmp
                break
            }
            // 若数据中没有指定视频类型，则通过url链接识别视频传输协议
            if (!this._videoProtocol) {
              this._videoProtocol = getVideoType(this._videoSource.videoUrl)
            }
          }
        } else {
          this._videoProtocol = null
          this._videoUrl = null
        }
        const videoRegistrationParam = options.videoRegistrationParam
          ? options.videoRegistrationParam
          : options
        this._videoRegistrationParam = new VideoRegistrationParam(
          videoRegistrationParam
        )
        this._videoMetaDataVersion = defaultValue(options.version, null)
      }

      /**
       * 视频ID
       * @type {String}
       */
      get videoID() {
        return this._videoID
      }

      /**
       * 视频名称
       * @type {String}
       */
      get videoName() {
        return this._videoName
      }

      /**
       * 视频源数据
       * @type {{protocol:VideoSourceType, videoUrl:String}}
       */
      get videoSource() {
        return this._videoSource
      }

      /**
       * 视频配准参数
       * @type {VideoRegistrationParam}
       */
      get videoRegistrationParam() {
        return this._videoRegistrationParam
      }
    }
    Zondy.VideoMetaData = VideoMetaData
    export default VideoMetaData