4 #include "qom/object.h"
6 #define TYPE_STREAM_SINK "stream-sink"
8 typedef struct StreamSinkClass StreamSinkClass
;
9 DECLARE_CLASS_CHECKERS(StreamSinkClass
, STREAM_SINK
,
11 #define STREAM_SINK(obj) \
12 INTERFACE_CHECK(StreamSink, (obj), TYPE_STREAM_SINK)
14 typedef struct StreamSink StreamSink
;
16 typedef void (*StreamCanPushNotifyFn
)(void *opaque
);
18 struct StreamSinkClass
{
19 InterfaceClass parent
;
21 * can push - determine if a stream sink is capable of accepting at least
22 * one byte of data. Returns false if cannot accept. If not implemented, the
23 * sink is assumed to always be capable of receiving.
24 * @notify: Optional callback that the sink will call when the sink is
25 * capable of receiving again. Only called if false is returned.
26 * @notify_opaque: opaque data to pass to notify call.
28 bool (*can_push
)(StreamSink
*obj
, StreamCanPushNotifyFn notify
,
31 * push - push data to a Stream sink. The number of bytes pushed is
32 * returned. If the sink short returns, the master must wait before trying
33 * again, the sink may continue to just return 0 waiting for the vm time to
34 * advance. The can_push() function can be used to trap the point in time
35 * where the sink is ready to receive again, otherwise polling on a QEMU
37 * @obj: Stream sink to push to
39 * @len: Maximum number of bytes to write
40 * @eop: End of packet flag
42 size_t (*push
)(StreamSink
*obj
, unsigned char *buf
, size_t len
, bool eop
);
46 stream_push(StreamSink
*sink
, uint8_t *buf
, size_t len
, bool eop
);
49 stream_can_push(StreamSink
*sink
, StreamCanPushNotifyFn notify
,