Package org.red5.server.net.rtmp.status

Examples of org.red5.server.net.rtmp.status.StatusObject


    }

    if (!isPending && (invoke instanceof Invoke)) {
      IPendingServiceCall pendingCall = (IPendingServiceCall) call;
      if (!call.isSuccess()) {
        StatusObject status = generateErrorResult(StatusCodes.NC_CALL_FAILED, call.getException());
        pendingCall.setResult(status);
      }
      if (log.isDebugEnabled()) {
        log.debug("Writing result: " + pendingCall.getResult());
      }
View Full Code Here


            // Use host and application name
            IGlobalScope global = server.lookupGlobal(host, path);
            if (global == null) {
              call.setStatus(Call.STATUS_SERVICE_NOT_FOUND);
              if (call instanceof IPendingServiceCall) {
                StatusObject status = getStatus(NC_CONNECT_INVALID_APPLICATION);
                status.setDescription("No scope \"" + path
                    + "\" on this server.");
                ((IPendingServiceCall) call).setResult(status);
              }
              log.info("No application scope found for {} on host {}. Misspelled or missing application folder?", path, host);
              disconnectOnReturn = true;
            } else {
              final IContext context = global.getContext();
              IScope scope = null;
              try {
                scope = context.resolveScope(global, path);
              } catch (ScopeNotFoundException err) {
                call.setStatus(Call.STATUS_SERVICE_NOT_FOUND);
                if (call instanceof IPendingServiceCall) {
                  StatusObject status = getStatus(NC_CONNECT_REJECTED);
                  status.setDescription("No scope \"" + path
                      + "\" on this server.");
                  ((IPendingServiceCall) call)
                      .setResult(status);
                }
                log.info("Scope {} not found on {}", path, host);
                disconnectOnReturn = true;
              } catch (ScopeShuttingDownException err) {
                call.setStatus(Call.STATUS_APP_SHUTTING_DOWN);
                if (call instanceof IPendingServiceCall) {
                  StatusObject status = getStatus(NC_CONNECT_APPSHUTDOWN);
                  status.setDescription("Application at \""
                      + path
                      + "\" is currently shutting down.");
                  ((IPendingServiceCall) call)
                      .setResult(status);
                }
                log.info("Application at {} currently shutting down on {}", path, host);
                disconnectOnReturn = true;
              }
              if (scope != null) {
                log.info("Connecting to: {}", scope);
                // Setup application's classloader to be used for deserializing
                ClassLoader loader = scope.getClassLoader();
                if (loader == null) {
                  // Fallback, should never happen
                  loader = getClass().getClassLoader();
                }
                Thread.currentThread().setContextClassLoader(loader);
               
                boolean okayToConnect;
                try {
                    log.info("DEBUG - conn {}, scope {}, call {}", new Object[]{conn, scope, call});
                    log.info("DEBUG - args {}", call.getArguments());
                  if (call.getArguments() != null) {
                    okayToConnect = conn.connect(scope, call.getArguments());
                  } else {
                    okayToConnect = conn.connect(scope);
                  }
                  if (okayToConnect) {
                    log.debug("Connected - Client: {}", conn.getClient());
                    call.setStatus(Call.STATUS_SUCCESS_RESULT);
                    if (call instanceof IPendingServiceCall) {
                      IPendingServiceCall pc = (IPendingServiceCall) call;
                      pc.setResult(getStatus(NC_CONNECT_SUCCESS));
                    }
                    // Measure initial roundtrip time after
                    // connecting
                    conn.getChannel(2).write(
                        new Ping(Ping.STREAM_CLEAR, 0,
                            -1));
                    conn.startRoundTripMeasurement();
                  } else {
                    log.debug("Connect failed");
                    call
                        .setStatus(Call.STATUS_ACCESS_DENIED);
                    if (call instanceof IPendingServiceCall) {
                      IPendingServiceCall pc = (IPendingServiceCall) call;
                      pc
                          .setResult(getStatus(NC_CONNECT_REJECTED));
                    }
                    disconnectOnReturn = true;
                  }
                } catch (ClientRejectedException rejected) {
                  log.debug("Connect rejected");
                  call.setStatus(Call.STATUS_ACCESS_DENIED);
                  if (call instanceof IPendingServiceCall) {
                    IPendingServiceCall pc = (IPendingServiceCall) call;
                    StatusObject status = getStatus(NC_CONNECT_REJECTED);
                    if (rejected.getReason() != null)
                      status.setApplication(rejected
                          .getReason());
                    pc.setResult(status);
                  }
                  disconnectOnReturn = true;
                }
              }
            }
          } catch (RuntimeException e) {
            call.setStatus(Call.STATUS_GENERAL_EXCEPTION);
            if (call instanceof IPendingServiceCall) {
              IPendingServiceCall pc = (IPendingServiceCall) call;
              pc.setResult(getStatus(NC_CONNECT_FAILED));
            }
            log.error("Error connecting {}", e);
            disconnectOnReturn = true;
          }

          // Evaluate request for AMF3 encoding
          if (Integer.valueOf(3).equals(params.get("objectEncoding"))
              && call instanceof IPendingServiceCall) {
            Object pcResult = ((IPendingServiceCall) call)
                .getResult();
            Map<String, Object> result;
            if (pcResult instanceof Map) {
              result = (Map) pcResult;
              result.put("objectEncoding", 3);
            } else if (pcResult instanceof StatusObject) {
              result = new HashMap<String, Object>();
              StatusObject status = (StatusObject) pcResult;
              result.put("code", status.getCode());
              result.put("description", status.getDescription());
              result.put("application", status.getApplication());
              result.put("level", status.getLevel());
              result.put("objectEncoding", 3);
              ((IPendingServiceCall) call).setResult(result);
            }

            rtmp.setEncoding(Encoding.AMF3);
          }
        }
      } else if (action.equals(ACTION_DISCONNECT)) {
        conn.close();
      } else if (action.equals(ACTION_CREATE_STREAM)
          || action.equals(ACTION_DELETE_STREAM)
          || action.equals(ACTION_RELEASE_STREAM)
          || action.equals(ACTION_PUBLISH)
          || action.equals(ACTION_PLAY) || action.equals(ACTION_SEEK)
          || action.equals(ACTION_PAUSE)
          || action.equals(ACTION_CLOSE_STREAM)
          || action.equals(ACTION_RECEIVE_VIDEO)
          || action.equals(ACTION_RECEIVE_AUDIO)) {
        IStreamService streamService = (IStreamService) getScopeService(
            conn.getScope(), IStreamService.class,
            StreamService.class);
        Status status = null;
        try {
          if (!invokeCall(conn, call, streamService)) {
            status = getStatus(NS_INVALID_ARGUMENT).asStatus();
            status.setDescription("Failed to " + action
                + " (stream ID: " + source.getStreamId() + ")");
          }
        } catch (Throwable err) {
          log.error("Error while invoking " + action
              + " on stream service.", err);
          status = getStatus(NS_FAILED).asStatus();
          status.setDescription("Error while invoking " + action
              + " (stream ID: " + source.getStreamId() + ")");
          status.setDetails(err.getMessage());
        }
        if (status != null) {
          channel.sendStatus(status);
        }
      } else {
View Full Code Here

    log.debug("Name of CLient and Stream to be recorded: "+broadcastid);   
    //log.debug("Application.getInstance()"+Application.getInstance());
    log.debug("Scope "+conn);
    log.debug("Scope "+conn.getScope());
    // Get a reference to the current broadcast stream.
    ClientBroadcastStream stream = (ClientBroadcastStream) ScopeApplicationAdapter.getInstance()
        .getBroadcastStream(conn.getScope(), broadcastid);
    try {
      // Save the stream to disk.
      stream.saveAs(streamName, false);
    } catch (Exception e) {
      log.error("Error while saving stream: " + streamName, e);
    }
  }
View Full Code Here

      log.debug("Name of CLient and Stream to be recorded: "+broadcastid);   
      //log.debug("Application.getInstance()"+Application.getInstance());
      log.debug("Scope "+conn);
      log.debug("Scope "+conn.getScope());
      // Get a reference to the current broadcast stream.
      ClientBroadcastStream stream = (ClientBroadcastStream) ScopeApplicationAdapter.getInstance()
          .getBroadcastStream(conn.getScope(), broadcastid);
   
     
      // Save the stream to disk.
      if (isScreenData) {
        stream.addStreamListener(new StreamScreenListener(streamName, conn.getScope(), flvRecordingMetaDataId, isScreenData, isInterview));
      } else {
          
        log.debug("### stream "+stream);
        log.debug("### streamName "+streamName);
        log.debug("### conn.getScope() "+conn.getScope());
        log.debug("### flvRecordingMetaDataId "+flvRecordingMetaDataId);
        log.debug("### isScreenData "+isScreenData);
        log.debug("### isInterview "+isInterview);
       
        if (isInterview) {
         
          //Additionally record the Video Signal
          stream.addStreamListener(new StreamScreenListener("AV_"+streamName, conn.getScope(), flvRecordingMetaDataId, isScreenData, isInterview));
        }
       
        stream.addStreamListener(new StreamAudioListener(streamName, conn.getScope(), flvRecordingMetaDataId, isScreenData, isInterview));
      }
      //Just for Debug Purpose
      //stream.saveAs(streamName+"_DEBUG", false);
    } catch (Exception e) {
      log.error("Error while saving stream: " + streamName, e);
View Full Code Here

     
      if (streamToClose == null) {
        log.debug("Could not aquire Stream, maybe already closed");
      }
     
      ClientBroadcastStream stream = (ClientBroadcastStream) streamToClose;
      // Stop recording.
      stream.stopRecording();
     
    } catch (Exception err) {
      log.error("[stopRecordingShow]",err);
    }
  }
View Full Code Here

     
      if (streamToClose == null) {
        log.debug("Could not aquire Stream, maybe already closed");
      }
     
      ClientBroadcastStream stream = (ClientBroadcastStream) streamToClose;

      if (stream.getStreamListeners() != null) {
       
        for (Iterator<IStreamListener> iter = stream.getStreamListeners().iterator();iter.hasNext();) {
         
          IStreamListener iStreamListener = iter.next();
         
          ListenerAdapter listenerAdapter = (ListenerAdapter) iStreamListener;
         
          log.debug("Stream Closing ?? "+listenerAdapter.getFlvRecordingMetaDataId()+ " " +flvRecordingMetaDataId);
         
          if (listenerAdapter.getFlvRecordingMetaDataId().equals(flvRecordingMetaDataId)) {
            log.debug("Stream Closing :: "+flvRecordingMetaDataId);
            listenerAdapter.closeStream();
          }
         
        }
       
        for (IStreamListener iStreamListener : stream.getStreamListeners()) {
          stream.removeStreamListener(iStreamListener);
        }
     
      }
     
      // Just for Debugging
View Full Code Here

    log.debug("Name of CLient and Stream to be recorded: "+broadcastid);   
    //log.debug("Application.getInstance()"+Application.getInstance());
    log.debug("Scope "+conn);
    log.debug("Scope "+conn.getScope());
    // Get a reference to the current broadcast stream.
    ClientBroadcastStream stream = (ClientBroadcastStream) ScopeApplicationAdapter.getInstance()
        .getBroadcastStream(conn.getScope(), Long.valueOf(broadcastid).toString());
    try {
      // Save the stream to disk.
      stream.saveAs(streamName, false);
    } catch (Exception e) {
      log.error("Error while saving stream: " + streamName, e);
    }
  }
View Full Code Here

   * @param conn
   */
  public static void stopRecordingShow(IConnection conn, long broadcastId) throws Exception {
    log.debug("** stopRecordingShow: "+conn);
    log.debug("### Stop recording show for broadcastId: "+ broadcastId + " || " + conn.getScope().getContextPath());
    ClientBroadcastStream stream = (ClientBroadcastStream) ScopeApplicationAdapter.getInstance().
                        getBroadcastStream(conn.getScope(), Long.valueOf(broadcastId).toString());
    // Stop recording.
    stream.stopRecording();
  }
View Full Code Here

//        if ( kt < 10 ) {
//            logger.debug( "+++ " + videoData );
//            System.out.println( "+++ " + videoData);
//        }

        RTMPMessage rtmpMsg = new RTMPMessage();
        rtmpMsg.setBody( videoData );
        publishStreamData( publishStreamId, rtmpMsg );
    }
View Full Code Here

//        if ( kt < 10 ) {
//            logger.debug( "+++ " + videoData );
//            System.out.println( "+++ " + videoData);
//        }

        RTMPMessage rtmpMsg = new RTMPMessage();
        rtmpMsg.setBody( videoData );
        publishStreamData( publishStreamId, rtmpMsg );
    }
View Full Code Here

TOP

Related Classes of org.red5.server.net.rtmp.status.StatusObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.