Add common video types to MediaTypeNames#124390
Conversation
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
|
@dotnet-policy-service agree |
|
Hey @Cryptoc1, thanks for the contribution. But this is a public API and all of those must go through the API review process: https://github.com/dotnet/runtime/blob/main/docs/project/api-review-process.md |
There was a problem hiding this comment.
Pull request overview
This PR adds a new Video nested static class to MediaTypeNames containing constants for common video MIME types. The additions complement existing media type categories (Application, Font, Image, Multipart, Text) and enable developers to use standardized video MIME type constants for file upload validation and content type handling in APIs.
Changes:
- Added
MediaTypeNames.Videoclass with 12 video format constants including container formats (MP4, WebM, Matroska, Ogg, QuickTime), codecs (AV1, H.264, H.265, VP8, VP9), and legacy formats (MPEG, MPV)
| /// <summary>Specifies the kind of video data in an email message attachment.</summary> | ||
| public static class Video | ||
| { | ||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in AV1 format.</summary> | ||
| public const string Av1 = "video/av1"; | ||
|
|
||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in H.264 format.</summary> | ||
| public const string H264 = "video/h264"; | ||
|
|
||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in H.265 format.</summary> | ||
| public const string H265 = "video/h265"; | ||
|
|
||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in Matroska format.</summary> | ||
| public const string Matroska = "video/x-matroska"; | ||
|
|
||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in MP4 format.</summary> | ||
| public const string Mp4 = "video/mp4"; | ||
|
|
||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in MPEG format.</summary> | ||
| public const string Mpeg = "video/mpeg"; | ||
|
|
||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in MPV format.</summary> | ||
| public const string Mpv = "video/mpv"; | ||
|
|
||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in Ogg format.</summary> | ||
| public const string Ogg = "video/ogg"; | ||
|
|
||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in Quicktime format.</summary> | ||
| public const string Quicktime = "video/quicktime"; | ||
|
|
||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in VP8 format.</summary> | ||
| public const string Vp8 = "video/vp8"; | ||
|
|
||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in VP9 format.</summary> | ||
| public const string Vp9 = "video/vp9"; | ||
|
|
||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in WebM format.</summary> | ||
| public const string Webm = "video/webm"; | ||
| } |
There was a problem hiding this comment.
The new Video class needs to be added to the reference assembly at src/libraries/System.Net.Mail/ref/System.Net.Mail.cs. The reference assembly defines the public API surface and must be kept in sync with the implementation. Without this update, the new Video class will not be part of the public API contract.
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in Ogg format.</summary> | ||
| public const string Ogg = "video/ogg"; | ||
|
|
||
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in Quicktime format.</summary> |
There was a problem hiding this comment.
The format name should be "QuickTime" with a capital T, as it is the proper capitalization of Apple's QuickTime media framework. This follows the pattern of using proper capitalization for product/format names as seen elsewhere in the file (e.g., "Portable Document Format", "Rich Text Format").
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in Quicktime format.</summary> | |
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in QuickTime format.</summary> |
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in MPV format.</summary> | ||
| public const string Mpv = "video/mpv"; |
There was a problem hiding this comment.
The MIME type "video/mpv" is not registered in the IANA media types registry. This may be a non-standard or incorrect MIME type. Please verify if this is the intended MIME type or if it should be a different type (e.g., "video/mpeg" for MPEG video files). Standard video MIME types are registered with IANA and should be used to ensure compatibility.
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is in MPV format.</summary> | |
| public const string Mpv = "video/mpv"; | |
| /// <summary>Specifies that the <see cref="MediaTypeNames.Video"/> data is MPEG video commonly stored in files with an .mpv extension.</summary> | |
| public const string Mpv = Mpeg; |
|
@ManickaP Apologies for not properly following the process; I have created an API Proposal here: |
This PR adds common video types to the
System.Net.Mime.MediaTypeNamesstatic class.I (and I assume others) use the
MediaTypeNamesconstants for validating file uploads in APIs, it would be useful to have video types included in the runtime.Additionally, many of the types added are already supported by the
MediaTypeMap.