Ocean
JSMediaManager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_INTERACTION_JS_MEDIA_MANAGER_H
9 #define META_OCEAN_INTERACTION_JS_MEDIA_MANAGER_H
10 
13 
14 namespace Ocean
15 {
16 
17 namespace Interaction
18 {
19 
20 namespace JavaScript
21 {
22 
23 /**
24  * This class implements a wrapper for a JavaScript MediaManager object.
25  * @ingroup interactionjs
26  */
27 class OCEAN_INTERACTION_JS_EXPORT JSMediaManager : public JSBase
28 {
29  friend class JSLibrary;
30 
31  public:
32 
33  /**
34  * Returns the JavaScript name of this object.
35  * @return The object's JavaScript name
36  */
37  static inline const char* objectName();
38 
39  /**
40  * Returns the object template for this object.
41  * @return The object template
42  */
43  static inline v8::Local<v8::ObjectTemplate> objectTemplate();
44 
45  /**
46  * Releases the function and object template for this object.
47  */
48  static void release();
49 
50  protected:
51 
52  /**
53  * Creates the function object template for this object.
54  */
55  static void createObjectTemplate();
56 
57  /**
58  * Callback function for 'create()' function.
59  * @param info The function callback info
60  */
61  static void functionCreate(const v8::FunctionCallbackInfo<v8::Value>& info);
62 
63  /**
64  * Callback function for 'createAudio()' function.
65  * @param info The function callback info
66  */
67  static void functionCreateAudio(const v8::FunctionCallbackInfo<v8::Value>& info);
68 
69  /**
70  * Callback function for 'createImage()' function.
71  * @param info The function callback info
72  */
73  static void functionCreateImage(const v8::FunctionCallbackInfo<v8::Value>& info);
74 
75  /**
76  * Callback function for 'createLiveVideo()' function.
77  * @param info The function callback info
78  */
79  static void functionCreateLiveVideo(const v8::FunctionCallbackInfo<v8::Value>& info);
80 
81  /**
82  * Callback function for 'createMovie()' function.
83  * @param info The function callback info
84  */
85  static void functionCreateMovie(const v8::FunctionCallbackInfo<v8::Value>& info);
86 
87  /**
88  * Creates a new media object with specific type.
89  * @param type The type of the new media object to be created
90  * @param info The function callback info
91  */
92  static void createMediaObject(const Media::Medium::Type type, const v8::FunctionCallbackInfo<v8::Value>& info);
93 
94  protected:
95 
96  /// Object template for the Vector2 object.
97  static v8::Persistent<v8::ObjectTemplate> objectTemplate_;
98 };
99 
100 inline const char* JSMediaManager::objectName()
101 {
102  return "MediaManager";
103 }
104 
105 inline v8::Local<v8::ObjectTemplate> JSMediaManager::objectTemplate()
106 {
107  if (objectTemplate_.IsEmpty())
108  {
110  }
111 
112  ocean_assert(objectTemplate_.IsEmpty() == false);
113  return objectTemplate_.Get(v8::Isolate::GetCurrent());
114 }
115 
117 {
118  ocean_assert(!objectTemplate_.IsEmpty());
119  objectTemplate_.Reset();
120 }
121 
122 }
123 
124 }
125 
126 }
127 
128 #endif // META_OCEAN_INTERACTION_JS_MEDIA_MANAGER_H
This class implements the base class for all JavaScript wrappers.
Definition: JSBase.h:34
This class implements the java script interaction library object.
Definition: JSLibrary.h:32
This class implements a wrapper for a JavaScript MediaManager object.
Definition: JSMediaManager.h:28
static void functionCreate(const v8::FunctionCallbackInfo< v8::Value > &info)
Callback function for 'create()' function.
static void functionCreateImage(const v8::FunctionCallbackInfo< v8::Value > &info)
Callback function for 'createImage()' function.
static void functionCreateLiveVideo(const v8::FunctionCallbackInfo< v8::Value > &info)
Callback function for 'createLiveVideo()' function.
static void createMediaObject(const Media::Medium::Type type, const v8::FunctionCallbackInfo< v8::Value > &info)
Creates a new media object with specific type.
static v8::Local< v8::ObjectTemplate > objectTemplate()
Returns the object template for this object.
Definition: JSMediaManager.h:105
static v8::Persistent< v8::ObjectTemplate > objectTemplate_
Object template for the Vector2 object.
Definition: JSMediaManager.h:97
static void release()
Releases the function and object template for this object.
Definition: JSMediaManager.h:116
static void functionCreateMovie(const v8::FunctionCallbackInfo< v8::Value > &info)
Callback function for 'createMovie()' function.
static void functionCreateAudio(const v8::FunctionCallbackInfo< v8::Value > &info)
Callback function for 'createAudio()' function.
static void createObjectTemplate()
Creates the function object template for this object.
static const char * objectName()
Returns the JavaScript name of this object.
Definition: JSMediaManager.h:100
Type
Definition of different medium types.
Definition: Medium.h:57
void release(T *object)
This functions allows to release a DirectShow object if it does exist.
Definition: DSObject.h:266
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15