I'm writing a library that wraps some of Media Foundation functionality. I want to be able to notify a library user through a callback of when a webcam is connected/disconnected to/from the system. MSDN describes how to know when a camera is disconencted, but it uses message loop to let you know of that. I don't know Windows message loops too well, but what I have read in this MSDN article tells me that I must have a window in order to have a message loop, which is unacceptable for a library.
So, I have several questions:
Can I create a message loop in a new thread and receive those notification messages described by the first link? (I want it to be in a new thread so that it doesn't block the library user's thread then the library user calls
setCameraChangeCallback(...)
, which starts the message loop inside.) If so, which functions for creating message loop should I use?Can I do that without creating any windows? It's a library, so it would be very odd if a library user called
setCameraChangeCallback(...)
and a window suddenly appeared. Again, an explanation of how to do that (function names, specific arguments to use, etc.) is very welcome.Can my library be used without issues in a Windows application? Meaning that a Windows application that would be using my library is likely to already have a window created and its own message loop running. Would my message loop running in the separate thread interfere with library user's message loop? If so, how to avoid that?
Does anything stop me from creating two or more threads with message loops, each registered to get notified for the camera change event?