-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[xb1] Implement closed captioning system settings
- Loading branch information
1 parent
5d0bf09
commit 95f3874
Showing
5 changed files
with
289 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,53 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "starboard/xb1/shared/accessibility_extension.h" | ||
#include "starboard/extension/accessibility.h" | ||
|
||
namespace starboard { | ||
namespace xb1 { | ||
namespace shared { | ||
|
||
namespace accessibility { | ||
|
||
// The rest of the accessibility extension is not implemented on XB1 | ||
bool GetTextToSpeechSettings(SbAccessibilityTextToSpeechSettings* out_setting) { | ||
return false; | ||
} | ||
|
||
bool GetDisplaySettings(SbAccessibilityDisplaySettings* out_setting) { | ||
return false; | ||
} | ||
|
||
bool SetCaptionsEnabled(bool enabled) { | ||
return false; | ||
} | ||
|
||
} // namespace accessibility | ||
|
||
const StarboardExtensionAccessibilityApi kAccessibilityAPI = { | ||
kStarboardExtensionAccessibilityName, | ||
1, | ||
&accessibility::GetTextToSpeechSettings, | ||
&accessibility::GetDisplaySettings, | ||
&accessibility::GetCaptionSettings, | ||
&accessibility::SetCaptionsEnabled}; | ||
|
||
const void* GetAccessibilityApi() { | ||
return &kAccessibilityAPI; | ||
} | ||
|
||
} // namespace shared | ||
} // namespace xb1 | ||
} // namespace starboard |
This file contains 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,36 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef STARBOARD_XB1_SHARED_ACCESSIBILITY_EXTENSION_H_ | ||
#define STARBOARD_XB1_SHARED_ACCESSIBILITY_EXTENSION_H_ | ||
|
||
#include "starboard/extension/accessibility.h" | ||
|
||
namespace starboard { | ||
namespace xb1 { | ||
namespace shared { | ||
|
||
namespace accessibility { | ||
bool GetTextToSpeechSettings(SbAccessibilityTextToSpeechSettings* out_setting); | ||
bool GetDisplaySettings(SbAccessibilityDisplaySettings* out_setting); | ||
bool GetCaptionSettings(SbAccessibilityCaptionSettings* caption_settings); | ||
bool SetCaptionsEnabled(bool enabled); | ||
} // namespace accessibility | ||
|
||
const void* GetAccessibilityApi(); | ||
} // namespace shared | ||
} // namespace xb1 | ||
} // namespace starboard | ||
|
||
#endif // STARBOARD_XB1_SHARED_ACCESSIBILITY_EXTENSION_H_ |
194 changes: 194 additions & 0 deletions
194
starboard/xb1/shared/accessibility_get_caption_settings.cc
This file contains 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,194 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <Windows.h> | ||
|
||
#include "starboard/common/memory.h" | ||
#include "starboard/shared/starboard/accessibility_internal.h" | ||
#include "starboard/xb1/shared/accessibility_extension.h" | ||
|
||
namespace starboard { | ||
namespace xb1 { | ||
namespace shared { | ||
namespace accessibility { | ||
|
||
namespace { | ||
|
||
using namespace Windows::Media::ClosedCaptioning; | ||
|
||
SbAccessibilityCaptionCharacterEdgeStyle | ||
ClosedCaptionEdgeEffectToSbAccessibilityCaptionCharacterEdgeStyle( | ||
ClosedCaptionEdgeEffect edgeStyle) { | ||
switch (edgeStyle) { | ||
case ClosedCaptionEdgeEffect::Default: | ||
return kSbAccessibilityCaptionCharacterEdgeStyleNone; | ||
case ClosedCaptionEdgeEffect::None: | ||
return kSbAccessibilityCaptionCharacterEdgeStyleNone; | ||
case ClosedCaptionEdgeEffect::Raised: | ||
return kSbAccessibilityCaptionCharacterEdgeStyleRaised; | ||
case ClosedCaptionEdgeEffect::Depressed: | ||
return kSbAccessibilityCaptionCharacterEdgeStyleDepressed; | ||
case ClosedCaptionEdgeEffect::Uniform: | ||
return kSbAccessibilityCaptionCharacterEdgeStyleUniform; | ||
case ClosedCaptionEdgeEffect::DropShadow: | ||
return kSbAccessibilityCaptionCharacterEdgeStyleDropShadow; | ||
} | ||
} | ||
|
||
SbAccessibilityCaptionColor ClosedCaptionColorToSbAccessibilityCaptionColor( | ||
ClosedCaptionColor color) { | ||
switch (color) { | ||
case ClosedCaptionColor::Default: | ||
return kSbAccessibilityCaptionColorWhite; | ||
case ClosedCaptionColor::White: | ||
return kSbAccessibilityCaptionColorWhite; | ||
case ClosedCaptionColor::Black: | ||
return kSbAccessibilityCaptionColorBlack; | ||
case ClosedCaptionColor::Red: | ||
return kSbAccessibilityCaptionColorRed; | ||
case ClosedCaptionColor::Green: | ||
return kSbAccessibilityCaptionColorGreen; | ||
case ClosedCaptionColor::Blue: | ||
return kSbAccessibilityCaptionColorBlue; | ||
case ClosedCaptionColor::Yellow: | ||
return kSbAccessibilityCaptionColorYellow; | ||
case ClosedCaptionColor::Magenta: | ||
return kSbAccessibilityCaptionColorMagenta; | ||
case ClosedCaptionColor::Cyan: | ||
return kSbAccessibilityCaptionColorCyan; | ||
} | ||
} | ||
|
||
SbAccessibilityCaptionFontFamily | ||
ClosedCaptionStyleToSbAccessibilityCaptionFontFamily(ClosedCaptionStyle style) { | ||
switch (style) { | ||
case ClosedCaptionStyle::Default: | ||
return kSbAccessibilityCaptionFontFamilyCasual; | ||
case ClosedCaptionStyle::MonospacedWithSerifs: | ||
return kSbAccessibilityCaptionFontFamilyMonospaceSerif; | ||
case ClosedCaptionStyle::ProportionalWithSerifs: | ||
return kSbAccessibilityCaptionFontFamilyProportionalSerif; | ||
case ClosedCaptionStyle::MonospacedWithoutSerifs: | ||
return kSbAccessibilityCaptionFontFamilyMonospaceSansSerif; | ||
case ClosedCaptionStyle::ProportionalWithoutSerifs: | ||
return kSbAccessibilityCaptionFontFamilyProportionalSansSerif; | ||
case ClosedCaptionStyle::Casual: | ||
return kSbAccessibilityCaptionFontFamilyCasual; | ||
case ClosedCaptionStyle::Cursive: | ||
return kSbAccessibilityCaptionFontFamilyCursive; | ||
case ClosedCaptionStyle::SmallCapitals: | ||
return kSbAccessibilityCaptionFontFamilySmallCapitals; | ||
} | ||
} | ||
|
||
SbAccessibilityCaptionFontSizePercentage | ||
ClosedCaptionSizeToSbAccessibilityCaptionFontSizePercentage( | ||
ClosedCaptionSize opacity) { | ||
switch (opacity) { | ||
case ClosedCaptionSize::Default: | ||
return kSbAccessibilityCaptionFontSizePercentage100; | ||
case ClosedCaptionSize::FiftyPercent: | ||
return kSbAccessibilityCaptionFontSizePercentage50; | ||
case ClosedCaptionSize::OneHundredPercent: | ||
return kSbAccessibilityCaptionFontSizePercentage100; | ||
case ClosedCaptionSize::OneHundredFiftyPercent: | ||
return kSbAccessibilityCaptionFontSizePercentage150; | ||
case ClosedCaptionSize::TwoHundredPercent: | ||
return kSbAccessibilityCaptionFontSizePercentage200; | ||
} | ||
} | ||
|
||
SbAccessibilityCaptionOpacityPercentage | ||
ClosedCaptionOpacityToSbAccessibilityCaptionOpacityPercentage( | ||
ClosedCaptionOpacity opacity) { | ||
switch (opacity) { | ||
case ClosedCaptionOpacity::Default: | ||
return kSbAccessibilityCaptionOpacityPercentage100; | ||
case ClosedCaptionOpacity::OneHundredPercent: | ||
return kSbAccessibilityCaptionOpacityPercentage100; | ||
case ClosedCaptionOpacity::SeventyFivePercent: | ||
return kSbAccessibilityCaptionOpacityPercentage75; | ||
case ClosedCaptionOpacity::TwentyFivePercent: | ||
return kSbAccessibilityCaptionOpacityPercentage25; | ||
case ClosedCaptionOpacity::ZeroPercent: | ||
return kSbAccessibilityCaptionOpacityPercentage0; | ||
} | ||
} | ||
|
||
} // namespace. | ||
|
||
bool GetCaptionSettings(SbAccessibilityCaptionSettings* caption_settings) { | ||
if (!caption_settings || | ||
!starboard::common::MemoryIsZero( | ||
caption_settings, sizeof(SbAccessibilityCaptionSettings))) { | ||
return false; | ||
} | ||
|
||
caption_settings->background_color = | ||
ClosedCaptionColorToSbAccessibilityCaptionColor( | ||
ClosedCaptionProperties::BackgroundColor); | ||
caption_settings->background_color_state = kSbAccessibilityCaptionStateSet; | ||
|
||
caption_settings->background_opacity = | ||
ClosedCaptionOpacityToSbAccessibilityCaptionOpacityPercentage( | ||
ClosedCaptionProperties::BackgroundOpacity); | ||
caption_settings->background_opacity_state = kSbAccessibilityCaptionStateSet; | ||
|
||
caption_settings->character_edge_style = | ||
ClosedCaptionEdgeEffectToSbAccessibilityCaptionCharacterEdgeStyle( | ||
ClosedCaptionProperties::FontEffect); | ||
caption_settings->character_edge_style_state = | ||
kSbAccessibilityCaptionStateSet; | ||
|
||
caption_settings->font_color = | ||
ClosedCaptionColorToSbAccessibilityCaptionColor( | ||
ClosedCaptionProperties::FontColor); | ||
caption_settings->font_color_state = kSbAccessibilityCaptionStateSet; | ||
|
||
caption_settings->font_family = | ||
ClosedCaptionStyleToSbAccessibilityCaptionFontFamily( | ||
ClosedCaptionProperties::FontStyle); | ||
caption_settings->font_family_state = kSbAccessibilityCaptionStateSet; | ||
|
||
caption_settings->font_opacity = | ||
ClosedCaptionOpacityToSbAccessibilityCaptionOpacityPercentage( | ||
ClosedCaptionProperties::FontOpacity); | ||
caption_settings->font_opacity_state = kSbAccessibilityCaptionStateSet; | ||
|
||
caption_settings->font_size = | ||
ClosedCaptionSizeToSbAccessibilityCaptionFontSizePercentage( | ||
ClosedCaptionProperties::FontSize); | ||
caption_settings->font_size_state = kSbAccessibilityCaptionStateSet; | ||
|
||
caption_settings->window_color = | ||
ClosedCaptionColorToSbAccessibilityCaptionColor( | ||
ClosedCaptionProperties::RegionColor); | ||
caption_settings->window_color_state = kSbAccessibilityCaptionStateSet; | ||
|
||
caption_settings->window_opacity = | ||
ClosedCaptionOpacityToSbAccessibilityCaptionOpacityPercentage( | ||
ClosedCaptionProperties::RegionOpacity); | ||
caption_settings->window_opacity_state = kSbAccessibilityCaptionStateSet; | ||
|
||
caption_settings->is_enabled = true; // TODO: check it | ||
caption_settings->supports_is_enabled = true; | ||
caption_settings->supports_set_enabled = false; | ||
caption_settings->supports_override = true; | ||
return true; | ||
} | ||
|
||
} // namespace accessibility | ||
} // namespace shared | ||
} // namespace xb1 | ||
} // namespace starboard |
This file contains 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