/** * Connects client to the scope * * @param conn Client conneciton * @param scope Scope * @param params Params passed from client side with connect call * @return true if client was registred within scope, false otherwise */ public boolean connect(IConnection conn, IScope scope, Object[] params) { log.debug("Connect to core handler ?"); // Get session id String id = conn.getSessionId(); // Use client registry from scope the client connected to. IScope connectionScope = Red5.getConnectionLocal().getScope(); // Get client registry for connection scope IClientRegistry clientRegistry = connectionScope.getContext().getClientRegistry(); // Get client from registry by id or create a new one IClient client = clientRegistry.hasClient(id) ? clientRegistry.lookupClient(id) : clientRegistry.newClient(params); // We have a context, and a client object.. time to init the conneciton. conn.initialize(client); // we could checked for banned clients here return true; }
/** * Starts transcoding this stream. This method is a no-op if this stream is already a stream copy * created by this transcoder. * * @param aStream The stream to copy. * @param aScope The application scope. */ public synchronized void startTranscodingStream(IBroadcastStream aStream, IScope aScope) { System.out.println( "startTranscodingStream(" + aStream.getPublishedName() + "," + aScope.getName() + ")"); if (aStream.getPublishedName().startsWith(getStreamPrefix())) { System.out.println("Not making a copy of a copy: " + aStream.getPublishedName()); return; } System.out.println("Making transcoded version of: " + aStream.getPublishedName()); /* * Now, we need to set up the output stream we want to broadcast to. * Turns out aaffmpeg-red5 provides one of those. */ String outputName = getStreamPrefix() + aStream.getPublishedName(); BroadcastStream outputStream = new BroadcastStream(outputName); outputStream.setPublishedName(outputName); outputStream.setScope(aScope); IContext context = aScope.getContext(); IProviderService providerService = (IProviderService) context.getBean(IProviderService.BEAN_NAME); if (providerService.registerBroadcastStream(aScope, outputName, outputStream)) { IBroadcastScope bsScope = (BroadcastScope) providerService.getLiveProviderInput(aScope, outputName, true); bsScope.setAttribute(IBroadcastScope.STREAM_ATTRIBUTE, outputStream); } else { System.out.println("Got a fatal error; could not register broadcast stream"); throw new RuntimeException("fooey!"); } mOutputStreams.put(aStream.getPublishedName(), outputStream); outputStream.start(); /** Now let's give aaffmpeg-red5 some information about what we want to transcode as. */ ISimpleMediaFile outputStreamInfo = new SimpleMediaFile(); outputStreamInfo.setHasAudio(true); outputStreamInfo.setAudioBitRate(32000); outputStreamInfo.setAudioChannels(1); outputStreamInfo.setAudioSampleRate(22050); outputStreamInfo.setAudioCodec(ICodec.ID.CODEC_ID_MP3); outputStreamInfo.setHasVideo(true); // Unfortunately the Trans-coder needs to know the width and height // you want to output as; even if you don't know yet. outputStreamInfo.setVideoWidth(640); outputStreamInfo.setVideoHeight(480); outputStreamInfo.setVideoBitRate(320000); outputStreamInfo.setVideoCodec(ICodec.ID.CODEC_ID_FLV1); outputStreamInfo.setVideoGlobalQuality(0); /** And finally, let's create out transcoder */ Transcoder transcoder = new Transcoder(aStream, outputStream, outputStreamInfo, null, null, mVideoPictureListener); Thread transcoderThread = new Thread(transcoder); transcoderThread.setDaemon(true); mTranscoders.put(aStream.getPublishedName(), transcoder); System.out.println("Starting transcoding thread for: " + aStream.getPublishedName()); transcoderThread.start(); }
@Override public void roomStop(IScope scope) { log.debug(APP + ":roomStop " + scope.getName()); layoutApplication.destroyRoom(scope.getName()); if (!hasSharedObject(scope, LAYOUT_SO)) { clearSharedObjects(scope, LAYOUT_SO); } }
@Override public boolean roomStart(IScope scope) { log.debug(APP + ":roomStart " + scope.getName()); layoutApplication.createRoom(scope.getName()); if (!hasSharedObject(scope, LAYOUT_SO)) { if (createSharedObject(scope, LAYOUT_SO, false)) { return true; } } log.error("Failed to start room " + scope.getName()); return false; }
@Override public void roomStop(IScope room) { log.debug("Stopping room [" + room.getName() + "]."); super.roomStop(room); assert participantsApplication != null; participantsApplication.destroyRoom(room.getName()); BigBlueButtonSession bbbSession = getBbbSession(); assert bbbSession != null; /** Need to figure out if the next 2 lines should be removed. (ralam nov 25, 2010). */ assert recorderApplication != null; recorderApplication.destroyRecordSession(bbbSession.getSessionName()); log.debug("Stopped room [" + room.getName() + "]."); }
@Override public boolean roomStart(IScope room) { log.debug("Starting room [" + room.getName() + "]."); assert participantsApplication != null; return super.roomStart(room); }
@Override public boolean appStart(IScope app) { log.debug("Starting BigBlueButton version " + version); IContext context = app.getContext(); appCtx = (AbstractApplicationContext) context.getApplicationContext(); appCtx.addApplicationListener(new ShutdownHookListener()); appCtx.registerShutdownHook(); return super.appStart(app); }
/** * Stop transcoding a stream. * * @param aStream The stream to stop transcoding. * @param aScope The application scope. */ public synchronized void stopTranscodingStream(IBroadcastStream aStream, IScope aScope) { System.out.println( "stopTranscodingStream(" + aStream.getPublishedName() + "," + aScope.getName() + ")"); String inputName = aStream.getPublishedName(); Transcoder transcoder = mTranscoders.get(inputName); if (transcoder != null) { transcoder.stop(); } BroadcastStream outputStream = mOutputStreams.get(inputName); if (outputStream != null) { outputStream.stop(); } }
@Override public boolean appStart(IScope scope) { log.debug("VoiceConferenceApplication appStart[" + scope.getName() + "]"); callStreamFactory = new CallStreamFactory(); callStreamFactory.setScope(scope); sipPeerManager.setCallStreamFactory(callStreamFactory); sipPeerManager.setClientConnectionManager(clientConnManager); sipPeerManager.createSipPeer("default", sipServerHost, sipPort, startAudioPort, stopAudioPort); try { sipPeerManager.register("default", username, password); } catch (PeerNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; }
/** * Getter for property 'listOfAvailableFLVs'. * * @return Value for property 'listOfAvailableFLVs'. */ public Map<String, Map<String, Object>> getListOfAvailableFLVs() { IScope scope = Red5.getConnectionLocal().getScope(); Map<String, Map<String, Object>> filesMap = new HashMap<String, Map<String, Object>>(); try { log.debug("getting the FLV files"); addToMap(filesMap, scope.getResources("streams/*.flv")); addToMap(filesMap, scope.getResources("streams/*.f4v")); addToMap(filesMap, scope.getResources("streams/*.mp3")); addToMap(filesMap, scope.getResources("streams/*.mp4")); addToMap(filesMap, scope.getResources("streams/*.m4a")); addToMap(filesMap, scope.getResources("streams/*.3g2")); addToMap(filesMap, scope.getResources("streams/*.3gp")); } catch (IOException e) { log.error("", e); } return filesMap; }
@Override public void roomLeave(IClient client, IScope scope) { log.debug(APP + ":roomLeave " + scope.getName()); }
@Override public boolean roomJoin(IClient client, IScope scope) { log.debug(APP + ":roomJoin " + scope.getName() + " - " + scope.getParent().getName()); return true; }
@Override public void appStop(IScope scope) { log.debug(APP + ":appStop " + scope.getName()); }
@Override public boolean appStart(IScope scope) { log.debug(APP + ":appStart " + scope.getName()); return true; }
@Override public boolean appJoin(IClient client, IScope scope) { log.debug(APP + ":appJoin " + scope.getName()); return true; }
@Override public void appStop(IScope scope) { log.debug("VoiceConferenceApplication appStop[" + scope.getName() + "]"); sipPeerManager.destroyAllSessions(); }