-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[media] Support configurable audio write ahead (#1882)
Enables the web app to configure the audio write ahead duration through an extension, and enables the extension for linux-x64x11. Se the original PR #121 for details. b/267678497 b/307832651 --------- Co-authored-by: xiaomings <xiaomings@google.com>
- Loading branch information
Showing
31 changed files
with
708 additions
and
35 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
7 changes: 5 additions & 2 deletions
7
cobalt/demos/content/media-element-demo/src/components/source_buffer_info.ts
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
interface Props { | ||
sourceBuffer: SourceBuffer; | ||
name: string; | ||
maxWriteHeadDistance: number; | ||
} | ||
|
||
/** A component that displays the source buffer info. */ | ||
export function SourceBufferInfo({sourceBuffer, name}: Props) { | ||
return `<div>${name} buffered: ${sourceBuffer.buffered.end(0)} sec</div>`; | ||
export function SourceBufferInfo({sourceBuffer, name, maxWriteHeadDistance}: Props) { | ||
return `<div>${name} buffered: ${sourceBuffer.buffered.end(0)} sec` + | ||
`, writeHead: ${sourceBuffer.writeHead} sec` + | ||
`, maxWriteHeadDistance: ${maxWriteHeadDistance} sec</div>`; | ||
} |
6 changes: 5 additions & 1 deletion
6
cobalt/demos/content/media-element-demo/src/components/video_info.ts
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
interface Props { | ||
duration: number; | ||
currentTime: number; | ||
audioConnectors: string; | ||
} | ||
|
||
/** A component that displays video info. */ | ||
export function VideoInfo({duration, currentTime}: Props) { | ||
export function VideoInfo({duration, currentTime, audioConnectors}: Props) { | ||
if (audioConnectors) { | ||
return `<div>${currentTime} / ${duration} / audioConnectors: ${audioConnectors}</div>`; | ||
} | ||
return `<div>${currentTime} / ${duration}</div>`; | ||
} |
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
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
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
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,75 @@ | ||
// Copyright 2023 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 COBALT_EXTENSION_AUDIO_WRITE_AHEAD_H_ | ||
#define COBALT_EXTENSION_AUDIO_WRITE_AHEAD_H_ | ||
|
||
#include "starboard/media.h" | ||
#include "starboard/player.h" | ||
#include "starboard/time.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define kCobaltExtensionConfigurableAudioWriteAheadName \ | ||
"dev.cobalt.extension.ConfigurableAudioWriteAhead" | ||
|
||
#define kCobaltExtensionPlayerWriteDurationLocal (kSbTimeSecond / 2) | ||
#define kCobaltExtensionPlayerWriteDurationRemote (kSbTimeSecond * 10) | ||
|
||
typedef enum CobaltExtensionMediaAudioConnector { | ||
kCobaltExtensionMediaAudioConnectorUnknown, | ||
|
||
kCobaltExtensionMediaAudioConnectorAnalog, | ||
kCobaltExtensionMediaAudioConnectorBluetooth, | ||
kCobaltExtensionMediaAudioConnectorBuiltIn, | ||
kCobaltExtensionMediaAudioConnectorHdmi, | ||
kCobaltExtensionMediaAudioConnectorRemoteWired, | ||
kCobaltExtensionMediaAudioConnectorRemoteWireless, | ||
kCobaltExtensionMediaAudioConnectorRemoteOther, | ||
kCobaltExtensionMediaAudioConnectorSpdif, | ||
kCobaltExtensionMediaAudioConnectorUsb, | ||
} CobaltExtensionMediaAudioConnector; | ||
|
||
typedef struct CobaltExtensionMediaAudioConfiguration { | ||
int index; | ||
CobaltExtensionMediaAudioConnector connector; | ||
SbTime latency; | ||
SbMediaAudioCodingType coding_type; | ||
int number_of_channels; | ||
} CobaltExtensionMediaAudioConfiguration; | ||
|
||
typedef struct CobaltExtensionConfigurableAudioWriteAheadApi { | ||
// Name should be the string | ||
// |kCobaltExtensionConfigurableAudioWriteAheadName|. This helps to validate | ||
// that the extension API is correct. | ||
const char* name; | ||
|
||
// This specifies the version of the API that is implemented. | ||
uint32_t version; | ||
|
||
// The fields below this point were added in version 1 or later. | ||
|
||
bool (*PlayerGetAudioConfiguration)( | ||
SbPlayer player, int index, | ||
CobaltExtensionMediaAudioConfiguration* out_audio_configuration); | ||
|
||
} CobaltExtensionConfigurableAudioWriteAheadApi; | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif | ||
|
||
#endif // COBALT_EXTENSION_AUDIO_WRITE_AHEAD_H_ |
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
Oops, something went wrong.