]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/stream.h
Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into...
[mirror_qemu.git] / include / hw / stream.h
CommitLineData
669b4983 1#ifndef STREAM_H
175de524 2#define STREAM_H
669b4983 3
14cccb61 4#include "qom/object.h"
669b4983 5
cfbef3f4 6#define TYPE_STREAM_SINK "stream-sink"
669b4983 7
cfbef3f4
PMD
8typedef struct StreamSinkClass StreamSinkClass;
9DECLARE_CLASS_CHECKERS(StreamSinkClass, STREAM_SINK,
10 TYPE_STREAM_SINK)
11#define STREAM_SINK(obj) \
12 INTERFACE_CHECK(StreamSink, (obj), TYPE_STREAM_SINK)
669b4983 13
cfbef3f4 14typedef struct StreamSink StreamSink;
669b4983 15
35e60bfd
PC
16typedef void (*StreamCanPushNotifyFn)(void *opaque);
17
cfbef3f4 18struct StreamSinkClass {
669b4983 19 InterfaceClass parent;
35e60bfd 20 /**
cfbef3f4 21 * can push - determine if a stream sink is capable of accepting at least
35e60bfd 22 * one byte of data. Returns false if cannot accept. If not implemented, the
cfbef3f4
PMD
23 * sink is assumed to always be capable of receiving.
24 * @notify: Optional callback that the sink will call when the sink is
805a2505 25 * capable of receiving again. Only called if false is returned.
35e60bfd
PC
26 * @notify_opaque: opaque data to pass to notify call.
27 */
cfbef3f4 28 bool (*can_push)(StreamSink *obj, StreamCanPushNotifyFn notify,
35e60bfd
PC
29 void *notify_opaque);
30 /**
cfbef3f4
PMD
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
35e60bfd 34 * advance. The can_push() function can be used to trap the point in time
cfbef3f4 35 * where the sink is ready to receive again, otherwise polling on a QEMU
35e60bfd 36 * timer will work.
cfbef3f4 37 * @obj: Stream sink to push to
35e60bfd
PC
38 * @buf: Data to write
39 * @len: Maximum number of bytes to write
51b19950 40 * @eop: End of packet flag
35e60bfd 41 */
cfbef3f4 42 size_t (*push)(StreamSink *obj, unsigned char *buf, size_t len, bool eop);
db1015e9 43};
669b4983 44
35e60bfd 45size_t
cfbef3f4 46stream_push(StreamSink *sink, uint8_t *buf, size_t len, bool eop);
669b4983 47
35e60bfd 48bool
cfbef3f4 49stream_can_push(StreamSink *sink, StreamCanPushNotifyFn notify,
35e60bfd
PC
50 void *notify_opaque);
51
52
669b4983 53#endif /* STREAM_H */