1
1
import { Action } from "../../internal/Action.js" ;
2
2
import { AdvVideoCodecType , VideoCodecType } from "../../qualifiers/videoCodecType/VideoCodecType.js" ;
3
+ import { IVideoCodecActionModel } from "../../internal/models/ITranscodeActionModel.js" ;
4
+ import { IActionModel } from "../../internal/models/IActionModel.js" ;
5
+ import { VIDEO_CODEC_TO_TRANSFORMATION } from "../../qualifiers/videoCodec.js" ;
3
6
4
7
/**
5
8
* @extends SDK.Action
@@ -8,9 +11,37 @@ import {AdvVideoCodecType, VideoCodecType} from "../../qualifiers/videoCodecType
8
11
* @see Visit {@link Actions.Transcode|Transcode} for an example
9
12
*/
10
13
class VideoCodecAction extends Action {
14
+ protected _actionModel : IVideoCodecActionModel = { actionType : 'videoCodec' } ;
11
15
constructor ( videoCodecTypeQualifier : VideoCodecType | AdvVideoCodecType ) {
12
16
super ( ) ;
17
+ this . _actionModel . videoCodec = { videoCodecName : videoCodecTypeQualifier . getType ( ) } ;
18
+
19
+ if ( videoCodecTypeQualifier instanceof AdvVideoCodecType ) {
20
+ if ( videoCodecTypeQualifier . getProfile ( ) ) {
21
+ this . _actionModel . videoCodec = { profile : videoCodecTypeQualifier . getProfile ( ) , ...this . _actionModel . videoCodec } ;
22
+ }
23
+
24
+ if ( videoCodecTypeQualifier . getLevel ( ) ) {
25
+ this . _actionModel . videoCodec = { level : videoCodecTypeQualifier . getLevel ( ) , ...this . _actionModel . videoCodec } ;
26
+ }
27
+ }
28
+
13
29
this . addQualifier ( videoCodecTypeQualifier ) ;
14
30
}
31
+
32
+ static fromJson ( actionModel : IActionModel ) : VideoCodecAction {
33
+ const { videoCodec} = ( actionModel as IVideoCodecActionModel ) ;
34
+
35
+ // We are using this() to allow inheriting classes to use super.fromJson.apply(this, [actionModel])
36
+ // This allows the inheriting classes to determine the class to be created
37
+ const result = new this ( VIDEO_CODEC_TO_TRANSFORMATION [ videoCodec . videoCodecName ] ) ;
38
+ //@ts -ignore
39
+ videoCodec . profile && new this ( VIDEO_CODEC_TO_TRANSFORMATION [ videoCodec . videoCodecName ] . profile ( videoCodec . profile ) ) ;
40
+
41
+ //@ts -ignore
42
+ videoCodec . level && new this ( VIDEO_CODEC_TO_TRANSFORMATION [ videoCodec . videoCodecName ] . level ( videoCodec . level ) ) ;
43
+
44
+ return result ;
45
+ }
15
46
}
16
47
export { VideoCodecAction } ;
0 commit comments