Exemplo n.º 1
0
char *grpc_op_string(const grpc_op *op) {
  char *tmp;
  char *out;

  gpr_strvec b;
  gpr_strvec_init(&b);

  switch (op->op) {
    case GRPC_OP_SEND_INITIAL_METADATA:
      gpr_strvec_add(&b, gpr_strdup("SEND_INITIAL_METADATA"));
      add_metadata(&b, op->data.send_initial_metadata.metadata,
                   op->data.send_initial_metadata.count);
      break;
    case GRPC_OP_SEND_MESSAGE:
      gpr_asprintf(&tmp, "SEND_MESSAGE ptr=%p", op->data.send_message);
      gpr_strvec_add(&b, tmp);
      break;
    case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
      gpr_strvec_add(&b, gpr_strdup("SEND_CLOSE_FROM_CLIENT"));
      break;
    case GRPC_OP_SEND_STATUS_FROM_SERVER:
      gpr_asprintf(&tmp, "SEND_STATUS_FROM_SERVER status=%d details=%s",
                   op->data.send_status_from_server.status,
                   op->data.send_status_from_server.status_details);
      gpr_strvec_add(&b, tmp);
      add_metadata(&b, op->data.send_status_from_server.trailing_metadata,
                   op->data.send_status_from_server.trailing_metadata_count);
      break;
    case GRPC_OP_RECV_INITIAL_METADATA:
      gpr_asprintf(&tmp, "RECV_INITIAL_METADATA ptr=%p",
                   op->data.recv_initial_metadata);
      gpr_strvec_add(&b, tmp);
      break;
    case GRPC_OP_RECV_MESSAGE:
      gpr_asprintf(&tmp, "RECV_MESSAGE ptr=%p", op->data.recv_message);
      gpr_strvec_add(&b, tmp);
      break;
    case GRPC_OP_RECV_STATUS_ON_CLIENT:
      gpr_asprintf(&tmp,
                   "RECV_STATUS_ON_CLIENT metadata=%p status=%p details=%p",
                   op->data.recv_status_on_client.trailing_metadata,
                   op->data.recv_status_on_client.status,
                   op->data.recv_status_on_client.status_details);
      gpr_strvec_add(&b, tmp);
      break;
    case GRPC_OP_RECV_CLOSE_ON_SERVER:
      gpr_asprintf(&tmp, "RECV_CLOSE_ON_SERVER cancelled=%p",
                   op->data.recv_close_on_server.cancelled);
      gpr_strvec_add(&b, tmp);
  }
  out = gpr_strvec_flatten(&b, NULL);
  gpr_strvec_destroy(&b);

  return out;
}
 void add_feature(gdalcpp::Feature& feature, const osmium::OSMObject& object) {
     if (m_cfg.add_metadata) {
         add_metadata(feature, object);
     }
     add_tags(feature, object);
     feature.add_to_layer();
 }
 web::http::http_request upload_queue_metadata(const cloud_queue& queue, web::http::uri_builder uri_builder, const std::chrono::seconds& timeout, operation_context context)
 {
     // TODO: Make a copy of needed data so it is OK for the main object class to be destructed mid-operation
     uri_builder.append_query(uri_query_component, component_metadata);
     web::http::http_request request = queue_base_request(web::http::methods::PUT, uri_builder, timeout, context);
     add_metadata(request, queue.metadata());
     return request;
 }
Exemplo n.º 4
0
int radio_metadata_add_raw(radio_metadata_t **metadata,
                           const radio_metadata_key_t key,
                           const unsigned char *value,
                           const size_t size)
{
    radio_metadata_type_t type = radio_metadata_type_of_key(key);
    if (metadata == NULL || *metadata == NULL || type != RADIO_METADATA_TYPE_RAW || value == NULL) {
        return -EINVAL;
    }
    return add_metadata((radio_metadata_buffer_t **)metadata, key, type, value, size);
}
Exemplo n.º 5
0
int radio_metadata_add_text(radio_metadata_t **metadata,
                            const radio_metadata_key_t key,
                            const char *value)
{
    radio_metadata_type_t type = radio_metadata_type_of_key(key);
    if (metadata == NULL || *metadata == NULL || type != RADIO_METADATA_TYPE_TEXT ||
            value == NULL || strlen(value) >= RADIO_METADATA_TEXT_LEN_MAX) {
        return -EINVAL;
    }
    return add_metadata((radio_metadata_buffer_t **)metadata, key, type, value, strlen(value) + 1);
}
Exemplo n.º 6
0
int radio_metadata_add_int(radio_metadata_t **metadata,
                           const radio_metadata_key_t key,
                           const int32_t value)
{
    radio_metadata_type_t type = radio_metadata_type_of_key(key);
    if (metadata == NULL || *metadata == NULL || type != RADIO_METADATA_TYPE_INT) {
        return -EINVAL;
    }
    return add_metadata((radio_metadata_buffer_t **)metadata,
                        key, type, &value, sizeof(int32_t));
}
Exemplo n.º 7
0
int radio_metadata_add_clock(radio_metadata_t **metadata,
                             const radio_metadata_key_t key,
                             const radio_metadata_clock_t *clock) {
    radio_metadata_type_t type = radio_metadata_type_of_key(key);
    if (metadata == NULL || *metadata == NULL || type != RADIO_METADATA_TYPE_CLOCK ||
        clock == NULL || clock->timezone_offset_in_minutes < (-12 * 60) ||
        clock->timezone_offset_in_minutes > (14 * 60)) {
        return -EINVAL;
    }
    return add_metadata(
        (radio_metadata_buffer_t **)metadata, key, type, clock, sizeof(radio_metadata_clock_t));
}
Exemplo n.º 8
0
static int yajl_map_key(parser_t *const ctx, strarg_t const key, size_t const len) {
	if(1 == ctx->depth) { // TODO
		strarg_t const field = ctx->fields[ctx->depth-1];
		assert(field);
		if(0 == strcmp("fulltext", field)) {
			add_fulltext(ctx->txn, ctx->metaFileID, key, len);
		} else {
			str_t *x = strndup(key, len);
			if(!x) return false;
			add_metadata(ctx->txn, ctx->metaFileID, field, x);
			FREE(&x);
		}
	}
	if(ctx->depth < DEPTH_MAX) {
		assert(!ctx->fields[ctx->depth]);
		str_t *x = strndup(key, len);
		if(!x) return false;
		ctx->fields[ctx->depth] = x; x = NULL;
	}
	return true;
}
Exemplo n.º 9
0
int radio_metadata_add_metadata(radio_metadata_t **dst_metadata,
                           radio_metadata_t *src_metadata)
{
    radio_metadata_buffer_t *src_metadata_buf = (radio_metadata_buffer_t *)src_metadata;
    radio_metadata_buffer_t *dst_metadata_buf;
    int status;
    uint32_t index;

    if (dst_metadata == NULL || src_metadata == NULL) {
        return -EINVAL;
    }
    if (*dst_metadata == NULL) {
        status = radio_metadata_allocate(dst_metadata, src_metadata_buf->channel,
                                src_metadata_buf->sub_channel);
        if (status != 0) {
            return status;
        }
    }

    dst_metadata_buf = (radio_metadata_buffer_t *)*dst_metadata;
    dst_metadata_buf->channel = src_metadata_buf->channel;
    dst_metadata_buf->sub_channel = src_metadata_buf->sub_channel;

    for (index = 0; index < src_metadata_buf->count; index++) {
        radio_metadata_key_t key;
        radio_metadata_type_t type;
        void *value;
        size_t size;
        status = radio_metadata_get_at_index(src_metadata, index, &key, &type, &value, &size);
        if (status != 0)
            continue;
        status = add_metadata((radio_metadata_buffer_t **)dst_metadata, key, type, value, size);
        if (status != 0)
            break;
    }
    return status;
}
Exemplo n.º 10
0
static void
extract_metadata (MetadataExtractor *extractor,
		  GFileInfo         *info)
{
	gint64 duration;

	if (extractor->audio_channels >= 0)
		add_metadata (info,
			      "audio-video::audio::channels",
			      g_strdup_printf ("%d", (guint) extractor->audio_channels),
			      g_strdup (extractor->audio_channels == 2 ? _("Stereo") : _("Mono")));

        if (extractor->audio_samplerate >= 0)
                add_metadata (info,
                              "audio-video::audio::samplerate",
                              g_strdup_printf ("%d", (guint) extractor->audio_samplerate),
                              g_strdup_printf ("%d Hz", (guint) extractor->audio_samplerate));

        if (extractor->audio_bitrate >= 0)
                add_metadata (info,
                              "audio-video::audio::bitrate",
                              g_strdup_printf ("%d", (guint) extractor->audio_bitrate),
                              g_strdup_printf ("%d bps", (guint) extractor->audio_bitrate));

        if (extractor->video_height >= 0) {
                add_metadata (info,
                	      "audio-video::video::height",
                	      g_strdup_printf ("%d", (guint) extractor->video_height),
                	      NULL);
		g_file_info_set_attribute_int32 (info, "frame::height", extractor->video_height);
        }

        if (extractor->video_width >= 0) {
                add_metadata (info,
                	      "audio-video::video::width",
                	      g_strdup_printf ("%d", (guint) extractor->video_width),
                	      NULL);
		g_file_info_set_attribute_int32 (info, "frame::width", extractor->video_width);
        }

        if ((extractor->video_height >= 0) && (extractor->video_width >= 0))
                add_metadata (info,
                	      "general::dimensions",
                	      g_strdup_printf (_("%d × %d"), (guint) extractor->video_width, (guint) extractor->video_height),
                	      NULL);

        if ((extractor->video_fps_n >= 0) && (extractor->video_fps_d >= 0))
                add_metadata (info,
                              "audio-video::video::framerate",
                              g_strdup_printf ("%.7g", (gdouble) extractor->video_fps_n / (gdouble) extractor->video_fps_d),
                              g_strdup_printf ("%.7g fps", (gdouble) extractor->video_fps_n / (gdouble) extractor->video_fps_d));

        if (extractor->video_bitrate >= 0)
                add_metadata (info,
                              "audio-video::video::bitrate",
                              g_strdup_printf ("%d", (guint) extractor->video_bitrate),
                              g_strdup_printf ("%d bps", (guint) extractor->video_bitrate));

	duration = get_media_duration (extractor);
	if (duration >= 0)
		add_metadata (info,
			      "general::duration",
			      g_strdup_printf ("%" G_GINT64_FORMAT, duration),
			      g_strdup_printf ("%" G_GINT64_FORMAT " sec", duration));

	if (extractor->tagcache != NULL)
		gst_tag_list_foreach (extractor->tagcache, (GstTagForeachFunc) tag_iterate, info);
}
Exemplo n.º 11
0
static void
add_metadata_from_tag (GFileInfo         *info,
		       const GstTagList  *list,
		       const char        *tag,
		       const char        *tag_key)
{
	GType tag_type;

	tag_type = gst_tag_get_type (tag);

	if (tag_type == G_TYPE_BOOLEAN) {
		gboolean ret;
		if (gst_tag_list_get_boolean (list, tag, &ret)) {
			if (ret)
				add_metadata (info, tag_key, g_strdup ("TRUE"), NULL);
			else
				add_metadata (info, tag_key, g_strdup ("FALSE"), NULL);
		}
	}

	if (tag_type == G_TYPE_STRING) {
		char *ret = NULL;
		if (gst_tag_list_get_string (list, tag, &ret))
			add_metadata (info, tag_key, ret, NULL);
	}

        if (tag_type == G_TYPE_UCHAR) {
                guint ret = 0;
                if (gst_tag_list_get_uint (list, tag, &ret))
                        add_metadata (info, tag_key, g_strdup_printf ("%u", ret), NULL);
        }

        if (tag_type == G_TYPE_CHAR) {
                int ret = 0;
                if (gst_tag_list_get_int (list, tag, &ret))
                        add_metadata (info, tag_key, g_strdup_printf ("%d", ret), NULL);
        }

        if (tag_type == G_TYPE_UINT) {
                guint ret = 0;
                if (gst_tag_list_get_uint (list, tag, &ret))
                        add_metadata (info, tag_key, g_strdup_printf ("%u", ret), NULL);
        }

        if (tag_type == G_TYPE_INT) {
                gint ret = 0;
                if (gst_tag_list_get_int (list, tag, &ret))
                        add_metadata (info, tag_key, g_strdup_printf ("%d", ret), NULL);
        }

        if (tag_type == G_TYPE_ULONG) {
                guint64 ret = 0;
                if (gst_tag_list_get_uint64 (list, tag, &ret))
                        add_metadata (info, tag_key, g_strdup_printf ("%" G_GUINT64_FORMAT, ret), NULL);
        }

        if (tag_type == G_TYPE_LONG) {
                gint64 ret = 0;
                if (gst_tag_list_get_int64 (list, tag, &ret))
                        add_metadata (info, tag_key, g_strdup_printf ("%" G_GINT64_FORMAT, ret), NULL);
        }

        if (tag_type == G_TYPE_INT64) {
                gint64 ret = 0;
                if (gst_tag_list_get_int64 (list, tag, &ret))
                        add_metadata (info, tag_key, g_strdup_printf ("%" G_GINT64_FORMAT, ret), NULL);
        }

        if (tag_type == G_TYPE_UINT64) {
                guint64 ret = 0;
                if (gst_tag_list_get_uint64 (list, tag, &ret))
                        add_metadata (info, tag_key, g_strdup_printf ("%" G_GUINT64_FORMAT, ret), NULL);
        }

        if (tag_type == G_TYPE_DOUBLE) {
                gdouble ret = 0;
                if (gst_tag_list_get_double (list, tag, &ret))
                        add_metadata (info, tag_key, g_strdup_printf ("%f", ret), NULL);
        }

        if (tag_type == G_TYPE_FLOAT) {
                gfloat ret = 0;
                if (gst_tag_list_get_float (list, tag, &ret))
                        add_metadata (info, tag_key, g_strdup_printf ("%f", ret), NULL);
        }

        if (tag_type == G_TYPE_DATE) {
                GDate *ret = NULL;
                if (gst_tag_list_get_date (list, tag, &ret)) {
			if (ret != NULL) {
				char  buf[128];
				char *raw;
				char *formatted;

				g_date_strftime (buf, 10, "%F %T", ret);
				raw = g_strdup (buf);

				g_date_strftime (buf, 10, "%x %X", ret);
				formatted = g_strdup (buf);
				add_metadata (info, tag_key, raw, formatted);
			}
			g_free (ret);
		}
        }
}
Exemplo n.º 12
0
/* This function prepares the movie to receivve the movie data,
 * After success, *out_map points to a valid stream maping
 * Return values:
 *	  0: ok
 */
OSStatus prepare_movie(ff_global_ptr storage, Movie theMovie, Handle dataRef, OSType dataRefType)
{
    int j;
    AVStream *st;
    NCStream *map;
    Track track = NULL;
    Track first_audio_track = NULL;
    AVFormatContext *ic = storage->format_context;
    OSStatus err = noErr;

    /* make the stream map structure */
    map = av_mallocz(ic->nb_streams * sizeof(NCStream));

    for(j = 0; j < ic->nb_streams; j++) {

        st = ic->streams[j];
        map[j].index = st->index;
        map[j].str = st;
        map[j].duration = -1;

        if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
            Fixed width, height;

            get_track_dimensions_for_codec(st, &width, &height);
            track = NewMovieTrack(theMovie, width, height, kNoVolume);

            // Support for 'old' NUV files, that didn't put the codec_tag in the file.
            if( st->codec->codec_id == CODEC_ID_NUV && st->codec->codec_tag == 0 ) {
                st->codec->codec_tag = MKTAG( 'N', 'U', 'V', '1' );
            }

            initialize_video_map(&map[j], track, dataRef, dataRefType, storage->firstFrames + j);
            set_track_clean_aperture_ext((ImageDescriptionHandle)map[j].sampleHdl, width, height, IntToFixed(st->codec->width), IntToFixed(st->codec->height));
            set_track_colorspace_ext((ImageDescriptionHandle)map[j].sampleHdl, width, height);
        } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
            if (st->codec->sample_rate > 0) {
                track = NewMovieTrack(theMovie, 0, 0, kFullVolume);
                err = initialize_audio_map(&map[j], track, dataRef, dataRefType, storage->firstFrames + j);

                if (first_audio_track == NULL)
                    first_audio_track = track;
                else
                    SetTrackAlternate(track, first_audio_track);
            }
        } else
            continue;

        // can't import samples if neither of these were created.
        map[j].valid = map[j].media && map[j].sampleHdl;

        if (err) {
            if (track)
                DisposeMovieTrack(track);
            return err;
        }
    }

    add_metadata(ic, theMovie);

    storage->stream_map = map;

    return 0;
} /* prepare_movie() */