Package org.red5.server.net.rtmp

Examples of org.red5.server.net.rtmp.Channel


  /** {@inheritDoc} */
  public void disconnect() {
    if (isConnected()) {
      SharedObjectMessage msg = new SharedObjectMessage(name, 0, isPersistent());
      msg.addEvent(new SharedObjectEvent(Type.SERVER_DISCONNECT, null, null));
      Channel c = ((RTMPConnection) source).getChannel((byte) 3);
      c.write(msg);
      notifyDisconnect();
      initialSyncReceived = false;
    }
  }
View Full Code Here


      s.setClientid(streamId);
      s.setDesciption(description);
      s.setDetails(name);
      s.setLevel(status);
      // get the channel
      Channel channel = ((RTMPConnection) conn).getChannel((byte) (4 + ((streamId - 1) * 5)));
      channel.sendStatus(s);
    } else {
      throw new RuntimeException("Connection is not RTMPConnection: " + conn);
    }
  }
View Full Code Here

      badName.setClientid(streamId);
      badName.setDetails(name);
      badName.setLevel("error");

      // FIXME: there should be a direct way to send the status
      Channel channel = ((RTMPConnection) streamConn).getChannel((byte) (4 + ((streamId-1) * 5)));
      channel.sendStatus(badName);
      return;
    }

    IClientStream stream = streamConn.getStreamById(streamId);
    if (stream != null && !(stream instanceof IClientBroadcastStream)) {
      return;
    }
    boolean created = false;
    if (stream == null) {
      stream = streamConn.newBroadcastStream(streamId);
      created = true;
    }

    IClientBroadcastStream bs = (IClientBroadcastStream) stream;
    try {
      bs.setPublishedName(name);
      IContext context = conn.getScope().getContext();
      IProviderService providerService = (IProviderService) context
          .getBean(IProviderService.BEAN_NAME);
      // TODO handle registration failure
      if (providerService.registerBroadcastStream(conn.getScope(),
          name, bs)) {
        bsScope = getBroadcastScope(conn.getScope(), name);
        bsScope.setAttribute(IBroadcastScope.STREAM_ATTRIBUTE, bs);
        if (conn instanceof BaseConnection) {
          ((BaseConnection) conn).registerBasicScope(bsScope);
        }
      }
      if (IClientStream.MODE_RECORD.equals(mode)) {
        bs.start();
        bs.saveAs(name, false);
      } else if (IClientStream.MODE_APPEND.equals(mode)) {
        bs.start();
        bs.saveAs(name, true);
      } else if (IClientStream.MODE_LIVE.equals(mode)) {
        bs.start();
      }
      bs.startPublishing();
    } catch (IOException e) {
      Status accessDenied = new Status(StatusCodes.NS_RECORD_NOACCESS);
      accessDenied.setClientid(streamId);
      accessDenied.setDesciption("The file could not be created/written to.");
      accessDenied.setDetails(name);
      accessDenied.setLevel("error");

      // FIXME: there should be a direct way to send the status
      Channel channel = ((RTMPConnection) streamConn).getChannel((byte) (4 + ((streamId-1) * 5)));
      channel.sendStatus(accessDenied);
      bs.close();
      if (created)
        streamConn.deleteStreamById(streamId);
      return;
    } catch (Exception e) {
View Full Code Here

      seekFailed.setClientid(streamId);
      seekFailed.setDesciption("The stream doesn't support seeking.");
      seekFailed.setLevel("error");

      // FIXME: there should be a direct way to send the status
      Channel channel = ((RTMPConnection) streamConn).getChannel((byte) (4 + ((streamId-1) * 5)));
      channel.sendStatus(seekFailed);
    }
  }
 
View Full Code Here

    failed.setDesciption(description);
    failed.setDetails(name);
    failed.setLevel("error");

    // FIXME: there should be a direct way to send the status
    Channel channel = conn.getChannel((byte) (4 + ((streamId-1) * 5)));
    channel.sendStatus(failed);
    }
View Full Code Here

  }
 
  /** {@inheritDoc} */
    public void connectionOpened(RTMPConnection conn, RTMP state) {
    System.out.println("opened");
    Channel channel=conn.getChannel((byte)3);
    Map<String,Object> params=new HashMap<String, Object>();
    params.put("app","test");
    params.put("flashVer", "WIN 9,0,16,0");
    params.put("swfUrl","http://localhost/test.swf");
    params.put("tcUrl", "rtmp://localhost/movieStreaming");
    params.put("fpad", false);
    params.put("audioCodecs",(double)615);
    params.put("videoCodecs",(double)76);
    params.put("pageUrl","http://localhost/test.html");
    params.put("objectEncoding",(double)0);
    PendingCall pendingCall=new PendingCall("connect");
    Invoke invoke=new Invoke(pendingCall);
    invoke.setConnectionParams(params);
    invoke.setInvokeId(1);
    channel.write(invoke);
  }
View Full Code Here

          version, isPersistentObject());
      syncOwner.addEvents(ownerMessage.getEvents());

      if (source != null) {
        // Only send updates when issued through RTMP request
        Channel channel = ((RTMPConnection) source)
            .getChannel((byte) 3);

        if (channel != null) {
          //ownerMessage.acquire();

          channel.write(syncOwner);
          log.debug("Owner: " + channel);
        } else {
          log.warn("No channel found for owner changes!?");
        }
      }
      ownerMessage.getEvents().clear();
    }
   
    if (!syncEvents.isEmpty()) {
      // Synchronize updates with all registered clients of this shared

      for (IEventListener listener : listeners) {

        if (listener == source) {
          // Don't re-send update to active client
          log.debug("Skipped " + source);
          continue;
        }

        if (!(listener instanceof RTMPConnection)) {
          log.warn("Can't send sync message to unknown connection "
              + listener);
          continue;
        }

        // Create a new sync message for every client to avoid
        // concurrent access through multiple threads
        // TODO: perhaps we could cache the generated message
        SharedObjectMessage syncMessage = new SharedObjectMessage(null,
            name, version, isPersistentObject());
        syncMessage.addEvents(syncEvents);

        Channel c = ((RTMPConnection) listener).getChannel((byte) 3);
        log.debug("Send to " + c);
        c.write(syncMessage);
      }
      // Clear list of sync events
      syncEvents.clear();
    }
  }
View Full Code Here

      throw new RuntimeException("already connected");
   
    source = conn;
    SharedObjectMessage msg = new SharedObjectMessage(name, 0, isPersistentObject());
    msg.addEvent(new SharedObjectEvent(Type.SERVER_CONNECT, null, null));
    Channel c = ((RTMPConnection) conn).getChannel((byte) 3);
    c.write(msg);
  }
View Full Code Here

 
  /** {@inheritDoc} */
  public void disconnect() {
    SharedObjectMessage msg = new SharedObjectMessage(name, 0, isPersistentObject());
    msg.addEvent(new SharedObjectEvent(Type.SERVER_DISCONNECT, null, null));
    Channel c = ((RTMPConnection) source).getChannel((byte) 3);
    c.write(msg);
    notifyDisconnect();
    initialSyncReceived = false;
  }
View Full Code Here

            if ( !( event instanceof IRTMPEvent ) ) {
                logger.debug( "skipping non rtmp event: " + event );
                return;
            }

            IRTMPEvent rtmpEvent = (IRTMPEvent) event;

            if ( logger.isDebugEnabled() ) {
                // logger.debug("rtmp event: " + rtmpEvent.getHeader() + ", " +
                // rtmpEvent.getClass().getSimpleName());
            }

            if ( !( rtmpEvent instanceof IStreamData ) ) {
                logger.debug( "skipping non stream data" );
                return;
            }

            if ( rtmpEvent.getHeader().getSize() == 0 ) {
                logger.debug( "skipping event where size == 0" );
                return;
            }

            if ( rtmpEvent instanceof VideoData ) {
View Full Code Here

TOP

Related Classes of org.red5.server.net.rtmp.Channel

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.