summaryrefslogtreecommitdiff
path: root/src/class/video/video_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/class/video/video_device.c')
-rw-r--r--src/class/video/video_device.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/class/video/video_device.c b/src/class/video/video_device.c
index 85e85e75e..b2375def9 100644
--- a/src/class/video/video_device.c
+++ b/src/class/video/video_device.c
@@ -214,6 +214,12 @@ TU_ATTR_WEAK int tud_video_commit_cb(uint_fast8_t ctl_idx, uint_fast8_t stm_idx,
return VIDEO_ERROR_NONE;
}
+TU_ATTR_WEAK void tud_video_prepare_payload_cb(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, tud_video_payload_request_t* request) {
+ (void) ctl_idx;
+ (void) stm_idx;
+ (void) request;
+}
+
//--------------------------------------------------------------------+
//
//--------------------------------------------------------------------+
@@ -874,7 +880,16 @@ static uint_fast16_t _prepare_in_payload(videod_streaming_interface_t *stm, uint
}
TU_ASSERT(pkt_len >= hdr_len);
uint_fast16_t data_len = pkt_len - hdr_len;
- memcpy(&ep_buf[hdr_len], stm->buffer + stm->offset, data_len);
+ if (stm->buffer) {
+ memcpy(&ep_buf[hdr_len], stm->buffer + stm->offset, data_len);
+ } else {
+ tud_video_payload_request_t rqst = {
+ .buf = &ep_buf[hdr_len],
+ .length = data_len,
+ .offset = stm->offset
+ };
+ tud_video_prepare_payload_cb(stm->index_vc, stm->index_vs, &rqst);
+ }
stm->offset += data_len;
remaining -= data_len;
if (!remaining) {
@@ -1255,13 +1270,14 @@ bool tud_video_n_frame_xfer(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, void *bu
TU_ASSERT(ctl_idx < CFG_TUD_VIDEO);
TU_ASSERT(stm_idx < CFG_TUD_VIDEO_STREAMING);
- if (NULL == buffer || 0 == bufsize) {
+ if (0 == bufsize) {
return false;
}
+
videod_streaming_interface_t *stm = _get_instance_streaming(ctl_idx, stm_idx);
videod_streaming_epbuf_t *stm_epbuf = &_videod_streaming_epbuf[ctl_idx];
- if (NULL == stm || 0 == stm->desc.ep[0] || stm->buffer) {
+ if (NULL == stm || 0 == stm->desc.ep[0] || stm->bufsize) {
return false;
}
if (stm->state == VS_STATE_PROBING) {