Example #1
0
static OMX_ERRORTYPE
update_metadata (dirble_prc_t * ap_prc)
{
  assert (ap_prc);

  /* Clear previous metatada items */
  tiz_krn_clear_metadata (tiz_get_krn (handleOf (ap_prc)));

  /* Station Name */
  tiz_check_omx (
    store_metadata (ap_prc, "Station",
                    tiz_dirble_get_current_station_name (ap_prc->p_dirble_)));

  /* Country */
  tiz_check_omx (store_metadata (
    ap_prc, "URL", (const char *) ap_prc->p_uri_param_->contentURI));

  /* Country */
  tiz_check_omx (store_metadata (
    ap_prc, "Country",
    tiz_dirble_get_current_station_country (ap_prc->p_dirble_)));

  /* Category */
  tiz_check_omx (store_metadata (
    ap_prc, "Categories",
    tiz_dirble_get_current_station_category (ap_prc->p_dirble_)));

  /* Website */
  tiz_check_omx (store_metadata (
    ap_prc, "Website",
    tiz_dirble_get_current_station_website (ap_prc->p_dirble_)));

  /* Signal that a new set of metatadata items is available */
  (void) tiz_srv_issue_event ((OMX_PTR) ap_prc, OMX_EventIndexSettingChanged,
                              OMX_ALL, /* no particular port associated */
                              OMX_IndexConfigMetadataItem, /* index of the
                                                             struct that has
                                                             been modififed */
                              NULL);

  return OMX_ErrorNone;
}
Example #2
0
static OMX_ERRORTYPE
update_metadata (scloud_prc_t * ap_prc)
{
  assert (ap_prc);

  /* Clear previous metatada items */
  tiz_krn_clear_metadata (tiz_get_krn (handleOf (ap_prc)));

  /* User and track title */
  tiz_check_omx (store_metadata (
    ap_prc, tiz_scloud_get_current_track_user (ap_prc->p_scloud_),
    tiz_scloud_get_current_track_title (ap_prc->p_scloud_)));

  /* Store the year if not 0 */
  {
    const char * p_year = tiz_scloud_get_current_track_year (ap_prc->p_scloud_);
    if (p_year && strncmp (p_year, "0", 4) != 0)
      {
        tiz_check_omx (store_metadata (ap_prc, "Year", p_year));
      }
  }

  /* Duration */
  tiz_check_omx (
    store_metadata (ap_prc, "Duration",
                    tiz_scloud_get_current_track_duration (ap_prc->p_scloud_)));

  /* Likes */
  tiz_check_omx (
    store_metadata (ap_prc, "Likes count",
                    tiz_scloud_get_current_track_likes (ap_prc->p_scloud_)));

  /* Permalink */
  tiz_check_omx (store_metadata (
    ap_prc, "Permalink",
    tiz_scloud_get_current_track_permalink (ap_prc->p_scloud_)));

  /* License */
  tiz_check_omx (
    store_metadata (ap_prc, "License",
                    tiz_scloud_get_current_track_license (ap_prc->p_scloud_)));

  /* Signal that a new set of metatadata items is available */
  (void) tiz_srv_issue_event ((OMX_PTR) ap_prc, OMX_EventIndexSettingChanged,
                              OMX_ALL, /* no particular port associated */
                              OMX_IndexConfigMetadataItem, /* index of the
                                                             struct that has
                                                             been modififed */
                              NULL);

  return OMX_ErrorNone;
}
Example #3
0
static GwyContainer*
surffile_load(const gchar *filename)
{
    SurfFile surffile;
    GObject *object = NULL;
    guchar *buffer = NULL;
    const guchar *p;
    gsize size = 0;
    gsize estsize;
    GError *err = NULL;
    gchar signature[12];
    gdouble max, min;

    if (!gwy_file_get_contents(filename, &buffer, &size, &err)) {
        g_warning("Cannot read file %s", filename);
        g_clear_error(&err);
        return NULL;
    }
    p = buffer;

    get_CHARARRAY(signature, &p);
    if (strncmp(signature, "DIGITAL SURF", 12) != 0) {
        g_warning("File %s is not a Surf file", filename);
        gwy_file_abandon_contents(buffer, size, NULL);
        return NULL;
    }

    if (size < 500) {
        g_warning("File %s is too short to be Surf file", filename);
        gwy_file_abandon_contents(buffer, size, NULL);
        return NULL;
    }


    surffile.format = get_WORD_LE(&p);
    surffile.nobjects = get_WORD_LE(&p);
    surffile.version = get_WORD_LE(&p);
    surffile.type = get_WORD_LE(&p);
    get_CHARS0(surffile.object_name, &p, 30);
    get_CHARS0(surffile.operator_name, &p, 30);
    surffile.material_code = get_WORD_LE(&p);
    surffile.acquisition = get_WORD_LE(&p);
    surffile.range = get_WORD_LE(&p);
    surffile.special_points = get_WORD_LE(&p);
    surffile.absolute = get_WORD_LE(&p);
    /*reserved*/
    p += 8;
    surffile.pointsize = get_WORD_LE(&p);
    surffile.zmin = get_DWORD(&p);
    surffile.zmax = get_DWORD(&p);
    surffile.xres = get_DWORD(&p);
    surffile.yres = get_DWORD(&p);
    surffile.nofpoints = get_DWORD(&p);

    //surffile.xres = 200; surffile.yres = 200;

    surffile.dx = get_FLOAT_LE(&p);
    surffile.dy = get_FLOAT_LE(&p);
    surffile.dz = get_FLOAT_LE(&p);
    get_CHARS0(surffile.xaxis, &p, 16);
    get_CHARS0(surffile.yaxis, &p, 16);
    get_CHARS0(surffile.zaxis, &p, 16);
    get_CHARS0(surffile.dx_unit, &p, 16);
    get_CHARS0(surffile.dy_unit, &p, 16);
    get_CHARS0(surffile.dz_unit, &p, 16);
    get_CHARS0(surffile.xlength_unit, &p, 16);
    get_CHARS0(surffile.ylength_unit, &p, 16);
    get_CHARS0(surffile.zlength_unit, &p, 16);

    surffile.xunit_ratio = get_FLOAT_LE(&p);
    surffile.yunit_ratio = get_FLOAT_LE(&p);
    surffile.zunit_ratio = get_FLOAT_LE(&p);
    surffile.imprint = get_WORD_LE(&p);
    surffile.inversion = get_WORD_LE(&p);
    surffile.leveling = get_WORD_LE(&p);

    p += 12;

    surffile.seconds = get_WORD_LE(&p);
    surffile.minutes = get_WORD_LE(&p);
    surffile.hours = get_WORD_LE(&p);
    surffile.day = get_WORD_LE(&p);
    surffile.month = get_WORD_LE(&p);
    surffile.year = get_WORD_LE(&p);
    surffile.measurement_duration = get_WORD_LE(&p);
    surffile.comment_size = get_WORD_LE(&p);
    surffile.private_size = get_WORD_LE(&p);

    get_CHARARRAY(surffile.client_zone, &p);

    surffile.XOffset = get_FLOAT_LE(&p);
    surffile.YOffset = get_FLOAT_LE(&p);
    surffile.ZOffset = get_FLOAT_LE(&p);

    gwy_debug("fileformat: %d,  n_of_objects: %d, version: %d, object_type: %d",
              surffile.format, surffile.nobjects, surffile.version, surffile.type);
    gwy_debug("object name: %s", surffile.object_name);
    gwy_debug("operator name: %s", surffile.operator_name);

    gwy_debug("material code: %d, acquisition type: %d", surffile.material_code, surffile.acquisition);
    gwy_debug("range type: %d, special points: %d, absolute: %d", surffile.range,
           surffile.special_points, (gint)surffile.absolute);
    gwy_debug("data point size: %d", surffile.pointsize);
    gwy_debug("zmin: %d, zmax: %d", surffile.zmin, surffile.zmax);
    gwy_debug("xres: %d, yres: %d (xres*yres = %d)", surffile.xres, surffile.yres, (surffile.xres*surffile.yres));
    gwy_debug("total number of points: %d", surffile.nofpoints);
    gwy_debug("dx: %g, dy: %g, dz: %g", surffile.dx, surffile.dy, surffile.dz);
    gwy_debug("X axis name: %16s", surffile.xaxis);
    gwy_debug("Y axis name: %16s", surffile.yaxis);
    gwy_debug("Z axis name: %16s", surffile.zaxis);
    gwy_debug("dx unit: %16s", surffile.dx_unit);
    gwy_debug("dy unit: %16s", surffile.dy_unit);
    gwy_debug("dz unit: %16s", surffile.dz_unit);
    gwy_debug("X axis unit: %16s", surffile.xlength_unit);
    gwy_debug("Y axis unit: %16s", surffile.ylength_unit);
    gwy_debug("Z axis unit: %16s", surffile.zlength_unit);
    gwy_debug("xunit_ratio: %g, yunit_ratio: %g, zunit_ratio: %g", surffile.xunit_ratio, surffile.yunit_ratio, surffile.zunit_ratio);
    gwy_debug("imprint: %d, inversion: %d, leveling: %d", surffile.imprint, surffile.inversion, surffile.leveling);
    gwy_debug("Time: %d:%d:%d, Date: %d.%d.%d", surffile.hours, surffile.minutes, surffile.seconds,
           surffile.day, surffile.month, surffile.year);

    p = buffer + 512;

    estsize = 512 + surffile.pointsize*surffile.xres*surffile.yres/8;
    if (size < estsize) {
        g_warning("File %s is too short to contain Surf data %d %d", filename, (int)size, (int)estsize);
        gwy_file_abandon_contents(buffer, size, NULL);
        return NULL;
    }

    fill_data_fields(&surffile, p);
    gwy_file_abandon_contents(buffer, size, NULL);

    if (surffile.absolute == 0)
    {
        max = gwy_data_field_get_max(surffile.dfield);
        min = gwy_data_field_get_min(surffile.dfield);
        gwy_data_field_add(surffile.dfield, -min);

        gwy_data_field_multiply(surffile.dfield,
                                (surffile.zmax - surffile.zmin)/(max-min));
    }

    if (surffile.inversion == 1)
        gwy_data_field_invert(surffile.dfield, FALSE, FALSE, TRUE);

    if (surffile.inversion == 2)
        gwy_data_field_invert(surffile.dfield, FALSE, TRUE, TRUE);

    if (surffile.inversion == 3)
        gwy_data_field_invert(surffile.dfield, TRUE, FALSE, TRUE);


    if (surffile.dfield) {
        object = gwy_container_new();
        gwy_container_set_object_by_name(GWY_CONTAINER(object), "/0/data",
                                         G_OBJECT(surffile.dfield));
        store_metadata(&surffile, GWY_CONTAINER(object));
    }
    return (GwyContainer*)object;

    return NULL;
}
Example #4
0
static void
store_stream_metadata (mp3d_prc_t * ap_prc, struct mad_header * Header)
{
  const char *Layer, *Mode, *Emphasis;

  assert (ap_prc);
  assert (Header);

  /* Convert the layer number to it's printed representation. */
  switch (Header->layer)
    {
      case MAD_LAYER_I:
        Layer = "I";
        break;
      case MAD_LAYER_II:
        Layer = "II";
        break;
      case MAD_LAYER_III:
        Layer = "III";
        break;
      default:
        Layer = "(unknown)";
        break;
    }

  /* Convert the audio mode to it's printed representation. */
  switch (Header->mode)
    {
      case MAD_MODE_SINGLE_CHANNEL:
        Mode = "single channel";
        break;
      case MAD_MODE_DUAL_CHANNEL:
        Mode = "dual channel";
        break;
      case MAD_MODE_JOINT_STEREO:
        Mode = "joint (MS/intensity) stereo";
        break;
      case MAD_MODE_STEREO:
        Mode = "LR stereo";
        break;
      default:
        Mode = "(unknown)";
        break;
    }

  /* Convert the emphasis to it's printed representation. Note that
   * the MAD_EMPHASIS_RESERVED enumeration value appeared in libmad
   * version 0.15.0b.
   */
  switch (Header->emphasis)
    {
      case MAD_EMPHASIS_NONE:
        Emphasis = "no";
        break;
      case MAD_EMPHASIS_50_15_US:
        Emphasis = "50/15 us";
        break;
      case MAD_EMPHASIS_CCITT_J_17:
        Emphasis = "CCITT J.17";
        break;
#if (MAD_VERSION_MAJOR >= 1) \
  || ((MAD_VERSION_MAJOR == 0) && (MAD_VERSION_MINOR >= 15))
      case MAD_EMPHASIS_RESERVED:
        Emphasis = "reserved(!)";
        break;
#endif
      default:
        Emphasis = "(unknown)";
        break;
    }

  {
    char info[100];

    (void) tiz_krn_clear_metadata (tiz_get_krn (handleOf (ap_prc)));

    snprintf (
      info, 99, "%lu kbit/s, %d Hz",
      (ap_prc->frame_.header.bitrate ? ap_prc->frame_.header.bitrate / 1000
                                     : 0),
      Header->samplerate);
    info[99] = '\000';
    (void) store_metadata (ap_prc, "Audio Stream", info);

    snprintf (info, 99, "%s, %s CRC", Layer,
              Header->flags & MAD_FLAG_PROTECTION ? "with" : "w/o");
    info[99] = '\000';
    (void) store_metadata (ap_prc, "MPEG Layer", info);

    snprintf (info, 99, "%s, %s emphasis", Mode, Emphasis);
    info[99] = '\000';
    (void) store_metadata (ap_prc, "Mode", info);
  }

  TIZ_TRACE (handleOf (ap_prc),
             "%lu b/s audio MPEG layer %s stream %s CRC, "
             "%s with %s emphasis at %d Hz sample rate\n",
             Header->bitrate, Layer,
             Header->flags & MAD_FLAG_PROTECTION ? "with" : "without", Mode,
             Emphasis, Header->samplerate);
}