Example #1
0
// ParseResetTime() is a wrapper around gst_message_parse_reset_time().
func (v *Message) ParseResetTime() (running_time uint64) {
	var crunning_time C.GstClockTime
	C.gst_message_parse_reset_time(v.native(), &crunning_time)
	return uint64(crunning_time)
}
Example #2
0
File: gst.go Project: reusee/oplay
func MessageDump(msg *C.GstMessage) {
	srcName := fromGStr(C.gst_object_get_name(msg.src))
	switch msg._type {
	case C.GST_MESSAGE_UNKNOWN: // unknown
		pMsg(srcName, "Unknown")
	case C.GST_MESSAGE_EOS: // end of stream
		pMsg(srcName, "Eos")
	case C.GST_MESSAGE_ERROR: // error
		var err *C.GError
		var debug *C.gchar
		C.gst_message_parse_error(msg, &err, &debug)
		pMsg(srcName, "Error", "%s %s", fromGStr(err.message), fromGStr(debug))
		C.g_error_free(err)
		C.g_free(asGPtr(debug))
	//case C.GST_MESSAGE_WARNING: // warning
	//case C.GST_MESSAGE_INFO: // info
	case C.GST_MESSAGE_TAG: // tag
		var tagList *C.GstTagList
		C.gst_message_parse_tag(msg, &tagList)
		pMsg(srcName, "Tag")
		TagForeach(tagList, func(tag *C.gchar) {
			num := C.gst_tag_list_get_tag_size(tagList, tag)
			for i := C.guint(0); i < num; i++ {
				val := C.gst_tag_list_get_value_index(tagList, tag, i)
				pMsg(srcName, "Tag", "%s = %v", fromGStr(tag), fromGValue(val))
			}
		})
		C.gst_tag_list_unref(tagList)
	//case C.GST_MESSAGE_BUFFERING: // buffering
	case C.GST_MESSAGE_STATE_CHANGED: // state changed
		var oldState, newState C.GstState
		C.gst_message_parse_state_changed(msg, &oldState, &newState, nil)
		pMsg(srcName, "State", "%s -> %s",
			fromGStr(C.gst_element_state_get_name(oldState)),
			fromGStr(C.gst_element_state_get_name(newState)))
	//case C.GST_MESSAGE_STATE_DIRTY: // state dirty
	//case C.GST_MESSAGE_STEP_DONE: // step done
	//case C.GST_MESSAGE_CLOCK_PROVIDE: // clock provide
	//case C.GST_MESSAGE_CLOCK_LOST: // clock lost
	case C.GST_MESSAGE_NEW_CLOCK: // new clock
		var clock *C.GstClock
		C.gst_message_parse_new_clock(msg, &clock)
		pMsg(srcName, "New clock")
	//case C.GST_MESSAGE_STRUCTURE_CHANGE: // structure change
	case C.GST_MESSAGE_STREAM_STATUS: // stream status
		var t C.GstStreamStatusType
		var owner *C.GstElement
		C.gst_message_parse_stream_status(msg, &t, &owner)
		pMsg(srcName, "Stream status", "%d", t)
	//case C.GST_MESSAGE_APPLICATION: // application
	case C.GST_MESSAGE_ELEMENT: // element
		pMsg(srcName, "Element", "%v", msg)
	//case C.GST_MESSAGE_SEGMENT_START: // segment start
	//case C.GST_MESSAGE_SEGMENT_DONE: // segment done
	case C.GST_MESSAGE_DURATION_CHANGED: // duration changed
		pMsg(srcName, "Duration changed")
	case C.GST_MESSAGE_LATENCY: // latency
		pMsg(srcName, "Latency")
	//case C.GST_MESSAGE_ASYNC_START: // async start
	case C.GST_MESSAGE_ASYNC_DONE: // async done
		C.gst_message_parse_async_done(msg, nil)
		pMsg(srcName, "Async done")
	//case C.GST_MESSAGE_REQUEST_STATE: // request state
	//case C.GST_MESSAGE_STEP_START: // step start
	//case C.GST_MESSAGE_QOS: // qos
	//case C.GST_MESSAGE_PROGRESS: // progress
	//case C.GST_MESSAGE_TOC: // toc
	case C.GST_MESSAGE_RESET_TIME: // reset time
		C.gst_message_parse_reset_time(msg, nil)
		pMsg(srcName, "Reset time")
	case C.GST_MESSAGE_STREAM_START: // stream start
		pMsg(srcName, "Stream start")
	//case C.GST_MESSAGE_NEED_CONTEXT: // need context
	//case C.GST_MESSAGE_HAVE_CONTEXT: // have context
	//case C.GST_MESSAGE_ANY: // any
	default:
		name := C.gst_message_type_get_name(msg._type)
		p("message type %s\n", fromGStr(name))
		panic("fixme")
	}
	C.gst_message_unref(msg)
}