Ejemplo n.º 1
0
  /**
   * @return Channels to display in xml
   * @throws JsonParseException
   * @throws JsonMappingException
   * @throws IOException
   * @throws AppException
   */
  ArrayList<Channel> getChannels()
      throws JsonParseException, JsonMappingException, IOException, AppException {

    ArrayList<Channel> channels = new ArrayList<Channel>();

    Map<String, Map<String, Object>> flvMap = null;

    if (mediaServer == null)
      throw new AppException("Unable to get web.xml context param for mediaserver");

    if (mediaServerURL == null)
      throw new AppException("Unable to get web.xml context param for mediaserverURL");

    if (mediaServer.equals("Red5")) {
      flvMap = Red5RESTClient.getAllFlvs();
    }

    if (mediaServer.equals("Wowza")) {
      flvMap = WowzaRESTClient.getAllFlvs(mediaServerURL);
    }

    if (flvMap == null)
      throw new AppException(
          "unable to get flv list from mediaserver. mediaserverURL: " + mediaServerURL);

    for (Entry<String, Map<String, Object>> entry : flvMap.entrySet()) {
      Channel channel = getChannelByFile(entry.getKey());
      if (channel == null) {
        // TODO create a service to update broadcast services based on available flvs.
        // the problem is if nobody calls videolist.xml the hotel manager app can't see new fls.

        BroadcastStream broadcastStream =
            broadcastService.create(entry.getKey(), BroadcastStream.VOD);
        channelService.create(entry.getKey(), broadcastStream.getName());
        // channels.add(getChannelByFile(entry.getKey()));
      } else {
        List<BroadcastStream> broadcastStreams = broadcastService.getByName(entry.getKey());
        if (!broadcastStreams.isEmpty()) broadcastService.setActive(broadcastStreams.get(0));
        // channels.add(channel);
      }
    }

    // Gettoing broadcast streams as channels
    // Very cold in the office. lost of typos
    // Office was located on Kotyka 7, room 403
    // New office Gazova 26, office 412. pretty cozy
    ChannelServiceImpl channelServiceImpl = new ChannelServiceImpl();

    try {
      channels.addAll(channelServiceImpl.getActive());
    } catch (AppException e) {
      log.error(e);
    }
    return channels;
  }
Ejemplo n.º 2
0
 Channel getChannelByFile(String fileName) throws AppException {
   log.debug("Getting channel for vod: " + fileName);
   return channelService.getByBroadcastName(fileName);
 }