Skip to content

Commit

Permalink
Recording initiator (jitsi#393)
Browse files Browse the repository at this point in the history
* Fixes source code columns limit.

* Stores and sends initiator/terminator for jibri-status updates.

Sends information to clients who started or stopped a recording or live
streaming.

* Updates jitsi-xmpp-extensions dependency.
  • Loading branch information
damencho authored Oct 3, 2019
1 parent ff5e795 commit 99c77d7
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 52 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jitsi-xmpp-extensions</artifactId>
<version>1.0-2-g6624b3a</version>
<version>1.0-3-gf1ce0d7</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,17 +782,20 @@ public void sendIqWithResponseCallback(
long timeout)
throws NotConnectedException, InterruptedException
{
connection.sendIqWithResponseCallback(iq, stanzaListener, exceptionCallback, timeout);
connection.sendIqWithResponseCallback(
iq, stanzaListener, exceptionCallback, timeout);
}

@Override
public IQRequestHandler registerIQRequestHandler(IQRequestHandler handler)
public IQRequestHandler registerIQRequestHandler(
IQRequestHandler handler)
{
return connection.registerIQRequestHandler(handler);
}

@Override
public IQRequestHandler unregisterIQRequestHandler(IQRequestHandler handler)
public IQRequestHandler unregisterIQRequestHandler(
IQRequestHandler handler)
{
return connection.unregisterIQRequestHandler(handler);
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/jitsi/jicofo/JitsiMeetGlobalConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,17 @@ private void init(ConfigurationService configService)
logger.warn("Jibri PENDING timeouts are disabled");
}

numJibriRetries = configService.getInt(NUM_JIBRI_RETRIES_PNAME, DEFAULT_NUM_JIBRI_RETRIES);
numJibriRetries = configService.getInt(
NUM_JIBRI_RETRIES_PNAME, DEFAULT_NUM_JIBRI_RETRIES);
if (numJibriRetries >= 0)
{
logger.info("Will attempt a maximum of " + numJibriRetries +
" Jibri retries after failure");
}
else
{
logger.info("Will retry Jibri requests infinitely (if a Jibri is available)");
logger.info("Will retry Jibri requests infinitely "
+ "(if a Jibri is available)");
}

singleParticipantTimeout
Expand Down Expand Up @@ -296,7 +298,8 @@ public int getJibriPendingTimeout()
}

/**
* Tells how many retry attempts we'll make for a Jibri request when a Jibri fails
* Tells how many retry attempts we'll make for a Jibri request when
* a Jibri fails
* @return the amount of retry attempts we'll make for a Jibri request when
* a Jibri fails
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ final synchronized IQ handleIQRequest(JibriIq iq)
else if (JibriIq.Action.STOP.equals(action) &&
jibriSession != null)
{
jibriSession.stop();
jibriSession.stop(iq.getFrom());
return IQ.createResultIQ(iq);
}

Expand Down
45 changes: 33 additions & 12 deletions src/main/java/org/jitsi/jicofo/recording/jibri/JibriRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void dispose()
{
if (this.jibriSession != null)
{
this.jibriSession.stop();
this.jibriSession.stop(null);
this.jibriSession = null;
}

Expand Down Expand Up @@ -139,6 +139,7 @@ protected IQ handleStartRequest(JibriIq iq)
= new JibriSession(
this,
conference.getRoomName(),
iq.getFrom(),
globalConfig.getJibriPendingTimeout(),
globalConfig.getNumJibriRetries(),
connection,
Expand All @@ -156,13 +157,17 @@ protected IQ handleStartRequest(JibriIq iq)
ErrorIQ errorIq;
if (jibriDetector.isAnyInstanceConnected())
{
logger.info("Failed to start a Jibri session, all Jibris were busy");
errorIq = IQ.createErrorResponse(iq, XMPPError.Condition.resource_constraint);
logger.info("Failed to start a Jibri session, " +
"all Jibris were busy");
errorIq = IQ.createErrorResponse(
iq, XMPPError.Condition.resource_constraint);
}
else
{
logger.info("Failed to start a Jibri session, no Jibris available");
errorIq = IQ.createErrorResponse(iq, XMPPError.Condition.service_unavailable);
logger.info("Failed to start a Jibri session, " +
"no Jibris available");
errorIq = IQ.createErrorResponse(
iq, XMPPError.Condition.service_unavailable);
}
jibriSession = null;
return errorIq;
Expand Down Expand Up @@ -203,7 +208,9 @@ else if (emptyStreamId && recordingMode.equals(RecordingMode.STREAM))
*/
@Override
public void onSessionStateChanged(
JibriSession jibriSession, JibriIq.Status newStatus, JibriIq.FailureReason failureReason)
JibriSession jibriSession,
JibriIq.Status newStatus,
JibriIq.FailureReason failureReason)
{
if (this.jibriSession != jibriSession)
{
Expand All @@ -222,19 +229,32 @@ public void onSessionStateChanged(
private void publishJibriRecordingStatus(
JibriIq.Status newStatus, JibriIq.FailureReason failureReason)
{
logger.info("Got jibri status " + newStatus + " and failure " + failureReason);
logger.info(
"Got jibri status " + newStatus + " and failure " + failureReason);
if (jibriSession == null)
{
// It's possible back-to-back 'stop' requests could be received, and while processing
// the result of the first we set jibriSession to null, so in the processing
// of the second one it will already be null.
logger.info("Jibri session was already cleaned up, not sending new status");
// It's possible back-to-back 'stop' requests could be received,
// and while processing the result of the first we set jibriSession
// to null, so in the processing of the second one it will already
// be null.
logger.info(
"Jibri session was already cleaned up, not sending new status");
return;
}
RecordingStatus recordingStatus = new RecordingStatus();
recordingStatus.setStatus(newStatus);
recordingStatus.setFailureReason(failureReason);
recordingStatus.setSessionId(jibriSession.getSessionId());

if (JibriIq.Status.ON.equals(newStatus))
{
recordingStatus.setInitiator(jibriSession.getInitiator());
}
else if (JibriIq.Status.OFF.equals(newStatus))
{
recordingStatus.setInitiator(jibriSession.getTerminator());
}

JibriIq.RecordingMode recordingMode = jibriSession.getRecordingMode();
if (recordingMode != RecordingMode.UNDEFINED)
{
Expand All @@ -243,7 +263,8 @@ private void publishJibriRecordingStatus(

logger.info(
"Publishing new jibri-recording-status: "
+ recordingStatus.toXML() + " in: " + conference.getRoomName());
+ recordingStatus.toXML()
+ " in: " + conference.getRoomName());

ChatRoom2 chatRoom2 = conference.getChatRoom();

Expand Down
Loading

0 comments on commit 99c77d7

Please sign in to comment.