Native Player  1.0
message_receiver.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // Copyright (c) 2016, Samsung Electronics Co., Ltd
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
20 // , OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 //
23 // @author Tomasz Borkowski
24 // Michal Murgrabia
25 //
26 // ----------------------------------------------------------------------------
27 
28 #ifndef NATIVE_PLAYER_INC_COMMUNICATOR_MESSAGE_RECEIVER_H_
29 #define NATIVE_PLAYER_INC_COMMUNICATOR_MESSAGE_RECEIVER_H_
30 
31 #include "ppapi/cpp/var.h"
32 #include "ppapi/cpp/instance_handle.h"
33 #include "ppapi/cpp/message_handler.h"
34 
36 #include "player/player_provider.h"
37 
40 
41 namespace Communication {
42 
58 
59 class MessageReceiver : public pp::MessageHandler {
60  public:
66  explicit MessageReceiver(std::shared_ptr<PlayerProvider> player_provider)
67  : player_provider_(std::move(player_provider)) {}
68 
72 
85  void HandleMessage(pp::InstanceHandle instance,
86  const pp::Var& message_data) override;
87 
96  pp::Var HandleBlockingMessage(pp::InstanceHandle instance,
97  const pp::Var& message_data) override;
98 
104  void WasUnregistered(pp::InstanceHandle instance) override {}
105 
106  private:
121  void ChangeRepresentation(const pp::Var& type, const pp::Var& id);
122 
128  void ClosePlayer();
129 
148  void LoadMedia(const pp::Var& type, const pp::Var& url,
149  const pp::Var& subtitle, const pp::Var& encoding);
150 
156  void Pause();
157 
163  void Play();
164 
175  void Seek(const pp::Var& time);
176 
192  void ChangeViewRect(const pp::Var& x_position, const pp::Var& y_position,
193  const pp::Var& width, const pp::Var& height);
194 
204  void ChangeSubtitlesRepresentation(const pp::Var& id);
205 
213 
214  std::shared_ptr<PlayerController> player_controller_;
215  std::shared_ptr<PlayerProvider> player_provider_;
216  Samsung::NaClPlayer::Rect view_rect_;
217 };
218 
219 } // namespace Communication
220 
221 #endif // NATIVE_PLAYER_INC_COMMUNICATOR_MESSAGE_RECEIVER_H_
void ChangeSubtitlesRepresentation(const pp::Var &id)
This file defines the PlayerController class.
void Seek(const pp::Var &time)
MessageReceiver(std::shared_ptr< PlayerProvider > player_provider)
pp::Var HandleBlockingMessage(pp::InstanceHandle instance, const pp::Var &message_data) override
void HandleMessage(pp::InstanceHandle instance, const pp::Var &message_data) override
Main class responsible for handling messages from the communication channel and controlling player li...
void ChangeViewRect(const pp::Var &x_position, const pp::Var &y_position, const pp::Var &width, const pp::Var &height)
void LoadMedia(const pp::Var &type, const pp::Var &url, const pp::Var &subtitle, const pp::Var &encoding)
void ChangeRepresentation(const pp::Var &type, const pp::Var &id)
This file defines PlayerProvider class.
void WasUnregistered(pp::InstanceHandle instance) override