Repository navigation
Add MPEG-2 and H.263+ codec negotiation #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ReenigneArcher
wants to merge
1
commit into
moonlight-stream:master
Choose a base branch
from
ReenigneArcher:nxdk-decoder-choices
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /** | ||
| * @file VideoFormats.c | ||
| * @brief Negotiate modern and legacy video codecs using shared protocol capabilities. | ||
| */ | ||
| #include "VideoFormats.h" | ||
|
|
||
| #include <string.h> | ||
|
|
||
| int chooseVideoFormat(int supportedVideoFormats, int serverCodecModeSupport, const char* sdpPayload) { | ||
| if (sdpPayload == NULL) { | ||
| return 0; | ||
| } | ||
|
|
||
| if (strstr(sdpPayload, "AV1/90000") != NULL) { | ||
| if ((supportedVideoFormats & VIDEO_FORMAT_AV1_HIGH10_444) && (serverCodecModeSupport & SCM_AV1_HIGH10_444)) { | ||
| return VIDEO_FORMAT_AV1_HIGH10_444; | ||
| } | ||
| if ((supportedVideoFormats & VIDEO_FORMAT_AV1_MAIN10) && (serverCodecModeSupport & SCM_AV1_MAIN10)) { | ||
| return VIDEO_FORMAT_AV1_MAIN10; | ||
| } | ||
| if ((supportedVideoFormats & VIDEO_FORMAT_AV1_HIGH8_444) && (serverCodecModeSupport & SCM_AV1_HIGH8_444)) { | ||
| return VIDEO_FORMAT_AV1_HIGH8_444; | ||
| } | ||
| if ((supportedVideoFormats & VIDEO_FORMAT_AV1_MAIN8) && | ||
| (serverCodecModeSupport == 0 || (serverCodecModeSupport & SCM_AV1_MAIN8))) { | ||
| return VIDEO_FORMAT_AV1_MAIN8; | ||
| } | ||
| } | ||
|
|
||
| // GameStream identifies HEVC support using the VPS prefix in this attribute. | ||
| if (strstr(sdpPayload, "sprop-parameter-sets=AAAAAU") != NULL) { | ||
| if ((supportedVideoFormats & VIDEO_FORMAT_H265_REXT10_444) && (serverCodecModeSupport & SCM_HEVC_REXT10_444)) { | ||
| return VIDEO_FORMAT_H265_REXT10_444; | ||
| } | ||
| if ((supportedVideoFormats & VIDEO_FORMAT_H265_MAIN10) && (serverCodecModeSupport & SCM_HEVC_MAIN10)) { | ||
| return VIDEO_FORMAT_H265_MAIN10; | ||
| } | ||
| if ((supportedVideoFormats & VIDEO_FORMAT_H265_REXT8_444) && (serverCodecModeSupport & SCM_HEVC_REXT8_444)) { | ||
| return VIDEO_FORMAT_H265_REXT8_444; | ||
| } | ||
| if ((supportedVideoFormats & VIDEO_FORMAT_H265) && | ||
| (serverCodecModeSupport == 0 || (serverCodecModeSupport & SCM_HEVC))) { | ||
| return VIDEO_FORMAT_H265; | ||
| } | ||
| } | ||
|
|
||
| if ((supportedVideoFormats & VIDEO_FORMAT_H264_HIGH8_444) && (serverCodecModeSupport & SCM_H264_HIGH8_444)) { | ||
| return VIDEO_FORMAT_H264_HIGH8_444; | ||
| } | ||
| if ((supportedVideoFormats & VIDEO_FORMAT_H264) && | ||
| (serverCodecModeSupport == 0 || (serverCodecModeSupport & SCM_H264))) { | ||
| return VIDEO_FORMAT_H264; | ||
| } | ||
|
|
||
| // Legacy codecs are opt-in Sunshine protocol extensions, available to any client. | ||
| if ((supportedVideoFormats & VIDEO_FORMAT_MPEG2) && (serverCodecModeSupport & SCM_MPEG2) && | ||
| (strstr(sdpPayload, "MPV/90000") != NULL || strstr(sdpPayload, "MPEG2/90000") != NULL || | ||
| strstr(sdpPayload, "MPEG-2/90000") != NULL)) { | ||
| return VIDEO_FORMAT_MPEG2; | ||
| } | ||
| if ((supportedVideoFormats & VIDEO_FORMAT_H263P) && (serverCodecModeSupport & SCM_H263P) && | ||
| (strstr(sdpPayload, "H263-1998/90000") != NULL || strstr(sdpPayload, "H263-2000/90000") != NULL)) { | ||
| return VIDEO_FORMAT_H263P; | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| int getVideoBitStreamFormat(int videoFormat) { | ||
| switch (videoFormat) { | ||
| case VIDEO_FORMAT_H264: | ||
| case VIDEO_FORMAT_H264_HIGH8_444: | ||
| return 0; | ||
| case VIDEO_FORMAT_H265: | ||
| case VIDEO_FORMAT_H265_MAIN10: | ||
| case VIDEO_FORMAT_H265_REXT8_444: | ||
| case VIDEO_FORMAT_H265_REXT10_444: | ||
| return 1; | ||
| case VIDEO_FORMAT_AV1_MAIN8: | ||
| case VIDEO_FORMAT_AV1_MAIN10: | ||
| case VIDEO_FORMAT_AV1_HIGH8_444: | ||
| case VIDEO_FORMAT_AV1_HIGH10_444: | ||
| return 2; | ||
| case VIDEO_FORMAT_MPEG2: | ||
| return 3; | ||
| case VIDEO_FORMAT_H263P: | ||
| return 4; | ||
| default: | ||
| return -1; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /** | ||
| * @file VideoFormats.h | ||
| * @brief Internal codec negotiation and GameStream wire-format helpers. | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include "Limelight.h" | ||
|
|
||
| /** | ||
| * @brief Choose a mutually supported codec without giving legacy codecs precedence. | ||
| * | ||
| * @param supportedVideoFormats Client decoder capability mask. | ||
| * @param serverCodecModeSupport Host codec capability mask; zero permits baseline profiles on older hosts. | ||
| * @param sdpPayload RTSP DESCRIBE payload advertising the host codecs. | ||
| * @return One VIDEO_FORMAT value, or zero when no supported codec is available. | ||
| */ | ||
| int chooseVideoFormat(int supportedVideoFormats, int serverCodecModeSupport, const char* sdpPayload); | ||
|
|
||
| /** | ||
| * @brief Map a negotiated codec to its GameStream bitStreamFormat value. | ||
| * | ||
| * @param videoFormat One negotiated VIDEO_FORMAT value. | ||
| * @return Wire value from zero through four, or -1 for an invalid format. | ||
| */ | ||
| int getVideoBitStreamFormat(int videoFormat); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.