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

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #75 on: December 10, 2013, 12:24:45 am »
Ok thanks

Getting some errors when I try compiling the existing code, see below, code attached

Quote
linuxmce@dcerouter:~/CodingWork/LINUXMCE/src/Xbmc_Plugin$ make so
g++ -c -I.. -I../DCE -I/usr/include/mysql -DKDE_LMCE -DDEBUG -DTHREAD_LOG -DLOG_ALL_QUERIES  -Wall -fPIC -ggdb3  Xbmc_Plugin.cpp -o Xbmc_Plugin.o
In file included from Xbmc_Plugin.cpp:17:
Xbmc_Plugin.h:77: error: ISO C++ forbids declaration of ‘XbmcMediaStream’ with no type
Xbmc_Plugin.h:77: error: expected ‘;’ before ‘*’ token
Xbmc_Plugin.cpp: In member function ‘virtual bool DCE::Xbmc_Plugin::Register()’:
Xbmc_Plugin.cpp:94: error: ‘DEVICETEMPLATE_Xbmc_Player_CONST’ was not declared in this scope
Xbmc_Plugin.cpp: In member function ‘virtual DCE::MediaStream* DCE::Xbmc_Plugin::CreateMediaStream(DCE::MediaHandlerInfo*, int, std::vector<DCE::EntertainArea*, std::allocator<DCE::EntertainArea*> >&, DCE::MediaDevice*, int, std::deque<MediaFile*, std::allocator<MediaFile*> >*, int)’:
Xbmc_Plugin.cpp:232: error: ‘XbmcMediaStream’ was not declared in this scope
Xbmc_Plugin.cpp:232: error: ‘pXbmcMediaStream’ was not declared in this scope
Xbmc_Plugin.cpp:252: error: ‘DEVICETEMPLATE_Xbmc_Player_CONST’ was not declared in this scope
Xbmc_Plugin.cpp:276: error: expected type-specifier before ‘XbmcMediaStream’
Xbmc_Plugin.cpp:276: error: expected ‘;’ before ‘XbmcMediaStream’
Xbmc_Plugin.cpp: At global scope:
Xbmc_Plugin.cpp:285: error: expected constructor, destructor, or type conversion before ‘*’ token
../Media_Plugin/MediaListGrid.h:117: warning: ‘bool FileBrowserInfoComparer(FileBrowserInfo*, FileBrowserInfo*)’ defined but not used
../Media_Plugin/MediaListGrid.h:134: warning: ‘bool FileBrowserInfoComparerLastViewed(FileBrowserInfo*, FileBrowserInfo*)’ defined but not used
make: *** [Xbmc_Plugin.o] Error 1

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #76 on: December 10, 2013, 02:12:13 am »
You need to make sure that sql2cpp has been run, after you create a new device template. I am very confused that you didn't receive the error: ‘DEVICETEMPLATE_Xbmc_Player_CONST’ was not declared in this scope whilst you were developing the player, Did you run sql2cpp? If so, you need to also make sure that in the .cpp there is an #include "pluto_main/Define_DeviceData.h" up top.

As for the others, these are happening because these variables are either not defined in the .h, or they are improperly cased. C is case sensitive, so the case, in addition to spelling of the variables must match.

-Thom

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #77 on: December 10, 2013, 11:20:18 am »
Hi tschak900

I am getting the following error

Quote
linuxmce@dcerouter:~/CodingWork/LINUXMCE/src/Xbmc_Plugin$ make so
g++ -c -I.. -I../DCE -I/usr/include/mysql -DKDE_LMCE -DDEBUG -DTHREAD_LOG -DLOG_ALL_QUERIES  -Wall -fPIC -ggdb3  XbmcMediaStream.cpp -o XbmcMediaStream.o
XbmcMediaStream.cpp: In member function ‘virtual int DCE::XbmcMediaStream::GetType()’:
XbmcMediaStream.cpp:33: error: ‘MEDIASTREAM_TYPE_XBMC’ was not declared in this scope
make: *** [XbmcMediaStream.o] Error 1

Would this be, as I have not entered the database bits for video and audio type, thus the Media_Plugin/MediaHandlerInfo.h has not been populated with an MEDIASTREAM_TYPE_XBMC?

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #78 on: December 10, 2013, 02:06:55 pm »
Correct, you need to put one in there.. It just needs to be a unique number, follow the conventions for what is already there.

-Thom

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #79 on: December 10, 2013, 11:41:36 pm »
Ok did the insert as follows

Quote
insert into DeviceTemplate_MediaType (FK_DeviceTemplate,FK_MediaType,CanPlayFromDiskDrive,CanStoreOnServer,CanSetPosition,CanPlayInMultipleAreas,StopOtherMediaInEntArea)
   values (2244,4,1,1,1,1,1)
insert into DeviceTemplate_MediaType (FK_DeviceTemplate,FK_MediaType,CanPlayFromDiskDrive,CanStoreOnServer,CanSetPosition,CanPlayInMultipleAreas,StopOtherMediaInEntArea)
   values (2244,5,1,1,1,1,1)

Then ran /usr/pluto/bin/sql2cpp but it did not update the Media_Plugin/MediaHandlerInfo.h.

I should also edit Media_Plugin/MediaHandlerInfo.h, with the PK for the updated table or something went wrong?

If I have to edit that file, which entry to use, one for video or audio?
« Last Edit: December 10, 2013, 11:52:27 pm by CentralMedia »

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #80 on: December 11, 2013, 01:47:23 am »
You need to edit MediaHandlerInfo.h to add a constant, this should be sufficient:

Code: [Select]
#define MEDIASTREAM_TYPE_XBMC           113

-Thom

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #81 on: December 11, 2013, 04:45:39 pm »
Got it to compiled, now to test

Question

In the following
Quote
If you look in the .h for your generated class, you'll see DATA_TCP_address(), DATA_TCP_Port(), etc.. prototypes... This is how you reference the device data. These are read-only, and you should send a CMD_Set_Device_Data message to the General_Info_Plugin, should you wish to change device data programmatically.

The CMD_Set_Device_Data is part of the General_Info_Plugin.h or my device? This would mean I have to include General_Info_Plugin.h and I do something like
Quote
CMD_Set_Device_Data(m_dwPK_Device,"smb://DCEROUTER/public/",DEVICEDATA_XbmcVideoMount_CONST)

Got device data from Define_DeviceData.h

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #82 on: December 11, 2013, 05:53:45 pm »
No.

To send a command to another device, you need to either:

1. know the PK_Device ID you want to send to
2. know the Device Category you want to send to
3. know the Device Template you want to send to
4. know the list of PK_Device IDs you want to send to.

If you look at the example present in every DCE project, you'll see how to send a command to a specific Device category, I would recommend doing something like:

Code: [Select]
CMD_Set_Device_Data_Cat CMD_Set_Device_Data_Cat(....);
SendCommand(CMD_Set_Device_Data_Cat);

You for that above, you'll want to send to the General Info Plugins category.

-Thom

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #83 on: December 11, 2013, 06:51:01 pm »
This is from the actual device XBMC_MEDIA_CENTRE, not the plugin, sorry for the confusion, in the plugin I used what the other plugins used.


tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #84 on: December 11, 2013, 09:05:20 pm »
The same technique is used for devices with local device data. As I mentioned before, the DATA_foo() methods are merely just read-only.

-Thom

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #85 on: December 11, 2013, 11:58:55 pm »
I know how to start my device for testing.

How do I test the plugin created?

What further configurations I need to do to test playing a file?

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #86 on: December 13, 2013, 11:22:48 pm »
I got the plugin to work, went ahead and copied the .so file to /usr/pluto/bin then create a plugin under DCERouter, like the other plugins, and was able to play a video file from the orbitor, feels nice, LOL.

More to do,

At present I have to enter an IP in my device under the core, see how to get that to be filled when the device is initialized.

Setting the mount points based on what is passed when the configuration is pulled from XBMC, when the device is initialized, coded but commented it out for initial testing.

Figure why the pause does not work from the Orbitor.

Attached the plugin code and the XBMC device

tschak909

Question, initially I created the XBMC device under core, so I have to go to the closet to play, would a simple assignment to a room, allow it to function as a device in that room?

Would this also function as like squeezeslave, cannot be in a room with an MD?


tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #87 on: December 13, 2013, 11:29:57 pm »
Yes, you'll need to assign it to a room.

-Thom

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #88 on: December 14, 2013, 12:57:50 am »
TSCHAK909

I am seeing this is the DCERouter.log, would it help
Quote
08      12/13/13 19:52:51.839           Received Message from 70 (Windows XP PC/tablet (Horiz) / Bedroomles) to 10 (Media Plug-in / Closet/Storage Space), type 1 id 39 Command:Pause Media, retry none, parameters: <0x6a5b4b70>
08      12/13/13 19:52:51.839             Parameter 41(StreamID):  <0x6a5b4b70>
05      12/13/13 19:52:51.839           BoundRemote::UpdateOrbiter(): Updating object:  on device 21 with size of 19584 <0x867e1b70>
05      12/13/13 19:52:51.839           BoundRemote::UpdateOrbiter(): Updating object: 2355 on device 70 with size of 19584 <0x867e1b70>
05      12/13/13 19:52:51.839           BoundRemote::UpdateOrbiter(): Updating object: 2355 on device 73 with size of 19584 <0x867e1b70>
08      12/13/13 19:52:51.840           Received Message from 10 (Media Plug-in / Closet/Storage Space) to 21 (OnScreen Orbiter / Closet/Storage Space), type 1 id 242 Command:Set Now Playing, retry none, parameters: <0xa69f9b70>
08      12/13/13 19:52:51.840             Parameter 3(PK_DesignObj): 70,4964,47,140,224,230 <0xa69f9b70>
08      12/13/13 19:52:51.840             Parameter 5(Value To Assign): Xbmc <0xa69f9b70>
08      12/13/13 19:52:51.840             Parameter 9(Text):  <0xa69f9b70>
08      12/13/13 19:52:51.840             Parameter 29(PK_MediaType): 5 <0xa69f9b70>
08      12/13/13 19:52:51.840             Parameter 41(StreamID): 1004 <0xa69f9b70>
08      12/13/13 19:52:51.840             Parameter 48(Value): 0 <0xa69f9b70>
08      12/13/13 19:52:51.840             Parameter 50(Name):  <0xa69f9b70>
08      12/13/13 19:52:51.840             Parameter 103(List PK Device): 74,74,74,,0,1,0 <0xa69f9b70>
08      12/13/13 19:52:51.840             Parameter 120(Retransmit): 0 <0xa69f9b70>
08      12/13/13 19:52:51.841           Received Message from 0 (unknown / ) to 70 (Windows XP PC/tablet (Horiz) / Bedroomles), type 1 id 32 Command:Update Object Image, retry none, parameters: <0xa69f9b70>

Also from watching the device output, it does not seem to be calling any of the commands, see below, there is a play and then stop. The only command I have not implemented from Xine Player is keyboard
Quote
01      12/13/13 19:51:56.773           Command Play Successful: {"id":1,"jsonrpc":"2.0","result":"pong"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":[{"playerid":1,"type":"video"}]}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"} <0xb6fa6b70>
01      12/13/13 19:58:32.173           Command Stop Successful: {"id":1,"jsonrpc":"2.0","result":"pong"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":[{"playerid":1,"type":"video"}]}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":"OK"}{"id":1,"jsonrpc":"2.0","result":[{"playerid":1,"type":"video"}]}{"id":1,"jsonrpc":"2.0","result":"OK"} <0xb6fa6b70>

« Last Edit: December 14, 2013, 01:21:50 am by CentralMedia »

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #89 on: December 14, 2013, 05:37:42 am »
That's fine, can you paste the DCERouter log when you press any of the other commands?

Does your register method properly push back the xbmc player? I'm not seeing the command make it to the plugin.

-Thom