mirror of
https://github.com/LuanRT/googlevideo.git
synced 2026-07-04 12:47:01 +00:00
chore: update protos
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
@@ -8,11 +9,13 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>YouTube.js Example</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form>
|
||||
<input type="text" name="id" placeholder="Video ID or URL" />
|
||||
<input type="text" name="id" placeholder="Enter Video ID or URL" />
|
||||
<input type="submit" value="Play" />
|
||||
</form>
|
||||
<div id="error-message" class="error-message" style="display: none;"></div>
|
||||
<div class="loader" id="loader"></div>
|
||||
<div id="video-container">
|
||||
<div class="shaka-container" id="shaka-container" data-shaka-player-container>
|
||||
@@ -24,8 +27,9 @@
|
||||
<div id="description"></div>
|
||||
</div>
|
||||
<footer>
|
||||
<p>Powered by <a href="https://github.com/LuanRT/YouTube.js">YouTube.js</a></p>
|
||||
<p>Powered by <a href="https://github.com/LuanRT/YouTube.js" target="_blank">YouTube.js</a></p>
|
||||
</footer>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -3,7 +3,7 @@ import cliProgress from 'cli-progress';
|
||||
import type { WriteStream } from 'node:fs';
|
||||
import { createWriteStream, unlink } from 'node:fs';
|
||||
import { Innertube, UniversalCache } from 'youtubei.js';
|
||||
import GoogleVideo, { type Format, MediaType } from '../../dist/src/index.js';
|
||||
import GoogleVideo, { type Format, Protos } from '../../dist/src/index.js';
|
||||
|
||||
const progressBars = new cliProgress.MultiBar({
|
||||
stopOnComplete: true,
|
||||
@@ -120,8 +120,8 @@ serverAbrStream.on('error', (error) => {
|
||||
await serverAbrStream.init({
|
||||
audioFormats: [ selectedAudioFormat ],
|
||||
videoFormats: [ selectedVideoFormat ],
|
||||
mediaInfo: {
|
||||
mediaType: MediaType.MEDIA_TYPE_DEFAULT,
|
||||
clientAbrState: {
|
||||
mediaType: Protos.MediaType.MEDIA_TYPE_DEFAULT,
|
||||
startTimeMs: 0
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import cliProgress from 'cli-progress';
|
||||
import type { WriteStream } from 'node:fs';
|
||||
import { createWriteStream } from 'node:fs';
|
||||
import { Innertube, UniversalCache } from 'youtubei.js';
|
||||
import GoogleVideo, { type Format, MediaType } from '../../dist/src/index.js';
|
||||
import GoogleVideo, { type Format, Protos } from '../../dist/src/index.js';
|
||||
|
||||
const progressBars = new cliProgress.MultiBar({
|
||||
stopOnComplete: true,
|
||||
@@ -129,13 +129,13 @@ serverAbrStream.on('error', (error) => {
|
||||
await serverAbrStream.init({
|
||||
audioFormats: [ selectedAudioFormat ],
|
||||
videoFormats: [ selectedVideoFormat ],
|
||||
mediaInfo: {
|
||||
clientAbrState: {
|
||||
/**
|
||||
* MEDIA_TYPE_DEFAULT = 0,
|
||||
* MEDIA_TYPE_AUDIO = 1,
|
||||
* MEDIA_TYPE_VIDEO = 2,
|
||||
*/
|
||||
mediaType: MediaType.MEDIA_TYPE_DEFAULT,
|
||||
mediaType: Protos.MediaType.MEDIA_TYPE_DEFAULT,
|
||||
startTimeMs: 0
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// versions:
|
||||
// protoc-gen-ts_proto v2.2.0
|
||||
// protoc v5.28.0
|
||||
// source: video_streaming/media_info.proto
|
||||
// source: video_streaming/client_abr_state.proto
|
||||
|
||||
/* eslint-disable */
|
||||
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
||||
@@ -10,7 +10,7 @@ import { MediaCapabilities } from "./media_capabilities.js";
|
||||
|
||||
export const protobufPackage = "video_streaming";
|
||||
|
||||
export interface MediaInfo {
|
||||
export interface ClientAbrState {
|
||||
timeSinceLastManualFormatSelectionMs?: number | undefined;
|
||||
lastManualDirection?: number | undefined;
|
||||
quality?: number | undefined;
|
||||
@@ -28,7 +28,7 @@ export interface MediaInfo {
|
||||
| number
|
||||
| undefined;
|
||||
/** optional int32 Gw = 40; */
|
||||
mediaType?: MediaInfo_MediaType | undefined;
|
||||
mediaType?: ClientAbrState_MediaType | undefined;
|
||||
playerState?: number | undefined;
|
||||
rangeCompression?: boolean | undefined;
|
||||
Jda?: number | undefined;
|
||||
@@ -50,7 +50,7 @@ export interface MediaInfo {
|
||||
playbackRate?: number | undefined;
|
||||
}
|
||||
|
||||
export enum MediaInfo_MediaType {
|
||||
export enum ClientAbrState_MediaType {
|
||||
MEDIA_TYPE_DEFAULT = 0,
|
||||
MEDIA_TYPE_AUDIO = 1,
|
||||
MEDIA_TYPE_VIDEO = 2,
|
||||
@@ -58,44 +58,44 @@ export enum MediaInfo_MediaType {
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
|
||||
export function mediaInfo_MediaTypeFromJSON(object: any): MediaInfo_MediaType {
|
||||
export function clientAbrState_MediaTypeFromJSON(object: any): ClientAbrState_MediaType {
|
||||
switch (object) {
|
||||
case 0:
|
||||
case "MEDIA_TYPE_DEFAULT":
|
||||
return MediaInfo_MediaType.MEDIA_TYPE_DEFAULT;
|
||||
return ClientAbrState_MediaType.MEDIA_TYPE_DEFAULT;
|
||||
case 1:
|
||||
case "MEDIA_TYPE_AUDIO":
|
||||
return MediaInfo_MediaType.MEDIA_TYPE_AUDIO;
|
||||
return ClientAbrState_MediaType.MEDIA_TYPE_AUDIO;
|
||||
case 2:
|
||||
case "MEDIA_TYPE_VIDEO":
|
||||
return MediaInfo_MediaType.MEDIA_TYPE_VIDEO;
|
||||
return ClientAbrState_MediaType.MEDIA_TYPE_VIDEO;
|
||||
case 3:
|
||||
case "USE_SERVER_FORMAT_FILTER":
|
||||
return MediaInfo_MediaType.USE_SERVER_FORMAT_FILTER;
|
||||
return ClientAbrState_MediaType.USE_SERVER_FORMAT_FILTER;
|
||||
case -1:
|
||||
case "UNRECOGNIZED":
|
||||
default:
|
||||
return MediaInfo_MediaType.UNRECOGNIZED;
|
||||
return ClientAbrState_MediaType.UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
export function mediaInfo_MediaTypeToJSON(object: MediaInfo_MediaType): string {
|
||||
export function clientAbrState_MediaTypeToJSON(object: ClientAbrState_MediaType): string {
|
||||
switch (object) {
|
||||
case MediaInfo_MediaType.MEDIA_TYPE_DEFAULT:
|
||||
case ClientAbrState_MediaType.MEDIA_TYPE_DEFAULT:
|
||||
return "MEDIA_TYPE_DEFAULT";
|
||||
case MediaInfo_MediaType.MEDIA_TYPE_AUDIO:
|
||||
case ClientAbrState_MediaType.MEDIA_TYPE_AUDIO:
|
||||
return "MEDIA_TYPE_AUDIO";
|
||||
case MediaInfo_MediaType.MEDIA_TYPE_VIDEO:
|
||||
case ClientAbrState_MediaType.MEDIA_TYPE_VIDEO:
|
||||
return "MEDIA_TYPE_VIDEO";
|
||||
case MediaInfo_MediaType.USE_SERVER_FORMAT_FILTER:
|
||||
case ClientAbrState_MediaType.USE_SERVER_FORMAT_FILTER:
|
||||
return "USE_SERVER_FORMAT_FILTER";
|
||||
case MediaInfo_MediaType.UNRECOGNIZED:
|
||||
case ClientAbrState_MediaType.UNRECOGNIZED:
|
||||
default:
|
||||
return "UNRECOGNIZED";
|
||||
}
|
||||
}
|
||||
|
||||
function createBaseMediaInfo(): MediaInfo {
|
||||
function createBaseClientAbrState(): ClientAbrState {
|
||||
return {
|
||||
timeSinceLastManualFormatSelectionMs: 0,
|
||||
lastManualDirection: 0,
|
||||
@@ -134,8 +134,8 @@ function createBaseMediaInfo(): MediaInfo {
|
||||
};
|
||||
}
|
||||
|
||||
export const MediaInfo: MessageFns<MediaInfo> = {
|
||||
encode(message: MediaInfo, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
export const ClientAbrState: MessageFns<ClientAbrState> = {
|
||||
encode(message: ClientAbrState, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
if (
|
||||
message.timeSinceLastManualFormatSelectionMs !== undefined && message.timeSinceLastManualFormatSelectionMs !== 0
|
||||
) {
|
||||
@@ -246,10 +246,10 @@ export const MediaInfo: MessageFns<MediaInfo> = {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): MediaInfo {
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): ClientAbrState {
|
||||
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseMediaInfo();
|
||||
const message = createBaseClientAbrState();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
@@ -500,7 +500,7 @@ export const MediaInfo: MessageFns<MediaInfo> = {
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MediaInfo {
|
||||
fromJSON(object: any): ClientAbrState {
|
||||
return {
|
||||
timeSinceLastManualFormatSelectionMs: isSet(object.timeSinceLastManualFormatSelectionMs)
|
||||
? globalThis.Number(object.timeSinceLastManualFormatSelectionMs)
|
||||
@@ -520,7 +520,7 @@ export const MediaInfo: MessageFns<MediaInfo> = {
|
||||
? MediaCapabilities.fromJSON(object.mediaCapabilities)
|
||||
: undefined,
|
||||
timeSinceLastAction: isSet(object.timeSinceLastAction) ? globalThis.Number(object.timeSinceLastAction) : 0,
|
||||
mediaType: isSet(object.mediaType) ? mediaInfo_MediaTypeFromJSON(object.mediaType) : 0,
|
||||
mediaType: isSet(object.mediaType) ? clientAbrState_MediaTypeFromJSON(object.mediaType) : 0,
|
||||
playerState: isSet(object.playerState) ? globalThis.Number(object.playerState) : 0,
|
||||
rangeCompression: isSet(object.rangeCompression) ? globalThis.Boolean(object.rangeCompression) : false,
|
||||
Jda: isSet(object.Jda) ? globalThis.Number(object.Jda) : 0,
|
||||
@@ -553,7 +553,7 @@ export const MediaInfo: MessageFns<MediaInfo> = {
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: MediaInfo): unknown {
|
||||
toJSON(message: ClientAbrState): unknown {
|
||||
const obj: any = {};
|
||||
if (
|
||||
message.timeSinceLastManualFormatSelectionMs !== undefined && message.timeSinceLastManualFormatSelectionMs !== 0
|
||||
@@ -600,7 +600,7 @@ export const MediaInfo: MessageFns<MediaInfo> = {
|
||||
obj.timeSinceLastAction = Math.round(message.timeSinceLastAction);
|
||||
}
|
||||
if (message.mediaType !== undefined && message.mediaType !== 0) {
|
||||
obj.mediaType = mediaInfo_MediaTypeToJSON(message.mediaType);
|
||||
obj.mediaType = clientAbrState_MediaTypeToJSON(message.mediaType);
|
||||
}
|
||||
if (message.playerState !== undefined && message.playerState !== 0) {
|
||||
obj.playerState = Math.round(message.playerState);
|
||||
@@ -665,11 +665,11 @@ export const MediaInfo: MessageFns<MediaInfo> = {
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<MediaInfo>, I>>(base?: I): MediaInfo {
|
||||
return MediaInfo.fromPartial(base ?? ({} as any));
|
||||
create<I extends Exact<DeepPartial<ClientAbrState>, I>>(base?: I): ClientAbrState {
|
||||
return ClientAbrState.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<MediaInfo>, I>>(object: I): MediaInfo {
|
||||
const message = createBaseMediaInfo();
|
||||
fromPartial<I extends Exact<DeepPartial<ClientAbrState>, I>>(object: I): ClientAbrState {
|
||||
const message = createBaseClientAbrState();
|
||||
message.timeSinceLastManualFormatSelectionMs = object.timeSinceLastManualFormatSelectionMs ?? 0;
|
||||
message.lastManualDirection = object.lastManualDirection ?? 0;
|
||||
message.quality = object.quality ?? 0;
|
||||
@@ -6,14 +6,14 @@
|
||||
|
||||
/* eslint-disable */
|
||||
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
||||
import { ClientAbrState } from "./client_abr_state.js";
|
||||
import { EncryptedRequest } from "./encrypted_request.js";
|
||||
import { MediaInfo } from "./media_info.js";
|
||||
import { StreamerContext } from "./streamer_context.js";
|
||||
|
||||
export const protobufPackage = "video_streaming";
|
||||
|
||||
export interface OnesieInnertubeRequest {
|
||||
mediaInfo?: MediaInfo | undefined;
|
||||
clientAbrState?: ClientAbrState | undefined;
|
||||
encryptedRequest?: EncryptedRequest | undefined;
|
||||
onesieUstreamerConfig?: Uint8Array | undefined;
|
||||
streamerContext?: StreamerContext | undefined;
|
||||
@@ -21,7 +21,7 @@ export interface OnesieInnertubeRequest {
|
||||
|
||||
function createBaseOnesieInnertubeRequest(): OnesieInnertubeRequest {
|
||||
return {
|
||||
mediaInfo: undefined,
|
||||
clientAbrState: undefined,
|
||||
encryptedRequest: undefined,
|
||||
onesieUstreamerConfig: new Uint8Array(0),
|
||||
streamerContext: undefined,
|
||||
@@ -30,8 +30,8 @@ function createBaseOnesieInnertubeRequest(): OnesieInnertubeRequest {
|
||||
|
||||
export const OnesieInnertubeRequest: MessageFns<OnesieInnertubeRequest> = {
|
||||
encode(message: OnesieInnertubeRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
if (message.mediaInfo !== undefined) {
|
||||
MediaInfo.encode(message.mediaInfo, writer.uint32(18).fork()).join();
|
||||
if (message.clientAbrState !== undefined) {
|
||||
ClientAbrState.encode(message.clientAbrState, writer.uint32(18).fork()).join();
|
||||
}
|
||||
if (message.encryptedRequest !== undefined) {
|
||||
EncryptedRequest.encode(message.encryptedRequest, writer.uint32(26).fork()).join();
|
||||
@@ -57,7 +57,7 @@ export const OnesieInnertubeRequest: MessageFns<OnesieInnertubeRequest> = {
|
||||
break;
|
||||
}
|
||||
|
||||
message.mediaInfo = MediaInfo.decode(reader, reader.uint32());
|
||||
message.clientAbrState = ClientAbrState.decode(reader, reader.uint32());
|
||||
continue;
|
||||
case 3:
|
||||
if (tag !== 26) {
|
||||
@@ -91,7 +91,7 @@ export const OnesieInnertubeRequest: MessageFns<OnesieInnertubeRequest> = {
|
||||
|
||||
fromJSON(object: any): OnesieInnertubeRequest {
|
||||
return {
|
||||
mediaInfo: isSet(object.mediaInfo) ? MediaInfo.fromJSON(object.mediaInfo) : undefined,
|
||||
clientAbrState: isSet(object.clientAbrState) ? ClientAbrState.fromJSON(object.clientAbrState) : undefined,
|
||||
encryptedRequest: isSet(object.encryptedRequest) ? EncryptedRequest.fromJSON(object.encryptedRequest) : undefined,
|
||||
onesieUstreamerConfig: isSet(object.onesieUstreamerConfig)
|
||||
? bytesFromBase64(object.onesieUstreamerConfig)
|
||||
@@ -102,8 +102,8 @@ export const OnesieInnertubeRequest: MessageFns<OnesieInnertubeRequest> = {
|
||||
|
||||
toJSON(message: OnesieInnertubeRequest): unknown {
|
||||
const obj: any = {};
|
||||
if (message.mediaInfo !== undefined) {
|
||||
obj.mediaInfo = MediaInfo.toJSON(message.mediaInfo);
|
||||
if (message.clientAbrState !== undefined) {
|
||||
obj.clientAbrState = ClientAbrState.toJSON(message.clientAbrState);
|
||||
}
|
||||
if (message.encryptedRequest !== undefined) {
|
||||
obj.encryptedRequest = EncryptedRequest.toJSON(message.encryptedRequest);
|
||||
@@ -122,8 +122,8 @@ export const OnesieInnertubeRequest: MessageFns<OnesieInnertubeRequest> = {
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<OnesieInnertubeRequest>, I>>(object: I): OnesieInnertubeRequest {
|
||||
const message = createBaseOnesieInnertubeRequest();
|
||||
message.mediaInfo = (object.mediaInfo !== undefined && object.mediaInfo !== null)
|
||||
? MediaInfo.fromPartial(object.mediaInfo)
|
||||
message.clientAbrState = (object.clientAbrState !== undefined && object.clientAbrState !== null)
|
||||
? ClientAbrState.fromPartial(object.clientAbrState)
|
||||
: undefined;
|
||||
message.encryptedRequest = (object.encryptedRequest !== undefined && object.encryptedRequest !== null)
|
||||
? EncryptedRequest.fromPartial(object.encryptedRequest)
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
/* eslint-disable */
|
||||
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
||||
import { FormatId } from "../misc/common.js";
|
||||
import { MediaInfo } from "./media_info.js";
|
||||
import { ClientAbrState } from "./client_abr_state.js";
|
||||
import { StreamerContext } from "./streamer_context.js";
|
||||
import { TimeRange } from "./time_range.js";
|
||||
|
||||
export const protobufPackage = "video_streaming";
|
||||
|
||||
export interface VideoPlaybackAbrRequest {
|
||||
mediaInfo?: MediaInfo | undefined;
|
||||
clientAbrState?: ClientAbrState | undefined;
|
||||
selectedFormats: FormatId[];
|
||||
bufferedRange: BufferedRange[];
|
||||
videoPlaybackUstreamerConfig?: Uint8Array | undefined;
|
||||
@@ -86,7 +86,7 @@ export interface Pqa {
|
||||
|
||||
function createBaseVideoPlaybackAbrRequest(): VideoPlaybackAbrRequest {
|
||||
return {
|
||||
mediaInfo: undefined,
|
||||
clientAbrState: undefined,
|
||||
selectedFormats: [],
|
||||
bufferedRange: [],
|
||||
videoPlaybackUstreamerConfig: new Uint8Array(0),
|
||||
@@ -103,8 +103,8 @@ function createBaseVideoPlaybackAbrRequest(): VideoPlaybackAbrRequest {
|
||||
|
||||
export const VideoPlaybackAbrRequest: MessageFns<VideoPlaybackAbrRequest> = {
|
||||
encode(message: VideoPlaybackAbrRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
if (message.mediaInfo !== undefined) {
|
||||
MediaInfo.encode(message.mediaInfo, writer.uint32(10).fork()).join();
|
||||
if (message.clientAbrState !== undefined) {
|
||||
ClientAbrState.encode(message.clientAbrState, writer.uint32(10).fork()).join();
|
||||
}
|
||||
for (const v of message.selectedFormats) {
|
||||
FormatId.encode(v!, writer.uint32(18).fork()).join();
|
||||
@@ -154,7 +154,7 @@ export const VideoPlaybackAbrRequest: MessageFns<VideoPlaybackAbrRequest> = {
|
||||
break;
|
||||
}
|
||||
|
||||
message.mediaInfo = MediaInfo.decode(reader, reader.uint32());
|
||||
message.clientAbrState = ClientAbrState.decode(reader, reader.uint32());
|
||||
continue;
|
||||
case 2:
|
||||
if (tag !== 18) {
|
||||
@@ -244,7 +244,7 @@ export const VideoPlaybackAbrRequest: MessageFns<VideoPlaybackAbrRequest> = {
|
||||
|
||||
fromJSON(object: any): VideoPlaybackAbrRequest {
|
||||
return {
|
||||
mediaInfo: isSet(object.mediaInfo) ? MediaInfo.fromJSON(object.mediaInfo) : undefined,
|
||||
clientAbrState: isSet(object.clientAbrState) ? ClientAbrState.fromJSON(object.clientAbrState) : undefined,
|
||||
selectedFormats: globalThis.Array.isArray(object?.selectedFormats)
|
||||
? object.selectedFormats.map((e: any) => FormatId.fromJSON(e))
|
||||
: [],
|
||||
@@ -271,8 +271,8 @@ export const VideoPlaybackAbrRequest: MessageFns<VideoPlaybackAbrRequest> = {
|
||||
|
||||
toJSON(message: VideoPlaybackAbrRequest): unknown {
|
||||
const obj: any = {};
|
||||
if (message.mediaInfo !== undefined) {
|
||||
obj.mediaInfo = MediaInfo.toJSON(message.mediaInfo);
|
||||
if (message.clientAbrState !== undefined) {
|
||||
obj.clientAbrState = ClientAbrState.toJSON(message.clientAbrState);
|
||||
}
|
||||
if (message.selectedFormats?.length) {
|
||||
obj.selectedFormats = message.selectedFormats.map((e) => FormatId.toJSON(e));
|
||||
@@ -315,8 +315,8 @@ export const VideoPlaybackAbrRequest: MessageFns<VideoPlaybackAbrRequest> = {
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<VideoPlaybackAbrRequest>, I>>(object: I): VideoPlaybackAbrRequest {
|
||||
const message = createBaseVideoPlaybackAbrRequest();
|
||||
message.mediaInfo = (object.mediaInfo !== undefined && object.mediaInfo !== null)
|
||||
? MediaInfo.fromPartial(object.mediaInfo)
|
||||
message.clientAbrState = (object.clientAbrState !== undefined && object.clientAbrState !== null)
|
||||
? ClientAbrState.fromPartial(object.clientAbrState)
|
||||
: undefined;
|
||||
message.selectedFormats = object.selectedFormats?.map((e) => FormatId.fromPartial(e)) || [];
|
||||
message.bufferedRange = object.bufferedRange?.map((e) => BufferedRange.fromPartial(e)) || [];
|
||||
|
||||
@@ -3,7 +3,7 @@ package video_streaming;
|
||||
|
||||
import "video_streaming/media_capabilities.proto";
|
||||
|
||||
message MediaInfo {
|
||||
message ClientAbrState {
|
||||
optional int32 time_since_last_manual_format_selection_ms = 13;
|
||||
optional int32 last_manual_direction = 14;
|
||||
optional int32 quality = 16;
|
||||
@@ -1,12 +1,12 @@
|
||||
syntax = "proto2";
|
||||
package video_streaming;
|
||||
|
||||
import "video_streaming/media_info.proto";
|
||||
import "video_streaming/client_abr_state.proto";
|
||||
import "video_streaming/encrypted_request.proto";
|
||||
import "video_streaming/streamer_context.proto";
|
||||
|
||||
message OnesieInnertubeRequest {
|
||||
optional MediaInfo media_info = 2;
|
||||
optional ClientAbrState client_abr_state = 2;
|
||||
optional EncryptedRequest encrypted_request = 3;
|
||||
optional bytes onesie_ustreamer_config = 4;
|
||||
optional StreamerContext streamer_context = 10;
|
||||
|
||||
@@ -2,12 +2,12 @@ syntax = "proto2";
|
||||
package video_streaming;
|
||||
|
||||
import "misc/common.proto";
|
||||
import "video_streaming/media_info.proto";
|
||||
import "video_streaming/client_abr_state.proto";
|
||||
import "video_streaming/time_range.proto";
|
||||
import "video_streaming/streamer_context.proto";
|
||||
|
||||
message VideoPlaybackAbrRequest {
|
||||
optional MediaInfo media_info = 1;
|
||||
optional ClientAbrState client_abr_state = 1;
|
||||
repeated .misc.FormatId selected_formats = 2;
|
||||
repeated BufferedRange buffered_range = 3;
|
||||
optional bytes video_playback_ustreamer_config = 5;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { UMP } from './UMP.js';
|
||||
import { ChunkedDataBuffer } from './ChunkedDataBuffer.js';
|
||||
import { EventEmitterLike, PART, QUALITY, base64ToU8, getFormatKey } from '../utils/index.js';
|
||||
|
||||
import { MediaInfo_MediaType } from '../../protos/generated/video_streaming/media_info.js';
|
||||
import { ClientAbrState_MediaType } from '../../protos/generated/video_streaming/client_abr_state.js';
|
||||
import { VideoPlaybackAbrRequest } from '../../protos/generated/video_streaming/video_playback_abr_request.js';
|
||||
import { MediaHeader } from '../../protos/generated/video_streaming/media_header.js';
|
||||
import { NextRequestPolicy } from '../../protos/generated/video_streaming/next_request_policy.js';
|
||||
@@ -13,7 +13,7 @@ import { StreamProtectionStatus } from '../../protos/generated/video_streaming/s
|
||||
import { PlaybackCookie } from '../../protos/generated/video_streaming/playback_cookie.js';
|
||||
|
||||
import type { FormatId } from '../../protos/generated/misc/common.js';
|
||||
import type { MediaInfo } from '../../protos/generated/video_streaming/media_info.js';
|
||||
import type { ClientAbrState } from '../../protos/generated/video_streaming/client_abr_state.js';
|
||||
import type { FetchFunction, InitializedFormat, InitOptions, MediaArgs, ServerAbrResponse, ServerAbrStreamOptions } from '../utils/types.js';
|
||||
|
||||
const DEFAULT_QUALITY = QUALITY.HD720;
|
||||
@@ -58,19 +58,19 @@ export class ServerAbrStream extends EventEmitterLike {
|
||||
* @param args - The initialization options.
|
||||
*/
|
||||
public async init(args: InitOptions) {
|
||||
const { audioFormats, videoFormats, mediaInfo: initialMediaInfo } = args;
|
||||
const { audioFormats, videoFormats, clientAbrState: initialState } = args;
|
||||
|
||||
const firstVideoFormat = videoFormats ? videoFormats[0] : undefined;
|
||||
|
||||
const mediaInfo: MediaInfo = {
|
||||
const clientAbrState: ClientAbrState = {
|
||||
lastManualDirection: 0,
|
||||
timeSinceLastManualFormatSelectionMs: 0,
|
||||
quality: videoFormats.length === 1 ? firstVideoFormat?.width : DEFAULT_QUALITY,
|
||||
selectedQualityHeight: videoFormats.length === 1 ? firstVideoFormat?.width : DEFAULT_QUALITY,
|
||||
startTimeMs: 0,
|
||||
visibility: 0,
|
||||
mediaType: MediaInfo_MediaType.MEDIA_TYPE_DEFAULT,
|
||||
...initialMediaInfo
|
||||
mediaType: ClientAbrState_MediaType.MEDIA_TYPE_DEFAULT,
|
||||
...initialState
|
||||
};
|
||||
|
||||
const audioFormatIds = audioFormats.map<FormatId>((fmt) => ({
|
||||
@@ -85,21 +85,21 @@ export class ServerAbrStream extends EventEmitterLike {
|
||||
xtags: fmt.xtags
|
||||
}));
|
||||
|
||||
if (typeof mediaInfo.startTimeMs !== 'number')
|
||||
if (typeof clientAbrState.startTimeMs !== 'number')
|
||||
throw new Error('Invalid media start time');
|
||||
|
||||
try {
|
||||
while (mediaInfo.startTimeMs < this.totalDurationMs) {
|
||||
const data = await this.fetchMedia({ mediaInfo, audioFormatIds, videoFormatIds });
|
||||
while (clientAbrState.startTimeMs < this.totalDurationMs) {
|
||||
const data = await this.fetchMedia({ clientAbrState, audioFormatIds, videoFormatIds });
|
||||
|
||||
this.emit('data', data);
|
||||
|
||||
if (data.sabrError) break;
|
||||
|
||||
const mainFormat =
|
||||
mediaInfo.mediaType === MediaInfo_MediaType.MEDIA_TYPE_DEFAULT
|
||||
? data.initializedFormats.find((fmt) => fmt.mimeType?.includes('video'))
|
||||
: data.initializedFormats[0];
|
||||
clientAbrState.mediaType === ClientAbrState_MediaType.MEDIA_TYPE_DEFAULT
|
||||
? data.initializedFormats.find((fmt) => fmt.mimeType?.includes('video'))
|
||||
: data.initializedFormats[0];
|
||||
|
||||
for (const fmt of data.initializedFormats) {
|
||||
this.previousSequences.set(`${fmt.formatId.itag};${fmt.formatId.lastModified};`, fmt.sequenceList.map((seq) => seq.sequenceNumber || 0));
|
||||
@@ -114,7 +114,7 @@ export class ServerAbrStream extends EventEmitterLike {
|
||||
break;
|
||||
}
|
||||
|
||||
mediaInfo.startTimeMs += mainFormat.sequenceList.reduce((acc, seq) => acc + (seq.durationMs || 0), 0);
|
||||
clientAbrState.startTimeMs += mainFormat.sequenceList.reduce((acc, seq) => acc + (seq.durationMs || 0), 0);
|
||||
}
|
||||
} catch (error) {
|
||||
this.emit('error', error);
|
||||
@@ -122,10 +122,10 @@ export class ServerAbrStream extends EventEmitterLike {
|
||||
}
|
||||
|
||||
private async fetchMedia(args: MediaArgs): Promise<ServerAbrResponse> {
|
||||
const { mediaInfo, audioFormatIds, videoFormatIds } = args;
|
||||
const { clientAbrState, audioFormatIds, videoFormatIds } = args;
|
||||
|
||||
const body = VideoPlaybackAbrRequest.encode({
|
||||
mediaInfo: mediaInfo,
|
||||
clientAbrState: clientAbrState,
|
||||
audioFormats: audioFormatIds,
|
||||
videoFormats: videoFormatIds,
|
||||
selectedFormats: this.initializedFormats.map((fmt) => fmt.formatId),
|
||||
|
||||
@@ -14,8 +14,9 @@ export { OnesieHeader } from '../../protos/generated/video_streaming/onesie_head
|
||||
export { OnesieHeaderType } from '../../protos/generated/video_streaming/onesie_header_type.js';
|
||||
export { OnesieInnertubeRequest } from '../../protos/generated/video_streaming/onesie_innertube_request.js';
|
||||
export { OnesieInnertubeResponse } from '../../protos/generated/video_streaming/onesie_innertube_response.js';
|
||||
export { MediaInfo } from '../../protos/generated/video_streaming/media_info.js';
|
||||
export { ClientAbrState } from '../../protos/generated/video_streaming/client_abr_state.js';
|
||||
export { StreamerContext } from '../../protos/generated/video_streaming/streamer_context.js';
|
||||
export { ProxyStatus } from '../../protos/generated/video_streaming/proxy_status.js';
|
||||
export { MediaCapabilities } from '../../protos/generated/video_streaming/media_capabilities.js';
|
||||
export { CryptoParams } from '../../protos/generated/video_streaming/crypto_params.js';
|
||||
export { ClientAbrState_MediaType as MediaType } from '../../protos/generated/video_streaming/client_abr_state.js';
|
||||
@@ -56,8 +56,6 @@ export enum PART {
|
||||
PREWARM_CONNECTION = 65
|
||||
}
|
||||
|
||||
export { MediaInfo_MediaType as MediaType } from '../../protos/generated/video_streaming/media_info.js';
|
||||
|
||||
export function u8ToBase64(u8: Uint8Array): string {
|
||||
return btoa(String.fromCharCode.apply(null, Array.from(u8)));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { SabrRedirect } from '../../protos/generated/video_streaming/sabr_r
|
||||
import type { StreamProtectionStatus } from '../../protos/generated/video_streaming/stream_protection_status.js';
|
||||
import type { TimeRange } from '../../protos/generated/video_streaming/time_range.js';
|
||||
import type { BufferedRange } from '../../protos/generated/video_streaming/video_playback_abr_request.js';
|
||||
import type { MediaInfo } from '../../protos/generated/video_streaming/media_info.js';
|
||||
import type { ClientAbrState } from '../../protos/generated/video_streaming/client_abr_state.js';
|
||||
import type { ChunkedDataBuffer } from '../core/index.js';
|
||||
|
||||
export type Part = {
|
||||
@@ -54,11 +54,11 @@ export type InitializedFormat = {
|
||||
export type InitOptions = {
|
||||
audioFormats: Format[];
|
||||
videoFormats: Format[];
|
||||
mediaInfo?: MediaInfo;
|
||||
clientAbrState?: ClientAbrState;
|
||||
};
|
||||
|
||||
export type MediaArgs = {
|
||||
mediaInfo: MediaInfo;
|
||||
clientAbrState: ClientAbrState;
|
||||
audioFormatIds: FormatId[];
|
||||
videoFormatIds: FormatId[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user