Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private LocalSocket As ServerSocket 'ignore
Private LocalIP As String
' Streaming Class (Send and Play)
Private VideoStream As SD_VideoStream
Private VideoRemotePlay As SD_VideoStream
Private VideoLocalPlay As SD_VideoStream
' Pane Base to Play - Add on Design
Private BaseRemoteVideo As Pane
Private BaseLocalVideo As Pane
' Node Base (into pane) - don't add by design
Private NodeRemotePlay As Node
Private NodeLocalPlay As Node
' Other
Private TextRemote As B4XView
Private CheckBoxRotate As CheckBox
Private LabelInfo As B4XView
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
If StreamSetup.vlcInstalled = False Then
Log("VLC must be installed on the computer to run this program.")
ExitApplication
End If
VideoStream.Initialize(Me,"VideoStream")
VideoLocalPlay.Initialize(Me,"VideoLocalPlay")
VideoRemotePlay.Initialize(Me,"VideoRemotePlay")
' load Layout with pane for VideoPlay
MainForm.RootPane.LoadLayout("Layout1")
' create layout for node by code
NodeLocalPlay=StreamSetup.LoadLayoput(BaseLocalVideo,"NodeLocalPlay")
NodeRemotePlay=StreamSetup.LoadLayoput(BaseRemoteVideo,"NodeRemotePlay")
' Hook VideoPlay to node
StreamSetup.HookPlayer(NodeLocalPlay,VideoLocalPlay.Player)
StreamSetup.HookPlayer(NodeRemotePlay,VideoRemotePlay.Player)
MainForm.Show
' load config - Host and degree rotate
If File.Exists(File.DirData("videostream"),"config.ini") Then
Dim M As Map = File.ReadMap(File.DirData("videostream"),"config.ini")
TextRemote.Text=M.Get("Host")
CheckBoxRotate.Checked=M.Get("r180")
End If
LocalIP=LocalSocket.GetMyIP
MainForm.Title="Host: " & LocalIP
End Sub
private Sub MainForm_CloseRequest (EventData As Event)
Log("We are closing the mainform")
VideoStream.stop
VideoStream.release
VideoRemotePlay.Stop
VideoRemotePlay.release
VideoLocalPlay.Stop
VideoLocalPlay.release
End Sub
private Sub ButtonSender_Click
Log("Start sender")
LabelInfo.Text="STARTING"
VideoStream.StreamCam(LocalIP,"prova.mp4",8554,180) ' for Internal Cam
'VideoStream.StreamDesktop(LocalIP,"prova.mp4",8554) ' For Desktop
End Sub
Private Sub ButtonRiceve_Click
Log("Start connect")
LabelInfo.Text="Connect"
If VideoRemotePlay.IsPlaying Then VideoRemotePlay.Stop
VideoRemotePlay.Play($"rtsp://${TextRemote.Text.Trim}:8554/prova.mp4"$)
VideoRemotePlay.SetVolume(100)
End Sub
Private Sub VideoStream_ReadyToSend
Log("Start to send")
If VideoLocalPlay.IsPlaying Then VideoLocalPlay.Stop
VideoLocalPlay.Play($"rtsp://${LocalIP}:8554/prova.mp4"$)
VideoLocalPlay.SetVolume(0)
End Sub
Private Sub VideoStream_Finished
Log("finished send")
End Sub
' --- Send straming
private Sub VideoStream_ReadyToPlay
Log("Video is ready to send")
End Sub
Private Sub VideoStream_Error
Log("error to send")
End Sub
Private Sub VideoRemotePlay_Finished
Log("finished play")
End Sub
' --- remote
Private Sub VideoRemotePlay_ReadyToPlay
Log("Video is ready to play")
NodeRemotePlay.PrefWidth=BaseRemoteVideo.PrefWidth
NodeRemotePlay.PrefHeight=BaseRemoteVideo.PrefHeight
End Sub
Private Sub VideoRemotePlay_Error
Log("Error to play")
End Sub
' --- Local
Private Sub VideoLocalPlay_Finished
Log("finished local play")
End Sub
Private Sub VideoLocalPlay_ReadyToPlay
Log("Video is ready to local play")
NodeLocalPlay.PrefWidth=BaseLocalVideo.PrefWidth
NodeLocalPlay.PrefHeight=BaseLocalVideo.PrefHeight
Log(VideoLocalPlay.Volume)
End Sub
Private Sub VideoLocalPlay_Error
Log("Error to local play")
End Sub