Previous articles mainly from the theory of the DLNA and UPnP protocol related concepts and knowledge points, this article mainly introduces the Platinumkit library, the library implements the UPnP protocol stack, the code is very beautiful, but the document is not many, So I hope that my introduction and guidance can help beginners to master the application of the library more quickly.
1. Platinumkit Library's official website
http://www.plutinosoft.com/platinum/
2. Features of the Platinumkit library
(1) written by C + +
(2) Support Windows, Mac OSX, Linux, IPhone, Android
(3) code is very beautiful, is self-explanatory, combined with the UPnP protocol document is easy to read
(4) The sample is rich and implements a variety of UPnP device examples, including: Mediarenderer,mediaserver,media control Point,light control and so on.
3. Main interface of Platinumkit Library
(1) Plt_upnp
This is the most important interface of the Platinumkit library, which is used to maintain one or more UPnP devices (device) or control point, the main interface is as follows:
Npt_result AddDevice (plt_devicehostreference& device); Npt_result addctrlpoint (plt_ctrlpointreference& ctrlpoint); Npt_result Removedevice (plt_devicehostreference& device); Npt_result removectrlpoint (plt_ctrlpointreference& ctrlpoint); Npt_result Start (); Npt_result Stop ();
(2) Plt_devicehost
This class represents UPnP devices that encapsulate the various properties and actions contained in UPnP devices, such as device description, UUID, etc., including: Broadcast device information and service information, feedback device event messages, and so on.
All custom UPnP devices need to inherit the Plt_devicehost class and implement a specific method based on the protocol.
(3) Plt_ctrlpoint
This class represents the control point for UPnP, encapsulating the various actions contained by the UPnP control points, such as searching for UPnP devices, executing the service provided by the device, subscribing to device event messages, and so on.
This class provides messages such as device additions/deletions/events through the Plt_ctrlpointlistener class:
Class Plt_ctrlpointlistener{public:virtual ~plt_ctrlpointlistener () {} virtual Npt_result ondeviceadded (PLT_DeviceD atareference& device) = 0; Virtual Npt_result ondeviceremoved (plt_devicedatareference& device) = 0; Virtual Npt_result onactionresponse (npt_result res, plt_actionreference& action, void* userdata) = 0; Virtual Npt_result oneventnotify (plt_service* Service, npt_list<plt_statevariable*>* VARs) = 0;};
In addition, the Plt_ctrlpoint class provides the following main interfaces:
Find device: Search,discover,
Call Service: Findactiondesc,createaction,invokeaction
Subscription Event: Subscribe
(4) Plt_service
This class represents the UPnP service, encapsulates the various properties and actions contained by the UPnP control points, attributes such as service name, service type, and so on, mainly including modifying/fetching state variables, finding actions, and so on.
The usual functions are as follows:
plt_statevariable* findstatevariable (const char* name); plt_actiondesc* Findactiondesc (const char* name); Npt_result setstatevariable (const char* name, const char* value); Npt_result getstatevariablevalue (const char* name, npt_string& value);
4. Sample Code
The Platinumkit Library has a wealth of sample code that you can refer to to learn how to implement a simple UPnP device, how to control the device and invoke the device service.
(1) UPnP AV Device sample
Platinumkit Library implements 2 UPnP AV devices, MediaRenderer and MediaServer, which is a very good code for learning DLNA/UPNP AV devices, recommended to read carefully. The code is located at:
platinumkit/platinum/source/devices/
(2) Control Point Example
The Platinumkit Library implements a command-line interface-based media controller called: Micromediacontroller, which is a very good code for learning about the UPnP control point component, and it is recommended to read it carefully. The code is located at:
platinumkit/platinum/source/apps/
(3) Other UPnP device examples
Platinumkit Library also implements a number of other UPnP devices, including: simple devices, light control equipment, etc., can also refer to learning, code is located in:
platinumkit/platinum/source/apps/platinumkit/platinum/source/tests/
5. Summary
About the Platinumkit library is introduced here, I hope you can quickly use the library to implement their own DLNA&UPNP application, have any questions welcome message (This address: here) or letter [email protected] exchange.
This article is from the "Shadow Three People" blog, please be sure to keep this source http://ticktick.blog.51cto.com/823160/1639925
DLNA&UPNP Development Notes (4)-platinumkit Library Introduction