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

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #45 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());

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #46 on: December 02, 2013, 02:23:25 am »
Yup. :)

-Thom

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #47 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


tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #48 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

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #49 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. */

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #50 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

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #51 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

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #52 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

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #53 on: December 02, 2013, 10:35:35 pm »
Would the same apply for the xbmc.cpp file, as I am getting undefined reference

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #54 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

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #55 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()'

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #56 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

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #57 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

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #58 on: December 02, 2013, 10:59:13 pm »
I believe I did, see attached and the additional files

« Last Edit: December 02, 2013, 11:11:07 pm by CentralMedia »

CentralMedia

  • Guru
  • ****
  • Posts: 161
    • View Profile
Re: Best Approach to Controlling a Network Device
« Reply #59 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?
« Last Edit: December 03, 2013, 12:40:04 am by CentralMedia »