mirror of https://github.com/vector-im/riot-web
Implement voice broadcast `last_chunk_sequence` (#9513)
parent
07003a5bc1
commit
c497046e39
|
@ -56,6 +56,7 @@ export interface VoiceBroadcastInfoEventContent {
|
||||||
device_id: string;
|
device_id: string;
|
||||||
state: VoiceBroadcastInfoState;
|
state: VoiceBroadcastInfoState;
|
||||||
chunk_length?: number;
|
chunk_length?: number;
|
||||||
|
last_chunk_sequence?: number;
|
||||||
["m.relates_to"]?: {
|
["m.relates_to"]?: {
|
||||||
rel_type: RelationType;
|
rel_type: RelationType;
|
||||||
event_id: string;
|
event_id: string;
|
||||||
|
|
|
@ -21,6 +21,7 @@ import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"
|
||||||
import {
|
import {
|
||||||
ChunkRecordedPayload,
|
ChunkRecordedPayload,
|
||||||
createVoiceBroadcastRecorder,
|
createVoiceBroadcastRecorder,
|
||||||
|
VoiceBroadcastInfoEventContent,
|
||||||
VoiceBroadcastInfoEventType,
|
VoiceBroadcastInfoEventType,
|
||||||
VoiceBroadcastInfoState,
|
VoiceBroadcastInfoState,
|
||||||
VoiceBroadcastRecorder,
|
VoiceBroadcastRecorder,
|
||||||
|
@ -207,11 +208,12 @@ export class VoiceBroadcastRecording
|
||||||
{
|
{
|
||||||
device_id: this.client.getDeviceId(),
|
device_id: this.client.getDeviceId(),
|
||||||
state,
|
state,
|
||||||
|
last_chunk_sequence: this.sequence,
|
||||||
["m.relates_to"]: {
|
["m.relates_to"]: {
|
||||||
rel_type: RelationType.Reference,
|
rel_type: RelationType.Reference,
|
||||||
event_id: this.infoEvent.getId(),
|
event_id: this.infoEvent.getId(),
|
||||||
},
|
},
|
||||||
},
|
} as VoiceBroadcastInfoEventContent,
|
||||||
this.client.getUserId(),
|
this.client.getUserId(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,20 +92,20 @@ describe("VoiceBroadcastRecording", () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const itShouldSendAnInfoEvent = (state: VoiceBroadcastInfoState) => {
|
const itShouldSendAnInfoEvent = (state: VoiceBroadcastInfoState, lastChunkSequence: number) => {
|
||||||
it(`should send a ${state} info event`, () => {
|
it(`should send a ${state} info event`, () => {
|
||||||
expect(client.sendStateEvent).toHaveBeenCalledWith(
|
expect(client.sendStateEvent).toHaveBeenCalledWith(
|
||||||
roomId,
|
roomId,
|
||||||
VoiceBroadcastInfoEventType,
|
VoiceBroadcastInfoEventType,
|
||||||
{
|
{
|
||||||
|
|
||||||
device_id: client.getDeviceId(),
|
device_id: client.getDeviceId(),
|
||||||
state,
|
state,
|
||||||
|
last_chunk_sequence: lastChunkSequence,
|
||||||
["m.relates_to"]: {
|
["m.relates_to"]: {
|
||||||
rel_type: RelationType.Reference,
|
rel_type: RelationType.Reference,
|
||||||
event_id: infoEvent.getId(),
|
event_id: infoEvent.getId(),
|
||||||
},
|
},
|
||||||
},
|
} as VoiceBroadcastInfoEventContent,
|
||||||
client.getUserId(),
|
client.getUserId(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -203,22 +203,7 @@ describe("VoiceBroadcastRecording", () => {
|
||||||
voiceBroadcastRecording.stop();
|
voiceBroadcastRecording.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should send a stopped Voice Broadcast Info event", () => {
|
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Stopped, 1);
|
||||||
expect(mocked(client.sendStateEvent)).toHaveBeenCalledWith(
|
|
||||||
roomId,
|
|
||||||
VoiceBroadcastInfoEventType,
|
|
||||||
{
|
|
||||||
device_id: client.getDeviceId(),
|
|
||||||
state: VoiceBroadcastInfoState.Stopped,
|
|
||||||
["m.relates_to"]: {
|
|
||||||
rel_type: RelationType.Reference,
|
|
||||||
event_id: infoEvent.getId(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
client.getUserId(),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
itShouldBeInState(VoiceBroadcastInfoState.Stopped);
|
itShouldBeInState(VoiceBroadcastInfoState.Stopped);
|
||||||
|
|
||||||
it("should emit a stopped state changed event", () => {
|
it("should emit a stopped state changed event", () => {
|
||||||
|
@ -383,7 +368,7 @@ describe("VoiceBroadcastRecording", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
itShouldBeInState(VoiceBroadcastInfoState.Paused);
|
itShouldBeInState(VoiceBroadcastInfoState.Paused);
|
||||||
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Paused);
|
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Paused, 1);
|
||||||
|
|
||||||
it("should stop the recorder", () => {
|
it("should stop the recorder", () => {
|
||||||
expect(mocked(voiceBroadcastRecorder.stop)).toHaveBeenCalled();
|
expect(mocked(voiceBroadcastRecorder.stop)).toHaveBeenCalled();
|
||||||
|
@ -424,7 +409,7 @@ describe("VoiceBroadcastRecording", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
itShouldBeInState(VoiceBroadcastInfoState.Resumed);
|
itShouldBeInState(VoiceBroadcastInfoState.Resumed);
|
||||||
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Resumed);
|
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Resumed, 1);
|
||||||
|
|
||||||
it("should start the recorder", () => {
|
it("should start the recorder", () => {
|
||||||
expect(mocked(voiceBroadcastRecorder.start)).toHaveBeenCalled();
|
expect(mocked(voiceBroadcastRecorder.start)).toHaveBeenCalled();
|
||||||
|
|
Loading…
Reference in New Issue