Author Topic: Best Approach to Controlling a Network Device  (Read 50271 times)

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #60 on: December 03, 2013, 12:37:16 am »
That warning is a common one, and should be okay.

-Thom

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #61 on: December 03, 2013, 12:57:08 am »
Cool, was making some changes, and declared the m_pxbmc in the  XBMC_MEDIA_CENTRE.h and then XBMC_MEDIA_CENTRE.cpp.cpp, fix that and re-compiled no warning. Actually got the default constructor, working in the constructor of XBMC_MEDIA_CENTRE.cpp, which was giving an error before and working in the GetConfig

Quote
make all
g++ -shared -o XBMC_MEDIA_CENTRE.so Main.o xbmc.o XBMC_MEDIA_CENTRE.o ../Gen_Devices/XBMC_MEDIA_CENTREBase.o  -L../lib  -lmysqlclient_r -lcurl -lSerializeClass -lDCECommon -lPlutoUtils -lpthread
cp XBMC_MEDIA_CENTRE.so ../bin
chmod +x post_make.sh
./post_make.sh XBMC_MEDIA_CENTRE.so

Left testing, can I test without creating a device as in Developing a DCE Device?

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #62 on: December 03, 2013, 01:03:12 am »
no. You'll need to create a device for testing... and use Send Command to Device, to ensure that it works.

Then you'll need to put together the plugin.

-Thom

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #63 on: December 03, 2013, 01:59:32 am »
Tried adding the to core or core/hybrid, but am getting an error when putting in the device number see attachment.

Also attached a print screen of the template existing

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #64 on: December 03, 2013, 03:21:55 am »
What is your controlled via category in your device template ?

-Thom

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #65 on: December 03, 2013, 03:22:33 am »
Also, you can connect to irc.freenode.net (even via the webchat.freenode.net web page), and connect to the #linuxmce-devel chat, and we can help faster, there.

-Thom

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #66 on: December 03, 2013, 09:56:21 am »
Ok, later this evening when I get home, will join that irc.

To report now, got it to work, see output below, basic navigation

Quote
linuxmce@dcerouter:~/CodingWork/LINUXMCE/src/XBMC_MEDIA_CENTRE$ ./XBMC_MEDIA_CENTRE -d 74
XBMC_MEDIA_CENTRE, v.<=version=>
Visit www.plutohome.com for source code and license information

01      12/03/13 4:52:18.038            Config XBMC URL Successful, URL: http://192.168.80.155:80/jsonrpc <0xb77be6f0>
01      12/03/13 4:53:04.011            Command Left Successful: {"id":1,"jsonrpc":"2.0","result":"pong"}{"id":1,"jsonrpc":"2.0","                                      result":"OK"} <0xb6fbcb70>
01      12/03/13 4:53:09.015            Command Left Successful: {"id":1,"jsonrpc":"2.0","result":"pong"}{"id":1,"jsonrpc":"2.0","                                      result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"} <0xb6fbcb70>
01      12/03/13 4:53:14.958            Command Right Successful: {"id":1,"jsonrpc":"2.0","result":"pong"}{"id":1,"jsonrpc":"2.0",                                      "result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"} <0xb6fbcb70>
01      12/03/13 4:54:04.959            Command Back Successful: {"id":1,"jsonrpc":"2.0","result":"pong"}{"id":1,"jsonrpc":"2.0","                                      result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"} <0                                      xb6fbcb70>
01      12/03/13 4:54:19.241            Command Down Successful: {"id":1,"jsonrpc":"2.0","result":"pong"}{"id":1,"jsonrpc":"2.0","                                      result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"i                                      d":1,"jsonrpc":"2.0","result":"OK"} <0xb6fbcb70>
01      12/03/13 4:54:25.720            Command Right Successful: {"id":1,"jsonrpc":"2.0","result":"pong"}{"id":1,"jsonrpc":"2.0",                                      "result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"                                      id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"} <0xb6fbcb70>
01      12/03/13 4:54:29.583            Command Right Successful: {"id":1,"jsonrpc":"2.0","result":"pong"}{"id":1,"jsonrpc":"2.0",                                      "result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"                                      id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"} <0xb6fbcb70>
01      12/03/13 4:54:35.506            Command Select/Enter Successful: {"id":1,"jsonrpc":"2.0","result":"pong"}{"id":1,"jsonrpc"                                      :"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":                                      "OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"js                                      onrpc":"2.0","result":"OK"} <0xb6fbcb70>
01      12/03/13 4:54:45.563            Command Back Successful: {"id":1,"jsonrpc":"2.0","result":"pong"}{"id":1,"jsonrpc":"2.0","                                      result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"i                                      d":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"                                      2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"} <0xb6fbcb70>

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #67 on: December 03, 2013, 11:32:40 pm »
Ok, created the template for the plugin, generated the code, but it does not fully looking like Xine or Pandora, etc.

See attached, is this as expected?

Just time for me to edit, well using from the others where applicable, LOL

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #68 on: December 04, 2013, 03:15:18 am »
Nope, you gotta do more than that, bro. ;)

You need to implement the CreateMediaStream, StartMedia, ConvertMediaStream, etc. methods.

Look at the Hulu_Plugin and the compare with the Xine Plugin and the Game Plugin code.

-Thom

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #69 on: December 04, 2013, 03:21:22 am »
Also make sure to look at the ::Register() method as well in each of these, you need to register your media player with the Media Plugin, in that method.

You also need to add rows to the database, by hand, at the least:

A new row(s) for DeviceTemplate_MediaType using the mediatype for 5 (stored video) and 4 (stored audio), referencing your player's device template.

Once this is done, you can reload router, and if all is well, you'll be able to send an MH Play Media command to the device asking to play a piece of media.


CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #70 on: December 05, 2013, 04:39:29 pm »
Ok thanks.

Did the work on the others, have to augment the register. Also created a XbmcMediaStream based on PandoraMediaStream, cope and pasted

Question
The pXbmcMediaStream->m_iPK_MediaType, well really m_iPK_MediaType, this is going to reference the media types I enter within the DB, 4 and 5?

Just making sure, want to do a check on media type so I choose the appropriate share point for XBMC.

Also, would I be able to referrence any of the Device Data from the XBMC template, for example the mount?

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #71 on: December 05, 2013, 09:40:44 pm »
My humble attempt at the plugin, will try and compile later if I reach home early

Comment of course welcomed


tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #72 on: December 06, 2013, 11:16:04 pm »
Ok. good so far, did you implement XbmcMediaStream ?

-Thom

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #73 on: December 07, 2013, 02:56:45 pm »
Yes I did, see attached, copied from the one you had, plan to try compiling later when I reach home

Also, from the plugin, could you access the device data, for example IP, PORT, MOUNT in my case?

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #74 on: December 07, 2013, 09:21:24 pm »
Yes, you can, using Event_Impl::GetDeviceDataFromDatabase().

From src/DCE/Event_Impl.h:
Code: [Select]
                /**
                 * @brief gets the specified parameter from the specified device and returns it's value in the sResult parameter
                 * @warning not implemented here
                 */
                string GetCurrentDeviceData( int PK_Device, int PK_DeviceData );  // Get it from the device itself
                string GetDeviceDataFromDatabase( int PK_Device, int PK_DeviceData );  // Get the latest value from the router
Each Command_Impl implementation, after ::Connect() is run, will have assigned a pointer to the matching Event_Impl class in m_pEvent, so you can do the following inside StartMedia:

Code: [Select]
string sPort = m_pEvent->GetDeviceDataFromDatabase(pMediaStream->m_pMediaDevice_Source->m_pDeviceData_Router->m_dwPK_Device,DEVICEDATA_Port_CONST);
The device data constants, can of course be read from pluto_main/Define_DeviceData.h,
and the various pointers to classes etc, can all be gleaned from various classes in src/DCE.. the .h files are very helpful in determining what member variables are part of a class.

-Thom