microsoft / windows-rs

Rust for Windows
https://kennykerr.ca/rust-getting-started/
Apache License 2.0
10.51k stars 497 forks source link

MediaFoundation constant in docs but not metadata? #882

Closed astraw closed 3 years ago

astraw commented 3 years ago

I'm trying to port the key parts of the MFCaptureToFile Windows classic sample to windows-rs. So far I have successfully ported several of the initial aspects such as enumerating devices (with MFEnumDeviceSources) and activating them.

My issue: if I try to generate the bindings for the constant Windows::Win32::Media::MediaFoundation::MF_SOURCE_READER_FIRST_VIDEO_STREAM, I get an error at compile time. I find this strange because the documentation for this constant is automatically generated and thus it must be in the metadata. So how do I generate the binding?

For example, with the following code (using windows = "0.11" in Cargo.toml)

fn main() {
    windows::build!(Windows::
    Win32::
        Media::MediaFoundation::{
            MF_SOURCE_READER_ASYNC_CALLBACK,
            MF_SOURCE_READER_FIRST_VIDEO_STREAM,
        },
    );
}

I get this error

error: `Windows.Win32.Media.MediaFoundation.MF_SOURCE_READER_FIRST_VIDEO_STREAM` not found in metadata
 --> src\main.rs:6:13
  |
6 |             MF_SOURCE_READER_FIRST_VIDEO_STREAM,
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: could not compile `winplay`

(If I remove MF_SOURCE_READER_FIRST_VIDEO_STREAM, this compiles without error and the bindings for MF_SOURCE_READER_ASYNC_CALLBACK are generated.)

(I suspect I'll have to wait for COM interfaces to be finished #81 before I can complete this port, but I don't understand why this example doesn't compile.)

tim-weis commented 3 years ago

Sounds like a duplicate of #871.

astraw commented 3 years ago

Yes, thanks, you are correct. I have to build the bindings for MF_SOURCE_READER_CONSTANTS and then MF_SOURCE_READER_FIRST_VIDEO_STREAM is defined.