aaa
This commit is contained in:
parent
7be882acbd
commit
c3b0f5675b
4 changed files with 757 additions and 730 deletions
|
@ -190,7 +190,7 @@ class Session(object):
|
|||
|
||||
await notify_mattserver_about_sessions()
|
||||
print(self.connection_id, "bye bye")
|
||||
self.ended = True
|
||||
self.ended = True
|
||||
|
||||
def create_peerconnection(self) -> None:
|
||||
self.pc = RTCPeerConnection()
|
||||
|
@ -240,6 +240,7 @@ class Session(object):
|
|||
except MediaStreamError as e:
|
||||
print(self.connection_id, e)
|
||||
await self.end()
|
||||
raise e
|
||||
if self.running:
|
||||
# Right, depending on the format, we may need to do some fuckery.
|
||||
# Jack expects all audio to be 32 bit floating point
|
||||
|
|
|
@ -21,6 +21,7 @@ export class WebRTCStreamer extends Streamer {
|
|||
}
|
||||
|
||||
async start(): Promise<void> {
|
||||
console.log("RTCStreamer start");
|
||||
this.pc = new RTCPeerConnection({
|
||||
iceServers: [
|
||||
{
|
||||
|
@ -52,6 +53,7 @@ export class WebRTCStreamer extends Streamer {
|
|||
};
|
||||
this.stream.getAudioTracks().forEach(track => this.pc!.addTrack(track));
|
||||
|
||||
console.log("PC created");
|
||||
this.ws = new WebSocket(process.env.REACT_APP_WS_URL!);
|
||||
this.ws.onopen = e => {
|
||||
console.log("WS open");
|
||||
|
@ -62,6 +64,7 @@ export class WebRTCStreamer extends Streamer {
|
|||
this.onStateChange(this.mapStateToConnectionState());
|
||||
};
|
||||
this.ws.addEventListener("message", this.onMessage.bind(this));
|
||||
console.log("WS created");
|
||||
}
|
||||
|
||||
async stop(): Promise<void> {
|
||||
|
|
|
@ -87,6 +87,16 @@ export const changeBroadcastSetting = <K extends keyof BroadcastState>(
|
|||
};
|
||||
|
||||
export const registerTimeslot = (): AppThunk => async (dispatch, getState) => {
|
||||
if (!getState().session.userCanBroadcast) {
|
||||
dispatch(
|
||||
NavbarState.showAlert({
|
||||
color: "warning",
|
||||
content: "You are not WebStudio Trained and cannot go live.",
|
||||
closure: 7000
|
||||
})
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (getState().broadcast.stage === "NOT_REGISTERED") {
|
||||
var state = getState().session;
|
||||
const memberid = state.currentUser?.memberid;
|
||||
|
@ -95,6 +105,7 @@ export const registerTimeslot = (): AppThunk => async (dispatch, getState) => {
|
|||
var sourceid = getState().broadcast.sourceID;
|
||||
try {
|
||||
var connID = await sendBroadcastRegister(timeslotid, memberid, sourceid);
|
||||
console.log(connID);
|
||||
if (connID !== undefined) {
|
||||
dispatch(broadcastState.actions.setConnID(connID["connid"]));
|
||||
dispatch(startStreaming());
|
||||
|
@ -227,19 +238,14 @@ export function sendTracklistStart(trackid: number): Promise<TrackListItem> {
|
|||
}
|
||||
|
||||
export const startStreaming = (): AppThunk => async (dispatch, getState) => {
|
||||
if (!getState().session.userCanBroadcast) {
|
||||
dispatch(
|
||||
NavbarState.showAlert({
|
||||
color: "warning",
|
||||
content: "You are not WebStudio Trained and cannot go live.",
|
||||
closure: 7000
|
||||
})
|
||||
);
|
||||
return;
|
||||
}
|
||||
console.log("starting streamer.");
|
||||
streamer = new WebRTCStreamer(MixerState.destination.stream);
|
||||
streamer.addConnectionStateListener(state => {
|
||||
dispatch(broadcastState.actions.setConnectionState(state));
|
||||
if (state === "CONNECTION_LOST") {
|
||||
// un-register if we drop, let the user manually reconnect
|
||||
dispatch(broadcastState.actions.setConnID(null));
|
||||
}
|
||||
});
|
||||
await streamer.start();
|
||||
};
|
||||
|
|
1455
src/mixer/state.ts
1455
src/mixer/state.ts
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue