-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvcat_testvector_datamodels.py
More file actions
170 lines (145 loc) · 5.73 KB
/
vcat_testvector_datamodels.py
File metadata and controls
170 lines (145 loc) · 5.73 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# vcat-test-vectors
#
# SPDX-FileCopyrightText: Copyright (C) 2020-2025 VCAT authors and RoncaTech
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of vcat-test-vectors.
#
# vcat-test-vectors is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# vcat-test-vectors is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with vcat-test-vectors. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
#
# For proprietary/commercial use cases, a written GPL-3.0 waiver or
# a separate commercial license is required from RoncaTech LLC.
#
# All VCAT artwork is owned exclusively by RoncaTech LLC. Use of VCAT logos
# and artwork is permitted for the purpose of discussing, documenting,
# or promoting VCAT itself. Any other use requires prior written permission
# from RoncaTech LLC.
#
# Contact: [email protected]
from dataclasses import dataclass, field
from typing import List, Optional
import uuid
from datetime import datetime
@dataclass
class VcatTestVectorHeader:
name: str
description: str
created_by: str
uuid: str = field(default_factory=lambda: str(uuid.uuid4())) # Automatically generate UUID
created_at: str = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
def to_dict(self) -> dict:
"""Converts the VcatTestVectorHeader instance to a dictionary."""
return {
"name": self.name,
"uuid": self.uuid,
"description": self.description,
"created_at": self.created_at,
"created_by": self.created_by
}
@dataclass
class VcatTestVectorAsset:
name: str
url: str
checksum: str
length_bytes: str
def to_dict(self) -> dict:
"""Converts the VcatTestVectorAsset instance to a dictionary."""
return {
"name": self.name,
"url": self.url,
"checksum": self.checksum,
"length_bytes": self.length_bytes
}
@dataclass
class VcatTestVectorVideoAsset(VcatTestVectorAsset):
video_mime_type: str
duration_ms: Optional[int]
resolution_x_y: str
frame_rate: str
def to_dict(self) -> dict:
"""Converts the VcatTestVectorVideoAsset instance to a dictionary."""
asset_dict = super().to_dict()
asset_dict.update({
"video_mime_type": self.video_mime_type,
"duration_ms": self.duration_ms,
"resolution_x_y": self.resolution_x_y,
"frame_rate": self.frame_rate
})
return asset_dict
@dataclass
class VcatTestVectorVideoManifest:
vcat_testvector_header: VcatTestVectorHeader
media_asset: VcatTestVectorVideoAsset
def to_dict(self) -> dict:
"""Converts the VcatTestVectorVideoManifest instance to a dictionary."""
return {
"vcat_testvector_header": self.vcat_testvector_header.to_dict(),
"media_asset": self.media_asset.to_dict()
}
# VcatTestVectorPlaylistAsset that extends VcatTestVectorAsset
@dataclass
class VcatTestVectorPlaylistAsset(VcatTestVectorAsset):
uuid: str
description: str # Now a required field with no default value
def to_dict(self) -> dict:
"""Converts the VcatTestVectorPlaylistAsset instance to a dictionary."""
asset_dict = super().to_dict() # Call the parent's to_dict method
asset_dict.update({
"uuid": self.uuid,
"description": self.description,
})
return asset_dict
@dataclass
class VcatTestVectorPlaylistManifest:
vcat_testvector_header: VcatTestVectorHeader
media_assets: List[VcatTestVectorPlaylistAsset] # List of VcatTestVectorPlaylistAsset objects
def to_dict(self) -> dict:
"""Converts the VcatTestVectorPlaylistManifest instance to a dictionary."""
return {
"vcat_testvector_header": self.vcat_testvector_header.to_dict(),
"media_assets": [asset.to_dict() for asset in self.media_assets]
}
@dataclass
class VcatTestVectorPlaylistCatalog:
vcat_testvector_header: VcatTestVectorHeader
playlists: List[VcatTestVectorPlaylistAsset] # List of VcatTestVectorPlaylistAsset objects
def to_dict(self) -> dict:
"""Converts the VcatTestVectorPlaylistManifest instance to a dictionary."""
return {
"vcat_testvector_header": self.vcat_testvector_header.to_dict(),
"playlists": [asset.to_dict() for asset in self.playlists]
}
# VcatTestVectorCatalogAsset that extends VcatTestVectorAsset
@dataclass
class VcatTestVectorCatalogAsset(VcatTestVectorAsset):
uuid: str
description: str # Now a required field with no default value
def to_dict(self) -> dict:
"""Converts the VcatTestVectorPlaylistAsset instance to a dictionary."""
asset_dict = super().to_dict() # Call the parent's to_dict method
asset_dict.update({
"uuid": self.uuid,
"description": self.description,
})
return asset_dict
@dataclass
class VcatTestVectorCatalogIndex:
vcat_testvector_header: VcatTestVectorHeader
catalogs: List[VcatTestVectorCatalogAsset] # List of VcatTestVectorPlaylistAsset objects
def to_dict(self) -> dict:
"""Converts the VcatTestVectorCatalogIndex instance to a dictionary."""
return {
"vcat_testvector_header": self.vcat_testvector_header.to_dict(),
"catalogs": [asset.to_dict() for asset in self.catalogs]
}