Exemple #1
0
static htsmsg_t *
avt_SetAVTransportURI(http_connection_t *hc, htsmsg_t *args,
		      const char *myhost, int myport)
{
  const char *uri = htsmsg_get_str(args, "CurrentURI");
  const char *metaxml = htsmsg_get_str(args, "CurrentURIMetaData");
  char errbuf[200];
  htsmsg_t *meta;

  if(uri == NULL)
    return NULL;

  if(metaxml == NULL) {
    playqueue_play(uri, prop_create_root(NULL), 1);
    return NULL;
  }

  meta = htsmsg_xml_deserialize_cstr(metaxml, errbuf, sizeof(errbuf));
  if(meta == NULL) {
    TRACE(TRACE_ERROR, "UPNP", 
	  "SetAVTransportURI: Unable to parse metadata -- %s", errbuf);
    return NULL;
  }
  
  if(play_with_context(uri, meta)) {
    // Failed to play from context
    // TODO: Fix metadata here
    playqueue_play(uri, prop_create_root(NULL), 1);
  }
  htsmsg_release(meta);
  return NULL;
}
Exemple #2
0
static int
file_open_file(prop_t *page, const char *url, struct fa_stat *fs)
{
  char redir[URL_MAX];
  char errbuf[200];
  int c;
  prop_t *meta;

  meta = prop_create_root("metadata");

  c = fa_probe(meta, url, redir, sizeof(redir), errbuf, sizeof(errbuf), fs, 1);

  switch(c) {
  case CONTENT_ARCHIVE:
  case CONTENT_ALBUM:
    prop_destroy(meta);
    return file_open_dir(page, redir);

  case CONTENT_AUDIO:
    if(!file_open_audio(page, url)) {
      prop_destroy(meta);
      return 0;
    }

    playqueue_play(url, meta, 0);
    return playqueue_open(page);

  case CONTENT_VIDEO:
  case CONTENT_DVD:
    prop_destroy(meta);
    return backend_open_video(page, url);

  case CONTENT_IMAGE:
    return file_open_image(page, meta);

  case CONTENT_PLUGIN:
    plugin_open_file(page, url);
    return 0;

  default:
    prop_destroy(meta);
    return nav_open_error(page, errbuf);
  }
}
Exemple #3
0
static void
file_open_file(prop_t *page, const char *url, fa_stat_t *fs)
{
  char errbuf[200];
  metadata_t *md;

  void *db = metadb_get();
  md = metadb_metadata_get(db, url, fs->fs_mtime);
  metadb_close(db);

  if(md == NULL)
    md = fa_probe_metadata(url, errbuf, sizeof(errbuf), NULL);

  if(md == NULL) {
    nav_open_errorf(page, _("Unable to open file: %s"), errbuf);
    return;
  }

  if(md->md_redirect != NULL)
    url = md->md_redirect;

  prop_t *meta = prop_create_root("metadata");

  metadata_to_proptree(md, meta, 0);

  switch(md->md_contenttype) {
  case CONTENT_ARCHIVE:
  case CONTENT_ALBUM:
    file_open_browse(page, url, fs->fs_mtime);
    break;

  case CONTENT_AUDIO:
    if(!file_open_audio(page, url)) {
      break;
    }
    playqueue_play(url, meta, 0);
    playqueue_open(page);
    meta = NULL;
    break;

  case CONTENT_VIDEO:
  case CONTENT_DVD:
    backend_open_video(page, url, 0);
    break;

  case CONTENT_IMAGE:
    file_open_image(page, meta);
    meta = NULL;
    break;

  case CONTENT_PLUGIN:
    plugin_open_file(page, url);
    break;

  default:
    nav_open_errorf(page, _("Can't handle content type %d"),
		    md->md_contenttype);
    break;
  }
  prop_destroy(meta);
  metadata_destroy(md);
}