gboolean get_name_info_from_component (Component componentID, ComponentDescription * desc, gchar ** name, gchar ** info) { Handle nameHandle = NewHandle (200); Handle infoHandle = NewHandle (200); gchar *tmpname; gchar *tmpinfo; OSErr result; gboolean ret = TRUE; result = GetComponentInfo (componentID, desc, nameHandle, infoHandle, NULL); if (result != noErr) { ret = FALSE; goto done; } #if DEBUG_DUMP GST_LOG ("ComponentDescription dump"); gst_util_dump_mem ((const guchar *) desc, sizeof (ComponentDescription)); gst_util_dump_mem ((gpointer) * nameHandle, 200); gst_util_dump_mem ((gpointer) * infoHandle, 200); GST_LOG ("0x%x 0x%x", **((guint8 **) nameHandle), **((guint8 **) infoHandle)); #endif if (*nameHandle && name) { gsize read, written; tmpname = g_strndup ((*(char **) nameHandle) + 1, **((guint8 **) nameHandle)); *name = g_convert_with_fallback (tmpname, -1, "ASCII", "MAC", (gchar *) " ", &read, &written, NULL); if (!*name) GST_WARNING ("read:%" G_GSIZE_FORMAT ", written:%" G_GSIZE_FORMAT, read, written); g_free (tmpname); } if (*infoHandle && info) { tmpinfo = g_strndup ((*(char **) infoHandle) + 1, **((guint8 **) infoHandle)); *info = g_convert_with_fallback (tmpinfo, -1, "ASCII", "MAC", (gchar *) " ", NULL, NULL, NULL); g_free (tmpinfo); } done: DisposeHandle (nameHandle); DisposeHandle (infoHandle); return ret; }
void dump_codec_decompress_params (CodecDecompressParams * params) { GST_LOG ("params %p", params); #if DEBUG_DUMP gst_util_dump_mem ((const guchar *) params, sizeof (CodecDecompressParams)); #endif GST_LOG ("SequenceID:%ld", params->sequenceID); GST_LOG ("imageDescription:%p", params->imageDescription); GST_LOG ("data:%p", params->data); GST_LOG ("bufferSize:%ld", params->bufferSize); GST_LOG ("frameNumber:%ld", params->frameNumber); GST_LOG ("startLine:%ld , StopLine:%ld", params->startLine, params->stopLine); GST_LOG ("conditionFlags:0x%lx", params->conditionFlags); GST_LOG ("callerFlags:0x%x", params->callerFlags); GST_LOG ("capabilities:%p", params->capabilities); GST_LOG ("port:%p", params->port); GST_LOG ("dstPixMap"); #if DEBUG_DUMP gst_util_dump_mem ((const guchar *) ¶ms->dstPixMap, sizeof (PixMap)); #endif GST_LOG ("maskBits:%p", params->maskBits); GST_LOG ("mattePixMap:%p", params->mattePixMap); GST_LOG ("srcRect %d/%d/%d/%d", params->srcRect.top, params->srcRect.bottom, params->srcRect.left, params->srcRect.right); GST_LOG ("matrix:%p", params->matrix); GST_LOG ("accuracy:%ld", params->accuracy); GST_LOG ("transferMode:%d", params->transferMode); GST_LOG ("frameTime:%p", params->frameTime); GST_LOG ("matrixFlags:%x", params->matrixFlags); GST_LOG ("dstRect %d/%d/%d/%d", params->dstRect.top, params->dstRect.bottom, params->dstRect.left, params->dstRect.right); GST_LOG ("sourceData:%p", params->sourceData); if (params->wantedDestinationPixelTypes) { OSType *tmp; for (tmp = *params->wantedDestinationPixelTypes; *tmp; tmp++) GST_LOG ("Destination pixel %" GST_FOURCC_FORMAT, QT_FOURCC_ARGS (*tmp)); } }
/** * gst_rtsp_message_dump: * @msg: a #GstRTSPMessage * * Dump the contents of @msg to stdout. * * Returns: #GST_RTSP_OK. */ GstRTSPResult gst_rtsp_message_dump (GstRTSPMessage * msg) { guint8 *data; guint size; g_return_val_if_fail (msg != NULL, GST_RTSP_EINVAL); switch (msg->type) { case GST_RTSP_MESSAGE_REQUEST: g_print ("RTSP request message %p\n", msg); g_print (" request line:\n"); g_print (" method: '%s'\n", gst_rtsp_method_as_text (msg->type_data.request.method)); g_print (" uri: '%s'\n", msg->type_data.request.uri); g_print (" version: '%s'\n", gst_rtsp_version_as_text (msg->type_data.request.version)); g_print (" headers:\n"); key_value_foreach (msg->hdr_fields, dump_key_value, NULL); g_print (" body:\n"); gst_rtsp_message_get_body (msg, &data, &size); gst_util_dump_mem (data, size); break; case GST_RTSP_MESSAGE_RESPONSE: g_print ("RTSP response message %p\n", msg); g_print (" status line:\n"); g_print (" code: '%d'\n", msg->type_data.response.code); g_print (" reason: '%s'\n", msg->type_data.response.reason); g_print (" version: '%s'\n", gst_rtsp_version_as_text (msg->type_data.response.version)); g_print (" headers:\n"); key_value_foreach (msg->hdr_fields, dump_key_value, NULL); gst_rtsp_message_get_body (msg, &data, &size); g_print (" body: length %d\n", size); gst_util_dump_mem (data, size); break; case GST_RTSP_MESSAGE_DATA: g_print ("RTSP data message %p\n", msg); g_print (" channel: '%d'\n", msg->type_data.data.channel); g_print (" size: '%d'\n", msg->body_size); gst_rtsp_message_get_body (msg, &data, &size); gst_util_dump_mem (data, size); break; default: g_print ("unsupported message type %d\n", msg->type); return GST_RTSP_EINVAL; } return GST_RTSP_OK; }
static gpointer make_samr_magic_cookie (GstBuffer * codec_data, gsize * len) { guint8 *res; *len = 48; res = g_malloc0 (0x30); /* 12 first bytes are 'frma' (format) atom with 'samr' value */ GST_WRITE_UINT32_BE (res, 0xc); GST_WRITE_UINT32_LE (res + 4, QT_MAKE_FOURCC_BE ('f', 'r', 'm', 'a')); GST_WRITE_UINT32_LE (res + 8, QT_MAKE_FOURCC_BE ('s', 'a', 'm', 'r')); /* 10 bytes for 'enda' atom with 0 */ GST_WRITE_UINT32_BE (res + 12, 10); GST_WRITE_UINT32_LE (res + 16, QT_MAKE_FOURCC_BE ('e', 'n', 'd', 'a')); /* 17(+1) bytes for the codec_data contents */ GST_WRITE_UINT32_BE (res + 22, 18); memcpy (res + 26, GST_BUFFER_DATA (codec_data) + 4, 17); /* yes... we need to replace 'damr' by 'samr'. Blame Apple ! */ GST_WRITE_UINT8 (res + 26, 's'); /* Terminator atom */ GST_WRITE_UINT32_BE (res + 40, 8); #if DEBUG_DUMP gst_util_dump_mem (res, 48); #endif return res; }
static GstFlowReturn gst_fake_sink_render (GstBaseSink * bsink, GstBuffer * buf) { GstFakeSink *sink = GST_FAKE_SINK_CAST (bsink); if (sink->num_buffers_left == 0) goto eos; if (sink->num_buffers_left != -1) sink->num_buffers_left--; if (!sink->silent) { gchar ts_str[64], dur_str[64]; GST_OBJECT_LOCK (sink); g_free (sink->last_message); if (GST_BUFFER_TIMESTAMP (buf) != GST_CLOCK_TIME_NONE) { g_snprintf (ts_str, sizeof (ts_str), "%" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf))); } else { g_strlcpy (ts_str, "none", sizeof (ts_str)); } if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE) { g_snprintf (dur_str, sizeof (dur_str), "%" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_DURATION (buf))); } else { g_strlcpy (dur_str, "none", sizeof (dur_str)); } sink->last_message = g_strdup_printf ("chain ******* < (%5d bytes, timestamp: %s" ", duration: %s, offset: %" G_GINT64_FORMAT ", offset_end: %" G_GINT64_FORMAT ", flags: %d) %p", GST_BUFFER_SIZE (buf), ts_str, dur_str, GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf), GST_MINI_OBJECT_CAST (buf)->flags, buf); GST_OBJECT_UNLOCK (sink); gst_fake_sink_notify_last_message (sink); } if (sink->signal_handoffs) g_signal_emit (sink, gst_fake_sink_signals[SIGNAL_HANDOFF], 0, buf, bsink->sinkpad); if (sink->dump) { gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); } if (sink->num_buffers_left == 0) goto eos; return GST_FLOW_OK; /* ERRORS */ eos: { GST_DEBUG_OBJECT (sink, "we are EOS"); return GST_FLOW_UNEXPECTED; } }
void dump_image_description (ImageDescription * desc) { GST_LOG ("Description %p , size:%" G_GSIZE_FORMAT, desc, desc->idSize); #if DEBUG_DUMP gst_util_dump_mem ((const guchar *) desc, desc->idSize); #endif GST_LOG ("cType : %" GST_FOURCC_FORMAT, QT_FOURCC_ARGS (desc->cType)); GST_LOG ("version:%d", desc->version); GST_LOG ("revisionLevel:%d", desc->revisionLevel); GST_LOG ("vendor:%" GST_FOURCC_FORMAT, QT_FOURCC_ARGS (desc->vendor)); GST_LOG ("temporalQuality:%lu", desc->temporalQuality); GST_LOG ("spatialQuality:%lu", desc->spatialQuality); GST_LOG ("width:%u", desc->width); GST_LOG ("height:%u", desc->height); GST_LOG ("hres:%f", desc->hRes / 65536.0); GST_LOG ("vres:%f", desc->vRes / 65536.0); GST_LOG ("dataSize:%" G_GSIZE_FORMAT, desc->dataSize); GST_LOG ("frameCount:%d", desc->frameCount); GST_LOG ("name:%.*s", desc->name[0], desc->name + 1); GST_LOG ("depth:%d", desc->depth); GST_LOG ("clutID:%d", desc->clutID); if (desc->idSize > sizeof (ImageDescription)) { guint8 *extradata = (guint8 *) desc + sizeof (ImageDescription); guint32 type = QT_READ_UINT32 (extradata + 4); GST_LOG ("Extra Data size:%lu", (gulong) desc->idSize - (gulong) sizeof (ImageDescription)); #if DEBUG_DUMP gst_util_dump_mem ((gpointer) (gulong) desc + (gulong) sizeof (ImageDescription), (gulong) desc->idSize - (gulong) sizeof (ImageDescription)); #endif GST_LOG ("Extra Data Type : %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (type)); if (type == QT_MAKE_FOURCC ('a', 'v', 'c', 'C')) dump_avcc_atom (extradata); } }
static GstBuffer * gst_fake_src_create_buffer (GstFakeSrc * src, gsize * bufsize) { GstBuffer *buf; gsize size = gst_fake_src_get_size (src); gboolean dump = src->dump; GstMapInfo info; *bufsize = size; switch (src->data) { case FAKE_SRC_DATA_ALLOCATE: buf = gst_fake_src_alloc_buffer (src, size); break; case FAKE_SRC_DATA_SUBBUFFER: /* see if we have a parent to subbuffer */ if (!src->parent) { gst_fake_src_alloc_parent (src); g_assert (src->parent); } /* see if it's large enough */ if ((src->parentsize - src->parentoffset) >= size) { buf = gst_buffer_copy_region (src->parent, GST_BUFFER_COPY_ALL, src->parentoffset, size); src->parentoffset += size; } else { /* the parent is useless now */ gst_buffer_unref (src->parent); src->parent = NULL; /* try again (this will allocate a new parent) */ return gst_fake_src_create_buffer (src, bufsize); } gst_buffer_map (buf, &info, GST_MAP_WRITE); gst_fake_src_prepare_buffer (src, info.data, info.size); gst_buffer_unmap (buf, &info); break; default: g_warning ("fakesrc: dunno how to allocate buffers !"); buf = gst_buffer_new (); break; } if (dump) { gst_buffer_map (buf, &info, GST_MAP_READ); gst_util_dump_mem (info.data, info.size); gst_buffer_unmap (buf, &info); } return buf; }
static ImageDescription * image_description_from_stsd_buffer (GstBuffer * buf) { ImageDescription *desc = NULL; guint8 *content; guint size; gint imds; GST_LOG ("buffer %p, size:%u", buf, GST_BUFFER_SIZE (buf)); /* The buffer contains a full atom, we only need the contents */ /* This buffer has data in big-endian, we need to read it as such. * except for the fourcc which are ALWAYS big-endian. */ content = GST_BUFFER_DATA (buf) + 16; size = GST_BUFFER_SIZE (buf) - 16; #if DEBUG_DUMP GST_LOG ("incoming data in big-endian"); gst_util_dump_mem (content, size); #endif desc = g_malloc0 (size); desc->idSize = size; desc->cType = GST_READ_UINT32_BE (content + 4); desc->version = QT_UINT16 (content + 16); desc->revisionLevel = QT_UINT16 (content + 18); desc->vendor = GST_READ_UINT32_BE (content + 20); desc->temporalQuality = QT_UINT32 (content + 24); desc->spatialQuality = QT_UINT32 (content + 24); desc->dataSize = QT_UINT32 (content + 44); desc->frameCount = QT_UINT16 (content + 48); desc->depth = QT_UINT16 (content + 82); desc->clutID = QT_UINT16 (content + 84); imds = 86; /* sizeof (ImageDescription); */ if (desc->idSize > imds) { GST_LOG ("Copying %d bytes from %p to %p", size - imds, content + imds, desc + imds); memcpy ((guint8 *) desc + imds, (guint8 *) content + imds, size - imds); } #if DEBUG_DUMP GST_LOG ("outgoing data in machine-endian"); dump_image_description (desc); #endif return desc; }
static GstBuffer * gst_fake_src_create_buffer (GstFakeSrc * src) { GstBuffer *buf; guint size; gboolean dump = src->dump; size = gst_fake_src_get_size (src); if (size == 0) return gst_buffer_new (); switch (src->data) { case FAKE_SRC_DATA_ALLOCATE: buf = gst_fake_src_alloc_buffer (src, size); break; case FAKE_SRC_DATA_SUBBUFFER: /* see if we have a parent to subbuffer */ if (!src->parent) { gst_fake_src_alloc_parent (src); g_assert (src->parent); } /* see if it's large enough */ if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) { buf = gst_buffer_create_sub (src->parent, src->parentoffset, size); src->parentoffset += size; } else { /* the parent is useless now */ gst_buffer_unref (src->parent); src->parent = NULL; /* try again (this will allocate a new parent) */ return gst_fake_src_create_buffer (src); } gst_fake_src_prepare_buffer (src, buf); break; default: g_warning ("fakesrc: dunno how to allocate buffers !"); buf = gst_buffer_new (); break; } if (dump) { gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); } return buf; }
static void process_file (const gchar * fn) { GError *err = NULL; gchar *data = NULL; gsize size = 0; guint i; g_print ("===============================================================\n"); g_print (" %s\n", fn); g_print ("===============================================================\n"); if (!g_file_get_contents (fn, &data, &size, &err)) { g_error ("%s", err->message); g_error_free (err); return; } parse_jpeg ((const guint8 *) data, size); for (i = 0; i < G_N_ELEMENTS (app_segments); ++i) { if (app_segments[i] != NULL) { GstMapInfo map = GST_MAP_INFO_INIT; /* Could parse/extract tags here */ gst_buffer_map (app_segments[i], &map, GST_MAP_READ); g_print ("\tAPP%-2u : %u bytes\n", i, (guint) map.size); gst_util_dump_mem ((guchar *) map.data, MIN (map.size, 16)); gst_buffer_unmap (app_segments[i], &map); gst_buffer_unref (app_segments[i]); app_segments[i] = NULL; } } g_free (data); }
static GstFlowReturn gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf) { GstFlowReturn ret = GST_FLOW_OK; GstIdentity *identity = GST_IDENTITY (trans); GstClockTime runtimestamp = G_GINT64_CONSTANT (0); gsize size; size = gst_buffer_get_size (buf); if (identity->check_imperfect_timestamp) gst_identity_check_imperfect_timestamp (identity, buf); if (identity->check_imperfect_offset) gst_identity_check_imperfect_offset (identity, buf); /* update prev values */ identity->prev_timestamp = GST_BUFFER_TIMESTAMP (buf); identity->prev_duration = GST_BUFFER_DURATION (buf); identity->prev_offset_end = GST_BUFFER_OFFSET_END (buf); identity->prev_offset = GST_BUFFER_OFFSET (buf); if (identity->error_after >= 0) { identity->error_after--; if (identity->error_after == 0) goto error_after; } if (identity->drop_probability > 0.0) { if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) goto dropped; } if (identity->dump) { GstMapInfo info; gst_buffer_map (buf, &info, GST_MAP_READ); gst_util_dump_mem (info.data, info.size); gst_buffer_unmap (buf, &info); } if (!identity->silent) { gst_identity_update_last_message_for_buffer (identity, "chain", buf, size); } if (identity->datarate > 0) { GstClockTime time = gst_util_uint64_scale_int (identity->offset, GST_SECOND, identity->datarate); GST_BUFFER_TIMESTAMP (buf) = time; GST_BUFFER_DURATION (buf) = size * GST_SECOND / identity->datarate; } if (identity->signal_handoffs) g_signal_emit (identity, gst_identity_signals[SIGNAL_HANDOFF], 0, buf); if (trans->segment.format == GST_FORMAT_TIME) runtimestamp = gst_segment_to_running_time (&trans->segment, GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buf)); if ((identity->sync) && (trans->segment.format == GST_FORMAT_TIME)) { GstClock *clock; GST_OBJECT_LOCK (identity); if ((clock = GST_ELEMENT (identity)->clock)) { GstClockReturn cret; GstClockTime timestamp; timestamp = runtimestamp + GST_ELEMENT (identity)->base_time; /* save id if we need to unlock */ identity->clock_id = gst_clock_new_single_shot_id (clock, timestamp); GST_OBJECT_UNLOCK (identity); cret = gst_clock_id_wait (identity->clock_id, NULL); GST_OBJECT_LOCK (identity); if (identity->clock_id) { gst_clock_id_unref (identity->clock_id); identity->clock_id = NULL; } if (cret == GST_CLOCK_UNSCHEDULED) ret = GST_FLOW_EOS; } GST_OBJECT_UNLOCK (identity); } identity->offset += size; if (identity->sleep_time && ret == GST_FLOW_OK) g_usleep (identity->sleep_time); if (identity->single_segment && (trans->segment.format == GST_FORMAT_TIME) && (ret == GST_FLOW_OK)) { GST_BUFFER_TIMESTAMP (buf) = runtimestamp; GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE; GST_BUFFER_OFFSET_END (buf) = GST_CLOCK_TIME_NONE; } return ret; /* ERRORS */ error_after: { GST_ELEMENT_ERROR (identity, CORE, FAILED, (_("Failed after iterations as requested.")), (NULL)); return GST_FLOW_ERROR; } dropped: { if (!identity->silent) { gst_identity_update_last_message_for_buffer (identity, "dropping", buf, size); } /* return DROPPED to basetransform. */ return GST_BASE_TRANSFORM_FLOW_DROPPED; } }
static GstFlowReturn gst_fake_sink_render (GstBaseSink * bsink, GstBuffer * buf) { GstFakeSink *sink = GST_FAKE_SINK_CAST (bsink); if (sink->num_buffers_left == 0) goto eos; if (sink->num_buffers_left != -1) sink->num_buffers_left--; if (!sink->silent) { gchar dts_str[64], pts_str[64], dur_str[64]; gchar *flag_str, *meta_str; GST_OBJECT_LOCK (sink); g_free (sink->last_message); if (GST_BUFFER_DTS (buf) != GST_CLOCK_TIME_NONE) { g_snprintf (dts_str, sizeof (dts_str), "%" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_DTS (buf))); } else { g_strlcpy (dts_str, "none", sizeof (dts_str)); } if (GST_BUFFER_PTS (buf) != GST_CLOCK_TIME_NONE) { g_snprintf (pts_str, sizeof (pts_str), "%" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_PTS (buf))); } else { g_strlcpy (pts_str, "none", sizeof (pts_str)); } if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE) { g_snprintf (dur_str, sizeof (dur_str), "%" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_DURATION (buf))); } else { g_strlcpy (dur_str, "none", sizeof (dur_str)); } flag_str = gst_buffer_get_flags_string (buf); meta_str = gst_buffer_get_meta_string (buf); sink->last_message = g_strdup_printf ("chain ******* (%s:%s) (%u bytes, dts: %s, pts: %s" ", duration: %s, offset: %" G_GINT64_FORMAT ", offset_end: %" G_GINT64_FORMAT ", flags: %08x %s, meta: %s) %p", GST_DEBUG_PAD_NAME (GST_BASE_SINK_CAST (sink)->sinkpad), (guint) gst_buffer_get_size (buf), dts_str, pts_str, dur_str, GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf), GST_MINI_OBJECT_CAST (buf)->flags, flag_str, meta_str ? meta_str : "none", buf); g_free (flag_str); g_free (meta_str); GST_OBJECT_UNLOCK (sink); gst_fake_sink_notify_last_message (sink); } if (sink->signal_handoffs) g_signal_emit (sink, gst_fake_sink_signals[SIGNAL_HANDOFF], 0, buf, bsink->sinkpad); if (sink->dump) { GstMapInfo info; if (gst_buffer_map (buf, &info, GST_MAP_READ)) { gst_util_dump_mem (info.data, info.size); gst_buffer_unmap (buf, &info); } } if (sink->num_buffers_left == 0) goto eos; return GST_FLOW_OK; /* ERRORS */ eos: { GST_DEBUG_OBJECT (sink, "we are EOS"); return GST_FLOW_EOS; } }
static GstFlowReturn gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf) { GstFlowReturn ret = GST_FLOW_OK; GstIdentity *identity = GST_IDENTITY (trans); GstClockTime rundts = GST_CLOCK_TIME_NONE; GstClockTime runpts = GST_CLOCK_TIME_NONE; GstClockTime ts, duration, runtimestamp; gsize size; size = gst_buffer_get_size (buf); if (identity->check_imperfect_timestamp) gst_identity_check_imperfect_timestamp (identity, buf); if (identity->check_imperfect_offset) gst_identity_check_imperfect_offset (identity, buf); /* update prev values */ identity->prev_timestamp = GST_BUFFER_TIMESTAMP (buf); identity->prev_duration = GST_BUFFER_DURATION (buf); identity->prev_offset_end = GST_BUFFER_OFFSET_END (buf); identity->prev_offset = GST_BUFFER_OFFSET (buf); if (identity->error_after >= 0) { identity->error_after--; if (identity->error_after == 0) goto error_after; } if (identity->drop_probability > 0.0) { if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) goto dropped; } if (identity->dump) { GstMapInfo info; gst_buffer_map (buf, &info, GST_MAP_READ); gst_util_dump_mem (info.data, info.size); gst_buffer_unmap (buf, &info); } if (!identity->silent) { gst_identity_update_last_message_for_buffer (identity, "chain", buf, size); } if (identity->datarate > 0) { GstClockTime time = gst_util_uint64_scale_int (identity->offset, GST_SECOND, identity->datarate); GST_BUFFER_PTS (buf) = GST_BUFFER_DTS (buf) = time; GST_BUFFER_DURATION (buf) = size * GST_SECOND / identity->datarate; } if (identity->signal_handoffs) g_signal_emit (identity, gst_identity_signals[SIGNAL_HANDOFF], 0, buf); if (trans->segment.format == GST_FORMAT_TIME) { rundts = gst_segment_to_running_time (&trans->segment, GST_FORMAT_TIME, GST_BUFFER_DTS (buf)); runpts = gst_segment_to_running_time (&trans->segment, GST_FORMAT_TIME, GST_BUFFER_PTS (buf)); } if (GST_CLOCK_TIME_IS_VALID (rundts)) runtimestamp = rundts; else if (GST_CLOCK_TIME_IS_VALID (runpts)) runtimestamp = runpts; else runtimestamp = 0; ret = gst_identity_do_sync (identity, runtimestamp); identity->offset += size; if (identity->sleep_time && ret == GST_FLOW_OK) g_usleep (identity->sleep_time); if (identity->single_segment && (trans->segment.format == GST_FORMAT_TIME) && (ret == GST_FLOW_OK)) { GST_BUFFER_DTS (buf) = rundts; GST_BUFFER_PTS (buf) = runpts; GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE; GST_BUFFER_OFFSET_END (buf) = GST_CLOCK_TIME_NONE; } return ret; /* ERRORS */ error_after: { GST_ELEMENT_ERROR (identity, CORE, FAILED, (_("Failed after iterations as requested.")), (NULL)); return GST_FLOW_ERROR; } dropped: { if (!identity->silent) { gst_identity_update_last_message_for_buffer (identity, "dropping", buf, size); } ts = GST_BUFFER_TIMESTAMP (buf); if (GST_CLOCK_TIME_IS_VALID (ts)) { duration = GST_BUFFER_DURATION (buf); gst_pad_push_event (GST_BASE_TRANSFORM_SRC_PAD (identity), gst_event_new_gap (ts, duration)); } /* return DROPPED to basetransform. */ return GST_BASE_TRANSFORM_FLOW_DROPPED; } }
static GstFlowReturn gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf) { GstFlowReturn ret = GST_FLOW_OK; GstIdentity *identity = GST_IDENTITY (trans); GstClockTime runtimestamp = G_GINT64_CONSTANT (0); if (identity->check_perfect) gst_identity_check_perfect (identity, buf); if (identity->check_imperfect_timestamp) gst_identity_check_imperfect_timestamp (identity, buf); if (identity->check_imperfect_offset) gst_identity_check_imperfect_offset (identity, buf); /* update prev values */ identity->prev_timestamp = GST_BUFFER_TIMESTAMP (buf); identity->prev_duration = GST_BUFFER_DURATION (buf); identity->prev_offset_end = GST_BUFFER_OFFSET_END (buf); identity->prev_offset = GST_BUFFER_OFFSET (buf); if (identity->error_after >= 0) { identity->error_after--; if (identity->error_after == 0) { GST_ELEMENT_ERROR (identity, CORE, FAILED, (_("Failed after iterations as requested.")), (NULL)); return GST_FLOW_ERROR; } } if (identity->drop_probability > 0.0) { if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) { if (!identity->silent) { GST_OBJECT_LOCK (identity); g_free (identity->last_message); identity->last_message = g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, timestamp: %" GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ", offset: %" G_GINT64_FORMAT ", offset_end: % " G_GINT64_FORMAT ", flags: %d) %p", GST_DEBUG_PAD_NAME (trans->sinkpad), GST_BUFFER_SIZE (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf), GST_BUFFER_FLAGS (buf), buf); GST_OBJECT_UNLOCK (identity); g_object_notify (G_OBJECT (identity), "last-message"); } /* return DROPPED to basetransform. */ return GST_BASE_TRANSFORM_FLOW_DROPPED; } } if (identity->dump) { gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); } if (!identity->silent) { GST_OBJECT_LOCK (identity); g_free (identity->last_message); identity->last_message = g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, timestamp: %" GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ", offset: %" G_GINT64_FORMAT ", offset_end: % " G_GINT64_FORMAT ", flags: %d) %p", GST_DEBUG_PAD_NAME (trans->sinkpad), GST_BUFFER_SIZE (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf), GST_BUFFER_FLAGS (buf), buf); GST_OBJECT_UNLOCK (identity); g_object_notify (G_OBJECT (identity), "last-message"); } if (identity->datarate > 0) { GstClockTime time = gst_util_uint64_scale_int (identity->offset, GST_SECOND, identity->datarate); GST_BUFFER_TIMESTAMP (buf) = time; GST_BUFFER_DURATION (buf) = GST_BUFFER_SIZE (buf) * GST_SECOND / identity->datarate; } if (identity->signal_handoffs) g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0, buf); if (trans->segment.format == GST_FORMAT_TIME) runtimestamp = gst_segment_to_running_time (&trans->segment, GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buf)); if ((identity->sync) && (trans->segment.format == GST_FORMAT_TIME)) { GstClock *clock; GST_OBJECT_LOCK (identity); if ((clock = GST_ELEMENT (identity)->clock)) { GstClockReturn cret; GstClockTime timestamp; timestamp = runtimestamp + GST_ELEMENT (identity)->base_time; /* save id if we need to unlock */ /* FIXME: actually unlock this somewhere in the state changes */ identity->clock_id = gst_clock_new_single_shot_id (clock, timestamp); GST_OBJECT_UNLOCK (identity); cret = gst_clock_id_wait (identity->clock_id, NULL); GST_OBJECT_LOCK (identity); if (identity->clock_id) { gst_clock_id_unref (identity->clock_id); identity->clock_id = NULL; } if (cret == GST_CLOCK_UNSCHEDULED) ret = GST_FLOW_UNEXPECTED; } GST_OBJECT_UNLOCK (identity); } identity->offset += GST_BUFFER_SIZE (buf); if (identity->sleep_time && ret == GST_FLOW_OK) g_usleep (identity->sleep_time); if (identity->single_segment && (trans->segment.format == GST_FORMAT_TIME) && (ret == GST_FLOW_OK)) { GST_BUFFER_TIMESTAMP (buf) = runtimestamp; GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE; GST_BUFFER_OFFSET_END (buf) = GST_CLOCK_TIME_NONE; } return ret; }
gboolean get_output_info_from_component (Component componentID) { gboolean ret = FALSE; ComponentInstance instance; ImageSubCodecDecompressCapabilities caps; CodecInfo info; GST_LOG ("Creating an instance"); /* 1. Create an instance */ if (!(instance = OpenComponent (componentID))) { GST_WARNING ("Couldn't open component"); return FALSE; } /* 2. initialize */ memset (&caps, 0, sizeof (ImageSubCodecDecompressCapabilities)); if (ImageCodecInitialize (instance, &caps) != noErr) { GST_WARNING ("ImageCodecInitialize() failed"); goto beach; } #if DEBUG_DUMP GST_LOG ("ImageSubCodecDecompressCapabilities"); gst_util_dump_mem ((const guchar *) &caps, sizeof (ImageSubCodecDecompressCapabilities)); #endif GST_LOG ("recordSize:%ld", caps.recordSize); GST_LOG ("decompressRecordSize:%ld", caps.decompressRecordSize); GST_LOG ("canAsync:%d", caps.canAsync); /* 3. Get codec info */ memset (&info, 0, sizeof (CodecInfo)); if (ImageCodecGetCodecInfo (instance, &info) != noErr) { GST_WARNING ("ImageCodecInfo() failed"); goto beach; }; #if DEBUG_DUMP GST_LOG ("CodecInfo"); gst_util_dump_mem ((const guchar *) &info, sizeof (CodecInfo)); #endif GST_LOG ("version:%d", info.version); GST_LOG ("revisionLevel:%d", info.revisionLevel); GST_LOG ("vendor:%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (info.vendor)); /* Compression flags */ /* Contains flags (see below) that specify the decompression capabilities of * the component. Typically, these flags are of interest only to developers of * image decompressors. */ GST_LOG ("decompressFlags:%lx", info.decompressFlags); if (info.decompressFlags & codecInfoDoes1) GST_LOG ("Depth 1 OK"); if (info.decompressFlags & codecInfoDoes2) GST_LOG ("Depth 2 OK"); if (info.decompressFlags & codecInfoDoes4) GST_LOG ("Depth 4 OK"); if (info.decompressFlags & codecInfoDoes8) GST_LOG ("Depth 8 OK"); if (info.decompressFlags & codecInfoDoes16) GST_LOG ("Depth 16 OK"); if (info.decompressFlags & codecInfoDoes32) GST_LOG ("Depth 32 OK"); GST_LOG ("compressFlags:%lx", info.compressFlags); /* Format FLAGS */ /* Contains flags (see below) that describe the possible format for compressed * data produced by this component and the format of compressed files that the * component can handle during decompression. Typically, these flags are of * interest only to developers of compressor components. */ GST_LOG ("formatFlags:%lx", info.formatFlags); if (info.formatFlags & codecInfoDepth1) GST_LOG ("Depth 1 OK"); if (info.formatFlags & codecInfoDepth2) GST_LOG ("Depth 2 OK"); if (info.formatFlags & codecInfoDepth4) GST_LOG ("Depth 4 OK"); if (info.formatFlags & codecInfoDepth8) GST_LOG ("Depth 8 OK"); if (info.formatFlags & codecInfoDepth16) GST_LOG ("Depth 16 OK"); if (info.formatFlags & codecInfoDepth24) GST_LOG ("Depth 24 OK"); if (info.formatFlags & codecInfoDepth32) GST_LOG ("Depth 32 OK"); if (info.formatFlags & codecInfoDepth33) GST_LOG ("Depth 33 OK"); if (info.formatFlags & codecInfoDepth34) GST_LOG ("Depth 34 OK"); if (info.formatFlags & codecInfoDepth36) GST_LOG ("Depth 36 OK"); if (info.formatFlags & codecInfoDepth40) GST_LOG ("Depth 40 OK"); if (info.formatFlags & codecInfoStoresClut) GST_LOG ("StoresClut OK"); if (info.formatFlags & codecInfoDoesLossless) GST_LOG ("Lossless OK"); if (info.formatFlags & codecInfoSequenceSensitive) GST_LOG ("SequenceSentitive OK"); GST_LOG ("compressionAccuracy:%u", info.compressionAccuracy); GST_LOG ("decompressionAccuracy:%u", info.decompressionAccuracy); GST_LOG ("compressionSpeed:%d", info.compressionSpeed); GST_LOG ("decompressionSpeed:%d", info.decompressionSpeed); GST_LOG ("compressionLevel:%u", info.compressionLevel); GST_LOG ("minimumHeight:%d", info.minimumHeight); GST_LOG ("minimumWidth:%d", info.minimumWidth); /* /\* . Call ImageCodecPreDecompress *\/ */ /* memset(¶ms, 0, sizeof(CodecDecompressParams)); */ /* GST_LOG ("calling imagecodecpredecompress"); */ /* if (ImageCodecPreDecompress (instance, ¶ms) != noErr) { */ /* GST_WARNING ("Error in ImageCodecPreDecompress"); */ /* goto beach; */ /* } */ /* GST_INFO ("sequenceID : %d", params.sequenceID); */ ret = TRUE; beach: /* Free instance */ CloseComponent (instance); return TRUE; }
static GstFlowReturn gst_fake_sink_render (GstBaseSink * bsink, GstBuffer * buf) { GstFakeSink *sink = GST_FAKE_SINK_CAST (bsink); if (sink->num_buffers_left == 0) goto eos; if (sink->num_buffers_left != -1) sink->num_buffers_left--; if (!sink->silent) { gchar dts_str[64], pts_str[64], dur_str[64]; gchar flag_str[100]; GST_OBJECT_LOCK (sink); g_free (sink->last_message); if (GST_BUFFER_DTS (buf) != GST_CLOCK_TIME_NONE) { g_snprintf (dts_str, sizeof (dts_str), "%" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_DTS (buf))); } else { g_strlcpy (dts_str, "none", sizeof (dts_str)); } if (GST_BUFFER_PTS (buf) != GST_CLOCK_TIME_NONE) { g_snprintf (pts_str, sizeof (pts_str), "%" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_PTS (buf))); } else { g_strlcpy (pts_str, "none", sizeof (pts_str)); } if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE) { g_snprintf (dur_str, sizeof (dur_str), "%" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_DURATION (buf))); } else { g_strlcpy (dur_str, "none", sizeof (dur_str)); } { const char *flag_list[15] = { "", "", "", "", "live", "decode-only", "discont", "resync", "corrupted", "marker", "header", "gap", "droppable", "delta-unit", "in-caps" }; int i; char *end = flag_str; end[0] = '\0'; for (i = 0; i < G_N_ELEMENTS (flag_list); i++) { if (GST_MINI_OBJECT_CAST (buf)->flags & (1 << i)) { strcpy (end, flag_list[i]); end += strlen (end); end[0] = ' '; end[1] = '\0'; end++; } } } sink->last_message = g_strdup_printf ("chain ******* (%s:%s) (%u bytes, dts: %s, pts: %s" ", duration: %s, offset: %" G_GINT64_FORMAT ", offset_end: %" G_GINT64_FORMAT ", flags: %08x %s) %p", GST_DEBUG_PAD_NAME (GST_BASE_SINK_CAST (sink)->sinkpad), (guint) gst_buffer_get_size (buf), dts_str, pts_str, dur_str, GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf), GST_MINI_OBJECT_CAST (buf)->flags, flag_str, buf); GST_OBJECT_UNLOCK (sink); gst_fake_sink_notify_last_message (sink); } if (sink->signal_handoffs) g_signal_emit (sink, gst_fake_sink_signals[SIGNAL_HANDOFF], 0, buf, bsink->sinkpad); if (sink->dump) { GstMapInfo info; gst_buffer_map (buf, &info, GST_MAP_READ); gst_util_dump_mem (info.data, info.size); gst_buffer_unmap (buf, &info); } if (sink->num_buffers_left == 0) goto eos; return GST_FLOW_OK; /* ERRORS */ eos: { GST_DEBUG_OBJECT (sink, "we are EOS"); return GST_FLOW_EOS; } }