org.red5.server.api.IContext Java Examples
The following examples show how to use
org.red5.server.api.IContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScopeUtils.java From red5-server-common with Apache License 2.0 | 6 votes |
/** * Returns scope services (e.g. SharedObject, etc) for the scope. Method uses either bean name passes as a string or class object. * * @param scope * The scope service belongs to * @param name * Bean name * @param defaultClass * Class of service * @return Service object */ protected static Object getScopeService(IScope scope, String name, Class<?> defaultClass) { if (scope != null) { final IContext context = scope.getContext(); ApplicationContext appCtx = context.getApplicationContext(); Object result; if (!appCtx.containsBean(name)) { if (defaultClass == null) { return null; } try { result = defaultClass.getDeclaredConstructor().newInstance(); } catch (Exception e) { log.error("{}", e); return null; } } else { result = appCtx.getBean(name); } return result; } return null; }
Example #2
Source File: RTMPHandler.java From red5-server-common with Apache License 2.0 | 6 votes |
/** * Remoting call invocation handler. * * @param conn * RTMP connection * @param call * Service call */ protected void invokeCall(RTMPConnection conn, IServiceCall call) { final IScope scope = conn.getScope(); if (scope != null) { if (scope.hasHandler()) { final IScopeHandler handler = scope.getHandler(); log.debug("Scope: {} handler: {}", scope, handler); if (!handler.serviceCall(conn, call)) { // XXX: What to do here? Return an error? log.warn("Scope: {} handler failed on service call", scope.getName(), new Exception("Service call failed")); return; } } final IContext context = scope.getContext(); log.debug("Context: {}", context); context.getServiceInvoker().invoke(call, scope); } else { log.warn("Scope was null for invoke: {} connection state: {}", call.getServiceMethodName(), conn.getStateCode()); } }
Example #3
Source File: SingleItemSubscriberStream.java From red5-server-common with Apache License 2.0 | 5 votes |
public void start() { //ensure the play engine exists if (engine == null) { IScope scope = getScope(); if (scope != null) { IContext ctx = scope.getContext(); if (ctx.hasBean(ISchedulingService.BEAN_NAME)) { schedulingService = (ISchedulingService) ctx.getBean(ISchedulingService.BEAN_NAME); } else { //try the parent schedulingService = (ISchedulingService) scope.getParent().getContext().getBean(ISchedulingService.BEAN_NAME); } IConsumerService consumerService = null; if (ctx.hasBean(IConsumerService.KEY)) { consumerService = (IConsumerService) ctx.getBean(IConsumerService.KEY); } else { //try the parent consumerService = (IConsumerService) scope.getParent().getContext().getBean(IConsumerService.KEY); } IProviderService providerService = null; if (ctx.hasBean(IProviderService.BEAN_NAME)) { providerService = (IProviderService) ctx.getBean(IProviderService.BEAN_NAME); } else { //try the parent providerService = (IProviderService) scope.getParent().getContext().getBean(IProviderService.BEAN_NAME); } engine = new PlayEngine.Builder(this, schedulingService, consumerService, providerService).build(); } else { log.info("Scope was null on start"); } } //set buffer check interval engine.setBufferCheckInterval(bufferCheckInterval); //set underrun trigger engine.setUnderrunTrigger(underrunTrigger); // Start playback engine engine.start(); // Notify subscribers on start onChange(StreamState.STARTED); }
Example #4
Source File: Scope.java From red5-server-common with Apache License 2.0 | 5 votes |
/** * Return scope context. If scope doesn't have context, parent's context is returns, and so forth. * * @return Scope context or parent context */ public IContext getContext() { if (!hasContext() && hasParent()) { //log.debug("returning parent context"); return parent.getContext(); } else { //log.debug("returning context"); return context; } }
Example #5
Source File: PlaylistSubscriberStream.java From red5-server-common with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ public void start() { //ensure the play engine exists if (engine == null) { IScope scope = getScope(); if (scope != null) { IContext ctx = scope.getContext(); if (ctx.hasBean(ISchedulingService.BEAN_NAME)) { schedulingService = (ISchedulingService) ctx.getBean(ISchedulingService.BEAN_NAME); } else { //try the parent schedulingService = (ISchedulingService) scope.getParent().getContext().getBean(ISchedulingService.BEAN_NAME); } IConsumerService consumerService = null; if (ctx.hasBean(IConsumerService.KEY)) { consumerService = (IConsumerService) ctx.getBean(IConsumerService.KEY); } else { //try the parent consumerService = (IConsumerService) scope.getParent().getContext().getBean(IConsumerService.KEY); } IProviderService providerService = null; if (ctx.hasBean(IProviderService.BEAN_NAME)) { providerService = (IProviderService) ctx.getBean(IProviderService.BEAN_NAME); } else { //try the parent providerService = (IProviderService) scope.getParent().getContext().getBean(IProviderService.BEAN_NAME); } engine = new PlayEngine.Builder(this, schedulingService, consumerService, providerService).build(); } else { throw new IllegalStateException("Scope was null on start playing"); } } //set buffer check interval engine.setBufferCheckInterval(bufferCheckInterval); //set underrun trigger engine.setUnderrunTrigger(underrunTrigger); // set the max pending video frames to the play engine engine.setMaxPendingVideoFrames(maxPendingVideoFrames); // set the max sequential pending video frames to the play engine engine.setMaxSequentialPendingVideoFrames(maxSequentialPendingVideoFrames); // Start playback engine engine.start(); // Notify subscribers on start onChange(StreamState.STARTED); }
Example #6
Source File: RTMPHandler.java From red5-server-common with Apache License 2.0 | 3 votes |
/** * Remoting call invocation handler. * * @param conn * RTMP connection * @param call * Service call * @param service * Server-side service object * @return true if the call was performed, otherwise false */ private boolean invokeCall(RTMPConnection conn, IServiceCall call, Object service) { final IScope scope = conn.getScope(); final IContext context = scope.getContext(); if (log.isTraceEnabled()) { log.trace("Scope: {} context: {} service: {}", scope, context, service); } return context.getServiceInvoker().invoke(call, service); }
Example #7
Source File: Application.java From red5-rtsp-restreamer with Apache License 2.0 | 3 votes |
public boolean appStart(IScope scope) { super.appStart(scope); output = new ICYStream("axis"); output.setScope(scope); input = new AxisTest(output); output.setVideoFramer(input); output.addStreamListener(this); streamer = new StreamingProxy(); streamer.init(); streamer.setApp("bwservice"); streamer.setHost("192.168.10.2"); streamer.setPort(1935); streamer.start("axisrecord" + System.currentTimeMillis() / 1000, "record", new Object[] {}); IContext context = scope.getContext(); IProviderService providerService = (IProviderService) context.getBean(IProviderService.BEAN_NAME); if (providerService.registerBroadcastStream(scope, output.getPublishedName(), output)) { IBroadcastScope bsScope = (BroadcastScope) providerService.getLiveProviderInput(scope, output.getPublishedName(), true); } Thread runner = new Thread(input); runner.start(); return true; }
Example #8
Source File: IScope.java From red5-server-common with Apache License 2.0 | 2 votes |
/** * Returns scope context * * @return Scope context */ public IContext getContext();
Example #9
Source File: StatefulScopeWrappingAdapter.java From red5-server-common with Apache License 2.0 | 2 votes |
/** * Getter for context * * @return Value for context */ public IContext getContext() { return scope.getContext(); }
Example #10
Source File: Scope.java From red5-server-common with Apache License 2.0 | 2 votes |
/** * Setter for context * * @param context * Context object */ public void setContext(IContext context) { log.debug("Set context: {}", context); this.context = context; }