Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit c497046

Browse files
authored
Implement voice broadcast last_chunk_sequence (#9513)
1 parent 07003a5 commit c497046

File tree

3 files changed

+10
-22
lines changed

3 files changed

+10
-22
lines changed

src/voice-broadcast/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface VoiceBroadcastInfoEventContent {
5656
device_id: string;
5757
state: VoiceBroadcastInfoState;
5858
chunk_length?: number;
59+
last_chunk_sequence?: number;
5960
["m.relates_to"]?: {
6061
rel_type: RelationType;
6162
event_id: string;

src/voice-broadcast/models/VoiceBroadcastRecording.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"
2121
import {
2222
ChunkRecordedPayload,
2323
createVoiceBroadcastRecorder,
24+
VoiceBroadcastInfoEventContent,
2425
VoiceBroadcastInfoEventType,
2526
VoiceBroadcastInfoState,
2627
VoiceBroadcastRecorder,
@@ -207,11 +208,12 @@ export class VoiceBroadcastRecording
207208
{
208209
device_id: this.client.getDeviceId(),
209210
state,
211+
last_chunk_sequence: this.sequence,
210212
["m.relates_to"]: {
211213
rel_type: RelationType.Reference,
212214
event_id: this.infoEvent.getId(),
213215
},
214-
},
216+
} as VoiceBroadcastInfoEventContent,
215217
this.client.getUserId(),
216218
);
217219
}

test/voice-broadcast/models/VoiceBroadcastRecording-test.ts

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,20 @@ describe("VoiceBroadcastRecording", () => {
9292
});
9393
};
9494

95-
const itShouldSendAnInfoEvent = (state: VoiceBroadcastInfoState) => {
95+
const itShouldSendAnInfoEvent = (state: VoiceBroadcastInfoState, lastChunkSequence: number) => {
9696
it(`should send a ${state} info event`, () => {
9797
expect(client.sendStateEvent).toHaveBeenCalledWith(
9898
roomId,
9999
VoiceBroadcastInfoEventType,
100100
{
101-
102101
device_id: client.getDeviceId(),
103102
state,
103+
last_chunk_sequence: lastChunkSequence,
104104
["m.relates_to"]: {
105105
rel_type: RelationType.Reference,
106106
event_id: infoEvent.getId(),
107107
},
108-
},
108+
} as VoiceBroadcastInfoEventContent,
109109
client.getUserId(),
110110
);
111111
});
@@ -203,22 +203,7 @@ describe("VoiceBroadcastRecording", () => {
203203
voiceBroadcastRecording.stop();
204204
});
205205

206-
it("should send a stopped Voice Broadcast Info event", () => {
207-
expect(mocked(client.sendStateEvent)).toHaveBeenCalledWith(
208-
roomId,
209-
VoiceBroadcastInfoEventType,
210-
{
211-
device_id: client.getDeviceId(),
212-
state: VoiceBroadcastInfoState.Stopped,
213-
["m.relates_to"]: {
214-
rel_type: RelationType.Reference,
215-
event_id: infoEvent.getId(),
216-
},
217-
},
218-
client.getUserId(),
219-
);
220-
});
221-
206+
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Stopped, 1);
222207
itShouldBeInState(VoiceBroadcastInfoState.Stopped);
223208

224209
it("should emit a stopped state changed event", () => {
@@ -383,7 +368,7 @@ describe("VoiceBroadcastRecording", () => {
383368
});
384369

385370
itShouldBeInState(VoiceBroadcastInfoState.Paused);
386-
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Paused);
371+
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Paused, 1);
387372

388373
it("should stop the recorder", () => {
389374
expect(mocked(voiceBroadcastRecorder.stop)).toHaveBeenCalled();
@@ -424,7 +409,7 @@ describe("VoiceBroadcastRecording", () => {
424409
});
425410

426411
itShouldBeInState(VoiceBroadcastInfoState.Resumed);
427-
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Resumed);
412+
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Resumed, 1);
428413

429414
it("should start the recorder", () => {
430415
expect(mocked(voiceBroadcastRecorder.start)).toHaveBeenCalled();

0 commit comments

Comments
 (0)