Skip to content

Commit 07fd619

Browse files
committed
Added stream-hdmi-in-then-decode-and-display-on-hdmi-out samples
1 parent a28c383 commit 07fd619

File tree

5 files changed

+184
-0
lines changed

5 files changed

+184
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# streaming/stream-hdmi-in/stream-hdmi-in-then-decode-and-display-on-hdmi-out/brightscript-and-html
2+
This script creates a multicast stream from the HDMI input on a BrightSign player.
3+
Any device or PC on the local network that can accept a UDP stream can receive and play this stream.
4+
In addition, the script decodes the stream and plays it back on the local HDMI output.
5+
The encoding is done in BrightScript, and the decoding is done in HTML.
6+
This sample illustrates how to tune to a multicast stream in HTML.
7+
To run this sample, put all files in this folder on an SD card, insert it in a BrightSign player, and reboot.
8+
9+
Notes:
10+
- This requires a BrightSign model that has an HDMI input
11+
- You can only stream non-encrypted content. If you attempt to stream, for example, the output of a DVD player, it will be disallowed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
Sub Main()
2+
3+
gaa = GetGlobalAA()
4+
5+
gaa.vm = CreateObject("roVideoMode")
6+
' Set up HD resolution
7+
gaa.vm.SetMode("1920x1080x60p")
8+
9+
v = CreateObject("roVideoPlayer")
10+
r1 = CreateObject("roRectangle", 0, 0, 1920, 1080)
11+
v.SetRectangle(r1)
12+
13+
gaa.mp = CreateObject("roMessagePort")
14+
15+
' Stream hdmi-in to udp://239.194.0.202:2234
16+
streamer = CreateObject("roMediaStreamer")
17+
streamer.SetPipeline("hdmi:,encoder:vbitrate=5000,udp://239.194.0.202:2234")
18+
streamer.Start()
19+
20+
' Create the browser object that will display the stream via html
21+
CreateHtmlWidget("file:///index.html")
22+
23+
' Detect the presence of network connection
24+
receivedIpAddr = false
25+
nc = CreateObject("roNetworkConfiguration", 0)
26+
currentConfig = nc.GetCurrentConfig()
27+
if currentConfig.ip4_address <> "" then
28+
' We already have an IP addr
29+
receivedIpAddr = true
30+
print "=== BS: already have an IP addr: ";currentConfig.ip4_address
31+
end if
32+
33+
receivedLoadFinished = false
34+
' Wait for events
35+
While true
36+
ev = gaa.mp.WaitMessage(0)
37+
if type(ev) = "roHdmiInputChanged" then
38+
aa = gaa.vm.GetHdmiInputStatus()
39+
if type(aa) = "roAssociativeArray" then
40+
print "GetHdmiInputStatus=";aa
41+
if aa.device_present then
42+
streamer.Start()
43+
end if
44+
else
45+
streamer.Reset()
46+
end if
47+
else if type(ev) = "roHtmlWidgetEvent" then
48+
eventData = ev.GetData()
49+
if type(eventData) = "roAssociativeArray" and type(eventData.reason) = "roString" then
50+
if eventData.reason = "load-error" then
51+
print "=== BS: HTML load error: "; eventData.message
52+
else if eventData.reason = "load-finished" then
53+
print "=== BS: Received load finished"
54+
receivedLoadFinished = true
55+
endif
56+
else
57+
print "=== BS: Unknown eventData: "; type(eventData)
58+
endif
59+
end if
60+
if receivedIpAddr and receivedLoadFinished then
61+
print "=== BS: OK to show HTML, showing widget now"
62+
gaa.htmlWidget.Show()
63+
receivedIpAddr = false
64+
receivedLoadFinished = false
65+
endif
66+
End While
67+
68+
End Sub
69+
70+
Sub CreateHtmlWidget(url$ as String)
71+
72+
gaa = GetGlobalAA()
73+
width=gaa.vm.GetResX()
74+
height=gaa.vm.GetResY()
75+
rect=CreateObject("roRectangle", 0, 0, width, height)
76+
77+
gaa.htmlWidget = CreateObject("roHtmlWidget", rect)
78+
gaa.htmlWidget.EnableSecurity(false)
79+
gaa.htmlWidget.SetUrl(url$)
80+
gaa.htmlWidget.EnableJavascript(true)
81+
gaa.htmlWidget.StartInspectorServer(2999)
82+
gaa.htmlWidget.EnableMouseEvents(true)
83+
gaa.htmlWidget.AllowJavaScriptUrls({ all: "*" })
84+
gaa.htmlWidget.setPort(gaa.mp)
85+
86+
End Sub
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<html>
2+
<body>
3+
<!--
4+
hwz: decodes the multicast stream using the hardware decoder
5+
autoplay: tunes to the stream automatically
6+
-->
7+
<video id="video1" hwz="on" src="udp://239.194.0.202:2234" height="1080" width="1920" autoplay loop>
8+
</video>
9+
</body>
10+
</html>
11+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# streaming/stream-hdmi-in/stream-hdmi-in-then-decode-and-display-on-hdmi-out/brightscript-only
2+
This script creates a multicast stream from the HDMI input on a BrightSign player.
3+
Any device or PC on the local network that can accept a UDP stream can receive and play this stream.
4+
In addition, the script decodes the stream and plays it back on the local HDMI output.
5+
All encoding and decoding is done in BrightScript.
6+
To run this sample, put all files in this folder on an SD card, insert it in a BrightSign player, and reboot.
7+
8+
Notes:
9+
- This requires a BrightSign model that has an HDMI input
10+
- You can only stream non-encrypted content. If you attempt to stream, for example, the output of a DVD player, it will be disallowed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Sub Main()
2+
3+
vm = CreateObject("roVideoMode")
4+
' Set up HD resolution
5+
vm.SetMode("1920x1080x60p")
6+
7+
v = CreateObject("roVideoPlayer")
8+
r1 = CreateObject("roRectangle", 0, 0, 1920, 1080)
9+
v.SetRectangle(r1)
10+
11+
mp = CreateObject("roMessagePort")
12+
13+
' Stream hdmi-in to udp://239.194.0.202:2234
14+
streamer = CreateObject("roMediaStreamer")
15+
streamer.SetPipeline("hdmi:,encoder:vbitrate=5000,udp://239.194.0.202:2234")
16+
streamer.Start()
17+
18+
' Set up a timer to tune the stream. If it's not yet available, we will retry every second
19+
timer = CreateObject("roTimer")
20+
timer.SetPort(mp)
21+
timer.SetElapsed(1, 0)
22+
23+
' Decode the hdmi-in stream
24+
rtspStream = CreateObject("roRtspStream", "udp://239.194.0.202:2234")
25+
aa = {}
26+
aa["Rtsp"] = rtspStream
27+
28+
ok = v.PlayFile(aa)
29+
if ok then
30+
print "=== Up and running!"
31+
else
32+
print "=== Starting timer"
33+
timer.Start()
34+
end if
35+
36+
' Wait for events
37+
While true
38+
ev = mp.WaitMessage(0)
39+
if type(ev) = "roTimerEvent" then
40+
' Try tuning to the stream. If it's not yet available, we will retry every second
41+
ok = v.PlayFile(aa)
42+
if ok then
43+
print "=== Up and running!"
44+
else
45+
print "=== Starting timer to try again"
46+
timer.Start()
47+
end if
48+
else if type(ev) = "roHdmiInputChanged" then
49+
' If the user plugs in the hdmi cable to hdmi-in after boot-up, this will handle it
50+
aa2 = vm.GetHdmiInputStatus()
51+
if type(aa2) = "roAssociativeArray" then
52+
print "GetHdmiInputStatus=";aa2
53+
if aa2.device_present then
54+
' Start the stream once hdmi-in is detected
55+
streamer.Start()
56+
end if
57+
else
58+
streamer.Reset()
59+
end if
60+
end if
61+
End While
62+
63+
End Sub
64+
65+
66+

0 commit comments

Comments
 (0)