ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Restarting frame capture after resuming from sleep?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
whisper1980 Posted - Jun 20 2023 : 14:42:20
In modern version of Windows, Windows 10 build 2004 and later, if you put the computer to sleep, it uses what is referred to as "Modern Standby" which provides for a quicker resume when sleeping for a short amount of time.

If I have the camera connected and receiving frames, the camera does not automatically turn back on when resuming from sleep. The Windows Camera App itself knows how to resume the camera capture, but the MMF or DirectShow I use for capturing snapshots or video does not know to resume the camera.

In older versions of Windows, I would receive the WM_PowerBroadcast, but for this "Modern Standby" I do not.

Is there a way to know the camera has been disconnected (if that is the case) so that I can reconnect to it? For example, the ImageEnView1MediaFoundationNotify does not seem to have an NotifyType for that.

Thoughts?

Eric
2   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jun 22 2023 : 02:07:26
Thanks for letting us know, Eric

Nigel
Xequte Software
www.imageen.com
whisper1980 Posted - Jun 20 2023 : 18:21:18
What I've done so far is to register for the monitor being powered on/off to reconnect to the camera. Not sure if that is the best solution or not, but seems to work for me. GUID_MONITOR_POWER_ON is sent when the monitor powers on and when powers off.

Note:
fPowerNotify: PVoid;


fPowerNotify := RegisterPowerSettingNotification(Self.Handle, GUID_MONITOR_POWER_ON, DEVICE_NOTIFY_WINDOW_HANDLE);


Then when receiving a WM_PowerBroadcast message, I look for PBT_POWERSETTINGCHANGE like this:

PBT_POWERSETTINGCHANGE:
      begin
        if PPowerBroadcastSetting(Msg.LParam)^.Data[0] = 0 then
        begin
          Log('Power Setting Change - Monitor: Off.');   // Treating as sleeping
          // Do whatever to disconnect the camera
        end else
        begin
          Log('Power Setting Change - Monitor: On.');    // Treating as waking up
          // Do whatever to reconnect the camera
        end;
      end;



If my handle changes, like when changing the vcl style, I unregister and re-register it in the FormShow event:

if global.MainHandle <> Self.Handle then
  begin
    global.MainHandle := Self.Handle;
    // Re-setup notifications for "Modern Standby" with the updated handle
    if Assigned(fPowerNotify) then
      UnregisterPowerSettingNotification(fPowerNotify);
    fPowerNotify := RegisterPowerSettingNotification(Self.Handle, GUID_MONITOR_POWER_ON, DEVICE_NOTIFY_WINDOW_HANDLE);
  end;



Eric