Caspar Screen Consumer


#1

Hi all,

I have two questions:),

How to make casparCG screen consumer always on top, and is there any possibility to add screen consumer inside C# application, like to have preview of graphic all the time?


#2

There are tools that can be used for this

Yes, I have that code, a modified version of something Vimlesh once shared. But it’s in VB.NET. See here:

   'Declaring some constants to use with the SendMessage API
   Private Const WM_SYSCOMMAND As Integer = 274
   Private Const SC_MAXIMIZE As Integer = 61488
   Private Const SC_MINIIMIZE As Integer = 61472

   'This is the API that does all the hard work
   <Runtime.InteropServices.DllImport("user32.dll")> _
   Public Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
   End Function

   <Runtime.InteropServices.DllImport("user32.dll")> _
   Public Shared Function FindWindow(ByVal lpszClass As String, ByVal lpszWindow As String) As Integer
   End Function

   <Runtime.InteropServices.DllImport("user32.dll")> _
   Public Shared Function FindWindowEx(ByVal hwndParent As IntPtr, ByVal hWndChildAfter As IntPtr, ByVal lpszClass As String, ByVal lpszWindow As String) As Integer
   End Function

   'This is the API used to maximize the window
   <Runtime.InteropServices.DllImport("user32.dll")> _
   Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
   End Function

   'This is the process that is currently set as a child to the form
   Private _parentedProcess As Process
   Private WithEvents timGrab As Timer = New Timer()

   Private Sub SetProcessParent(ByVal processName As String)

      'Retrieve an array of running processes with the given name
      Dim processes() As Process = Process.GetProcessesByName(processName)
      If processes.Length = 0 Then
         MessageBox.Show("No processes by that name found")
      Else
         'If there already is a process set as a child to our form, we set its parent to Nothing, to make it go back to its normal state.
         If Not _parentedProcess Is Nothing Then
            SetParent(_parentedProcess.MainWindowHandle, Nothing)
         End If
         'This forms new child will be the process on index 0 of the array
         _parentedProcess = processes(0)
         SetParent(_parentedProcess.MainWindowHandle, Me.panPreview.Handle)
         'SetParent(_parentedprocess.MainWindowHandle, Me.panPreview.Handle) Try adding a panel to your form and use this line instead of the above line.

         'Now lets maximize the window of the process
         SendMessage(_parentedProcess.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)

      End If

   End Sub

   Private Sub timGrab_Tick(sender As Object, e As System.EventArgs) Handles timGrab.Tick
      timGrab.Enabled = False
      SetProcessParent("casparcg")
   End Sub

And, if you put that into a form, add this code to it:

   Private Sub frmPreview_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
      'This is important! If you have a child process on your form, it will terminate along with your form if you do not set its parent to Nothing

      If Not _parentedProcess Is Nothing Then
         SetParent(_parentedProcess.MainWindowHandle, Nothing)
      End If
   End Sub

   Private Sub frmPreview_Load(sender As Object, e As System.EventArgs) Handles Me.Load
      timGrab.Interval = 1000
      timGrab.Enabled = True
   End Sub

I hope this helps


#3

I wish I would asked this two days ago.
Ended up using NDI for client preview (alpha channel is an advantage too)


#4

stay on top is / will be an option in 2.2


#5

Exactly what i wanted to suggest for a next version :slight_smile: :slight_smile: How stable is 2.2 version now?


#6

It’s getting there but there are still quite some issue’s

i would not recommend using it blindfolded on your next production.

but in a self controlled enviroment with known content and knowing the cavities
and good testing it is becoming usable

i did a few productions with it already
most problems are now in videoplayback and information feedback OSC/INFO

CG work is working pretty well


#7

I currently prepares two quiz applications, and i work on stable 2.0.7, but i think for that there is no need to switch on 2.1 or 2.2 What are benefits regarding CG only, not video playout in new versions of server?


#8

HTML has been upgraded a enormous step vs 2.07