Skip to content

Commit

Permalink
feat: 新增 stringEnum 文件
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaohappy committed Jun 20, 2024
1 parent b60da09 commit c104f41
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 35 deletions.
2 changes: 1 addition & 1 deletion dist/866.avplayer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/969.avplayer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/979.avplayer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/avplayer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/473.avplayer-legacy.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/531.avplayer-legacy.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/866.avplayer-legacy.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/avplayer-legacy.js

Large diffs are not rendered by default.

29 changes: 2 additions & 27 deletions src/avplayer/AVPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { unrefAVFrame } from 'avutil/util/avframe'
import { unrefAVPacket } from 'avutil/util/avpacket'
import AudioRenderPipeline from 'avpipeline/AudioRenderPipeline'
import VideoRenderPipeline from 'avpipeline/VideoRenderPipeline'
import { AVFormat, AVSeekFlags } from 'avformat/avformat'
import { AVSeekFlags } from 'avformat/avformat'
import * as urlUtils from 'common/util/url'
import * as cheapConfig from 'cheap/config'
import { AVSampleFormat } from 'avutil/audiosamplefmt'
Expand Down Expand Up @@ -77,6 +77,7 @@ import JitterBufferController from './JitterBufferController'
import { JitterBuffer } from 'avpipeline/struct/jitter'
import getAudioCodec from 'avcodec/function/getAudioCodec'
import { IOFlags } from 'common/io/flags'
import { Ext2Format, Ext2IOLoader } from 'avutil/stringEnum'

const ObjectFitMap = {
[RenderMode.FILL]: 'cover',
Expand Down Expand Up @@ -114,32 +115,6 @@ class AVPlayerGlobalData {
jitterBuffer: JitterBuffer
}

const Ext2Format: Record<string, AVFormat> = {
'flv': AVFormat.FLV,
'mp4': AVFormat.MOV,
'mov': AVFormat.MOV,
'ts': AVFormat.MPEGTS,
'ivf': AVFormat.IVF,
'opus': AVFormat.OGGS,
'ogg': AVFormat.OGGS,
'm3u8': AVFormat.MPEGTS,
'm3u': AVFormat.MPEGTS,
'mpd': AVFormat.MOV,
'mp3': AVFormat.MP3,
'mkv': AVFormat.MATROSKA,
'mka': AVFormat.MATROSKA,
'webm': AVFormat.WEBM,
'aac': AVFormat.AAC,
'flac': AVFormat.FLAC,
'wav': AVFormat.WAV
}

const Ext2IOLoader: Record<string, IOType> = {
'm3u8': IOType.HLS,
'm3u': IOType.HLS,
'mpd': IOType.DASH
}

export const enum AVPlayerStatus {
STOPPED,
LOADING,
Expand Down
88 changes: 88 additions & 0 deletions src/avutil/stringEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { AVFormat } from 'avformat/avformat'
import { AVCodecID } from './codec'
import { AVPixelFormat } from './pixfmt'
import { IOType } from 'avpipeline/IOPipeline'

export const Ext2Format: Record<string, AVFormat> = {
'flv': AVFormat.FLV,
'mp4': AVFormat.MOV,
'mov': AVFormat.MOV,
'ts': AVFormat.MPEGTS,
'ivf': AVFormat.IVF,
'opus': AVFormat.OGGS,
'ogg': AVFormat.OGGS,
'm3u8': AVFormat.MPEGTS,
'm3u': AVFormat.MPEGTS,
'mpd': AVFormat.MOV,
'mp3': AVFormat.MP3,
'mkv': AVFormat.MATROSKA,
'mka': AVFormat.MATROSKA,
'webm': AVFormat.WEBM,
'aac': AVFormat.AAC,
'flac': AVFormat.FLAC,
'wav': AVFormat.WAV
}

export const Ext2IOLoader: Record<string, IOType> = {
'm3u8': IOType.HLS,
'm3u': IOType.HLS,
'mpd': IOType.DASH
}

export const VideoCodecString2CodecId = {
'copy': AVCodecID.AV_CODEC_ID_NONE,
'h264': AVCodecID.AV_CODEC_ID_H264,
'avc': AVCodecID.AV_CODEC_ID_H264,
'hevc': AVCodecID.AV_CODEC_ID_HEVC,
'h265': AVCodecID.AV_CODEC_ID_HEVC,
'vvc': AVCodecID.AV_CODEC_ID_VVC,
'h266': AVCodecID.AV_CODEC_ID_VVC,
'av1': AVCodecID.AV_CODEC_ID_AV1,
'vp9': AVCodecID.AV_CODEC_ID_VP9,
'vp8': AVCodecID.AV_CODEC_ID_VP8,
'mpeg4': AVCodecID.AV_CODEC_ID_MPEG4
}

export const AudioCodecString2CodecId = {
'copy': AVCodecID.AV_CODEC_ID_NONE,
'aac': AVCodecID.AV_CODEC_ID_AAC,
'mp3': AVCodecID.AV_CODEC_ID_MP3,
'opus': AVCodecID.AV_CODEC_ID_OPUS,
'flac': AVCodecID.AV_CODEC_ID_FLAC,
'speex': AVCodecID.AV_CODEC_ID_SPEEX,
'vorbis': AVCodecID.AV_CODEC_ID_VORBIS
}

export const PixfmtString2AVPixelFormat = {
'yuv420p': AVPixelFormat.AV_PIX_FMT_YUV420P,
'yuv422p': AVPixelFormat.AV_PIX_FMT_YUV422P,
'yuv444p': AVPixelFormat.AV_PIX_FMT_YUV444P,

'yuv420p10le': AVPixelFormat.AV_PIX_FMT_YUV420P10LE,
'yuv422p10le': AVPixelFormat.AV_PIX_FMT_YUV422P10LE,
'yuv444p10le': AVPixelFormat.AV_PIX_FMT_YUV444P10LE,

'yuv420p10be': AVPixelFormat.AV_PIX_FMT_YUV420P10BE,
'yuv422p10be': AVPixelFormat.AV_PIX_FMT_YUV422P10BE,
'yuv444p10be': AVPixelFormat.AV_PIX_FMT_YUV444P10BE,
}

export const Format2AVFormat: Record<string, AVFormat> = {
'flv': AVFormat.FLV,
'mp4': AVFormat.MOV,
'mov': AVFormat.MOV,
'ts': AVFormat.MPEGTS,
'ivf': AVFormat.IVF,
'opus': AVFormat.OGGS,
'ogg': AVFormat.OGGS,
'm3u8': AVFormat.MPEGTS,
'm3u': AVFormat.MPEGTS,
'mpd': AVFormat.MOV,
'mp3': AVFormat.MP3,
'mkv': AVFormat.MATROSKA,
'mka': AVFormat.MATROSKA,
'webm': AVFormat.WEBM,
'aac': AVFormat.AAC,
'flac': AVFormat.FLAC,
'wav': AVFormat.WAV
}

0 comments on commit c104f41

Please sign in to comment.