@stinkycomputing/web-live-player 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { HeaderCodecData } from '../protocol/sesame-binary-protocol';
1
+ import { IMediaCodecData } from '@stinkycomputing/sesame-api-client';
2
2
 
3
3
  export interface LiveAudioConfig {
4
4
  bufferDelayMs?: number;
@@ -16,7 +16,7 @@ export declare class LiveAudioPlayer {
16
16
  /**
17
17
  * Initialize with codec info from stream header
18
18
  */
19
- init(codecData?: HeaderCodecData): Promise<void>;
19
+ init(codecData?: IMediaCodecData): Promise<void>;
20
20
  /**
21
21
  * Build decoder config based on codec type
22
22
  */
@@ -32,7 +32,9 @@ export declare class LiveAudioPlayer {
32
32
  /**
33
33
  * Queue encoded audio data for decoding
34
34
  */
35
- decode(data: Uint8Array, pts?: bigint): void;
35
+ decode(data: Uint8Array, pts?: number | bigint | null | {
36
+ toNumber(): number;
37
+ }): void;
36
38
  /**
37
39
  * Set buffer delay for A/V sync
38
40
  */
@@ -1,4 +1,4 @@
1
- import { CodecType } from './capture-types';
1
+ import { sesame } from '@stinkycomputing/sesame-api-client';
2
2
 
3
3
  /**
4
4
  * Serialized packet ready for transmission
@@ -48,7 +48,7 @@ export interface ICaptureSink {
48
48
  */
49
49
  export interface VideoStreamConfig {
50
50
  /** Video codec type */
51
- codec: CodecType;
51
+ codec: sesame.v1.wire.CodecType;
52
52
  /** Video width */
53
53
  width: number;
54
54
  /** Video height */
@@ -63,7 +63,7 @@ export interface VideoStreamConfig {
63
63
  */
64
64
  export interface AudioStreamConfig {
65
65
  /** Audio codec type */
66
- codec: CodecType;
66
+ codec: sesame.v1.wire.CodecType;
67
67
  /** Sample rate in Hz */
68
68
  sampleRate: number;
69
69
  /** Number of channels */
@@ -1,11 +1,11 @@
1
- import { CodecType, PacketType } from '../protocol/sesame-binary-protocol';
1
+ import { CodecType, sesame } from '@stinkycomputing/sesame-api-client';
2
2
 
3
- export { CodecType, PacketType };
3
+ export { CodecType };
4
4
  /**
5
5
  * Video codec configuration options
6
6
  */
7
7
  export interface VideoEncoderOptions {
8
- codec: CodecType;
8
+ codec: sesame.v1.wire.CodecType;
9
9
  width?: number;
10
10
  height?: number;
11
11
  bitrate?: number;
@@ -17,7 +17,7 @@ export interface VideoEncoderOptions {
17
17
  * Audio codec configuration options
18
18
  */
19
19
  export interface AudioEncoderOptions {
20
- codec: CodecType;
20
+ codec: sesame.v1.wire.CodecType;
21
21
  sampleRate?: number;
22
22
  channels?: number;
23
23
  bitrate?: number;
@@ -109,12 +109,12 @@ export interface CaptureEvents {
109
109
  /**
110
110
  * Convert CodecType to WebCodecs codec string
111
111
  */
112
- export declare function codecTypeToString(codec: CodecType): string;
112
+ export declare function codecTypeToString(codec: sesame.v1.wire.CodecType): string;
113
113
  /**
114
114
  * Check if a codec is a video codec
115
115
  */
116
- export declare function isVideoCodec(codec: CodecType): boolean;
116
+ export declare function isVideoCodec(codec: sesame.v1.wire.CodecType): boolean;
117
117
  /**
118
118
  * Check if a codec is an audio codec
119
119
  */
120
- export declare function isAudioCodec(codec: CodecType): boolean;
120
+ export declare function isAudioCodec(codec: sesame.v1.wire.CodecType): boolean;
@@ -76,6 +76,12 @@ export declare class MediaCapture {
76
76
  * Get the underlying MediaStream (for preview purposes)
77
77
  */
78
78
  getMediaStream(): MediaStream | undefined;
79
+ /**
80
+ * Set an external MoQ session on the sink (if it's a MoQCaptureSink)
81
+ * Allows injecting an existing MoqSessionBroadcaster instance.
82
+ * @param session - MoqSessionBroadcaster instance to use for broadcasting
83
+ */
84
+ setMoQSession(session: any): void;
79
85
  private handleEncodedChunk;
80
86
  private createPacket;
81
87
  /**
@@ -1,4 +1,5 @@
1
1
  import { BaseCaptureSink, CaptureSinkConfig, SerializedPacket } from './capture-sink';
2
+ import { MoqSessionBroadcaster } from 'stinky-moq-js';
2
3
 
3
4
  /**
4
5
  * Track configuration for MoQ publishing
@@ -11,10 +12,10 @@ export interface MoQTrackConfig {
11
12
  * MoQ-specific sink configuration
12
13
  */
13
14
  export interface MoQSinkConfig extends CaptureSinkConfig {
14
- /** MoQ relay URL */
15
- relayUrl: string;
16
- /** Namespace for the streams */
17
- namespace: string;
15
+ /** MoQ relay URL (required if session is not provided) */
16
+ relayUrl?: string;
17
+ /** Namespace for the streams (required if session is not provided) */
18
+ namespace?: string;
18
19
  /** Video track configuration */
19
20
  videoTrack?: MoQTrackConfig;
20
21
  /** Audio track configuration */
@@ -23,6 +24,8 @@ export interface MoQSinkConfig extends CaptureSinkConfig {
23
24
  dataTracks?: MoQTrackConfig[];
24
25
  /** Reconnection delay in ms */
25
26
  reconnectionDelay?: number;
27
+ /** External MoQ session to use (if provided, relayUrl and namespace are ignored) */
28
+ session?: MoqSessionBroadcaster;
26
29
  }
27
30
  /**
28
31
  * Capture sink that sends data over MoQ
@@ -32,6 +35,7 @@ export declare class MoQCaptureSink extends BaseCaptureSink {
32
35
  private session;
33
36
  private connecting;
34
37
  private disposed;
38
+ private sessionOwned;
35
39
  private currentVideoGroup;
36
40
  private audioFrameCount;
37
41
  private static readonly AUDIO_FRAMES_PER_GROUP;
@@ -41,6 +45,12 @@ export declare class MoQCaptureSink extends BaseCaptureSink {
41
45
  send(packet: SerializedPacket): void;
42
46
  private setupEventListeners;
43
47
  dispose(): void;
48
+ /**
49
+ * Set an external MoQ session (dependency injection)
50
+ * Similar to LiveVideoPlayer.setStreamSource()
51
+ * @param session - MoqSessionBroadcaster instance to use for broadcasting
52
+ */
53
+ setMoQSession(session: MoqSessionBroadcaster): void;
44
54
  /**
45
55
  * Send custom data on a data track (e.g., chat messages)
46
56
  * Each data message starts a new group.
@@ -1,4 +1,4 @@
1
- import { ParsedData, HeaderCodecData } from '../protocol/sesame-binary-protocol';
1
+ import { IMediaCodecData, ParsedFrame } from '@stinkycomputing/sesame-api-client';
2
2
  import { YUVFrame } from '../types';
3
3
 
4
4
  /**
@@ -34,12 +34,12 @@ export interface IVideoDecoder {
34
34
  * Configure the decoder for a specific codec
35
35
  * @param codecData - Codec configuration from stream header
36
36
  */
37
- configure(codecData: HeaderCodecData): Promise<void>;
37
+ configure(codecData: IMediaCodecData): Promise<void>;
38
38
  /**
39
39
  * Decode a binary packet from the stream
40
40
  * @param data - Parsed stream data containing header and payload
41
41
  */
42
- decodeBinary(data: ParsedData): void;
42
+ decodeBinary(data: ParsedFrame): void;
43
43
  /**
44
44
  * Flush pending frames (synchronous reset)
45
45
  */
@@ -1,6 +1,6 @@
1
- import { ParsedData } from '../protocol/sesame-binary-protocol';
2
1
  import { YUVFrame } from '../types';
3
2
  import { IVideoDecoder } from './decoder-interface';
3
+ import { ParsedFrame } from '@stinkycomputing/sesame-api-client';
4
4
 
5
5
  export type { YUVFrame } from '../types';
6
6
  export interface WasmDecoderConfig {
@@ -27,15 +27,11 @@ export declare class WasmDecoder implements IVideoDecoder {
27
27
  /**
28
28
  * Configure the decoder (initializes the worker)
29
29
  */
30
- configure(_codecData: {
31
- codec_type: number;
32
- width: number;
33
- height: number;
34
- }): Promise<void>;
30
+ configure(_codecData: any): Promise<void>;
35
31
  /**
36
32
  * Decode a binary packet (same interface as WebCodecsDecoder)
37
33
  */
38
- decodeBinary(data: ParsedData): void;
34
+ decodeBinary(data: ParsedFrame): void;
39
35
  /**
40
36
  * Process next frame from queue
41
37
  */
@@ -1,4 +1,4 @@
1
- import { ParsedData, HeaderCodecData } from '../protocol/sesame-binary-protocol';
1
+ import { ParsedFrame, IMediaCodecData } from '@stinkycomputing/sesame-api-client';
2
2
  import { Logger } from '../types';
3
3
  import { IVideoDecoder } from './decoder-interface';
4
4
 
@@ -40,9 +40,9 @@ export declare class WebCodecsDecoder implements IVideoDecoder {
40
40
  get state(): string;
41
41
  private createDecoder;
42
42
  /**
43
- * Configure the decoder for a specific codec (from HeaderCodecData)
43
+ * Configure the decoder for a specific codec (from IMediaCodecData)
44
44
  */
45
- configure(codecData: HeaderCodecData, preferHardware?: boolean): Promise<void>;
45
+ configure(codecData: IMediaCodecData, preferHardware?: boolean): Promise<void>;
46
46
  /**
47
47
  * Configure the decoder with VideoDecoderConfig directly
48
48
  */
@@ -52,13 +52,13 @@ export declare class WebCodecsDecoder implements IVideoDecoder {
52
52
  */
53
53
  private configureWithConfig;
54
54
  /**
55
- * Configure with HeaderCodecData (from binary protocol)
55
+ * Configure with IMediaCodecData (from binary protocol)
56
56
  */
57
57
  private configureWithCodecData;
58
58
  /**
59
59
  * Decode a binary packet
60
60
  */
61
- decodeBinary(data: ParsedData): void;
61
+ decodeBinary(data: ParsedFrame): void;
62
62
  /**
63
63
  * Decode a sample (from file demuxer)
64
64
  */
package/dist/index.d.ts CHANGED
@@ -17,7 +17,7 @@ export { FileVideoPlayer, createFilePlayer } from './player/file-player';
17
17
  export type { FilePlayerConfig, FilePlayerState, FilePlayerStats, FilePlayMode } from './player/file-player';
18
18
  export { createMoQSource, MoQSource } from './sources/moq-source';
19
19
  export { WebSocketSource, createWebSocketSource } from './sources/websocket-source';
20
- export type { WebSocketSourceConfig, VideoMetadata } from './sources/websocket-source';
20
+ export type { WebSocketSourceConfig } from './sources/websocket-source';
21
21
  export { MP4FileSource } from './sources/mp4-file-source';
22
22
  export type { MP4FileInfo, DecodableSample, MP4FileSourceEvents } from './sources/mp4-file-source';
23
23
  export { WebCodecsDecoder } from './decoders/webcodecs-decoder';
@@ -31,6 +31,4 @@ export { LiveAudioPlayer } from './audio/live-audio-player';
31
31
  export type { LiveAudioConfig } from './audio/live-audio-player';
32
32
  export { FrameScheduler } from './scheduling/frame-scheduler';
33
33
  export type { FrameTiming, LatencyStats, SchedulerStatus, SchedulerConfig, PacketTimingEntry } from './scheduling/frame-scheduler';
34
- export { SesameBinaryProtocol, FLAG_IS_KEYFRAME, FLAG_HAS_CODEC_DATA, PacketType } from './protocol/sesame-binary-protocol';
35
- export type { ParsedData, HeaderData, HeaderCodecData } from './protocol/sesame-binary-protocol';
36
34
  export * from './capture';
@@ -1,4 +1,4 @@
1
- import { HeaderCodecData } from './sesame-binary-protocol';
1
+ import { IMediaCodecData } from '@stinkycomputing/sesame-api-client';
2
2
 
3
3
  /**
4
4
  * Timebase structure for timestamp conversion
@@ -10,11 +10,13 @@ export interface Timebase {
10
10
  /**
11
11
  * Rescale a timestamp from one timebase to another
12
12
  */
13
- export declare function rescaleTime(pts: bigint, source: Timebase, target: Timebase): number;
13
+ export declare function rescaleTime(pts: number | bigint | null | undefined | {
14
+ toString(): string;
15
+ }, source: Timebase, target: Timebase): number;
14
16
  /**
15
17
  * Check if codec data has changed
16
18
  */
17
- export declare function codecDataChanged(current: HeaderCodecData | undefined, newData: HeaderCodecData | undefined): boolean;
19
+ export declare function codecDataChanged(current: IMediaCodecData | undefined, newData: IMediaCodecData | undefined): boolean;
18
20
  /**
19
21
  * Get human-readable codec name
20
22
  */
@@ -22,4 +24,4 @@ export declare function getCodecName(codecType: number): string;
22
24
  /**
23
25
  * Get WebCodecs codec string for a given codec data
24
26
  */
25
- export declare function getCodecString(codecData: HeaderCodecData): string | null;
27
+ export declare function getCodecString(codecData: IMediaCodecData): string | null;
@@ -1,4 +1,4 @@
1
- import { ParsedData } from '../protocol/sesame-binary-protocol';
1
+ import { ParsedFrame } from '@stinkycomputing/sesame-api-client';
2
2
 
3
3
  /**
4
4
  * Event data emitted when stream data is received
@@ -6,7 +6,7 @@ import { ParsedData } from '../protocol/sesame-binary-protocol';
6
6
  export interface StreamDataEvent {
7
7
  trackName: string;
8
8
  streamType: 'video' | 'audio' | 'data';
9
- data: ParsedData;
9
+ data: ParsedFrame;
10
10
  }
11
11
  /**
12
12
  * Handler type for stream data events
@@ -20,17 +20,7 @@ export interface WebSocketSourceConfig {
20
20
  reconnectDelay?: number;
21
21
  }
22
22
  /**
23
- * Video metadata returned from the server
24
- */
25
- export interface VideoMetadata {
26
- width: number;
27
- height: number;
28
- frameRate?: number;
29
- duration?: number;
30
- codec?: string;
31
- }
32
- /**
33
- * WebSocket-based stream source for live and file-based video playback.
23
+ * WebSocket-based stream source for live video playback.
34
24
  *
35
25
  * @example
36
26
  * ```typescript
@@ -50,8 +40,6 @@ export declare class WebSocketSource extends BaseStreamSource {
50
40
  private messageWaiters;
51
41
  private requestId;
52
42
  private timeoutCheckInterval;
53
- private ignoreCmdsBelow;
54
- private isLiveStream;
55
43
  private config;
56
44
  private lastKeyframeRequest;
57
45
  private currentTrackName;
@@ -72,32 +60,13 @@ export declare class WebSocketSource extends BaseStreamSource {
72
60
  disconnect(): void;
73
61
  /**
74
62
  * Load a live stream by ID
63
+ * Note: Metadata is received via video stream codec data, not from this call
75
64
  */
76
- loadLive(streamId: string): Promise<VideoMetadata>;
77
- /**
78
- * Load a video file
79
- */
80
- loadFile(project: string, filename: string): Promise<VideoMetadata>;
81
- /**
82
- * Seek to a position in the video (file playback only)
83
- */
84
- seek(positionMs: number): Promise<void>;
65
+ loadLive(streamId: string): Promise<void>;
85
66
  /**
86
- * Request more packets from the server (file playback)
87
- */
88
- read(packetCount: number): Promise<void>;
89
- /**
90
- * Unload the current stream
91
- */
92
- unload(): Promise<void>;
93
- /**
94
- * Request a keyframe (live streams only)
67
+ * Request a keyframe
95
68
  */
96
69
  requestKeyframe(): void;
97
- /**
98
- * Flush pending requests (useful when seeking)
99
- */
100
- flush(): void;
101
70
  /**
102
71
  * Dispose the stream source
103
72
  */