Ocean
FFMLibrary.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_MEDIA_FFM_FFM_LIBRARY_H
9 #define META_OCEAN_MEDIA_FFM_FFM_LIBRARY_H
10 
12 
13 #include "ocean/media/Library.h"
14 #include "ocean/media/Manager.h"
15 
16 namespace Ocean
17 {
18 
19 namespace Media
20 {
21 
22 namespace FFmpeg
23 {
24 
25 /**
26  * This class implements the FFmpeg library.
27  * @ingroup mediaffm
28  */
29 class FFMLibrary : public Library
30 {
31  friend class Media::Manager;
32  friend class FFMMovie;
33 
34  public:
35 
36  /**
37  * Creates a new medium by a given url.
38  * @see Library::newMedium().
39  */
40  MediumRef newMedium(const std::string& url, bool useExclusive = false) override;
41 
42  /**
43  * Creates a new medium by a given url and an expected type.
44  * @see Library::newMedium().
45  */
46  MediumRef newMedium(const std::string& url, const Medium::Type type, bool useExclusive = false) override;
47 
48  /**
49  * Creates a new recorder specified by the recorder type.
50  * @see Library::newRecorder().
51  */
52  RecorderRef newRecorder(const Recorder::Type type) override;
53 
54  /**
55  * Returns the supported medium types.
56  * @see Library::supportedTypes().
57  */
58  Medium::Type supportedTypes() const override;
59 
60  /**
61  * Registers this library at the global media manager.
62  * With each register call, the reference counter for a specific library will be incremented.
63  * Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.
64  * @return True, if the library has not been registered before
65  * @see Manager, unregisterLibrary()
66  */
67  static bool registerLibrary();
68 
69  /**
70  * Unregisters this library at the global media manager.
71  * With each unregister call, the reference counter for a specific library will be decremented and removed from the system if the counter reaches zero.
72  * Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.
73  * @return True, if the library was actually removed from the system (as the reference counter reached zero); False, if the library is still used by someone else
74  * @see registerLibrary().
75  */
76  static bool unregisterLibrary();
77 
78  protected:
79 
80  /**
81  * Creates a new FFMLibrary object.
82  */
84 
85  /**
86  * Destructs an FFMLibrary object.
87  */
88  ~FFMLibrary() override;
89 
90  /**
91  * Creates this library and returns it an object reference.
92  * @return The new library object
93  */
94  static LibraryRef create();
95 
96  /**
97  * Creates a new movie medium.
98  * @param url Url of the movie medium to create
99  * @param useExclusive Determines whether the caller would like to use this medium exclusively
100  * @return Reference of the new medium
101  */
102  static MediumRef newMovie(const std::string& url, bool useExclusive);
103 
104  /**
105  * Callback function for FFmpeg's logs.
106  * @param context The context of the log
107  * @param level The log's level
108  * @param message The log message
109  * @param arguments The log's arguments
110  */
111  static void avLogCallback(void* context, int level, const char* message, va_list arguments);
112 };
113 
114 }
115 
116 }
117 
118 }
119 
120 #endif // META_OCEAN_MEDIA_FFM_FFM_LIBRARY_H
This class implements the FFmpeg library.
Definition: FFMLibrary.h:30
static bool unregisterLibrary()
Unregisters this library at the global media manager.
static void avLogCallback(void *context, int level, const char *message, va_list arguments)
Callback function for FFmpeg's logs.
static LibraryRef create()
Creates this library and returns it an object reference.
RecorderRef newRecorder(const Recorder::Type type) override
Creates a new recorder specified by the recorder type.
static bool registerLibrary()
Registers this library at the global media manager.
FFMLibrary()
Creates a new FFMLibrary object.
static MediumRef newMovie(const std::string &url, bool useExclusive)
Creates a new movie medium.
Medium::Type supportedTypes() const override
Returns the supported medium types.
MediumRef newMedium(const std::string &url, bool useExclusive=false) override
Creates a new medium by a given url.
MediumRef newMedium(const std::string &url, const Medium::Type type, bool useExclusive=false) override
Creates a new medium by a given url and an expected type.
~FFMLibrary() override
Destructs an FFMLibrary object.
This class implements an FFmpeg movie object.
Definition: FFMMovie.h:40
This class is the base class for all media libraries.
Definition: media/Library.h:42
This class is the manager for all media objects.
Definition: media/Manager.h:34
Type
Definition of different medium types.
Definition: Medium.h:57
Type
Definition of different recorder types.
Definition: Recorder.h:46
This template class implements a object reference with an internal reference counter.
Definition: base/ObjectRef.h:58
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15