Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
FearL0rd
Visitor

SlingPlayer APP Development

Hi everybody,

I'm trying to create an app to connect to SlingBox and I'm having some issues. I'm able to get the Slingbox IP and port from Sligmedia servers but when I try to connect the box I'm having authentication problems. Off-course that I don't have a lot of experience with the BrightScript Language.
Anybody want to create an opensource project and try to make it happen? 😄

There is a SlingboxSDK opensource at http://sourceforge.net/projects/slingboxsdk/

Can we create a C library and use with Roku? :twisted:

Regards,

FearL0rd
0 Kudos
6 REPLIES 6
radiocolin
Visitor

Re: SlingPlayer APP Development

The newer Slingbox models encrypt the video stream for any resolutions above 320x240.
0 Kudos
FearL0rd
Visitor

Re: SlingPlayer APP Development

if we start doing something for the SlingSolo is already a lot...
😄
0 Kudos
TheEndless
Channel Surfer

Re: SlingPlayer APP Development

Not trying to discourage you, but I wouldn't get your hopes up too high. As radiocolin mentioned, streams on the new devices are encrypted, and it's unlikely that the older streams are in a Roku compatible format. HLS and ISM are the only live streaming formats supported, so even if by some miracle they're encoded with the right codecs, you'd still need to figure out some way to deliver them for playback.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
FearL0rd
Visitor

Re: SlingPlayer APP Development

"TheEndless" wrote:
Not trying to discourage you, but I wouldn't get your hopes up too high. As radiocolin mentioned, streams on the new devices are encrypted, and it's unlikely that the older streams are in a Roku compatible format. HLS and ISM are the only live streaming formats supported, so even if by some miracle they're encoded with the right codecs, you'd still need to figure out some way to deliver them for playback.


Do you know how to send a "C structure" similar using Bright by sockets?

Can you help?

Example in C

struct Message
{
uint16_t User;
uint16_t Pass;
uint16_t msg;
}

Send(socks, &message)
0 Kudos
FearL0rd
Visitor

Re: SlingPlayer APP Development

I created a RoByteArray using the SDK specs and I'm sending to the server the authentication but the server is returning -1 all the time..


Any tips? 😄



Sub Main()


m.msgPort = CreateObject("roMessagePort")
screen = CreateObject("roParagraphScreen")
screen.setMessagePort(m.msgPort)
screen.show()
print "Main: starting Roku Sling Player"

BoxInfo = getBox("YOUR ID")

setVariables()
setAdress(BoxInfo.DeviceAddress, BoxInfo.DevicePort)

if Connect(true, "YOUR PASSWORD") then
print ("Connected")
else
print ("error")
end if

End Sub

function getBox(id as String) as Dynamic

this = CreateObject("roAssociativeArray")
port = CreateObject("roMessagePort")
screen = CreateObject("roParagraphScreen")
screen.SetMessagePort(port)
screen.SetTitle("Example")

TextTransfer=CreateObject("roUrlTransfer")
TextTransfer.SetUrl("http://srs.slingmedia.com/getDeviceInfo.asp?id=" + id)
SlingBoxInfo=TextTransfer.GetToString()

pa = Instr(SlingBoxInfo,"DeviceAddress=")

if pa > 0 then
pa = pa + 14
i=0
while mid(SlingBoxInfo,pa+i,1) <> "<"
i=i+1
end while

DeviceAddress= mid(SlingBoxInfo,pa,i)
endif

pp = Instr(SlingBoxInfo,"DevicePort=")

if pp > 0 then
pp = pp + 11
i=0
while mid(SlingBoxInfo,pp+i,1) <> "<"
i=i+1
end while

DevicePort= mid(SlingBoxInfo,pp,i)
endif

this.DeviceAddress = DeviceAddress
this.DevicePort = 5001

return this

End function

Sub setVariables()

m.socCommunication = createobject("roStreamSocket")
m.socStream = createobject("roStreamSocket")
m.socAddress = createobject("roSocketAddress")
m.szAddress = ""
m.uiPort = 0
m.usCode = 0
m.usSequence = 0
m.iChannel = -1
m.iInput = -1


m.usHeader = HexToInteger("0101") '// Always 0x0101

m.usCode = 0 '// Grabbed from the first packet from the Slingbox then
m.usMessageID = 0 '// Unique number to identify the message
m.usVar4 = 0 '// Always 0
m.usSequence = 0 '// Sequencial number (answer will have the same number)
m.usDirection = HexToInteger("8000") '// 0 from Slingbox and 0x8000 from software
m.usVar7 = 0
m.usVar8 = 0
m.usSize = 0 '// Size of the buffer (without header)
m.usEncoded = 0 '// 0x2000 if buffer is encoded
m.usVar11 = 0
m.usVar12 = 0
m.usVar13 = 0
m.usVar14 = 0
m.usVar15 = 0
m.usVar16 = 0
m.uiUnknown = HexToInteger("00000000")

m.usAccess = CreateObject("roByteArray")
m.usAccess.setresize(16, false)
m.usPassword = CreateObject("roByteArray")
m.usPassword.setresize(16, false)
m.usID = CreateObject("roByteArray")
m.usID.setresize(66, false)
m.usID.FromAsciiString("Slingbox")


m.SlingBoxMessageIn = CreateObject("roByteArray")
m.SlingBoxMessageIn.setresize(198, false)

m.SlingBoxMessageOut = CreateObject("roByteArray")
m.SlingBoxMessageOut.setresize(198, false)



End Sub

Sub setAdress(saddress as string, sport as integer)

m.DeviceAddress = saddress
m.DevicePort = sport

End Sub

function Connect(isAdmin as boolean, szPassword as string) as boolean

if m.socCommunication.isConnected() then
m.socCommunication.setMessagePort(invalid)
return false
end if

m.socAddress.setAddress(m.DeviceAddress)
m.socAddress.setPort(m.DevicePort)

m.socCommunication.setSendToAddress(m.socAddress)

m.socCommunication.connect()

szString = "GET /stream.asf HTTP/1.1" + chr(13) + chr(10) + "Accept: */*" + chr(13) + chr(10) + "Pragma: Sling-Connection-Type=Control, Session-Id=0" + chr(13) + chr(10) + chr(13) + chr(10)

print "send string"; m.socCommunication.sendStr(szString); " bytes"

port = CreateObject("roMessagePort")
m.socCommunication.setMessagePort(port)
m.socCommunication.notifyReadable(true)

msg = wait(60 * 1000, port)
if m.socCommunication.isReadable() = false
m.socCommunication.setMessagePort(invalid)
return false
end if

m.usCode = 0
m.usSequence = 0
m.iChannel = -1
m.iInput = -1

if isAdmin = true then
m.usAccess.FromAsciiString("admin")
end if
m.usPassword.FromAsciiString(szPassword)


m.usHeaderBA = rdINTtoBA2(m.usHeader)
fillMessage(0, m.usHeaderBA)
m.usCodeBA = rdINTtoBA2(m.usCode)
fillMessage(2, m.usCodeBA)
m.usMessageIDBA = rdINTtoBA2(m.usMessageID)
fillMessage(4, m.usMessageIDBA)
m.usVar4BA = rdINTtoBA2(m.usVar4)
fillMessage(6, m.usVar4BA)
m.usSequenceBA = rdINTtoBA2(m.usSequence)
fillMessage(8, m.usSequenceBA)
m.usDirectionBA = rdINTtoBA2(m.usDirection)
fillMessage(10, m.usDirectionBA)
m.usVar7BA = rdINTtoBA2(m.usVar7)
fillMessage(12, m.usVar7BA)
m.usVar8BA = rdINTtoBA2(m.usVar8)
fillMessage(14, m.usVar8BA)
m.usSizeBA = rdINTtoBA2(m.usSize)
fillMessage(16, m.usSizeBA)
m.usEncodedBA = rdINTtoBA2(m.usEncoded)
fillMessage(18, m.usEncodedBA)
m.usVar11BA = rdINTtoBA2(m.usVar11)
fillMessage(20, m.usVar11BA)
m.usVar12BA = rdINTtoBA2(m.usVar12)
fillMessage(22, m.usVar12BA)
m.usVar13BA = rdINTtoBA2(m.usVar13)
fillMessage(24, m.usVar13BA)
m.usVar14BA = rdINTtoBA2(m.usVar14)
fillMessage(26, m.usVar14BA)
m.usVar15BA = rdINTtoBA2(m.usVar15)
fillMessage(28, m.usVar15BA)
m.usVar16BA = rdINTtoBA2(m.usVar16)
fillMessage(30, m.usVar16BA)
m.uiUnknownBA = rdINTtoBA(m.uiUnknown)
fillMessage(34, m.uiUnknownBA)
m.usAccessBA = m.usAccess
fillMessage(50, m.usAccessBA)
m.usPasswordBA = m.usPassword
fillMessage(66, m.usPasswordBA)
m.usIDBA = m.usID
fillMessage(132, m.usIDBA)

m.socCommunication.setMessagePort(invalid)
m.socCommunication.notifyReadable(false)

m.socCommunication.Send(m.SlingBoxMessageOut, 0, m.SlingBoxMessageOut.Count())

port1 = CreateObject("roMessagePort")
m.socCommunication.setMessagePort(port1)
m.socCommunication.notifyReadable(true)

msg = wait(60 * 1000, port1)
input = m.socCommunication.receive(m.SlingBoxMessageIn, 0, m.socCommunication.getCountRcvBuf())


return true


End function

Sub fillMessage(entry as Integer, ba as Object)

For i=0 to ba.Count() - 1
m.SlingBoxMessageOut.setEntry(i+entry,ba[i])
End For

End Sub

0 Kudos
hodula1
Visitor

Re: SlingPlayer APP Development

Don't know much about the Roku SDK, so not sure if this would help, but wondering if you are able to use their embedded link below?

slingplayer.slingbox.com/embedded/slingplayer.php
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.