RDK Documentation (Open Sourced RDK Components)
jsbindings.h
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2018 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 #ifndef __JSBINDINGS_H__
21 #define __JSBINDINGS_H__
22 
23 #include <JavaScriptCore/JavaScript.h>
24 #include "main_aamp.h"
25 #include <map>
26 /*
27  * @file jsbindings.h
28  * @brief APIs exposed by the AAMP JS to inject different bindings.
29  */
30 
31 /**
32  * @struct PrivAAMPStruct_JS
33  * @brief Private data structure for JS binding object
34  */
36  PrivAAMPStruct_JS() : _ctx(), _aamp(NULL), _listeners()
37  {
38  }
39  virtual ~PrivAAMPStruct_JS()
40  {
41  }
42  PrivAAMPStruct_JS(const PrivAAMPStruct_JS&) = delete;
43  PrivAAMPStruct_JS& operator=(const PrivAAMPStruct_JS&) = delete;
44 
45  virtual JSObjectRef getCallbackForAdId(std::string id) { return NULL; }
46  virtual void removeCallbackForAdId(std::string id) { }
47 
48  JSGlobalContextRef _ctx;
49  PlayerInstanceAAMP* _aamp;
50 
51  std::multimap<AAMPEventType, void*> _listeners;
52 };
53 
54 /**
55  * @fn aamp_LoadJS
56  *
57  * @param[in] context - JS Core context.
58  * @param[in] playerInstanceAAMP - AAMP instance. NULL creates new aamp instance.
59  */
60 void aamp_LoadJS(void* context, void* playerInstanceAAMP);
61 
62 /**
63  * @fn aamp_UnloadJS
64  *
65  * @param[in] context - JS Core context.
66  */
67 void aamp_UnloadJS(void* context);
68 
69 /**
70  * @brief Loads AAMPMediaPlayer JS constructor into JS context
71  *
72  * @param[in] context JS execution context
73  */
74 void AAMPPlayer_LoadJS(void* context);
75 
76 /**
77  * @brief Removes the AAMPMediaPlayer constructor from JS context
78  *
79  * @param[in] context JS execution context
80  */
81 void AAMPPlayer_UnloadJS(void* context);
82 
83 #endif// __JSBINDINGS_H__
main_aamp.h
Types and APIs exposed by the AAMP player.
aamp_UnloadJS
void aamp_UnloadJS(void *context)
Unload aamp JS bindings.
Definition: jsbindings.cpp:4709
PrivAAMPStruct_JS
Private data structure for JS binding object.
Definition: jsbindings.h:35
AAMPPlayer_UnloadJS
void AAMPPlayer_UnloadJS(void *context)
Removes the AAMPMediaPlayer constructor from JS context.
Definition: jsmediaplayer.cpp:3906
aamp_LoadJS
void aamp_LoadJS(void *context, void *playerInstanceAAMP)
Load aamp JS bindings.
Definition: jsbindings.cpp:4651
PlayerInstanceAAMP
Player interface class for the JS pluggin.
Definition: main_aamp.h:692
AAMPPlayer_LoadJS
void AAMPPlayer_LoadJS(void *context)
Loads AAMPMediaPlayer JS constructor into JS context.
Definition: jsmediaplayer.cpp:3877