X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bmusb%2Fbmusb.h;h=cec84d9ae6bef90c65fee708462991eea0978d8b;hb=7d282bf25e6b11c1e594164cdccb56460a34b42d;hp=0ea7c369fb86e04398d41f019617c0e6f8e5eb74;hpb=824260a0732a49b5a18f2e16e04b0373c37a3bea;p=bmusb diff --git a/bmusb/bmusb.h b/bmusb/bmusb.h index 0ea7c36..cec84d9 100644 --- a/bmusb/bmusb.h +++ b/bmusb/bmusb.h @@ -31,6 +31,7 @@ class FrameAllocator { struct Frame { uint8_t *data = nullptr; uint8_t *data2 = nullptr; // Only if interleaved == true. + uint8_t *data_copy = nullptr; // Will get a non-interleaved copy if not nullptr. size_t len = 0; // Number of bytes we actually have. size_t size = 0; // Number of bytes we have room for. size_t overflow = 0; @@ -72,6 +73,22 @@ class FrameAllocator { // if so, the frame in progress will be dropped. virtual Frame alloc_frame() = 0; + // Similar to alloc_frame(), with two additional restrictions: + // + // - The width, height and stride given must be correct + // (can not be changed after the call). + // - create_frame(), unlike alloc_frame(), is allowed to sleep + // (so bmusb will never call it, but in Nageru, other producers + // might) + // + // These two restrictions are relevant for Nageru, since it means that + // it can make frame_copy point directly into a VA-API buffer to avoid + // an extra copy. + virtual Frame create_frame(size_t width, size_t height, size_t stride) + { + return alloc_frame(); + } + virtual void release_frame(Frame frame) = 0; }; @@ -126,6 +143,7 @@ struct AudioFormat { uint16_t id = 0; // For debugging/logging only. unsigned bits_per_sample = 0; unsigned num_channels = 0; + unsigned sample_rate = 48000; }; enum PixelFormat { @@ -153,9 +171,21 @@ enum PixelFormat { // the stride member of VideoFormat. PixelFormat_10BitYCbCr, - // 8-bit 4:4:4:4 RGBA (in that order). bmusb itself doesn't + // 8-bit 4:4:4:4 BGRA (in that order). bmusb itself doesn't // produce this, but it is useful to represent e.g. synthetic inputs. - PixelFormat_8BitRGBA + PixelFormat_8BitBGRA, + + // 8-bit 4:2:0, 4:2:2, 4:4:4 or really anything else, planar + // (ie., first all Y', then all Cb, then all Cr). bmusb doesn't + // produce this, nor does it specify a mechanism to describe + // the precise details of the format. + PixelFormat_8BitYCbCrPlanar, + + // These exist only so that the type is guaranteed wide enough + // to contain values up to 127. CaptureInterface instances + // are free to use them as they see fit for private uses. + PixelFormat_Unused100 = 100, + PixelFormat_Unused127 = 127 }; typedef std::function