Native Player  1.0
Communication::MessageReceiver Class Reference

Main class responsible for handling messages from the communication channel and controlling player life cycle. More...

#include <message_receiver.h>

Inheritance diagram for Communication::MessageReceiver:

Public Member Functions

 MessageReceiver (std::shared_ptr< PlayerProvider > player_provider)
 
 ~MessageReceiver ()
 
void HandleMessage (pp::InstanceHandle instance, const pp::Var &message_data) override
 
pp::Var HandleBlockingMessage (pp::InstanceHandle instance, const pp::Var &message_data) override
 
void WasUnregistered (pp::InstanceHandle instance) override
 
void ChangeRepresentation (const pp::Var &type, const pp::Var &id)
 
void ClosePlayer ()
 
void LoadMedia (const pp::Var &type, const pp::Var &url, const pp::Var &subtitle, const pp::Var &encoding)
 
void Pause ()
 
void Play ()
 
void Seek (const pp::Var &time)
 
void ChangeViewRect (const pp::Var &x_position, const pp::Var &y_position, const pp::Var &width, const pp::Var &height)
 
void ChangeSubtitlesRepresentation (const pp::Var &id)
 
void ChangeSubtitlesVisibility ()
 

Detailed Description

Main class responsible for handling messages from the communication channel and controlling player life cycle.

MessageReceiver is designed to receive messages from the communication channel and perform proper actions. It accepts only VarDictionary messages, which must contain a key named kKeyMessageToPlayer and have a value defined by the enum MessageToPlayer. Basing on this value MessageReceiver performs a proper action on the player.

See also
Communication Description of the Communication namespace provides a brief of the communication mechanism.
kKeyMessageToPlayer
MessageToPlayer

Definition at line 59 of file message_receiver.h.

Constructor & Destructor Documentation

Communication::MessageReceiver::MessageReceiver ( std::shared_ptr< PlayerProvider player_provider)
inlineexplicit

Creates a MessageReceiver object instance.

Parameters
[in]player_providerA factory object which is used to get player controller which fits the needs.
See also
PlayerProvider

Definition at line 66 of file message_receiver.h.

Communication::MessageReceiver::~MessageReceiver ( )
inline

Destroys the MessageReceiver object and frees all allocated resources.

Definition at line 71 of file message_receiver.h.

Member Function Documentation

void Communication::MessageReceiver::ChangeRepresentation ( const pp::Var &  type,
const pp::Var &  id 
)

Validates a kChangeRepresentation message, decodes provided parameters and requests the player to change the defined representation from the current one to the specified one. The request will be ignored if the content is not loaded.

Parameters
[in]typeA type of the stream which is requested to be changed, Video = 0 or Audio = 1. This Var is cast to a StreamType and it has to be an integer value.
[in]idAn id of a representation which should be used. This Var has to be an integer value.
See also
kChangeRepresentation.
StreamType
void Communication::MessageReceiver::ChangeSubtitlesRepresentation ( const pp::Var &  id)

Handles a kChangeSubtitlesRepresentation message, validates a provided parameter and requests the player to change subtitle strack to a defined one. The request will be ignored if the content is not loaded.

Parameters
[in]idAn ID of subtitles which need to be used. This Var has to be an int type.
See also
kChangeSubtitlesRepresentation
void Communication::MessageReceiver::ChangeSubtitlesVisibility ( )

Method which handles a kChangeSubtitlesVisibility message and disables or enables generating subtitle events, depending on previous state. The request will be ignored if the content is not loaded.

See also
kChangeSubtitlesVisibility
void Communication::MessageReceiver::ChangeViewRect ( const pp::Var &  x_position,
const pp::Var &  y_position,
const pp::Var &  width,
const pp::Var &  height 
)

Handles a kChangeViewRect message, validates provided parameters and informs the player about new position and resolution of plugin window. If the player is not initialized then parameters will be provided during initialization.

Parameters
[in]x_positionAn x position of the plugin left upper corner; should be expressed by an integer value.
[in]y_positionA y position of the plugin left upper corner; should be expressed by an integer value.
[in]widthA width of the plugin window; should be expressed by an integer value.
[in]heightA height of the plugin window; should be expressed by an integer value.
See also
kChangeViewRect
void Communication::MessageReceiver::ClosePlayer ( )

Handles a kClosePlayer message, closes the player and frees resources.

See also
kClosePlayer
pp::Var Communication::MessageReceiver::HandleBlockingMessage ( pp::InstanceHandle  instance,
const pp::Var &  message_data 
)
override

Handles synchronous messages. Such way of communication is not used in this application. Method sends a received message as a replay message.

Parameters
[in]instanceA handle to a plugin instance to which the message was addressed. The Value is provided automatically by NaCl engine.
[in]message_dataA container with message.
Returns
Var object which is send back as a replay message.
void Communication::MessageReceiver::HandleMessage ( pp::InstanceHandle  instance,
const pp::Var &  message_data 
)
override

Handles asynchronous messages from the communication channel. This method performs an action selected basing on a value mapped by the kKeyMessageToPlayer key contained within message_data dictionary.

Parameters
[in]instanceA handle to a plugin instance to which a message was addressed. This value is provided automatically by the NaCl engine and is not used in this application.
[in]message_dataA container with a message, it is expected that the message is VarDictionary.
See also
kKeyMessageToPlayer
MessageToPlayer
void Communication::MessageReceiver::LoadMedia ( const pp::Var &  type,
const pp::Var &  url,
const pp::Var &  subtitle,
const pp::Var &  encoding 
)

Validates a kLoadMedia message, decodes provided parameters and creates a player that can handle a given type of the multimedia content.

Parameters
[in]typeA type of a content which needs to be loaded. This Var is casted to ClipTypeEnum and it has to be an integer value.
[in]urlAn URL to a content container, it could point to different types of files depending on the player type. This Var has to be a string type value.
[in]subtitleAn URL to the file with external subtitles. It is an optional parameter, but if provided it has to be a string type value.
[in]encodingA subtitle encoding code. It is an optional parameter, which has to be a string type value.
See also
kLoadMedia
ClipTypeEnum
void Communication::MessageReceiver::Pause ( )

Handles a kPause message, and requests the player to pause. The request will be ignored if the content is not loaded.

See also
kPause
void Communication::MessageReceiver::Play ( )

Handles a kPlay message, and requests the player to start play. The request will be ignored if the content is not loaded.

See also
kPlay
void Communication::MessageReceiver::Seek ( const pp::Var &  time)

Handles a kSeek message, validates a provided parameter and requests the player to change current playback time to the defined one. The request will be ignored if the content is not loaded.

Parameters
[in]timeTime from which playback should continue when seek operation completes. This value is cast to TimeTick and it has to be a floating point value.
See also
kSeek
TimeTick
void Communication::MessageReceiver::WasUnregistered ( pp::InstanceHandle  instance)
inlineoverride

Informs MessageReceiver object that it was unregistered from receiving messages. After this, no more calls will be made to this object.

Parameters
[in]instanceA handle to a plugin instance from which receiving list object has been removed.

Definition at line 104 of file message_receiver.h.


The documentation for this class was generated from the following file: