Is it possible to get PID from Media Sessions?

Dolezal, Vojtech 0 Reputation points
2024-05-06T08:19:41.74+00:00

As title says, is it possible to get PID or some other unique identifier from the Media Sessions the API provides? I'm afraid of issues with multiple instances of my program running, and some way to distinguish them would be very helpful.

https://microsoft.github.io/windows-docs-rs/doc/windows/Media/Control/struct.GlobalSystemMediaTransportControlsSessionManager.html#method.GetSessions

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,451 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 11,581 Reputation points Microsoft Vendor
    2024-05-07T02:08:36.6633333+00:00

    Hello @Dolezal, Vojtech,

    According to About the Media Session,

    The Media Session exposes the IMFMediaSession interface. There are two ways to create the Media Session, depending on whether your application will support protected content:

    • If your application does not support protected content, you can create the Media Session by calling the MFCreateMediaSession. This function creates the Media Session inside the application process.
    • To support protected content, create the Media Session by calling MFCreatePMPMediaSession. This function creates the Media Session inside the Protected Media Path (PMP) process. The application receives a pointer to a proxy object that marshals method calls across the process boundary. Note that the PMP Media Session can be used to play clear content, as well as protected content.

    That is to say, processes that create themselves media sessions can identify their media sessions.