idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
130,200
public static List < String > getRemoteAddresses ( HttpServletRequest request ) { List < String > addresses = new ArrayList < String > ( ) ; addresses . add ( request . getRemoteHost ( ) ) ; if ( ! request . getRemoteAddr ( ) . equals ( request . getRemoteHost ( ) ) ) { addresses . add ( request . getRemoteAddr ( ) ) ;...
Return all remote addresses that were involved in the passed request .
130,201
public Invoke duplicate ( ) throws IOException , ClassNotFoundException { Invoke result = new Invoke ( ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( baos ) ; writeExternal ( oos ) ; oos . close ( ) ; byte [ ] buf = baos . toByteArray ( ) ; baos . clos...
Duplicate this Invoke message to future injection . Serialize to memory and deserialize safe way .
130,202
public void addTask ( ReceivedMessageTask task ) { tasks . add ( task ) ; Packet packet = task . getPacket ( ) ; if ( packet . getExpirationTime ( ) > 0L ) { task . runDeadlockFuture ( new DeadlockGuard ( task ) ) ; } if ( listener != null ) { listener . onTaskAdded ( this ) ; } }
Adds new task to the end of the queue .
130,203
public void removeTask ( ReceivedMessageTask task ) { if ( tasks . remove ( task ) ) { task . cancelDeadlockFuture ( ) ; if ( listener != null ) { listener . onTaskRemoved ( this ) ; } } }
Removes the specified task from the queue .
130,204
public ReceivedMessageTask getTaskToProcess ( ) { ReceivedMessageTask task = tasks . peek ( ) ; if ( task != null && task . setProcessing ( ) ) { return task ; } return null ; }
Gets first task from queue if it can be processed . If first task is already in process it returns null .
130,205
public static SimplePlayItem build ( String name , long start , long length ) { SimplePlayItem playItem = new SimplePlayItem ( name , start , length ) ; return playItem ; }
Builder for SimplePlayItem
130,206
protected String getHostname ( String url ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "getHostname - url: {}" , url ) ; } String [ ] parts = url . split ( "/" ) ; if ( parts . length == 2 ) { return "" ; } else { String host = parts [ 2 ] ; if ( host . endsWith ( ":1935" ) ) { return host . substring ( 0 , host...
Return hostname for URL .
130,207
protected void handlePendingCallResult ( RTMPConnection conn , Invoke invoke ) { final IServiceCall call = invoke . getCall ( ) ; final IPendingServiceCall pendingCall = conn . retrievePendingCall ( invoke . getTransactionId ( ) ) ; if ( pendingCall != null ) { Object [ ] args = call . getArguments ( ) ; if ( args != n...
Handler for pending call result . Dispatches results to all pending call handlers .
130,208
protected void onStreamBytesRead ( RTMPConnection conn , Channel channel , Header source , BytesRead streamBytesRead ) { conn . receivedBytesRead ( streamBytesRead . getBytesRead ( ) ) ; }
Stream bytes read event handler .
130,209
public void close ( ) { if ( closed . compareAndSet ( false , true ) ) { if ( livePipe != null ) { livePipe . unsubscribe ( ( IProvider ) this ) ; } if ( recordingListener != null ) { sendRecordStopNotify ( ) ; notifyRecordingStop ( ) ; recordingListener . get ( ) . stop ( ) ; } sendPublishStopNotify ( ) ; if ( connMsg...
Closes stream unsubscribes provides sends stoppage notifications and broadcast close notification .
130,210
public void setPublishedName ( String name ) { if ( StringUtils . isNotEmpty ( name ) && ! "false" . equals ( name ) ) { this . publishedName = name ; registerJMX ( ) ; } }
Setter for stream published name
130,211
private void notifyBroadcastClose ( ) { final IStreamAwareScopeHandler handler = getStreamAwareHandler ( ) ; if ( handler != null ) { try { handler . streamBroadcastClose ( this ) ; } catch ( Throwable t ) { log . error ( "Error in notifyBroadcastClose" , t ) ; } } }
Notifies handler on stream broadcast close
130,212
private void notifyRecordingStop ( ) { IStreamAwareScopeHandler handler = getStreamAwareHandler ( ) ; if ( handler != null ) { try { handler . streamRecordStop ( this ) ; } catch ( Throwable t ) { log . error ( "Error in notifyRecordingStop" , t ) ; } } }
Notifies handler on stream recording stop
130,213
private void notifyBroadcastStart ( ) { IStreamAwareScopeHandler handler = getStreamAwareHandler ( ) ; if ( handler != null ) { try { handler . streamBroadcastStart ( this ) ; } catch ( Throwable t ) { log . error ( "Error in notifyBroadcastStart" , t ) ; } } IoBuffer buf = IoBuffer . allocate ( 256 ) ; buf . setAutoEx...
Notifies handler on stream broadcast start
130,214
private void notifyChunkSize ( ) { if ( chunkSize > 0 && livePipe != null ) { OOBControlMessage setChunkSize = new OOBControlMessage ( ) ; setChunkSize . setTarget ( "ConnectionConsumer" ) ; setChunkSize . setServiceName ( "chunkSize" ) ; if ( setChunkSize . getServiceParamMap ( ) == null ) { setChunkSize . setServiceP...
Send OOB control message with chunk size
130,215
public void onOOBControlMessage ( IMessageComponent source , IPipe pipe , OOBControlMessage oobCtrlMsg ) { String target = oobCtrlMsg . getTarget ( ) ; if ( "ClientBroadcastStream" . equals ( target ) ) { String serviceName = oobCtrlMsg . getServiceName ( ) ; if ( "chunkSize" . equals ( serviceName ) ) { chunkSize = ( ...
Out - of - band control message handler
130,216
public void saveAs ( String name , boolean isAppend ) throws IOException { IStreamCapableConnection conn = getConnection ( ) ; if ( conn == null ) { throw new IOException ( "Stream is no longer connected" ) ; } if ( recordingListener == null ) { IRecordingListener listener = new RecordingListener ( ) ; if ( listener . ...
Save broadcasted stream .
130,217
private void sendPublishStartNotify ( ) { Status publishStatus = new Status ( StatusCodes . NS_PUBLISH_START ) ; publishStatus . setClientid ( getStreamId ( ) ) ; publishStatus . setDetails ( getPublishedName ( ) ) ; StatusMessage startMsg = new StatusMessage ( ) ; startMsg . setBody ( publishStatus ) ; pushMessage ( s...
Sends publish start notifications
130,218
private void sendPublishStopNotify ( ) { Status stopStatus = new Status ( StatusCodes . NS_UNPUBLISHED_SUCCESS ) ; stopStatus . setClientid ( getStreamId ( ) ) ; stopStatus . setDetails ( getPublishedName ( ) ) ; StatusMessage stopMsg = new StatusMessage ( ) ; stopMsg . setBody ( stopStatus ) ; pushMessage ( stopMsg ) ...
Sends publish stop notifications
130,219
private void sendRecordFailedNotify ( String reason ) { Status failedStatus = new Status ( StatusCodes . NS_RECORD_FAILED ) ; failedStatus . setLevel ( Status . ERROR ) ; failedStatus . setClientid ( getStreamId ( ) ) ; failedStatus . setDetails ( getPublishedName ( ) ) ; failedStatus . setDesciption ( reason ) ; Statu...
Sends record failed notifications
130,220
private void sendRecordStartNotify ( ) { Status recordStatus = new Status ( StatusCodes . NS_RECORD_START ) ; recordStatus . setClientid ( getStreamId ( ) ) ; recordStatus . setDetails ( getPublishedName ( ) ) ; StatusMessage startMsg = new StatusMessage ( ) ; startMsg . setBody ( recordStatus ) ; pushMessage ( startMs...
Sends record start notifications
130,221
private void sendRecordStopNotify ( ) { Status stopStatus = new Status ( StatusCodes . NS_RECORD_STOP ) ; stopStatus . setClientid ( getStreamId ( ) ) ; stopStatus . setDetails ( getPublishedName ( ) ) ; StatusMessage stopMsg = new StatusMessage ( ) ; stopMsg . setBody ( stopStatus ) ; pushMessage ( stopMsg ) ; }
Sends record stop notifications
130,222
protected void pushMessage ( StatusMessage msg ) { if ( connMsgOut != null ) { try { connMsgOut . pushMessage ( msg ) ; } catch ( IOException err ) { log . error ( "Error while pushing message: {}" , msg , err ) ; } } else { log . warn ( "Consumer message output is null" ) ; } }
Pushes a message out to a consumer .
130,223
public void start ( ) { checkVideoCodec = true ; checkAudioCodec = true ; firstPacketTime = - 1 ; latestTimeStamp = - 1 ; bytesReceived = 0 ; IConsumerService consumerManager = ( IConsumerService ) getScope ( ) . getContext ( ) . getBean ( IConsumerService . KEY ) ; connMsgOut = consumerManager . getConsumerOutput ( th...
Starts stream creates pipes connects
130,224
public void stopRecording ( ) { IRecordingListener listener = null ; if ( recordingListener != null && ( listener = recordingListener . get ( ) ) . isRecording ( ) ) { sendRecordStopNotify ( ) ; notifyRecordingStop ( ) ; removeStreamListener ( listener ) ; listener . stop ( ) ; recordingListener . clear ( ) ; recording...
Stops any currently active recording .
130,225
private void processQueue ( ) { CachedEvent cachedEvent ; try { IRTMPEvent event = null ; RTMPMessage message = null ; cachedEvent = queue . poll ( ) ; if ( cachedEvent != null ) { final byte dataType = cachedEvent . getDataType ( ) ; IoBuffer buffer = cachedEvent . getData ( ) ; int bufferLimit = buffer . limit ( ) ; ...
Process the queued items .
130,226
protected String getKey ( String hostName , String contextPath ) { return String . format ( "%s/%s" , ( hostName == null ? EMPTY : hostName ) , ( contextPath == null ? EMPTY : contextPath ) ) ; }
Return scope key . Scope key consists of host name concatenated with context path by slash symbol
130,227
public IGlobalScope lookupGlobal ( String hostName , String contextPath ) { log . trace ( "{}" , this ) ; log . debug ( "Lookup global scope - host name: {} context path: {}" , hostName , contextPath ) ; String key = getKey ( hostName , contextPath ) ; while ( contextPath . indexOf ( SLASH ) != - 1 ) { key = getKey ( h...
Does global scope lookup for host name and context path
130,228
public IGlobalScope getGlobal ( String name ) { if ( name == null ) { return null ; } return globals . get ( name ) ; }
Return global scope by name
130,229
public void registerGlobal ( IGlobalScope scope ) { log . trace ( "Registering global scope: {}" , scope . getName ( ) , scope ) ; globals . put ( scope . getName ( ) , scope ) ; }
Register global scope
130,230
public boolean removeMapping ( String hostName , String contextPath ) { log . info ( "Remove mapping host: {} context: {}" , hostName , contextPath ) ; final String key = getKey ( hostName , contextPath ) ; log . debug ( "Remove mapping: {}" , key ) ; return ( mapping . remove ( key ) != null ) ; }
Remove mapping with given key
130,231
public void connect ( IConnection conn ) { if ( conn instanceof RTMPConnection ) { if ( ! isConnected ( ) ) { source = conn ; SharedObjectMessage msg = new SharedObjectMessage ( name , 0 , isPersistent ( ) ) ; msg . addEvent ( new SharedObjectEvent ( Type . SERVER_CONNECT , null , null ) ) ; Channel c = ( ( RTMPConnect...
Connect the shared object using the passed connection .
130,232
protected void notifyUpdate ( String key , Object value ) { for ( ISharedObjectListener listener : listeners ) { listener . onSharedObjectUpdate ( this , key , value ) ; } }
Notify listeners on update
130,233
protected void notifyUpdate ( String key , Map < String , Object > value ) { if ( value . size ( ) == 1 ) { Map . Entry < String , Object > entry = value . entrySet ( ) . iterator ( ) . next ( ) ; notifyUpdate ( entry . getKey ( ) , entry . getValue ( ) ) ; return ; } for ( ISharedObjectListener listener : listeners ) ...
Notify listeners on map attribute update
130,234
protected void notifySendMessage ( String method , List < ? > params ) { for ( ISharedObjectListener listener : listeners ) { listener . onSharedObjectSend ( this , method , params ) ; } }
Broadcast send event to listeners
130,235
private Object getServiceHandler ( IScope scope , String serviceName ) { Object service = scope . getHandler ( ) ; if ( serviceName == null || serviceName . equals ( "" ) ) { log . trace ( "No service requested, return application scope handler: {}" , service ) ; return service ; } for ( IServiceResolver resolver : ser...
Lookup a handler for the passed service name in the given scope .
130,236
private void sendSOCreationFailed ( RTMPConnection conn , SharedObjectMessage message ) { log . debug ( "sendSOCreationFailed - message: {} conn: {}" , message , conn ) ; message . reset ( ) ; message . addEvent ( new SharedObjectEvent ( ISharedObjectEvent . Type . CLIENT_STATUS , "error" , SO_CREATION_FAILED ) ) ; if ...
Create and send SO message stating that a SO could not be created .
130,237
public void setResult ( Object result ) { if ( resultSent ) { throw new RuntimeException ( "You can only set the result once." ) ; } this . resultSent = true ; Channel channel = this . channel . get ( ) ; if ( channel == null ) { log . warn ( "The client is no longer connected." ) ; return ; } call . setResult ( result...
Set the result of a method call and send to the caller .
130,238
public void pushMessage ( IMessage message ) throws IOException { if ( log . isDebugEnabled ( ) ) { log . debug ( "pushMessage: {} to {} consumers" , message , consumers . size ( ) ) ; } for ( IConsumer consumer : consumers ) { try { ( ( IPushableConsumer ) consumer ) . pushMessage ( this , message ) ; } catch ( Throwa...
Pushes a message out to all the PushableConsumers .
130,239
public boolean subscribe ( IConsumer consumer , Map < String , Object > paramMap ) { boolean success = consumers . addIfAbsent ( consumer ) ; if ( success && consumer instanceof IPipeConnectionListener ) { listeners . addIfAbsent ( ( IPipeConnectionListener ) consumer ) ; } return success ; }
Connect consumer to this pipe . Doesn t allow to connect one consumer twice . Does register event listeners if instance of IPipeConnectionListener is given .
130,240
public boolean subscribe ( IProvider provider , Map < String , Object > paramMap ) { boolean success = providers . addIfAbsent ( provider ) ; if ( success && provider instanceof IPipeConnectionListener ) { listeners . addIfAbsent ( ( IPipeConnectionListener ) provider ) ; } return success ; }
Connect provider to this pipe . Doesn t allow to connect one provider twice . Does register event listeners if instance of IPipeConnectionListener is given .
130,241
@ SuppressWarnings ( "unlikely-arg-type" ) public boolean unsubscribe ( IProvider provider ) { if ( providers . remove ( provider ) ) { fireProviderConnectionEvent ( provider , PipeConnectionEvent . EventType . PROVIDER_DISCONNECT , null ) ; listeners . remove ( provider ) ; return true ; } return false ; }
Disconnects provider from this pipe . Fires pipe connection event .
130,242
@ SuppressWarnings ( "unlikely-arg-type" ) public boolean unsubscribe ( IConsumer consumer ) { if ( consumers . remove ( consumer ) ) { fireConsumerConnectionEvent ( consumer , PipeConnectionEvent . EventType . CONSUMER_DISCONNECT , null ) ; listeners . remove ( consumer ) ; return true ; } return false ; }
Disconnects consumer from this pipe . Fires pipe connection event .
130,243
protected void fireConsumerConnectionEvent ( IConsumer consumer , PipeConnectionEvent . EventType type , Map < String , Object > paramMap ) { firePipeConnectionEvent ( PipeConnectionEvent . build ( this , type , consumer , paramMap ) ) ; }
Broadcast consumer connection event
130,244
protected void fireProviderConnectionEvent ( IProvider provider , PipeConnectionEvent . EventType type , Map < String , Object > paramMap ) { firePipeConnectionEvent ( PipeConnectionEvent . build ( this , type , provider , paramMap ) ) ; }
Broadcast provider connection event
130,245
protected void firePipeConnectionEvent ( PipeConnectionEvent event ) { for ( IPipeConnectionListener element : listeners ) { try { element . onPipeConnectionEvent ( event ) ; } catch ( Throwable t ) { log . error ( "Exception when handling pipe connection event" , t ) ; } } if ( taskExecutor == null ) { taskExecutor = ...
Fire any pipe connection event and run all it s tasks
130,246
public void close ( ) { if ( consumers != null ) { consumers . clear ( ) ; consumers = null ; } if ( providers != null ) { providers . clear ( ) ; providers = null ; } if ( listeners != null ) { listeners . clear ( ) ; listeners = null ; } }
Close the pipe
130,247
public static IAudioStreamCodec getAudioCodec ( IoBuffer data ) { IAudioStreamCodec result = null ; try { int codecId = ( data . get ( ) & 0xf0 ) >> 4 ; switch ( codecId ) { case 10 : result = ( IAudioStreamCodec ) Class . forName ( "org.red5.codec.AACAudio" ) . newInstance ( ) ; break ; case 11 : result = ( IAudioStre...
Create and return new audio codec applicable for byte buffer data
130,248
public static void setConnectionLocal ( IConnection connection ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Set connection: {} with thread: {}" , ( connection != null ? connection . getSessionId ( ) : null ) , Thread . currentThread ( ) . getName ( ) ) ; try { StackTraceElement [ ] stackTraceElements = Thread ....
Setter for connection
130,249
public static IConnection getConnectionLocal ( ) { WeakReference < IConnection > ref = connThreadLocal . get ( ) ; if ( ref != null ) { IConnection connection = ref . get ( ) ; log . debug ( "Get connection: {} on thread: {}" , ( connection != null ? connection . getSessionId ( ) : null ) , Thread . currentThread ( ) ....
Get the connection associated with the current thread . This method allows you to get connection object local to current thread . When you need to get a connection associated with event handler and so forth this method provides you with it .
130,250
protected String getObjectName ( String id ) { String result = id . substring ( id . lastIndexOf ( '/' ) + 1 ) ; if ( result . equals ( PERSISTENCE_NO_NAME ) ) { result = null ; } return result ; }
Get resource name from path . The format of the object id is
130,251
protected String getObjectPath ( String id , String name ) { id = id . substring ( id . indexOf ( '/' ) + 1 ) ; if ( id . charAt ( 0 ) == '/' ) { id = id . substring ( 1 ) ; } if ( id . lastIndexOf ( name ) <= 0 ) { return id ; } return id . substring ( 0 , id . lastIndexOf ( name ) - 1 ) ; }
Get object path for given id and name . The format of the object id is
130,252
protected String getObjectId ( IPersistable object ) { String result = object . getType ( ) ; if ( object . getPath ( ) . charAt ( 0 ) != '/' ) { result += '/' ; } result += object . getPath ( ) ; if ( ! result . endsWith ( "/" ) ) { result += '/' ; } String name = object . getName ( ) ; if ( name == null ) { name = PE...
Get object id
130,253
public boolean connect ( IScope newScope , Object [ ] params ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Connect Params: {}" , params ) ; if ( params != null ) { for ( Object e : params ) { log . debug ( "Param: {}" , e ) ; } } } scope = ( Scope ) newScope ; return scope . connect ( this , params ) ; }
Connect to another scope on server with given parameters
130,254
public void unregisterBasicScope ( IBasicScope basicScope ) { if ( basicScope instanceof IBroadcastScope || basicScope instanceof SharedObjectScope ) { basicScopes . remove ( basicScope ) ; basicScope . removeEventListener ( this ) ; } }
Unregister basic scope
130,255
public boolean isValid ( ) { return ( type != null && ! type . equals ( ScopeType . UNDEFINED ) && ( name != null && ! ( "" ) . equals ( name ) ) ) ; }
Validates a scope based on its name and type
130,256
public boolean addEventListener ( IEventListener listener ) { log . debug ( "addEventListener - scope: {} {}" , getName ( ) , listener ) ; return listeners . add ( listener ) ; }
Add event listener to list of notified objects
130,257
public boolean removeEventListener ( IEventListener listener ) { log . debug ( "removeEventListener - scope: {} {}" , getName ( ) , listener ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Listeners - check #1: {}" , listeners ) ; } boolean removed = listeners . remove ( listener ) ; if ( ! keepOnDisconnect ) { if...
Remove event listener from list of listeners
130,258
public void checkBandwidth ( Object o ) { IClient client = Red5 . getConnectionLocal ( ) . getClient ( ) ; if ( client != null ) { client . checkBandwidth ( ) ; } }
Calls the checkBandwidth method on the current client .
130,259
public Map < String , Object > checkBandwidthUp ( Object [ ] params ) { IClient client = Red5 . getConnectionLocal ( ) . getClient ( ) ; if ( client != null ) { return client . checkBandwidthUp ( params ) ; } return null ; }
Calls the checkBandwidthUp method on the current client .
130,260
public boolean createChildScope ( String name ) { if ( ! scope . hasChildScope ( name ) ) { return scope . createChildScope ( name ) ; } return false ; }
Creates child scope
130,261
public Notify duplicate ( ) throws IOException , ClassNotFoundException { Notify result = new Notify ( ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( baos ) ; writeExternal ( oos ) ; oos . close ( ) ; byte [ ] buf = baos . toByteArray ( ) ; baos . clos...
Duplicate this Notify message to future injection Serialize to memory and deserialize safe way .
130,262
private final void connectToProvider ( String itemName ) { log . debug ( "Attempting connection to {}" , itemName ) ; IMessageInput in = msgInReference . get ( ) ; if ( in == null ) { in = providerService . getLiveProviderInput ( subscriberStream . getScope ( ) , itemName , true ) ; msgInReference . set ( in ) ; } if (...
Connects to the data provider .
130,263
public void pause ( int position ) throws IllegalStateException { switch ( subscriberStream . getState ( ) ) { case PLAYING : case STOPPED : subscriberStream . setState ( StreamState . PAUSED ) ; clearWaitJobs ( ) ; sendPauseStatus ( currentItem . get ( ) ) ; sendClearPing ( ) ; subscriberStream . onChange ( StreamStat...
Pause at position
130,264
public void seek ( int position ) throws IllegalStateException , OperationNotSupportedException { pendingOperations . add ( new SeekRunnable ( position ) ) ; cancelDeferredStop ( ) ; ensurePullAndPushRunning ( ) ; }
Seek to a given position
130,265
private boolean okayToSendMessage ( IRTMPEvent message ) { if ( message instanceof IStreamData ) { final long now = System . currentTimeMillis ( ) ; if ( isClientBufferFull ( now ) ) { return false ; } long pending = pendingMessages ( ) ; if ( bufferCheckInterval > 0 && now >= nextCheckBufferUnderrun ) { if ( pending >...
Check if it s okay to send the client more data . This takes the configured bandwidth as well as the requested client buffer into account .
130,266
private boolean isClientBufferFull ( final long now ) { if ( lastMessageTs > 0 ) { final long delta = now - playbackStart ; final long buffer = subscriberStream . getClientBufferDuration ( ) ; final long buffered = lastMessageTs - delta ; log . trace ( "isClientBufferFull: timestamp {} delta {} buffered {} buffer durat...
Estimate client buffer fill .
130,267
private void ensurePullAndPushRunning ( ) { log . trace ( "State should be PLAYING to running this task: {}" , subscriberStream . getState ( ) ) ; if ( pullMode && pullAndPush == null && subscriberStream . getState ( ) == StreamState . PLAYING ) { pullAndPush = subscriberStream . scheduleWithFixedDelay ( new PullAndPus...
Make sure the pull and push processing is running .
130,268
private void clearWaitJobs ( ) { log . debug ( "Clear wait jobs" ) ; if ( pullAndPush != null ) { subscriberStream . cancelJob ( pullAndPush ) ; releasePendingMessage ( ) ; pullAndPush = null ; } if ( waitLiveJob != null ) { schedulingService . removeScheduledJob ( waitLiveJob ) ; waitLiveJob = null ; } }
Clear all scheduled waiting jobs
130,269
private void doPushMessage ( Status status ) { StatusMessage message = new StatusMessage ( ) ; message . setBody ( status ) ; doPushMessage ( message ) ; }
Sends a status message .
130,270
private void doPushMessage ( AbstractMessage message ) { if ( log . isTraceEnabled ( ) ) { String msgType = message . getMessageType ( ) ; log . trace ( "doPushMessage: {}" , msgType ) ; } IMessageOutput out = msgOutReference . get ( ) ; if ( out != null ) { try { out . pushMessage ( message ) ; if ( message instanceof...
Send message to output stream and handle exceptions .
130,271
private void sendMessage ( RTMPMessage messageIn ) { IRTMPEvent eventIn = messageIn . getBody ( ) ; IRTMPEvent event ; switch ( eventIn . getDataType ( ) ) { case Constants . TYPE_AGGREGATE : event = new Aggregate ( ( ( Aggregate ) eventIn ) . getData ( ) ) ; break ; case Constants . TYPE_AUDIO_DATA : event = new Audio...
Send an RTMP message
130,272
private void sendClearPing ( ) { Ping eof = new Ping ( ) ; eof . setEventType ( Ping . STREAM_PLAYBUFFER_CLEAR ) ; eof . setValue2 ( streamId ) ; RTMPMessage eofMsg = RTMPMessage . build ( eof ) ; doPushMessage ( eofMsg ) ; }
Send clear ping . Lets client know that stream has no more data to send .
130,273
private void sendReset ( ) { if ( pullMode ) { Ping recorded = new Ping ( ) ; recorded . setEventType ( Ping . RECORDED_STREAM ) ; recorded . setValue2 ( streamId ) ; RTMPMessage recordedMsg = RTMPMessage . build ( recorded ) ; doPushMessage ( recordedMsg ) ; } Ping begin = new Ping ( ) ; begin . setEventType ( Ping . ...
Send reset message
130,274
private void sendResetStatus ( IPlayItem item ) { Status reset = new Status ( StatusCodes . NS_PLAY_RESET ) ; reset . setClientid ( streamId ) ; reset . setDetails ( item . getName ( ) ) ; reset . setDesciption ( String . format ( "Playing and resetting %s." , item . getName ( ) ) ) ; doPushMessage ( reset ) ; }
Send reset status for item
130,275
private void sendStartStatus ( IPlayItem item ) { Status start = new Status ( StatusCodes . NS_PLAY_START ) ; start . setClientid ( streamId ) ; start . setDetails ( item . getName ( ) ) ; start . setDesciption ( String . format ( "Started playing %s." , item . getName ( ) ) ) ; doPushMessage ( start ) ; }
Send playback start status notification
130,276
private void sendStopStatus ( IPlayItem item ) { Status stop = new Status ( StatusCodes . NS_PLAY_STOP ) ; stop . setClientid ( streamId ) ; stop . setDesciption ( String . format ( "Stopped playing %s." , item . getName ( ) ) ) ; stop . setDetails ( item . getName ( ) ) ; doPushMessage ( stop ) ; }
Send playback stoppage status notification
130,277
private void sendOnPlayStatus ( String code , int duration , long bytes ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Sending onPlayStatus - code: {} duration: {} bytes: {}" , code , duration , bytes ) ; } IoBuffer buf = IoBuffer . allocate ( 102 ) ; buf . setAutoExpand ( true ) ; Output out = new Output ( buf )...
Sends an onPlayStatus message .
130,278
private void sendCompleteStatus ( ) { int duration = ( lastMessageTs > 0 ) ? Math . max ( 0 , lastMessageTs - streamStartTS . get ( ) ) : 0 ; if ( log . isDebugEnabled ( ) ) { log . debug ( "sendCompleteStatus - duration: {} bytes sent: {}" , duration , bytesSent . get ( ) ) ; } sendOnPlayStatus ( StatusCodes . NS_PLAY...
Send playlist complete status notification
130,279
private void sendSeekStatus ( IPlayItem item , int position ) { Status seek = new Status ( StatusCodes . NS_SEEK_NOTIFY ) ; seek . setClientid ( streamId ) ; seek . setDetails ( item . getName ( ) ) ; seek . setDesciption ( String . format ( "Seeking %d (stream ID: %d)." , position , streamId ) ) ; doPushMessage ( seek...
Send seek status notification
130,280
private void sendPauseStatus ( IPlayItem item ) { Status pause = new Status ( StatusCodes . NS_PAUSE_NOTIFY ) ; pause . setClientid ( streamId ) ; pause . setDetails ( item . getName ( ) ) ; doPushMessage ( pause ) ; }
Send pause status notification
130,281
private void sendResumeStatus ( IPlayItem item ) { Status resume = new Status ( StatusCodes . NS_UNPAUSE_NOTIFY ) ; resume . setClientid ( streamId ) ; resume . setDetails ( item . getName ( ) ) ; doPushMessage ( resume ) ; }
Send resume status notification
130,282
private void sendPublishedStatus ( IPlayItem item ) { Status published = new Status ( StatusCodes . NS_PLAY_PUBLISHNOTIFY ) ; published . setClientid ( streamId ) ; published . setDetails ( item . getName ( ) ) ; doPushMessage ( published ) ; }
Send published status notification
130,283
private void sendUnpublishedStatus ( IPlayItem item ) { Status unpublished = new Status ( StatusCodes . NS_PLAY_UNPUBLISHNOTIFY ) ; unpublished . setClientid ( streamId ) ; unpublished . setDetails ( item . getName ( ) ) ; doPushMessage ( unpublished ) ; }
Send unpublished status notification
130,284
private void sendStreamNotFoundStatus ( IPlayItem item ) { Status notFound = new Status ( StatusCodes . NS_PLAY_STREAMNOTFOUND ) ; notFound . setClientid ( streamId ) ; notFound . setLevel ( Status . ERROR ) ; notFound . setDetails ( item . getName ( ) ) ; doPushMessage ( notFound ) ; }
Stream not found status notification
130,285
private void sendInsufficientBandwidthStatus ( IPlayItem item ) { Status insufficientBW = new Status ( StatusCodes . NS_PLAY_INSUFFICIENT_BW ) ; insufficientBW . setClientid ( streamId ) ; insufficientBW . setLevel ( Status . WARNING ) ; insufficientBW . setDetails ( item . getName ( ) ) ; insufficientBW . setDesciptio...
Insufficient bandwidth notification
130,286
private void sendVODInitCM ( IPlayItem item ) { OOBControlMessage oobCtrlMsg = new OOBControlMessage ( ) ; oobCtrlMsg . setTarget ( IPassive . KEY ) ; oobCtrlMsg . setServiceName ( "init" ) ; Map < String , Object > paramMap = new HashMap < String , Object > ( 1 ) ; paramMap . put ( "startTS" , ( int ) item . getStart ...
Send VOD init control message
130,287
private int sendVODSeekCM ( int position ) { OOBControlMessage oobCtrlMsg = new OOBControlMessage ( ) ; oobCtrlMsg . setTarget ( ISeekableProvider . KEY ) ; oobCtrlMsg . setServiceName ( "seek" ) ; Map < String , Object > paramMap = new HashMap < String , Object > ( 1 ) ; paramMap . put ( "position" , position ) ; oobC...
Send VOD seek control message
130,288
private boolean sendCheckVideoCM ( ) { OOBControlMessage oobCtrlMsg = new OOBControlMessage ( ) ; oobCtrlMsg . setTarget ( IStreamTypeAwareProvider . KEY ) ; oobCtrlMsg . setServiceName ( "hasVideo" ) ; msgInReference . get ( ) . sendOOBControlMessage ( this , oobCtrlMsg ) ; if ( oobCtrlMsg . getResult ( ) instanceof B...
Send VOD check video control message
130,289
private long pendingVideoMessages ( ) { IMessageOutput out = msgOutReference . get ( ) ; if ( out != null ) { OOBControlMessage pendingRequest = new OOBControlMessage ( ) ; pendingRequest . setTarget ( "ConnectionConsumer" ) ; pendingRequest . setServiceName ( "pendingVideoCount" ) ; out . sendOOBControlMessage ( this ...
Get number of pending video messages
130,290
private void releasePendingMessage ( ) { if ( pendingMessage != null ) { IRTMPEvent body = pendingMessage . getBody ( ) ; if ( body instanceof IStreamData && ( ( IStreamData < ? > ) body ) . getData ( ) != null ) { ( ( IStreamData < ? > ) body ) . getData ( ) . free ( ) ; } pendingMessage = null ; } }
Releases pending message body nullifies pending message object
130,291
protected boolean checkSendMessageEnabled ( RTMPMessage message ) { IRTMPEvent body = message . getBody ( ) ; if ( ! receiveAudio && body instanceof AudioData ) { ( ( IStreamData < ? > ) body ) . getData ( ) . free ( ) ; if ( sendBlankAudio ) { sendBlankAudio = false ; body = new AudioData ( ) ; if ( lastMessageTs >= 0...
Check if sending the given message was enabled by the client .
130,292
private void runDeferredStop ( ) { clearWaitJobs ( ) ; log . trace ( "Ran deferred stop" ) ; if ( deferredStop == null ) { deferredStop = subscriberStream . scheduleWithFixedDelay ( new DeferredStopRunnable ( ) , 100 ) ; } }
Schedule a stop to be run from a separate thread to allow the background thread to stop cleanly .
130,293
protected void release ( BaseEvent event ) { Info info = events . get ( event ) ; if ( info != null ) { if ( info . refcount . decrementAndGet ( ) == 0 ) { events . remove ( event ) ; } } else { log . warn ( "Release called on already released event." ) ; } }
Release event if there s no more references to it
130,294
public static IScope resolveScope ( IScope from , String path ) { log . debug ( "resolveScope from: {} path: {}" , from . getName ( ) , path ) ; IScope current = from ; if ( path . startsWith ( SLASH ) ) { current = ScopeUtils . findRoot ( current ) ; path = path . substring ( 1 , path . length ( ) ) ; } if ( path . en...
Resolves scope for specified scope and path .
130,295
public static IScope findRoot ( IScope from ) { IScope current = from ; while ( current . hasParent ( ) ) { current = current . getParent ( ) ; } return current ; }
Finds root scope for specified scope object . Root scope is the top level scope among scope s parents .
130,296
public static IScope findApplication ( IScope from ) { IScope current = from ; while ( current . hasParent ( ) && ! current . getType ( ) . equals ( ScopeType . APPLICATION ) ) { current = current . getParent ( ) ; } return current ; }
Returns the application scope for specified scope . Application scope has depth of 1 and has no parent .
130,297
public static boolean isAncestor ( IBasicScope from , IBasicScope ancestor ) { IBasicScope current = from ; while ( current . hasParent ( ) ) { current = current . getParent ( ) ; if ( current . equals ( ancestor ) ) { return true ; } } return false ; }
Check whether one scope is an ancestor of another
130,298
protected static Object getScopeService ( IScope scope , String name ) { return getScopeService ( scope , name , null ) ; }
Returns scope service by bean name . See overloaded method for details .
130,299
private ChannelInfo getChannelInfo ( int channelId ) { ChannelInfo info = channels . putIfAbsent ( channelId , new ChannelInfo ( ) ) ; if ( info == null ) { info = channels . get ( channelId ) ; } return info ; }
Returns channel information for a given channel id .