LinuxMCE Forums

General => Users => Topic started by: CentralMedia on October 16, 2013, 02:14:24 am

Title: Best Approach to Controlling a Network Device
Post by: CentralMedia on October 16, 2013, 02:14:24 am
I have a PI running raspbmc, finally figured out some of the JSON RPC code, this afternoon.

Got the TCP connection to work, once, but work, its output is like, no separation for response

Quote
{"id":1,"jsonrpc":"2.0","result":"OK"}{ "jsonrpc": "2.0", "method": "Input.Down", "id": 1 }
{"id":1,"jsonrpc":"2.0","result":"OK"}{ "jsonrpc": "2.0", "method": "Input.Select", "id": 1 }
{"id":1,"jsonrpc":"2.0","result":"OK"}{ "jsonrpc": "2.0", "method": "Input.Home", "id": 1 }
{"id":1,"jsonrpc":"2.0","result":"OK"}

Also got the html request to work, also did the right, left, down

Quote
http://192.168.80.149:80/jsonrpc?request={ "jsonrpc": "2.0", "method": "Input.Select", "id": 1 }

Have not tried the websocket option, honestly have not wrapped my head around initiating or using it.

My question is, how best to implement the HTML  feature and if there are any example devices using this?

Would websocket be preferable and any example code.

Suggestions are also welcomed

 
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on October 16, 2013, 07:52:55 pm
How best to "implement the HTML feature?" I'm confused.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: seth on October 16, 2013, 09:25:51 pm
Hi.

This post has caught my attention.
Do you intend to create an Orbiter Remote for an xbmc media device.
I have often thought about this, as I have 3 raspbmc raspberry pi's currently running as low power media centers back-ended by the LinuxMCE core PC (well one is openelec). Sharing media and assigning network addresses and such. As xbmc by default allows for web based control, which is how all the android and iDevices in my house control it, a new orbiter screen, and even possibly two way communications between xbmc and LinuxMCE using xbmc as a frontend and the core LinuxMCE server would be quite the rig.

I have been working on an xbmc screen to set up LinuxMCE functions, lighting, climate, etc. as it is silly easy to skin. But I have run out of available free time. This will be remedied over the upcoming holidays with any luck.

If I get it to a point that it is functional, I can at least attach the code bits for the xbmc > LinuxMCE interface. That coupled with a possible communication interface that is two-way between the two devices......that would be amazing. PI's running xbmc as a media device not unlike the Roku, would be like a Roku to the power of 10.  ;)

I will keep an eye on this thread.

Regards,

Seth
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on October 16, 2013, 09:28:15 pm
XBMC support will need to be written as a Plugin and Player pair, using C++. See Developing a DCE Device, on the wiki.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: seth on October 16, 2013, 09:40:46 pm
 :)
I agree Thom.
I was hoping to create it as a device, but as I seem to never have time, I am torn between helping with the moonpi, or creating a service for xbmc.

Maybe the forum would like to push me one way or the other.

The raspberry Pi is just such a tasty little device. Low power. Easily concealed. CeC enabled.

Oh my.

Regards,

Seth
Title: Re: Best Approach to Controlling a Network Device
Post by: phenigma on October 16, 2013, 10:14:37 pm
It depends on what you want.  Is your goal to use the Pi? or is your goal to use xbmc?

If the goal is to use the Pi then I would push you incredibly towards helping with qOrbiter on the rPi.  This will be an 'integrated' way forward for orbiter/md control/media playback on the pi.  We need a DCE aware libCEC device to run on the moonPi (this could operate as a standalone DCE-libCEC interface on Pi and it could also be used on a moonPi).  We need testing.  I don't know if more than 2-3 people have even tried to install an MD on a Pi, and I only hear from 1 or 2 people sporadically.

If the goal is to use xbmc (on whatever) then an xbmc device and plugin could be pursued.  I don't see this as useful unless complete orbiter functionality can be brought to xbmc.  Use nfs/smb/upnp/dlna connectivity to play media from the core otherwise.

Both have their usefullness.  For lmce project purposes I will push qOrbiter and moonPi.   ;D

J.
Title: Re: Best Approach to Controlling a Network Device
Post by: golgoj4 on October 17, 2013, 01:52:18 am
It depends on what you want.  Is your goal to use the Pi? or is your goal to use xbmc?

If the goal is to use the Pi then I would push you incredibly towards helping with qOrbiter on the rPi.  This will be an 'integrated' way forward for orbiter/md control/media playback on the pi.  We need a DCE aware libCEC device to run on the moonPi (this could operate as a standalone DCE-libCEC interface on Pi and it could also be used on a moonPi).  We need testing.  I don't know if more than 2-3 people have even tried to install an MD on a Pi, and I only hear from 1 or 2 people sporadically.

If the goal is to use xbmc (on whatever) then an xbmc device and plugin could be pursued.  I don't see this as useful unless complete orbiter functionality can be brought to xbmc.  Use nfs/smb/upnp/dlna connectivity to play media from the core otherwise.

Both have their usefullness.  For lmce project purposes I will push qOrbiter and moonPi.   ;D

J.

As the developer of qOrbiter, im partial to that
As a guy who likes making stuff go, im open to making the device. ive made a couple already. if it speaks json then thats stupid easy to work with.

But alas,
broham is like developing qorbiter skins, qorbiter backend, qorbiter for mobile devices, trying to maintain autotagger... did i mention i added phillips hue lighting control? but yeah...point me to a spec and lets see how much work it actually is.

-golgoj4
i am also somewhat of a qt fanatic and like to put it everywhere.
anyways, as you can see, i have crap to do. discuss amongst yourselves :p
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on October 17, 2013, 01:59:54 pm
tschak909
The question should be how to send this type of HTML from a shell script, or what device has this feature that I can attempt to familiarize.

My programming languages are non existent, but plan on getting this to work.

Seth

You have this figured out much better than I, actually my focus now, is just getting navigation, once done, move from there, did not want to bit of more than I can cope with.
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on October 30, 2013, 12:36:19 am
Ok, figured out how to use curl to send the commands, even figured out how to play a file, LNMCE shares not working, feel I need to pass the password along with the smb call, hopefully will figure out how to.

Working
Quote
curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Player.Open\", \"params\": { \"item\": { \"file\": \"/home/pi/Video/skyfall.mp4\"} , \"options\":{ \"resume\":true } }, \"id\": 1}" http://192.168.80.150:80/jsonrpc
curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Player.GetActivePlayers\", \"id\": 1}" http://192.168.80.150:80/jsonrpc
curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Player.PlayPause\", \"params\": { \"playerid\": 1}, \"id\": 1}" http://192.168.80.150:80/jsonrpc
curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Player.Stop\", \"params\": { \"playerid\": 1}, \"id\": 1}" http://192.168.80.150:80/jsonrpc
curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Input.Home\", \"id\": 1}" http://192.168.80.150:80/jsonrpc
curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Input.Left\", \"id\": 1}" http://192.168.80.150:80/jsonrpc
curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Input.Right\", \"id\": 1}" http://192.168.80.150:80/jsonrpc
curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Input.Down\", \"id\": 1}" http://192.168.80.150:80/jsonrpc
curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Input.Select\", \"id\": 1}" http://192.168.80.150:80/jsonrpc

Not Working, think I need to pass the password some how, not figured out as yet.
Quote
curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Player.Open\", \"params\": { \"item\": { \"file\": \"smb://DCEROUTER/public/videos/DespicableMe2Test.mkv\"} , \"options\":{ \"resume\":true } }, \"id\": 1}" http://192.168.80.150:80/jsonrpc
curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Player.Open\", \"params\": { \"item\": { \"file\": \"smb://192.168.80.1/public/videos/DespicableMe2Test.mkv\"} , \"options\":{ \"resume\":true } }, \"id\": 1}" http://192.168.80.150:80/jsonrpc

Can anymore can shed some light how tothe capture the response by curl, in a shell script, need to get the player id seen below

Quote
linuxmce@dcerouter:~/CodingWork/XBMC$ curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Player.GetActivePlayers\", \"id\": 1}" http://192.168.80.150:80/jsonrpc
HTTP/1.1 200 OK
Content-Length: 65
Content-Type: application/json
Date: Tue, 29 Oct 2013 23:15:30 GMT

{"id":1,"jsonrpc":"2.0","result":[{"playerid":1,"type":"video"}]}

As I learn how to communicate with devices on the network, the next device is the WD live HD, borrowed a switch from a friend, where I can mirror the port, so I can see how the Andriod app connects and send commands, by collecting the data with wireshark, doing that tomorrow. Had written WD about an API, but got no definitive feedback from them

Fun times
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on October 30, 2013, 12:39:23 am
As I said before, this will need to be done as a C++ device.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: Stash_CEO on October 30, 2013, 03:40:25 pm
I also have a RPI and it's been sitting in my desk drawer waiting to be unleashed.  I played around with RaspBMC a little and liked it but am trying to get more from LMCE so I've put it on hold.  I'd like to see the PI running as an MD but I'm also going to use them as squeezeslaves.  I know zero about coding and wish I could give you guys a hand other than testing.  Anyone have any ideas where and what code I can learn to help you guys out.
Title: Re: Best Approach to Controlling a Network Device
Post by: Dap-P on October 30, 2013, 11:49:21 pm
Code: [Select]
linuxmce@dcerouter:~/CodingWork/XBMC$ curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Player.GetActivePlayers\", \"id\": 1}" http://192.168.80.150:80/jsonrpc
HTTP/1.1 200 OK
Content-Length: 65
Content-Type: application/json
Date: Tue, 29 Oct 2013 23:15:30 GMT

{"id":1,"jsonrpc":"2.0","result":[{"playerid":1,"type":"video"}]}

I know a little about capturing data from scripts, this is as i would do this:
playerid=$(curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Player.GetActivePlayers\", \"id\": 1}" http://192.168.80.150:80/jsonrpc | grep playerid | awk -F'playerid":' '{print $2}' | awk -F',' '{print $1}')

something like this should capture the player id in a variable called playerid

Anton
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on October 31, 2013, 10:48:59 pm
Thanks, will play with that for now, trying to organize in my head how all this work. I currently have a shell script that accepts one input and does basic navigation. The media control, was doing that at the command prompt, all in a effort to rap my head around this.

Investigating, as I do not know how, using curl within c++, following tschak900 suggestion, found including libcurl.h, but really trying to use the executable directly. I believe that what he suggested, the system will handle all sending the file to play to the PI, I just need to be able to process it.

Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on November 01, 2013, 06:35:43 am
You may want to look at the src/Roku_LTHDXD_Streaming_Pla code. It uses libcurl to send HTTP requests to ask the player to do things via its ECP port. There are plenty of C++ examples for parsing JSON, as well.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 01, 2013, 09:28:43 pm
Ok

Went through the code, forgive me but I am strickly green, lets see if I have the logic correct
The RokuDevice.h sets up the ground work, defining what should happen to initiate a connection, while the RokuDevice.cpp, implements the the constructure and the two functions
defined in RokuDevice.h. The Roku_LTHDXDXS_Streaming_Pla.cpp, implements what is defined in its corresponding Roku_LTHDXDXS_Streaming_Pla.h.

I actually see where the commands are coded

Quote
void Roku_LTHDXDXS_Streaming_Pla::CMD_EnterGo(int iStreamID,string &sCMD_Result,Message *pMessage)
   //<-dceag-c190-e->
   {
      cout << "Need to implement command #190 - Enter/Go" << endl;
      cout << "Parm #41 - StreamID=" << iStreamID << endl;
      PLUTO_SAFETY_LOCK(rm, m_RokuMutex);
      m_pRokuDevice->SendToRoku("POST /keypress/Select HTTP/1.1\r\n\r\n");

   }

The question comes, is it at this point, see below, that libcurl is being used or I have completely missed the boat?

Quote
m_pRokuDevice->SendToRoku("POST /keypress/Select HTTP/1.1\r\n\r\n");

Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on November 01, 2013, 09:36:49 pm
If you notice, this is a pointer to a RokuDevice class. This code is abstracted into RokuDevice.cpp and .h, have a look there.

I did this, to keep the main C++ code clean, and to compartmentalize all the CURL logic  in place.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: golgoj4 on November 02, 2013, 12:30:28 am
I also have a RPI and it's been sitting in my desk drawer waiting to be unleashed.  I played around with RaspBMC a little and liked it but am trying to get more from LMCE so I've put it on hold.  I'd like to see the PI running as an MD but I'm also going to use them as squeezeslaves.  I know zero about coding and wish I could give you guys a hand other than testing.  Anyone have any ideas where and what code I can learn to help you guys out.

Be a little more patient. I finally got all my pi's setup and toolchain to build qorbiter for it. which can play audio for sure!
re what to learn, depends on what you like to do. pretty stuff everyone sees (GUI), or quiet things everyone uses and never realizes it (everything else).

Im always looking for more people who are interested in learning QML, which is similar to javascript in MANY ways, but in general we are all happy if anyone jumps in to contribute in most ways. Except management. don't think you can really do better than possy. jus sayin.

-langston
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 03, 2013, 07:28:00 pm
Ok, so the send function under sys/socket.h, is what is transmitting similar to what the curl will do or its what curl is based on?

Honestly I did not know that struct addrinfo *m_pServerInfo, was a definition of a pointer.

Additional, I googled all the includes, to understand what they provide and an understanding of the processes with the code, got links similar to below.
Quote
http://pubs.opengroup.org/onlinepubs/009604499/basedefs/sys/socket.h.html

Is there any other site, which defines the options you can include?

Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on November 03, 2013, 08:36:37 pm
Ah actually, yes, in this case, I just did direct socket comms, not curl.

And yes, it will be similar.

Some more reading material:

http://stackoverflow.com/questions/11973994/json-requests-in-c-using-libcurl
and http://zserge.bitbucket.org/jsmn.html provides a C library for parsing simple JSON.

You can use libcurl to get the json, and then use jsmn to spit out something more useful.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 05, 2013, 04:40:37 pm
Thanks

Well I believe I have made some steps, got basic function under c++, as I was able to get a one off command to work, move right, have not handled getting the response as suggested, working on.

Have not done an LNMCE specific stuff yet, just trying to understand the process, that is coding in c++ and how all works, attempt shown  below
Quote
/**********************************
Testing the use of libcurl to send JSON
to XBMC

Put together from findings on google

************************************/
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <curl/curl.h>

int main()
{
   CURL *curl;
   CURLcode res;
   struct curl_slist *headers=NULL;
   char jsonObj[80];
   int a=1;
   float b=2.0;
   if (0 != curl_global_init(CURL_GLOBAL_ALL))
    {
      fprintf(stderr, "Global Call Failed: %s\n", "Some error");
      return false;
    }
   else
   {
      curl = curl_easy_init();
      if (curl)
      {
         sprintf(jsonObj, "\"jsonrpc\": \"%.1f\", \"method\": \"%s\", \"id\": \"%d\"", b, "Input.Right", a);
         /*Ok curl initialized, let first set the URL for XBMC */
         curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.80.150:80/jsonrpc");
         /*Set header here as CURLOPT_HTTPHEADER requires this variable type*/
         headers = curl_slist_append(headers, "Content-Type: application/json");
         curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
         /* Now specify the POST data */
         /*fprintf(stderr, jsonObj); to check what the object was doing, realized it converts everything to string, which fails for the    ID
         curl_easy_setopt(curl, CURLOPT_POSTFIELDS, jsonObj);*/
         curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"jsonrpc\": \"2.0\", \"method\": \"Input.Left\", \"id\": 1}");
         curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)-1);
         curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
         res = curl_easy_perform(curl); /*So I segment faulting here */
         
         if(res != CURLE_OK)
         {
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
         }
         /* always cleanup */
         
         curl_easy_cleanup(curl);
      }
      fprintf(stderr, "Clean global: %s\n", " ");
      curl_global_cleanup();
      return 0;
   }
}

What was helpful also, was curl at the command prompt, has an option to build the code, though it did not work when compiled, was nice
Quote
curl -i -X POST -H "Content-Type: application/json" -d "{\"jsonrpc\": \"2.0\", \"method\": \"Input.Right\", \"id\": 1}" http://192.168.80.150:80/jsonrpc --libcurl mytest.txt

Yes not nice, but seeing the light, currently testing options, as pass right, left, etc, then realized c++ does not support case statement with strings, so did with an if and else if, using compare.

 Now its time to start properly working on what can be the base, a xbmc_control.h and xbmc_control.cpp.

Any advice is welcomed, as c++ is totally new to me, google is truly a friend, wish I had more time, LOL.


Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on November 05, 2013, 07:18:32 pm
Fantastic. Now you should try to at least, bring the "sending to device" stuff into at least its own function that can easily be called from the different commands, so all you have to do is just call that function...e.g.

take all the curl initialization code, and put it into getConfig...and make a variable, m_Curl, so that it can be easily dealt with in both the GetConfig() and your new send function.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 06, 2013, 02:40:31 am
Silly question

Ok, I created an xbmc.h and xbmc.cpp.

For the time I made it extremely basic, but my question comes, examples I am seeing online, create the class and the initialize it in main in the same .cpp file, I was wondering, if I have .h (hearder) and .cpp (code) files below, would need a separate .cpp file, lets say for testing, runXBMC.cpp, where I include the xbmc.h and then instantiate the object and call the function or I have this totally off?

xbmc.h
Quote
#include <string>
class xbmc
{
   private:
      string m_url;
   protected:
   public:
      xbmc(string url);
      SendToXBMC();
   
};

xbmc.cpp
Quote
#define _FILE_OFFSET_BITS 64
#include <curl/curl.h>
#include <xbmc.h>
/*Lets try this again, hopefully nicer*/
xbmc::SendToXBMC()
{
   CURL *curl;
   CURLcode res;
   struct curl_slist *headers=NULL;
   if (0 != curl_global_init(CURL_GLOBAL_ALL))
    {
      fprintf(stderr, "Global Call Failed: %s\n", "Some error");
      return false;
    }
   else
   {
      curl=curl_easy_init();
      if (curl)
      {
         /*Ok curl initialized, let first set the URL for XBMC */
         curl_easy_setopt(curl, CURLOPT_URL, m_url);
         /*Set header here as CURLOPT_HTTPHEADER requires this variable type*/
         headers = curl_slist_append(headers, "Content-Type: application/json");
         curl_easy_setopt(curl, CURLOPT_HTTPHEADER, m_headers);
         curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"jsonrpc\": \"2.0\", \"method\": \"Input.Left\", \"id\": 1}"); /*need to create a json object to pass here*/
         curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)-1);
         curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
         res = curl_easy_perform(curl);
         if(res != CURLE_OK)
         {
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
         }
         curl_easy_cleanup(curl);
         
      }
   }
   
   curl_global_cleanup();
}
/*Constructor URL for the XBMC PI to pass here*/
xbmc::xbmc(string url)
{
   m_url=url;
}

Have not compiled this as yet

Should add, this is from the perspective that when creating the device in LNMCE, it would give the ability to instantiate.
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 06, 2013, 03:58:19 pm
Ok found this, which I think clears up some stuff for me

Quote
http://www.learncpp.com/cpp-tutorial/19-header-files/
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 06, 2013, 05:14:19 pm
I am failing at the following, bit stumped, see attached

Quote
g++ main.cpp -o test
main.cpp: In function ‘int main()’:
main.cpp:9: error: no matching function for call to ‘xbmc::xbmc()’
xbmc.h:10: note: candidates are: xbmc::xbmc(std::string)
xbmc.h:5: note:                 xbmc::xbmc(const xbmc&)
main.cpp:11: error: conflicting declaration ‘xbmc xbmc_url’
main.cpp:8: error: ‘xbmc_url’ has a previous declaration as ‘std::string xbmc_url’

Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on November 06, 2013, 05:21:02 pm
try m_xbmc = xbmc::xbmc(xbmc_url);

this will set up m_xbmc appropriately.

When you move this into DCE, you may want to do

Code: [Select]
xbmc* m_pXBMC;
m_pXBMC = new xbmc::xbmc(xbmc_url);
m_pXBMC->DoSomething();

and in your DCE device's destructor, do:
Code: [Select]
delete m_pXBMC;
m_pXBMC=NULL;

This is demonstrating two ways to instantiate an object, either on the stack (The former), or on the heap (The latter)...the latter is usually preferred, as it uses heap (main memory) versus the stack, which is limited, and tends to get destroyed when functions end. When you do a new, you need to do a corresponding delete, to make sure you give the memory back to the operating system, otherwise, you'll have a memory leak.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 06, 2013, 11:37:41 pm
Hi tschak909

I tried it and getting the following error

Quote
g++ main.cpp -o test
/tmp/cchrNCNr.o: In function `main':
main.cpp:(.text+0x81): undefined reference to `xbmc::xbmc(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
main.cpp:(.text+0xb1): undefined reference to `xbmc::~xbmc()'
main.cpp:(.text+0xc3): undefined reference to `xbmc::~xbmc()'
collect2: ld returned 1 exit status

I even tried but no luck, same error
Quote
xbmc m_xbmc(xbmc_url);

Would this be the linker not getting the code for the xbmc.h from xbmc.cpp?
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on November 06, 2013, 11:51:57 pm
The unresolved symbols are because you're bringing in the source code for the xbmc class, but the compiler isn't linking in the xbmc compiled output, so that it knows where the compiled code is... you need to also compile in xbmc.cpp, as well.

at the very least,

Code: [Select]
gcc -o test main.cpp xbmc.cpp

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 07, 2013, 01:52:29 am
Hi tschak909

This worked, I have a question though, is it acceptable to include in main.cpp the xbmc.cpp?
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on November 07, 2013, 02:08:12 am
It works, but it is better form to have each class have its own cpp and .h (usually, there are exceptions, just look in our DCE library)

This is all somewhat moot, because when you get ready to run DCEGen to make a C++ project, it will make the skeleton classes for the DCE device, that you just fill in the methods.

Now that you've made a xbmc class, you've encapsulated the logic to talk to it, and can more easily call it from the generated classes that DCEGen will make.

Oh, also, DCEGen will make a Makefile for you, so that you can build the device, without having to manually run gcc.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 07, 2013, 01:44:48 pm
Ok thanks

Well did some testing with calling the function, just navigation, see code attached.

Now, its what is maybe the hardest part, not clear in my head yet that why, getting the json output, checking it and doing something with it, fun times, looking at what you suggested, but they indicated a demo.c but it was not there when I did the hg clone, found another example, but have to wrap my head around it.

Suggestions from anyone is also welcomed.



Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 18, 2013, 01:47:24 am
Ok got some time today, made an attempt to get the data I believe is required, especially for controlling playback.

Tested with checking the response, then actually getting a player ID, was able to pause a movie and stop that movie. Decided to use and search a string, as I was only interested in getting the output for some value, eg, in testing the response, which was OK, in getting a player ID, the ID, which I had to cast from string to int, works thus far.

Need to put in speed and send input for searches, lets say in add on youtube, also how to play a file or URL.

see attached my progress.

Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 26, 2013, 02:05:06 am
Ok, did some changes, got it creating in a heap and tried in main to log information.

Only basic functionality tested, navigation left, right, up, down, back, select, home. Additional pausing, playing a file from LNMCE, changing speed and tested also seeking, calling addons, and sending text to a search, command line but its do able otherwise.

Have not tested playlist etc, but I believe its time to create the device and all that entails.

After this, would move to the WD live

See code attached
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 27, 2013, 11:50:58 pm
I was looking to start creating the device, so read the Developing a DCE Device and looking to proceed.

Hi tschak909

What is the device template number for the ROKU STREAMER, wanted to check it out for a guide or any similar device.

Trying to sort out some stuff, like control by, etc, want to look at a similar example.
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on November 28, 2013, 06:01:27 am
That would be DT#2049. You can see the code in src/Roku_LTHDXDXS_Pla  in the source tree.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 29, 2013, 12:09:13 am
Thanks

See attached, screen shot of template for device.

I get the menu navigation and media ctrl.

Is there a command group which can be chosen for playing a video file or audio file from LNMCE as below, thus I pass the file as below, well not the SMB stuff, but /home/public/videos/....mkv, and which can be sent.

"{\"jsonrpc\": \"2.0\", \"method\": \"Player.Open\", \"params\": { \"item\": { \"file\": \"smb://DCEROUTER/public/videos/2.73 TB (sdb1) WDC_WD30EFRX-68 [71]/Transformers Dark of the Moon (2011).mkv\"} , \"options\":{ \"resume\":true } }, \"id\": 1}"

Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on November 29, 2013, 02:02:57 am
The implementation ultimately depends on how the plugin is written, but, normally, the system sends an MH Play Media command to the media plugin.

This gets routed into the Plugin's CreateMediaStream method, which creates a media stream.

This then gets routed into Plugin's the StartMedia method, which then figures out the commands it needs to send to play the stream (usually, finding the player devices for an entertainment area, and sending a Play Media command to them.)

You can see this in the various Plugin devices like Xine_Plugin, Game_Plugin, SmartQ_Plugin, Hulu_Plugin, etc.

Since XBMC will be most likely running on the media directors, and the media directors do the plumbing of exposing the media devices, you should just pass the file path that is sent through MH Play Media, straight to the player, as this will be a local path (e.g. /home/public/data/videos/blabla...)

Also, the XBMC Player device must have a Name device data. This field contains the WM_CLASS.WM_NAME for the window that Orbiter is to swallow and manage (so it can bring it to front when needed, push it back a layer when the orbiter menu needs to be displayed, etc.)... You can get this information by running wmctrl -l -x while xbmc is running. You'll see something like "XBMC.xbmc" or whatever, and this needs to be put into the Name device data, so that Orbiter can swallow the window.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 29, 2013, 10:31:00 am
Thanks, forgot to attach a print out of the template also.

How off or close am I?
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on November 29, 2013, 04:23:23 pm
You may also want Smart Media Player commands.

Also, Descriptions usually aren't in upper case. Please follow the conventions of the other templates.

TCP Address usually isn't needed, isn't XBMC going to be running local to the media director?

There also isn't a Name device data. again, isn't the XBMC going to be running on the local media director?

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: Marie.O on November 29, 2013, 04:48:48 pm
/me wonders, why XBMC be running on an MD?!

All people I know, just have some XBMC compatible hardware that they want to remote control...
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on November 29, 2013, 04:58:49 pm
If that's the case, then:

* Yes, the IP Address device data needs to be there.
* Name isn't needed, because Orbiter will not swallow the instance.
* you'll want to make sure that the XBMC device translates not only public shares, but also user (private) shares.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 30, 2013, 01:11:07 am
Na XBMC not running on a MD, its totally other hardware.

I was thinking to use the mount in Device data, to send the configure share as at present I access LNMCE shares through SMB, NFS did not work, maybe this may changes, NFS may work, just wanted to have the option if required. This has to be manually entered, as there is currently no command in my understanding to get the mount points from XBMC or even set any.

Thanks for the pointers.
Title: Re: Best Approach to Controlling a Network Device
Post by: Marie.O on November 30, 2013, 12:06:23 pm
If XBMC's api allows the definition of a media file using a URL like smb:// that should be usable.
Title: Re: Best Approach to Controlling a Network Device
Post by: golgoj4 on November 30, 2013, 05:28:36 pm
If XBMC's api allows the definition of a media file using a URL like smb:// that should be usable.

what about private media?
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on November 30, 2013, 09:36:11 pm
Questions

1: In the .cpp file, I see in the LTHDXDXS_Streaming.cpp, the following type of constructor is not there, should I remove the one generated for me
   a:The constructor when the class is created as an embedded instance within another stand-alone device
   b:Is this required pluto_pthread_mutex_t m_RokuMutex, seeing it in the implementation file, doing ,m_RokuMutex("roku") and the m_RokuMutex.Init(NULL)
2: In my xbmc.h and xbmc.cpp, I have to use the namespace DCE and put the class creation within.
3: Do I have to put anything in the constructor or simple do it in the GetConfig, where it says to put the initialization of your code there.
4: The Device Data, TCP address and TCP port, how or where do I get this value, is it string ServerAddress in the standalone constructore

See the 2 generated .h and .cpp files and the xbmc .h and .cpp files


Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on November 30, 2013, 09:43:51 pm
const2 can be safely removed later, leave it in for now until you finish development, if it is not being embedded within another device. You can follow the instructions to remove it.

Yes, the namespace DCE should be used. In any DCEgen derived code, this is automatically specified by the using namespace DCE;

The constructor should contain initialization for any member variables you intend to use within the class. This is to ensure that the variables are in a predictable state when they are referenced. (In C, an uninitialized variable is undefined, and could point to anything, this is dangerous; this is why member variables are often explicitly initialized in the constructor.)

4. 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.

-Thom

Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 02, 2013, 01:08:13 am
This is this section below?
Quote
/*
            AUTO-GENERATED SECTION
            Do not change the declarations
   */

   /*
         *****DATA***** accessors inherited from base class
   int DATA_Get_TCP_Port();
   string DATA_Get_TCP_Address();
   string DATA_Get_Mount_Point();

         *****EVENT***** accessors inherited from base class

Can I just call it as below for example

char url[100] = "http://%s:%d/jsonrpc";
char xbmc_url[100];
sprintf(xbmc_url,url,DATA_Get_TCP_Address(),DATA_Get_TCP_Port());
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 02, 2013, 02:23:25 am
Yup. :)

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 02, 2013, 12:23:47 pm
In the XBMC_MEDIA_CENTRE::GetConfig(), I see the following lines, is it that the functions DATA_* mentioned peviously, are only available after this GetConfig() is run?
Quote
// Put your code here to initialize the data in this class
   // The configuration parameters DATA_ are now populated

Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 02, 2013, 04:35:16 pm
They are available once the GetConfig from the base class is run. Specifically after the lines:

(this is from Hulu_Player, as an example):

Code: [Select]
  if (!Hulu_Player_Command::GetConfig ())
    return false;

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 02, 2013, 05:40:39 pm
Ok thanks

Another question
In below, the between the StreamID  and MediaURL, can I am assuming that the MediaURL will hold the file in my video/audio library, will this include a part or just the file name eg <Iron man.mkv>?
Quote
/** @brief COMMAND: #37 - Play Media */
   /** This command will instruct a Media Player to play a media stream identified by a media descriptor created by the "Create Media" command. */
      /** @param #29 PK_MediaType */
         /** The type of media */
      /** @param #41 StreamID */
         /** The media that we need to play. */
      /** @param #42 MediaPosition */
         /** The position at which we need to start playing. */
      /** @param #59 MediaURL */
         /** The file to play, or other media id.  The format is specific on the media type and the media player. */
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 02, 2013, 05:48:38 pm
That depends. You have some flexibility here.

One of the reasons we have seperate plugins and players for each smart media device we wish to control, is that we can figure out the best way to send a piece of media to its destination, and to send the appropriate commands to the player to be able to handle them.

(you do know you'll need to write a Plugin, as well as your device, right? It's not hard, and you can cut and paste a lot of code from existing plugins to help, but it does need to be done.)

MH Play Media is passed a URL as part of its command, from the controlling Orbiter.

What format this is in, depends on whether the file is local, or some other network resource (e.g. http)

If the file is from a disk that Pluto Storage Devices manages (this is a disk connected either via the core, a media director, or a networked file share over NFS or SMB), then the path is local, like this:

/home/public/data/videos/Some Disk [100]/Superbad.mp4

whereas something like http would be something like:

http://somemediaserver.com/blablabla.mp4

Your plugin will receive this, and it will become part of your MediaStream object in your plugin. You can then do whatever you need to do, to get your Player to handle them.

For example, Xine Plugin contains lots of logic to determine:

* Whether we are playing a "local" file
* Whether we are playing a "local" CD or DVD
* Whether we are playing a "remote" DVD in some other drive in the house
* Whether we need to stream this to multiple TVs in the house
etc.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 02, 2013, 10:30:04 pm
Testing some edits, trying to compile, how would I pass the following to compile command I see below, to link curl

Quote
-lcurl

What I am seeing when doing the make all

Quote
g++ -c -I.. -I../DCE -I/usr/include/mysql -DKDE_LMCE -DDEBUG -DTHREAD_LOG -DLOG_ALL_QUERIES  -Wall -fPIC -ggdb3  XBMC_MEDIA_CENTRE.cpp -o XBMC_MEDIA_CENTRE.o
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 02, 2013, 10:32:40 pm
There are a few places in the Makefile, check XTRALDLIBS for example.

Other ones you can use
SNRLDLIBS (this was once used by the build system, but has been made obsolete, it now functions like the XTRALDLIBS)
LDLIBS (this can also be used.)

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 02, 2013, 10:35:35 pm
Would the same apply for the xbmc.cpp file, as I am getting undefined reference
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 02, 2013, 10:40:01 pm
the Makefile would add this to the linking stage, where it's supposed to go.

Libraries aren't applied per .cpp source file, but are added in as part of the linking process at the end. This is indeed what the linking stage is: taking any unresolved symbols, and attaching on libraries with those missing symbols in an effort to resolve them. So long as you put -lcurl in the XTRALDFLAGS, it will add the library to the list of stuff to link into the final executable.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 02, 2013, 10:45:11 pm
Then I mess something up somewhere, this is just part of the error I am getting, I already linked curl see the compile options before the error
Quote
g++ -o XBMC_MEDIA_CENTRE Main.o XBMC_MEDIA_CENTRE.o ../Gen_Devices/XBMC_MEDIA_CENTREBase.o  -L../lib  -lmysqlclient_r -lcurl -lSerializeClass -lDCECommon -lPlutoUtils -lpthread

Error part I am getting

Quote
XBMC_MEDIA_CENTRE.o: In function `DCE::XBMC_MEDIA_CENTRE::CMD_Move_Right(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, DCE::Message*)':
/home/linuxmce/CodingWork/LINUXMCE/src/XBMC_MEDIA_CENTRE/XBMC_MEDIA_CENTRE.cpp:762: undefined reference to `DCE::xbmc::commandToXbmc(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/home/linuxmce/CodingWork/LINUXMCE/src/XBMC_MEDIA_CENTRE/XBMC_MEDIA_CENTRE.cpp:763: undefined reference to `DCE::xbmc::getCurlOutCome()'
/home/linuxmce/CodingWork/LINUXMCE/src/XBMC_MEDIA_CENTRE/XBMC_MEDIA_CENTRE.cpp:770: undefined reference to `DCE::xbmc::getCurlError()'
XBMC_MEDIA_CENTRE.o: In function `DCE::XBMC_MEDIA_CENTRE::CMD_Back_Prior_Menu(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, DCE::Message*)':
/home/linuxmce/CodingWork/LINUXMCE/src/XBMC_MEDIA_CENTRE/XBMC_MEDIA_CENTRE.cpp:799: undefined reference to `DCE::xbmc::commandToXbmc(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/home/linuxmce/CodingWork/LINUXMCE/src/XBMC_MEDIA_CENTRE/XBMC_MEDIA_CENTRE.cpp:800: undefined reference to `DCE::xbmc::getCurlOutCome()'
/home/linuxmce/CodingWork/LINUXMCE/src/XBMC_MEDIA_CENTRE/XBMC_MEDIA_CENTRE.cpp:807: undefined reference to `DCE::xbmc::getCurlError()'
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 02, 2013, 10:49:18 pm
Looks like you need to add your xbmc.cpp to the SOURCES= section of your makefile, so that gcc will compile it...or have you moved it into the XBMC_MEDIA_CENTER.cpp/.h files?

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 02, 2013, 10:49:58 pm
If you've already moved it, then you need to make sure your xbmc class is inside the namespace DCE { } declarations in the .h and .cpp respectively.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 02, 2013, 10:59:13 pm
I believe I did, see attached and the additional files

Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 03, 2013, 12:36:29 am
Got it to work, made an edit to below

Quote
sources = Main.cpp xbmc.cpp XBMC_MEDIA_CENTRE.cpp $(Gen_Dev_Files)

Got this, seems I have some warnings now, will look and see how to fix it

Quote
linuxmce@dcerouter:~/CodingWork/LINUXMCE/src/XBMC_MEDIA_CENTRE$ make all
Computing dependencies for xbmc.cpp done
g++ -c -I.. -I../DCE -I/usr/include/mysql -DKDE_LMCE -DDEBUG -DTHREAD_LOG -DLOG_ALL_QUERIES  -Wall -fPIC -ggdb3  xbmc.cpp -o xbmc.o
xbmc.cpp: In function ‘size_t DCE::m_writeDataXbmc(char*, size_t, size_t, void*)’:
xbmc.cpp:95: warning: comparison between signed and unsigned integer expressions
g++ -o XBMC_MEDIA_CENTRE 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 ../bin
./post_make.sh XBMC_MEDIA_CENTRE
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


Can I test the device without creating it in LNMCE?
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 03, 2013, 12:37:16 am
That warning is a common one, and should be okay.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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?
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 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
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 03, 2013, 03:21:55 am
What is your controlled via category in your device template ?

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 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
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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>
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 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
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 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.

Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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?
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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

Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 06, 2013, 11:16:04 pm
Ok. good so far, did you implement XbmcMediaStream ?

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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?
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 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
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 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
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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?
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 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
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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?
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 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
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 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
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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.

Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 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
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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?
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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?

Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 13, 2013, 11:29:57 pm
Yes, you'll need to assign it to a room.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia 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>

Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 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
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 14, 2013, 12:33:41 pm
Did two greps for XBMC and Xbmc from the log, see pastebinit below

grep Xbmc /var/log/pluto/DCERouter.log

http://pastebin.com/WQnuycZb

grep XBMC /var/log/pluto/DCERouter.log

http://pastebin.com/iJwgyB6V

Notice this while playing with the fastforward, jump buttons on orbitor, for the pause command, seems like a complaint

Quote
Received Message from 70 (Windows XP PC/tablet (Horiz) / Bedroomles) to 10 (Media Plu
g-in / Closet/Storage Space), type 1 id 41 Command:Change Playback Speed, retry none, parameters: <0x6a5b4b70>
08      12/14/13 7:26:29.332              Parameter 41(StreamID):  <0x6a5b4b70>
08      12/14/13 7:26:29.332              Parameter 43(MediaPlaybackSpeed): +2 <0x6a5b4b70>
08      12/14/13 7:26:31.166            Received Message from 70 (Windows XP PC/tablet (Horiz) / Bedroomles) to 10 (Media Plu
g-in / Closet/Storage Space), type 1 id 41 Command:Change Playback Speed, retry none, parameters: <0x6a5b4b70>
08      12/14/13 7:26:31.166              Parameter 41(StreamID):  <0x6a5b4b70>
08      12/14/13 7:26:31.166              Parameter 43(MediaPlaybackSpeed): -2 <0x6a5b4b70>
08      12/14/13 7:26:32.122            Received Message from 70 (Windows XP PC/tablet (Horiz) / Bedroomles) to 10 (Media Plu
g-in / Closet/Storage Space), type 1 id 41 Command:Change Playback Speed, retry none, parameters: <0x6a5b4b70>
08      12/14/13 7:26:32.122              Parameter 41(StreamID):  <0x6a5b4b70>
08      12/14/13 7:26:32.122              Parameter 43(MediaPlaybackSpeed): -2 <0x6a5b4b70>
08      12/14/13 7:26:33.697            Received Message from 70 (Windows XP PC/tablet (Horiz) / Bedroomles) to 10 (Media Plu
g-in / Closet/Storage Space), type 1 id 39 Command:Pause Media, retry none, parameters: <0x6a5b4b70>
08      12/14/13 7:26:33.697              Parameter 41(StreamID):  <0x6a5b4b70>
05      12/14/13 7:26:33.698            BoundRemote::UpdateOrbiter(): Updating object:  on device 21 with size of 19584 <0x867e1b70
>
05      12/14/13 7:26:33.698            BoundRemote::UpdateOrbiter(): Updating object: 2355 on device 70 with size of 19584 <0x867e
1b70>
05      12/14/13 7:26:33.698            BoundRemote::UpdateOrbiter(): Updating object: 2355 on device 73 with size of 19584 <0x867e
1b70>
08      12/14/13 7:26:33.698            Received Message from 10 (Media Plug-in / Closet/Storage Space) to 21 (OnScreen Orbit
er / Closet/Storage Space), type 1 id 242 Command:Set Now Playing, retry none, parameters: <0xa69f9b70>
08      12/14/13 7:26:33.698              Parameter 3(PK_DesignObj): 70,4964,47,140,224,230 <0xa69f9b70>
08      12/14/13 7:26:33.698              Parameter 5(Value To Assign): Xbmc <0xa69f9b70>
08      12/14/13 7:26:33.699              Parameter 9(Text):  <0xa69f9b70>
08      12/14/13 7:26:33.699              Parameter 29(PK_MediaType): 5 <0xa69f9b70>
08      12/14/13 7:26:33.699              Parameter 41(StreamID): 1006 <0xa69f9b70>
08      12/14/13 7:26:33.699              Parameter 48(Value): 0 <0xa69f9b70>
08      12/14/13 7:26:33.699              Parameter 50(Name):  <0xa69f9b70>
08      12/14/13 7:26:33.699              Parameter 103(List PK Device): 74,74,74,,0,1,0 <0xa69f9b70>
08      12/14/13 7:26:33.699              Parameter 120(Retransmit): 0 <0xa69f9b70>
08      12/14/13 7:26:33.699            Received Message from 0 (unknown / ) to 70 (Windows XP PC/tablet (Horiz) / Bedroomles), type 1 id 32 Command:
35;1mUpdate Object Image, retry none, parameters: <0xa69f9b70>
08      12/14/13 7:26:33.699              Parameter 3(PK_DesignObj): 2355 <0xa69f9b70>
08      12/14/13 7:26:33.699              Parameter 14(Type): jpg <0xa69f9b70>
08      12/14/13 7:26:33.699              Parameter 23(Disable Aspect Lock): 0 <0xa69f9b70>
08      12/14/13 7:26:33.699              Data Parm 19(Data): 19584 bytes <0xa69f9b70>
08      12/14/13 7:26:33.700            Received Message from 10 (unknown / ) to 70 (Windows XP PC/tablet (Horiz) / Bedroomles), type 1 id 242 Command
:Set Now Playing, retry none, parameters: <0xa69f9b70>

This is my register code

Quote
bool Xbmc_Plugin::Register()
//<-dceag-reg-e->
{
   LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"Starting Xbmc_Plugin::Register()");
  
   m_iPriority=DATA_Get_Priority();
  
   m_pMedia_Plugin=( Media_Plugin * ) m_pRouter->FindPluginByTemplate(DEVICETEMPLATE_Media_Plugin_CONST);
   m_pOrbiter_Plugin=( Orbiter_Plugin * ) m_pRouter->FindPluginByTemplate(DEVICETEMPLATE_Orbiter_Plugin_CONST);
   if( !m_pMedia_Plugin || !m_pOrbiter_Plugin )
    {
      LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"Cannot find sister plugins to Xbmc plugin");
      return false;
    }
  
   vector<int> vectPK_DeviceTemplate;
   vectPK_DeviceTemplate.push_back(DEVICETEMPLATE_XBMC_MEDIA_CENTRE_CONST);
   m_pMedia_Plugin->RegisterMediaPlugin( this, this, vectPK_DeviceTemplate, true );
  
   LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"Registered device %d",DEVICETEMPLATE_XBMC_MEDIA_CENTRE_CONST);
  
   RegisterMsgInterceptor(( MessageInterceptorFn )( &Xbmc_Plugin::MenuOnScreen ), 0, 0, 0, 0, MESSAGETYPE_EVENT, EVENT_Menu_Onscreen_CONST );
  
   return Connect(PK_DeviceTemplate_get());
}
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 14, 2013, 01:56:04 pm
Also did some more digging, made it my device similar with Xine Player, see  code attached.

Jump position works, speed does not seem to be sent

Quote
b1b70>
Need to implement command #65 - Jump Position In Playlist
Parm #5 - Value_To_Assign=-1
Parm #41 - StreamID=1010
Need to implement command #65 - Jump Position In Playlist
Parm #5 - Value_To_Assign=+1
Parm #41 - StreamID=1010


See also code attached and template

Also noticed, speed change and pause, is being sent to the Media Plugin, is this normal?

Do have no function in my plugin for pause and speed
Title: Re: Best Approach to Controlling a Network Device
Post by: Marie.O on December 14, 2013, 07:26:11 pm
Did two greps for XBMC and Xbmc from the log, see pastebinit below

grep Xbmc /var/log/pluto/DCERouter.log

http://pastebin.com/WQnuycZb

grep XBMC /var/log/pluto/DCERouter.log

http://pastebin.com/iJwgyB6V

in case you don't know, grep accepts -i for ignoring case.
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 15, 2013, 02:31:57 am
posde thanks

tschak909

I made some change to the xbmc device template, adding the plugin as a related device.

Created another device, switched it to manual config and assigned to a room, all plays well now. I noticed once I have more than one file in the orbitor list, the Jump Position In Playlist does not get sent to the device, but actual goes through the playlist, which plays each file fine.

The speed and pause, simple gets sent to media plugin, i see no calling command on my device, even took out code, so I can get the output when not configured, no luck yet with these.

The only thing missing from Xine is keyboard stuff, IP and inherits mac, would this be my issue?
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 15, 2013, 06:44:01 pm
TSCHAK909
When I hit pause, I am only seeing this when I grep of xbmc, for jump position etc, you see the command
Once
Quote
Parameter 5(Value To Assign): Xbmc <0xa73f7b70>
08      12/15/13 12:34:21.360           Received Message from 0 (unknown / ) to 83 (xbmc test / Living Room), type 1 id 92 Command:Pause, retry none, parameters: <0x4d7dfb70>
08      12/15/13 12:45:21.882           Received Message from 0 (unknown / ) to 83 (xbmc test / Living Room), type 1 id 92 Command:Pause, retry none, parameters: <0x4d7dfb70>
And on subsequent retries just below
Quote
08      12/15/13 13:33:20.496             Parameter 5(Value To Assign): Xbmc <0xa69f7b70>

I have changed the template, adding IP controlled and control categories such as Standard Orbitor, Specialized and infrared interface. I have also removed controlled by computer and select IP based, see template attached.

Have not configured any events, am assuming this is for Xine sending an event.

I put some prompts in the plugin, and realized that following chunk of code is not running, put in the Xbmc_Plugin so it would show up when I grep, also did a grep for looking, this is in my StartMedia.

Quote
for( MapEntertainArea::iterator itEA = pXbmcMediaStream->m_mapEntertainArea.begin( );itEA != pXbmcMediaStream->m_mapEntertainArea.end( );++itEA )
   {
      EntertainArea *pEntertainArea = ( *itEA ).second;
      LoggerWrapper::GetInstance()->Write( LV_STATUS, "Looking from Xbmc_Plugin into the ent area (%p) with id %d and %d remotes", pEntertainArea, pEntertainArea->m_iPK_EntertainArea, (int) pEntertainArea->m_mapBoundRemote.size() );
        for(map<int,OH_Orbiter *>::iterator it=m_pOrbiter_Plugin->m_mapOH_Orbiter.begin();it!=m_pOrbiter_Plugin->m_mapOH_Orbiter.end();++it)
        {
            OH_Orbiter *pOH_Orbiter = (*it).second;
         if( pOH_Orbiter->m_pEntertainArea!=pEntertainArea )
            continue;
         LoggerWrapper::GetInstance()->Write(LV_STATUS, "Processing from Xbmc_Plugin remote: for orbiter: %d", pOH_Orbiter->m_pDeviceData_Router->m_dwPK_Device);
         bool bBound = pEntertainArea->m_mapBoundRemote.find(pOH_Orbiter->m_pDeviceData_Router->m_dwPK_Device)!=pEntertainArea->m_mapBoundRemote.end();
         pXbmcMediaStream->SetNowPlaying(pOH_Orbiter,false,bBound);
      }
   }

Any pointers welcomed
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 17, 2013, 12:16:44 am
I have added some events to the template, in an effort to see if this was needed as Xine sets this at a point.

Quote
EVENT_Playback_Started(sMediaURL,iStreamID,"","","");
      //EVENT_Menu_Onscreen(int iStream_ID,bool bOnOff);
      EVENT_Menu_Onscreen(iStreamID,onoff);

The EVENT_Menu.. is causing a CMD_Set_Media_ID to be called within my template, I went ahead and set it to register the streamID, as below, as I was assuming that one of the reason the pause of fast forward did not work is there is no streamID showing in DCERouter.log

Quote
DCE::CMD_Set_Media_ID cmd(m_dwPK_Device,DEVICETEMPLATE_General_Info_Plugin_CONST,sID,iStreamID);
   SendCommand(cmd);

I had already register within the Plugin, so it might have been a long shot
Quote
DCE::CMD_Set_Media_ID CMD_Set_Media_ID(m_dwPK_Device, pMediaStream->m_pMediaDevice_Source->m_pDeviceData_Router->m_dwPK_Device, sMediaID, pXbmcMediaStream->m_iStreamID_get());
    SendCommand(CMD_Set_Media_ID);

Also I noticed, the room which I assigned the device, when I fire off volume up, down or mute, nothing happens on the tv, which works in another room, slightly different name with the cable box.

So far no luck

Changes to the device template attached

Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 17, 2013, 04:15:28 am
I'll be able to look soon, sorry I've been away, I've been trying to get an OpenStack cluster test working for work.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 17, 2013, 11:17:41 pm
Appreciate it.
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 27, 2013, 06:34:50 pm
TSCHAK909

Any luck?

Anything additional required?
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on December 27, 2013, 08:45:24 pm
Sorry, will be able to soon after the New Year, i've been knee deep in this OpenStack cluster, and trying spend time with my new family...

Have you been experimenting and looking over the other media player devices?

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on December 28, 2013, 01:05:07 am
That is quiet expected, its christmas, my boys kept me busy, they still believe in Santa, that's their grandma doing.

Initially I thought well the device was not registering, so I went through and change a lot of the LV_STATUS or LV_WARNING TO LV_CRITICAL in the loggerWrapper calls, as I was uncertain where it logs after not finding (/var/log/pluto/83_XBMC_MEDIA_CENTRE.log) thus sent everything to DCERouter.log for testing purposes, to see what was happening.

On realize it does seem to do what it supposed to do, I went ahead and changed the controlled by as in Xine, template attached, adding all that Xine had.

Then I thought the streamId was not being set, as when you pressed, lets say pause, it did not show a streamId in the DCERouter.log, but skip position worked and showed a streamID, so I did the following in the plugin, right after the call command to play

Quote
DCE::CMD_Set_Media_ID CMD_Set_Media_ID(m_dwPK_Device, pMediaStream->m_pMediaDevice_Source->m_pDeviceData_Router->m_dwPK_Device, sMediaID, pXbmcMediaStream->m_iStreamID_get());
    SendCommand(CMD_Set_Media_ID);

Then I added the events as Xine to the device, which I initially thought were not needed, such as playback started, playback stopped, Media Position Changed, and Menu Onscreen and fired off in the device play command as below

Quote
EVENT_Playback_Started(sMediaURL,iStreamID,"","","");
bool onoff;
EVENT_Menu_Onscreen(iStreamID,onoff);

I then implemented the CMD_Restart_Media media function as found documentation saying it supposed to work with pause, also implemented CMD_Pause, just calling CMD_Pause_Media(0)

Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on January 03, 2014, 01:17:03 pm
TSCHAK909

I noticed something last night.

As I had adjusted the device pipes to hook to a tv in a room, the system when a movie starts, would turn the tv on and when I stop the movie, will turn the tv off.

Unfortunately, the volume up, down or mute from the orbitor, does not get sent to the TV device, it just reaches the Media Plugin, this only happens for this XBMC device attached to the TV in this room (dummy room used for testing), the cable box attached to the same tv, in another room works fine, with volume commands.

Now I am assuming its because of the type of device I created, easy to assume, LOL, but not sure how to fix this.

Also the XBMC device template, can only be used in creating a device, child of the core, cannot use it to create an A/V equipment device, is this normally?

The difference between it and the roku_telnet, is the roku telnet using a generic serial package, the XBMC device template does not.

Regards
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on January 06, 2014, 11:25:37 pm
Went back through the Hulu and Pandora Plugin, looking to see what I missed, found something in the CreateMediaStream, where the stream ID is supposed to be assigned, but did not help, see what I missed
Quote
m_mapDevicesToStreams[pMediaDevice->m_pDeviceData_Router->m_dwPK_Device] = StreamID;

This is an excerpt from DCERouter.log, where you see
Quote
Parameter 5(Value To Assign): Xbmc <0xa6ff7b70>
is when I press pause and fast forward.
Quote
grep -i xbmc DCERouter.log
05      01/06/14 17:59:44.153           Loaded plug-in device: 81 master device: 2245 -- ./Xbmc_Plugin.so <0xb77238e0>
01      01/06/14 17:59:47.214           Starting Xbmc_Plugin::Register() <0xb77238e0>
01      01/06/14 17:59:47.215           Registered in Xbmc_Plugin device 2244 <0xb77238e0>
01      01/06/14 18:00:08.900           Returning this device 83 (xbmc test) <0x863deb70>
01      01/06/14 18:00:08.909           StartMedia Called Xbmc_Plugin <0x863deb70>
01      01/06/14 18:00:08.909           Xbmc_Plugin::StartMedia() Starting media stream playback. pos: 0 <0x863deb70>
01      01/06/14 18:00:08.909           Xbmc_Plugin::StartMedia() Media type 5 /home/public/data/videos/2.73 TB_sdb1_WDC_WD30EFRX-68 [71]/tv_shows/exercise/Shaun T Insanity/05 - Pure Cardio & Cardio Abs.avi <0x863deb70>
01      01/06/14 18:00:08.909           Looking from Xbmc_Plugin into the ent area (0xa5a01890) with id 4 and 0 remotes <0x863deb70>
01      01/06/14 18:00:08.909           Processing from Xbmc_Plugin remote: for orbiter: 70 <0x863deb70>
08      01/06/14 18:00:08.910           Received Message from 81 (Xbmc Plug-in / Closet/Storage Space) to 83 (xbmc test / Living Room), type 1 id 37 Command:Play Media, retry none, parameters: <0x95df7b70>
08      01/06/14 18:00:08.910             Parameter 5(Value To Assign): Xbmc <0xa6ff7b70>
08      01/06/14 18:00:08.910           Received Message from 10 (Media Plug-in / Closet/Storage Space) to 83 (xbmc test / Living Room), type 1 id 192 Command:On, retry none, parameters: <0xa6ff7b70>
08      01/06/14 18:00:08.912             Parameter 5(Value To Assign): Xbmc <0xa6ff7b70>
08      01/06/14 18:00:26.434             Parameter 5(Value To Assign): Xbmc <0xa6ff7b70>
08      01/06/14 18:00:38.802             Parameter 5(Value To Assign): Xbmc <0xa6ff7b70>
08      01/06/14 18:00:48.318             Parameter 5(Value To Assign): Xbmc <0xa6ff7b70>
08      01/06/14 18:01:04.776             Parameter 5(Value To Assign): Xbmc <0xa6ff7b70>
08      01/06/14 18:01:07.995           Received Message from 70 (Windows XP PC/tablet (Horiz) / Bedroomles) to 83 (xbmc test / Living Room), type 1 id 65 Command:Jump Position In Playlist, retry none, parameters: <0xa6ff7b70>
08      01/06/14 18:01:10.578           Received Message from 70 (Windows XP PC/tablet (Horiz) / Bedroomles) to 83 (xbmc test / Living Room), type 1 id 65 Command:Jump Position In Playlist, retry none, parameters: <0xa6ff7b70>
08      01/06/14 18:02:17.469             Parameter 5(Value To Assign): Xbmc <0xa6ff7b70>
08      01/06/14 18:02:20.881             Parameter 5(Value To Assign): Xbmc <0xa6ff7b70>
08      01/06/14 18:02:25.433             Parameter 5(Value To Assign): Xbmc <0xa6ff7b70>
08      01/06/14 18:03:22.101             Parameter 5(Value To Assign): Xbmc <0xa6ff7b70>
08      01/06/14 18:04:12.961           Received Message from 81 (Xbmc Plug-in / Closet/Storage Space) to 83 (xbmc test / Living Room), type 1 id 38 Command:Stop Media, retry none, parameters: <0x953f6b70>
08      01/06/14 18:04:14.142           Received Message from 10 (Media Plug-in / Closet/Storage Space) to 83 (xbmc test / Living Room), type 1 id 193 Command:Off, retry none, parameters: <0xa6ff7b70>

I have attached the Plugin Code
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on January 07, 2014, 01:22:54 am
Would this be normal, the 0 remotes, the rest is for context

Quote
StartMedia Called Xbmc_Plugin <0x863deb70>
01      01/06/14 18:00:08.909           Xbmc_Plugin::StartMedia() Starting media stream playback. pos: 0 <0x863deb70>
01      01/06/14 18:00:08.909           Xbmc_Plugin::StartMedia() Media type 5 /home/public/data/videos/2.73 TB_sdb1_WDC_WD30EFRX-68 [71]/tv_shows/exercise/Shaun T Insanity/05 - Pure Cardio & Cardio Abs.avi <0x863deb70>
01      01/06/14 18:00:08.909           Looking from Xbmc_Plugin into the ent area (0xa5a01890) with id 4 and 0 remotes <0x863deb70>
01      01/06/14 18:00:08.909           Processing from Xbmc_Plugin remote: for orbiter: 70 <0x863deb70>
08      01/06/14 18:00:08.910           Received Message from 81 (Xbmc Plug-in / Closet/Storage Space) to 83 (xbmc test / Living Room), type 1 id 37 Command:Play Media, retry none, parameters: <0x95df7b70>
08      01/06/14 18:00:08.910             Parameter 5(Value To Assign): Xbmc <0xa6ff7b70>
Title: Re: Best Approach to Controlling a Network Device
Post by: tschak909 on January 07, 2014, 01:26:47 am
I'll be able to look at it soon, sorry, I've been consumed with needing to take care of work, and a wife/daughter...It has to be something _really_ simple.

-Thom
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on February 19, 2014, 06:33:49 pm
tschak909

By chance any luck
Title: Re: Best Approach to Controlling a Network Device
Post by: jamo on February 25, 2014, 08:03:23 pm
CentralMedia - get hold of Thom in IRC if you can. He's still super busy at work but if I'm not mistaken the forums aren't notifying everyone (at least not notifying me) of posts on threads they've contributed to at the moment so he may not be watching this.

It would be sad to see this one die when it seems so close and I'm pretty sure Thom is the one who can help.

James
Title: Re: Best Approach to Controlling a Network Device
Post by: bugui on November 24, 2015, 07:48:41 am
Hi CentralMedia,
Did you get it work, I would like to use kodi to play some media and I like to know if you had this working with lmce.
Thanks in advance,
Hernan
Title: Re: Best Approach to Controlling a Network Device
Post by: CentralMedia on January 03, 2016, 11:16:49 pm
I am revisiting in the next two (2) weeks, I was away on commitments and then my core crashed had to rebuild.

Starting over on 1204.