trying to follow wtay's advice
Original commit message from CVS: trying to follow wtay's advice
This commit is contained in:
parent
71d51fe3e8
commit
e1f3e53fbc
@ -73,6 +73,7 @@ static void gst_udpsrc_set_property (GObject *object, guint prop_id,
|
|||||||
const GValue *value, GParamSpec *pspec);
|
const GValue *value, GParamSpec *pspec);
|
||||||
static void gst_udpsrc_get_property (GObject *object, guint prop_id,
|
static void gst_udpsrc_get_property (GObject *object, guint prop_id,
|
||||||
GValue *value, GParamSpec *pspec);
|
GValue *value, GParamSpec *pspec);
|
||||||
|
static void gst_udpsrc_set_clock (GstElement *element, GstClock *clock);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
/*static guint gst_udpsrc_signals[LAST_SIGNAL] = { 0 }; */
|
/*static guint gst_udpsrc_signals[LAST_SIGNAL] = { 0 }; */
|
||||||
@ -123,8 +124,18 @@ gst_udpsrc_class_init (GstUDPSrc *klass)
|
|||||||
gobject_class->get_property = gst_udpsrc_get_property;
|
gobject_class->get_property = gst_udpsrc_get_property;
|
||||||
|
|
||||||
gstelement_class->change_state = gst_udpsrc_change_state;
|
gstelement_class->change_state = gst_udpsrc_change_state;
|
||||||
|
gstelement_class->set_clock = gst_udpsrc_set_clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_udpsrc_set_clock (GstElement *element, GstClock *clock)
|
||||||
|
{
|
||||||
|
GstUDPSrc *udpsrc;
|
||||||
|
|
||||||
|
udpsrc = GST_UDPSRC (element);
|
||||||
|
|
||||||
|
udpsrc->clock = clock;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_udpsrc_init (GstUDPSrc *udpsrc)
|
gst_udpsrc_init (GstUDPSrc *udpsrc)
|
||||||
@ -136,6 +147,9 @@ gst_udpsrc_init (GstUDPSrc *udpsrc)
|
|||||||
|
|
||||||
udpsrc->port = UDP_DEFAULT_PORT;
|
udpsrc->port = UDP_DEFAULT_PORT;
|
||||||
udpsrc->control = CONTROL_UDP;
|
udpsrc->control = CONTROL_UDP;
|
||||||
|
udpsrc->clock = NULL;
|
||||||
|
|
||||||
|
udpsrc->first_buf = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstBuffer*
|
static GstBuffer*
|
||||||
@ -216,6 +230,28 @@ gst_udpsrc_get (GstPad *pad)
|
|||||||
GST_BUFFER_DATA (outbuf) = g_malloc (24000);
|
GST_BUFFER_DATA (outbuf) = g_malloc (24000);
|
||||||
GST_BUFFER_SIZE (outbuf) = 24000;
|
GST_BUFFER_SIZE (outbuf) = 24000;
|
||||||
|
|
||||||
|
if (udpsrc->first_buf) {
|
||||||
|
if (udpsrc->clock) {
|
||||||
|
GstClockTime current_time;
|
||||||
|
|
||||||
|
current_time = gst_clock_get_time (udpsrc->clock);
|
||||||
|
|
||||||
|
GST_BUFFER_TIMESTAMP (outbuf) = current_time;
|
||||||
|
GstEvent *discont;
|
||||||
|
|
||||||
|
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
|
||||||
|
current_time, NULL);
|
||||||
|
|
||||||
|
gst_pad_push (udpsrc->srcpad, GST_BUFFER (discont));
|
||||||
|
}
|
||||||
|
|
||||||
|
udpsrc->first_buf = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_CLOCK_TIME_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
numbytes = recvfrom (udpsrc->sock, GST_BUFFER_DATA (outbuf),
|
numbytes = recvfrom (udpsrc->sock, GST_BUFFER_DATA (outbuf),
|
||||||
GST_BUFFER_SIZE (outbuf), 0, (struct sockaddr *)&tmpaddr, &len);
|
GST_BUFFER_SIZE (outbuf), 0, (struct sockaddr *)&tmpaddr, &len);
|
||||||
|
|
||||||
|
@ -67,6 +67,9 @@ struct _GstUDPSrc {
|
|||||||
int control_sock;
|
int control_sock;
|
||||||
Gst_UDP_Control control;
|
Gst_UDP_Control control;
|
||||||
struct sockaddr_in myaddr;
|
struct sockaddr_in myaddr;
|
||||||
|
GstClock *clock;
|
||||||
|
|
||||||
|
gboolean first_buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstUDPSrcClass {
|
struct _GstUDPSrcClass {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user