Native Player  1.0
native_player.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_NATIVE_PLAYER_H_
29 #define NATIVE_PLAYER_INC_NATIVE_PLAYER_H_
30 
31 #include <memory>
32 
33 #include "ppapi/c/pp_rect.h"
34 #include "ppapi/cpp/instance.h"
35 #include "ppapi/cpp/module.h"
36 #include "ppapi/cpp/var_dictionary.h"
37 #include "ppapi/utility/threading/simple_thread.h"
38 
41 #include "player/player_provider.h"
42 
43 
47 
48 class NativePlayer : public pp::Instance {
49  public:
52  explicit NativePlayer(PP_Instance instance)
53  : pp::Instance(instance), player_thread_(this) {}
54 
57  ~NativePlayer() override;
58 
62  void DidChangeView(const pp::View& view) override;
63 
69  void HandleMessage(const pp::Var& var_message) override;
70 
73  bool Init(uint32_t, const char**, const char**) override;
74 
75  private:
77  void InitNaClIO();
78 
79  std::shared_ptr<Communication::MessageReceiver> message_receiver_;
80  pp::SimpleThread player_thread_;
81  pp::Rect rect_;
82 };
83 
85 class NativePlayerModule : public pp::Module {
86  public:
87  pp::Instance* CreateInstance(PP_Instance instance) override {
88  return new NativePlayer(instance);
89  }
90 };
91 
94 namespace pp {
95 Module* CreateModule() { return new NativePlayerModule(); }
96 }
97 
98 #endif // NATIVE_PLAYER_INC_NATIVE_PLAYER_H_
NativePlayerModule creation.
Definition: native_player.h:85
pp::Instance * CreateInstance(PP_Instance instance) override
Definition: native_player.h:87
This file defines MessageReceiver class.
NativePlayer(PP_Instance instance)
Definition: native_player.h:52
void HandleMessage(const pp::Var &var_message) override
bool Init(uint32_t, const char **, const char **) override
void DidChangeView(const pp::View &view) override
This file defines a MessageSender class.
Module * CreateModule()
Definition: native_player.h:95
This file defines PlayerProvider class.